[Feature][ZXW-237]merge P54U03 version

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: Id39ef8b992af691eab09c01d4ea26da89e5f4049
diff --git a/ap/app/Script/scripts/wan_ipv4.sh b/ap/app/Script/scripts/wan_ipv4.sh
index 95b5203..0473738 100755
--- a/ap/app/Script/scripts/wan_ipv4.sh
+++ b/ap/app/Script/scripts/wan_ipv4.sh
@@ -233,9 +233,9 @@
 	udhcpc_kill
 	pppoe_kill
 	
-	if [ "-$c_id" == "-0" -o "-$c_id" == "-$def_cid" ]; then
-		echo 0 > /proc/sys/net/ipv4/ip_forward
-	fi
+	#if [ "-$c_id" == "-0" -o "-$c_id" == "-$def_cid" ]; then
+		#echo 0 > /proc/sys/net/ipv4/ip_forward
+	#fi
 	
 	ifconfig $wan_if 0.0.0.0 2>>$test_log
 	if [ $? -ne 0 ];then
diff --git a/ap/app/Script/scripts/wan_ipv6.sh b/ap/app/Script/scripts/wan_ipv6.sh
index d1c1708..e1e60d1 100755
--- a/ap/app/Script/scripts/wan_ipv6.sh
+++ b/ap/app/Script/scripts/wan_ipv6.sh
@@ -142,7 +142,7 @@
             fi
 			
 			killall -9 clatd
-			clatd -i $wan_if -p 1:1:1:123:: &
+			#clatd -i $wan_if -p 1:1:1:123:: &
 			
 			if [ "-$c_id" != "-$def_cid" ]; then
 				wan_pri=`nv get $1"_priority"`
@@ -237,7 +237,7 @@
                 fi
 				
 				killall -9 clatd
-				clatd -i $wan_if -p 1:1:1:123:: &
+				#clatd -i $wan_if -p 1:1:1:123:: &
 			else
 				echo "the zte_ipv6_slaac fail"
 				nv set $wan_if"_ipv6_state"="dead"
@@ -297,6 +297,9 @@
 	if [ "-$c_id" == "-0" -o "-$c_id" == "-$def_cid" ]; then
 		echo 0 > /proc/sys/net/ipv6/conf/all/forwarding  
 		ip -6 route del default
+		ip route del default
+		killall clatd
+		iptables -t nat -D POSTROUTING -o v4-$wan_if -j MASQUERADE
 		#if [ $? -ne 0 ];then
 	        #echo "Error: ip -6 route del default failed." >> $test_log
         #fi
diff --git a/ap/app/Script/scripts/wan_ipv6_config.sh b/ap/app/Script/scripts/wan_ipv6_config.sh
index 1c1e278..9098fab 100755
--- a/ap/app/Script/scripts/wan_ipv6_config.sh
+++ b/ap/app/Script/scripts/wan_ipv6_config.sh
@@ -264,7 +264,23 @@
     
     ndp_kill
     zte_ndp -a -s br0 -d "$wan_if" -l $ndp_log &
-
+    xlat_enable=`nv get xlat_enable`
+    if [ "-$xlat_enable" == "-1" ];then
+	route_info=`route|grep default`
+	if [ "$route_info" == "" ];then
+		xlat_prefix=`nv get xlat_prefix`
+		#chmod 777 /dev/net/tun
+		if [ "$xlat_prefix" == "" ];then
+			clatd -i $defwan6_if &
+		else
+			clatd -i $defwan6_if -p $xlat_prefix &
+		fi		
+		echo 1 > /proc/sys/net/ipv4/ip_forward
+		iptables -t nat -A POSTROUTING -o v4-$defwan6_if -j MASQUERADE
+		sleep 1
+		ip route add default dev v4-$defwan6_if
+	fi
+    fi
 }
 
 ############ipv6 shell entry#################