2 append DRIVERS
"mac80211"
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 }${ahdemo:+$ahdemo }${sta:+$sta }${wds:+$wds }${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
58 ifconfig
"$ifname" down
2>/dev
/null
59 config_get ifname
"$vif" ifname
60 config_get enc
"$vif" encryption
61 config_get eap_type
"$vif" eap_type
62 config_get mode
"$vif" mode
64 config_get ifname
"$vif" ifname
66 echo "enable_mac80211($device): Failed to set up $mode vif $ifname" >&2
69 config_set
"$vif" ifname
"$ifname"
72 # only need to change freq band and channel on the first vif
73 iwconfig
"$ifname" channel
"$channel" >/dev
/null
2>/dev
/null
74 if [ "$mode" = adhoc
]; then
75 iwlist
"$ifname" scan
>/dev
/null
2>/dev
/null
77 iwconfig
"$ifname" mode ad-hoc
>/dev
/null
2>/dev
/null
79 # mesh interface should be created only for the first interface
80 if [ "$mode" = mesh
]; then
81 config_get mesh_id
"$vif" mesh_id
82 if [ -n "$mesh_id" ]; then
83 iw dev
"$ifname" interface add msh
$mesh_idx type mp mesh_id
$mesh_id
87 iwconfig
"$ifname" channel
"$channel" >/dev
/null
2>/dev
/null
89 if [ "$mode" = sta
]; then
90 iwconfig
"$ifname" mode managed
>/dev
/null
2>/dev
/null
92 iwconfig
"$ifname" mode
$mode >/dev
/null
2>/dev
/null
98 for idx
in 1 2 3 4; do
99 config_get key
"$vif" "key${idx}"
100 iwconfig
"$ifname" enc
"[$idx]" "${key:-off}"
102 config_get key
"$vif" key
105 [1234]) iwconfig
"$ifname" enc
"[$key]";;
106 *) iwconfig
"$ifname" enc
"$key";;
110 config_get key
"$vif" key
116 config_get addr
"$vif" bssid
118 iwconfig
"$ifname" ap
"$addr"
122 config_get ssid
"$vif" ssid
124 config_get vif_txpower
"$vif" txpower
125 # use vif_txpower (from wifi-iface) to override txpower (from
126 # wifi-device) if the latter doesn't exist
127 txpower
="${txpower:-$vif_txpower}"
128 [ -z "$txpower" ] || iwconfig
"$ifname" txpower
"${txpower%%.*}"
130 config_get frag
"$vif" frag
131 if [ -n "$frag" ]; then
132 iwconfig
"$ifname" frag
"${frag%%.*}"
135 config_get rts
"$vif" rts
136 if [ -n "$rts" ]; then
137 iwconfig
"$ifname" rts
"${rts%%.*}"
140 ifconfig
"$ifname" up
141 iwconfig
"$ifname" channel
"$channel" >/dev
/null
2>/dev
/null
144 net_cfg
="$(find_net_config "$vif")"
145 [ -z "$net_cfg" ] ||
{
146 bridge
="$(bridge_interface "$net_cfg")"
147 config_set
"$vif" bridge
"$bridge"
148 start_net
"$ifname" "$net_cfg"
150 iwconfig
"$ifname" essid
"$ssid"
151 set_wifi_up
"$vif" "$ifname"
154 if eval "type hostapd_setup_vif" 2>/dev
/null
>/dev
/null
; then
155 hostapd_setup_vif
"$vif" nl80211 ||
{
156 echo "enable_mac80211($device): Failed to set up wpa for interface $ifname" >&2
157 # make sure this wifi interface won't accidentally stay open without encryption
158 ifconfig
"$ifname" down
164 if eval "type wpa_supplicant_setup_vif" 2>/dev
/null
>/dev
/null
; then
165 wpa_supplicant_setup_vif
"$vif" wext ||
{
166 echo "enable_mac80211($device): Failed to set up wpa_supplicant for interface $ifname" >&2
167 # make sure this wifi interface won't accidentally stay open without encryption
168 ifconfig
"$ifname" down
174 # special case where physical interface should be down for mesh to work
175 ifconfig
"$ifname" down
176 ifconfig
"msh$mesh_idx" up
180 mesh_idx
=$
(expr $mesh_idx + 1)
187 for dev
in $
(ls -d wlan
* 2>&-); do
188 config_get
type "$dev" type
189 [ "$type" = mac80211
] && return
191 config wifi-device $dev
195 # REMOVE THIS LINE TO ENABLE WIFI:
203 option encryption none