[ar71xx] generate firmware image for the TL-WR941ND device
[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\""
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_type=$(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 cat > /var/run/wpa_supplicant-$ifname.conf <<EOF
61 ctrl_interface=/var/run/wpa_supplicant-$ifname
62 network={
63 scan_ssid=1
64 ssid="$ssid"
65 key_mgmt=$key_mgmt
66 proto=$proto
67 $passphrase
68 $pairwise
69 $group
70 $eap_type
71 $ca_cert
72 $priv_key
73 $priv_key_pwd
74 $phase2
75 $identity
76 $password
77 }
78 EOF
79 [ -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
80 }
This page took 0.045886 seconds and 5 git commands to generate.