2013-03-27 08:40:10 -04:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
DIR="$( cd "$( dirname "$0" )" && pwd )"
|
|
|
|
WPAS=$DIR/../../wpa_supplicant/wpa_supplicant
|
2013-08-26 09:47:15 -04:00
|
|
|
WPACLI=$DIR/../../wpa_supplicant/wpa_cli
|
2013-03-27 08:40:10 -04:00
|
|
|
HAPD=$DIR/../../hostapd/hostapd
|
2013-12-27 03:16:50 -05:00
|
|
|
HAPD_AS=$DIR/../../hostapd/hostapd
|
2013-03-27 08:40:10 -04:00
|
|
|
WLANTEST=$DIR/../../wlantest/wlantest
|
2013-09-29 12:14:16 -04:00
|
|
|
HLR_AUC_GW=$DIR/../../hostapd/hlr_auc_gw
|
2014-02-27 10:18:36 -05:00
|
|
|
DATE="$(date +%s)"
|
2013-03-27 08:40:10 -04:00
|
|
|
|
2013-10-30 09:55:58 -04:00
|
|
|
if [ -z "$LOGDIR" ] ; then
|
2013-10-31 08:27:57 -04:00
|
|
|
LOGDIR="$DIR/logs/$DATE"
|
2013-10-30 17:08:10 -04:00
|
|
|
mkdir -p $LOGDIR
|
2013-12-27 03:16:50 -05:00
|
|
|
else
|
|
|
|
if [ -e $LOGDIR/alt-wpa_supplicant/wpa_supplicant/wpa_supplicant ]; then
|
|
|
|
WPAS=$LOGDIR/alt-wpa_supplicant/wpa_supplicant/wpa_supplicant
|
|
|
|
fi
|
|
|
|
if [ -e $LOGDIR/alt-hostapd/hostapd/hostapd ]; then
|
|
|
|
HAPD=$LOGDIR/alt-hostapd/hostapd/hostapd
|
|
|
|
fi
|
|
|
|
if [ -e $LOGDIR/alt-hostapd-as/hostapd/hostapd ]; then
|
|
|
|
HAPD_AS=$LOGDIR/alt-hostapd-as/hostapd/hostapd
|
2014-02-15 10:07:35 -05:00
|
|
|
fi
|
|
|
|
if [ -e $LOGDIR/alt-hlr_auc_gw/hostapd/hlr_auc_gw ]; then
|
|
|
|
HLR_AUC_GW=$LOGDIR/alt-hlr_auc_gw/hostapd/hlr_auc_gw
|
2013-12-27 03:16:50 -05:00
|
|
|
fi
|
2013-10-30 09:55:58 -04:00
|
|
|
fi
|
|
|
|
|
2014-02-27 10:18:36 -05:00
|
|
|
if test -w "$DIR/logs" ; then
|
|
|
|
rm -rf $DIR/logs/current
|
|
|
|
ln -sf $DATE $DIR/logs/current
|
|
|
|
fi
|
|
|
|
|
2013-09-29 09:41:17 -04:00
|
|
|
if groups | tr ' ' "\n" | grep -q ^admin$; then
|
|
|
|
GROUP=admin
|
|
|
|
else
|
|
|
|
GROUP=adm
|
|
|
|
fi
|
|
|
|
|
2013-11-08 02:13:14 -05:00
|
|
|
for i in 0 1 2; do
|
|
|
|
sed "s/ GROUP=.*$/ GROUP=$GROUP/" "$DIR/p2p$i.conf" > "$LOGDIR/p2p$i.conf"
|
|
|
|
done
|
|
|
|
|
2014-02-15 08:57:21 -05:00
|
|
|
sed "s/group=admin/group=$GROUP/" "$DIR/auth_serv/as.conf" > "$LOGDIR/as.conf"
|
2014-05-10 18:06:00 -04:00
|
|
|
sed "s/group=admin/group=$GROUP/;s%LOGDIR%$LOGDIR%" "$DIR/auth_serv/as2.conf" > "$LOGDIR/as2.conf"
|
2014-02-15 08:57:21 -05:00
|
|
|
|
2013-09-29 09:37:25 -04:00
|
|
|
if [ "$1" = "valgrind" ]; then
|
2013-08-24 13:33:21 -04:00
|
|
|
VALGRIND=y
|
2013-10-30 17:08:10 -04:00
|
|
|
VALGRIND_WPAS="valgrind --log-file=$LOGDIR/valgrind-wlan%d"
|
|
|
|
VALGRIND_HAPD="valgrind --log-file=$LOGDIR/valgrind-hostapd"
|
2013-10-30 13:55:00 -04:00
|
|
|
chmod -f a+rx $WPAS
|
|
|
|
chmod -f a+rx $HAPD
|
2014-06-02 09:20:08 -04:00
|
|
|
chmod -f a+rx $HAPD_AS
|
|
|
|
HAPD_AS="valgrind --log-file=$LOGDIR/valgrind-auth-serv $HAPD_AS"
|
2013-09-29 09:37:25 -04:00
|
|
|
shift
|
2013-08-24 13:33:21 -04:00
|
|
|
else
|
|
|
|
unset VALGRIND
|
2013-10-30 13:43:59 -04:00
|
|
|
VALGRIND_WPAS=
|
|
|
|
VALGRIND_HAPD=
|
2013-08-24 13:33:21 -04:00
|
|
|
fi
|
|
|
|
|
2013-09-29 09:37:25 -04:00
|
|
|
if [ "$1" = "trace" ]; then
|
2013-09-28 03:36:56 -04:00
|
|
|
TRACE="T"
|
2013-09-29 09:37:25 -04:00
|
|
|
shift
|
2013-09-28 03:36:56 -04:00
|
|
|
else
|
|
|
|
TRACE=""
|
|
|
|
fi
|
|
|
|
|
2013-11-02 09:39:25 -04:00
|
|
|
$DIR/stop.sh
|
2013-12-30 16:08:25 -05:00
|
|
|
test -f /proc/modules && sudo modprobe mac80211_hwsim radios=6
|
2013-03-27 08:40:10 -04:00
|
|
|
sudo ifconfig hwsim0 up
|
2013-11-17 14:25:17 -05:00
|
|
|
sudo $WLANTEST -i hwsim0 -n $LOGDIR/hwsim0.pcapng -c -dt -L $LOGDIR/hwsim0 &
|
2013-10-30 13:43:59 -04:00
|
|
|
for i in 0 1 2; do
|
2013-11-08 02:13:14 -05:00
|
|
|
sudo $(printf -- "$VALGRIND_WPAS" $i) $WPAS -g /tmp/wpas-wlan$i -G$GROUP -Dnl80211 -iwlan$i -c $LOGDIR/p2p$i.conf \
|
2013-11-24 13:55:15 -05:00
|
|
|
-ddKt$TRACE -f $LOGDIR/log$i &
|
2013-10-30 13:43:59 -04:00
|
|
|
done
|
2013-12-30 16:08:25 -05:00
|
|
|
sudo $(printf -- "$VALGRIND_WPAS" 5) $WPAS -g /tmp/wpas-wlan5 -G$GROUP \
|
|
|
|
-ddKt$TRACE -f $LOGDIR/log5 &
|
2013-11-02 05:53:38 -04:00
|
|
|
sudo $VALGRIND_HAPD $HAPD -ddKt$TRACE -g /var/run/hostapd-global -G $GROUP -ddKt -f $LOGDIR/hostapd &
|
2013-10-30 13:43:59 -04:00
|
|
|
|
2013-03-27 08:40:10 -04:00
|
|
|
sleep 1
|
2013-11-17 14:25:17 -05:00
|
|
|
sudo chown -f $USER $LOGDIR/hwsim0.pcapng $LOGDIR/hwsim0 $LOGDIR/log* $LOGDIR/hostapd
|
2013-08-26 09:47:15 -04:00
|
|
|
|
2013-09-29 12:14:16 -04:00
|
|
|
if [ -x $HLR_AUC_GW ]; then
|
2014-03-30 09:25:27 -04:00
|
|
|
cp $DIR/auth_serv/hlr_auc_gw.milenage_db $LOGDIR/hlr_auc_gw.milenage_db
|
|
|
|
sudo $HLR_AUC_GW -u -m $LOGDIR/hlr_auc_gw.milenage_db -g $DIR/auth_serv/hlr_auc_gw.gsm > $LOGDIR/hlr_auc_gw &
|
2013-09-29 12:14:16 -04:00
|
|
|
fi
|
|
|
|
|
2014-05-10 18:06:00 -04:00
|
|
|
touch $LOGDIR/hostapd.db
|
|
|
|
sudo $HAPD_AS -ddKt $LOGDIR/as.conf $LOGDIR/as2.conf > $LOGDIR/auth_serv &
|
2014-06-02 09:20:08 -04:00
|
|
|
if [ "x$VALGRIND" = "xy" ]; then
|
|
|
|
sleep 1
|
|
|
|
sudo chown -f $USER $LOGDIR/*valgrind*
|
|
|
|
fi
|
2013-09-29 12:14:16 -04:00
|
|
|
|
2013-08-26 09:47:15 -04: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 11:19:38 -04:00
|
|
|
exit 1
|
2013-08-26 09:47:15 -04: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 11:19:38 -04:00
|
|
|
exit 1
|
2013-08-26 09:47:15 -04:00
|
|
|
fi
|
|
|
|
sleep 1
|
|
|
|
done
|
2013-09-28 11:19:38 -04:00
|
|
|
|
|
|
|
exit 0
|