zte's code,first commit

Change-Id: I9a04da59e459a9bc0d67f101f700d9d7dc8d681b
diff --git a/ap/app/Script/scripts/auto_dial.sh b/ap/app/Script/scripts/auto_dial.sh
new file mode 100644
index 0000000..f6508cc
--- /dev/null
+++ b/ap/app/Script/scripts/auto_dial.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+
+echo "Info: auto_dial.sh $1 start" >> $test_log
+
+wanlan_select()
+{
+	auto_wan_if=`nv get $1`
+	ifconfig $auto_wan_if down 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $auto_wan_if down" >> $test_log
+	fi
+	ifconfig $auto_wan_if up 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $auto_wan_if up" >> $test_log
+	fi
+	(eth_auto_connect || echo "Error: eth_auto_connect failed." >> $test_log) &
+}
+
+
+wanlan_select $1
diff --git a/ap/app/Script/scripts/clat_config.sh b/ap/app/Script/scripts/clat_config.sh
new file mode 100644
index 0000000..c1a9b2b
--- /dev/null
+++ b/ap/app/Script/scripts/clat_config.sh
@@ -0,0 +1,63 @@
+#!/bin/sh 
+
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+
+echo "Info: clat_config.sh $1 $2 start" >> $test_log
+
+if [ "x$2" != "x" ]; then
+	wan1_ipv6_prefix_info=`nv get $2"_ipv6_prefix_info"`
+fi
+
+if [ "x$wan1_ipv6_prefix_info" != "x" ]; then
+    clat6_ipv6="$wan1_ipv6_prefix_info"":464"
+fi
+
+ipv4_fake_subnet=`nv get ipv4_fake_subnet`
+clat_fake_subnet=`nv get clat_fake_subnet`
+ipv6_fake_addr=`nv get ipv6_fake_subnet`
+if [ "x$ipv6_fake_addr" != "x" ];then
+	ipv6_fake_subnet=$ipv6_fake_addr"/64"
+fi
+
+case $1 in 
+ "up") 
+    if [ "x$ipv4_fake_subnet" == "x" -a "x$clat_fake_subnet" == "x" -a "x$ipv6_fake_addr" == "x" ];then
+        echo "Info: ipv4_fake_subnet and clat_fake_subnet not exist, please check!!!" >> $test_log
+    fi
+
+	# for 46
+	route add default dev clat4 metric 40
+    route add -net $ipv4_fake_subnet netmask 255.255.0.0 dev clat4
+	iptables -t nat -A POSTROUTING -o clat4 -j MASQUERADE
+	
+	if [ "x$clat6_ipv6" != "x" -a "x$2" != "x" ]; then
+		ip -6 neigh add proxy $clat6_ipv6 dev $2
+	fi
+	
+	echo 1 > /proc/sys/net/ipv4/ip_forward
+	
+	#for 64
+	#ip -6 route add $ipv6_fake_subnet dev clat
+	#route add -net $clat_fake_subnet netmask 255.255.255.0 dev clat4
+    ;;
+ 
+ "down") 
+	
+	# for 46
+	route del default dev clat4 metric 40
+    route del -net $ipv4_fake_subnet netmask 255.255.0.0 dev clat4
+	iptables -t nat -D POSTROUTING -o clat4 -j MASQUERADE
+	
+	if [ "x$clat6_ipv6" != "x" -a "x$2" != "x" ]; then
+		ip -6 neigh del proxy $clat6_ipv6 dev $2
+	fi
+	
+	#for 64
+	#ip -6 route del $ipv6_fake_subnet dev clat
+	#route del -net $clat_fake_subnet netmask 255.255.255.0 dev clat4
+    ;;
+
+esac
+
+
diff --git a/ap/app/Script/scripts/config-dns.sh b/ap/app/Script/scripts/config-dns.sh
new file mode 100644
index 0000000..5237ca3
--- /dev/null
+++ b/ap/app/Script/scripts/config-dns.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+#
+# $Id: config-dns.sh, v10.08.05, 2010-08-05 15:00:00
+#
+# usage: config-dns.sh [<dns1>] [<dns2>]
+#
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+echo "Info: config-dns.sh $1 $2 start" >> $test_log
+fname=$path_conf"/etc/resolv.conf"
+fbak=$path_conf"/etc/resolv_conf.bak"
+
+# in case no previous file
+touch $fname
+
+# backup file without nameserver part
+sed -e '/nameserver/d' $fname > $fbak
+
+# set primary and seconday DNS
+if [ "x$1" != "x" ]; then
+  echo "nameserver $1" > $fname
+else # empty dns
+  rm -f $fname
+fi
+if [ "x$2" != "x" ]; then
+  echo "nameserver $2" >> $fname
+fi
+
+cat $fbak >> $fname
+rm -f $fbak
+
diff --git a/ap/app/Script/scripts/config-hostname.sh b/ap/app/Script/scripts/config-hostname.sh
new file mode 100644
index 0000000..bf4c5cc
--- /dev/null
+++ b/ap/app/Script/scripts/config-hostname.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+echo "Info: config-hostname.sh $1 $2 start" >> $test_log
+fname=$path_conf"/hostname_mac_file"
+fbak=$path_conf"/hostname_mac_file_bak"
+
+if [ "x$1" = "x" ]; then
+    echo "insufficient arguments.."
+elif [ "x$2" = "x" ]; then
+    sed -e "/$1/d" $fname > $fbak
+	cat $fbak > $fname
+    rm -f $fbak
+else # $1 mac, $2 hostname
+    sed -e "/$1/d" $fname > $fbak
+    echo "$1 $2" >> $fbak
+	cat $fbak > $fname
+    rm -f $fbak
+fi
+
+
diff --git a/ap/app/Script/scripts/config-igmpproxy.sh b/ap/app/Script/scripts/config-igmpproxy.sh
new file mode 100644
index 0000000..353970e
--- /dev/null
+++ b/ap/app/Script/scripts/config-igmpproxy.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+#
+# usage: see function usage()
+
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+
+
+usage () {
+  echo "usage: config-udhcpd.sh [option]..."
+  echo "options:"
+  echo "  -h                        	: print this help"
+  echo "  -c 							: clean the conf file"
+  echo "  -u interface					: set upstream interface for server"
+  echo "  -d interface1 [interface2]..	: set downstream interface for client"
+  echo "  -s addr						: set gateway of upstream interface"
+  echo "  -r 							: run igmpproxy"
+  exit
+}
+
+config () {
+  case "$1" in
+    "-c")
+      sed -i '36,$d' $fname;;  
+    "-u")
+      sed -i "30c phyint $2 upstream  ratelimit 0  threshold 1" $fname;;      
+    "-d")
+      sed -i '$a phyint '"$2"' downstream  ratelimit 0  threshold 1' $fname
+	  sed -i '$a' $fname;;	        
+    "-s")
+      sed -i "31c altnet $2/24" $fname;;      
+
+  esac  
+
+}
+
+
+fname=$path_conf"/igmpproxy.conf"
+	
+case "$1" in
+  
+
+  "-h") usage;;
+  "-c") config "$1";;
+  "-u") config "$1" "$2";;
+  "-s") config "$1" "$2";;
+  "-d") config "$1" "$2" "$3" "$4";;
+  "-r") igmpproxy& ;;
+  *) usage;;
+esac
+
+
diff --git a/ap/app/Script/scripts/config-parents.sh b/ap/app/Script/scripts/config-parents.sh
new file mode 100644
index 0000000..b38ff67
--- /dev/null
+++ b/ap/app/Script/scripts/config-parents.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+echo "Info: config-parents $1 $2 $3 start" >> $test_log
+
+device()
+{
+	fname=$path_conf"/children_device_file"
+	fbak=$path_conf"/children_device_file_bak"
+
+	if [ "x$1" = "x" ]; then
+		echo "insufficient arguments.."
+	elif [ "x$2" = "x" ]; then
+		sed -e "/$1/d" $fname > $fbak
+		cat $fbak > $fname
+		rm -f $fbak
+	else # $1 mac, $2 hostname
+		sed -e "/$1/d" $fname > $fbak
+		echo "$1 $2" >> $fbak
+		cat $fbak > $fname
+		rm -f $fbak
+	fi
+}
+white_site()
+{
+	fname=${path_conf}/white_site_file
+	fbak=${path_conf}/white_site_file_bak
+	if [ "x$1" = "x" ]; then
+		echo "no action"
+	elif [ "x$1" = "x-A" ]; then
+		if [ "x$2" = "x" ]; then
+			echo "no site to add"
+		else #s2:site s3:name
+			#sed -i "s%$2.*%%" $fname 
+			#sed -i "/^$/d" $fname
+			echo "$2,$3" >> $fname
+			#cat $fbak > $fname
+			#rm -f $fbak
+		fi
+	elif [ "x$1" = "x-D" ]; then
+		if [ "x$2" = "x" ]; then
+			echo "no site to delete"
+		else #s2:ids
+			ids=$2
+			if [ -n "$ids" ]; then
+				echo $ids|grep ",$"
+				if [ 0 -eq $? ]; then
+					echo "_____1"
+					echo $ids|sed 's/\(,\)/d;/g'|sed 's%^\(.*\)%sed -i "\1"%'|sed "s,$, $fname,"|sh
+				else
+					echo "______2"
+					echo $ids|sed 's/\(,\)/d;/g'|sed 's%^\(.*\)%sed -i "\1d"%'|sed "s,$, $fname," |sh
+				fi
+			fi
+		fi
+	else # $1 mac, $2 hostname
+		echo "error action"
+	fi
+}
+
+if [ "$1" = "white_site" ]; then
+	white_site $2 $3 $4
+elif [ "$1" = "device" ]; then
+	device $2 $3
+fi
\ No newline at end of file
diff --git a/ap/app/Script/scripts/config-udhcpd.sh b/ap/app/Script/scripts/config-udhcpd.sh
new file mode 100644
index 0000000..dfbd2c1
--- /dev/null
+++ b/ap/app/Script/scripts/config-udhcpd.sh
@@ -0,0 +1,271 @@
+#!/bin/sh
+#
+# $Id: config-udhcpd.sh,v 1.10 2010-06-18 06:33:21 steven Exp $
+#
+# usage: see function usage()
+
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+
+dhcp_type=$1
+
+usage () {
+  echo "usage: config-udhcpd.sh [option]..."
+  echo "options:"
+  echo "  -h              : print this help"
+  echo "  -s ipaddr       : set ipaddr as start of the IP lease block"
+  echo "  -e ipaddr       : set ipaddr as end of the IP lease block"
+  echo "  -i ifc          : set ifc as the interface that udhcpd will use"
+  echo "  -d dns1 [dns2]  : set dns1 and dns2 as DNS"
+  echo "  -m mask         : set mask as subnet netmask"
+  echo "  -g gateway      : set gateway as router's IP address"
+  echo "  -t time         : set time seconds as the IP life time"
+  echo "  -r [sleep_time] : run dhcp server"
+  echo "  -k              : kill the running dhcp server"
+  echo "  -S [mac ipaddr] : statically assign IP to given MAC address"
+
+  exit
+}
+
+config () {
+  case "$1" in
+    "-s")
+      sed -e '/start/d' $fname > $fbak
+      echo "start $2" >> $fbak ;;
+    "-e")
+      sed -e '/end/d' $fname > $fbak
+      echo "end $2" >> $fbak ;;
+    "-i")
+      sed -e '/interface/d' $fname > $fbak
+      echo "interface $2" >> $fbak ;;
+	"-p")
+      sed -e '/pidfile/d' $fname > $fbak
+      echo "pidfile $2" >> $fbak ;;
+	"-l")
+      sed -e '/lease_file/d' $fname > $fbak
+      echo "lease_file $2" >> $fbak ;;
+    "-d")
+      sed -e '/option *dns/d' $fname > $fbak
+      echo "option dns $2 $3" >> $fbak ;;
+    "-m")
+      sed -e '/option *subnet/d' $fname > $fbak
+      echo "option subnet $2" >> $fbak ;;
+    "-g")
+      sed -e '/option *router/d' $fname > $fbak
+      echo "option router $2" >> $fbak ;;
+    "-t")
+      sed -e '/option *lease/d' $fname > $fbak
+      echo "option lease $2" >> $fbak ;;
+    "-S")
+      if [ "$2" = "" ]; then
+        sed -e '/static_lease/d' $fname > $fbak
+      elif [ "$3" = "" ]; then
+	echo "insufficient arguments.."
+	usage
+      else
+        sed -e "/$2/d" $fname > $fbak
+        echo "static_lease $2 $3" >> $fbak
+		cat $fbak > $fname
+		rm -f $fbak
+		sed -e "/$2/d" $fname_static > $fbak_static
+        echo "$2 $3" >> $fbak_static
+		cat $fbak_static > $fname_static
+		rm -f $fbak_static
+	return
+      fi
+      ;;
+    "-x")
+      sed -e '/static_netmask/d' $fname > $fbak
+      echo "static_netmask $2" >> $fbak ;;
+    "-y")
+      sed -e '/static_router/d' $fname > $fbak
+      echo "static_router $2" >> $fbak ;;
+	"-D")
+      sed -e "/$2/d" $fname > $fbak 
+	  sed -e "/$2/d" $fname_static > $fbak_static 
+	  cat $fbak_static > $fname_static
+      rm -f $fbak_static;;
+	"-E")
+      while read LINE
+	  do
+		echo "static_lease $LINE" >> $fbak
+	  done < $fname_static ;;
+    *) return;;
+  esac
+  cat $fbak > $fname
+  rm -f $fbak
+  return
+}
+
+#  arg1:  phy address.
+link_down()
+{
+	# get original register value
+	get_mii=`mii_mgr -g -p $1 -r 0`
+	orig=`echo $get_mii | sed 's/^.....................//'`
+
+	# stupid hex value calculation.
+	pre=`echo $orig | sed 's/...$//'`
+	post=`echo $orig | sed 's/^..//'` 
+	num_hex=`echo $orig | sed 's/^.//' | sed 's/..$//'`
+	case $num_hex in
+		"0")	rep="8"	;;
+		"1")	rep="9"	;;
+		"2")	rep="a"	;;
+		"3")	rep="b"	;;
+		"4")	rep="c"	;;
+		"5")	rep="d"	;;
+		"6")	rep="e"	;;
+		"7")	rep="f"	;;
+		# The power is already down
+		*)		echo "Port$1 is down. Skip.";return;;
+	esac
+	new=$pre$rep$post
+	# power down
+	mii_mgr -s -p $1 -r 0 -v $new 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: mii_mgr -s -p $1 -r 0 -v $new" >> $test_log
+	fi
+}
+
+link_up()
+{
+	# get original register value
+	get_mii=`mii_mgr -g -p $1 -r 0`
+	orig=`echo $get_mii | sed 's/^.....................//'`
+
+	# stupid hex value calculation.
+	pre=`echo $orig | sed 's/...$//'`
+	post=`echo $orig | sed 's/^..//'` 
+	num_hex=`echo $orig | sed 's/^.//' | sed 's/..$//'`
+	case $num_hex in
+		"8")	rep="0"	;;
+		"9")	rep="1"	;;
+		"a")	rep="2"	;;
+		"b")	rep="3"	;;
+		"c")	rep="4"	;;
+		"d")	rep="5"	;;
+		"e")	rep="6"	;;
+		"f")	rep="7"	;;
+		# The power is already up
+		*)		echo "Port$1 is up. Skip.";return;;
+	esac
+	new=$pre$rep$post
+	# power up
+	mii_mgr -s -p $1 -r 0 -v $new 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: mii_mgr -s -p $1 -r 0 -v $new" >> $test_log
+	fi
+}
+
+reset_all_phys()
+{
+	sleep_time=$1
+
+	if [ "x$CONFIG_RAETH_ROUTER" != "xy" -a "x$CONFIG_RT_3052_ESW" != "xy" ]; then
+		return
+	fi
+
+	opmode=`nvram_get 2860 OperationMode`
+
+	#skip WAN port
+	if [ "x$opmode" != "x1" ]; then #no wan port
+		link_down 0
+		link_down 4
+	elif [ "x$CONFIG_WAN_AT_P4" = "xy" ]; then #wan port at port4
+		link_down 0
+	elif [ "x$CONFIG_WAN_AT_P0" = "xy" ]; then #wan port at port0
+		link_down 4
+	fi
+	link_down 1
+	link_down 2
+	link_down 3
+
+	#force Windows clients to renew IP and update DNS server
+	sleep $sleep_time
+
+	#skip WAN port
+	if [ "x$opmode" != "x1" ]; then #no wan port
+		link_up 0
+		link_up 4
+	elif  [ "x$CONFIG_WAN_AT_P4" = "xy" ]; then #wan port at port4
+		link_up 0
+	elif [ "x$CONFIG_WAN_AT_P0" = "xy" ]; then #wan port at port0
+		link_up 4
+	fi
+	link_up 1
+	link_up 2
+	link_up 3
+}
+
+# argv 1 is empty
+if [ "$1" = "" ]; then
+  usage
+fi
+
+# argv 2 is empty
+if [ "$2" = "" ]; then
+  if [ "$1" != "-r" -a "$1" != "-k" -a "$1" != "-S" ]; then
+      usage
+  fi
+fi
+
+
+if [ "x$1" == "xlan" ]; then
+    fname=$path_conf"/udhcpd.conf"
+    fbak=$path_conf"/udhcpd.conf_bak"
+    pidfile=$path_conf"/udhcpd.pid"
+    leases=$path_conf"/udhcpd.leases"
+else
+    fname=$path_conf"/udhcpd"$1".conf"
+    fbak=$path_conf"/udhcpd"$1".conf_bak"
+    pidfile=$path_conf"/udhcpd"$1".pid"
+    leases=$path_conf"/udhcpd"$1".leases"
+fi
+fname_static=$path_conf"/static_macip_file"
+fbak_static=$path_conf"/static_macip_file_bak"
+touch $fname  
+	
+case "$2" in
+  
+  "-r")
+    
+    if [ -e ${pidfile} ]; then
+      kill `cat $pidfile`
+    fi
+    rm -f $pidfile
+    touch $leases
+	sed '/^lease_file /d' $fname > $fbak
+	cat $fbak > $fname
+    echo "lease_file $leases" >> $fname
+    linenum=`cat $fname|wc -l`
+    if [ $linenum -ne 9 -a "$dhcp_type" == "lan" ]; then
+        . $path_sh/user-config-udhcpd.sh
+    fi
+    udhcpd -f $fname &
+	reset_all_phys $3
+		;;
+  "-h") usage;;
+  "-p") config "$2" "$3";;
+  "-l") config "$2" "$3";;
+  "-s") config "$2" "$3";;
+  "-e") config "$2" "$3";;
+  "-i") config "$2" "$3";;
+  "-d") config "$2" "$3" "$4";;
+  "-m") config "$2" "$3";;
+  "-g") config "$2" "$3";;
+  "-t") config "$2" "$3";;
+  "-S") config "$2" "$3" "$4";;
+  "-D") config "$2" "$3";;
+  "-E") config "$2";;
+  "-k")
+    if [ -e ${pidfile} ]; then
+      kill `cat $pidfile`
+    fi
+    rm -f $pidfile ;;
+  "-x") config "$2" "$3";;
+  "-y") config "$2" "$3";;
+  *) usage;;
+esac
+
+
diff --git a/ap/app/Script/scripts/customer_type.sh b/ap/app/Script/scripts/customer_type.sh
new file mode 100644
index 0000000..aa3a7d4
--- /dev/null
+++ b/ap/app/Script/scripts/customer_type.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+# ´Ë½Ç¶ÈÓÃÓÚ¿Í»§¶¨Öƹ¦ÄÜ
+
+# Ϊ¹úµç¶¨ÖÆ£¬Èç¹ûÊǹúµç£¬Ç¿Ðгõʼ»¯¹úµçÏà¹ØNV£¬ÐèÒªÔÚÏà¹ØÓ¦ÓÃÆô¶¯Ç°
+customer_type=$(nv get customer_type)
+if [ x"${customer_type}" == x"guodian" ];then
+    # fota
+    nv set fota_updateMode=0
+    nv set pwron_auto_check=0
+    # mmi
+    nv set mmi_showmode=led
+    nv set mmi_task_tab=net_task+ctrl_task
+    nv set mmi_led_mode=sleep_mode
+    zte_mmi &
+    # uart
+    nv set self_adaption_port=/dev/ttyS0
+elif [ x"${customer_type}" == x"nandian" ]; then
+    # fota
+    nv set fota_updateMode=0
+    nv set pwron_auto_check=0
+    # mmi
+    nv set mmi_showmode=led
+    nv set mmi_task_tab=net_task+ctrl_task+key_task
+    nv set mmi_led_mode=sleep_mode
+    zte_mmi &
+    # uart
+    nv set self_adaption_port=/dev/ttyS0
+fi
diff --git a/ap/app/Script/scripts/ddns.sh b/ap/app/Script/scripts/ddns.sh
new file mode 100644
index 0000000..baac6c0
--- /dev/null
+++ b/ap/app/Script/scripts/ddns.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# $Id: ddns.sh,v 1.1 2007-09-24 09:34:52 winfred Exp $
+#
+# usage: ddns.sh
+#
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+echo "Info: ddns.sh start" >> $test_log
+
+srv=`nv get DDNSProvider`
+ddns=`nv get DDNS`
+ddns_hash=`nv get DDNS_Hash_Value`
+u=`nv get DDNSAccount`
+pw=`nv get DDNSPassword`
+ddns_enable=`nv get DDNS_Enable`
+
+killall -q inadyn
+rm -rf $path_conf/inadyn.status
+
+if [ "x$ddns_enable" = "x0" ]; then
+	exit 0
+fi
+if [ "x$srv" = "x" -o "x$srv" = "xnone" ]; then
+	exit 0
+fi
+if [ "x$ddns" = "x" -o "x$u" = "x" -o "x$pw" = "x" ]; then
+	exit 0
+fi
+
+# debug
+echo "srv=$srv"
+echo "ddns=$ddns"
+echo "ddns_hash=$ddns_hash"
+echo "u=$u"
+echo "pw=$pw"
+
+
+if [ "x$srv" = "xdyndns.org" ]; then
+	inadyn -u $u -p $pw -a $ddns --dyndns_system dyndns@$srv &
+elif [ "x$srv" = "xfreedns.afraid.org" ]; then
+	inadyn -u $u -p $pw -a $ddns,$ddns_hash --dyndns_system default@$srv &
+elif [ "x$srv" = "xzoneedit.com" ]; then
+	inadyn -u $u -p $pw -a $ddns --dyndns_system default@$srv &
+elif [ "x$srv" = "xno-ip.com" ]; then
+	inadyn -u $u -p $pw -a $ddns --dyndns_system default@$srv &
+else
+	inadyn -u $u -p $pw -a $ddns --dyndns_system default@$srv &
+	echo "unknown DDNS provider: $srv"
+fi
+
diff --git a/ap/app/Script/scripts/defwan_set.sh b/ap/app/Script/scripts/defwan_set.sh
new file mode 100644
index 0000000..bac6f8f
--- /dev/null
+++ b/ap/app/Script/scripts/defwan_set.sh
@@ -0,0 +1,144 @@
+#!/bin/sh
+
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+echo "Info: defwan_set.sh $1 start" >> $test_log
+nd_dns=`nv get lan_ipaddr`
+#linuxϵͳetcĿ¼¿É¶Áд£¬resolv.conf¿ÉÒÔÖ±½Ó·ÅÔÚetcÏ£¬Í¬²½uc´úÂëʱעÒâ²»Òª½«´Ë´¦Í¬²½
+resolv_conf=/etc/resolv.conf
+dnsmasq_conf=$path_conf/dnsmasq.conf
+
+killall -9 dnsmasq
+def_cid=`nv get default_cid`
+
+if [ "-$1" == "-pswan" ]; then
+    ipaddr_type=`nv get "pdp_act_type"$def_cid`
+elif [ "-$1" == "-ethwan" ]; then
+    ipaddr_type=`nv get eth_act_type`
+elif [ "-$1" == "-wifiwan" ]; then
+    ipaddr_type=`nv get wifi_act_type`
+fi
+
+#»ñȡĬÈÏÍø¿Ú
+wan_if=$defwan_if
+wan6_if=$defwan6_if
+
+echo "" > $dnsmasq_conf
+
+#Èç¹û±¾µØÓ¦ÓÃÐèҪʹÓÃdnsmasqµÄ¹¦ÄÜ£¬ÐèÒªÔÚ"/etc/resolv.conf" ÎļþÖÐÌí¼Ó "127.0.0.1"£¬±ØÐë·ÅÔÚµÚÒ»Ìõ
+echo "" > $resolv_conf
+echo nameserver 127.0.0.1 > $resolv_conf
+
+
+#DNS¶ÔÓÚÍ¬Ò»Íø¿Ú£¬²»Çå³þ½«À´ÐèÇóÊÇ·ñÖ§³Ö·Ö±ð¶Ôv4¡¢v6½øÐÐauto¡¢manualÉèÖ㬴˴¦ÔÝʱ×ö³É¿É·Ö±ðÉèÖÃ
+#ÉèÖÃIPv4 ȱʡ·ÓÉ DNS
+if [ "-$ipaddr_type" == "-IPv4" -o "-$ipaddr_type" == "-IPv4v6" -o "-$ipaddr_type" == "-IPV4V6" -o "-$ipaddr_type" == "-" ];then
+	#ÉèÖÃIPv4µÄĬÈÏÍø¹Ø
+	route del default
+	Flag=`route | grep -w "default"`
+	if [ "-$Flag" != "-" ];then
+	    echo "Error: route del default failed." >> $test_log
+	fi
+
+	defwan_gw=`nv get $wan_if"_gw"`
+	if [ "-$defwan_gw" != "-" -o "-$defwan_rel" != "-" ];then
+        route add default gw $defwan_gw dev $defwan_rel 2>>$test_log
+	    if [ $? -ne 0 ];then
+	        echo "Error: route add default gw $defwan_gw dev $defwan_rel failed." >> $test_log
+	    fi
+	fi
+	
+  
+
+    
+	#dnsmodeÓÉatserver´¦Àí£¬´«Êµ¼ÊʹÓõÄÖµ£¬´Ë´¦½öʹÓÃÒ»¸önv£¬²»Çø·Öauto manual
+	dns_mode=`nv get $1"_dns_mode"`
+	if [ "-$1" == "-pswan" -o "-$dns_mode" == "-auto" -o "-$dns_mode" == "-" ]; then
+	        pridns=`nv get $wan_if"_pridns"`
+		    secdns=`nv get $wan_if"_secdns"`
+	elif [ "-$dns_mode" == "-manual" ]; then	
+		pridns=`nv get $1"_pridns_manual"`
+		secdns=`nv get $1"_secdns_manual"`
+	fi
+	
+	if [ "-$pridns" == "-" -o "-$pridns" == "-0.0.0.0" ] && [ "-$secdns" == "-" -o "-$secdns" == "-0.0.0.0" ]; then
+		pridns="114.114.114.114"
+		secdns="8.8.8.8"
+	fi
+	
+	if [ "-$pridns" != "-" -a "-$pridns" != "-0.0.0.0" ]; then
+		echo nameserver $pridns > $dnsmasq_conf
+	fi
+	if [ "-$secdns" != "-" -a "-$secdns" != "-0.0.0.0" ]; then
+		echo nameserver $secdns >> $dnsmasq_conf
+	fi
+		
+	dns_extern=`nv get dns_extern`
+	if [ -n "$dns_extern" ]; then
+		echo nameserver $dns_extern >> $dnsmasq_conf
+	fi
+	if [ "-$1" == "-pswan" ]; then
+		tc_tbf.sh up $def_cid
+	fi
+fi
+
+#ÒÑÉèÖúÃÍâÍø¿ÚÔò¿ª×ª·¢
+if [ "-$wan_if" != "-" ]; then
+	echo 1 > /proc/sys/net/ipv4/ip_forward
+fi
+
+#ÉèÖÃIPv6 DNS
+if [ "-$ipaddr_type" == "-IPv6" -o "-$ipaddr_type" == "-IPV6" -o "-$ipaddr_type" == "-IPv4v6" -o "-$ipaddr_type" == "-IPV4V6" ];then
+	#dnsmodeÓÉatserver´¦Àí£¬´«Êµ¼ÊʹÓõÄÖµ£¬´Ë´¦½öʹÓÃÒ»¸önv£¬²»Çø·Öauto manual
+	ipv6_dns_mode=`nv get $1"_ipv6_dns_mode"`
+	if [ "-$1" == "-pswan" -o "-$ipv6_dns_mode" == "-auto" -o "-$ipv6_dns_mode" == "-" ]; then
+	    ipv6_pridns=`nv get $wan6_if"_ipv6_pridns_auto"`
+        ipv6_secdns=`nv get $wan6_if"_ipv6_secdns_auto"`
+	elif [ "-$ipv6_dns_mode" == "-manual" ]; then	
+            ipv6_pridns=`nv get $1"_ipv6_pridns_manual"`
+            ipv6_secdns=`nv get $1"_ipv6_secdns_manual"`
+	fi
+    
+    nv set $wan6_if"_radvd_ipv6_dns_servers"=$ipv6_pridns,$ipv6_secdns
+	
+    if [ -n "$ipv6_pridns" ] && [ "$ipv6_pridns" != "::" ] && [ "$ipv6_pridns" != "::0" ] && [ "$ipv6_pridns" != "0000:0000:0000:0000:0000:0000:0000:0000" ];then
+        echo nameserver $ipv6_pridns >> $dnsmasq_conf
+    fi
+            
+    if [ -n "$ipv6_secdns" ] && [ "$ipv6_secdns" != "::" ] && [ "$ipv6_secdns" != "::0" ] && [ "$ipv6_secdns" != "0000:0000:0000:0000:0000:0000:0000:0000" ];then
+        echo nameserver $ipv6_secdns >> $dnsmasq_conf
+    fi
+		
+	ipv6_dns_extern=`nv get ipv6_dns_extern`
+	if [ -n "$ipv6_dns_extern" ]; then
+		echo nameserver $ipv6_dns_extern >> $dnsmasq_conf
+	fi	
+    if [ "-$1" == "-pswan" ]; then
+		tc_tbf.sh up $def_cid
+	fi
+fi
+
+nv set $wan6_if"_radvd_ipv6_dns_servers"=$ipv6_pridns,$ipv6_secdns
+
+#ÉèÖøøÒ³ÃæÏÔʾµ±Ç°ÍâÍøIPµØÖ·
+#ÉèÖÃIPv4Ò³ÃæÏÔʾµØÖ·
+if [ "-$ipaddr_type" == "-IPv4" -o "-$ipaddr_type" == "-IPV4" -o "-$ipaddr_type" == "-IPv4v6" -o "-$ipaddr_type" == "-IPV4V6" -o "-$ipaddr_type" == "-" ]; then
+    wan4_ip=`nv get $wan_if"_ip"`
+    nv set wan_ipaddr="$wan4_ip"
+fi
+
+#ÉèÖÃIPv6Ò³ÃæÏÔʾµØÖ·
+if [ "-$ipaddr_type" == "-IPv6" -o "-$ipaddr_type" == "-IPV6" -o "-$ipaddr_type" == "-IPv4v6" -o "-$ipaddr_type" == "-IPV4V6" ]; then
+    wan6_ip=`nv get $wan6_if"_ipv6_ip"`
+    nv set ipv6_wan_ipaddr="$wan6_ip"
+fi
+
+dnsmasq -i $lan_if -r $dnsmasq_conf &
+
+# ppp0ÐèÒªÉèÖÃMSS×Ϊ1440£¬·ñÔò¿ÉÄÜtcp²»Í¨
+if [ "$defwan_rel" == "ppp0"  ]; then
+    echo "Info: dns_set ppp0 set MSS 1440" >> $test_log
+    iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1440
+fi
+
+
diff --git a/ap/app/Script/scripts/firewall_init.sh b/ap/app/Script/scripts/firewall_init.sh
new file mode 100644
index 0000000..b28f885
--- /dev/null
+++ b/ap/app/Script/scripts/firewall_init.sh
@@ -0,0 +1,79 @@
+#!/bin/sh
+# Created by LiuWei @ 2010.8.27 
+# init firewall
+#
+
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+echo "Info: firewall_init.sh start" >> $test_log
+
+
+ZTE_FILTER_CHAIN=macipport_filter
+ZTE_WEB_FILTER_CHAIN=web_filter
+ZTE_CLILDREN_CHAIN=children_filter
+ZTE_CLILDREN_WEB_CHAIN=children_web_filter
+ZTE_CLILDREN_WEB_PHONECHAIN=children_web_filter_phone
+
+#clear filter
+iptables -t filter -F
+iptables -t filter -X $ZTE_FILTER_CHAIN
+iptables -t filter -X $ZTE_WEB_FILTER_CHAIN
+iptables -t filter -X $ZTE_CLILDREN_CHAIN
+iptables -t filter -X $ZTE_CLILDREN_WEB_CHAIN
+iptables -t filter -X $ZTE_CLILDREN_WEB_PHONECHAIN
+
+ip6tables -t filter -F
+ip6tables -t filter -X $ZTE_FILTER_CHAIN 
+
+#make a new chain for filter
+iptables -t filter -N $ZTE_FILTER_CHAIN
+iptables -t filter -N $ZTE_WEB_FILTER_CHAIN
+iptables -t filter -N $ZTE_CLILDREN_CHAIN
+iptables -t filter -N $ZTE_CLILDREN_WEB_CHAIN
+iptables -t filter -N $ZTE_CLILDREN_WEB_PHONECHAIN
+ip6tables -t filter -N $ZTE_FILTER_CHAIN 
+
+iptables -t filter -A FORWARD -j $ZTE_WEB_FILTER_CHAIN
+iptables -t filter -A FORWARD -j $ZTE_FILTER_CHAIN
+iptables -t filter -A FORWARD -j $ZTE_CLILDREN_CHAIN
+iptables -t filter -A INPUT -j $ZTE_CLILDREN_WEB_CHAIN
+iptables -t filter -A FORWARD -j $ZTE_CLILDREN_WEB_PHONECHAIN
+ip6tables -t filter -A FORWARD -j $ZTE_FILTER_CHAIN 
+
+ip6tables -t filter -A $ZTE_FILTER_CHAIN -m state --state RELATED,ESTABLISHED -j ACCEPT
+
+#Close unused port
+iptables -t filter -A INPUT -i $defwan_rel -p udp --dport 53 -j DROP
+iptables -t filter -A INPUT -i $defwan_rel -p tcp --dport 53 -j DROP
+iptables -t filter -A INPUT -p tcp --dport 7777 -j DROP
+iptables -t filter -A INPUT -p udp --dport 7777 -j DROP
+iptables -t filter -I INPUT -i $defwan_rel -p icmp --icmp-type echo-reply -j ACCEPT
+
+permit_gw=`nv get permit_gw`
+permit_nm=`nv get permit_nm`
+if [ "-${permit_gw}" != "-" ]; then
+	iptables -A FORWARD -o $defwan_rel -d $permit_gw/$permit_nm -j ACCEPT
+	iptables -A FORWARD -o $defwan_rel -j DROP
+	iptables -A OUTPUT -o $defwan_rel -d $permit_gw/$permit_nm -j ACCEPT
+	iptables -A OUTPUT -o $defwan_rel -j DROP
+fi
+
+permit_ip6=`nv get permit_ip6`
+if [ "-${permit_ip6}" != "-" ]; then
+	ip6tables -A FORWARD -o $defwan6_rel -d $permit_ip6 -j ACCEPT
+	ip6tables -A FORWARD -o $defwan6_rel -j DROP
+	ip6tables -A OUTPUT -o $defwan6_rel -d $permit_ip6 -j ACCEPT
+	ip6tables -A OUTPUT -o $defwan6_rel -j DROP
+fi
+
+
+if [ "-$defwan_rel" == "-ppp0" ]; then
+	mtu=`nv get mtu`
+	pppoe_mtu=`expr $mtu - 60`
+	iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss $pppoe_mtu
+else
+	iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
+fi
+# firewall will flush nat and filter, so upnp should run after it.
+#sh $path_sh/upnp.sh
+
diff --git a/ap/app/Script/scripts/fota_release_space.sh b/ap/app/Script/scripts/fota_release_space.sh
new file mode 100755
index 0000000..dfe8908
--- /dev/null
+++ b/ap/app/Script/scripts/fota_release_space.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+echo "Begin release space..."
+
+#ɱµôÓ¦ÓÃ
+killall at_ctl
+killall dnsmasq
+killall radvd
+killall dhcp6
+killall zte_ndp
+killall zte_mainctrl
+killall zte_hotplug
+killall sntp
+killall rtc-service
+killall zte_audio_ctrl
+killall sms
+killall phonebook
+#EC 616000558980
+#killall zte_mmi
+
+killall fluxstat
+killall goahead
+killall wpa_supplicant-2.6
+killall hostapd
+killall zte_volte
+killall wifi_manager
+killall hostapd 
+killall udhcpd
+killall sd_hotplug
+
+killall syslogd
+rm -rf /var/log
+
+#EC 616000558980
+killall zte_mifi
+killall zte_cpe
+echo 7 >/proc/sys/vm/drop_caches
+
+#¿ÉÄÜ»¹ÒªÉ¾³ýijЩռÄÚ´æµÄÏß³Ì
+
diff --git a/ap/app/Script/scripts/gateway_send_arp.sh b/ap/app/Script/scripts/gateway_send_arp.sh
new file mode 100644
index 0000000..6a8664a
--- /dev/null
+++ b/ap/app/Script/scripts/gateway_send_arp.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+test_log=`nv get path_log`"te.log"
+
+lan_if=br0
+
+ip=`nv get lan_ipaddr`
+
+arping -U -I $lan_if -c 1 $ip
+
diff --git a/ap/app/Script/scripts/get_errinfo.sh b/ap/app/Script/scripts/get_errinfo.sh
new file mode 100644
index 0000000..5ac323d
--- /dev/null
+++ b/ap/app/Script/scripts/get_errinfo.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+line=`grep "^$1" -n /sbin/app_errmsg.txt | awk -F: '{print $1}'`
+awk -F= -v c=$2 -v n=$line '(NR - n == c) {print $2}' /sbin/app_errmsg.txt
diff --git a/ap/app/Script/scripts/getpid.sh b/ap/app/Script/scripts/getpid.sh
new file mode 100644
index 0000000..bb28f3f
--- /dev/null
+++ b/ap/app/Script/scripts/getpid.sh
@@ -0,0 +1,12 @@
+#/bin/sh
+
+TMPLINE=`ps|grep -s "[[:digit:]]\+:[[:digit:]]\+ \(/.*/\)*$1\>"`
+
+if [ -z "${TMPLINE}" ]; then
+		echo "nono"
+		exit 127
+else
+	echo "${TMPLINE}"|awk '{print $1}'
+	exit 0
+fi
+
diff --git a/ap/app/Script/scripts/global.sh b/ap/app/Script/scripts/global.sh
new file mode 100755
index 0000000..f39ba94
--- /dev/null
+++ b/ap/app/Script/scripts/global.sh
@@ -0,0 +1,87 @@
+#!/bin/sh
+
+#
+#¸Ã½Å±¾ÓÃÓÚ»ñȡһЩͨÓõÄnv±äÁ¿¼°¶¨Ò幫¹²º¯ÊýʹÓÃ
+#
+
+####»ñȡͨÓÃnv±äÁ¿####
+path_conf=`nv get path_conf`
+test_log=`nv get telog_path`
+if [ "$test_log" == "" ]; then
+	test_log=`nv get path_log`"te.log"
+fi
+path_tmp=`nv get path_tmp`
+path_ro=`nv get path_ro`
+
+##getLanIfName
+lan_if=`nv get lan_name`
+#echo "LanIfName=$lan_if"
+
+##getWanIfName
+pswan_name=`nv get pswan`
+def_cid_tmp=`nv get default_cid`
+pswan_if=$pswan_name$def_cid_tmp
+ethwan_if=`nv get ethwan`
+wifiwan_if=`nv get wifiwan`
+
+#ipv4
+defwan_if=`nv get default_wan_name`
+defwan_rel=`nv get default_wan_rel`
+
+#ipv6
+defwan6_if=`nv get default_wan6_name`
+defwan6_rel=`nv get default_wan6_rel`
+
+####¹«¹²º¯Êý####
+#²éÕÒ¶ÔÓ¦dhcpc½ø³ÌºÅ²¢É±ËÀ
+udhcpc_kill()
+{
+	ps > ${path_tmp}/udhcpc.sh.$$
+	udhcpc_pid=`awk 'BEGIN{temp1="'"${wan_if}"'";temp2="'$path_sh/udhcpc.sh'"}{if(index($0,temp1)>0 && index($0,temp2)>0){print $1}}' ${path_tmp}/udhcpc.sh.$$`
+	rm -f ${path_tmp}/udhcpc.sh.$$
+	[ -n "$udhcpc_pid" ] && { kill -9 $udhcpc_pid; echo "Info: kill udhcpc $udhcpc_pid " >> $test_log ; }
+}
+#²éÕÒ¶ÔÓ¦pppoe½ø³ÌºÅ²¢É±ËÀ
+pppoe_kill()
+{
+	ps > ${path_tmp}/pppoecd.${wan_if}.$$
+	pppoe_pid=`awk 'BEGIN{temp1="'"${wan_if}"'";temp2="pppoecd"}{if(index($0,temp1)>0 && index($0,temp2)>0){print $1}}' ${path_tmp}/pppoecd.${wan_if}.$$`
+	rm -f ${path_tmp}/pppoecd.${wan_if}.$$
+	[ -n "$pppoe_pid" ] && { kill -9 $pppoe_pid; echo "Info: kill pppoecd $pppoe_pid " >> $test_log ; }
+}
+#²éÕÒ¶ÔÓ¦dhcp6s½ø³ÌºÅ²¢É±ËÀ
+dhcp6s_kill()
+{
+	ps > ${path_tmp}/${dhcp6s_conf##*/}.$$
+	dhcp6s_pid=`awk 'BEGIN{temp1="'"${dhcp6s_conf}"'";temp2="dhcp6s"}{if(index($0,temp1)>0 && index($0,temp2)>0){print $1}}' ${path_tmp}/${dhcp6s_conf##*/}.$$`
+	rm -f ${path_tmp}/${dhcp6s_conf##*/}.$$
+    [ -n "$dhcp6s_pid" ] && { kill -9 $dhcp6s_pid; echo "Info: kill dhcp6s $dhcp6s_pid " >> $test_log ; }
+}
+
+#²éÕÒ¶ÔÓ¦radvd½ø³ÌºÅ²¢É±ËÀ
+radvd_kill()
+{
+	ps > ${path_tmp}/${radvd_conf##*/}.$$
+	radvd_pid=`awk 'BEGIN{temp1="'"${radvd_conf}"'";temp2="radvd"}{if(index($0,temp1)>0 && index($0,temp2)>0){print $1}}' ${path_tmp}/${radvd_conf##*/}.$$`
+	rm -f ${path_tmp}/${radvd_conf##*/}.$$
+    [ -n "$radvd_pid" ] && { kill -9 $radvd_pid; echo "Info: kill radvd $radvd_pid " >> $test_log ; }
+}
+
+#²éÕÒ¶ÔÓ¦dhcp6c½ø³ÌºÅ²¢É±ËÀ
+dhcp6c_kill()
+{
+	ps > ${path_tmp}/dhcp6c.${wan_if}.$$
+	dhcp6c_pid=`awk 'BEGIN{temp1="'"${wan_if}"'";temp2="dhcp6c"}{if(index($0,temp1)>0 && index($0,temp2)>0){print $1}}' ${path_tmp}/dhcp6c.${wan_if}.$$`
+	rm -f ${path_tmp}/dhcp6c.${wan_if}.$$
+    [ -n "$dhcp6c_pid" ] && { kill -9 $dhcp6c_pid; echo "Info: kill dhcp6c $dhcp6c_pid " >> $test_log ; }
+}
+
+#²éÕÒ¶ÔÓ¦ndp½ø³ÌºÅ²¢É±ËÀ
+ndp_kill()
+{
+	ps > ${path_tmp}/${ndp_log##*/}.$$
+	ndp_pid=`awk 'BEGIN{temp1="'"${ndp_log}"'";temp2="zte_ndp"}{if(index($0,temp1)>0 && index($0,temp2)>0){print $1}}' ${path_tmp}/${ndp_log##*/}.$$`
+	rm -f ${path_tmp}/${ndp_log##*/}.$$
+    [ -n "$ndp_pid" ] && { kill -9 $ndp_pid; echo "Info: kill ndp $ndp_pid " >> $test_log ; }
+}
+
diff --git a/ap/app/Script/scripts/internet.sh b/ap/app/Script/scripts/internet.sh
new file mode 100755
index 0000000..b9ff044
--- /dev/null
+++ b/ap/app/Script/scripts/internet.sh
@@ -0,0 +1,116 @@
+#!/bin/sh
+#
+# internet.sh,v 10.08.05 2010-08-05 15:00:00
+#
+# usage: internet.sh
+#
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+echo "Info: internet.sh start" > $test_log
+echo "Info: `date +%m-%d %H:%M:%S`" >> $test_log
+
+genSysFiles()
+{
+	login=`nv get Login`
+	pass=`nv get Password`
+	echo "$login::0:0:Adminstrator:/:/bin/sh" > /etc/passwd
+	echo "$login:x:0:$login" > /etc/group
+	echo "$login:$pass" > /tmp/tmpchpw
+	chpasswd < /tmp/tmpchpw
+	rm -f /tmp/tmpchpw
+}
+user_login=`cat /etc/passwd | grep admin`
+#user_login²»´æÔÚ»òΪ¿ÕʱºòÖ´Ðк¯ÊýgenSysFiles
+[ -n "$user_login" ] || { genSysFiles;}
+
+safe_run()
+{
+    ps_tmp=`nv get path_log`"ps.tmp"
+    ps > ${ps_tmp}
+	flag=`grep -w "$1" ${ps_tmp}`
+	if [ "-${flag}" = "-" ];then
+		$1 &
+	fi
+	rm -rf ${ps_tmp}
+}
+
+#¶¯Ì¬nvÖÿÕ
+#. $path_sh/cfgnv_init.sh
+pswan=`nv get pswan`
+ethwan=`nv get ethwan`
+wifiwan=`nv get wifiwan`
+echo 0 > /proc/sys/net/ipv6/conf/$pswan"1"/accept_ra
+echo 0 > /proc/sys/net/ipv6/conf/$pswan"2"/accept_ra
+echo 0 > /proc/sys/net/ipv6/conf/$pswan"3"/accept_ra
+echo 0 > /proc/sys/net/ipv6/conf/$pswan"4"/accept_ra
+echo 0 > /proc/sys/net/ipv6/conf/$pswan"5"/accept_ra
+echo 0 > /proc/sys/net/ipv6/conf/$pswan"6"/accept_ra
+echo 0 > /proc/sys/net/ipv6/conf/$pswan"7"/accept_ra
+echo 0 > /proc/sys/net/ipv6/conf/$pswan"8"/accept_ra
+if [ "-$ethwan" != "-" ]; then
+    echo 0 > /proc/sys/net/ipv6/conf/$ethwan/accept_ra
+fi
+if [ "-$wifiwan" != "-" ]; then
+    echo 0 > /proc/sys/net/ipv6/conf/$wifiwan/accept_ra
+fi
+
+#°²È«ÒªÇó
+echo 0 > /proc/sys/net/ipv4/conf/all/send_redirects
+echo 0 > /proc/sys/net/ipv4/conf/default/send_redirects
+echo 0 > /proc/sys/net/ipv4/conf/all/accept_redirects
+echo 0 > /proc/sys/net/ipv4/conf/default/accept_redirects
+echo 0 > /proc/sys/net/ipv6/conf/all/accept_redirects
+echo 0 > /proc/sys/net/ipv6/conf/default/accept_redirects
+echo 0 > /proc/sys/net/ipv4/conf/all/secure_redirects
+echo 0 > /proc/sys/net/ipv4/conf/default/secure_redirects
+
+#EC ÉèÖÃÁ¬½Ó¸ú×Ù×î´óÖµ,·Åµ½rcÀïÃæÅäÖÃ
+#echo 2000 > /proc/sys/net/nf_conntrack_max
+echo 7200 > /proc/sys/net/netfilter/nf_conntrack_tcp_timeout_established
+
+#zte_mainctrl &
+
+#½«br_name,usblan_name´«¸øÄÚºËʵÏÖÆ½Ì¨»¯
+fast_usb=`nv get fast_usb`
+lan_enable=`nv get LanEnable`
+
+#LanEnableΪ2ʱºòûÓÐbr£¬²»ÐèҪдbr_name
+if [ "$lan_enable" != "2" ]; then
+    echo $lan_if > /proc/net/br_name
+fi
+
+echo $fast_usb > /proc/net/usb_name
+
+echo "" > /etc/resolv.conf
+
+#br0´î½¨£¬¼°ÄÚÍødhcp
+sh $path_sh/lan.sh
+
+#½«¿ìËÙת·¢¼¶±ð´«¸øÄÚºË
+fastnat_level=`nv get fastnat_level`
+echo "Info: set fastnat_level£º$fastnat_level" >> $test_log
+echo $fastnat_level > /proc/net/fastnat_level
+
+#½«²»Ö§³Ö¿ìËÙת·¢µÄЭÒé¶Ë¿ÚºÅ´«¸øÄÚºË
+nofast_port=`nv get nofast_port`
+echo "Info: set nofast_port£º$nofast_port" >> $test_log
+echo $nofast_port > /proc/net/nofast_port
+
+#SKB debug¿ª¹Ø
+skb_debug=`nv get skb_debug`
+echo "Info: set skb_debug£º$skb_debug" >> $test_log
+if [ "-$skb_debug" != "-1" ]; then
+    echo 0 > /proc/net/skb_debug_off
+fi
+
+killall -9 miniupnpd
+rm -rf $path_conf/inadyn.status
+
+#¼Ç¼½ø³Ì±»ºÎÖÖÐźÅkilledµô
+netdog -s exitsig=1
+
+#¼à¿ØÄÚºËskbÏà¹ØÐÅÏ¢µÄ×î´óÖµ
+#safe_run netmonitor
+
+#¼à¿ØÄں˵Änetlinkʼþ´æÎļþ£¬Ö§³ÖÄÚºË×Ô¶¨Òåʼþ£¬Òò»áдflash°æ±¾Ä¬ÈϹرÕ
+#safe_run event_proc
diff --git a/ap/app/Script/scripts/lan.sh b/ap/app/Script/scripts/lan.sh
new file mode 100755
index 0000000..407c47b
--- /dev/null
+++ b/ap/app/Script/scripts/lan.sh
@@ -0,0 +1,145 @@
+#!/bin/sh
+#
+# $Id: lan.sh
+#
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+
+br_set()
+{
+    br_name=$lan_if
+
+    #ÉèÖÃÍøÇÅ
+    killall -9 udhcpd
+    echo "ifconfig $br_name down...................."
+    ifconfig $br_name down
+
+    echo "brctl delbr $br_name......................"
+    brctl delbr $br_name
+
+    echo "brctl addbr $br_name......................"
+    brctl addbr $br_name 2>>$test_log
+    if [ $? -ne 0 ];then
+        echo "Error: brctl addbr $br_name failed." >> $test_log
+    fi
+    echo "brctl setfd $br_name 0.1.................."
+    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
+    echo "ifconfig lo up......................."
+    ifconfig lo up 2>>$test_log
+    if [ $? -ne 0 ];then
+        echo "Error: ifconfig lo up failed." >> $test_log
+    fi
+    echo "ifconfig $br_name up......................"
+    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
+    
+    br_node=`nv get br_node`
+
+    #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`
+    nm=`nv get lan_netmask`
+    ifconfig $lan_if $ip netmask $nm 2>>$test_log
+    if [ $? -ne 0 ];then
+        echo "Error: ifconfig $lan_if $ip netmask $nm failed." >> $test_log
+    fi
+
+    webv6_enable=`nv get webv6_enable`
+    ipv6=`nv get lan_ipv6addr`
+    if [ "x$webv6_enable" == "x1" ]; then
+        ifconfig $lan_if $ipv6
+    if [ $? -ne 0 ];then
+        echo "Error: ifconfig $lan_if $ipv6 failed." >> $test_log
+    fi
+    fi
+}
+
+#½âÎöÄÚÍøµØÖ·¡¢Íø¹ØµØÖ·Í¨¹ýproc»úÖÆ¶¯Ì¬´«µÝ¸øÄںˣ¬ÒÔ±ãÄÚºËʵÏÖ·ÀÖ¹ÄÚÍøµØÖ·Ð¹Â¶¹¦ÄÜ
+lanip_proc()
+{
+    #ipµØÖ·»»Ëã³É4×Ö½ÚÕûÐÍÊÇÍøÂç×Ö½ÚÐò£¬Òªµßµ¹ÏÂ
+    #uclinux²»Ö§³Ö×óÒÆ×Ö·û
+	ip_value=`echo "$ip" | awk -F '.' '{printf $1 + 256* $2 + 256*256* $3 + 256*256*256* $4}'`
+	nm_value=`echo "$nm" | awk -F '.' '{printf $1 + 256* $2 + 256*256* $3 + 256*256*256* $4}'`
+
+    echo $ip_value > /sys/module/lanip_filter_ipv4/parameters/lan_ipaddr
+    echo $nm_value > /sys/module/lanip_filter_ipv4/parameters/lan_netmask
+}
+
+main()
+{
+    lan_enable=`nv get LanEnable`
+    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" != "x" ]; then
+        lan_set
+    fi
+    
+    #vlanÅäÖã¬ÔÝʱ·ÅÓÚ´Ë´¦£¬1 ¿ª»úµÄʱºò²»ÐèÒª½«sw¼ÓÈëµ½ÍøÇÅÏ 
+    #2 ´Ë´¦±ØÐ뽫sw upÆðÀ´£¬Èç¹û²»upµÄ»°½«²»»áÓÐrj45ÈȲå°Îʼþ
+    sw_name=`nv get swvlan`
+    ifconfig $sw_name up
+    natenable=`nv get natenable`
+    dosenable=`nv get dosenable`
+    if [[ "x$natenable" != "x0" || "x$dosenable" != "x0" ]]; then
+        lanip_proc
+    fi
+    if [ "x$dosenable" != "x0" ]; then
+        echo 1 > /sys/module/fast_common/parameters/lan_dos_enable
+    fi
+
+
+
+
+    echo "" > $path_conf/udhcpd.leases
+
+    . $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
+
+    dnsmasq -i $lan_if -r $path_conf/resolv.conf &
+    . $path_sh/upnp.sh
+    
+	#»ñÈ¡br0µÄipv6µØÖ·
+    ipv6lanipaddrcmd="ifconfig $br_name | grep Scope:Link | sed 's/^.*addr: //g' | sed 's/\/.*$//g'"
+    ipv6lanipaddr=`eval $ipv6lanipaddrcmd`
+    nv set ipv6_lan_ipaddr=$ipv6lanipaddr
+}
+
+main
diff --git a/ap/app/Script/scripts/landev_updown.sh b/ap/app/Script/scripts/landev_updown.sh
new file mode 100644
index 0000000..8bf322e
--- /dev/null
+++ b/ap/app/Script/scripts/landev_updown.sh
@@ -0,0 +1,133 @@
+#!/bin/sh
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+echo "Info: landev_updown.sh $1 $2 start" >> $test_log
+lan_enable=`nv get LanEnable`
+
+xgw_lan()
+{
+	. $path_sh/xjz_init.sh                       
+	xgwlan=`nv get lan_name`
+	real_gw=`nv get  lan_ipaddr`
+	real_nm=`nv get  lan_netmask`
+	ifconfig $xgwlan down
+	ifconfig $xgwlan $real_gw netmask $real_nm up
+	if [ $? -ne 0 ];then
+		echo "Error: ifconfig $xgwlan $real_gw netmask $real_nm up failed." >> $test_log
+	fi
+		
+	echo "stop gtp_proxy .... " >> $test_log
+	killall -9 gtp_proxy
+	gtp_proxy &                    
+	echo "start gtp_proxy .... " >> $test_log   
+}
+
+landev_up()
+{
+	if [ "-$1" == "-ethwan" ]; then
+		(router_msg_proxy del_timer ethwan 1>> $test_log 2>&1 || echo "Error: router_msg_proxy del_timer failed." >> $test_log) &
+	fi
+	landev_name=`nv get $1`
+	if [ "-$lan_enable" == "-2" ]; then
+		
+			ip=`nv get lan_ipaddr`
+			nm=`nv get lan_netmask`
+			ifconfig $landev_name $ip netmask $nm up 2>>$test_log
+			if [ $? -ne 0 ];then
+				echo "Error: ifconfig $lan_if $ip netmask $nm failed." >> $test_log
+			fi
+
+	else
+		br_name=`nv get lan_name`
+		ifconfig $landev_name down 2>>$test_log
+		if [ $? -ne 0 ];then
+			echo "Error: ifconfig $landev_name down failed." >> $test_log
+		fi
+		ifconfig $landev_name up 2>>$test_log
+		if [ $? -ne 0 ];then
+			echo "Error: ifconfig $landev_name up failed." >> $test_log
+		fi
+		brctl addif $br_name $landev_name 
+
+	fi
+}
+
+landev_down()
+{
+	landev_name=`nv get $1`	
+	ifconfig $landev_name down 2>>$test_log
+	if [ $? -ne 0 ];then
+		echo "Error: ifconfig $landev_name down failed." >> $test_log
+	fi
+	if [ "-$lan_enable" == "-1" ]; then
+		br_name=`nv get lan_name`
+		brctl delif $br_name $landev_name 2>>$test_log
+		if [ $? -ne 0 ];then
+			echo "Error: brctl delif $br_name $landev_name" >> $test_log
+		fi
+	fi
+    if [ "-$lan_enable" == "-2" ]; then
+        ps > ${path_tmp}/landev_updown.sh.$$
+	    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.$$`
+	    rm -f ${path_tmp}/landev_updown.sh.$$
+	    [ -n "$udhcpd_pid" ] && { kill $udhcpd_pid; echo "Info: kill udhcpd $udhcpd_pid " >> $test_log ; }
+    fi
+}
+
+get_cid()
+{
+	ps_ext_cid=$1
+	c_id=${ps_ext_cid##ps_ext}
+}
+
+ps_ext_up()
+{
+	landev_name=`nv get $1`
+	get_cid $1
+    landev_name=`nv get $1`
+	get_cid $1
+    br="br"$c_id
+    br_ip6=`nv get $br"_ipv6_ip"`
+    up_flag="0"
+    if [ "-$br_ip6" != "-" -a "-$br_ip6" != "-::" ]; then
+        up_flag="1"
+    fi
+    br_ip=`nv get $br"_ip"`
+    if [ "-$br_ip" != "-" -a "-$br_ip" != "-0.0.0.0" ]; then
+        up_flag="1"
+    fi
+    if [ "-$up_flag" == "-1" ]; then
+        ifconfig $landev_name up 2>>$test_log
+        if [ $? -ne 0 ];then
+            echo "Error: ifconfig $landev_name up failed." >> $test_log
+        fi
+		#for usb remove netlink
+		brctl addif $br $landev_name
+    fi
+}
+
+ps_ext_down()
+{
+    landev_name=`nv get $1`
+    ifconfig $landev_name down 2>>$test_log
+    if [ $? -ne 0 ];then
+        echo "Error: ifconfig $landev_name down failed." >> $test_log
+    fi
+}
+
+if [ "-$1" == "-ethlan" -o "-$1" == "-wifilan" -o "-$1" == "-wifilan2" -o "-$1" == "-usblan" -o "-$1" == "-ethwan" ]; then
+	if [ "-$2" == "-up" ]; then
+		landev_up $1
+	else 
+		landev_down $1
+	fi
+else #ps_ext
+	ps_ext_state=`nv get $1"_pdpstate"`
+	if [ "-$ps_ext_state" == "-working" ]; then
+		if [ "-$2" == "-up" ]; then
+			ps_ext_up $1
+		else
+			ps_ext_down $1
+		fi
+	fi
+fi
\ No newline at end of file
diff --git a/ap/app/Script/scripts/nat.sh b/ap/app/Script/scripts/nat.sh
new file mode 100644
index 0000000..1c9b82e
--- /dev/null
+++ b/ap/app/Script/scripts/nat.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+#
+# $Id: nat.sh,v 1.4 2009-12-09 08:45:37 steven Exp $
+#
+# usage: nat.sh
+#
+
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+echo "Info: nat.sh start " >> $test_log
+
+ZTE_FORWARD_CHAIN=port_forward
+ZTE_DMZ_CHAIN=DMZ
+ZTE_MAPPING_CHAIN=port_mapping
+
+iptables -P INPUT ACCEPT
+iptables -P OUTPUT ACCEPT
+iptables -P FORWARD ACCEPT
+
+#clear nat
+iptables -t nat -F
+iptables -t nat -X $ZTE_FORWARD_CHAIN
+iptables -t nat -X $ZTE_DMZ_CHAIN
+iptables -t nat -X $ZTE_MAPPING_CHAIN
+
+
+#Make a new chain for nat
+iptables -t nat -N $ZTE_FORWARD_CHAIN
+iptables -t nat -N $ZTE_DMZ_CHAIN
+iptables -t nat -N $ZTE_MAPPING_CHAIN
+
+iptables -t nat -I PREROUTING 1 -j $ZTE_FORWARD_CHAIN
+iptables -t nat -I PREROUTING 1 -j $ZTE_DMZ_CHAIN
+iptables -t nat -I PREROUTING 1 -j $ZTE_MAPPING_CHAIN
+	
+	lan_en=`nv get LanEnable`
+	nat_en=`nv get natenable`
+	if [ "-$nat_en" != "-0" -a "-$lan_en" == "-2" ]; then
+	    iptables -t nat -A POSTROUTING -o ${defwan_rel%:*} -j MASQUERADE
+	elif [ "-$nat_en" != "-0" -a "-$lan_en" != "-0" ]; then
+		iptables -t nat -A POSTROUTING -o $defwan_rel -j MASQUERADE
+	fi
+
+clat46_en=1
+	if [ "-$clat46_en" = "-1" ]; then
+		iptables -t nat -A POSTROUTING -o clat4 -j MASQUERADE
+	fi
+  
+  
diff --git a/ap/app/Script/scripts/netdog_init_set.sh b/ap/app/Script/scripts/netdog_init_set.sh
new file mode 100644
index 0000000..7087c38
--- /dev/null
+++ b/ap/app/Script/scripts/netdog_init_set.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+#
+#
+path_conf=`nv get path_conf`
+test_log=`nv get path_log`"te.log"
+
+br_ipchange_flag=`nv get br_ipchange_flag`
+leak_set_flag=`nv get leak_set_flag`
+
+leak_full_panic=`nv get leak_full_panic`
+skb_max_panic=`nv get skb_max_panic`
+skb_max_fail=`nv get skb_max_fail`
+leak_list_max=`nv get leak_list_max`
+debug_mode=`nv get debug_mode`
+
+if [ "${leak_list_max}" != "" ]; then
+    netdog -s 'leak_list_max='${leak_list_max} &
+	echo "Info: netdog -s 'leak_list_max='${leak_list_max}" >> $test_log
+fi
+if [ "${skb_max_panic}" != "" ]; then
+    netdog -s 'skb_max_panic='${skb_max_panic} &
+	echo "Info: netdog -s 'skb_max_panic='${skb_max_panic}" >> $test_log
+fi
+if [ "${skb_max_fail}" != "" ]; then
+    netdog -s 'skb_max_fail='${skb_max_fail} &
+	echo "Info: netdog -s 'skb_max_fail='${skb_max_fail}" >> $test_log
+fi
+if [ "${leak_full_panic}" != "" ]; then
+    netdog -s 'leak_full_panic='${leak_full_panic} &
+	echo "Info: netdog -s 'leak_full_panic='${leak_full_panic}" >> $test_log
+fi
+if [ "$br_ipchange_flag" != "" ]; then
+    netdog -s 'brip='$br_ipchange_flag &
+	echo "Info: netdog -s 'brip='$br_ipchange_flag" >> $test_log
+fi
+if [ "${leak_set_flag}" != "" ]; then
+    netdog -s 'leak='${leak_set_flag} &
+	echo "Info: netdog -s 'leak='${leak_set_flag}" >> $test_log
+fi
+if [ "${debug_mode}" == "zephyr" ]; then
+    7100_ip_proxy &
+	echo "Info: debug_mode 'debug_mode='${debug_mode}" >> $test_log
+fi
diff --git a/ap/app/Script/scripts/ppp_updown.sh b/ap/app/Script/scripts/ppp_updown.sh
new file mode 100755
index 0000000..65a674d
--- /dev/null
+++ b/ap/app/Script/scripts/ppp_updown.sh
@@ -0,0 +1,484 @@
+#!/bin/sh
+
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+
+echo "Info: ppp_updown.sh $1 $2 start" >> $test_log
+
+echo 1 > /proc/sys/net/ipv4/ip_forward
+
+path_sh=`nv get path_sh`
+path_conf=`nv get path_conf`
+c_id=$2
+
+ps_if=`nv get pswan`$c_id
+eth_if=`nv get ppp_name`
+pdp_type=`nv get ppp_pdp_type`
+
+dhcp6s_conf=$path_conf/dhcp6s$c_id.conf
+radvd_conf=$path_conf/radvd$c_id.conf
+ndp_log=$path_conf/ndp$c_id.log
+radvd_pidfile=$path_tmp/radvd$c_id.pid
+
+dnsconfig=0
+
+b_dhcpv6stateEnabled=`nv get dhcpv6stateEnabled`
+b_dhcpv6statelessEnabled=`nv get dhcpv6statelessEnabled`
+
+#ipµØÖ·¸ñʽa.b.c.d
+#»ñÈ¡ip²¢ÅäÖÃps¡¢eth,´Ë´¦IPµØÖ·µÄÅäÖùæÔòΪpdp¼¤»îipµØÖ·×îºóһλµÄ×îºóÒ»¸öbitºÍµ¹ÊýµÚ¶þbit·Ö±ðÈ¡·´£¬¸Ã¹æÔòºóÐø¸ù¾øÐèÇó¿ÉÐÞ¸Ä
+ipaddr_set()
+{
+    pdp_ip=`nv get $ps_if"_ip"`
+	#´Óa.b.c.d»ñȡǰÈý×Ö½Úa.b.c
+	ps_ip_abc=${pdp_ip%.*}
+	#´Óa.b.c»ñȡǰÁ½¸ö×Ö½Úa.b
+	ps_ip_ab=${ps_ip_abc%.*}
+	#´Óa.b.c»ñÈ¡µÚÈý×Ö½Úc
+	ps_ip_c=${ps_ip_abc##*.}
+	#´Óa.b.c.d»ñÈ¡µÚËÄ×Ö½Úd
+	ps_ip_d=${pdp_ip##*.}  
+	
+	#pdp_ipµÚËÄλµÄ×îºó1bitÈ¡·´
+	[ "$ps_ip_c" -ge "254" ] && { ps_ip_c="250"; }
+	[ "$ps_ip_c" -le "2" ] && { ps_ip_c="10"; }
+	ps_ip_c1=`expr $ps_ip_c + 1`
+	ps_ip_c2=`expr $ps_ip_c - 1`
+
+	ps_ip=$ps_ip_ab"."$ps_ip_c1"."$ps_ip_d
+	
+	ifconfig $ps_if $ps_ip netmask 255.255.255.0 up
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $ps_if $ps_ip up failed." >> $test_log
+    fi
+	echo "Info: ifconfig $ps_if $ps_ip gw $ps_ip up" >> $test_log
+
+	#pdp_ipµÚËÄλµÄµ¹ÊýµÚ2bitÈ¡·´	
+	eth_ip=$ps_ip_ab"."$ps_ip_c2"."$ps_ip_d
+	
+	
+	nv set $eth_if"_ip"=$eth_ip
+	#ppp0Íø¿ÚÔÚpppdÖÐÒѾ­up£¬ÎÞÐèÔÙ´Îup
+	ifconfig $eth_if $eth_ip
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $eth_if $eth_ip up failed." >> $test_log
+    fi
+	echo "Info: ifconfig $eth_if $eth_ip up" >> $test_log
+	nv set $ps_if"_pppip"=$ps_ip
+}
+
+#·ÓɹæÔò£¬psÓëeth¼¶Áª
+route_set()
+{
+    marknum=`expr $c_id + 20`
+    iptables -t mangle -A PREROUTING -i $ps_if -j MARK --set-mark $marknum
+	rt_num=`expr $c_id + 120`
+    
+    echo "Info: ip route add default dev $eth_if table $rt_num " >> $test_log	
+    ip route add default dev $eth_if table $rt_num 	
+		
+	echo "Info: ip rule add to $pdp_ip fwmark $marknum table $rt_num " >> $test_log
+	ip rule add to $pdp_ip fwmark $marknum table $rt_num
+		
+	marknum=`expr $c_id + 10`
+    iptables -t mangle -A PREROUTING -i $eth_if -d ! $eth_ip/24 -j MARK --set-mark $marknum
+	rt_num=`expr $c_id + 100`
+
+	echo "Info: ip route add default dev $ps_if table $rt_num " >> $test_log
+    ip route add default dev $ps_if table $rt_num
+	
+	echo "Info: ip rule add from $pdp_ip fwmark $marknum table $rt_num " >> $test_log
+	ip rule add from $pdp_ip fwmark $marknum table $rt_num
+
+	ip route flush cache
+	
+	#±¾µØÍøÂçÅäÖÃ
+    iptables -t nat -I POSTROUTING -s $ps_ip -o $ps_if -j SNAT --to $pdp_ip
+    
+	route_info=`route|grep default`
+	
+	if [ "$route_info" == "" ];then
+		route add default dev $ps_if
+	else
+		echo "Debug: default route already exist." >> $test_log
+	fi
+}
+
+#ɾ³ý¶ÔÓ¦µÄ·ÓɹæÔò
+route_del()
+{
+    pdp_ip=`nv get $ps_if"_ip"`
+	
+	eth_ip=`nv get $eth_if"_ip"`
+	
+	ps_ip=`nv get $ps_if"_pppip"`
+	
+	marknum=`expr $c_id + 10`
+	rt_num=`expr $c_id + 100`
+	
+	iptables -t mangle -D PREROUTING -i $eth_if -d ! $eth_ip/24 -j MARK --set-mark $marknum
+	ip rule del from $pdp_ip fwmark $marknum table $rt_num 
+    ip route del default dev $ps_if table $rt_num
+	
+    marknum=`expr $c_id + 20`
+	rt_num=`expr $c_id + 120`
+    iptables -t mangle -D PREROUTING -i $ps_if -j MARK --set-mark $marknum
+	ip rule del to $pdp_ip fwmark $marknum table $rt_num
+    ip route del default dev $eth_if table $rt_num 
+	
+	iptables -t nat -D POSTROUTING -s $ps_ip -o $ps_if -j SNAT --to $pdp_ip
+	
+	ifconfig $ps_if down
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $ps_if down failed." >> $test_log
+    fi
+	
+    #reset nv
+	nv set ppp_cid=""
+    nv set $eth_if"_ip"=0.0.0.0
+    nv set $eth_if"_nm"=0.0.0.0
+    nv set $ps_if"_ip"=0.0.0.0
+    nv set $ps_if"_pridns"=0.0.0.0
+    nv set $ps_if"_secdns"=0.0.0.0
+    nv set $ps_if"_pppip"=0.0.0.0
+}
+
+#############linkup  dhcpserver set############
+linkup_add_dns_to_dhcp6s_radvd_conf()
+{
+    #Ö±Á¬Ä£Ê½Ã»ÓÐÊÖ¶¯DNS
+    ipv6_pridns_auto=`nv get $ps_if"_ipv6_pridns_auto"`
+    ipv6_secdns_auto=`nv get $ps_if"_ipv6_secdns_auto"`
+
+    if [ -n "$ipv6_pridns_auto" ] && [ "-$ipv6_pridns_auto" != "-::" ] && [ "-$ipv6_pridns_auto" != "-::0" ];then
+        ipv6_prefer_dns=$ipv6_pridns_auto
+    fi
+
+    if [ -n "$ipv6_secdns_auto" ] && [ "-$ipv6_secdns_auto" != "-::" ] && [ "-$ipv6_secdns_auto" != "-::0" ];then
+        ipv6_standby_dns=$ipv6_secdns_auto
+    fi
+
+    if [ "-$ipv6_prefer_dns" == "-" -a "-$ipv6_standby_dns" == "-" ]; then
+        return
+    else
+        if [ -n "$1" ] && [ "-$1" == "-dhcp6s" ] ;then
+            echo -e "\toption dns_servers $ipv6_prefer_dns $ipv6_standby_dns;" >> $dhcp6s_conf
+        elif [ -n "$1" ] && [ "-$1" == "-radvd" ] ;then
+            # del last line
+            sed -i '$d' $radvd_conf
+            echo -e "\tRDNSS $ipv6_prefer_dns $ipv6_standby_dns\n\t{" >> $radvd_conf
+            echo -e "\t\tAdvRDNSSPreference 15;" >> $radvd_conf
+            echo -e "\t\tAdvRDNSSOpen on;" >> $radvd_conf
+            echo -e "\t};\n};" >> $radvd_conf
+        fi
+		
+        if [ "-$dnsconfig" == "-0" ]; then
+            echo "dnsconfig $1 $ipv6_prefer_dns, $ipv6_standby_dns" >> $test_log
+            if [ "-$ipv6_prefer_dns" != "-" ]; then
+                echo "nameserver $ipv6_prefer_dns" >> /etc/resolv.conf
+            fi
+            if [ "-$ipv6_standby_dns" != "-" ]; then
+                echo "nameserver $ipv6_standby_dns" >> /etc/resolv.conf
+            fi
+            dnsconfig=1
+        fi
+    fi
+}
+
+linkup_dhcpv6_set()
+{
+    dhcpv6_start=$pdp_ip
+    dhcpv6_end=$pdp_ip
+    
+    #nvÖµ·Ç¿ÕÔò±íʾÓû§ÉèÖÃÁ˾²Ì¬ip¡¢gw
+    gw=`nv get $ps_if"_ipv6_gw"`
+    
+    echo -e "interface $eth_if {" > $dhcp6s_conf
+    if [ "-$b_dhcpv6stateEnabled" = "-1" ];then
+        echo -e "\tserver-preference 255;\n\trenew-time 6000;" >> $dhcp6s_conf
+        echo -e "\trebind-time 9000;\n\tprefer-life-time 1300;" >> $dhcp6s_conf
+        echo -e "\tvalid-life-time 2000;\n\tallow rapid-commit;" >> $dhcp6s_conf
+        echo -e "\tlink $eth_if {\n\t\tallow unicast;\n\t\tsend unicast;" >> $dhcp6s_conf
+        echo -e "\t\tpool {\n\t\t\trange $dhcpv6_start to $dhcpv6_end/$prefix_len;" >> $dhcp6s_conf
+        echo -e "\t\t};\n\t};" >> $dhcp6s_conf
+        linkup_add_dns_to_dhcp6s_radvd_conf dhcp6s
+        echo -e "};" >> $dhcp6s_conf
+        dhcp6s -dDf -c $dhcp6s_conf $eth_if &
+    else
+        #slaac with dhcp statelessset dns info
+        if [ "-$b_dhcpv6statelessEnabled" = "-1" ];then
+            echo -e "\tlink $eth_if {\n\t};" >> $dhcp6s_conf
+            linkup_add_dns_to_dhcp6s_radvd_conf dhcp6s
+            echo -e "};" >> $dhcp6s_conf
+            dhcp6s -dDf -c $dhcp6s_conf $eth_if &
+			if [ $? -ne 0 ];then
+                echo "Error: dhcp6s -dDf -c $dhcp6s_conf $eth_if failed." >> $test_log
+            fi
+        fi
+    fi
+}
+
+#»ñÈ¡ip²¢ÅäÖÃps¡¢eth
+ip6addr_set()
+{
+    #disable the forwarding to send RS and not set the addr when receive ra packet
+    echo 0 > /proc/sys/net/ipv6/conf/all/forwarding
+    echo 0 > /proc/sys/net/ipv6/conf/$ps_if/accept_ra
+    echo 0 > /proc/sys/net/ipv6/conf/$eth_if/accept_ra
+
+    #call the slaac program to get the prefix addr 
+    ifconfig $ps_if up 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $ps_if up failed." >> $test_log
+    fi
+	prefix_info_temp=`nv get $ps_if"_ipv6_prefix_info"`
+	#Èç¹ûµ±Ç°Ã»ÓÐǰ׺£¬ÔòÖ±½ÓÆô¶¯slaac£¬Èç¹ûµ±Ç°Ç°×ºÒѾ­ÉèÖã¬Ôò˵Ã÷ÒѾ­»ñÈ¡µ½£¬Ö±½ÓÅäÖÃIPµØÖ·¼´¿É
+	if [ -n "$prefix_info_temp" -a "-$prefix_info_temp" != "-::" ]; then
+		ret_code=0
+	else
+		sleep 1
+		interface_id_temp1=`nv get $ps_if"_ipv6_interface_id"`
+		local_ipv6_addr="fe80::"$interface_id_temp1
+		local_ipv6_addr_nv="$ps_if""_local_ipv6_addr"
+		nv set $local_ipv6_addr_nv=$local_ipv6_addr
+		ip -6 addr add $local_ipv6_addr/64 dev $ps_if 2>>$test_log
+		zte_ipv6_slaac -i "$ps_if" 
+		ret_code=$?
+	fi
+
+    echo "Info: zte_ipv6_slaac return: $ret_code" >> $test_log
+    echo "the program zte_ipv6_slaac return  = $ret_code"
+    if [ $ret_code -eq 0 ]; then
+        echo "the zte_ipv6_slaac success"
+        interface_id_temp=`nv get $ps_if"_ipv6_interface_id"`
+        prefix_info_temp=`nv get $ps_if"_ipv6_prefix_info"`
+        
+        echo "##############1##########"
+        echo "$interface_id_temp"
+        echo "$prefix_info_temp"
+        echo "##############2##########"
+        
+        #pdp ¼¤»îµÄipv6µØÖ·
+        pdp_ip6=$prefix_info_temp$interface_id_temp
+        #pdp¼¤»îµØÖ·£¬ÊÊÅäÒ³ÃæÊ¹ÓÃ
+        nv set ipv6_wan_ipaddr="$pdp_ip6"
+        
+        ipv6_addr_conver $pdp_ip6 "$ps_if"
+        
+        #¸øeth·ÖÅ䵨ַ£¬Ê¹ÓÃipv6_addr_converÔÚµÚ15+1
+        eth_ip6=`nv get ipv6_br0_addr`
+
+        ip -6 addr add $eth_ip6/64 dev $eth_if 
+		if [ $? -ne 0 ];then
+	        echo "Error: ip -6 addr add $eth_ip6/64 dev $eth_if failed." >> $test_log
+        fi
+        #¸øÍâÍø¿Ú·ÖÅ䵨ַ£¬Ê¹ÓÃipv6_addr_converÔÚµÚ15+2
+        ps_ip6=`nv get $ps_if"_dhcpv6_start"`
+        nv set $ps_if"_ipv6_ip"=$ps_ip6
+        ip -6 addr add $ps_ip6/126 dev $ps_if 2>>$test_log
+		if [ $? -ne 0 ];then
+	        echo "Error: ip -6 addr add $ps_ip6/126 dev $ps_if failed." >> $test_log
+        fi
+		nv set $ps_if"_ipv6_state"="working"
+        
+        echo "Info: zte_ipv6_slaac pdp_ip6: $pdp_ip6" >> $test_log
+        echo "Info: zte_ipv6_slaac ps_ip6: $ps_ip6" >> $test_log
+        echo "Info: zte_ipv6_slaac eth_ip6: $eth_ip6" >> $test_log
+    else
+        echo "the zte_ipv6_slaac fail"
+		nv set $ps_if"_ipv6_state"="dead"
+        exit 1
+    fi
+}
+
+#·ÓɹæÔò£¬psÓëeth¼¶Áª
+route6_set()	
+{
+	echo 0 > /proc/sys/net/ipv6/conf/all/forwarding 
+
+    marknum=`expr $c_id + 60`
+    ip6tables -t mangle -A PREROUTING -i $ps_if -j MARK --set-mark $marknum
+    rt_num=`expr $c_id + 160`
+    ip -6 route add default dev $eth_if table $rt_num
+    ip -6 rule add to $pdp_ip6/64 fwmark $marknum table $rt_num
+
+    marknum=`expr $c_id + 50`
+    ip6tables -t mangle -A PREROUTING -i $eth_if -j MARK --set-mark $marknum
+    rt_num=`expr $c_id + 150`
+    ip -6 route add default dev $ps_if table $rt_num
+    ip -6 rule add from $pdp_ip6/64 fwmark $marknum table $rt_num
+
+    ip6tables -t filter -A FORWARD -p icmpv6 --icmpv6-type 135 -j DROP
+	
+    ip -6 route flush cache
+	
+    #Õâ¾äÉèÍ꣬ÀïÃæ¿ÉÒÔpingͨÍâÍøÁË
+    echo "Info: route6_set pdp_ip6=$pdp_ip6" >> $test_log
+    
+    ip -6 route add default dev $ps_if 2>>$test_log
+    if [ $? -ne 0 ];then
+	    echo "Error: ip -6 route add default dev $ps_if failed." >> $test_log
+    fi
+		
+    #enable ipv6 packet forwarding
+    echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
+    echo 1 > /proc/sys/net/ipv6/conf/$ps_if/accept_ra
+    echo 1 > /proc/sys/net/ipv6/conf/$eth_if/accept_ra
+    #enable ipv6 neigh discovery proxy
+    echo 1 > /proc/sys/net/ipv6/conf/all/proxy_ndp
+    
+    ndp_kill
+    zte_ndp -a -s $eth_if -d $ps_if -l $ndp_log -p &
+}
+
+#############linkup radvd set############
+linkup_radvd_set() 
+{
+    echo "enter linkup_radvd_set "
+    
+    prefix_len=64
+    
+    rm -rf $radvd_conf
+    
+    if [ "-$b_dhcpv6stateEnabled" = "-1" ];then
+        echo -e "interface $eth_if\n{\n\tAdvSendAdvert on;" > $radvd_conf
+        echo -e "\tAdvManagedFlag on;\n};" >> $radvd_conf
+        radvd_kill
+		rm -rf $radvd_pidfile
+        radvd -d 3 -C $radvd_conf -p $radvd_pidfile&
+        echo  "leave linkup_radvd_set "
+        return
+    fi
+    
+    echo "Info: psext_updown_ipv6.sh eth_if:$eth_if, prefix_len:$prefix_len" >> $test_log
+    echo "prefix_len:$prefix_len"
+    
+    cp $path_ro/radvd_template.conf $radvd_conf
+	
+	sed  -i -e 's/#ipv6_wan_addr#\/64/#ipv6_wan_addr#\/#prefix_len#/g' $radvd_conf
+    sed  -i -e s/br0/$eth_if/g $radvd_conf
+    sed  -i -e s/#ipv6_wan_addr#/$eth_ip6/g $radvd_conf 
+    sed  -i -e s/#prefix_len#/$prefix_len/g $radvd_conf
+    sed  -i -e s/#adv_switch#/on/g $radvd_conf 
+
+    #slaac with dns info
+    if [ "-$b_dhcpv6statelessEnabled" = "-1" ];then
+        echo "use dhcpv6stateless for dns"
+    else
+        sed -i -e 's/AdvOtherConfigFlag on;/AdvOtherConfigFlag off;/g' $radvd_conf
+        linkup_add_dns_to_dhcp6s_radvd_conf radvd
+    fi
+
+    radvd_kill
+    sleep 1
+	rm -rf $radvd_pidfile
+    radvd -d 3 -C $radvd_conf -p $radvd_pidfile &
+    
+    echo  "leave linkup_radvd_set "
+}
+
+#Çå³ýÏàÓ¦µÄradvd½ø³Ì
+linkdown_radvd_set()
+{
+    #¸úÖÕ¶ËÁ¬½ÓµÄÍø¿ÚÖ±½Ó»ádown£¬ËùÒÔ²»ÓÃÏñufiÒ»ÑùÉèÖóÉ1sÓÐЧÆÚ
+    radvd_kill
+}
+
+#Çå³ýÏàÓ¦µÄDHCPv6½ø³Ì
+linkdown_dhcpv6_server_set()
+{
+    dhcp6s_kill
+}
+
+#ɾ³ýÏàÓ¦µÄipv6·ÓɹæÔò
+route6_del()
+{
+    eth_ip6=`nv get ipv6_br0_addr`
+    ps_ip6=`nv get $ps_if"_ipv6_ip"`
+    pdp_ip6=`nv get ipv6_wan_ipaddr`
+
+    ip6tables -t filter -D FORWARD -p icmpv6 --icmpv6-type 135 -j DROP
+	
+    marknum=`expr $c_id + 50`
+    rt_num=`expr $c_id + 150`
+    ip -6 rule del from $pdp_ip6/64 fwmark $marknum table $rt_num
+    ip6tables -t mangle -D PREROUTING -i $eth_if -j MARK --set-mark $marknum
+    ip -6 route del default dev $ps_if table $rt_num
+
+    marknum=`expr $c_id + 60`
+    rt_num=`expr $c_id + 160`
+    ip -6 rule del to $pdp_ip6/64 fwmark $marknum table $rt_num
+    ip6tables -t mangle -D PREROUTING -i $ps_if -j MARK --set-mark $marknum
+    ip -6 route del default dev $eth_if table $rt_num
+
+    ip -6 addr del $eth_ip6/64 dev $eth_if
+	#if [ $? -ne 0 ];then
+	#    echo "Error: ip -6 addr del $eth_ip/64 dev $eth_if failed." >> $test_log
+    #fi
+    ip -6 addr del $ps_ip6/126 dev $ps_if
+	#if [ $? -ne 0 ];then
+	#    echo "Error: ip -6 addr del $ps_ip6/126 dev $ps_if  failed." >> $test_log
+    #fi
+    ip -6 route del default
+	#if [ $? -ne 0 ];then
+	#    echo "Error: ip -6 route del default failed." >> $test_log
+    #fi
+
+    ifconfig $eth_if down 2>>$test_log
+	#if [ $? -ne 0 ];then
+    #    echo "Error: ifconfig $eth_if down failed." >> $test_log
+    #fi
+    ifconfig $ps_if down 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $ps_if down failed." >> $test_log
+    fi
+
+    echo 0 > /proc/sys/net/ipv6/conf/$ps_if/accept_ra
+	
+    #reset nv
+    nv set ppp_cid=""
+    nv set $ps_if"_pppv6_ip"="::"
+    nv set $ps_if"_ipv6_ip"="::"
+    nv set $ps_if"_ipv6_pridns_auto"="::"
+    nv set $ps_if"_ipv6_secdns_auto"="::"
+    nv set $ps_if"_ipv6_gw"="::"
+    nv set $ps_if"_ipv6_interface_id"="::"
+    nv set $ps_if"_ipv6_prefix_info"="::"
+    nv set $ps_if"_dhcpv6_start"="::"
+    nv set $ps_if"_dhcpv6_end"="::"
+
+    #ÊÊÅäÒ³ÃæµÈÆäËûµØ·½Ê¹ÓÃÀÏNV
+    nv set ipv6_wan_ipaddr="::"
+	nv set $ps_if"_ipv6_state"="dead"
+	
+	local_ipv6_addr_nv="$ps_if""_local_ipv6_addr"
+	nv set $local_ipv6_addr_nv="::"
+
+    ndp_kill
+}
+
+if [ "$1" == "linkup" ]; then
+	if [ "$pdp_type" != "IPV6" ]; then
+		ipaddr_set
+		route_set
+	fi
+	if [ "$pdp_type" == "IPV6" -o "$pdp_type" == "IPV4V6" ]; then
+		ip6addr_set
+		route6_set
+		linkup_dhcpv6_set
+		linkup_radvd_set
+	fi
+elif [ "$1" == "linkdown" ]; then
+	if [ "$pdp_type" != "IPV6" ]; then		
+	    route_del
+	fi	
+	if [ "$pdp_type" == "IPV6" -o "$pdp_type" == "IPV4V6" ]; then 	
+		linkdown_radvd_set
+		linkdown_dhcpv6_server_set
+		route6_del
+		slaac_kill
+		echo "" > /etc/resolv.conf
+	fi
+fi
+
+echo "Info: ppp_updown.sh $1 $2 leave" >> $test_log
diff --git a/ap/app/Script/scripts/pppd_up.sh b/ap/app/Script/scripts/pppd_up.sh
new file mode 100755
index 0000000..db1ba09
--- /dev/null
+++ b/ap/app/Script/scripts/pppd_up.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+#
+# $Id: lan.sh
+#
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+
+pppd_auth=`nv get pppd_auth`
+dev_name=$1
+echo "name is $1"
+aa=`echo $dev_name | sed 's/\//\\\\\//g'`
+echo "aa is $aa"
+echo "Info:start pppd!" >> $test_log
+if [ "$pppd_auth" == "auth" ]; then
+	cp $path_ro/options.auth $path_conf/options
+	cp $path_ro/pap-secrets $path_conf/pap-secrets
+	cp $path_ro/chap-secrets $path_conf/chap-secrets
+	sed  -i -e "s/#dev_name#/$aa/g" $path_conf/options
+	sed  -i -e "s/#dev_name#/$aa/g" $path_conf/options
+	killall -9 pppd
+	pppd &
+elif [ "$pppd_auth" == "noauth" ]; then
+	cp $path_ro/options.noauth $path_conf/options
+	sed  -i -e "s/#dev_name#/$aa/g" $path_conf/options
+	sed  -i -e "s/#dev_name#/$aa/g" $path_conf/options
+	killall -9 pppd
+	pppd &
+fi
diff --git a/ap/app/Script/scripts/pppoe_dail.sh b/ap/app/Script/scripts/pppoe_dail.sh
new file mode 100755
index 0000000..fc1269f
--- /dev/null
+++ b/ap/app/Script/scripts/pppoe_dail.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+#
+# $Id: pppoe_dail.sh,v 1.1 2007-09-26 01:33:21 winfred Exp $
+#
+# usage: pppoe_dail.sh
+#
+# pppoe_dail.sh,v1.0 2010-09-09 10:00:00 maxiaoliang  $
+#
+# usage: pppoe_dail.sh
+#
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+echo "Info: pppoe_dail.sh start " >> $test_log
+
+usage()
+{
+        echo "Usage:"
+        echo "  $0 [connect | disconnect]"
+        exit 1
+}
+if [ "$1" = "" ]; then
+        echo "$0: insufficient arguments"
+        usage $0
+fi
+
+killall pppoecd
+ 
+eth_dial_mode=`nv get ethwan_dialmode`
+
+idle_time=`nv get idle_time`
+wan0=`nv get ethwan` 
+
+ 	if [ "$1" = "connect" ]; then
+		pppoe_user=`nv get pppoe_username`
+		pppoe_pass=`nv get pppoe_cc`
+    	if [ "-${pppoe_user}" = "-" -a "-${pppoe_pass}" = "-" ];then
+		    echo "WARN: pppoe_user is ${pppoe_user}, pppoe_pass is ${pppoe_pass}, so not connect pppoecd. " >> $test_log
+		else
+		#dial mode
+		if [ "$eth_dial_mode" == "auto" ]; then 
+			pppoecd $wan0  -u $pppoe_user -p $pppoe_pass -N 2 -k &
+		elif [ "$eth_dial_mode" == "ondemand" ]; then 
+			pppoecd $wan0  -u $pppoe_user -p $pppoe_pass -N 2 -i $idle_time -R -k &
+		elif [ "$eth_dial_mode" == "manual" ]; then 
+			pppoecd $wan0  -u $pppoe_user -p $pppoe_pass -N 2 -k &
+		fi
+	fi
+	fi
+		
+	if [ "$1" = "disconnect" ]; then
+		echo "pppoe-down:   pppoe is disconnected! "
+		sleep 2
+	fi
+ 
diff --git a/ap/app/Script/scripts/pppoe_updown.sh b/ap/app/Script/scripts/pppoe_updown.sh
new file mode 100644
index 0000000..fbbbb6b
--- /dev/null
+++ b/ap/app/Script/scripts/pppoe_updown.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+path_sh=`nv get path_sh`
+echo "Info: pppoe_updown.sh $1 start " >> $test_log
+wan_if=`nv get ethwan`
+. $path_sh/global.sh
+
+pppoe_down()
+{
+	nv set rj45_state="idle"
+    #killall pppoecd
+	(/sbin/router_msg_proxy ipv4 pppoe_updown.sh 1>> $test_log 2>&1 || echo "Error: router_msg_proxy ipv4 pppoe_updown.sh failed." >> $test_log) &
+	if [ $? -ne 0 ];then
+	    echo "Error: router_msg_proxy ipv4 failed." >> $test_log
+    fi
+}
+pppoe_up()
+{
+    udhcpc_kill
+	nv set rj45_state="working"
+	nv set eth_curmode="pppoe"
+	(/sbin/router_msg_proxy del_timer ethwan 1>> $test_log 2>&1 || echo "Error: router_msg_proxy del_timer failed." >> $test_log) &
+	if [ $? -ne 0 ];then
+	    echo "Error: router_msg_proxy del_timer failed." >> $test_log
+    fi
+	(/sbin/router_msg_proxy ipv4 pppoe_updown.sh 1>> $test_log 2>&1 || echo "Error: router_msg_proxy ipv4 pppoe_updown.sh failed." >> $test_log) &
+	if [ $? -ne 0 ];then
+	    echo "Error: router_msg_proxy ipv4 failed." >> $test_log
+    fi
+	
+	wan_ip=`nv get $wan_if"_ip"`
+    wan_gw=`nv get $wan_if"_gw"`
+	wan_pri=`nv get ethwan_priority`
+	rt_num=`expr $wan_pri \* 10 `
+	ip rule add from $wan_ip table $rt_num 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ip rule add from $wan_ip table $rt_num failed." >> $test_log
+    fi
+	ip route add default via $wan_gw table $rt_num 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ip route add default via $wan_gw table $rt_num failed." >> $test_log
+    fi
+	ip route flush cache 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ip route flush cache failed." >> $test_log
+    fi
+}
+
+if [ "$1" == "up" ]; then
+    pppoe_up
+elif [ "$1" == "down" ]; then
+    pppoe_down
+fi
+    
\ No newline at end of file
diff --git a/ap/app/Script/scripts/print_errmsg.sh b/ap/app/Script/scripts/print_errmsg.sh
new file mode 100644
index 0000000..4530abd
--- /dev/null
+++ b/ap/app/Script/scripts/print_errmsg.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+echo "error:"
+grep "\<${1##0}\>" /etc_ro/errmsg.txt|sed -n "s/#define[[:blank:]]\+[a-zA-Z0-9]\+[[:blank:]]\+[0-9]\+[[:blank:]]\+\(.*\)/\1/p" |awk -F'*' '{print $2}'
diff --git a/ap/app/Script/scripts/psext_down.sh b/ap/app/Script/scripts/psext_down.sh
new file mode 100755
index 0000000..b9d3877
--- /dev/null
+++ b/ap/app/Script/scripts/psext_down.sh
@@ -0,0 +1,65 @@
+#!/bin/sh
+test_log=`nv get telog_path`
+if [ "$test_log" == "" ]; then
+	test_log=`nv get path_log`"te.log"
+fi
+echo "Info: psext_down.sh $1 start" >> $test_log
+c_id=$1
+ps_if=`nv get pswan`$c_id
+eth_if=`nv get "ps_ext"$c_id`
+ext_br="br"$c_id
+
+#ɾ³ý¶ÔÓ¦µÄ·ÓɹæÔò
+route_del()
+{
+    pdp_ip=`nv get $ps_if"_pdp_ip"`
+	ps_ip=`nv get $ps_if"_ip"`
+	br_ip=`nv get $ext_br"_ip"`
+	marknum=`expr $c_id + 10`
+	rt_num=`expr $c_id + 100`
+	
+	iptables -t mangle -D PREROUTING -i $ext_br -j MARK --set-mark $marknum
+	ip rule del from $pdp_ip fwmark $marknum table $rt_num 
+    ip route del default dev $ps_if table $rt_num
+	
+    marknum=`expr $c_id + 20`
+	rt_num=`expr $c_id + 120`
+    iptables -t mangle -D PREROUTING -i $ps_if -j MARK --set-mark $marknum
+	ip rule del to $pdp_ip fwmark $marknum table $rt_num
+    ip route del default dev $ext_br table $rt_num 
+	#±¾µØÍøÂçÅäÖÃ
+    iptables -t nat -D POSTROUTING -s $ps_ip -o $ps_if -j SNAT --to $pdp_ip
+    if [ $? -ne 0 ];then
+        echo "cmd <<iptables -t nat -D POSTROUTING -s $ps_ip -o $ps_if -j SNAT --to $pdp_ip>> exec failed"  >> $test_log
+    fi
+    route delete default dev $ps_if
+    if [ $? -ne 0 ];then
+        echo "cmd <<route delete default dev $ps_if>> exec failed"  >> $test_log
+    fi
+	
+    ifconfig $ext_br 0.0.0.0
+	ifconfig $ext_br down 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $ext_br down failed." >> $test_log
+    fi
+    
+    ifconfig $ps_if 0.0.0.0
+	ifconfig $ps_if down 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $ps_if down failed." >> $test_log
+    fi
+	
+    #reset nv
+    nv set $ext_br"_ip"=0.0.0.0
+    nv set $ext_br"_nm"=0.0.0.0
+    nv set $ps_if"_pdp_ip"=0.0.0.0
+    nv set $ps_if"_pridns"=0.0.0.0
+    nv set $ps_if"_secdns"=0.0.0.0
+    nv set $ps_if"_ip"=0.0.0.0
+}
+tc_tbf.sh down $c_id
+route_del
+ifconfig $eth_if down
+ifconfig $ext_br down
+brctl delif $ext_br $eth_if
+brctl delbr $ext_br 
diff --git a/ap/app/Script/scripts/psext_down_ipv6.sh b/ap/app/Script/scripts/psext_down_ipv6.sh
new file mode 100755
index 0000000..2ce0d21
--- /dev/null
+++ b/ap/app/Script/scripts/psext_down_ipv6.sh
@@ -0,0 +1,84 @@
+#!/bin/sh
+test_log=`nv get telog_path`
+if [ "$test_log" == "" ]; then
+	test_log=`nv get path_log`"te.log"
+fi
+echo "Info: psext_updown_ipv6.sh $ps_if $eth_if $br_if start" >> $test_log
+
+c_id=$1
+ps_if=`nv get pswan`$c_id
+eth_if=`nv get "ps_ext"$c_id`
+br_if="br"$c_id
+
+#删除相应的ipv6路由规则
+linkdown_route_set()
+{
+    br_ip=`nv get $br_if"_ipv6_ip"`
+    ps_ip=`nv get $ps_if"_ipv6_ip"`
+    pdp_ip=`nv get ipv6_wan_ipaddr`
+
+    ip6tables -t filter -D FORWARD -p icmpv6 --icmpv6-type 135 -j DROP
+	
+    marknum=`expr $c_id + 50`
+    rt_num=`expr $c_id + 150`
+    ip -6 rule del from $pdp_ip/64 fwmark $marknum table $rt_num
+    ip6tables -t mangle -D PREROUTING -i $br_if -j MARK --set-mark $marknum
+    ip -6 route del default dev $ps_if table $rt_num
+
+    marknum=`expr $c_id + 60`
+    rt_num=`expr $c_id + 160`
+    ip -6 rule del to $pdp_ip/64 fwmark $marknum table $rt_num
+    ip6tables -t mangle -D PREROUTING -i $ps_if -j MARK --set-mark $marknum
+    ip -6 route del default dev $br_if table $rt_num
+
+    ip -6 addr del $br_ip/126 dev $br_if
+	#if [ $? -ne 0 ];then
+	#    echo "Error: ip -6 addr del $eth_ip/126 dev $eth_if failed." >> $test_log
+    #fi
+    ip -6 addr del $ps_ip/126 dev $ps_if
+	#if [ $? -ne 0 ];then
+	#    echo "Error: ip -6 addr del $ps_ip/126 dev $ps_if  failed." >> $test_log
+    #fi
+    ip -6 route del default
+	#if [ $? -ne 0 ];then
+	#    echo "Error: ip -6 route del default failed." >> $test_log
+    #fi
+
+    ifconfig $br_if down 2>>$test_log
+	if [ $? -ne 0 ];then
+        echo "Error: ifconfig $br_if down failed." >> $test_log
+    fi
+    ifconfig $ps_if down 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $ps_if down failed." >> $test_log
+    fi
+
+    echo 0 > /proc/sys/net/ipv6/conf/$ps_if/accept_ra
+	
+    #reset nv 
+    nv set $br_if"_ipv6_ip"="::"
+    nv set $ps_if"_ipv6_ip"="::"
+    nv set $ps_if"_ipv6_pridns_auto"="::"
+    nv set $ps_if"_ipv6_secdns_auto"="::"
+    nv set $ps_if"_ipv6_gw"="::"
+    nv set $ps_if"_ipv6_interface_id"="::"
+    nv set $ps_if"_ipv6_prefix_info"="::"
+    nv set $ps_if"_dhcpv6_start"="::"
+    nv set $ps_if"_dhcpv6_end"="::"
+
+    #适配页面等其他地方使用老NV
+    nv set ipv6_wan_ipaddr="::"
+	nv set $ps_if"_ipv6_state"="dead"
+	
+	local_ipv6_addr_nv="$ps_if""_local_ipv6_addr"
+	nv set $local_ipv6_addr_nv="::"
+
+    #ndp_kill
+}
+
+tc_tbf.sh down $c_id
+linkdown_route_set
+brctl delif $br_if $eth_if
+ifconfig $eth_if down
+#echo "" > /etc/resolv.conf
+echo "Info: psext_down_ipv6.sh leave" >> $test_log
diff --git a/ap/app/Script/scripts/psext_up.sh b/ap/app/Script/scripts/psext_up.sh
new file mode 100755
index 0000000..8846ccb
--- /dev/null
+++ b/ap/app/Script/scripts/psext_up.sh
@@ -0,0 +1,104 @@
+#!/bin/sh
+test_log=`nv get telog_path`
+if [ "$test_log" == "" ]; then
+	test_log=`nv get path_log`"te.log"
+fi
+echo "Info: psext_up.sh $1 start" >> $test_log
+path_conf=`nv get path_conf`
+
+echo 1 > /proc/sys/net/ipv4/ip_forward
+c_id=$1
+ps_if=`nv get pswan`$c_id
+eth_if=`nv get "ps_ext"$c_id`
+ext_br="br"$c_id
+pidfile=$path_conf"/udhcpd"$c_id".pid"
+confile=$path_conf"/udhcpd"$c_id".conf"
+leases=$path_conf"/udhcpd"$c_id".leases"
+
+arp_proxy_set()
+{
+	(zte_arp_proxy -i $ext_br 2>> $test_log || echo "Error: zte_arp_proxy -i $ext_br failed." >> $test_log) &
+}
+
+dhcp_set()
+{
+	mask=`nv get $ext_br"_nm"`
+	ifconfig $ext_br netmask $mask 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $eth_br netmask $mask failed." >> $test_log
+	fi
+    if [ -e ${pidfile} ]; then
+      kill `cat $pidfile`
+	  rm -f $pidfile
+    fi
+	touch $leases
+	udhcpd -f $confile &
+}
+
+#»ñÈ¡ip²¢ÅäÖÃps¡¢eth
+get_ipaddr()
+{
+    pdp_ip=`nv get $ps_if"_pdp_ip"`
+	ps_ip=`nv get $ps_if"_ip"`
+	br_ip=`nv get $ext_br"_ip"`
+	ifconfig $ps_if $ps_ip netmask 255.255.255.0 up 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $ps_if $ps_ip up failed." >> $test_log
+    fi
+	nv set default_wan_rel=$ps_if
+	nv set default_cid=$c_id
+	nv set $ext_br"_ip"=$br_ip
+	ifconfig $ext_br $br_ip 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $ext_br $br_ip up failed." >> $test_log
+    fi
+}
+#·ÓɹæÔò£¬psÓëeth¼¶Áª
+route_set()
+{
+    marknum=`expr $c_id + 20`
+    iptables -t mangle -A PREROUTING -i $ps_if -j MARK --set-mark $marknum
+	rt_num=`expr $c_id + 120`
+    
+    ip route add default dev $ext_br table $rt_num 	
+		
+	ip rule add to $pdp_ip fwmark $marknum table $rt_num
+	
+	marknum=`expr $c_id + 10`
+    iptables -t mangle -A PREROUTING -i $ext_br -j MARK --set-mark $marknum
+	rt_num=`expr $c_id + 100`
+
+    ip route add default dev $ps_if table $rt_num
+	ip rule add from $pdp_ip fwmark $marknum table $rt_num
+
+	ip route flush cache
+    
+    #±¾µØÍøÂçÅäÖÃ
+    iptables -t nat -I POSTROUTING -s $ps_ip -o $ps_if -j SNAT --to $pdp_ip
+    
+	route_info=`route|grep default`
+	
+	if [ "$route_info" == "" ];then
+		route add default dev $ps_if
+	else
+		echo "Debug: default route already exist." >> $test_log
+	fi
+}
+
+mtu=`nv get mtu`
+ifconfig $ps_if mtu $mtu
+brctl addbr $ext_br
+brctl setfd $ext_br 0.1
+brctl addif $ext_br $eth_if
+ifconfig $ext_br up
+get_ipaddr
+dhcp_set
+route_set
+arp_proxy_set
+ifconfig $eth_if up
+ismbim=`ps |grep -v grep |grep -w mbim |awk '{printf $1}'`
+if [ "-$ismbim" != "-" ]; then
+	eth_mac=`cat "/sys/class/net/"$eth_if"/address"`
+	arp -s $pdp_ip $eth_mac -i $ext_br 2>>$test_log
+fi
+tc_tbf.sh up $c_id
diff --git a/ap/app/Script/scripts/psext_up_ipv6.sh b/ap/app/Script/scripts/psext_up_ipv6.sh
new file mode 100755
index 0000000..07ef6dc
--- /dev/null
+++ b/ap/app/Script/scripts/psext_up_ipv6.sh
@@ -0,0 +1,114 @@
+#!/bin/sh
+test_log=`nv get telog_path`
+if [ "$test_log" == "" ]; then
+	test_log=`nv get path_log`"te.log"
+fi
+
+c_id=$1
+path_conf=`nv get path_conf`
+path_tmp=`nv get path_tmp`
+dhcp6s_conf=$path_conf/dhcp6s$c_id.conf
+radvd_conf=$path_conf/radvd$c_id.conf
+ndp_log=$path_conf/ndp$c_id.log
+radvd_pidfile=$path_tmp/radvd$c_id.pid
+
+ps_if=`nv get pswan`$c_id
+eth_if=`nv get "ps_ext"$c_id`
+br_if="br"$c_id
+
+echo "Info: psext_updown_ipv6.sh $ps_if $eth_if $br_if start" >> $test_log
+
+prefix_len=`nv get $ps_if"_ipv6_prefix_len"`
+br_ip=`nv get $br_if"_ipv6_ip"`
+ps_ip=`nv get $ps_if"_ipv6_ip"`
+pdp_ip=`nv get $ps_if"_ipv6_pdp"`
+local_ipv6_addr=`nv get $ps_if"_ipv6_local"`
+
+#获取ip并配置ps、eth
+linkup_get_addr()
+{
+    #disable the forwarding to send RS and not set the addr when receive ra packet
+    echo 0 > /proc/sys/net/ipv6/conf/all/forwarding
+    echo 0 > /proc/sys/net/ipv6/conf/$ps_if/accept_ra
+    echo 0 > /proc/sys/net/ipv6/conf/$eth_if/accept_ra
+    echo 0 > /proc/sys/net/ipv6/conf/$br_if/accept_ra
+    #call the slaac program to get the prefix addr 
+    ifconfig $ps_if up 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $ps_if up failed." >> $test_log
+    fi
+	ip -6 addr add $local_ipv6_addr/64 dev $ps_if 2>>$test_log
+	brctl addbr $br_if
+	brctl setfd $br_if 0.1
+	ifconfig $br_if up 2>>$test_log
+	if [ $? -ne 0 ];then
+		echo "Error: ifconfig $br_if up failed." >> $test_log
+	fi
+	ip -6 addr add $br_ip/64 dev $br_if 
+	ip -6 addr add $ps_ip/126 dev $ps_if 2>>$test_log
+	if [ $? -ne 0 ];then
+		echo "Error: ip -6 addr add $ps_ip/126 dev $ps_if failed." >> $test_log
+	fi
+	nv set $ps_if"_ipv6_state"="working"	
+}
+
+#路由规则,ps与eth级联
+linkup_route_set()
+{
+    echo 0 > /proc/sys/net/ipv6/conf/all/forwarding 
+
+    marknum=`expr $c_id + 60`
+    ip6tables -t mangle -A PREROUTING -i $ps_if -j MARK --set-mark $marknum
+    rt_num=`expr $c_id + 160`
+    ip -6 route add default dev $br_if table $rt_num 	
+    ip -6 rule add to $pdp_ip/64 fwmark $marknum table $rt_num
+
+    marknum=`expr $c_id + 50`
+    ip6tables -t mangle -A PREROUTING -i $br_if -j MARK --set-mark $marknum
+    rt_num=`expr $c_id + 150`
+    ip -6 route add default dev $ps_if table $rt_num
+    ip -6 rule add from $pdp_ip/64 fwmark $marknum table $rt_num
+
+    ip6tables -t filter -A FORWARD -p icmpv6 --icmpv6-type 135 -j DROP
+	
+    ip -6 route flush cache
+	
+    #这句设完,里面可以ping通外网了
+    echo "Info: route_set ps_ip=$ps_ip" >> $test_log
+    #ip -6 route add default via $ps_ip dev $ps_if
+    ip -6 route add default dev $ps_if 2>>$test_log
+    if [ $? -ne 0 ];then
+	    echo "Error: ip -6 route add default dev $ps_if failed." >> $test_log
+    fi
+		
+    #enable ipv6 packet forwarding
+    echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
+    echo 1 > /proc/sys/net/ipv6/conf/$ps_if/accept_ra
+    echo 1 > /proc/sys/net/ipv6/conf/$eth_if/accept_ra
+    echo 1 > /proc/sys/net/ipv6/conf/$br_if/accept_ra
+    #enable ipv6 neigh discovery proxy
+    echo 1 > /proc/sys/net/ipv6/conf/all/proxy_ndp
+
+    zte_ndp -a -s $br_if -d $ps_if -l $ndp_log -p &
+}
+
+linkup_dhcpv6_set()
+{
+	dhcp6s -dDf -c $dhcp6s_conf $br_if &
+}
+
+linkup_radvd_set() 
+{
+	radvd -d 3 -C $radvd_conf -p $radvd_pidfile &
+}
+
+mtu=`nv get mtu`
+ifconfig $ps_if mtu $mtu
+linkup_get_addr
+linkup_route_set
+linkup_dhcpv6_set
+linkup_radvd_set
+brctl addif $br_if $eth_if
+ifconfig $eth_if up
+tc_tbf.sh up $c_id
+echo "Info: psext_up_ipv6.sh leave" >> $test_log
diff --git a/ap/app/Script/scripts/psext_updown.sh b/ap/app/Script/scripts/psext_updown.sh
new file mode 100755
index 0000000..9b4650e
--- /dev/null
+++ b/ap/app/Script/scripts/psext_updown.sh
@@ -0,0 +1,476 @@
+#!/bin/sh
+
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+echo "Info: psext_updown.sh $1 $2 start" >> $test_log
+
+echo 1 > /proc/sys/net/ipv4/ip_forward
+c_id=$2
+ps_if=`nv get pswan`$c_id
+eth_if=`nv get "ps_ext"$c_id`
+ext_br="br"$c_id
+ps_ext_mode=`nv get need_jilian`
+#Óû§ÉèÖþ²Ì¬ip¡¢gw£¬nmÔÚ´Ë´¦¼ÆËã
+arp_proxy_kill()
+{
+	ps > ${path_tmp}/zte_arp_proxy.$ext_br.$$
+	arp_proxy_pid=`awk 'BEGIN{temp1="'"${ext_br}"'";temp2="zte_arp_proxy"}{if(index($0,temp1)>0 && index($0,temp2)>0){print $1}}' ${path_tmp}/zte_arp_proxy.$ext_br.$$`
+	rm -f ${path_tmp}/zte_arp_proxy.$ext_br.$$
+	[ -n "$arp_proxy_pid" ] && { kill $arp_proxy_pid; echo "test: kill udhcpc $arp_proxy_pid " >> $test_log ; }
+}
+
+arp_proxy_set()
+{
+	arp_proxy_kill
+	(zte_arp_proxy -i $ext_br 2>> $test_log || echo "Error: zte_arp_proxy -i $ext_br failed." >> $test_log) &
+}
+
+get_mask()
+{
+    mask=`echo ${ps_ip}"."${gw} | awk -F '.' '{
+        nm1=0;nm2=0;nm3=0
+	    if($1 == $5)
+	       nm1=255
+	
+	    if(255 == nm1 && $2 == $6)
+	       nm2=255
+	
+	    if(255 == nm2 && $3 == $7)
+	       nm3=255
+	
+	    printf nm1"."nm2"."nm3".0"
+    }'`
+}
+
+dhcp_set()
+{
+    
+	start=$pdp_ip 
+    end=$pdp_ip
+	#nvÖµ·Ç¿ÕÔò±íʾÓû§ÉèÖÃÁ˾²Ì¬ip¡¢gw
+	gw=`nv get $ps_if"_gw"`
+	if [ "-$gw" == "-" -o "-$gw" == "-0.0.0.0" ]; then
+		gw=$br_ip
+		mask=$valid_mask
+        echo psip $ps_ip br_ip  $br_ip valid_mask $valid_mask  $mask
+	else
+        echo "no mask"
+	    get_mask
+	fi
+	nv set $ext_br"_nm"=$mask 
+	ifconfig $ext_br netmask $mask 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $eth_br netmask $mask failed." >> $test_log
+    fi
+    dns=`nv get $ps_if"_pridns"`
+    dns2=`nv get $ps_if"_secdns"`
+    lease="86400"
+	
+    #±¾µØÍøÂçÅäÖÃ
+    if [ "-$dns" == "-" -o "-$dns" == "-0.0.0.0" ] && [ "-$dns2" == "-" -o "-$dns2" == "-0.0.0.0" ]; then
+        echo "Error: no valid dns, use default dns." >> $test_log
+        dns="114.114.114.114"
+        dns2="8.8.8.8"
+    fi
+    rm -rf $path_conf"/udhcpd"$c_id".conf"
+	touch $path_conf"/udhcpd"$c_id".conf"
+	echo " " > $path_conf"/udhcpd"$c_id".conf"
+	
+    if [ "-$dns" != "-" -a "-$dns" != "-0.0.0.0" ]; then
+        echo "nameserver $dns" >> /etc/resolv.conf
+    fi
+    if [ "-$dns2" != "-" -a "-$dns2" != "-0.0.0.0" ]; then
+        echo "nameserver $dns2" >> /etc/resolv.conf
+    fi
+    
+    pidfile=$path_conf"/udhcpd"$c_id".pid"
+    leasesfile=$path_conf"/udhcpd"$c_id".leases"
+
+    sh $path_sh/config-udhcpd.sh $c_id -s $start
+    sh $path_sh/config-udhcpd.sh $c_id -e $end
+    sh $path_sh/config-udhcpd.sh $c_id -i $ext_br
+    sh $path_sh/config-udhcpd.sh $c_id -m $mask
+    sh $path_sh/config-udhcpd.sh $c_id -d $dns $dns2
+    if [ "-$gw" != "-" ]; then
+        sh $path_sh/config-udhcpd.sh $c_id -g $gw
+    fi
+    if [ "-$lease" != "-" ]; then
+        sh $path_sh/config-udhcpd.sh $c_id -t $lease
+    fi
+    sh $path_sh/config-udhcpd.sh $c_id -p $pidfile
+    sh $path_sh/config-udhcpd.sh $c_id -l $leasesfile
+	sh $path_sh/config-udhcpd.sh $c_id -r 1
+}
+get_validnum()
+{
+    last4=${ipaddr##*.}
+    ipaddr=${ipaddr%.*}
+    mark=`expr $last4 % 2`
+    last3=0
+    frag=`expr $frag + 1`
+    echo $ipaddr $last4 $last3
+    if [ $last4 -eq 0 ] || [ $last4 -eq 255 ];
+    then
+            last3=${ipaddr##*.}
+    fi
+    if [ $last4 -eq 0 ] && [ $last3 -eq 0 ];
+    then
+        get_validnum
+    elif [ $last4 -eq 255 ] && [ $last3 -eq 255 ];
+    then
+        get_validnum
+    else
+        return
+    fi
+}
+get_netmask_btrunk()
+{
+	pdpip=$1
+	pdp_ip4=${pdpip##*.}
+	front3=${pdpip%.*}
+	
+	if [ $pdp_ip4 -eq 1 ];then 
+        tmp_ip1=`expr $pdp_ip4 + 1`
+        tmp_ip2=`expr $pdp_ip4 + 2`
+        ps_ip="$front3.$tmp_ip1"
+        br_ip="$front3.$tmp_ip2"
+    elif  [ $pdp_ip4 -eq 254 ];then
+		tmp_ip1=`expr $pdp_ip4 - 2`
+		tmp_ip2=`expr $pdp_ip4 - 1`
+		ps_ip="$front3.$tmp_ip1"
+		br_ip="$front3.$tmp_ip2"
+	else
+		tmp_ip1=`expr $pdp_ip4 - 1`
+		tmp_ip2=`expr $pdp_ip4 + 1`
+		ps_ip="$front3.$tmp_ip1"
+		br_ip="$front3.$tmp_ip2"
+    fi
+
+	nv set $ps_if"_ip"=$ps_ip
+	valid_mask="255.255.0.0"
+}
+
+get_netmask()
+{
+    ipaddr=$1
+    last4=0
+    last3=0
+    mark=0
+    frag=0
+    
+    get_validnum
+    echo $ipaddr $last4 $last3 $mark $frag
+    #½«ÓÐЧ¶ÎÖÐÓÐЧλÖÃΪ1£¬¸Ãλ×ó±ß¶¼ÖÃΪ0
+    valid_num=0
+    
+    if [ $mark -eq 1 -a $last3 -eq 0 ];then
+        valid_num=`expr $last4 + 1`
+    elif [ $mark -eq 0 -a $last3 -eq 0 ];then
+        valid_num=$last4
+    elif [ $mark -eq 1 -a $last3 -ne 0 ];then
+        valid_num=`expr $last3 + 1`
+    elif [ $mark -eq 0 -a $last3 -ne 0 ];then
+        valid_num=$last3
+    fi
+    echo  $valid_num
+    #´Ó×óÏòÓÒÕÒµ½ÓÐЧ¶ÎÖеÚÒ»¸ö1µÄλÖÃ
+    place=1
+    while [ `expr $valid_num % 2` -eq 0 ]
+    do
+        place=`expr $place + 1`
+        valid_num=`expr $valid_num / 2`
+    done
+
+    if [ $last3 -eq 0 ]
+    then
+        frag=`expr $frag - 1`
+    fi
+    count=1
+    
+    if [ $place -gt 8 ]
+    then
+        place=`expr $place - 8`
+        frag=`expr $frag + 1`
+    fi
+
+    tmp_place=$place
+    while [ $tmp_place -gt 0 ]
+    do
+        count=`expr $count \* 2`
+        tmp_place=`expr $tmp_place - 1`
+    done
+
+    #ÖÁÉÙÐèÒªÈý¸öÓÐЧipµØÖ·£¨ps¿Ú£¬pc£¬Íø¹Ø£©£¬ÑÚÂë×î´óΪ255.255.255.248
+    if [ $frag -eq 0  -a  $place -eq 2 ]
+    then
+        count=`expr $count + 3`
+    else
+        count=`expr $count - 1`
+    fi
+
+    before=$frag
+    
+    while [ $before -lt 3 ]
+    do
+        valid_mask=$valid_mask"255."
+        before=`expr $before + 1`
+    done
+        valid_mask=$valid_mask"`expr 255 - $count`"
+    while [ $frag -gt 0 ]
+    do
+        valid_mask=$valid_mask".0"
+        frag=`expr $frag - 1`
+    done
+
+    pdpip=$1
+    pdp_ip4=${pdpip##*.}
+    pdp_ip4_tmp=$pdp_ip4
+    front3=${pdpip%.*}
+    
+    tmp_count=0
+    com_num=0
+    while [ $tmp_count -lt 3 ]
+    do
+        valid_count=0
+        
+        if [ `expr $pdp_ip4_tmp % 2` -eq 1 ]
+        then
+            tmp_count1=$tmp_count
+            valid_count=1
+            while [ $tmp_count1 -gt 0 ]
+            do
+                valid_count=`expr $valid_count \* 2`
+                tmp_count1=`expr $tmp_count1 - 1`
+            done
+        fi
+        com_num=`expr $com_num + $valid_count`
+        tmp_count=`expr $tmp_count + 1`
+        pdp_ip4_tmp=`expr $pdp_ip4_tmp / 2`
+    done
+    echo com_num $com_num
+    
+    if [ $com_num -gt 2 ]
+    then 
+        tmp_ip1=`expr $pdp_ip4 - 1`
+        tmp_ip2=`expr $pdp_ip4 - 2`
+        ps_ip="$front3.$tmp_ip1"
+        br_ip="$front3.$tmp_ip2"
+    else
+        tmp_ip1=`expr $pdp_ip4 + 1`
+        tmp_ip2=`expr $pdp_ip4 + 2`
+        ps_ip="$front3.$tmp_ip1"
+        br_ip="$front3.$tmp_ip2"
+    fi
+
+    echo ps_ip $ps_ip br_ip $br_ip valid_mask $valid_mask
+    nv set $ps_if"_ip"=$ps_ip
+}
+#»ñÈ¡ip²¢ÅäÖÃps¡¢eth
+get_ipaddr()
+{
+    pdp_ip=`nv get $ps_if"_pdp_ip"`
+#ÅжÏÊÇ·ÊÇñbtrunkÐͺŻú	
+	btrunk=`cat /sys/module/fast_common/parameters/btrunk_fw`
+	if [ "$btrunk" -eq "0" ];then
+		get_netmask $pdp_ip
+    else
+		get_netmask_btrunk $pdp_ip
+	fi
+	
+	ifconfig $ps_if $ps_ip netmask 255.255.255.0 up 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $ps_if $ps_ip up failed." >> $test_log
+    fi
+	nv set default_wan_rel=$ps_if
+	nv set default_cid=$c_id
+	nv set $ext_br"_ip"=$br_ip
+	ifconfig $ext_br $br_ip 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $ext_br $br_ip up failed." >> $test_log
+    fi
+}
+#·ÓɹæÔò£¬psÓëeth¼¶Áª
+route_set()
+{
+    marknum=`expr $c_id + 20`
+    iptables -t mangle -A PREROUTING -i $ps_if -j MARK --set-mark $marknum
+	rt_num=`expr $c_id + 120`
+    
+    ip route add default dev $ext_br table $rt_num 	
+		
+	ip rule add to $pdp_ip fwmark $marknum table $rt_num
+	
+	marknum=`expr $c_id + 10`
+    iptables -t mangle -A PREROUTING -i $ext_br -j MARK --set-mark $marknum
+	rt_num=`expr $c_id + 100`
+
+    ip route add default dev $ps_if table $rt_num
+	ip rule add from $pdp_ip fwmark $marknum table $rt_num
+
+	ip route flush cache
+    
+    #±¾µØÍøÂçÅäÖÃ
+    iptables -t nat -I POSTROUTING -s $ps_ip -o $ps_if -j SNAT --to $pdp_ip
+    
+	route_info=`route|grep default`
+	
+	if [ "$route_info" == "" ];then
+		route add default dev $ps_if
+	else
+		echo "Debug: default route already exist." >> $test_log
+	fi
+}
+#¹¹½¨ÍøÇÅ
+br_up()
+{
+    br="br"$c_id
+    brctl addbr $br
+    brctl setfd $br 0.1
+    ifconfig $br up 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $br up failed." >> $test_log
+    fi
+	
+	ifconfig $ps_if up 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $ps_if up failed." >> $test_log
+    fi
+    brctl addif $br $ps_if 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: brctl addif $br $ps_if failed." >> $test_log
+    fi
+    brctl addif $br $eth_if 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: brctl addif $br $eth_if failed." >> $test_log
+    fi
+	ifconfig $eth_if up 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $eth_if up failed." >> $test_log
+    fi
+	   
+}
+#ɾ³ýÍøÇÅ
+br_down()
+{
+    br="br"$c_id
+	brctl delif $br $eth_if 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: brctl delif $br $eth_if failed." >> $test_log
+    fi
+	ifconfig $eth_if down 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $eth_if down failed." >> $test_log
+    fi
+	brctl delif $br $ps_if 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: brctl delif $br $ps_if failed." >> $test_log
+    fi
+	ifconfig $ps_if down 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $ps_if down failed." >> $test_log
+    fi
+    ifconfig $br down 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $br down failed." >> $test_log
+    fi
+    brctl delbr $br 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: brctl delbr $br failed." >> $test_log
+    fi
+}
+#ɱËÀ¶ÔÓ¦µÄDHCP½ø³Ì
+dhcp_kill()
+{
+    pidfile=$path_conf"/udhcpd"$c_id".pid"
+	kill `cat $pidfile`
+}
+#ɾ³ý¶ÔÓ¦µÄ·ÓɹæÔò
+route_del()
+{
+    pdp_ip=`nv get $ps_if"_pdp_ip"`
+#	ps_ip1=${pdp_ip%.*}
+#	ps_ip2=${pdp_ip##*.}
+#	[ "$ps_ip2" -ge "254" ] && { ps_ip2="250"; }
+#	ps_ip2=`expr $ps_ip2 + 1`
+	ps_ip=`nv get $ps_if"_ip"`
+	br_ip=`nv get $ext_br"_ip"`
+	marknum=`expr $c_id + 10`
+	rt_num=`expr $c_id + 100`
+	
+	iptables -t mangle -D PREROUTING -i $ext_br -j MARK --set-mark $marknum
+	ip rule del from $pdp_ip fwmark $marknum table $rt_num 
+    ip route del default dev $ps_if table $rt_num
+	
+    marknum=`expr $c_id + 20`
+	rt_num=`expr $c_id + 120`
+    iptables -t mangle -D PREROUTING -i $ps_if -j MARK --set-mark $marknum
+	ip rule del to $pdp_ip fwmark $marknum table $rt_num
+    ip route del default dev $ext_br table $rt_num 
+	#±¾µØÍøÂçÅäÖÃ
+    iptables -t nat -D POSTROUTING -s $ps_ip -o $ps_if -j SNAT --to $pdp_ip
+    if [ $? -ne 0 ];then
+        echo "cmd <<iptables -t nat -D POSTROUTING -s $ps_ip -o $ps_if -j SNAT --to $pdp_ip>> exec failed"  >> $test_log
+    fi
+    route delete default dev $ps_if
+    if [ $? -ne 0 ];then
+        echo "cmd <<route delete default dev $ps_if>> exec failed"  >> $test_log
+    fi
+	
+    ifconfig $ext_br 0.0.0.0
+	ifconfig $ext_br down 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $ext_br down failed." >> $test_log
+    fi
+    
+    ifconfig $ps_if 0.0.0.0
+	ifconfig $ps_if down 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $ps_if down failed." >> $test_log
+    fi
+	
+    #reset nv
+    nv set $ext_br"_ip"=0.0.0.0
+    nv set $ext_br"_nm"=0.0.0.0
+    nv set $ps_if"_pdp_ip"=0.0.0.0
+    nv set $ps_if"_pridns"=0.0.0.0
+    nv set $ps_if"_secdns"=0.0.0.0
+    nv set $ps_if"_ip"=0.0.0.0
+}
+
+if [ "-$1" == "-linkup" ]; then
+	mtu=`nv get mtu`
+	ifconfig $ps_if mtu $mtu
+	if [ "-$ps_ext_mode" == "-1" ]; then
+        brctl addbr $ext_br
+        brctl setfd $ext_br 0.1
+        brctl addif $ext_br $eth_if
+        ifconfig $ext_br up
+        get_ipaddr
+		dhcp_set
+	    route_set
+		arp_proxy_set
+        ifconfig $eth_if up
+	ismbim=`ps |grep -v grep |grep -w mbim |awk '{printf $1}'`
+	if [ "-$ismbim" != "-" ]; then
+		eth_mac=`cat "/sys/class/net/"$eth_if"/address"`
+		arp -s $pdp_ip $eth_mac 2>>$test_log
+	fi
+		tc_tbf.sh up $c_id
+	elif [ "-$ps_ext_mode" == "-0" ]; then
+	    br_up
+	fi	
+elif [ "-$1" == "-linkdown" ]; then
+    if [ "-$ps_ext_mode" == "-1" ]; then
+		tc_tbf.sh down $c_id
+		arp_proxy_kill
+        dhcp_kill
+	    route_del
+        ifconfig $eth_if down
+        ifconfig $ext_br down
+        brctl delif $ext_br $eth_if
+        brctl delbr $ext_br 
+        echo "" > /etc/resolv.conf
+	elif [ "-$ps_ext_mode" == "-0" ]; then
+	    br_down
+	fi	
+fi
diff --git a/ap/app/Script/scripts/psext_updown_ipv6.sh b/ap/app/Script/scripts/psext_updown_ipv6.sh
new file mode 100755
index 0000000..a48bd73
--- /dev/null
+++ b/ap/app/Script/scripts/psext_updown_ipv6.sh
@@ -0,0 +1,446 @@
+#!/bin/sh
+
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+
+#echo "Info: psext_updown_ipv6.sh $1 $2 start" >> $test_log
+
+c_id=$2
+
+dhcp6s_conf=$path_conf/dhcp6s$c_id.conf
+radvd_conf=$path_conf/radvd$c_id.conf
+ndp_log=$path_conf/ndp$c_id.log
+radvd_pidfile=$path_tmp/radvd$c_id.pid
+
+ps_if=`nv get pswan`$c_id
+eth_if=`nv get "ps_ext"$c_id`
+ps_ext_mode=`nv get need_jilian`
+br_if="br"$c_id
+dnsconfig=0
+prefix_len=64
+echo "Info: psext_updown_ipv6.sh $ps_ext_mode $ps_if $eth_if $br_if start" >> $test_log
+
+b_dhcpv6stateEnabled=`nv get dhcpv6stateEnabled`
+b_dhcpv6statelessEnabled=`nv get dhcpv6statelessEnabled`
+
+#采用PDP激活方式,没有dhcp6c进程
+
+#############linkup  dhcpserver set############
+linkup_add_dns_to_dhcp6s_radvd_conf()
+{
+    #直连模式没有手动DNS
+    ipv6_pridns_auto=`nv get $ps_if"_ipv6_pridns_auto"`
+    ipv6_secdns_auto=`nv get $ps_if"_ipv6_secdns_auto"`
+
+    if [ -n "$ipv6_pridns_auto" ] && [ "-$ipv6_pridns_auto" != "-::" ] && [ "-$ipv6_pridns_auto" != "-::0" ];then
+        ipv6_prefer_dns=$ipv6_pridns_auto
+    fi
+
+    if [ -n "$ipv6_secdns_auto" ] && [ "-$ipv6_secdns_auto" != "-::" ] && [ "-$ipv6_secdns_auto" != "-::0" ];then
+        ipv6_standby_dns=$ipv6_secdns_auto
+    fi
+
+    if [ "-$ipv6_prefer_dns" == "-" -a "-$ipv6_standby_dns" == "-" ]; then
+        return
+    else
+        if [ -n "$1" ] && [ "-$1" == "-dhcp6s" ] ;then
+            echo -e "\toption dns_servers $ipv6_prefer_dns $ipv6_standby_dns;" >> $dhcp6s_conf
+        elif [ -n "$1" ] && [ "-$1" == "-radvd" ] ;then
+            # del last line
+            sed -i '$d' $radvd_conf
+            echo -e "\tRDNSS $ipv6_prefer_dns $ipv6_standby_dns\n\t{" >> $radvd_conf
+            echo -e "\t\tAdvRDNSSPreference 15;" >> $radvd_conf
+            echo -e "\t\tAdvRDNSSOpen on;" >> $radvd_conf
+            echo -e "\t};\n};" >> $radvd_conf
+        fi
+		
+        if [ "-$dnsconfig" == "-0" ]; then
+            echo "dnsconfig $1 $ipv6_prefer_dns, $ipv6_standby_dns" >> $test_log
+            if [ "-$ipv6_prefer_dns" != "-" ]; then
+                echo "nameserver $ipv6_prefer_dns" >> /etc/resolv.conf
+            fi
+            if [ "-$ipv6_standby_dns" != "-" ]; then
+                echo "nameserver $ipv6_standby_dns" >> /etc/resolv.conf
+            fi
+            dnsconfig=1
+        fi
+    fi
+}
+
+linkup_dhcpv6_set()
+{
+    dhcpv6_start=$pdp_ip
+    dhcpv6_end=$pdp_ip
+    
+    #nv值非空则表示用户设置了静态ip、gw
+    gw=`nv get $ps_if"_ipv6_gw"`
+    
+    echo -e "interface $br_if {" > $dhcp6s_conf
+    if [ "-$b_dhcpv6stateEnabled" = "-1" ];then
+        echo -e "\tserver-preference 255;\n\trenew-time 6000;" >> $dhcp6s_conf
+        echo -e "\trebind-time 9000;\n\tprefer-life-time 1300;" >> $dhcp6s_conf
+        echo -e "\tvalid-life-time 2000;\n\tallow rapid-commit;" >> $dhcp6s_conf
+        echo -e "\tlink $br_if {\n\t\tallow unicast;\n\t\tsend unicast;" >> $dhcp6s_conf
+        echo -e "\t\tpool {\n\t\t\trange $dhcpv6_start to $dhcpv6_end/$prefix_len;" >> $dhcp6s_conf
+        echo -e "\t\t};\n\t};" >> $dhcp6s_conf
+        linkup_add_dns_to_dhcp6s_radvd_conf dhcp6s
+        echo -e "};" >> $dhcp6s_conf
+        dhcp6s -dDf -c $dhcp6s_conf $br_if &
+    else
+        #slaac with dhcp statelessset dns info
+        if [ "-$b_dhcpv6statelessEnabled" = "-1" ];then
+            echo -e "\tlink $br_if {\n\t};" >> $dhcp6s_conf
+            linkup_add_dns_to_dhcp6s_radvd_conf dhcp6s
+            echo -e "};" >> $dhcp6s_conf
+            dhcp6s -dDf -c $dhcp6s_conf $br_if &
+			if [ $? -ne 0 ];then
+                echo "Error: dhcp6s -dDf -c $dhcp6s_conf $br_if failed." >> $test_log
+            fi
+        fi
+    fi
+}
+
+#获取ip并配置ps、eth
+linkup_get_addr()
+{
+    #disable the forwarding to send RS and not set the addr when receive ra packet
+    echo 0 > /proc/sys/net/ipv6/conf/all/forwarding
+    echo 0 > /proc/sys/net/ipv6/conf/$ps_if/accept_ra
+    echo 0 > /proc/sys/net/ipv6/conf/$eth_if/accept_ra
+    echo 0 > /proc/sys/net/ipv6/conf/$br_if/accept_ra
+    #call the slaac program to get the prefix addr 
+    ifconfig $ps_if up 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $ps_if up failed." >> $test_log
+    fi
+	prefix_info_temp=`nv get $ps_if"_ipv6_prefix_info"`
+	#如果当前没有前缀,则直接启动slaac,如果当前前缀已经设置,则说明已经获取到,直接配置IP地址即可
+	if [ -n "$prefix_info_temp" -a "-$prefix_info_temp" != "-::" ]; then
+		ret_code=0
+	else
+		sleep 1
+		interface_id_temp1=`nv get $ps_if"_ipv6_interface_id"`
+		local_ipv6_addr="fe80::"$interface_id_temp1
+		local_ipv6_addr_nv="$ps_if""_local_ipv6_addr"
+		nv set $local_ipv6_addr_nv=$local_ipv6_addr
+		ip -6 addr add $local_ipv6_addr/64 dev $ps_if 2>>$test_log
+		zte_ipv6_slaac -i "$ps_if" 
+		ret_code=$?
+	fi
+    echo "Info: zte_ipv6_slaac return: $ret_code" >> $test_log
+    echo "the program zte_ipv6_slaac return  = $ret_code"
+    if [ $ret_code -eq 0 ]; then
+        echo "the zte_ipv6_slaac success"
+        interface_id_temp=`nv get $ps_if"_ipv6_interface_id"`
+        prefix_info_temp=`nv get $ps_if"_ipv6_prefix_info"`
+        prefix_len=`nv get $ps_if"_ipv6_prefix_len"`
+        echo "##############1##########"
+        echo "$interface_id_temp"
+        echo "$prefix_info_temp $prefix_len"
+        echo "##############2##########"
+        
+        #pdp 激活的ipv6地址
+        pdp_ip=$prefix_info_temp$interface_id_temp
+        #pdp激活地址,适配页面使用
+        nv set ipv6_wan_ipaddr="$pdp_ip"
+        
+        ipv6_addr_conver $pdp_ip "$ps_if"
+        
+        #给eth分配地址,使用ipv6_addr_conver在第15+1
+        br_ip=`nv get ipv6_br0_addr`
+        brctl addbr $br_if
+        brctl setfd $br_if 0.1
+        nv set $br_if"_ipv6_ip"=$br_ip
+        ifconfig $br_if up 2>>$test_log
+		if [ $? -ne 0 ];then
+            echo "Error: ifconfig $br_if up failed." >> $test_log
+        fi
+        ip -6 addr add $br_ip/64 dev $br_if 
+        #给外网口分配地址,使用ipv6_addr_conver在第15+2
+        ps_ip=`nv get $ps_if"_dhcpv6_start"`
+        nv set $ps_if"_ipv6_ip"=$ps_ip
+        #ifconfig $ps_if $ps_ip up
+		#if [ $? -ne 0 ];then
+	    #    echo "Error: ifconfig $ps_ip up failed." >> $test_log
+        #fi
+        ip -6 addr add $ps_ip/126 dev $ps_if 2>>$test_log
+		if [ $? -ne 0 ];then
+	        echo "Error: ip -6 addr add $ps_ip/126 dev $ps_if failed." >> $test_log
+        fi
+		nv set $ps_if"_ipv6_state"="working"
+        
+        echo "Info: zte_ipv6_slaac pdp_ip: $pdp_ip" >> $test_log
+        echo "Info: zte_ipv6_slaac ps_ip: $ps_ip" >> $test_log
+        echo "Info: zte_ipv6_slaac br_ip: $br_ip" >> $test_log
+    else
+        echo "the zte_ipv6_slaac fail"
+		nv set $ps_if"_ipv6_state"="dead"
+        exit 1
+    fi
+}
+
+#路由规则,ps与eth级联
+linkup_route_set()
+{
+    echo 0 > /proc/sys/net/ipv6/conf/all/forwarding 
+
+    marknum=`expr $c_id + 60`
+    ip6tables -t mangle -A PREROUTING -i $ps_if -j MARK --set-mark $marknum
+    rt_num=`expr $c_id + 160`
+    ip -6 route add default dev $br_if table $rt_num 	
+    ip -6 rule add to $pdp_ip/64 fwmark $marknum table $rt_num
+
+    marknum=`expr $c_id + 50`
+    ip6tables -t mangle -A PREROUTING -i $br_if -j MARK --set-mark $marknum
+    rt_num=`expr $c_id + 150`
+    ip -6 route add default dev $ps_if table $rt_num
+    ip -6 rule add from $pdp_ip/64 fwmark $marknum table $rt_num
+
+    ip6tables -t filter -A FORWARD -p icmpv6 --icmpv6-type 135 -j DROP
+	
+    ip -6 route flush cache
+	
+    #这句设完,里面可以ping通外网了
+    echo "Info: route_set ps_ip=$ps_ip" >> $test_log
+    #ip -6 route add default via $ps_ip dev $ps_if
+    ip -6 route add default dev $ps_if 2>>$test_log
+    if [ $? -ne 0 ];then
+	    echo "Error: ip -6 route add default dev $ps_if failed." >> $test_log
+    fi
+		
+    #enable ipv6 packet forwarding
+    echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
+    echo 1 > /proc/sys/net/ipv6/conf/$ps_if/accept_ra
+    echo 1 > /proc/sys/net/ipv6/conf/$eth_if/accept_ra
+    echo 1 > /proc/sys/net/ipv6/conf/$br_if/accept_ra
+    #enable ipv6 neigh discovery proxy
+    echo 1 > /proc/sys/net/ipv6/conf/all/proxy_ndp
+    
+    ndp_kill
+    zte_ndp -a -s $br_if -d $ps_if -l $ndp_log -p &
+}
+
+#############linkup radvd set############
+linkup_radvd_set() 
+{
+    echo "enter linkup_radvd_set "
+    
+    rm -rf $radvd_conf
+    
+    if [ "-$b_dhcpv6stateEnabled" = "-1" ];then
+        echo -e "interface $br_if\n{\n\tAdvSendAdvert on;" > $radvd_conf
+        echo -e "\tAdvManagedFlag on;\n};" >> $radvd_conf
+        radvd_kill
+		rm -rf $radvd_pidfile
+        radvd -d 3 -C $radvd_conf -p $radvd_pidfile&
+        echo  "leave linkup_radvd_set "
+        return
+    fi
+    
+    echo "Info: psext_updown_ipv6.sh br_if:$br_if, prefix_len:$prefix_len" >> $test_log
+    echo "ipv6_br0_addr_tmp:$ipv6_br0_addr_tmp"
+    echo "prefix_len:$prefix_len"
+    
+    cp $path_ro/radvd_template.conf $radvd_conf
+	
+	sed  -i -e 's/#ipv6_wan_addr#\/64/#ipv6_wan_addr#\/#prefix_len#/g' $radvd_conf
+    sed  -i -e s/br0/$br_if/g $radvd_conf
+    sed  -i -e s/#ipv6_wan_addr#/$br_ip/g $radvd_conf 
+    sed  -i -e s/#prefix_len#/$prefix_len/g $radvd_conf
+    sed  -i -e s/#adv_switch#/on/g $radvd_conf 
+
+    # TODO: replace br0's ipv6 address
+    #sed  -i -e s/#ipv6_wan_addr#/$wan_addr/g $radvd_conf
+    #sed  -i -e s/#adv_switch#/on/g $radvd_conf 
+
+    #slaac with dns info
+    if [ "-$b_dhcpv6statelessEnabled" = "-1" ];then
+        echo "use dhcpv6stateless for dns"
+    else
+        sed -i -e 's/AdvOtherConfigFlag on;/AdvOtherConfigFlag off;/g' $radvd_conf
+        linkup_add_dns_to_dhcp6s_radvd_conf radvd
+    fi
+
+    radvd_kill
+    sleep 1
+	rm -rf $radvd_pidfile
+    radvd -d 3 -C $radvd_conf -p $radvd_pidfile &
+    
+    echo  "leave linkup_radvd_set "
+}
+
+#构建网桥
+br_up()
+{
+    br="br"$c_id
+    brctl addbr $br 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: brctl addbr $br failed." >> $test_log
+    fi
+    brctl setfd $br 0.1 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: brctl setfd $br 0.1 failed." >> $test_log
+    fi
+    ifconfig $br up 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $br up failed." >> $test_log
+    fi
+    
+    ifconfig $ps_if up 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $ps_if up failed." >> $test_log
+    fi
+    brctl addif $br $ps_if 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: brctl addif $br $ps_if failed." >> $test_log
+    fi
+    
+    brctl addif $br $eth_if 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: brctl addif $br $eth_if failed." >> $test_log
+    fi
+    ifconfig $eth_if up 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $eth_if up failed." >> $test_log
+    fi
+}
+
+#删除网桥
+br_down()
+{
+    br="br"$c_id
+    brctl delif $br $eth_if 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: brctl delif $br $eth_if failed." >> $test_log
+    fi
+    ifconfig $eth_if down 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $eth_if down failed." >> $test_log
+    fi
+    brctl delif $br $ps_if 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: brctl delif $br $ps_if failed." >> $test_log
+    fi
+    ifconfig $ps_if down 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $ps_if down failed." >> $test_log
+    fi
+    ifconfig $br down 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $br down failed." >> $test_log
+    fi
+    brctl delbr $br 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: brctl delbr $br failed." >> $test_log
+    fi
+}
+
+#清除相应的radvd进程
+linkdown_radvd_set()
+{
+    #跟终端连接的网口直接会down,所以不用像ufi一样设置成1s有效期
+    radvd_kill
+}
+
+#清除相应的DHCPv6进程
+linkdown_dhcpv6_server_set()
+{
+    dhcp6s_kill
+}
+
+#删除相应的ipv6路由规则
+linkdown_route_set()
+{
+    br_ip=`nv get $br_if"_ipv6_ip"`
+    ps_ip=`nv get $ps_if"_ipv6_ip"`
+    pdp_ip=`nv get ipv6_wan_ipaddr`
+
+    ip6tables -t filter -D FORWARD -p icmpv6 --icmpv6-type 135 -j DROP
+	
+    marknum=`expr $c_id + 50`
+    rt_num=`expr $c_id + 150`
+    ip -6 rule del from $pdp_ip/64 fwmark $marknum table $rt_num
+    ip6tables -t mangle -D PREROUTING -i $br_if -j MARK --set-mark $marknum
+    ip -6 route del default dev $ps_if table $rt_num
+
+    marknum=`expr $c_id + 60`
+    rt_num=`expr $c_id + 160`
+    ip -6 rule del to $pdp_ip/64 fwmark $marknum table $rt_num
+    ip6tables -t mangle -D PREROUTING -i $ps_if -j MARK --set-mark $marknum
+    ip -6 route del default dev $br_if table $rt_num
+
+    ip -6 addr del $br_ip/126 dev $br_if
+	#if [ $? -ne 0 ];then
+	#    echo "Error: ip -6 addr del $eth_ip/126 dev $eth_if failed." >> $test_log
+    #fi
+    ip -6 addr del $ps_ip/126 dev $ps_if
+	#if [ $? -ne 0 ];then
+	#    echo "Error: ip -6 addr del $ps_ip/126 dev $ps_if  failed." >> $test_log
+    #fi
+    ip -6 route del default
+	#if [ $? -ne 0 ];then
+	#    echo "Error: ip -6 route del default failed." >> $test_log
+    #fi
+
+    ifconfig $br_if down 2>>$test_log
+	if [ $? -ne 0 ];then
+        echo "Error: ifconfig $br_if down failed." >> $test_log
+    fi
+    ifconfig $ps_if down 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: ifconfig $ps_if down failed." >> $test_log
+    fi
+
+    echo 0 > /proc/sys/net/ipv6/conf/$ps_if/accept_ra
+	
+    #reset nv 
+    nv set $br_if"_ipv6_ip"="::"
+    nv set $ps_if"_ipv6_ip"="::"
+    nv set $ps_if"_ipv6_pridns_auto"="::"
+    nv set $ps_if"_ipv6_secdns_auto"="::"
+    nv set $ps_if"_ipv6_gw"="::"
+    nv set $ps_if"_ipv6_interface_id"="::"
+    nv set $ps_if"_ipv6_prefix_info"="::"
+    nv set $ps_if"_dhcpv6_start"="::"
+    nv set $ps_if"_dhcpv6_end"="::"
+
+    #适配页面等其他地方使用老NV
+    nv set ipv6_wan_ipaddr="::"
+	nv set $ps_if"_ipv6_state"="dead"
+	
+	local_ipv6_addr_nv="$ps_if""_local_ipv6_addr"
+	nv set $local_ipv6_addr_nv="::"
+
+    ndp_kill
+}
+
+if [ "$1" == "linkup" ]; then
+	mtu=`nv get mtu`
+	ifconfig $ps_if mtu $mtu
+    if [ "-$ps_ext_mode" == "-1" ]; then
+        linkup_get_addr
+        linkup_route_set
+        linkup_dhcpv6_set
+        linkup_radvd_set
+        brctl addif $br_if $eth_if
+		ifconfig $eth_if up
+		tc_tbf.sh up $c_id
+    elif [ "-$ps_ext_mode" == "-0" ]; then
+        br_up
+    fi
+elif [ "$1" == "linkdown" ]; then
+    if [ "-$ps_ext_mode" == "-1" ]; then
+        tc_tbf.sh down $c_id
+        linkdown_radvd_set
+        linkdown_dhcpv6_server_set
+        linkdown_route_set
+        slaac_kill
+        brctl delif $br_if $eth_if
+        ifconfig $eth_if down
+        echo "" > /etc/resolv.conf
+    elif [ "-$ps_ext_mode" == "-0" ]; then
+        br_down
+    fi
+fi
+
+echo "Info: psext_updown_ipv6.sh leave" >> $test_log
diff --git a/ap/app/Script/scripts/start_telnetd.sh b/ap/app/Script/scripts/start_telnetd.sh
new file mode 100644
index 0000000..9ed0fc3
--- /dev/null
+++ b/ap/app/Script/scripts/start_telnetd.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+flag=`nv get telnetd_enable`
+
+if [ "$flag" == "y" ]; then
+    echo "Starting telnetd......!"
+    /usr/sbin/telnetd -p 4719 & 
+fi
+
+
diff --git a/ap/app/Script/scripts/start_update_app.sh b/ap/app/Script/scripts/start_update_app.sh
new file mode 100644
index 0000000..aec2890
--- /dev/null
+++ b/ap/app/Script/scripts/start_update_app.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# $Id: lan.sh
+#
+
+update_type=`nv get update_type`
+fota_dm_vendor=`nv get fota_dm_vendor`
+if [ "$update_type" == "mifi_local" ]; then
+    echo "update_type: mifi_local"
+fi
+
+if [ "$update_type" == "mifi_fota" ]; then
+    echo "update_type: mifi_fota"
+	if [ "$fota_dm_vendor" == "zx" ]; then
+		fota_dm_zx &
+	else
+		fota_dm_gs &
+	fi
+fi
+
+if [ "$update_type" == "mdl_local" ]; then
+    echo "update_type: mdl_local"
+	localUpdate &
+fi
+
+if [ "$update_type" == "mdl_fota" ]; then
+    echo "update_type: mdl_fota"
+	if [ "$fota_dm_vendor" == "zx" ]; then
+		fota_dm_zx &
+	else
+		fota_dm_gs &
+	fi
+fi
+
+if [ "$update_type" == "none" ]; then
+    echo "update_type: none"
+fi
\ No newline at end of file
diff --git a/ap/app/Script/scripts/tc_tbf.sh b/ap/app/Script/scripts/tc_tbf.sh
new file mode 100644
index 0000000..a893cba
--- /dev/null
+++ b/ap/app/Script/scripts/tc_tbf.sh
@@ -0,0 +1,126 @@
+#!/bin/sh
+# ===========================================================
+# usage: tc_control.sh
+# traffic control by tc_uplink and tc_downlink
+
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+
+echo "Info: tc_tbf $1 $2 start "
+echo "Info: tc_tbf $1 $2 start" >> $test_log
+
+#Á÷¿ØÉÏÏÂÐз§Öµ£¬Îª¿Õ»òΪ0±íʾ²»½øÐÐÁ÷¿Ø£¬ÔÝʱֻʵÏÖÉÏÐеÄtc£¬ÏÂÐн«À´¸ù¾Ýʵ¼ÊÐèÒªÔÙÀ©Õ¹ÊµÏÖ
+UPLINK=`nv get tc_uplink`
+DOWNLINK=`nv get tc_downlink`
+def_cid=`nv get default_cid`
+tc_enable=`nv get tc_enable`
+
+#tc_enable=0£¬Á÷Á¿¿ØÖƹ¦Äܹرգ¬Ö±½ÓÍ˳ö
+if [ "$tc_enable" == "0" ]; then
+	echo "tc_enable=0" 
+	echo "tc_enable=0" >> $test_log
+	exit 0
+fi
+
+#ÉÏÏÂÐеijö¿ÚdevÐèÒª¸ù¾Ýʵ¼ÊÇé¿öÑ¡Ôñ
+need_jilian=`nv get need_jilian`
+lanEnable=`nv get LanEnable`
+if [ "$need_jilian" == "1" ]; then
+    if [ "$lanEnable" == "1" ]; then
+        IN=`nv get lan_name`
+    elif [ "$lanEnable" == "0" ]; then
+        IN=`nv get "ps_ext"$def_cid`
+    fi
+elif [ "$need_jilian" == "0" ]; then
+    IN=`nv get lan_name`
+fi
+
+#˫ջʱ£¬ipv4ºÍipv6µÄĬÈÏÍâÍø¿Ú¿ÉÄܲ»Ò»Ö£¬ËäÈ»¶ÌÆÚÄÚ¶¼²»»áÓÐʵ¼Ê³¡¾°
+OUT4=$defwan_rel
+OUT6=$defwan6_rel
+
+if [ "$lanEnable" == "1" ]; then
+    GATEWAY=`nv get lan_ipaddr`
+fi
+
+echo "IN=$IN, OUT4=$OUT4, OUT6=$OUT6, GATEWAY=$GATEWAY, DOWNLINK=$DOWNLINK, UPLINK=$UPLINK"
+echo "IN=$IN, OUT4=$OUT4, OUT6=$OUT6, GATEWAY=$GATEWAY, DOWNLINK=$DOWNLINK, UPLINK=$UPLINK" >> $test_log
+
+#Çå¿ÕÔ­ÏȵÄÁ÷³Ì¹æÔò
+tc qdisc del dev $IN root
+if [ "$OUT4" != "" ]; then
+    tc qdisc del dev $OUT4 root
+fi
+if [ "$OUT6" != "" -a "$OUT6" != "$OUT4" ]; then
+    echo "clear tc for $OUT6"
+    tc qdisc del dev $OUT6 root
+fi
+
+#¸øÄں˻ָ´¿ìËÙת·¢¼¶±ð
+fastnat_level=`nv get fastnat_level`
+echo "Info: fastnat_level restore to£º$fastnat_level" >> $test_log
+echo $fastnat_level > /proc/net/fastnat_level
+
+ifconfig $IN txqueuelen 10
+if [ "$OUT4" != "" ]; then
+    ifconfig $OUT4 txqueuelen 10
+fi
+if [ "$OUT6" != "" -a "$OUT6" != "$OUT4" ]; then
+    ifconfig $OUT6 txqueuelen 10
+fi
+
+#ÊÊÅä֮ǰµÄ¿Í»§£ºÈç¹û$1²»µÈÓÚdown/DOWN£¬¾Í°´up/UP´¦Àí
+if [ "$1" == "down" -o "$1" == "DOWN" ]; then
+	echo "traffic control down" 
+	echo "traffic control down" >> $test_log
+	exit 0
+fi
+
+if [ "$DOWNLINK" == "" -o "$DOWNLINK" == "0" ] && [ "$UPLINK" == "" -o "$UPLINK" == "0" ]; then
+    echo "no need to traffic control"
+    echo "no need to traffic control" >> $test_log
+    exit 0
+fi
+
+#Ôݶ¨uc/v2¶¼ÐèÒª¹Ø±Õ¿ìËÙת·¢
+
+echo 0 > /proc/net/fastnat_level
+
+if [ "$DOWNLINK" != "0" -a "$DOWNLINK" != "" ]; then
+    echo "traffic control for down"
+    echo "traffic control for down" >> $test_log
+    
+    LOCAL=`nv get tc_local`
+    SUM=`expr ${DOWNLINK} + ${LOCAL}`
+    echo "LOCAL=$LOCAL, SUM=$SUM"
+    echo "LOCAL=$LOCAL, SUM=$SUM" >> $test_log
+    
+    ifconfig $IN txqueuelen 1000
+
+    #ÏÞËٵĴóСµ¥Î»ËäÈ»ÊÇbps£¬µ«Êµ¼ÊÊÇ×Ö½Ú
+    tc qdisc add dev $IN root handle 1: htb default 20
+    tc class add dev $IN parent 1: classid 1:1 htb rate ${SUM}bps
+    tc class add dev $IN parent 1:1 classid 1:20 htb rate ${DOWNLINK}bps
+    tc class add dev $IN parent 1:1 classid 1:10 htb rate ${LOCAL}bps
+    tc qdisc add dev $IN parent 1:10 handle 10: sfq perturb 10
+    tc qdisc add dev $IN parent 1:20 handle 20: sfq perturb 10
+    tc filter add dev $IN protocol ip parent 1:0 prio 1 u32 match ip src ${GATEWAY}/32 match ip sport 80 0xffff flowid 1:10
+fi
+
+if [ "$UPLINK" != "0" -a "$UPLINK" != "" ]; then
+    if [ "$OUT4" != "" ]; then
+        echo "traffic control for up - ipv4"
+        echo "traffic control for up - ipv4" >> $test_log
+        ifconfig $OUT4 txqueuelen 1000
+        tc qdisc add dev $OUT4 root handle 1: htb default 1
+        tc class add dev $OUT4 parent 1: classid 1:1 htb rate ${UPLINK}bps
+    fi
+
+    if [ "$OUT6" != "" -a "$OUT6" != "$OUT4" ]; then
+        echo "traffic control for up - ipv6"
+        echo "traffic control for up - ipv6" >> $test_log
+        ifconfig $OUT6 txqueuelen 1000
+        tc qdisc add dev $OUT6 root handle 1: htb default 1
+        tc class add dev $OUT6 parent 1: classid 1:1 htb rate ${UPLINK}bps
+    fi
+fi
\ No newline at end of file
diff --git a/ap/app/Script/scripts/to_mnt_ubifs.sh b/ap/app/Script/scripts/to_mnt_ubifs.sh
new file mode 100644
index 0000000..abaa4a9
--- /dev/null
+++ b/ap/app/Script/scripts/to_mnt_ubifs.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+#Author: comlee
+#
+
+#外部传参 
+# 参数1: mount点
+# 参数2: 分区名
+RECVFS_MTD_NUM=`cat /proc/mtd | grep "$2\"" | awk '{print $1}'| cut -b 4- |sed 's/://g'`
+ubiattach /dev/ubi_ctrl -m ${RECVFS_MTD_NUM}
+echo "attach $2  $1"
+
+if [ $? != 0 ];then
+	echo "fail to attach $2"	
+	exit 1
+fi
+
+UBIDEV_NUM=`ls /sys/devices/virtual/ubi|wc -l`
+MYTMP=0
+
+if [ ! -e $1 ]; then
+	mkdir -p $1
+fi
+
+while :
+do
+	if [ -e /sys/devices/virtual/ubi/ubi${MYTMP} ]; then
+		TMPDEV=`cat /sys/devices/virtual/ubi/ubi${MYTMP}/mtd_num`
+		if [ $TMPDEV -eq ${RECVFS_MTD_NUM} ]; then
+#			umount $1
+			mount -t ubifs  -o rw,sync,noatime ubi${MYTMP}_0 $1
+			exit 0
+		fi
+	else
+		if [ ${MYTMP} -ge ${UBIDEV_NUM} ]; then
+			exit 1
+		fi
+	fi
+	MYTMP=`expr $MYTMP + 1`
+done
+
+
diff --git a/ap/app/Script/scripts/udhcpc.sh b/ap/app/Script/scripts/udhcpc.sh
new file mode 100644
index 0000000..1cdeae0
--- /dev/null
+++ b/ap/app/Script/scripts/udhcpc.sh
@@ -0,0 +1,155 @@
+#!/bin/sh
+# udhcpc script edited by Tim Riker <Tim@Rikers.org>
+
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+
+echo "Info: udhcpc.sh $1 $2 start" >> $test_log
+
+[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
+
+RESOLV_CONF=$path_conf"/resolv.conf"
+#broadcast´æÔÚʱºò£¬ÉèÖÃBROADCAST
+[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
+#subnet´æÔÚʱºò£¬ÉèÖÃNETMASK
+[ -n "$subnet" ] && NETMASK="netmask $subnet"
+
+deconfig_wan()
+{   
+    nv set $1"_ip"=0.0.0.0
+    nv set $1"_nm"=0.0.0.0
+    nv set $1"_gw"=0.0.0.0
+    nv set $1"_pridns"=0.0.0.0
+    nv set $1"_secdns"=0.0.0.0	
+}
+
+get_wan_name()
+{
+    c_id="0"
+	ps_name=`nv get pswan`
+	rj45_name=`nv get ethwan`
+	wifi_name=`nv get wifiwan`
+	case "$1" in
+	    $ps_name"1")
+            wanname="pswan"	
+			c_id="1" ;;
+		$ps_name"2")
+            wanname="pswan"	
+			c_id="2" ;;
+		$ps_name"3")
+            wanname="pswan"	
+			c_id="3" ;;
+		$ps_name"4")
+            wanname="pswan"	
+			c_id="4" ;;
+        $rj45_name)
+            wanname="ethwan"  ;;
+        $wifi_name)
+            wanname="wifiwan" ;;		
+    esac	
+}
+
+
+case "$1" in
+    deconfig)
+   		echo "case deconfig "
+        ifconfig $interface 0.0.0.0 2>>$test_log
+        if [ $? -ne 0 ];then
+	        echo "Error: ifconfig $interface 0.0.0.0 failed." >> $test_log
+        fi
+		deconfig_wan $interface 2>>$test_log
+		(router_msg_proxy ipv4 udhcpc.sh >> $test_log 2>&1 || echo "Error: router_msg_proxy ipv4 udhcpc.sh failed." >> $test_log) &
+         echo "case deconfig over"
+		 
+		 step=`nvram_get 2860 step_tmp`
+		 if [ "-$step" = "-" ];then
+			step=0
+		 fi
+		 
+		 echo "step=$step"
+		 
+		 step=`expr $step + 1`
+		 nv set step_tmp=$step
+		 
+		 if [ "-$step" = "-3" ];then
+			nv set step_tmp=0
+		 fi
+		 	 
+        ;;
+
+    renew|bound)
+    	echo "case renew bound"
+        
+		get_wan_name $interface	
+		if [ "-$wanname" == "-ethwan" -o "-$wanname" == "-wifiwan" ]; then
+			(router_msg_proxy del_timer $wanname >> $test_log 2>&1 || echo "Error: router_msg_proxy del_timer failed." >> $test_log) &
+		fi
+
+        #µ÷Óøýű¾Æðudhcpʱºò£¬ÅжÏinterfaceÊÇ·ñºÍethwanÆ¥Å䣬ƥÅäÔòÆðethwan,·ñÔòÓÃÔ­interface
+		ethwan_tmp=`nv get ethwan`
+        sw0_flag=`echo $ethwan_tmp | grep $interface`
+        if [ "-${sw0_flag}" != "-" ];then
+            interface=${ethwan_tmp}
+        fi
+		ifconfig $interface $ip $BROADCAST $NETMASK 2>>$test_log
+		if [ $? -ne 0 ];then
+	        echo "Error: ifconfig $interface $ip $BROADCAST $NETMASK failed." >> $test_log
+        fi
+		if [ "-$wanname" == "-wifiwan" ]; then
+			nv set wifi_state="working"
+	    elif [ "-$wanname" == "-ethwan" ]; then
+		    #×ÔÊÊÓ¦£¬dhcp»ñÈ¡ip³É¹¦ÔòɱËÀpppoe½ø³Ì
+		    pppoe_pid=`ps | grep -v grep | grep $interface | grep pppoecd | awk '{print $1}'`
+			kill $pppoe_pid
+			nv set rj45_state="working"
+			nv set eth_curmode="dhcp"
+	    fi
+		
+        echo "interface:$interface, ip:$ip, NETMASK:$subnet"
+        echo "router:$router"
+        echo "dns:$dns"
+       
+        #set new value to ip, netmask, gateway and dns in nv 
+        nv set $interface"_ip"=$ip
+        nv set $interface"_nm"=$subnet
+        nv set $interface"_gw"=$router
+		#set dns to nv
+        for i in $dns ; do
+            [ -n "$pspridns" ] || { nv set $interface"_pridns"=$i; pspridns="pspridns"; }
+            nv set $interface"_secdns"=$i   
+        done
+			
+		#c_id=0ÔòÊÇrj45»òWiFi£¬c_id=defaultÔòΪÓÃÓÚÍâÍøµÄps¿Ú
+        def_cid=`nv get default_cid`
+	    if [ "-$c_id" == "-0" -o "-$c_id" == "-$def_cid" ]; then
+			(router_msg_proxy ipv4 udhcpc.sh >> $test_log 2>&1 || echo "Error: router_msg_proxy ipv4 udhcpc.sh failed." >> $test_log) &
+		else
+			#policy router
+			wan_pri=`nv get $wanname"_priority"`
+			rt_num=`expr $wan_pri \* 10 + $c_id`
+			ip rule add from $ip table $rt_num 2>>$test_log
+			if [ $? -ne 0 ];then
+				echo "Error: ip rule add from $ip table $rt_num failed." >> $test_log
+			fi
+			ip route add default via $router table $rt_num 2>>$test_log
+			if [ $? -ne 0 ];then
+				echo "Error: ip route add default via $router table $rt_num failed." >> $test_log
+			fi
+			ip route flush cache 2>>$test_log
+			if [ $? -ne 0 ];then
+				echo "Error: ip route flush cache failed." >> $test_log
+			fi
+	    fi
+     
+		# notify goahead when the WAN IP has been acquired. --yy
+		echo "case renew bound over"
+		
+        #nv set ppp_status=ppp_connected
+		nv set step_tmp=0
+		;;
+esac
+
+
+
+exit 0
+
diff --git a/ap/app/Script/scripts/upnp.sh b/ap/app/Script/scripts/upnp.sh
new file mode 100644
index 0000000..732e0a6
--- /dev/null
+++ b/ap/app/Script/scripts/upnp.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+#
+# $Id: upnp.sh,v 1.22.6.1 2008-10-02 12:57:42 winfred Exp $
+#
+# usage: upnp.sh
+#
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+echo "Info: upnp.sh start " >> $test_log
+
+
+# stop all
+killall -9 miniupnpd
+sh $path_sh/upnp_ipt_remove.sh
+
+# upnp
+upnp=`nv get upnpEnabled`
+if [ "$upnp" = "1" ]; then
+	if [ -f $path_conf/pidfile/miniupnp.pid ]
+	then
+		rm -f $path_conf/pidfile/miniupnpd.pid
+	fi
+	
+	if [ -f /var/run/miniupnpd.pid ]
+	then
+		rm -f /var/run/miniupnpd.pid
+	fi	
+	
+	if [ -f $path_conf/miniupnpd.conf ]
+	then
+		echo "$path_conf/miniupnpd.conf already exist!"
+	    rm $path_conf/miniupnpd.conf
+	fi
+	
+	cp $path_ro/miniupnpd_temp.conf $path_conf/miniupnpd.conf
+	
+	gw=`nv get lan_ipaddr`
+	. $path_sh/upnp_set_listenip.sh $gw/16
+	
+	route del -net 239.0.0.0 netmask 255.0.0.0 dev $lan_if
+	route add -net 239.0.0.0 netmask 255.0.0.0 dev $lan_if 2>>$test_log
+	if [ $? -ne 0 ];then
+	    echo "Error: route add -net 239.0.0.0 netmask 255.0.0.0 dev $lan_if failed." >> $test_log
+    fi
+	. $path_sh/upnp_ipt_init.sh
+	miniupnpd -f $path_conf/miniupnpd.conf &
+fi
diff --git a/ap/app/Script/scripts/upnp_ipt_init.sh b/ap/app/Script/scripts/upnp_ipt_init.sh
new file mode 100644
index 0000000..e942b8c
--- /dev/null
+++ b/ap/app/Script/scripts/upnp_ipt_init.sh
@@ -0,0 +1,22 @@
+#! /bin/sh
+# $Id: iptables_init.sh,v 1.1 2008-09-15 12:28:53 winfred Exp $
+
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+
+echo "Info: upnp_ipt_init.sh start" >> $test_log
+IPTABLES=iptables
+
+#change this parameters :
+EXTIF=$defwan_rel
+
+#adding the MINIUPNPD chain for nat
+$IPTABLES -t nat -N MINIUPNPD
+#adding the rule to MINIUPNPD
+#$IPTABLES -t nat -A PREROUTING -d $EXTIP -i $EXTIF -j MINIUPNPD
+$IPTABLES -t nat -I PREROUTING -i $EXTIF -j MINIUPNPD
+
+#adding the MINIUPNPD chain for filter
+$IPTABLES -t filter -N MINIUPNPD
+#adding the rule to MINIUPNPD
+$IPTABLES -t filter -I FORWARD -i $EXTIF -o ! $EXTIF -j MINIUPNPD
diff --git a/ap/app/Script/scripts/upnp_ipt_remove.sh b/ap/app/Script/scripts/upnp_ipt_remove.sh
new file mode 100644
index 0000000..4cbcb1d
--- /dev/null
+++ b/ap/app/Script/scripts/upnp_ipt_remove.sh
@@ -0,0 +1,25 @@
+#! /bin/sh
+# $Id: iptables_removeall.sh,v 1.1 2008-09-15 12:28:53 winfred Exp $
+
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+
+echo "Info: upnp_ipt_remove.sh start" >> $test_log
+
+IPTABLES=iptables
+
+#change this parameters :
+EXTIF="$defwan_rel"
+
+#removing the MINIUPNPD chain for nat
+$IPTABLES -t nat -F MINIUPNPD
+#removing the rule to MINIUPNPD
+#$IPTABLES -t nat -D PREROUTING -d $EXTIP -i $EXTIF -j MINIUPNPD
+$IPTABLES -t nat -D PREROUTING -i $EXTIF -j MINIUPNPD
+$IPTABLES -t nat -X MINIUPNPD
+
+#removing the MINIUPNPD chain for filter
+$IPTABLES -t filter -F MINIUPNPD
+#adding the rule to MINIUPNPD
+$IPTABLES -t filter -D FORWARD -i $EXTIF -o ! $EXTIF -j MINIUPNPD
+$IPTABLES -t filter -X MINIUPNPD
diff --git a/ap/app/Script/scripts/upnp_set_listenip.sh b/ap/app/Script/scripts/upnp_set_listenip.sh
new file mode 100644
index 0000000..dcfbc4f
--- /dev/null
+++ b/ap/app/Script/scripts/upnp_set_listenip.sh
@@ -0,0 +1,21 @@
+#! /bin/sh
+
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+
+echo "Info: upnp_set_listenip.sh start" >> $test_log
+
+if [ -f $path_conf/miniupnpd.conf ]
+	then
+		echo "$path_conf/miniupnpd.conf already exist!"
+fi
+
+conf_file=$path_conf/miniupnpd.conf
+
+listening_ip=$(grep listening_ip= $conf_file)
+aim="listening_ip=$1"
+sed -i "s:$listening_ip:$aim:g" $conf_file
+ip=`nv get lan_ipaddr`
+sed  -i -e "s/#allow_ip#/$ip/g" $conf_file
+name=`nv get device_name`
+sed  -i -e "s/#device_name#/$name/g" $conf_file
diff --git a/ap/app/Script/scripts/user-config-udhcpd.sh b/ap/app/Script/scripts/user-config-udhcpd.sh
new file mode 100644
index 0000000..62eefd7
--- /dev/null
+++ b/ap/app/Script/scripts/user-config-udhcpd.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+echo "Info: user-config-udhcpd.sh start" >> $test_log
+
+lan_enable=`nv get LanEnable`
+if [ "-$lan_enable" == "-0" ]; then
+    exit 0
+fi
+
+static_ip_init()
+{
+	mac_ip_list=`nv get mac_ip_list`
+	num_any=`echo $mac_ip_list| grep -c ";"`
+	num_one=`echo $mac_ip_list| grep -c "+"`
+
+	if [ "$num_any" -eq "0" ]; then
+		if [ "$num_one" -eq "1" ]; then
+			mac=`echo $mac_ip_list| awk -F '+' '{print $2}'`
+			ip=`echo $mac_ip_list| awk -F '+' '{print $3}'`
+			sh $path_sh/config-udhcpd.sh "lan" -S $mac $ip
+		else
+			echo "the mac_ip_list is null"
+		
+		fi		
+	else
+		var=`echo $mac_ip_list | sed "s/;/ /g"`
+		for list in $var
+		do
+			mac=`echo $list| awk -F '+' '{print $2}'`
+			ip=`echo $list| awk -F '+' '{print $3}'`
+			sh $path_sh/config-udhcpd.sh "lan" -S $mac $ip
+		done
+
+	fi
+}
+
+start=`nv get dhcpStart`
+end=`nv get dhcpEnd`
+dns=`nv get dhcpDns`
+mask=`nv get lan_netmask`
+gw=`nv get lan_ipaddr`
+lease=`nv get dhcpLease_hour`
+lease=`expr $lease \* 3600`
+pidfile=$path_conf"/udhcpd.pid"
+leasesfile=$path_conf"/udhcpd.leases"
+
+sh $path_sh/config-udhcpd.sh "lan" -s $start
+sh $path_sh/config-udhcpd.sh "lan" -e $end
+sh $path_sh/config-udhcpd.sh "lan" -i $lan_if
+sh $path_sh/config-udhcpd.sh "lan" -m $mask
+sh $path_sh/config-udhcpd.sh "lan" -d $dns
+echo "Info: config-udhcpd.sh lan -d $dns" >> $test_log
+if [ "-$gw" != "-" ]; then
+    sh $path_sh/config-udhcpd.sh "lan" -g $gw
+	echo "Info: config-udhcpd.sh lan -g $gw" >> $test_log
+fi
+if [ "-$lease" != "-" ]; then
+    sh $path_sh/config-udhcpd.sh "lan" -t $lease
+fi
+
+static_ip_init
+
+sh $path_sh/config-udhcpd.sh "lan" -p $pidfile
+sh $path_sh/config-udhcpd.sh "lan" -l $leasesfile
\ No newline at end of file
diff --git a/ap/app/Script/scripts/wan_ipv4.sh b/ap/app/Script/scripts/wan_ipv4.sh
new file mode 100755
index 0000000..209ed18
--- /dev/null
+++ b/ap/app/Script/scripts/wan_ipv4.sh
@@ -0,0 +1,292 @@
+#!/bin/sh
+#usg: wan_ipv4 linkup pswan
+ 
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+
+#Èë²ÎÖÐÓÐc_idÔòÉèÖã¬Ã»ÓÐÔòÖÃÁ㣬ÓÃÓÚÉèÖòßÂÔ·ÓɱíºÅ
+if [ "-$3" == "-" ]; then
+    c_id="0"
+else
+    c_id=$3
+fi
+def_cid=`nv get default_cid`
+
+#»ñÈ¡ÍøÂçÉ豸Ãû
+get_wan_if()
+{
+	case $1 in 
+	"pswan")
+		wan_if="$pswan_name"$2 ;;
+	"ethwan")
+		wan_if=$ethwan_if ;;
+	"wifiwan")
+		wan_if=$wifiwan_if ;;		
+	esac
+	
+	mtu=`nv get mtu`
+	ifconfig $wan_if mtu $mtu
+}
+#ÉèÖù¤×÷״̬ ÕýÔÚÁ¬½Ó£ºconnect ÒÑÁ¬½Ó£ºworking ÒѶϿª£ºdead
+state_set()
+{
+	if [ "-$wan_name" == "-wifiwan" ]; then
+		nv set wifi_state="working"	
+	elif [ "-$wan_name" == "-ethwan" ]; then
+		nv set rj45_state="working"		
+	fi
+}
+#¸ù¾ÝÍø¿ÚÊÇ·ñÓÃÓÚÆÕͨÉÏÍâÍø£¬È·¶¨ÊÇ·ñÐèÒª·¢ÏûÏ¢¸øzte_router
+msg_zte_router()
+{
+	if [ "-$c_id" == "-0" -o "-$c_id" == "-$def_cid" ]; then
+		(router_msg_proxy ipv4 wan_ipv4.sh >> $test_log 2>&1 || echo "Error: router_msg_proxy ipv4 wan_ipv4.sh failed." >> $test_log) &
+	fi
+}
+
+linkup()
+{
+	#$1 :pswan / usbwan / ethwan / wifiwan
+	wan_name=$1
+	wan_mode=`nv get $wan_name"_mode"`
+	
+	#»ñÈ¡wan_if±äÁ¿
+	get_wan_if $1 $2
+	
+	if [ "-$wan_mode" == "-static" ]; then
+		wan_ip=`nv get "static_"$wan_name"_ip"`
+		wan_gw=`nv get "static_"$wan_name"_gw"`
+		wan_pridns=`nv get "static_"$wan_name"_pridns"`
+		wan_secdns=`nv get "static_"$wan_name"_secdns"`
+		wan_nm=`nv get "static_"$wan_name"_nm"`
+		if [ "-$wan_name" != "-wifiwan" ]; then
+			ifconfig $wan_if down 2>>$test_log
+			if [ $? -ne 0 ];then
+	            echo "Error: ifconfig $wan_if down failed." >> $test_log
+            fi
+			ifconfig $wan_if $wan_ip up 2>>$test_log
+			if [ $? -ne 0 ];then
+	            echo "Error: ifconfig $wan_if $wan_ip up failed." >> $test_log
+            fi
+		fi
+		if [ "-$wan_name" == "-ethwan" ]; then
+			nv set eth_curmode="static"
+			#rj45¾²Ì¬Á¬½Ó£¬¹Ø±Õ³¬Ê±¼ÆÊ±Æ÷
+			(router_msg_proxy del_timer ethwan >> $test_log 2>&1 || echo "Error: router_msg_proxy del_timer failed." >> $test_log) &
+		fi		
+		
+		#ÉèÖÃÍøÂçÉ豸״̬±ê־Ϊworking	
+		state_set
+		#set ip¡¢gw¡¢dns to nv
+		nv set $wan_if"_ip"=$wan_ip
+		nv set $wan_if"_gw"=$wan_gw
+		nv set $wan_if"_pridns"=$wan_pridns
+		nv set $wan_if"_secdns"=$wan_secdns
+	
+		wan_pri=`nv get $1"_priority"`
+		rt_num=`expr $wan_pri \* 10 + $c_id`
+		ip rule add from $wan_ip table $rt_num 2>>$test_log
+		if [ $? -ne 0 ];then
+	        echo "Error: ip rule add from $wan_ip table $rt_num failed." >> $test_log
+        fi
+		ip route add default via $wan_gw table $rt_num 2>>$test_log
+		if [ $? -ne 0 ];then
+	        echo "Error: ip route add default via $wan_gw table $rt_num failed." >> $test_log
+        fi
+		ip route flush cache 2>>$test_log
+		if [ $? -ne 0 ];then
+	        echo "Error: ip route flush cache failed." >> $test_log
+        fi
+       
+		#in this proxy ,we send msg to zte_mainctrl 
+		msg_zte_router
+	   
+	# pswan PDP 	 
+	elif [ "-$wan_mode" == "-pdp" ]; then
+		pswan_ip=`nv get $wan_if"_ip"`
+		pswan_gw=`nv get $wan_if"_gw"`
+		pswan_pridns=`nv get $wan_if"_pridns"`
+		pswan_secdns=`nv get $wan_if"_secdns"`
+		pswan_nm=`nv get $wan_if"_nm"`
+		
+		#ifconfig $wan_if down 2>>$test_log
+		ifconfig $wan_if $pswan_ip netmask 255.255.255.0 up 2>>$test_log
+		if [ $? -ne 0 ];then
+	        echo "Error: ifconfig $wan_if $pswan_ip up failed." >> $test_log
+        fi
+		
+		pswan_pri=`nv get pswan_priority`
+		rt_num=`expr $pswan_pri \* 10 + $c_id`
+		ip rule add from $pswan_ip table $rt_num 2>>$test_log
+		if [ $? -ne 0 ];then
+	        echo "Error: ip rule add from $pswan_ip table $rt_num failed." >> $test_log
+        fi
+		ip route add default via $pswan_gw table $rt_num 2>>$test_log
+		if [ $? -ne 0 ];then
+	        echo "Error: ip route add default via $pswan_gw table $rt_num failed." >> $test_log
+        fi
+		ip route flush cache 2>>$test_log
+		if [ $? -ne 0 ];then
+	        echo "Error: ip route flush cache failed." >> $test_log
+        fi
+		      
+		msg_zte_router
+	
+	elif [ "-$wan_mode" == "-auto" ]; then
+		pppoe_user=`nv get pppoe_username`
+		pppoe_pass=`nv get pppoe_cc`
+		udhcpc_kill
+		pppoe_kill
+		
+		if [ "-$wan_name" == "-ethwan" ]; then
+			nv set eth_curmode=""
+		fi	
+		if [ "-$wan_name" != "-wifiwan" ]; then
+			ifconfig $wan_if down 2>>$test_log
+		    if [ $? -ne 0 ];then
+	            echo "Error: ifconfig $wan_if down failed." >> $test_log
+            fi
+			ifconfig $wan_if up 2>>$test_log
+			if [ $? -ne 0 ];then
+	            echo "Error: ifconfig $wan_if up failed." >> $test_log
+            fi
+		fi
+		
+    	if [ "-${pppoe_user}" = "-" -a "-${pppoe_pass}" = "-" ];then
+		    echo "auto wan_mode: pppoe_user is ${pppoe_user}, pppoe_pass is ${pppoe_pass}, so start dhcp client. " >> $test_log
+			udhcpc -i $wan_if -s $path_sh/udhcpc.sh &
+		else
+			sh $path_sh/pppoe_dail.sh connect	
+		fi
+		
+	elif [ "-$wan_mode" == "-dhcp" ]; then
+		udhcpc_kill
+		pppoe_kill
+		
+		if [ "-$wan_name" == "-pswan" ]; then
+		    ifconfig $wan_if arp 2>>$test_log
+			if [ $? -ne 0 ];then
+	            echo "Error: ifconfig $wan_if arp failed." >> $test_log
+            fi
+		fi
+		
+		if [ "-$wan_name" == "-ethwan" ]; then
+			nv set eth_curmode="dhcp"
+		fi	
+		
+		if [ "-$wan_name" != "-wifiwan" ]; then
+			ifconfig $wan_if down 2>>$test_log
+			if [ $? -ne 0 ];then
+	            echo "Error: ifconfig $wan_if down failed." >> $test_log
+            fi
+			ifconfig $wan_if up 2>>$test_log
+			if [ $? -ne 0 ];then
+	            echo "Error: ifconfig $wan_if up failed." >> $test_log
+            fi
+		fi
+		udhcpc -i $wan_if -s $path_sh/udhcpc.sh &		
+	
+	elif [ "-$wan_mode" == "-pppoe" ]; then
+		udhcpc_kill
+		pppoe_kill
+		
+		if [ "-$wan_name" == "-ethwan" ]; then
+			nv set eth_curmode="pppoe"
+		fi	
+		
+		if [ "-$wan_name" != "-wifiwan" ]; then
+			ifconfig $wan_if down 2>>$test_log
+			if [ $? -ne 0 ];then
+	            echo "Error: ifconfig $wan_if down failed." >> $test_log
+            fi
+			ifconfig $wan_if up 2>>$test_log
+			if [ $? -ne 0 ];then
+	            echo "Error: ifconfig $wan_if up failed." >> $test_log
+            fi
+		fi
+		sh $path_sh/pppoe_dail.sh connect	
+	fi
+	
+}
+
+del_default_wan()
+{
+	default_wan_name=`nv get default_wan_name`
+	if [ "$1" == "$default_wan_name" ]; then
+		nv set default_wan_name=""
+		nv set default_wan_rel=""
+	fi
+}
+
+linkdown()
+{
+	wan_name=$1
+	get_wan_if $1 $2
+
+	udhcpc_kill
+	pppoe_kill
+	
+	#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
+	    echo "Error: ifconfig $wan_if 0.0.0.0 failed." >> $test_log
+    fi
+	if [ "$wan_name" == "wifiwan" ]; then
+		echo $wan_if > /proc/net/dev_down
+	else
+		ifconfig $wan_if down 2>>$test_log
+		if [ $? -ne 0 ];then
+	        echo "Error: ifconfig $wan_if down failed." >> $test_log
+        fi
+	fi
+	wan_ip=`nv get $wan_if"_ip"`
+	wan_gw=`nv get $wan_if"_gw"`
+	
+	route del default gw $wan_gw dev $wan_if 
+	#if [ $? -ne 0 ];then
+	#    echo "Error: route del default gw $wan_gw dev $wan_if failed." >> $test_log
+    #fi
+		
+	#del policy router
+	wan_pri=`nv get $1"_priority"`
+	rt_num=`expr $wan_pri \* 10 + $c_id`
+	ip rule del from $wan_ip table $rt_num 
+	#if [ $? -ne 0 ];then
+	#    echo "Error: ip rule del from $wan_ip table $rt_num failed." >> $test_log
+    #fi
+	ip route del default via $wan_gw table $rt_num 
+	#if [ $? -ne 0 ];then
+	#    echo "Error: ip route del default via $wan_gw table $rt_num failed." >> $test_log
+    #fi
+	
+	#wan_ipaddÐèÒªÊÊÅä
+	if [ "$wan_if" == "$defwan_if" ]; then
+		nv set wan_ipaddr=""
+	fi
+	nv set $wan_if"_ip"=0.0.0.0
+	nv set $wan_if"_nm"=0.0.0.0
+	nv set $wan_if"_gw"=0.0.0.0
+	nv set $wan_if"_pridns"=0.0.0.0
+	nv set $wan_if"_secdns"=0.0.0.0
+	pdp_type=`nv get "pdp_act_type"$def_cid`
+	if [ "$2" == "$def_cid" -a "-$pdp_type" != "-IPv4v6" ]; then
+		nv set default_cid=""
+	fi
+	del_default_wan $wan_if 
+	msg_zte_router 
+
+}
+
+echo "Info: wan_ipv4.sh $1 $2 $3 start" >> $test_log
+if [ "$1" == "linkup" ]; then
+	linkup $2 $3
+	
+elif [ "$1" == "linkdown" ]; then
+	if [ "-$2" == "-pswan" ]; then
+		tc_tbf.sh down $def_cid
+	fi
+	linkdown $2 $3	
+fi
\ No newline at end of file
diff --git a/ap/app/Script/scripts/wan_ipv6.sh b/ap/app/Script/scripts/wan_ipv6.sh
new file mode 100755
index 0000000..1e45966
--- /dev/null
+++ b/ap/app/Script/scripts/wan_ipv6.sh
@@ -0,0 +1,419 @@
+#!/bin/sh 
+
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+
+
+echo "input param is $1 $2 $3"
+echo "Info: wan_ipv6 $1 $2 $3 start" >> $test_log
+
+#Èë²ÎÖÐÓÐc_idÔòÉèÖã¬Ã»ÓÐÔòÖÃÁ㣬ÓÃÓÚÉèÖòßÂÔ·ÓɱíºÅ
+if [ "$3" == "" ]; then
+    c_id="0"
+else
+    c_id=$3
+fi
+def_cid=`nv get default_cid`
+
+is_chinamobile_pd_diff=`nv get pd_chinamobile_enable`
+pd_chinamobile=`nv get pd_chinamobile`
+prefix_len=`nv get pd_len_chinamobile`
+
+b_dhcpv6stateEnabled=`nv get dhcpv6stateEnabled`
+b_dhcpv6statelessEnabled=`nv get dhcpv6statelessEnabled`
+
+############# »ñȡָ¶¨Íø¿ÚµÄÈ«¾Ö±äÁ¿ ############
+get_wan_info() 
+{
+    echo "wan_name_info = $1"
+
+    #»ñÈ¡¶ÔÓ¦wan¿ÚµÄip mode
+    wan_mode=`nv get $1"_mode"`
+
+    #»ñÈ¡¶ÔÓ¦µÄÍø¿ÚÃû
+    case $1 in 
+    "pswan")
+        wan_if=$pswan_name$2 ;;
+    "usbwan")
+        wan_if=$usbwan_if ;;
+    "ethwan")
+        wan_if=$ethwan_if ;;
+    "wifiwan")
+        wan_if=$wifiwan_if ;;
+    esac
+    mtu=`nv get mtu`
+    ifconfig $wan_if mtu $mtu
+
+    #ÐèÒªÓõ½Ïà¹ØÅäÖÃÎļþ
+    dhcp6s_conf=$path_conf/dhcp6s_$wan_if.conf
+    radvd_conf=$path_conf/radvd_$wan_if.conf
+	radvd_pidfile=$path_tmp/radvd_$wan_if.pid
+    #resolv_conf=$path_conf/resolv_$wan_if.conf
+    ndp_log=$path_conf/ndp_$wan_if.log
+
+    #·ÀdosÏà¹ØÅäÖÃ
+    dosenable=`nv get dosenable`
+    if [ "x$dosenable" != "x0" ]; then
+        if [ "$1" == "pswan" ]; then
+            wan6_prefix=$1$2"_prefix"
+        else
+            wan6_prefix=$1"_prefix"
+        fi
+        echo 1 > /sys/module/fast_common/parameters/lan_dos_enable
+        echo "wan6_prefix_name = $wan6_prefix"
+    fi
+
+    echo "wan_if_info = $wan_if"
+}
+
+#Çå³ýÏàÓ¦µÄslaac½ø³Ì
+slaac_kill()
+{
+	ps > ${path_tmp}/zte_ipv6_slaac.${wan_if}.$$
+	slaac_pid=`awk 'BEGIN{temp1="'"${wan_if}"'";temp2="zte_ipv6_slaac"}{if(index($0,temp1)>0 && index($0,temp2)>0){print $1}}' ${path_tmp}/zte_ipv6_slaac.${wan_if}.$$`
+	rm -f ${path_tmp}/zte_ipv6_slaac.${wan_if}.$$
+    [ -n "$slaac_pid" ] && { kill $slaac_pid; echo "Info: kill slaac $slaac_pid " >> $test_log ; }
+}
+
+linkup_get_wan_addr()
+{
+    echo "wan_name_info = $wan_if"
+    
+    #disable the forwarding to send RS and not set the addr when receive ra packet
+    #echo 0 > /proc/sys/net/ipv6/conf/all/forwarding
+    echo 0 > /proc/sys/net/ipv6/conf/$wan_if/accept_ra
+
+    # IPv6ÔÝʱ²»¿¼ÂÇstaticģʽ£¬È罫À´ÓÐÐèÇ󣬲ο¼ipv4ÅäÖÃ
+    # µ±wan_modeΪDHCP£¬»òÕßusbwan¡¢ethwanΪPPP¡¢PPPOEʱ£¬Æô¶¯dhcp6c
+	if [ "$1" == "pswan" ]; then
+		
+		if [ "-$wan_mode" == "-dhcp" ]; then
+		    ifconfig $wan_if arp 2>>$test_log
+			if [ $? -ne 0 ];then
+	            echo "Error: ifconfig $wan_if arp failed." >> $test_log
+            fi
+		fi
+		#call the slaac program to get the prefix addr 
+		ifconfig $wan_if up 2>>$test_log
+		if [ $? -ne 0 ];then
+	        echo "Error: ifconfig $wan_if up failed." >> $test_log
+        fi
+		prefix_info_temp=`nv get $wan_if"_ipv6_prefix_info"`
+		#Èç¹ûµ±Ç°Ã»ÓÐǰ׺£¬ÔòÖ±½ÓÆô¶¯slaac£¬Èç¹ûµ±Ç°Ç°×ºÒѾ­ÉèÖã¬Ôò˵Ã÷ÒѾ­»ñÈ¡µ½£¬Ö±½ÓÅäÖÃIPµØÖ·¼´¿É
+		if [ -n "$prefix_info_temp" -a "-$prefix_info_temp" != "-::" ]; then
+			ret_code=0
+		else
+			sleep 1
+			interface_id_temp1=`nv get $wan_if"_ipv6_interface_id"`
+			local_ipv6_addr="fe80::"$interface_id_temp1
+			local_ipv6_addr_nv="$wan_if""_local_ipv6_addr"
+			nv set $local_ipv6_addr_nv=$local_ipv6_addr
+			ip -6 addr add $local_ipv6_addr/64 dev $wan_if 2>>$test_log
+			zte_ipv6_slaac -i "$wan_if" 
+			ret_code=$?
+		fi
+        
+		echo "the program zte_ipv6_slaac return  = $ret_code"
+		if [ $ret_code -eq 0 ]; then
+			echo "the zte_ipv6_slaac success"
+			interface_id_temp=`nv get $wan_if"_ipv6_interface_id"`
+			prefix_info_temp=`nv get $wan_if"_ipv6_prefix_info"`
+            
+			echo "##############1##########"
+			echo "$interface_id_temp"
+			echo "$prefix_info_temp"
+			echo "##############2##########"            
+			
+			if [ "x$dosenable" != "x0" ]; then
+				ip6_prefix=`echo "$prefix_info_temp" | awk -F ':' '{printf "0x"$1",0x"$2",0x"$3",0x"$4}'`
+				echo "ip6_prefix1=$ip6_prefix"
+				echo $ip6_prefix > /sys/module/fast_common/parameters/$wan6_prefix
+			fi
+			
+			
+			wan_addr=$prefix_info_temp$interface_id_temp
+			wan_addr_nv=$wan_if"_ipv6_ip"
+			nv set $wan_addr_nv="$wan_addr"
+			echo "wan_addr = $wan_addr"
+            
+			ip -6 addr add $wan_addr/126 dev $wan_if 2>>$test_log
+			if [ $? -ne 0 ];then
+	            echo "Error: ip -6 addr add $wan_addr/126 dev $wan_if failed." >> $test_log
+            fi
+			
+			killall -9 clatd
+			#clatd -i $wan_if -p 1:1:1:123:: &
+			
+			if [ "-$c_id" != "-$def_cid" ]; then
+				wan_pri=`nv get $1"_priority"`
+				rt_num=`expr $wan_pri \* 10 + $c_id`
+				default_gw_addr_temp=`nv get $wan_if"_ipv6_gw"`
+				echo "ipv6_wan_default_gw = $default_gw_addr_temp"
+				ip -6 rule add from $wan_addr table $rt_num 2>>$test_log
+				if [ $? -ne 0 ];then
+	                echo "Error: ip -6 rule add from $wan_addr table $rt_num failed." >> $test_log
+                fi
+				if [ -n "$default_gw_addr_temp" -a "-$default_gw_addr_temp" != "-::" ] ; then
+					ip -6 route add default via $default_gw_addr_temp dev $wan_if table $rt_num 2>>$test_log
+					if [ $? -ne 0 ];then
+	                    echo "Error: ip -6 route add default via $default_gw_addr_temp dev $wan_if table $rt_num failed." >> $test_log
+                    fi
+				else
+					ip -6 route add default dev $wan_if table $rt_num 2>>$test_log
+					if [ $? -ne 0 ];then
+	                    echo "Error: ip -6 route add default dev $wan_if table $rt_num failed." >> $test_log
+                    fi
+				fi
+				ip -6 route flush cache 2>>$test_log
+				if [ $? -ne 0 ];then
+	                echo "Error: ip -6 route flush cache failed." >> $test_log
+                fi
+				#sleep 1
+			fi
+			nv set $wan_if"_ipv6_state"="working"
+		else
+			echo "the zte_ipv6_slaac fail"
+			nv set $wan_if"_ipv6_state"="dead"
+			#exit 1
+		fi
+	else	
+		#if [ "-$wan_mode" == "-DHCP" -o "-$wan_mode" == "-PPP" -o "-$wan_mode" == "-PPPOE"  ]; then 
+			#dhcp6c -dDf -z $wan_if &
+		# ²ÉÓÃPDP¼¤»î·ÖÅäµÄipv6µØÖ·
+		#else
+			#call the slaac program to get the prefix addr 
+			ifconfig $wan_if up 2>>$test_log
+			if [ $? -ne 0 ];then
+	            echo "Error: ifconfig $wan_if up failed." >> $test_log
+            fi
+			#sleep 1
+			#interface_id_temp1=`nv get $wan_if"_ipv6_interface_id"`
+			interface_id_temp1="0001:0002:0003:0004"
+			nv set $wan_if"_ipv6_interface_id"=$interface_id_temp1
+			local_ipv6_addr="fe80::"$interface_id_temp1
+			local_ipv6_addr_nv="$wan_if""_local_ipv6_addr"
+			nv set $local_ipv6_addr_nv=$local_ipv6_addr
+			ip -6 addr add $local_ipv6_addr/64 dev $wan_if 2>>$test_log
+			
+			zte_ipv6_slaac -i "$wan_if" 
+			ret_code=$?
+        
+			echo "the program zte_ipv6_slaac return  = $ret_code"
+			if [ $ret_code -eq 0 ]; then
+				echo "the zte_ipv6_slaac success"
+				#ifconfig $wan_if up 2>>$test_log
+				dhcp6c -dDf -z $wan_if &
+				interface_id_temp=`nv get $wan_if"_ipv6_interface_id"`
+				prefix_info_temp=`nv get $wan_if"_ipv6_prefix_info"`
+				if [ "-$prefix_info_temp" == "-" -o "-$prefix_info_temp" == "-::" ]; then
+					echo "wait dhcp6c get ipv6_prefix"
+					sleep 2
+					prefix_info_temp=`nv get $wan_if"_ipv6_prefix_info"`
+				fi
+            
+				echo "##############1##########"
+				echo "$interface_id_temp"
+				echo "$prefix_info_temp"
+				echo "##############2##########"            
+				if [ "-$prefix_info_temp" == "-" -o "-$prefix_info_temp" == "-::" ]; then
+					echo "get ipv6_prefix fail"
+					nv set $wan_if"_ipv6_state"="dead"
+					exit 1
+				fi
+				if [ "x$dosenable" != "x0" ]; then
+					ip6_prefix=`echo "$prefix_info_temp" | awk -F ':' '{printf "0x"$1",0x"$2",0x"$3",0x"$4}'`
+					echo "ip6_prefix2=$ip6_prefix"
+					echo $ip6_prefix > /sys/module/fast_common/parameters/$wan6_prefix
+				fi
+				
+				wan_addr=$prefix_info_temp$interface_id_temp
+				wan_addr_nv=$wan_if"_ipv6_ip"
+				nv set $wan_addr_nv="$wan_addr"
+				echo "wan_addr = $wan_addr"
+            
+				ip -6 addr add $wan_addr/126 dev $wan_if 2>>$test_log
+				if [ $? -ne 0 ];then
+	                echo "Error: ip -6 addr add $wan_addr/126 dev $wan_if failed." >> $test_log
+                fi
+				
+				killall -9 clatd
+				#clatd -i $wan_if -p 1:1:1:123:: &
+			else
+				echo "the zte_ipv6_slaac fail"
+				nv set $wan_if"_ipv6_state"="dead"
+				exit 1
+			fi
+		#fi
+	fi
+}
+
+#############linkdown radvd set############
+linkdown_radvd_set() 
+{
+    if [ "-$b_dhcpv6stateEnabled" = "-1" ];then
+        radvd_kill
+        return
+    else
+        sed  -i -e s/AdvValidLifetime.*/'AdvValidLifetime 30;'/g $radvd_conf
+        sed  -i -e s/AdvPreferredLifetime.*/'AdvPreferredLifetime 1;'/g $radvd_conf
+    fi
+
+    if [ "-$is_chinamobile_pd_diff" = "-1" ] ; then
+        if [ "-$pd_chinamobile" == "-" ] ; then
+            echo "no pd info get"
+        else
+            radvd_kill
+			rm -rf $radvd_pidfile
+            radvd -d 3 -C $radvd_conf -s -p $radvd_pidfile &
+            nv set pd_chinamobile=""
+            nv set pd_len_chinamobile=""
+            radvd_kill
+        fi
+    fi
+
+    radvd_kill
+	rm -rf $radvd_pidfile
+    radvd -d 3 -C $radvd_conf -s -p $radvd_pidfile &
+}
+
+#############linkdown wanaddr route set############
+linkdown_route_set()
+{
+    echo "wan_name_info = $wan_if"
+    
+    wan_addr=`nv get $wan_if"_ipv6_ip"`
+	ip -6 addr del $wan_addr/126 dev $wan_if
+	
+	local_ipv6_addr_nv="$wan_if""_local_ipv6_addr"
+	local_ipv6_addr=`nv get $local_ipv6_addr_nv`
+	ip -6 addr del $local_ipv6_addr/64 dev $wan_if 2>>$test_log
+	#if [ $? -ne 0 ];then
+	#    echo "Error: ip -6 addr del $wan_addr/126 dev $wan_if   failed." >> $test_log
+    #fi
+	
+	killall clatd
+	sh $path_sh/clat_config.sh down $wan_if
+	
+	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
+	
+		nv set ipv6_br0_addr="::"
+		ipv6_addr_conver $wan_addr "$wan_if"
+		ipv6_br0_addr_tmp=`nv get ipv6_br0_addr`
+		ip -6 addr del $ipv6_br0_addr_tmp/64 dev br0
+		#if [ $? -ne 0 ];then
+	        #echo "Error: ip -6 addr del $ipv6_br0_addr_tmp/64 dev br0 failed." >> $test_log
+        #fi
+		
+		#ÊÊÅäÒ³ÃæµÈÆäËûµØ·½Ê¹ÓÃÀÏNV
+		nv set ipv6_wan_ipaddr="::"
+		
+		def_cid=`nv get default_cid`
+		if [ "-$c_id" == "-$def_cid" ]; then
+			nv set default_cid=""
+			nv set $wan_if"_ipv6_state"="dead"
+		fi
+	else
+		wan_pri=`nv get $1"_priority"`
+		rt_num=`expr $wan_pri \* 10 + $c_id`
+		
+		default_gw_addr_temp=`nv get $wan_if"_ipv6_gw"`
+		echo "ipv6_wan_default_gw = $default_gw_addr_temp"
+		
+		ip -6 rule del from $wan_addr table $rt_num
+		#if [ $? -ne 0 ];then
+	        #echo "Error: ip -6 rule del from $wan_addr table $rt_num failed." >> $test_log
+        #fi
+		if [ -n "$default_gw_addr_temp" ] ; then
+			ip -6 route del default via $default_gw_addr_temp dev $wan_if table $rt_num 
+			#if [ $? -ne 0 ];then
+	            #echo "Error: ip -6 route del default via $default_gw_addr_temp dev $wan_if table $rt_num failed." >> $test_log
+            #fi
+		else
+			ip -6 route del default dev $wan_if table $rt_num 
+			#if [ $? -ne 0 ];then
+	            #echo "Error: ip -6 route del default dev $wan_if table $rt_num failed." >> $test_log
+            #fi
+		fi
+		ip -6 route flush cache 2>>$test_log
+		if [ $? -ne 0 ];then
+	        echo "Error: ip -6 route flush cache failed." >> $test_log
+        fi
+		
+		nv set $wan_if"_ipv6_state"="dead"
+			
+	fi
+    
+    echo 0 > /proc/sys/net/ipv6/conf/$wan_if/accept_ra
+	
+    #reset wan'nv
+    nv set $wan_if"_ipv6_ip"="::"
+    nv set $wan_if"_ipv6_pridns_auto"="::"
+    nv set $wan_if"_ipv6_secdns_auto"="::"
+    nv set $wan_if"_ipv6_gw"="::"
+    nv set $wan_if"_ipv6_interface_id"="::"
+    nv set $wan_if"_ipv6_prefix_info"="::"
+    nv set $wan_if"_dhcpv6_start"="::"
+    nv set $wan_if"_dhcpv6_end"="::"
+    nv set $wan_if"_radvd_ipv6_dns_servers"="::"
+	
+	if [ "x$dosenable" != "x0" ]; then
+		echo 0,0,0,0 > /sys/module/fast_common/parameters/$wan6_prefix
+	fi
+	if [ "$1" == "pswan" ]; then
+		ifconfig $wan_if down 2>>$test_log
+		if [ $? -ne 0 ];then
+			echo "Error: ifconfig $wan_if down failed." >> $test_log
+		fi
+	fi
+}
+
+#Çå³ýÏàÓ¦µÄDHCPv6½ø³Ì
+linkdown_dhcpv6_server_set()
+{
+    dhcp6c_kill
+    dhcp6s_kill
+}
+
+del_default_wan6()
+{
+	default_wan6_name=`nv get default_wan6_name`
+	if [ "-$1" == "-$default_wan6_name" ]; then
+		nv set default_wan6_name=""
+		nv set default_wan6_rel=""
+	fi
+}
+############ipv6 shell entry#################
+get_wan_info $2 $3
+
+case $1 in 
+ "linkup") 
+    linkup_get_wan_addr $2 $3
+	
+    ;;
+ 
+ "linkdown") 
+		if [ "-$2" == "-pswan" ]; then
+			tc_tbf.sh down $def_cid
+		fi
+		linkdown_radvd_set
+		linkdown_dhcpv6_server_set
+		linkdown_route_set $2
+		slaac_kill
+		ndp_kill
+		del_default_wan6 $wan_if
+    ;;
+
+esac
+
+
+if [ "-$c_id" == "-0" -o "-$c_id" == "-$def_cid" ]; then
+	(router_msg_proxy ipv6 wan_ipv6.sh >> $test_log 2>&1 || echo "Error: router_msg_proxy ipv6 wan_ipv6.sh failed." >> $test_log) &
+fi
diff --git a/ap/app/Script/scripts/wan_ipv6_config.sh b/ap/app/Script/scripts/wan_ipv6_config.sh
new file mode 100755
index 0000000..9098fab
--- /dev/null
+++ b/ap/app/Script/scripts/wan_ipv6_config.sh
@@ -0,0 +1,292 @@
+#!/bin/sh 
+
+path_sh=`nv get path_sh`
+. $path_sh/global.sh
+
+echo "input param is $1"
+echo "Info: wan_ipv6_config.sh $1 start" >> $test_log
+
+wan_addr_temp=`nv get $wan_if"ipv6_wan_ipaddr"`
+wan_addr=`echo $wan_addr_temp | sed 's/\/64//'`
+
+is_chinamobile_pd_diff=`nv get pd_chinamobile_enable`
+pd_chinamobile=`nv get pd_chinamobile`
+#prefix_len=`nv get pd_len_chinamobile`
+prefix_len=`nv get $wan_if"_ipv6_prefix_len"`
+
+b_dhcpv6stateEnabled=`nv get dhcpv6stateEnabled`
+b_dhcpv6statelessEnabled=`nv get dhcpv6statelessEnabled`
+b_dhcpv6statePdEnabled=`nv get dhcpv6statePdEnabled`
+
+############# »ñȡĬÈÏÍø¿ÚÃûÏà¹ØÐÅÏ¢ ############
+get_default_wan_info()
+{
+    wan_if_name=$1
+    wan_if=$defwan6_if
+    wan_addr=`nv get $wan_if"_ipv6_ip"`
+	def_cid=`nv get default_cid`
+	
+    if [ "$1" == "pswan" ]; then
+        ipaddr_type=`nv get "pdp_act_type"$def_cid`
+    elif [ "$1" == "ethwan" ]; then
+        ipaddr_type=`nv get eth_act_type`
+    elif [ "$1" == "wifiwan" ]; then
+        ipaddr_type=`nv get wifi_act_type`
+    fi
+
+    #ÐèÒªÓõ½Ïà¹ØÅäÖÃÎļþ
+    dhcp6s_conf=$path_conf/dhcp6s_$wan_if.conf
+    radvd_conf=$path_conf/radvd_$wan_if.conf
+	radvd_pidfile=$path_tmp/radvd_$wan_if.pid
+    ndp_log=$path_conf/ndp_$wan_if.log
+
+    echo "test: default_wan_if_info = $wan_if, wan_addr:$wan_addr"
+}
+
+#############linkup  dhcpserver set############
+linkup_add_dns_to_dhcp6s_radvd_conf()
+{
+    # ipv6 dns set
+    ipv6_dns_mode=`nv get $wan_if_name"_ipv6_dns_mode"`
+    echo "ipv6_dns_mode:$ipv6_dns_mode"
+    echo "the input param  is $1"
+    
+    ipv6_prefer_dns=""
+    ipv6_standby_dns=""
+    if [ "-$ipv6_dns_mode" = "-auto" ];then
+     
+          ipv6_pridns_auto=`nv get $wan_if"_ipv6_pridns_auto"`
+          ipv6_secdns_auto=`nv get $wan_if"_ipv6_secdns_auto"`
+          
+            if [ -n "$ipv6_pridns_auto" ] && [ "-$ipv6_pridns_auto" != "-::" ] && [ "-$ipv6_pridns_auto" != "-::0" ];then
+                ipv6_prefer_dns=$ipv6_pridns_auto
+            fi
+            
+            if [ -n "$ipv6_secdns_auto" ] && [ "-$ipv6_secdns_auto" != "-::" ] && [ "-$ipv6_secdns_auto" != "-::0" ];then
+                ipv6_standby_dns=$ipv6_secdns_auto
+            fi
+
+    elif [ "-$ipv6_dns_mode" = "-manual" ];then
+            #¶ÔÓÚÊÖ¶¯DNS£¬Ò³ÃæÖ»ÄÜÉèÖõ½pswan¿Ú£¬ËùÒÔ¶ÔÓÚÊÖ¶¯dns£¬²»¹ÜºÎÖÖģʽ£¬ÔÝʱ¶¼È¡ÓÃpswanµÄÊÖ¶¯dnsµØÖ·
+            ipv6_pridns_manual=`nv get $pswan_if_name"_ipv6_pridns_manual"`
+            ipv6_secdns_manual=`nv get $pswan_if_name"_ipv6_secdns_manual"`
+            
+            if [ -n "$ipv6_pridns_manual" ] && [ "-$ipv6_pridns_manual" != "-::" ] && [ "-$ipv6_pridns_manual" != "-::0" ];then
+                ipv6_prefer_dns=$ipv6_pridns_manual
+            fi
+            
+            if [ -n "$ipv6_secdns_manual" ] && [ "-$ipv6_secdns_manual" != "-::" ] && [ "-$ipv6_secdns_manual" != "-::0" ];then
+                ipv6_standby_dns=$ipv6_secdns_manual
+            fi
+            
+      fi
+
+    if [ "-$ipv6_prefer_dns" == "-" -a "-$ipv6_standby_dns" == "-" ]; then
+        return
+    else
+        if [ -n "$1" ] && [ "$1" == "dhcp6s" ] ;then
+            echo -e "\toption dns_servers $ipv6_prefer_dns $ipv6_standby_dns;" >> $dhcp6s_conf
+        elif [ -n "$1" ] && [ "$1" == "radvd" ] ;then
+            # del last line
+            sed -i '$d' $radvd_conf
+            echo -e "\tRDNSS $ipv6_prefer_dns $ipv6_standby_dns\n\t{" >> $radvd_conf
+            echo -e "\t\tAdvRDNSSPreference 15;" >> $radvd_conf
+            echo -e "\t\tAdvRDNSSOpen on;" >> $radvd_conf
+            echo -e "\t};\n};" >> $radvd_conf
+        fi
+    fi
+}
+
+linkup_dhcpv6_server_set()
+{
+    dhcp6s_kill
+    rm -fr $dhcp6s_conf
+
+    if [ "-$is_chinamobile_pd_diff" = "-1" ] ; then
+        nv set pd_chinamobile=""
+        nv set pd_len_chinamobile=""
+        dhcp6c -dDf -z $wan_if &
+        for i in a b c d e; do
+          #sleep 1;
+          pd_chinamobile=`nv get pd_chinamobile`
+          if [ "-$pd_chinamobile" == "-" ]; then
+            echo "no pd get";
+          else
+            echo "pd get";
+            break;
+          fi
+        done
+        pd_chinamobile=`nv get pd_chinamobile`
+        prefix_len=`nv get pd_len_chinamobile`
+        if [ "-$pd_chinamobile" == "-" ]; then
+            dhcp6c_kill
+            prefix_len="64"
+        else
+          wan_addr=$pd_chinamobile
+          # here br0 is bind by dhcp6c, need to kill then run dhcp6s£¬need to fix
+          dhcp6c_kill
+          #sleep 1
+        fi
+    else
+        if [ "-$prefix_len" == "-" ]; then
+            prefix_len=64
+        fi
+        echo "not chinamobile"
+    fi
+    
+    ipv6_addr_conver "$wan_addr" "$wan_if"
+    dhcpv6_start=`nv get $wan_if"_dhcpv6_start"`
+    dhcpv6_end=`nv get $wan_if"_dhcpv6_end"`
+    prefix_info_temp=`nv get $wan_if"_ipv6_prefix_info"`
+    echo -e "interface br0 {" > $dhcp6s_conf
+    #dhcpv6 pd
+    if [ "-$b_dhcpv6statePdEnabled" = "-1" ];then
+        echo -e "\tserver-preference 255;\n\trenew-time 6000;" >> $dhcp6s_conf
+        echo -e "\trebind-time 9000;\n\tprefer-life-time 1300;" >> $dhcp6s_conf
+        echo -e "\tvalid-life-time 2000;\n\tallow rapid-commit;" >> $dhcp6s_conf
+        echo -e "\tlink br0 {\n\t\tallow unicast;\n\t\tsend unicast;" >> $dhcp6s_conf
+        echo -e "\t\tprefix $prefix_info_temp:/$prefix_len;\n\t};" >> $dhcp6s_conf
+        linkup_add_dns_to_dhcp6s_radvd_conf dhcp6s
+        echo -e "};" >> $dhcp6s_conf
+        dhcp6s -dDf -c $dhcp6s_conf $lan_if &
+        return
+    fi
+    #set up dhcpv6 addr pool
+    if [ "-$b_dhcpv6stateEnabled" = "-1" ];then
+        echo -e "\tserver-preference 255;\n\trenew-time 6000;" >> $dhcp6s_conf
+        echo -e "\trebind-time 9000;\n\tprefer-life-time 1300;" >> $dhcp6s_conf
+        echo -e "\tvalid-life-time 2000;\n\tallow rapid-commit;" >> $dhcp6s_conf
+        echo -e "\tlink br0 {\n\t\tallow unicast;\n\t\tsend unicast;" >> $dhcp6s_conf
+        echo -e "\t\tpool {\n\t\t\trange $dhcpv6_start to $dhcpv6_end/$prefix_len;" >> $dhcp6s_conf
+        echo -e "\t\t};\n\t};" >> $dhcp6s_conf
+        linkup_add_dns_to_dhcp6s_radvd_conf dhcp6s
+        echo -e "};" >> $dhcp6s_conf
+        dhcp6s -dDf -c $dhcp6s_conf $lan_if &
+    else
+        #slaac with dhcp statelessset dns info
+        if [ "-$b_dhcpv6statelessEnabled" = "-1" ];then
+            echo -e "\tlink br0 {\n\t};" >> $dhcp6s_conf
+            linkup_add_dns_to_dhcp6s_radvd_conf dhcp6s
+            echo -e "};" >> $dhcp6s_conf
+            dhcp6s -dDf -c $dhcp6s_conf $lan_if &
+        fi
+    fi
+}
+
+#############linkup  radvd set############
+linkup_radvd_set() 
+{
+    echo  "enter linkup_radvd_set "
+
+    if [ "-$is_chinamobile_pd_diff" = "-1" ] ; then
+        pd_chinamobile=`nv get pd_chinamobile`
+        prefix_len=`nv get pd_len_chinamobile`
+        if [ "-$pd_chinamobile" == "-" ]; then
+            prefix_len="64"
+        else
+            wan_addr=$pd_chinamobile
+        fi
+    else
+        if [ "-$prefix_len" == "-" ]; then
+            prefix_len=64
+        fi
+        echo "not chinamobile"
+    fi
+    
+    rm -rf $radvd_conf
+    #wangming delete
+    if [ "-$b_dhcpv6stateEnabled" = "-1" -o "-$b_dhcpv6statePdEnabled" = "-1"];then
+        echo -e "interface br0\n{\n\tAdvSendAdvert on;" > $radvd_conf
+        echo -e "\tAdvManagedFlag on;\n};" >> $radvd_conf
+        radvd_kill
+		rm -rf $radvd_pidfile
+        radvd -d 3 -C $radvd_conf -p $radvd_pidfile &
+        echo  "leave linkup_radvd_set "
+        return
+    fi
+    
+    cp $path_ro/radvd_template.conf $radvd_conf
+	
+	sed  -i -e 's/#ipv6_wan_addr#\/64/#ipv6_wan_addr#\/#prefix_len#/g' $radvd_conf
+    sed  -i -e s/#ipv6_wan_addr#/$wan_addr/g $radvd_conf 
+    sed  -i -e s/#prefix_len#/$prefix_len/g $radvd_conf
+    sed  -i -e s/#adv_switch#/on/g $radvd_conf 
+
+    echo "copy radvd_template.conf"
+    echo "wan_addr:$wan_addr"
+    echo "prefix_len:$prefix_len"
+
+#slaac with dns info
+    if [ "-$b_dhcpv6statelessEnabled" = "-1" ];then
+        echo "use dhcpv6stateless for dns"
+    else
+        sed -i -e 's/AdvOtherConfigFlag on;/AdvOtherConfigFlag off;/g' $radvd_conf
+        linkup_add_dns_to_dhcp6s_radvd_conf radvd
+    fi
+
+    radvd_kill
+    #sleep 1
+	rm -rf $radvd_pidfile
+    radvd -d 3 -C $radvd_conf -p $radvd_pidfile &
+
+    echo  "leave linkup_radvd_set "
+}
+
+#############linkup resolve config set############
+linkup_route_set() 
+{
+    default_gw_addr_temp=`nv get $wan_if"_ipv6_gw"`
+    echo "ipv6_wan_default_gw = $default_gw_addr_temp"
+
+    echo 0 > /proc/sys/net/ipv6/conf/all/forwarding 
+
+    if [ -n "$default_gw_addr_temp" -a "-$default_gw_addr_temp" != "-::" ] ; then
+        ip -6 route add default via $default_gw_addr_temp dev $defwan6_rel
+    else
+        ip -6 route add default dev $defwan6_rel
+    fi
+    
+    nv set ipv6_br0_addr="::"
+    
+    ipv6_addr_conver "$wan_addr" "$wan_if"
+    
+    ipv6_br0_addr_tmp=`nv get ipv6_br0_addr`
+    echo "ipv6_br0_addr_tmp = $ipv6_br0_addr_tmp"
+    
+    ip -6 addr add  $ipv6_br0_addr_tmp/64 dev br0    
+    
+    #enable ipv6 packet forwarding
+    #sleep 3
+    echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
+
+    #enable ipv6 neigh discovery proxy
+    echo 1 > /proc/sys/net/ipv6/conf/all/proxy_ndp
+    
+    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#################
+get_default_wan_info $1
+linkup_route_set 
+linkup_dhcpv6_server_set
+linkup_radvd_set
+#linkup_resolve_config_set #ÓÉzte_router¶ÔIPv4£¬IPv6ͳ¼Æ½øÐÐdnsµÄÏà¹Ø²Ù×÷
+
diff --git a/ap/app/Script/scripts/zte_watch_devid_qrcode.sh b/ap/app/Script/scripts/zte_watch_devid_qrcode.sh
new file mode 100755
index 0000000..781c4c5
--- /dev/null
+++ b/ap/app/Script/scripts/zte_watch_devid_qrcode.sh
@@ -0,0 +1,35 @@
+#!/bin/sh 
+## 
+# $Id: zte_qrcode_create.sh,v 0.0.0.1 2013.05.06 liuweipeng Exp $ 
+# 
+# usage: zte_qrcode_create.sh
+# 
+
+#wifi_ssid_qrcode_name='/usr/zte_web/web/img/qrcode_ssid_wifikey.png'
+#wifi_ssid_qrcode_name_bmp='/usr/zte/zte_conf/mmi/mmi_image/ssid_wifikey.bmp'
+
+#multi_wifi_ssid_qrcode_name='/usr/zte_web/web/img/qrcode_multi_ssid_wifikey.png'
+#multi_wifi_ssid_qrcode_name_bmp='/usr/zte/zte_conf/mmi/mmi_image/multi_ssid_wifikey.bmp'
+
+#local_domain_qrcode_name='/usr/zte_web/web/img/qrcode_local_domaind.png'
+#local_domain_qrcode_name_bmp='/usr/zte/zte_conf/mmi/mmi_image/local_domaind.bmp'
+
+reg_id_text=`nv get reg_id`
+dl_url_text=`nv get app_dl_url`
+
+device_qrcode_name="/etc_rw/zcore/system/qrcode_devid.png"
+appdl_qrcode_name="/etc_rw/zcore/system/qrcode_appdl.png"
+
+
+echo "device_qrcode_name=$device_qrcode_name"
+   
+echo "enter the device id qrcode create"
+
+
+rm -rf  $device_qrcode_name
+rm -rf  $appdl_qrcode_name
+
+qrencode -o $appdl_qrcode_name -m 1 -s 7 "$dl_url_text"
+qrencode -o $device_qrcode_name -m 1 -s 7 "$reg_id_text"
+
+