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