[tools] fix segfault when using the maxlen argument (#4359)
[openwrt.git] / package / wpa_supplicant / files / wpa_supplicant.sh
1 wpa_supplicant_setup_vif() {
2 local vif="$1"
3 local driver="$2"
4
5 # wpa_supplicant should use wext for mac80211 cards
6 [ "$driver" = "mac80211" ] && driver='wext'
7
8 case "$enc" in
9 PSK|psk|psk2|PSK2)
10 key_mgmt='WPA-PSK'
11 config_get_bool usepassphrase "$vif" passphrase 1
12 case "$enc" in
13 psk|PSK)
14 proto='WPA'
15 if [ "$usepassphrase" = "1" ]; then
16 passphrase="psk=\"${key}\""
17 else
18 passphrase="psk=${key}"
19 fi
20 ;;
21 psk2|PSK2)
22 proto='RSN'
23 if [ "$usepassphrase" = "1" ]; then
24 passphrase="psk=\"${key}\""
25 else
26 passphrase="psk=${key}"
27 fi
28 ;;
29 esac
30 ;;
31 WPA|wpa|WPA2|wpa2|8021x|8021X)
32 proto='WPA2'
33 key_mgmt='WPA-EAP'
34 config_get ca_cert "$vif" ca_cert
35 ca_cert=${ca_cert:+"ca_cert=\"$ca_cert\""}
36 case "$eap_type" in
37 tls|TLS)
38 pairwise='pairwise=CCMP'
39 group='group=CCMP'
40 config_get priv_key "$vif" priv_key
41 config_get priv_key_pwd "$vif" priv_key_pwd
42 priv_key="private_key=\"$priv_key\""
43 priv_key_pwd="private_key_passwd=\"$priv_key_pwd\""
44 ;;
45 peap|PEAP|ttls|TTLS)
46 config_get auth "$vif" auth
47 config_get identity "$vif" identity
48 config_get password "$vif" password
49 phase2="phase2=\"auth=${auth:-MSCHAPV2}\""
50 identity="identity=\"$identity\""
51 password="password=\"$password\""
52 ;;
53 esac
54 eap_type="eap=$(echo $eap_type | tr 'a-z' 'A-Z')"
55 ;;
56 esac
57 config_get ifname "$vif" ifname
58 config_get bridge "$vif" bridge
59 config_get ssid "$vif" ssid
60 config_get bssid "$vif" bssid
61 bssid=${bssid:+"bssid=$bssid"}
62 cat > /var/run/wpa_supplicant-$ifname.conf <<EOF
63 ctrl_interface=/var/run/wpa_supplicant-$ifname
64 network={
65 scan_ssid=1
66 ssid="$ssid"
67 $bssid
68 key_mgmt=$key_mgmt
69 proto=$proto
70 $passphrase
71 $pairwise
72 $group
73 $eap_type
74 $ca_cert
75 $priv_key
76 $priv_key_pwd
77 $phase2
78 $identity
79 $password
80 }
81 EOF
82 [ -z "$proto" ] || wpa_supplicant ${bridge:+ -b $bridge} -B -P "/var/run/wifi-${ifname}.pid" -D ${driver:-wext} -i "$ifname" -c /var/run/wpa_supplicant-$ifname.conf
83 }
This page took 0.068145 seconds and 5 git commands to generate.