2013-03-27 13:40:10 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
DIR="$( cd "$( dirname "$0" )" && pwd )"
|
|
|
|
WPAS=$DIR/../../wpa_supplicant/wpa_supplicant
|
2013-08-26 15:47:15 +02:00
|
|
|
WPACLI=$DIR/../../wpa_supplicant/wpa_cli
|
2013-03-27 13:40:10 +01:00
|
|
|
HAPD=$DIR/../../hostapd/hostapd
|
|
|
|
WLANTEST=$DIR/../../wlantest/wlantest
|
2013-09-29 18:14:16 +02:00
|
|
|
HLR_AUC_GW=$DIR/../../hostapd/hlr_auc_gw
|
2013-03-27 13:40:10 +01:00
|
|
|
|
2013-10-30 14:55:58 +01:00
|
|
|
if [ -z "$LOGDIR" ] ; then
|
2013-10-30 22:08:10 +01:00
|
|
|
LOGDIR="$DIR/logs/$(date +%s)"
|
|
|
|
mkdir -p $LOGDIR
|
2013-10-30 14:55:58 +01:00
|
|
|
fi
|
|
|
|
|
2013-09-29 15:41:17 +02:00
|
|
|
if groups | tr ' ' "\n" | grep -q ^admin$; then
|
|
|
|
GROUP=admin
|
|
|
|
else
|
|
|
|
GROUP=adm
|
|
|
|
fi
|
|
|
|
|
2013-09-29 15:37:25 +02:00
|
|
|
if [ "$1" = "concurrent" ]; then
|
|
|
|
CONCURRENT=y
|
2013-10-30 18:43:59 +01:00
|
|
|
CONCURRENT_ARGS="-N -Dnl80211 -ista%d -c $DIR/sta-dummy.conf"
|
2013-09-29 15:37:25 +02:00
|
|
|
shift
|
|
|
|
else
|
|
|
|
unset CONCURRENT
|
2013-10-30 18:43:59 +01:00
|
|
|
CONCURRENT_ARGS=
|
2013-09-29 15:37:25 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "valgrind" ]; then
|
2013-08-24 19:33:21 +02:00
|
|
|
VALGRIND=y
|
2013-10-30 22:08:10 +01:00
|
|
|
VALGRIND_WPAS="valgrind --log-file=$LOGDIR/valgrind-wlan%d"
|
|
|
|
VALGRIND_HAPD="valgrind --log-file=$LOGDIR/valgrind-hostapd"
|
2013-10-30 18:55:00 +01:00
|
|
|
chmod -f a+rx $WPAS
|
|
|
|
chmod -f a+rx $HAPD
|
2013-09-29 15:37:25 +02:00
|
|
|
shift
|
2013-08-24 19:33:21 +02:00
|
|
|
else
|
|
|
|
unset VALGRIND
|
2013-10-30 18:43:59 +01:00
|
|
|
VALGRIND_WPAS=
|
|
|
|
VALGRIND_HAPD=
|
2013-08-24 19:33:21 +02:00
|
|
|
fi
|
|
|
|
|
2013-09-29 15:37:25 +02:00
|
|
|
if [ "$1" = "trace" ]; then
|
2013-09-28 09:36:56 +02:00
|
|
|
TRACE="T"
|
2013-09-29 15:37:25 +02:00
|
|
|
shift
|
2013-09-28 09:36:56 +02:00
|
|
|
else
|
|
|
|
TRACE=""
|
|
|
|
fi
|
|
|
|
|
2013-03-27 13:40:10 +01:00
|
|
|
$DIR/stop-wifi.sh
|
2013-10-30 23:14:55 +01:00
|
|
|
test -f /proc/modules && sudo modprobe mac80211_hwsim radios=5
|
2013-09-29 15:37:25 +02:00
|
|
|
if [ "$CONCURRENT" = "y" ]; then
|
|
|
|
sudo iw wlan0 interface add sta0 type station
|
|
|
|
sudo iw wlan1 interface add sta1 type station
|
|
|
|
sudo iw wlan2 interface add sta2 type station
|
|
|
|
fi
|
2013-10-30 14:55:58 +01:00
|
|
|
mkdir -p $LOGDIR
|
2013-03-27 13:40:10 +01:00
|
|
|
sudo ifconfig hwsim0 up
|
2013-10-30 22:08:10 +01:00
|
|
|
sudo $WLANTEST -i hwsim0 -c -d > $LOGDIR/hwsim0 &
|
|
|
|
sudo tcpdump -ni hwsim0 -s 2500 -w $LOGDIR/hwsim0.dump > $LOGDIR/tcpdump 2>&1 &
|
2013-10-30 18:43:59 +01:00
|
|
|
for i in 0 1 2; do
|
|
|
|
sudo $(printf -- "$VALGRIND_WPAS" $i) $WPAS -g /tmp/wpas-wlan$i -G$GROUP -Dnl80211 -iwlan$i -c $DIR/p2p$i.conf \
|
2013-10-30 22:08:10 +01:00
|
|
|
$(printf -- "$CONCURRENT_ARGS" $i) -ddKt$TRACE > $LOGDIR/log$i &
|
2013-10-30 18:43:59 +01:00
|
|
|
done
|
2013-10-30 22:08:10 +01:00
|
|
|
sudo $VALGRIND_HAPD $HAPD -ddKt$TRACE -g /var/run/hostapd-global -G $GROUP -ddKt > $LOGDIR/hostapd &
|
2013-10-30 18:43:59 +01:00
|
|
|
|
2013-03-27 13:40:10 +01:00
|
|
|
sleep 1
|
2013-10-30 23:16:05 +01:00
|
|
|
sudo chown -f $USER $LOGDIR/hwsim0.dump
|
2013-08-24 19:33:21 +02:00
|
|
|
if [ "x$VALGRIND" = "xy" ]; then
|
2013-10-30 23:16:05 +01:00
|
|
|
sudo chown -f $USER $LOGDIR/*valgrind*
|
2013-08-24 19:33:21 +02:00
|
|
|
fi
|
2013-08-26 15:47:15 +02:00
|
|
|
|
2013-09-29 18:14:16 +02:00
|
|
|
if [ -x $HLR_AUC_GW ]; then
|
2013-10-30 22:08:10 +01:00
|
|
|
$HLR_AUC_GW -m $DIR/auth_serv/hlr_auc_gw.milenage_db > $LOGDIR/hlr_auc_gw &
|
2013-09-29 18:14:16 +02:00
|
|
|
fi
|
|
|
|
|
2013-10-30 22:08:10 +01:00
|
|
|
$HAPD -ddKt $DIR/auth_serv/as.conf > $LOGDIR/auth_serv &
|
2013-09-29 18:14:16 +02:00
|
|
|
|
2013-08-26 15:47:15 +02:00
|
|
|
# wait for programs to be fully initialized
|
|
|
|
for i in 0 1 2; do
|
|
|
|
for j in `seq 1 10`; do
|
|
|
|
if $WPACLI -g /tmp/wpas-wlan$i ping | grep -q PONG; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
if [ $j = "10" ]; then
|
|
|
|
echo "Could not connect to /tmp/wpas-wlan$i"
|
2013-09-28 17:19:38 +02:00
|
|
|
exit 1
|
2013-08-26 15:47:15 +02:00
|
|
|
fi
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
for j in `seq 1 10`; do
|
|
|
|
if $WPACLI -g /var/run/hostapd-global ping | grep -q PONG; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
if [ $j = "10" ]; then
|
|
|
|
echo "Could not connect to /var/run/hostapd-global"
|
2013-09-28 17:19:38 +02:00
|
|
|
exit 1
|
2013-08-26 15:47:15 +02:00
|
|
|
fi
|
|
|
|
sleep 1
|
|
|
|
done
|
2013-09-28 17:19:38 +02:00
|
|
|
|
|
|
|
exit 0
|