blob: 8bf322e37adf9ea440bbe869e804ce33115a9290 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#!/bin/sh
2path_sh=`nv get path_sh`
3. $path_sh/global.sh
4echo "Info: landev_updown.sh $1 $2 start" >> $test_log
5lan_enable=`nv get LanEnable`
6
7xgw_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
25landev_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
41 br_name=`nv get lan_name`
42 ifconfig $landev_name down 2>>$test_log
43 if [ $? -ne 0 ];then
44 echo "Error: ifconfig $landev_name down failed." >> $test_log
45 fi
46 ifconfig $landev_name up 2>>$test_log
47 if [ $? -ne 0 ];then
48 echo "Error: ifconfig $landev_name up failed." >> $test_log
49 fi
50 brctl addif $br_name $landev_name
51
52 fi
53}
54
55landev_down()
56{
57 landev_name=`nv get $1`
58 ifconfig $landev_name down 2>>$test_log
59 if [ $? -ne 0 ];then
60 echo "Error: ifconfig $landev_name down failed." >> $test_log
61 fi
62 if [ "-$lan_enable" == "-1" ]; then
63 br_name=`nv get lan_name`
64 brctl delif $br_name $landev_name 2>>$test_log
65 if [ $? -ne 0 ];then
66 echo "Error: brctl delif $br_name $landev_name" >> $test_log
67 fi
68 fi
69 if [ "-$lan_enable" == "-2" ]; then
70 ps > ${path_tmp}/landev_updown.sh.$$
71 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.$$`
72 rm -f ${path_tmp}/landev_updown.sh.$$
73 [ -n "$udhcpd_pid" ] && { kill $udhcpd_pid; echo "Info: kill udhcpd $udhcpd_pid " >> $test_log ; }
74 fi
75}
76
77get_cid()
78{
79 ps_ext_cid=$1
80 c_id=${ps_ext_cid##ps_ext}
81}
82
83ps_ext_up()
84{
85 landev_name=`nv get $1`
86 get_cid $1
87 landev_name=`nv get $1`
88 get_cid $1
89 br="br"$c_id
90 br_ip6=`nv get $br"_ipv6_ip"`
91 up_flag="0"
92 if [ "-$br_ip6" != "-" -a "-$br_ip6" != "-::" ]; then
93 up_flag="1"
94 fi
95 br_ip=`nv get $br"_ip"`
96 if [ "-$br_ip" != "-" -a "-$br_ip" != "-0.0.0.0" ]; then
97 up_flag="1"
98 fi
99 if [ "-$up_flag" == "-1" ]; then
100 ifconfig $landev_name up 2>>$test_log
101 if [ $? -ne 0 ];then
102 echo "Error: ifconfig $landev_name up failed." >> $test_log
103 fi
104 #for usb remove netlink
105 brctl addif $br $landev_name
106 fi
107}
108
109ps_ext_down()
110{
111 landev_name=`nv get $1`
112 ifconfig $landev_name down 2>>$test_log
113 if [ $? -ne 0 ];then
114 echo "Error: ifconfig $landev_name down failed." >> $test_log
115 fi
116}
117
118if [ "-$1" == "-ethlan" -o "-$1" == "-wifilan" -o "-$1" == "-wifilan2" -o "-$1" == "-usblan" -o "-$1" == "-ethwan" ]; then
119 if [ "-$2" == "-up" ]; then
120 landev_up $1
121 else
122 landev_down $1
123 fi
124else #ps_ext
125 ps_ext_state=`nv get $1"_pdpstate"`
126 if [ "-$ps_ext_state" == "-working" ]; then
127 if [ "-$2" == "-up" ]; then
128 ps_ext_up $1
129 else
130 ps_ext_down $1
131 fi
132 fi
133fi