Return to rc.wifi CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / elwix / config / etc / default |
1.1 misho 1: # Common loader functions for WIFI boot scripts
2: # (C)`09 AITNET ltd - Sofia/Bulgaria <misho@aitbg.com>
3: #
1.2.20.1! misho 4: # $Id: rc.wifi,v 1.2 2011/11/02 09:51:32 misho Exp $
1.1 misho 5:
6:
7: # setWEP() <iface> <default_key> <key1> [key2] [key3] [key4]
8: setWEP()
9: {
10: if [ $# -lt 3 ]; then
11: echo "setWEP() Not enough parameters ..."
12: return 1
13: fi
14:
1.2 misho 15: ARGS="authmode open wepmode on deftxkey $2 wepkey 1:$3"
1.1 misho 16: if [ $# -gt 3 ]; then
17: ARGS=$ARGS" wepkey 2:$4"
18: fi
19: if [ $# -gt 4 ]; then
20: ARGS=$ARGS" wepkey 3:$5"
21: fi
22: if [ $# -gt 5 ]; then
23: ARGS=$ARGS" wepkey 4:$6"
24: fi
25:
26: ifconfig $1 $ARGS
27: }
28:
29: # mkhostconf() <iface> <host_mode> <wpa_pass> [wep_key]
30: mkhostconf()
31: {
32: if [ $# -lt 3 ]; then
33: echo "mkhostconf() Not enough parameters ..."
34: return 1
35: fi
36:
37: case $2 in
38: wpa1|1)
39: WPA_MODE=1
40: WPA_PAIR=CCMP
41: ;;
42: wpa1_tkip)
43: WPA_MODE=1
44: WPA_PAIR=TKIP
45: ;;
46: wpa2|2)
47: WPA_MODE=2
48: WPA_PAIR=CCMP
49: ;;
50: wpa2_tkip)
51: WPA_MODE=2
52: WPA_PAIR=TKIP
53: ;;
54: wpa|3)
55: WPA_MODE=3
56: WPA_PAIR=CCMP
57: ;;
58: tsn)
59: if [ -z $4 ]; then
60: echo "mkhostconf() Not enough parameters ..."
61: return 1;
62: else
63: WEP_KEY0=$4
64: fi
65:
66: WPA_MODE=1
67: WPA_PAIR=TKIP
68: ;;
69: *)
70: echo "mkhostconf() Unknown WPA mode ..."
71: return 1
72: ;;
73: esac
74:
75: CONF=/var/tmp/hostapd_$1.conf
76: rm -f $CONF
77:
78: cat >$CONF <<_EOF
79: interface=$1
80: ctrl_interface=/var/run/hostapd_$1.sock
81: logger_syslog=-1
82: logger_syslog_level=0
83: logger_stdout=-1
84: logger_stdout_level=0
85: debug=4
86: wpa_psk_file=/etc/hostapd.wpa_psk
87: wpa=$WPA_MODE
88: wpa_pairwise=$WPA_PAIR
89: wpa_key_mgmt=WPA-PSK
90: wpa_passphrase=$3
91: _EOF
92:
93: if [ ${#WEP_KEY0} -ne 0 ]; then
94: cat >>$CONF <<_EOF
95: tsn=1
96: wep_key0=$WEP_KEY0
97: _EOF
98: fi
99: }