[Feature][YUKUAI_patch]add 18.02 code

Only Configure: No
Affected branch: master
Affected module: unknow
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No

Change-Id: I7f71153004f10fc0ea5adfa083866aaeeb1053ac
diff --git a/rootfs/sbin/lan.sh b/rootfs/sbin/lan.sh
new file mode 100755
index 0000000..2d6fa29
--- /dev/null
+++ b/rootfs/sbin/lan.sh
@@ -0,0 +1,121 @@
+#!/bin/sh
+#
+# $Id: lan.sh
+#
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+
+br_set()
+{
+    br_name=$lan_if_cap
+
+    #ÉèÖÃÍøÇÅ
+    killall -9 udhcpd
+    echo "ifconfig $br_name start...................."
+    ifconfig $br_name down
+    brctl delbr $br_name
+    brctl addbr $br_name 2>>$test_log
+    if [ $? -ne 0 ];then
+        echo "Error: brctl addbr $br_name failed." >> $test_log
+    fi
+    brctl setfd $br_name 0.1 2>>$test_log
+    if [ $? -ne 0 ];then
+        echo "Error: brctl setfd $br_name 0.1 failed." >> $test_log
+    fi
+    ifconfig lo up 2>>$test_log
+    if [ $? -ne 0 ];then
+        echo "Error: ifconfig lo up failed." >> $test_log
+    fi
+    ifconfig $br_name up 2>>$test_log
+    if [ $? -ne 0 ];then
+        echo "Error: ifconfig $br_name up failed." >> $test_log
+    fi
+
+    #´ò¿ªÍøÇŵØÖ·¸Ä±ä֪ͨµÄ¿ª¹Ø
+    echo 1 > /proc/sys/net/ipv4/conf/$br_name/arp_notify
+    prj=`cat /sys/gmac/gmacconfig/type`
+    if [ "$prj" == "cpe" ]; then
+        ifconfig eth0 up 2>>$test_log
+        brctl addif $br_name eth0 2>>$test_log
+    fi
+    br_node=`nv get br_node_cap`
+
+    #analysis br_node ex: usb0+wifi0+¡­
+    IFS_OLD=$IFS
+    IFS="+"
+    for device in $br_node
+    do
+        ifconfig $device up
+        
+        brctl addif $br_name $device 2>>$test_log
+        if [ $? -ne 0 ];then
+            echo "Error: brctl addif $br_name $device failed." >> $test_log
+        fi
+    done
+    IFS=$IFS_OLD
+}
+
+lan_set()
+{
+    ip=`nv get lan_ipaddr_cap`
+    nm=`nv get lan_netmask_cap`
+    ifconfig $lan_if_cap $ip netmask $nm 2>>$test_log
+    if [ $? -ne 0 ];then
+        echo "Error: ifconfig $lan_if_cap $ip netmask $nm failed." >> $test_log
+    fi
+
+    webv6_enable=`nv get webv6_enable`
+    ipv6=`nv get lan_ipv6addr_cap`
+    if [ "x$webv6_enable" == "x1" ]; then
+        ifconfig $lan_if_cap $ipv6/64
+    if [ $? -ne 0 ];then
+        echo "Error: ifconfig $lan_if_cap $ipv6 failed." >> $test_log
+    fi
+    fi
+}
+
+main()
+{
+    lan_enable=`nv get LanEnable_cap`
+    if [ "x$lan_enable" == "x0" ]; then
+        exit 0
+    fi
+
+    echo "Info: lan.sh start" >> $test_log
+
+    if [ "x$lan_enable" == "x1" ]; then
+        br_set
+    fi
+	
+	if [ "x$lan_if_cap" != "x" ]; then
+        lan_set
+    fi
+ 
+	dhcps_in_cap=`nv get dhcps_in_cap`
+
+	if [ "x$dhcps_in_cap" == "x1" ]; then
+    echo "" > $path_conf/udhcpd.leases
+    rm -rf $path_conf/udhcpd.conf
+    . $path_sh/user-config-udhcpd.sh
+        
+    dhcp=`nv get dhcpEnabled`
+    if [ "$dhcp" == "1" ]; then
+        echo "Info: config-udhcpd.sh lan -r 1 start" >> $test_log
+        . $path_sh/config-udhcpd.sh "lan" -r 1
+    fi
+	fi
+    dnsmasq -i $lan_if_cap -r $path_conf/resolv.conf &
+	gw_in_cap=`nv get gw_in_cap`
+	if [ "x$gw_in_cap" != "x1" ]; then
+		ap_ip=`nv get lan_ipaddr`
+		ap_ipv6=`nv get lan_ipv6addr`
+		
+		ip route add default via $ap_ip
+		ip -6 route add default via $ap_ipv6 dev $lan_if_cap
+		echo "nameserver $ap_ip" >> /etc/resolv.conf
+	else
+		echo 1 > /proc/net/ct_iptables_syn
+	fi
+}
+
+main