xref: /freebsd/tools/tools/net80211/scripts/config (revision 06c3fb27)
1#
2# Common configuration settings for vap test scripts.
3#
4#
5
6media_type()
7{
8	ifconfig $1 2>/dev/null | while read line; do
9		case "$line" in
10		*media:?Ethernet*)
11			echo 802.3
12			;;
13		*media:?IEEE?802.11*)
14			echo 802.11
15			;;
16		esac
17	done
18}
19
20#
21# Auto-detect WIRED and WIRELESS.
22# NB: takes first device of each type; to fix
23#     either specify them before . config.
24#
25for i in `ifconfig -l`; do
26	case `media_type $i`  in
27	802.3)
28		test -z "$WIRED" && WIRED=$i
29		;;
30	802.11)
31		test -z "$WIRELESS" && WIRELESS=$i
32		;;
33	esac
34done
35test -z "$WIRED" && { echo "No wired device detected!"; exit; }
36test -z "$WIRELESS" && { echo "No wireless device detected!"; exit; }
37
38# fixed channel
39#CHANNEL=${1:-36:a}
40#CHANNEL=${1:-36:ht/20}
41CHANNEL=${1:-36}
42#CHANNEL=${1:-6:g}
43#CHANNEL=${1:-6:b}
44
45# default WPA passphrase
46test -z "$WPA_PASSPHRASE" && WPA_PASSPHRASE='I am not a geek'
47
48# default ssid for ap vaps
49test -z "$SSID"		&& SSID=freebsd-ap
50
51# default meshid for mesh vaps
52test -z "$MESHID"	&& MESHID=freebsd-mesh
53
54# directory to create files like hostapd.conf
55test -z "$TMPDIR"	&& TMPDIR=.
56
57test -z "$HOSTAPD_CTRL_INTERFACE" && HOSTAPD_CTRL_INTERFACE=/var/run/hostapd
58
59# applications (may want ../ for wlan test apps)
60test -z "$HOSTAPD"	&& HOSTAPD=/usr/sbin/hostapd
61test -z "$WLANWATCH"	&& WLANWATCH=/usr/local/bin/wlanwatch
62test -z "$WLANWDS"	&& WLANWDS=/usr/local/bin/wlanwds
63
64start_hostapd()
65{
66	for m in wlan_xauth wlan_ccmp wlan_tkip wlan_wep; do
67		kldstat -q -m $m || kldload $m
68	done
69	$HOSTAPD $*
70}
71