1 hostapd_set_bss_options
() {
4 local enc wpa_group_rekey
6 config_get enc
"$vif" encryption
7 config_get wpa_group_rekey
"$vif" wpa_group_rekey
8 config_get_bool ap_isolate
"$vif" isolate
0
10 if [ "$ap_isolate" -gt 0 ]; then
11 append
"$var" "ap_isolate=$ap_isolate" "$N"
15 # psk-mixed/tkip => WPA1+2 PSK, TKIP
16 # wpa-psk2/tkip+aes => WPA2 PSK, CCMP+TKIP
17 # wpa2/tkip+aes => WPA2 RADIUS, CCMP+TKIP
20 # TODO: move this parsing function somewhere generic, so that
21 # later it can be reused by drivers that don't use hostapd
23 # crypto defaults: WPA2 vs WPA1
39 # explicit override for crypto setting
41 *tkip
+aes|
*tkip
+ccmp
) crypto
="CCMP TKIP";;
42 *aes|
*ccmp
) crypto
="CCMP";;
43 *tkip
) crypto
="TKIP";;
46 # use crypto/auth settings for building the hostapd config
49 config_get psk
"$vif" key
50 if [ ${#psk} -eq 64 ]; then
51 append
"$var" "wpa_psk=$psk" "$N"
53 append
"$var" "wpa_passphrase=$psk" "$N"
57 # required fields? formats?
58 # hostapd is particular, maybe a default configuration for failures
59 config_get server
"$vif" server
60 append
"$var" "auth_server_addr=$server" "$N"
61 config_get port
"$vif" port
63 append
"$var" "auth_server_port=$port" "$N"
64 config_get secret
"$vif" key
65 append
"$var" "auth_server_shared_secret=$secret" "$N"
66 config_get nasid
"$vif" nasid
67 append
"$var" "nas_identifier=$nasid" "$N"
68 append
"$var" "eapol_key_index_workaround=1" "$N"
69 append
"$var" "radius_acct_interim_interval=300" "$N"
70 append
"$var" "ieee8021x=1" "$N"
71 append
"$var" "auth_algs=1" "$N"
72 append
"$var" "wpa_key_mgmt=WPA-EAP" "$N"
73 append
"$var" "wpa_group_rekey=300" "$N"
74 append
"$var" "wpa_gmk_rekey=640" "$N"
77 config_get key
"$vif" key
81 for idx
in 1 2 3 4; do
84 config_get ckey
"$vif" "key${idx}"
86 append
"$var" "wep_key${zidx}=$(prepare_key_wep "$ckey")" "$N"
88 append
"$var" "wep_default_key=$((key - 1))" "$N"
91 append
"$var" "wep_key0=$(prepare_key_wep "$key")" "$N"
92 append
"$var" "wep_default_key=0" "$N"
103 append
"$var" "wpa=$wpa" "$N"
104 [ -n "$crypto" ] && append
"$var" "wpa_pairwise=$crypto" "$N"
105 [ -n "$wpa_group_rekey" ] && append
"$var" "wpa_group_rekey=$wpa_group_rekey" "$N"
107 config_get ssid
"$vif" ssid
108 config_get bridge
"$vif" bridge
109 config_get ieee80211d
"$vif" ieee80211d
111 append
"$var" "ssid=$ssid" "$N"
112 [ -n "$bridge" ] && append
"$var" "bridge=$bridge" "$N"
113 [ -n "$ieee80211d" ] && append
"$var" "ieee80211d=$ieee80211d" "$N"
115 [ "$wpa" -ge "2" ] && config_get ieee80211w
"$vif" ieee80211w
116 case "$ieee80211w" in
118 append
"$var" "ieee80211w=$ieee80211w" "$N"
119 [ "$ieee80211w" -gt "0" ] && {
120 config_get ieee80211w_max_timeout
"$vif" ieee80211w_max_timeout
121 config_get ieee80211w_retry_timeout
"$vif" ieee80211w_retry_timeout
122 [ -n "$ieee80211w_max_timeout" ] && \
123 append
"$var" "assoc_sa_query_max_timeout=$ieee80211w_max_timeout" "$N"
124 [ -n "$ieee80211w_retry_timeout" ] && \
125 append
"$var" "assoc_sa_query_retry_timeout=$ieee80211w_retry_timeout" "$N"
131 hostapd_setup_vif
() {
136 hostapd_set_bss_options hostapd_cfg
"$vif"
137 config_get ifname
"$vif" ifname
138 config_get device
"$vif" device
139 config_get channel
"$device" channel
140 config_get hwmode
"$device" hwmode
142 *bg|
*gdt|
*gst|
*fh
) hwmode
=g
;;
143 *adt|
*ast
) hwmode
=a
;;
145 [ "$channel" = auto
] && channel
=
146 [ -n "$channel" -a -z "$hwmode" ] && wifi_fixup_hwmode
"$device"
147 cat > /var
/run
/hostapd-
$ifname.conf
<<EOF
148 ctrl_interface=/var/run/hostapd-$ifname
151 ${hwmode:+hw_mode=${hwmode#11}}
152 ${channel:+channel=$channel}
155 hostapd
-P /var
/run
/wifi-
$ifname.pid
-B /var
/run
/hostapd-
$ifname.conf