yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # script file to start network |
| 4 | # |
| 5 | # Usage: wps_init.sh {pbc | pin} {PINNUM} |
| 6 | # |
| 7 | |
| 8 | ##if [ $# -lt 2 ]; then echo "Usage: $0 {gw | ap} {all | bridge | wan}"; exit 1 ; fi |
| 9 | ROOT=`nv get wifi_root_dir` |
| 10 | LOG=$ROOT/wifi/realtek/slog |
| 11 | |
| 12 | CONFIG_ROOT_DIR="$ROOT/wifi/realtek/rtl8192c" |
| 13 | |
| 14 | ID=`nv get wifi_wps_index` |
| 15 | echo "enter wps init.sh wifi_wps_index=$ID >>>>>>>>" >> $LOG |
| 16 | ID=`expr $ID - 1` |
| 17 | echo "enter wps init.sh ID=$ID >>>>>>>>" >> $LOG |
| 18 | |
| 19 | if [ "$ID" = "0" ];then |
| 20 | #CONFIG_DIR=$CONFIG_ROOT_DIR/wlan0 |
| 21 | #WLAN_INTERFACE="wlan0" |
| 22 | CONFIG_DIR=$CONFIG_ROOT_DIR/wlan0-va$ID |
| 23 | WLAN_INTERFACE="wlan0-va$ID" |
| 24 | else |
| 25 | CONFIG_DIR=$CONFIG_ROOT_DIR/wlan0-va$ID |
| 26 | WLAN_INTERFACE="wlan0-va$ID" |
| 27 | fi |
| 28 | |
| 29 | echo "enter wps init.sh $CONFIG_DIR >>>>>>>>" >> $LOG |
| 30 | if [ -z "$SCRIPT_DIR" ]; then |
| 31 | SCRIPT_DIR=`cat $CONFIG_ROOT_DIR/wifi_script_dir` |
| 32 | fi |
| 33 | START_WLAN_APP=$SCRIPT_DIR/wlanapp_8192c.sh |
| 34 | echo "0" > $CONFIG_DIR/wsc_upnp_enabled |
| 35 | echo "1" > $CONFIG_DIR/wsc_configured |
| 36 | echo "0" > $CONFIG_DIR/wsc_disabled |
| 37 | if [ $1 = "pbc" ]; then |
| 38 | echo "2" > $CONFIG_DIR/wsc_method |
| 39 | else |
| 40 | echo "1" > $CONFIG_DIR/wsc_method |
| 41 | echo $2 > $CONFIG_DIR/wsc_pin |
| 42 | fi |
| 43 | |
| 44 | echo "<<<<<wps init $1 $2 >>>>>>>>" >> $LOG |
| 45 | |
| 46 | |
| 47 | GET_WLAN_ENCRYPT=`cat $CONFIG_DIR/encrypt` |
| 48 | if [ "$GET_WLAN_ENCRYPT" = "2" ]; then #WPAPSK |
| 49 | echo "2" > $CONFIG_DIR/wsc_auth |
| 50 | GET_WLAN_AUTH=`cat $CONFIG_DIR/wpa_cipher` |
| 51 | if [ "$GET_WLAN_AUTH" = "1" ]; then #TKIP |
| 52 | echo "4" > $CONFIG_DIR/wsc_enc |
| 53 | elif [ "$GET_WLAN_AUTH" = "2" ]; then #AES |
| 54 | echo "8" > $CONFIG_DIR/wsc_enc |
| 55 | else #TKIPAES |
| 56 | echo "12" > $CONFIG_DIR/wsc_enc |
| 57 | fi |
| 58 | GET_PSK=`cat $CONFIG_DIR/wpa_psk` |
| 59 | echo $GET_PSK > $CONFIG_DIR/wsc_psk |
| 60 | elif [ "$GET_WLAN_ENCRYPT" = "4" ]; then #WPA2PSK |
| 61 | echo "32" > $CONFIG_DIR/wsc_auth |
| 62 | if [ "$GET_WLAN_AUTH" = "1" ]; then #TKIP |
| 63 | echo "4" > $CONFIG_DIR/wsc_enc |
| 64 | elif [ "$GET_WLAN_AUTH" = "2" ]; then #AES |
| 65 | echo "8" > $CONFIG_DIR/wsc_enc |
| 66 | else #TKIPAES |
| 67 | echo "12" > $CONFIG_DIR/wsc_enc |
| 68 | fi |
| 69 | GET_PSK=`cat $CONFIG_DIR/wpa_psk` |
| 70 | echo $GET_PSK > $CONFIG_DIR/wsc_psk |
| 71 | elif [ "$GET_WLAN_ENCRYPT" = "6" ]; then #WPAPSKWPA2PSK |
| 72 | echo "34" > $CONFIG_DIR/wsc_auth |
| 73 | if [ "$GET_WLAN_AUTH" = "1" ]; then #TKIP |
| 74 | echo "4" > $CONFIG_DIR/wsc_enc |
| 75 | elif [ "$GET_WLAN_AUTH" = "2" ]; then #AES |
| 76 | echo "8" > $CONFIG_DIR/wsc_enc |
| 77 | else #TKIPAES |
| 78 | echo "12" > $CONFIG_DIR/wsc_enc |
| 79 | fi |
| 80 | GET_PSK=`cat $CONFIG_DIR/wpa_psk` |
| 81 | echo $GET_PSK > $CONFIG_DIR/wsc_psk |
| 82 | else #open |
| 83 | echo "1" > $CONFIG_DIR/wsc_auth |
| 84 | echo "1" > $CONFIG_DIR/wsc_enc |
| 85 | fi |
| 86 | |
| 87 | |
| 88 | echo "0" > $CONFIG_DIR/wsc_manual_enabled |
| 89 | echo "0" > $CONFIG_DIR/wsc_upnp_enabled |
| 90 | echo "1" > $CONFIG_DIR/wsc_registrar_enabled |
| 91 | ESSID=`cat $CONFIG_DIR/ssid` |
| 92 | echo $ESSID > $CONFIG_DIR/wsc_ssid |
| 93 | echo "0" > $CONFIG_DIR/wsc_configbyextreg |
| 94 | |
| 95 | echo -e "\n test to check if loop here\n" >> $LOG |
| 96 | |
| 97 | BR_INTERFACE="br0" |
| 98 | echo -e "\n <<<${START_WLAN_APP##*/} start $WLAN_INTERFACE $BR_INTERFACE>>>" >> $LOG |
| 99 | $START_WLAN_APP start $WLAN_INTERFACE $BR_INTERFACE |
| 100 | ERR=`echo $?` |
| 101 | if [ $ERR != 0 ]; then |
| 102 | exit $ERR; |
| 103 | fi |