1#! /bin/sh
2#
3# Script for testing single-bss WPA1+WPA2.
4#
5# $FreeBSD: src/tools/tools/net80211/scripts/setup.wpa,v 1.1 2008/04/20 20:43:42 sam Exp $
6#
7PATH=.:$PATH
8. config
9
10BRIDGE=bridge0
11WLAN=wlan0
12CONF=$TMPDIR/bsd-$WLAN.conf
13SSID=$SSID-wpa
14
15makeconf()
16{
17	conf=$1
18	rm -f $conf
19	cat >$1 <<EOF
20interface=$WLAN
21ctrl_interface=$HOSTAPD_CTRL_INTERFACE
22logger_syslog=-1
23logger_syslog_level=0
24logger_stdout=-1
25logger_stdout_level=0
26debug=4
27wpa=3
28wpa_key_mgmt=WPA-PSK
29wpa_passphrase=$WPA_PASSPHRASE
30wpa_pairwise=CCMP
31EOF
32}
33
34trap "ifconfig $BRIDGE destroy; ifconfig $WLAN destroy; \
35	rm -f $CONF" 2
36
37ifconfig $WLAN create wlandev $WIRELESS wlanmode hostap
38#wlandebug -i $WLAN assoc+crypto
39wlandebug -i $WLAN state+assoc+11n
40ifconfig $WLAN ssid $SSID
41ifconfig $WLAN channel $CHANNEL
42ifconfig $WLAN mtu 1500		# NB: if_bridge requires matching mtu's
43
44ifconfig $BRIDGE create
45ifconfig $BRIDGE addm $WIRED addm $WLAN up
46ifconfig $WLAN up
47ifconfig $WIRED up
48
49ifconfig
50
51makeconf $CONF
52#athdebug -i $WIRELESS keycache
53start_hostapd -K $CONF
54