start.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #!/bin/sh
  2. DIR="$( cd "$( dirname "$0" )" && pwd )"
  3. WPAS=$DIR/../../wpa_supplicant/wpa_supplicant
  4. WPACLI=$DIR/../../wpa_supplicant/wpa_cli
  5. HAPD=$DIR/../../hostapd/hostapd
  6. WLANTEST=$DIR/../../wlantest/wlantest
  7. HLR_AUC_GW=$DIR/../../hostapd/hlr_auc_gw
  8. DATE=`date +%s`
  9. if [ -z "$LOGDIR" ] ; then
  10. LOGDIR=$DIR/logs
  11. fi
  12. export LOGDIR
  13. if groups | tr ' ' "\n" | grep -q ^admin$; then
  14. GROUP=admin
  15. else
  16. GROUP=adm
  17. fi
  18. if [ "$1" = "concurrent" ]; then
  19. CONCURRENT=y
  20. CONCURRENT_ARGS="-N -Dnl80211 -ista%d -c $DIR/sta-dummy.conf"
  21. shift
  22. else
  23. unset CONCURRENT
  24. CONCURRENT_ARGS=
  25. fi
  26. if [ "$1" = "valgrind" ]; then
  27. VALGRIND=y
  28. VALGRIND_WPAS="valgrind --log-file=$LOGDIR/$DATE-valgrind-wlan%d"
  29. VALGRIND_HAPD="valgrind --log-file=$LOGDIR/$DATE-valgrind-hostapd"
  30. chmod -f a+rx $WPAS
  31. chmod -f a+rx $HAPD
  32. shift
  33. else
  34. unset VALGRIND
  35. VALGRIND_WPAS=
  36. VALGRIND_HAPD=
  37. fi
  38. if [ "$1" = "trace" ]; then
  39. TRACE="T"
  40. shift
  41. else
  42. TRACE=""
  43. fi
  44. $DIR/stop-wifi.sh
  45. sudo modprobe mac80211_hwsim radios=5
  46. if [ "$CONCURRENT" = "y" ]; then
  47. sudo iw wlan0 interface add sta0 type station
  48. sudo iw wlan1 interface add sta1 type station
  49. sudo iw wlan2 interface add sta2 type station
  50. fi
  51. mkdir -p $LOGDIR
  52. sudo ifconfig hwsim0 up
  53. sudo $WLANTEST -i hwsim0 -c -d > $LOGDIR/$DATE-hwsim0 &
  54. sudo tcpdump -ni hwsim0 -s 2500 -w $LOGDIR/$DATE-hwsim0.dump > $LOGDIR/$DATE-tcpdump 2>&1 &
  55. for i in 0 1 2; do
  56. sudo $(printf -- "$VALGRIND_WPAS" $i) $WPAS -g /tmp/wpas-wlan$i -G$GROUP -Dnl80211 -iwlan$i -c $DIR/p2p$i.conf \
  57. $(printf -- "$CONCURRENT_ARGS" $i) -ddKt$TRACE > $LOGDIR/$DATE-log$i &
  58. done
  59. sudo $VALGRIND_HAPD $HAPD -ddKt$TRACE -g /var/run/hostapd-global -G $GROUP -ddKt > $LOGDIR/$DATE-hostapd &
  60. sleep 1
  61. sudo chown $USER $LOGDIR/$DATE-hwsim0.dump
  62. if [ "x$VALGRIND" = "xy" ]; then
  63. sudo chown $USER $LOGDIR/$DATE-*valgrind*
  64. fi
  65. if [ -x $HLR_AUC_GW ]; then
  66. $HLR_AUC_GW -m $DIR/auth_serv/hlr_auc_gw.milenage_db > $LOGDIR/$DATE-hlr_auc_gw &
  67. fi
  68. $HAPD -ddKt $DIR/auth_serv/as.conf > $LOGDIR/$DATE-auth_serv &
  69. # wait for programs to be fully initialized
  70. for i in 0 1 2; do
  71. for j in `seq 1 10`; do
  72. if $WPACLI -g /tmp/wpas-wlan$i ping | grep -q PONG; then
  73. break
  74. fi
  75. if [ $j = "10" ]; then
  76. echo "Could not connect to /tmp/wpas-wlan$i"
  77. exit 1
  78. fi
  79. sleep 1
  80. done
  81. done
  82. for j in `seq 1 10`; do
  83. if $WPACLI -g /var/run/hostapd-global ping | grep -q PONG; then
  84. break
  85. fi
  86. if [ $j = "10" ]; then
  87. echo "Could not connect to /var/run/hostapd-global"
  88. exit 1
  89. fi
  90. sleep 1
  91. done
  92. exit 0