1178361Ssam#! /bin/sh
2178361Ssam#
3178361Ssam# Script for testing WPA1 w/ AES.
4178361Ssam#
5178361Ssam# $FreeBSD$
6178361Ssam#
7178361SsamPATH=.:$PATH
8178361Ssam. config
9178361Ssam
10178361SsamBRIDGE=bridge0
11178361SsamWLAN=wlan0
12178361SsamSSID=$SSID-wpa
13178361SsamCONF=$TMPDIR/bsd-$WLAN.conf
14178361Ssam
15178361Ssammakeconf()
16178361Ssam{
17178361Ssam	conf=$1
18178361Ssam	rm -f $conf
19178361Ssam	cat >$1 <<EOF
20178361Ssaminterface=$WLAN
21178361Ssamctrl_interface=$HOSTAPD_CTRL_INTERFACE
22178361Ssamlogger_syslog=-1
23178361Ssamlogger_syslog_level=0
24178361Ssamlogger_stdout=-1
25178361Ssamlogger_stdout_level=0
26178361Ssamdebug=4
27178361Ssamwpa=1
28178361Ssamwpa_key_mgmt=WPA-PSK
29178361Ssamwpa_passphrase=$WPA_PASSPHRASE
30178361Ssamwpa_pairwise=CCMP
31178361SsamEOF
32178361Ssam}
33178361Ssam
34178361Ssamtrap "ifconfig $BRIDGE destroy; ifconfig $WLAN destroy; \
35178361Ssam	rm -f $CONF" 2
36178361Ssam
37178361Ssamifconfig $WLAN create wlandev $WIRELESS wlanmode hostap
38178361Ssam#wlandebug -i $WLAN assoc+crypto
39178361Ssamwlandebug -i $WLAN assoc
40178361Ssamifconfig $WLAN ssid $SSID
41178361Ssamifconfig $WLAN channel $CHANNEL
42178361Ssamifconfig $WLAN mtu 1500		# NB: if_bridge requires matching mtu's
43178361Ssam
44178361Ssamifconfig $BRIDGE create
45178361Ssamifconfig $BRIDGE addm $WIRED addm $WLAN up
46178361Ssamifconfig $WLAN up
47178361Ssamifconfig $WIRED up
48178361Ssam
49178361Ssamifconfig
50178361Ssam
51178361Ssammakeconf $CONF
52178361Ssam#mwldebug -i $WIRELESS keycache
53178361Ssamstart_hostapd -K $CONF
54