This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 17a46ee549a8a805368ab7739621a76d8bb9ed1d
Author: wangchen <wangche...@xiaomi.com>
AuthorDate: Wed Mar 27 16:47:03 2024 +0800

    sim_wifi.sh:add stop_bridge script to the 
command(./tools/simwifi/sim_wifi.sh clean interface)
    
    stop_bridge script will excute simhostroute.sh interface off
    command example:sudo ./tools/simwifi/sim_wifi.sh clean eno1
    
    Signed-off-by: wangchen <wangche...@xiaomi.com>
---
 tools/simwifi/sim_wifi.sh | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/simwifi/sim_wifi.sh b/tools/simwifi/sim_wifi.sh
index 5b7c785ece..4088bbb160 100755
--- a/tools/simwifi/sim_wifi.sh
+++ b/tools/simwifi/sim_wifi.sh
@@ -520,11 +520,19 @@ init()
 
 clean()
 {
+  [ -z "$1" ] && {
+    echo "Missing the default wan interface."
+    exit -1
+  }
+
   recovery_to_init
 
   cur_mode=$(get_var mode $DEFCONF_FILE)
   [ "$cur_mode" = "hwsim" ] &&  modprobe -r mac80211_hwsim
 
+  echo "defwan:$1" > $DEFCONF_FILE
+  [ -n "$1" -a  -n "$(ifconfig | grep $1)" ] && stop_bridge $1
+
   rm -fr $RUN_DIR
   rm -f $UDHCPC_SCRIPT
 }
@@ -532,7 +540,7 @@ clean()
 usage()
 {
   echo "$(basename $SOURCE) (rename <old> <new> |"
-  echo -e "\t init <wan> <mode> |clean |"
+  echo -e "\t init <wan> <mode> |clean <wan> |"
   echo -e "\t start_wpa <wlan0> |stop_wpa |"
   echo -e "\t start_hostapd <wlan0> |stop_hostapd |"
   echo -e "\t start_udhcpc <wlan0> |stop_udhcpc |"
@@ -552,7 +560,7 @@ get_script_path $0
 
 case $1 in
   init) init $2 $3;;
-  clean) clean;;
+  clean) clean $2;;
   start_bridge) start_bridge $2;;
   stop_bridge) stop_bridge $2;;
   start_hwsim)  start_hwsim $2 $3;;

Reply via email to