cpmac: patch to reimplement rx ring with EOQ markers to avoid reset storms (closes...
[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 [ -f "$prifw" ] || [ -f "$stafw" ] && [ -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 ifconfig "$device" up
55 [ -n "$txpower" ] && iwconfig $device txpower $txpower
56 [ -n "$maclist" ] && {
57 # flush MAC list
58 iwpriv $device maccmd 3
59 for mac in $maclist; do
60 iwpriv $device addmac $mac
61 done
62 }
63 case "$macpolicy" in
64 open)
65 iwpriv $device maccmd 0
66 ;;
67 allow)
68 iwpriv $device maccmd 1
69 ;;
70 deny)
71 iwpriv $device maccmd 2
72 ;;
73 *)
74 # default deny policy if mac list exists
75 [ -n "$maclist" ] && iwpriv $device maccmd 2
76 ;;
77 esac
78 # kick all stations if we have policy explicitly set
79 [ -n "$macpolicy" ] && iwpriv $device maccmd 4
80 local net_cfg bridge
81 net_cfg="$(find_net_config "$device")"
82 [ -z "$net_cfg" ] || {
83 bridge="$(bridge_interface "$net_cfg")"
84 config_set "$device" bridge "$bridge"
85 start_net "$device" "$net_cfg"
86 }
87 set_wifi_up "$device" "$device"
88 }
89
90
91 detect_prism2() {
92 cd /proc/net/hostap
93 [ -d wlan0 ] || return
94 for dev in wlan*; do
95 config_get type "$dev" type
96 [ "$type" = prism2 ] && continue
97 cat <<EOF
98
99 config wifi-device $dev
100 option type prism2
101 # option rate 11M
102 option channel 5
103 option txpower 127
104 option mode managed
105 option ssid OpenWrt
106 # option macpolicy deny
107 # option maclist '12:34:56:78:90:12
108 # 09:87:65:43:21:09'
109
110 # REMOVE THIS LINE TO ENABLE WIFI:
111 option disabled 1
112
113 EOF
114 done
115 }
This page took 0.056372 seconds and 5 git commands to generate.