lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | path_sh=`nv get path_sh` |
| 3 | . $path_sh/global.sh |
| 4 | echo "Info: landev_updown.sh $1 $2 start" >> $test_log |
| 5 | lan_enable=`nv get LanEnable` |
| 6 | |
| 7 | xgw_lan() |
| 8 | { |
| 9 | . $path_sh/xjz_init.sh |
| 10 | xgwlan=`nv get lan_name` |
| 11 | real_gw=`nv get lan_ipaddr` |
| 12 | real_nm=`nv get lan_netmask` |
| 13 | ifconfig $xgwlan down |
| 14 | ifconfig $xgwlan $real_gw netmask $real_nm up |
| 15 | if [ $? -ne 0 ];then |
| 16 | echo "Error: ifconfig $xgwlan $real_gw netmask $real_nm up failed." >> $test_log |
| 17 | fi |
| 18 | |
| 19 | echo "stop gtp_proxy .... " >> $test_log |
| 20 | killall -9 gtp_proxy |
| 21 | gtp_proxy & |
| 22 | echo "start gtp_proxy .... " >> $test_log |
| 23 | } |
| 24 | |
| 25 | landev_up() |
| 26 | { |
| 27 | if [ "-$1" == "-ethwan" ]; then |
| 28 | (router_msg_proxy del_timer ethwan 1>> $test_log 2>&1 || echo "Error: router_msg_proxy del_timer failed." >> $test_log) & |
| 29 | fi |
| 30 | landev_name=`nv get $1` |
| 31 | if [ "-$lan_enable" == "-2" ]; then |
| 32 | |
| 33 | ip=`nv get lan_ipaddr` |
| 34 | nm=`nv get lan_netmask` |
| 35 | ifconfig $landev_name $ip netmask $nm up 2>>$test_log |
| 36 | if [ $? -ne 0 ];then |
| 37 | echo "Error: ifconfig $lan_if $ip netmask $nm failed." >> $test_log |
| 38 | fi |
| 39 | |
| 40 | else |
xf.li | df7f8ba | 2024-09-12 23:53:34 -0700 | [diff] [blame^] | 41 | br_name=`nv get lan_name_$landev_name` |
| 42 | if [ "x$br_name" == "x" ]; then |
| 43 | br_name=`nv get lan_name` |
| 44 | fi |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 45 | ifconfig $landev_name down 2>>$test_log |
| 46 | if [ $? -ne 0 ];then |
| 47 | echo "Error: ifconfig $landev_name down failed." >> $test_log |
| 48 | fi |
| 49 | ifconfig $landev_name up 2>>$test_log |
| 50 | if [ $? -ne 0 ];then |
| 51 | echo "Error: ifconfig $landev_name up failed." >> $test_log |
| 52 | fi |
| 53 | brctl addif $br_name $landev_name |
| 54 | |
| 55 | fi |
| 56 | } |
| 57 | |
| 58 | landev_down() |
| 59 | { |
| 60 | landev_name=`nv get $1` |
| 61 | ifconfig $landev_name down 2>>$test_log |
| 62 | if [ $? -ne 0 ];then |
| 63 | echo "Error: ifconfig $landev_name down failed." >> $test_log |
| 64 | fi |
| 65 | if [ "-$lan_enable" == "-1" ]; then |
xf.li | df7f8ba | 2024-09-12 23:53:34 -0700 | [diff] [blame^] | 66 | br_name=`nv get lan_name_$landev_name` |
| 67 | if [ "x$br_name" == "x" ]; then |
| 68 | br_name=`nv get lan_name` |
| 69 | fi |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 70 | brctl delif $br_name $landev_name 2>>$test_log |
| 71 | if [ $? -ne 0 ];then |
| 72 | echo "Error: brctl delif $br_name $landev_name" >> $test_log |
| 73 | fi |
| 74 | fi |
| 75 | if [ "-$lan_enable" == "-2" ]; then |
| 76 | ps > ${path_tmp}/landev_updown.sh.$$ |
| 77 | udhcpd_pid=`awk 'BEGIN{temp1="'"${landev_name}"'";temp2="'dhcpd'"}{if(index($0,temp1)>0 && index($0,temp2)>0){print $1}}' ${path_tmp}/landev_updown.sh.$$` |
| 78 | rm -f ${path_tmp}/landev_updown.sh.$$ |
| 79 | [ -n "$udhcpd_pid" ] && { kill $udhcpd_pid; echo "Info: kill udhcpd $udhcpd_pid " >> $test_log ; } |
| 80 | fi |
| 81 | } |
| 82 | |
| 83 | get_cid() |
| 84 | { |
| 85 | ps_ext_cid=$1 |
| 86 | c_id=${ps_ext_cid##ps_ext} |
| 87 | } |
| 88 | |
| 89 | ps_ext_up() |
| 90 | { |
| 91 | landev_name=`nv get $1` |
| 92 | get_cid $1 |
| 93 | landev_name=`nv get $1` |
| 94 | get_cid $1 |
| 95 | br="br"$c_id |
| 96 | br_ip6=`nv get $br"_ipv6_ip"` |
| 97 | up_flag="0" |
| 98 | if [ "-$br_ip6" != "-" -a "-$br_ip6" != "-::" ]; then |
| 99 | up_flag="1" |
| 100 | fi |
| 101 | br_ip=`nv get $br"_ip"` |
| 102 | if [ "-$br_ip" != "-" -a "-$br_ip" != "-0.0.0.0" ]; then |
| 103 | up_flag="1" |
| 104 | fi |
| 105 | if [ "-$up_flag" == "-1" ]; then |
| 106 | ifconfig $landev_name up 2>>$test_log |
| 107 | if [ $? -ne 0 ];then |
| 108 | echo "Error: ifconfig $landev_name up failed." >> $test_log |
| 109 | fi |
| 110 | #for usb remove netlink |
| 111 | brctl addif $br $landev_name |
| 112 | fi |
| 113 | } |
| 114 | |
| 115 | ps_ext_down() |
| 116 | { |
| 117 | landev_name=`nv get $1` |
| 118 | ifconfig $landev_name down 2>>$test_log |
| 119 | if [ $? -ne 0 ];then |
| 120 | echo "Error: ifconfig $landev_name down failed." >> $test_log |
| 121 | fi |
| 122 | } |
| 123 | |
| 124 | if [ "-$1" == "-ethlan" -o "-$1" == "-wifilan" -o "-$1" == "-wifilan2" -o "-$1" == "-usblan" -o "-$1" == "-ethwan" ]; then |
| 125 | if [ "-$2" == "-up" ]; then |
| 126 | landev_up $1 |
| 127 | else |
| 128 | landev_down $1 |
| 129 | fi |
| 130 | else #ps_ext |
| 131 | ps_ext_state=`nv get $1"_pdpstate"` |
| 132 | if [ "-$ps_ext_state" == "-working" ]; then |
| 133 | if [ "-$2" == "-up" ]; then |
| 134 | ps_ext_up $1 |
| 135 | else |
| 136 | ps_ext_down $1 |
| 137 | fi |
| 138 | fi |
| 139 | fi |