start.sh 2.9 KB

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