1 wpa_supplicant_setup_vif
() {
10 [ -n "$4" ] && freq
="frequency=$4"
12 # make sure we have the encryption type and the psk
14 config_get enc
"$vif" encryption
17 config_get key
"$vif" key
21 config_get bridge
"$vif" bridge
23 net_cfg
="$(find_net_config "$vif")"
24 [ -z "$net_cfg" ] || bridge
="$(bridge_interface "$net_cfg")"
25 config_set
"$vif" bridge
"$bridge"
28 local mode ifname wds modestr
=""
29 config_get mode
"$vif" mode
30 config_get ifname
"$vif" ifname
31 config_get_bool wds
"$vif" wds
0
32 [ -z "$bridge" ] ||
[ "$mode" = ap
] ||
[ "$mode" = sta
-a $wds -eq 1 ] ||
{
33 echo "wpa_supplicant_setup_vif($ifname): Refusing to bridge $mode mode interface"
36 [ "$mode" = "adhoc" ] && {
46 config_get key
"$vif" key
50 for idx
in 1 2 3 4; do
53 config_get ckey
"$vif" "key${idx}"
55 append
"wep_key${zidx}" "wep_key${zidx}=$(prepare_key_wep "$ckey")"
57 wep_tx_keyidx
="wep_tx_keyidx=$((key - 1))"
60 wep_key0
="wep_key0=$(prepare_key_wep "$key")"
61 wep_tx_keyidx
="wep_tx_keyidx=0"
67 # if you want to use PSK with a non-nl80211 driver you
68 # have to use WPA-NONE and wext driver for wpa_s
69 [ "$mode" = "adhoc" -a "$driver" != "nl80211" ] && {
73 if [ ${#key} -eq 64 ]; then
74 passphrase
="psk=${key}"
76 passphrase
="psk=\"${key}\""
81 config_get ieee80211w
"$vif" ieee80211w
91 config_get ieee80211w
"$vif" ieee80211w
92 config_get ca_cert
"$vif" ca_cert
93 config_get eap_type
"$vif" eap_type
94 ca_cert
=${ca_cert:+"ca_cert=\"$ca_cert\""}
97 pairwise
='pairwise=CCMP'
99 config_get identity
"$vif" identity
100 config_get client_cert
"$vif" client_cert
101 config_get priv_key
"$vif" priv_key
102 config_get priv_key_pwd
"$vif" priv_key_pwd
103 identity
="identity=\"$identity\""
104 client_cert
="client_cert=\"$client_cert\""
105 priv_key
="private_key=\"$priv_key\""
106 priv_key_pwd
="private_key_passwd=\"$priv_key_pwd\""
109 config_get auth
"$vif" auth
110 config_get identity
"$vif" identity
111 config_get password
"$vif" password
112 phase2
="phase2=\"auth=${auth:-MSCHAPV2}\""
113 identity
="identity=\"$identity\""
114 password
="password=\"$password\""
117 eap_type
="eap=$(echo $eap_type | tr 'a-z' 'A-Z')"
121 case "$ieee80211w" in
123 ieee80211w
="ieee80211w=$ieee80211w"
127 local fixed_freq bssid1 beacon_interval brates mrate
128 config_get ifname
"$vif" ifname
129 config_get bridge
"$vif" bridge
130 bssid1
=${bssid:+"bssid=$bssid"}
131 beacon_interval
=${beacon_int:+"beacon_interval=$beacon_int"}
133 local br brval brsub brstr
134 [ -n "$basic_rate_list" ] && {
135 for br
in $basic_rate_list; do
136 brval
="$(($br / 1000))"
137 brsub
="$((($br / 100) % 10))"
138 [ "$brsub" -gt 0 ] && brval
="$brval.$brsub"
139 [ -n "$brstr" ] && brstr
="$brstr,"
142 brates
=${basic_rate_list:+"rates=$brstr"}
146 [ -n "$mcast_rate" ] && {
147 mcval
="$(($mcast_rate / 1000))"
148 mcsub
="$(( ($mcast_rate / 100) % 10 ))"
149 [ "$mcsub" -gt 0 ] && mcval
="$mcval.$mcsub"
150 mrate
=${mcast_rate:+"mcast_rate=$mcval"}
154 [ -n "$ht" ] && ht_str
="htmode=$ht"
156 rm -rf /var
/run
/wpa_supplicant-
$ifname
157 cat > /var
/run
/wpa_supplicant-
$ifname.conf
<<EOF
158 ctrl_interface=/var/run/wpa_supplicant-$ifname
168 ${fixed:+"fixed_freq=1"}
192 [ -z "$proto" -a "$key_mgmt" != "NONE" ] || \
193 wpa_supplicant
${bridge:+ -b $bridge} -B -P "/var/run/wifi-${ifname}.pid" -D ${driver:-wext} -i "$ifname" -c /var
/run
/wpa_supplicant-
$ifname.conf
$options