summaryrefslogtreecommitdiff
path: root/package/hostap-driver/files/lib
diff options
context:
space:
mode:
authorthepeople <thepeople@3c298f89-4303-0410-b956-a3cf2f4a3e73>2007-11-28 03:44:18 +0000
committerthepeople <thepeople@3c298f89-4303-0410-b956-a3cf2f4a3e73>2007-11-28 03:44:18 +0000
commitd20afc8d2254c64f5638757c535ee8cf8f1f5da7 (patch)
tree0b9241281e78fb9a015c538d36bedfdc9a0723ec /package/hostap-driver/files/lib
parent572de1e5c43668941bcb22f62a56725b8dfbd35b (diff)
add txpower patches and add uci configuration file From: Vasilis T. (aka Acinonyx)
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@9610 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/hostap-driver/files/lib')
-rwxr-xr-xpackage/hostap-driver/files/lib/wifi/hostap.sh112
1 files changed, 112 insertions, 0 deletions
diff --git a/package/hostap-driver/files/lib/wifi/hostap.sh b/package/hostap-driver/files/lib/wifi/hostap.sh
new file mode 100755
index 0000000000..964a504180
--- /dev/null
+++ b/package/hostap-driver/files/lib/wifi/hostap.sh
@@ -0,0 +1,112 @@
+#!/bin/sh
+append DRIVERS "prism2"
+
+scan_prism2() {
+ local device="$1"
+
+ config_get mode "$device" mode
+ case "$mode" in
+ ad-hoc|managed|master)
+ ;;
+ *) echo "$device: Invalid mode, ignored."; continue;;
+ esac
+
+}
+
+disable_prism2() (
+ local device="$1"
+
+ set_wifi_down "$device"
+
+ include /lib/network
+ ifconfig "$device" down
+ unbridge "$device"
+ return 0
+)
+
+enable_prism2() {
+ local irqdevs
+
+ config_get prifw "$device" prifw
+ config_get stafw "$device" stafw
+ config_get mode "$device" mode
+ config_get rate "$device" rate
+ config_get channel "$device" channel
+ config_get txpower "$device" txpower
+ config_get ssid "$device" ssid
+ config_get maclist "$device" maclist
+ config_get macpolicy "$device" macpolicy
+ [ -x /usr/sbin/prism2_srec ] && {
+ irqdevs=$(cat /proc/interrupts | grep wifi${device##wlan} | cut -b 37- | tr -d ",")
+ for dev in "$irqdevs"; do
+ [ "$(config_get "$dev" type)" = "atheros" ] && wifi down "$dev"
+ done
+ [ -f "$prifw" ] && prism2_srec -g $device $prifw
+ [ -f "$stafw" ] && prism2_srec -r $device $stafw
+ for dev in "$irqdevs"; do
+ [ "$(config_get "$dev" type)" = "atheros" ] && wifi up "$dev"
+ done
+ }
+ [ -n "$mode" ] && iwconfig $device mode $mode
+ [ -n "$rate" ] && iwconfig $device rate $rate
+ [ -n "$channel" ] && iwconfig $device channel $channel
+ [ -n "$ssid" ] && iwconfig $device essid $ssid
+ [ -n "$txpower" ] && iwconfig $device txpower $txpower
+ [ -n "$maclist" ] && {
+ # flush MAC list
+ iwpriv $device maccmd 3
+ for mac in $maclist; do
+ iwpriv $device addmac $mac
+ done
+ }
+ case "$macpolicy" in
+ open)
+ iwpriv $device maccmd 0
+ ;;
+ allow)
+ iwpriv $device maccmd 1
+ ;;
+ deny)
+ iwpriv $device maccmd 2
+ ;;
+ *)
+ # default deny policy if mac list exists
+ [ -n "$maclist" ] && iwpriv $device maccmd 2
+ ;;
+ esac
+ # kick all stations if we have policy explicitly set
+ [ -n "$macpolicy" ] && iwpriv $device maccmd 4
+ local net_cfg bridge
+ net_cfg="$(find_net_config "$device")"
+ [ -z "$net_cfg" ] || {
+ bridge="$(bridge_interface "$net_cfg")"
+ config_set "$device" bridge "$bridge"
+ start_net "$device" "$net_cfg"
+ }
+ set_wifi_up "$vif" "$ifname"
+}
+
+
+detect_prism2() {
+ cd /proc/net/hostap
+ [ -d wlan0 ] || return
+ for dev in wlan*; do
+ config_get type "$dev" type
+ [ "$type" = prism2 ] && continue
+ cat <<EOF
+
+config wifi-device $dev
+ option type prism2
+# option rate 11M
+ option channel 5
+ option txpower 127
+ option mode managed
+ option ssid OpenWrt
+# option macpolicy deny
+# option maclist '12:34:56:78:90:12
+# 09:87:65:43:21:09'
+
+EOF
+ done
+}
+