fixed linux-uvc, didn't read nicos comment
[openwrt.git] / package / hostapd / files / hostapd.sh
1 hostapd_setup_vif() {
2 local vif="$1"
3 local driver="$2"
4 local hostapd_cfg=
5
6 # Examples:
7 # psk-mixed/tkip => WPA1+2 PSK, TKIP
8 # wpa-psk2/tkip+aes => WPA2 PSK, CCMP+TKIP
9 # wpa2/tkip+aes => WPA2 RADIUS, CCMP+TKIP
10 # ...
11
12 # TODO: move this parsing function somewhere generic, so that
13 # later it can be reused by drivers that don't use hostapd
14
15 # crypto defaults: WPA2 vs WPA1
16 case "$enc" in
17 wpa2*|WPA2*|*PSK2*|*psk2*)
18 wpa=2
19 crypto="CCMP"
20 ;;
21 *mixed*)
22 wpa=3
23 crypto="CCMP TKIP"
24 ;;
25 *)
26 wpa=1
27 crypto="TKIP"
28 ;;
29 esac
30
31 # explicit override for crypto setting
32 case "$enc" in
33 *tkip+aes|*TKIP+AES|*tkip+ccmp|*TKIP+CCMP) crypto="CCMP TKIP";;
34 *tkip|*TKIP) crypto="TKIP";;
35 *aes|*AES|*ccmp|*CCMP) crypto="CCMP";;
36 esac
37
38 # use crypto/auth settings for building the hostapd config
39 case "$enc" in
40 *psk*|*PSK*)
41 config_get psk "$vif" key
42 append hostapd_cfg "wpa_passphrase=$psk" "$N"
43 ;;
44 *wpa*|*WPA*)
45 # FIXME: add wpa+radius here
46 ;;
47 *)
48 return 0;
49 ;;
50 esac
51 config_get ifname "$vif" ifname
52 config_get bridge "$vif" bridge
53 config_get ssid "$vif" ssid
54 cat > /var/run/hostapd-$ifname.conf <<EOF
55 driver=$driver
56 interface=$ifname
57 ${bridge:+bridge=$bridge}
58 ssid=$ssid
59 debug=0
60 wpa=$wpa
61 wpa_pairwise=$crypto
62 $hostapd_cfg
63 EOF
64 hostapd -B /var/run/hostapd-$ifname.conf
65 }
66
This page took 0.041196 seconds and 5 git commands to generate.