add txpower patches and add uci configuration file From: Vasilis T. (aka Acinonyx)
[openwrt.git] / package / hostap-driver / files / lib / wifi / hostap.sh
1 #!/bin/sh
2 append DRIVERS "prism2"
3
4 scan_prism2() {
5 local device="$1"
6
7 config_get mode "$device" mode
8 case "$mode" in
9 ad-hoc|managed|master)
10 ;;
11 *) echo "$device: Invalid mode, ignored."; continue;;
12 esac
13
14 }
15
16 disable_prism2() (
17 local device="$1"
18
19 set_wifi_down "$device"
20
21 include /lib/network
22 ifconfig "$device" down
23 unbridge "$device"
24 return 0
25 )
26
27 enable_prism2() {
28 local irqdevs
29
30 config_get prifw "$device" prifw
31 config_get stafw "$device" stafw
32 config_get mode "$device" mode
33 config_get rate "$device" rate
34 config_get channel "$device" channel
35 config_get txpower "$device" txpower
36 config_get ssid "$device" ssid
37 config_get maclist "$device" maclist
38 config_get macpolicy "$device" macpolicy
39 [ -x /usr/sbin/prism2_srec ] && {
40 irqdevs=$(cat /proc/interrupts | grep wifi${device##wlan} | cut -b 37- | tr -d ",")
41 for dev in "$irqdevs"; do
42 [ "$(config_get "$dev" type)" = "atheros" ] && wifi down "$dev"
43 done
44 [ -f "$prifw" ] && prism2_srec -g $device $prifw
45 [ -f "$stafw" ] && prism2_srec -r $device $stafw
46 for dev in "$irqdevs"; do
47 [ "$(config_get "$dev" type)" = "atheros" ] && wifi up "$dev"
48 done
49 }
50 [ -n "$mode" ] && iwconfig $device mode $mode
51 [ -n "$rate" ] && iwconfig $device rate $rate
52 [ -n "$channel" ] && iwconfig $device channel $channel
53 [ -n "$ssid" ] && iwconfig $device essid $ssid
54 [ -n "$txpower" ] && iwconfig $device txpower $txpower
55 [ -n "$maclist" ] && {
56 # flush MAC list
57 iwpriv $device maccmd 3
58 for mac in $maclist; do
59 iwpriv $device addmac $mac
60 done
61 }
62 case "$macpolicy" in
63 open)
64 iwpriv $device maccmd 0
65 ;;
66 allow)
67 iwpriv $device maccmd 1
68 ;;
69 deny)
70 iwpriv $device maccmd 2
71 ;;
72 *)
73 # default deny policy if mac list exists
74 [ -n "$maclist" ] && iwpriv $device maccmd 2
75 ;;
76 esac
77 # kick all stations if we have policy explicitly set
78 [ -n "$macpolicy" ] && iwpriv $device maccmd 4
79 local net_cfg bridge
80 net_cfg="$(find_net_config "$device")"
81 [ -z "$net_cfg" ] || {
82 bridge="$(bridge_interface "$net_cfg")"
83 config_set "$device" bridge "$bridge"
84 start_net "$device" "$net_cfg"
85 }
86 set_wifi_up "$vif" "$ifname"
87 }
88
89
90 detect_prism2() {
91 cd /proc/net/hostap
92 [ -d wlan0 ] || return
93 for dev in wlan*; do
94 config_get type "$dev" type
95 [ "$type" = prism2 ] && continue
96 cat <<EOF
97
98 config wifi-device $dev
99 option type prism2
100 # option rate 11M
101 option channel 5
102 option txpower 127
103 option mode managed
104 option ssid OpenWrt
105 # option macpolicy deny
106 # option maclist '12:34:56:78:90:12
107 # 09:87:65:43:21:09'
108
109 EOF
110 done
111 }
112
This page took 0.049565 seconds and 5 git commands to generate.