1#! /bin/sh
2#
3# Script for test vap create+destroy when using WPA.
4# Also used to verify resources are reclaimed properly
5# on vap destroy.
6#
7#
8PATH=.:$PATH
9. config
10
11BRIDGE=bridge0
12SSID=$SSID-wpa
13WLAN=wlan0
14CONF=$TMPDIR/bsd-$WLAN.conf
15
16makeconf()
17{
18	conf=$1
19	rm -f $conf
20	cat >$1 <<EOF
21interface=$WLAN
22ctrl_interface=$HOSTAPD_CTRL_INTERFACE
23logger_syslog=-1
24logger_syslog_level=0
25logger_stdout=-1
26logger_stdout_level=0
27debug=0
28wpa=1
29wpa_key_mgmt=WPA-PSK
30wpa_passphrase=$WPA_PASSPHRASE
31wpa_pairwise=CCMP
32EOF
33}
34
35n=0
36while true; do
37	echo "---- $n"; n=`expr $n + 1`
38	ifconfig $WLAN create wlandev $WIRELESS wlanmode hostap
39	wlandebug -i $WLAN assoc
40	ifconfig $WLAN ssid $SSID channel $CHANNEL mtu 1500
41
42	ifconfig $BRIDGE create
43	ifconfig $BRIDGE addm $WIRED addm $WLAN up
44	ifconfig $WLAN up
45#	ifconfig $WIRED up
46
47	makeconf $CONF
48	start_hostapd $CONF&
49	pid=$!
50	ifconfig
51
52	sleep 2
53	kill $pid
54	ifconfig $WLAN destroy;
55	ifconfig $BRIDGE destroy;
56	rm -f $CONF
57	vmstat -m | grep 80211
58	netstat -m
59	sleep 1
60done
61