2 append DRIVERS
"mac80211"
6 local adhoc sta ap monitor mesh
8 config_get vifs
"$device" vifs
11 config_get ifname
"$vif" ifname
12 config_set
"$vif" ifname
"${ifname:-$device}"
14 config_get mode
"$vif" mode
16 adhoc|sta|ap|monitor|mesh
)
19 *) echo "$device($vif): Invalid mode, ignored."; continue;;
23 config_set
"$device" vifs
"${ap:+$ap }${adhoc:+$adhoc }${sta:+$sta }${monitor:+$monitor }${mesh:+$mesh}"
30 set_wifi_down
"$device"
31 # kill all running hostapd and wpa_supplicant processes that
32 # are running on atheros/mac80211 vifs
33 for pid
in `pidof hostapd wpa_supplicant`; do
34 grep wlan
/proc
/$pid/cmdline
>/dev
/null
&& \
41 grep "$device" "$dev/%parent" >/dev
/null
2>/dev
/null
&& {
51 config_get channel
"$device" channel
52 config_get vifs
"$device" vifs
53 config_get txpower
"$device" txpower
57 wifi_fixup_hwmode
"$device" "g"
59 ifconfig
"$ifname" down
2>/dev
/null
60 config_get ifname
"$vif" ifname
61 config_get enc
"$vif" encryption
62 config_get eap_type
"$vif" eap_type
63 config_get mode
"$vif" mode
65 config_get ifname
"$vif" ifname
67 echo "enable_mac80211($device): Failed to set up $mode vif $ifname" >&2
70 config_set
"$vif" ifname
"$ifname"
73 # only need to change freq band and channel on the first vif
74 iwconfig
"$ifname" channel
"$channel" >/dev
/null
2>/dev
/null
75 if [ "$mode" = adhoc
]; then
76 iwlist
"$ifname" scan
>/dev
/null
2>/dev
/null
78 iwconfig
"$ifname" mode ad-hoc
>/dev
/null
2>/dev
/null
80 # mesh interface should be created only for the first interface
81 if [ "$mode" = mesh
]; then
82 config_get mesh_id
"$vif" mesh_id
83 if [ -n "$mesh_id" ]; then
84 iw dev
"$ifname" interface add msh
$mesh_idx type mp mesh_id
$mesh_id
88 iwconfig
"$ifname" channel
"$channel" >/dev
/null
2>/dev
/null
90 if [ "$mode" = sta
]; then
91 iwconfig
"$ifname" mode managed
>/dev
/null
2>/dev
/null
93 iwconfig
"$ifname" mode
$mode >/dev
/null
2>/dev
/null
99 for idx
in 1 2 3 4; do
100 config_get key
"$vif" "key${idx}"
101 iwconfig
"$ifname" enc
"[$idx]" "${key:-off}"
103 config_get key
"$vif" key
106 [1234]) iwconfig
"$ifname" enc
"[$key]";;
107 *) iwconfig
"$ifname" enc
"$key";;
111 config_get key
"$vif" key
117 config_get addr
"$vif" bssid
119 iwconfig
"$ifname" ap
"$addr"
123 config_get ssid
"$vif" ssid
125 config_get vif_txpower
"$vif" txpower
126 # use vif_txpower (from wifi-iface) to override txpower (from
127 # wifi-device) if the latter doesn't exist
128 txpower
="${txpower:-$vif_txpower}"
129 [ -z "$txpower" ] || iwconfig
"$ifname" txpower
"${txpower%%.*}"
131 config_get frag
"$vif" frag
132 if [ -n "$frag" ]; then
133 iwconfig
"$ifname" frag
"${frag%%.*}"
136 config_get rts
"$vif" rts
137 if [ -n "$rts" ]; then
138 iwconfig
"$ifname" rts
"${rts%%.*}"
141 ifconfig
"$ifname" up
142 iwconfig
"$ifname" channel
"$channel" >/dev
/null
2>/dev
/null
145 net_cfg
="$(find_net_config "$vif")"
146 [ -z "$net_cfg" ] ||
{
147 bridge
="$(bridge_interface "$net_cfg")"
148 config_set
"$vif" bridge
"$bridge"
149 start_net
"$ifname" "$net_cfg"
151 iwconfig
"$ifname" essid
"$ssid"
152 set_wifi_up
"$vif" "$ifname"
155 if eval "type hostapd_setup_vif" 2>/dev
/null
>/dev
/null
; then
156 hostapd_setup_vif
"$vif" nl80211 ||
{
157 echo "enable_mac80211($device): Failed to set up wpa for interface $ifname" >&2
158 # make sure this wifi interface won't accidentally stay open without encryption
159 ifconfig
"$ifname" down
165 if eval "type wpa_supplicant_setup_vif" 2>/dev
/null
>/dev
/null
; then
166 wpa_supplicant_setup_vif
"$vif" wext ||
{
167 echo "enable_mac80211($device): Failed to set up wpa_supplicant for interface $ifname" >&2
168 # make sure this wifi interface won't accidentally stay open without encryption
169 ifconfig
"$ifname" down
175 # special case where physical interface should be down for mesh to work
176 ifconfig
"$ifname" down
177 ifconfig
"msh$mesh_idx" up
178 iwlist msh
$mesh_idx scan
2>/dev
/null
>/dev
/null
182 mesh_idx
=$
(expr $mesh_idx + 1)
189 for dev
in $
(ls -d wlan
* 2>&-); do
190 config_get
type "$dev" type
191 [ "$type" = mac80211
] && return
193 config wifi-device $dev
197 # REMOVE THIS LINE TO ENABLE WIFI:
205 option encryption none