[Feature][S300][task-view-617][project] add S300 project based CPE_COMMON

Change-Id: I1ff09219a8d432a839f89312341021ddaf5da4d8
diff --git a/Makefile b/Makefile
index 47b96d7..c7bca08 100755
--- a/Makefile
+++ b/Makefile
@@ -39,6 +39,7 @@
 	@echo example CPE_COMMON : make AP_PRJ=prj_mifi_min BOOT_PRJ=mifi_mini_64 PACK_PRJ=prj_mifi PATH_PRJ=lynq/CPE_COMMON
 	@echo example CPE_TELKOMSEL : make AP_PRJ=prj_mifi_min BOOT_PRJ=mifi_mini_64 PACK_PRJ=prj_mifi PATH_PRJ=lynq/CPE_TELKOMSEL
 	@echo example R307 : make AP_PRJ=prj_cpe_min BOOT_PRJ=ufi_mini PACK_PRJ=prj_cpe PATH_PRJ=lynq/R307
+	@echo example CPE_COMMON : make AP_PRJ=prj_mifi_min BOOT_PRJ=mifi_mini_64 PACK_PRJ=prj_mifi PATH_PRJ=lynq/S300
 	@echo The default value of AP_PRJ is prj_cpe_min. The following values are optional :
 	@ls ap/project/zx297520v3/*/ -d | xargs -I {} basename "{}" | tr '\n' '   '
 	@echo
diff --git a/lynq/S300/allbins/zx297520v3/prj_evb/nv/merge_lte/phyLteaAmtUser_nvrwo_0x00007800.bin b/lynq/S300/allbins/zx297520v3/prj_evb/nv/merge_lte/phyLteaAmtUser_nvrwo_0x00007800.bin
new file mode 100644
index 0000000..72f6c9d
--- /dev/null
+++ b/lynq/S300/allbins/zx297520v3/prj_evb/nv/merge_lte/phyLteaAmtUser_nvrwo_0x00007800.bin
Binary files differ
diff --git a/lynq/S300/allbins/zx297520v3/prj_evb/nv/merge_lte/phycom_nvrwo_0x0002BC00.bin b/lynq/S300/allbins/zx297520v3/prj_evb/nv/merge_lte/phycom_nvrwo_0x0002BC00.bin
new file mode 100644
index 0000000..69601e2
--- /dev/null
+++ b/lynq/S300/allbins/zx297520v3/prj_evb/nv/merge_lte/phycom_nvrwo_0x0002BC00.bin
Binary files differ
diff --git a/lynq/S300/allbins/zx297520v3/prj_evb/nv/phyLteAmtCali_nvro_0x00008000.bin b/lynq/S300/allbins/zx297520v3/prj_evb/nv/phyLteAmtCali_nvro_0x00008000.bin
new file mode 100755
index 0000000..8fb000e
--- /dev/null
+++ b/lynq/S300/allbins/zx297520v3/prj_evb/nv/phyLteAmtCali_nvro_0x00008000.bin
Binary files differ
diff --git a/lynq/S300/allbins/zx297520v3/prj_mifi/config_min_R306/partition.bin b/lynq/S300/allbins/zx297520v3/prj_mifi/config_min_R306/partition.bin
new file mode 100755
index 0000000..96a1525
--- /dev/null
+++ b/lynq/S300/allbins/zx297520v3/prj_mifi/config_min_R306/partition.bin
Binary files differ
diff --git a/lynq/S300/allbins/zx297520v3/prj_mifi/config_min_R306/partition.ini b/lynq/S300/allbins/zx297520v3/prj_mifi/config_min_R306/partition.ini
new file mode 100755
index 0000000..2a9defe
--- /dev/null
+++ b/lynq/S300/allbins/zx297520v3/prj_mifi/config_min_R306/partition.ini
@@ -0,0 +1,67 @@
+[PartitionHead]

+partition_magic=0x31594876

+partition_platform=WF7520

+partition_version=0x00201304

+partition_entrys=0xA

+partition_crc=0x12345678

+

+[Partition0]

+partition_name=zloader

+partition_type=nand

+partition_addr=0x00000000

+partition_size=0x00008000

+

+[Partition1]

+partition_name=nvrofs

+partition_type=nand

+partition_addr=0x00008000

+partition_size=0x00038000

+

+[Partition2]

+partition_name=uboot

+partition_type=nand

+partition_addr=0x00040000

+partition_size=0x00028000

+

+[Partition3]

+partition_name=uboot-mirr

+partition_type=nand

+partition_addr=0x00068000

+partition_size=0x00028000

+

+[Partition4]

+partition_name=imagefs

+partition_type=nand

+partition_addr=0x00090000

+partition_size=0x00580000

+

+[Partition5]

+partition_name=rootfs

+partition_type=nand

+partition_addr=0x00610000

+partition_size=0x00600000

+

+[Partition6]

+partition_name=resource

+partition_type=nand

+partition_addr=0x00C10000

+partition_size=0x00040000

+

+[Partition7]

+partition_name=userdata

+partition_type=nand

+partition_addr=0x00C50000

+partition_size=0x003B0000

+

+[Partition8]

+partition_name=ddr

+partition_type=ddr

+partition_addr=0x00000000

+partition_size=0xFFFFFFFF

+

+[Partition9]

+partition_name=raw

+partition_type=raw

+partition_addr=0x00000000

+partition_size=0x01000000

+

diff --git a/lynq/S300/allbins/zx297520v3/prj_mifi/nv_min_R306_dcxo/Ref_nvrw_0x26C00.bin b/lynq/S300/allbins/zx297520v3/prj_mifi/nv_min_R306_dcxo/Ref_nvrw_0x26C00.bin
new file mode 100644
index 0000000..53b0a3f
--- /dev/null
+++ b/lynq/S300/allbins/zx297520v3/prj_mifi/nv_min_R306_dcxo/Ref_nvrw_0x26C00.bin
Binary files differ
diff --git a/lynq/S300/allbins/zx297520v3/prj_mifi/nv_min_R306_dcxo/at_nvrw_0x00001000.bin b/lynq/S300/allbins/zx297520v3/prj_mifi/nv_min_R306_dcxo/at_nvrw_0x00001000.bin
new file mode 100755
index 0000000..949443e
--- /dev/null
+++ b/lynq/S300/allbins/zx297520v3/prj_mifi/nv_min_R306_dcxo/at_nvrw_0x00001000.bin
Binary files differ
diff --git a/lynq/S300/allbins/zx297520v3/prj_mifi/nv_min_R306_dcxo/phyLteaAmtUser_nvrwo_0x00007800.bin b/lynq/S300/allbins/zx297520v3/prj_mifi/nv_min_R306_dcxo/phyLteaAmtUser_nvrwo_0x00007800.bin
new file mode 100644
index 0000000..72f6c9d
--- /dev/null
+++ b/lynq/S300/allbins/zx297520v3/prj_mifi/nv_min_R306_dcxo/phyLteaAmtUser_nvrwo_0x00007800.bin
Binary files differ
diff --git a/lynq/S300/allbins/zx297520v3/prj_mifi/nv_min_R306_dcxo/phyWcdmaAmtUser_nvrwo_0x00005000.bin b/lynq/S300/allbins/zx297520v3/prj_mifi/nv_min_R306_dcxo/phyWcdmaAmtUser_nvrwo_0x00005000.bin
new file mode 100644
index 0000000..2bb553a
--- /dev/null
+++ b/lynq/S300/allbins/zx297520v3/prj_mifi/nv_min_R306_dcxo/phyWcdmaAmtUser_nvrwo_0x00005000.bin
Binary files differ
diff --git a/lynq/S300/allbins/zx297520v3/prj_mifi/nv_min_R306_dcxo/phycom_nvrwo_0x0002BC00.bin b/lynq/S300/allbins/zx297520v3/prj_mifi/nv_min_R306_dcxo/phycom_nvrwo_0x0002BC00.bin
new file mode 100644
index 0000000..69601e2
--- /dev/null
+++ b/lynq/S300/allbins/zx297520v3/prj_mifi/nv_min_R306_dcxo/phycom_nvrwo_0x0002BC00.bin
Binary files differ
diff --git a/lynq/S300/allbins/zx297520v3/prj_mifi/nv_min_R306_dcxo/psPriData_nvrw_0x00002000.bin b/lynq/S300/allbins/zx297520v3/prj_mifi/nv_min_R306_dcxo/psPriData_nvrw_0x00002000.bin
new file mode 100755
index 0000000..032f475
--- /dev/null
+++ b/lynq/S300/allbins/zx297520v3/prj_mifi/nv_min_R306_dcxo/psPriData_nvrw_0x00002000.bin
Binary files differ
diff --git a/lynq/S300/ap/app/Script/scripts/lan.sh b/lynq/S300/ap/app/Script/scripts/lan.sh
new file mode 100755
index 0000000..b4915a7
--- /dev/null
+++ b/lynq/S300/ap/app/Script/scripts/lan.sh
@@ -0,0 +1,153 @@
+#!/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
+        # youchen@2024-09-07 temp fix choke when boot without eth phy, begin
+        if [ "$device" == "eth0" ]; then
+	    eth_state=`cat /sys/gmac/gmacconfig/eth_phy_state`
+	    if [ "$eth_state" != "1" ]; then
+                continue
+	    fi
+	fi
+        # youchen@2024-09-07 temp fix choke when boot without eth phy, end
+        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/lynq/S300/ap/app/cwmp/netcwmp/cwmp.conf b/lynq/S300/ap/app/cwmp/netcwmp/cwmp.conf
new file mode 100755
index 0000000..89aae65
--- /dev/null
+++ b/lynq/S300/ap/app/cwmp/netcwmp/cwmp.conf
@@ -0,0 +1,57 @@
+[cwmp]
+enable=1;
+soap_env=SOAP-ENV
+soap_enc=SOAP-ENC
+acs_auth=1
+cpe_auth=1
+event_filename=/cache/cwmpevent.bin
+
+
+acs_url=http://192.168.0.100:7547/ACS
+#acs_url=http://192.168.28.246:9999/
+ca_file=/cache/ca.pem
+ca_password=
+
+
+cpe_manufacture=zxic
+cpe_oui=FEDCBA
+cpe_sn=744AA4E7b050
+cpe_name=000000	
+cpe_pc=OT2800
+cpe_specver=V1.0
+cpe_hwver=V1.0
+cpe_version=V3.3.3.3
+cpe_username=cpe
+cpe_password=cpe
+acs_username=cpe
+acs_password=cpe
+
+
+
+[cwmpd]
+httpd_port=7547
+http_timeout=-1
+
+[file]
+download_root=/cache
+download_img_path=/cache/download.img
+download_cfg_path=/cache/download.cfg
+download_unknown_path=/cache/download.tmp
+upload_cfg_path=/cache/cwmp.cfg
+upload_log_path=/cache/cwmp.log
+
+
+[periodic]
+enable=1
+interval=60
+
+[test]
+parameterkey=123456
+stun_enable=0
+stun_serveraddress=192.168.0.100
+stun_serverport=8080
+stun_username=stun
+stun_password=
+stun_maximumkeepaliveperiod=100
+stun_minimumkeepaliveperiod=10
+natdetected=0
\ No newline at end of file
diff --git a/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/agent.c b/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/agent.c
new file mode 100755
index 0000000..8d83e7b
--- /dev/null
+++ b/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/agent.c
@@ -0,0 +1,1315 @@
+/************************************************************************

+ *                                                                      *

+ * Netcwmp/Opencwmp Project                                             *

+ * A software client for enabling TR-069 in embedded devices (CPE).     *

+ *                                                                      *

+ * Copyright (C) 2013-2014  netcwmp.netcwmp group                            *

+ *                                                                      *

+ * This program is free software; you can redistribute it and/or        *

+ * modify it under the terms of the GNU General Public License          *

+ * as published by the Free Software Foundation; either version 2       *

+ * of the License, or (at your option) any later version.               *

+ *                                                                      *

+ * This program is distributed in the hope that it will be useful,      *

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of       *

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *

+ * GNU General Public License for more details.                         *

+ *                                                                      *

+ * You should have received a copy of the GNU Lesser General Public     *

+ * License along with this library; if not, write to the                *

+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,          *

+ * Boston, MA  02111-1307 USA                                           *

+ *                                                                      *

+ * Copyright 2013-2014  Mr.x(Mr.x) <netcwmp@gmail.com>          *

+ *                                                                      *

+ ***********************************************************************/

+#include "cwmp/periodic.h"

+

+#include "cwmp_module.h"

+#include "cwmp_agent.h"

+#include <cwmp/session.h>

+//#include "modules/data_model.h"

+

+#include "soft_timer.h"

+

+

+#define CWMP_TRUE   1

+

+#define MAX_SESSION_RETRY 3

+

+enum

+{

+    CWMP_ST_START = 0, 

+	CWMP_ST_INFORM, 

+	CWMP_ST_SEND, 

+	CWMP_ST_RESEMD, 

+	CWMP_ST_RECV, 

+	CWMP_ST_ANSLYSE, 

+	CWMP_ST_RETRY, 

+	CWMP_ST_END, 

+	CWMP_ST_EXIT

+};

+

+pthread_t g_inform_process;

+int g_stop_inform_thread = 0;

+

+#define SECHEDULE_INFORM_TIMER   (31)

+

+schedule_inform_info_st g_si;

+

+int get_session_status()

+{

+     return g_si.cwmp->session_running;

+}

+

+void *schedule_inform_timeout(void *arg)

+{

+    FUNCTION_TRACE();

+	int i = 0;

+

+	schedule_inform_info_st *psi = (schedule_inform_info_st *)arg;

+

+    cwmp_log_info("push begin");

+

+    psi->timer_running = 2;

+

+//	while(1)

+//	{

+//		if(SESSION_NO_RUNNING == get_session_status())

+//		{

+    	    psi->cwmp->new_request = CWMP_YES;

+    	    cwmp_event_set_value(psi->cwmp, INFORM_SCHEDULED, 1, psi->commandKey, 0, 0, 0);

+    	    cwmp_log_info("commandkey is:%s", psi->commandKey);

+			psi->timer_running = 0;

+

+            cwmp_log_info("push ok");

+

+			return NULL;

+//		}

+//		else

+//		{

+//		   cwmp_log_info("there is session running");

+//		   psi->timer_running = 0;

+//           g_si.delaytime += 1;

+//           if(CWMP_OK != schedule_inform_create_timer(&g_si))

+//           {

+//              ;

+//           }

+//		}

+//	}

+

+    return NULL;

+}

+

+

+int schedule_inform_create_timer(schedule_inform_info_st* psi)

+{

+    FUNCTION_TRACE();

+

+	if(2 == g_si.timer_running){

+		cwmp_log_info("there is other schedule inform running!");

+		return CWMP_OK;

+	}

+	else if(1 == g_si.timer_running)

+	{

+        // if exist one schedule inform timer, update		

+		cwmp_log_info("there is other schedule inform active!");

+		DeleteSoftTimer(SECHEDULE_INFORM_TIMER);	

+	}

+	else

+	{

+        cwmp_log_info("update schedule inform info, create timer");

+	}

+

+	TRstrncpy(g_si.commandKey, psi->commandKey, COMMAND_KEY_LEN);

+	g_si.delaytime = psi->delaytime;

+	g_si.cwmp = psi->cwmp;

+

+

+	cwmp_log_info("begin to create timer!");

+

+    long result = CreateSoftTimer(SECHEDULE_INFORM_TIMER, TIMER_FLAG_ONCE, psi->delaytime*1000, schedule_inform_timeout, &g_si);

+	g_si.timer_running = 1;

+	cwmp_log_info("end to create timer!");

+

+    cwmp_log_info("commandkey is:%s, delaytime:%d", psi->commandKey, psi->delaytime);

+

+	return CWMP_OK;

+}

+

+

+

+int cwmp_agent_retry_session(cwmp_session_t * session)

+{

+

+    int sec = 0;

+	int count = 1;

+

+    srand(time(NULL));

+    switch (session->retry_count)

+    {

+    case 0:

+    {

+        count = 5; //5~10

+        break;

+    }

+    case 1:

+    {

+        count = 10; //5~15

+        break;

+    }

+    case 2:

+    {

+        count = 20; //5~25

+        break;

+    }

+    default:

+    {

+        count = 30; //5~35

+        break;

+    }

+    }

+

+    sec = 5 + rand()% count;

+

+    while (sec>0)

+    {

+        sleep(1);

+        sec--;

+    }

+

+    if (session->retry_count > MAX_SESSION_RETRY)

+    {

+        session->retry_count = 0;

+        return CWMP_TIMEOUT;

+    }

+    else

+    {

+        session->retry_count ++;

+        return CWMP_OK;

+    }

+

+}

+

+

+int cwmp_agent_create_datetimes(datatime_t *nowtime)

+{

+    struct tm *t;

+    time_t tn;

+

+

+    //FUNCTION_TRACE();

+    tn = time(NULL);

+#ifdef WIN32

+    cwmp_log_debug("inform datatime");

+    //localtime_s(&t, &tn);

+    t = MALLOC(sizeof(struct tm));

+    memset(t, 0, sizeof(struct tm));

+#else

+    t = localtime(&tn);

+#endif

+

+    if(NULL != t)

+    {

+        nowtime->year = t->tm_year + 1900;

+        nowtime->month = t->tm_mon + 1;

+        nowtime->day = t->tm_mday;

+        nowtime->hour = t->tm_hour;

+        nowtime->min = t->tm_min;

+        nowtime->sec = t->tm_sec;

+    }

+	else

+	{

+	    cwmp_log_error("localtime return null");

+	}

+

+    return CWMP_OK;

+}

+

+//ȡ��active event�Լ�count

+int cwmp_agent_get_active_event(cwmp_t *cwmp, cwmp_session_t * session,  event_list_t **pevent_list)

+{

+    event_list_t * el;

+    event_code_t * ev;

+    int i=0;

+    FUNCTION_TRACE();

+

+    el = cwmp_create_event_list(session->env, INFORM_MAX);

+	if(NULL == el)

+	{

+	    cwmp_log_error("el cwmp_create_event_list return NULL");

+		return CWMP_ERROR;

+	}

+

+    event_code_t ** pec = cwmp->el->events;

+

+    int elsize = cwmp->el->count;

+    for(i=0; i<elsize; i++)

+    {      

+

+	    if(pec[i]  && pec[i]->ref > 0)

+        {

+

+            event_code_t * ec = pec[i];

+            ev = cwmp_create_event_code(session->env);

+            if(NULL == ev)

+            {

+                cwmp_log_error("ev cwmp_create_event_code return null");

+				return CWMP_ERROR;

+            }

+

+            ev->event = ec->event;

+            ev->code = ec->code;

+

+            if (pec[i]->event == INFORM_MREBOOT || pec[i]->event == INFORM_BOOTSTRAP)

+            {

+                strncpy(ev->command_key , ec->command_key, COMMAND_KEY_LEN);

+            }

+

+

+            el->events[el->count++] = ev;

+            ev = NULL;

+

+        }

+    }

+    if (el->count == 0)

+    {

+        ev = cwmp_create_event_code(session->env);

+		if(NULL == ev)

+		{

+		    cwmp_log_error("ev cwmp_create_event_code return null");

+			return CWMP_ERROR;

+		}

+

+        ev->event = INFORM_BOOT;

+        ev->code = CWMP_INFORM_EVENT_CODE_1;

+        el->events[el->count++] = ev;

+    }

+

+    *pevent_list = el;

+

+    return CWMP_OK;

+}

+

+int cwmp_agent_send_request(cwmp_session_t * session)

+{

+    FUNCTION_TRACE();

+    return cwmp_session_send_request(session);

+}

+

+int cwmp_agent_recv_response(cwmp_session_t * session)

+{

+    return cwmp_session_recv_response(session);

+}

+

+static void* inform_timer_process_thread(cwmp_session_t* session) 

+{

+    FUNCTION_TRACE();

+

+    char periodic_enable[4] = {0};

+    char periodic_interval[8] = {0};

+    cwmp_t * cwmp = session->cwmp;

+

+    while (1) 

+    {

+        if (g_stop_inform_thread)

+        {

+            break;

+        }

+

+        cfg_get_item("periodic_enable", periodic_enable, sizeof(periodic_enable));

+

+        if(0 == strcmp(periodic_enable, "1"))

+        {

+            event_list_t * evtlist = NULL;

+            xmldoc_t * newdoc = NULL;

+

+            cfg_get_item("periodic_interval", periodic_interval, sizeof(periodic_interval));

+            sleep(atoi(periodic_interval));

+

+            cwmp_agent_get_active_event(cwmp, session,  &evtlist);

+

+			if(evtlist != NULL)

+			{

+				cwmp_event_clear_active(cwmp);

+			}

+			else

+			{

+				cwmp_log_debug("evtlist is null");

+			}

+

+			if (cwmp->acs_auth)

+			{

+				cwmp_session_set_auth(session, cwmp->acs_user, cwmp->acs_pwd);

+			}				

+

+			cwmp_log_debug("session stutus: INFORM\n");

+			newdoc = cwmp_session_create_inform_message(session, evtlist, session->envpool);

+

+			if(NULL != newdoc)

+			{

+				cwmp_write_doc_to_chunk(newdoc, session->writers, session->envpool);

+				cwmp_agent_send_request(session);

+			}

+			else

+			{

+				cwmp_log_error("newdoc is null");

+			}

+		}

+

+        sleep(1);

+    }

+

+    return NULL;

+}

+

+static void cwmp_agent_start_periodic_inform_session(cwmp_session_t* session)

+{

+    if (pthread_create(&g_inform_process, NULL, inform_timer_process_thread, session) != 0)

+    {

+        cwmp_log_error("pthread create error\n");

+    }

+

+    return;

+}

+

+void cwmp_agent_start_session(cwmp_t * cwmp)

+{

+    int rv;

+    cwmp_session_t * session;

+    int session_close = CWMP_NO;

+    xmldoc_t * newdoc;

+    FUNCTION_TRACE();

+    event_list_t  *evtlist;

+    int inform_flag = 1;

+

+    while (TRUE)

+    {

+        if (cwmp->new_request == CWMP_NO)

+        {

+            cwmp_log_debug("No new request from ACS\n");

+            sleep(2);

+            //cwmp->new_request = CWMP_YES;

+            continue;

+        }

+

+        cwmp_log_debug("New request from ACS\n");

+

+		cwmp_clean_periodic_inform(cwmp);

+

+        cwmp->new_request = CWMP_NO;

+        session = cwmp_session_create(cwmp);

+        if(NULL == session)

+        {

+            cwmp_log_error("session cwmp_session_create return NULL");

+			cwmp->new_request = CWMP_YES;

+			continue;

+        }

+

+        session_close  = CWMP_NO;

+        session->timeout = cwmp_conf_get_int("cwmpd:http_timeout");

+        //cwmp_session_set_timeout(cwmp_conf_get_int("cwmpd:http_timeout"));

+        cwmp_log_debug("session timeout is %d", session->timeout);

+

+        cwmp_session_open(session);

+

+        while (!session_close)

+        {

+            //cwmp_log_debug("session status: %d", session->status);

+            switch (session->status)

+            {

+            case CWMP_ST_START:

+                //create a new connection to acs

+                cwmp_log_debug("session stutus: New START\n");

+

+                if (cwmp_session_connect(session, cwmp->acs_url) != CWMP_OK)

+                {

+                    cwmp_log_error("connect to acs: %s failed.\n", cwmp->acs_url);

+                    session->status = CWMP_ST_RETRY;

+                }

+                else

+                {

+                    session->status = CWMP_ST_INFORM;

+                }

+                break;

+            case CWMP_ST_INFORM:

+				evtlist = NULL;

+				cwmp_log_debug("session stutus: INFORM\n");

+				cwmp_agent_get_active_event(cwmp, session,  & evtlist);

+				if(evtlist != NULL)

+				{

+					cwmp_event_clear_active(cwmp);

+				}

+				else

+				{

+					cwmp_log_debug("evtlist is null");

+					session->status = CWMP_ST_EXIT;	

+					break;

+				}

+

+				cwmp_log_debug("session stutus: INFORM2\n");

+                if (cwmp->acs_auth)

+                {			

+                    cwmp_session_set_auth(session, cwmp->acs_user, cwmp->acs_pwd );

+                }				

+

+				cwmp_log_debug("session stutus: INFORM3\n");

+                newdoc = cwmp_session_create_inform_message(session, evtlist, session->envpool);

+

+				if(NULL != newdoc)

+				{

+                    cwmp_write_doc_to_chunk(newdoc, session->writers,  session->envpool);

+                    session->last_method = CWMP_INFORM_METHOD;

+                    session->status = CWMP_ST_SEND;

+				}

+				else

+				{

+				    cwmp_log_error("newdoc is null");

+					session->last_method = CWMP_INFORM_METHOD;

+                    session->status = CWMP_ST_EXIT;

+				}

+

+                break;

+

+            case CWMP_ST_SEND:

+

+                cwmp_log_debug("session stutus: SEND");

+                cwmp_log_debug("session data request length: %d", cwmp_chunk_length(session->writers));

+                session->newdata = CWMP_NO;

+

+                rv = cwmp_agent_send_request(session);

+

+                if (rv == CWMP_OK)

+                {

+					cwmp_log_debug("session data sended OK, rv=%d", rv);

+					session->status = CWMP_ST_RECV;

+                }

+				else

+				{

+					cwmp_log_debug("session data sended faild! rv=%d", rv);

+					session->status = CWMP_ST_EXIT;

+					/*

+					if (rv == CWMP_COULDNOT_CONNECT)

+					{

+						session->status = CWMP_ST_RETRY;

+					}

+					else

+                    {

+                        session->status = CWMP_ST_EXIT;

+                    }

+					*/

+                }

+

+                break;

+            case CWMP_ST_RECV:

+                cwmp_log_debug("session stutus: RECV");

+                cwmp_chunk_clear(session->readers);

+

+                rv = cwmp_agent_recv_response(session);

+

+                if (rv == CWMP_OK)

+                {

+                    session->status = CWMP_ST_ANSLYSE;

+                }

+                else

+                {

+                    session->status = CWMP_ST_END;

+                }

+                break;

+

+            case CWMP_ST_ANSLYSE:

+                cwmp_log_debug("session stutus: ANSLYSE");

+                if(1 == inform_flag)

+                {

+                    inform_flag = 0;

+                    g_stop_inform_thread = 0;

+                    cwmp_agent_start_periodic_inform_session(session);

+                }

+

+                rv = cwmp_agent_analyse_session(session);

+                if (rv == CWMP_OK)

+                {

+                    session->status = CWMP_ST_SEND;

+                }

+                else

+                {

+                    session->status = CWMP_ST_END;

+                }

+                break;

+            case CWMP_ST_RETRY:

+				cwmp_log_debug("session stutus: RETRY");

+                if (cwmp_agent_retry_session(session) == CWMP_TIMEOUT)

+                {

+					cwmp_log_debug("session retry timeover, go out");

+                    session->status = CWMP_ST_EXIT;

+                }

+                else

+                {

+                    session->status = CWMP_ST_START;

+                }

+                break;

+            case CWMP_ST_END:

+                //close connection of ACS

+                cwmp_log_debug("session stutus: END");

+				//run task from queue

+

+                if (session->newdata == CWMP_YES)

+                {

+                    session->status = CWMP_ST_SEND;

+                }

+                else

+                {

+                    session->status = CWMP_ST_EXIT;

+                }

+                break;

+

+            case CWMP_ST_EXIT:

+                cwmp_log_debug("session stutus: EXIT");

+

+                g_stop_inform_thread = 1;

+                if (g_inform_process != 0)

+                {

+                    pthread_join(g_inform_process, NULL);

+                }

+                inform_flag = 1;

+

+                cwmp_session_close(session);

+                if (session->reconnect == CWMP_YES)

+                {

+                    session->reconnect = CWMP_NO;

+                    session->status = CWMP_ST_START;

+                    break;

+                }

+                session_close = CWMP_YES;

+                break;

+

+

+            default:

+				cwmp_log_debug("Unknown session stutus");

+                break;

+            }//end switch

+        }//end while(!session_close)

+

+        cwmp_log_debug("session stutus: EXIT");

+        cwmp_session_free(session);

+        session = NULL;

+

+		cwmp->session_running = SESSION_NO_RUNNING;

+

+		int newtaskres = cwmp_agent_run_tasks(cwmp);

+		if(newtaskres == CWMP_YES)

+		{

+			cwmp->new_request = CWMP_YES;

+		}

+

+        cwmp_reset_periodic_inform(cwmp);

+

+    }//end while(TRUE)

+}

+

+void to_upper_case_substring(char *str, const char *substring)

+{

+    int i = 0;

+    char *found = strstr(str, substring);

+    int sub_len = strlen(substring);

+

+    while (found != NULL) 

+    {

+        for (i = 0; i < sub_len; ++i)

+        {

+            found[i] = toupper((unsigned char)found[i]);

+        }

+        found = strstr(found + sub_len, substring);

+    }

+}

+

+int cwmp_agent_analyse_session(cwmp_session_t * session)

+{

+    pool_t * doctmppool  = NULL;

+    char * xmlbuf;

+    char cwmp_id[10] = {0};

+    cwmp_uint32_t len;

+    xmldoc_t *  doc;

+    char * method;

+    xmldoc_t *   newdoc = NULL;

+    int rc = CWMP_OK;

+

+    static char * xml_fault = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:cwmp=\"urn:dslforum-org:cwmp-1-0\" xmlns=\"urn:dslforum-org:cwmp-1-0\"><SOAP-ENV:Body SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"  id=\"_0\"><SOAP-ENV:Fault>Error Message</SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>";

+

+    cwmp_uint32_t msglength = 0;

+

+    FUNCTION_TRACE();

+	if(NULL == session)

+	{

+	    cwmp_log_error("session is null");

+		return CWMP_ERROR;

+	}

+

+	cwmp_t * cwmp = session->cwmp;

+	if(NULL == cwmp)

+	{

+	    cwmp_log_error("cwmp is null");

+		return CWMP_ERROR;

+	}	

+

+    msglength = cwmp_chunk_length(session->readers);	

+    if (msglength<= 0)

+    {

+        session->newdata = CWMP_NO;

+        cwmp_log_debug("analyse receive length is 0");

+	    goto eventcheck;

+//        return CWMP_ERROR;

+    }

+

+    doctmppool = pool_create(POOL_DEFAULT_SIZE);

+	if(NULL == doctmppool)

+	{

+	    cwmp_log_error("doctmppool is null");

+		return CWMP_ERROR;

+	}		

+

+    xmlbuf = pool_palloc(doctmppool, msglength+32);

+	if(NULL == xmlbuf)

+	{

+	    cwmp_log_error("xmlbuf is null");

+		return CWMP_ERROR;

+	}	

+

+    len = sprintf(xmlbuf,"<cwmp>");

+    cwmp_chunk_copy(xmlbuf + len, session->readers, msglength);

+    strncpy(xmlbuf+len+msglength, "</cwmp>", 32-len-1);

+    strcpy(cwmp_id, "cwmp:ID");

+    to_upper_case_substring(xmlbuf, cwmp_id);

+

+    cwmp_log_debug("agent analyse xml: \n%s", xmlbuf);

+

+    doc = XmlParseBuffer(doctmppool, xmlbuf);

+    if (!doc)

+    {

+        cwmp_log_debug("analyse create doc null\n");

+        cwmp_chunk_write_string(session->writers, xml_fault, TRstrlen(xml_fault), session->envpool);

+        goto finished;

+

+    }

+

+    method = cwmp_get_rpc_method_name(doc);

+    cwmp_log_debug("analyse method is: %s\n", method);

+

+    cwmp_chunk_clear(session->writers);

+    pool_clear(session->envpool);

+

+    cwmp_log_info("----------------------------");

+

+    if (TRstrcmp(method, CWMP_RPC_GETRPCMETHODS) == 0)

+    {

+        newdoc = cwmp_session_create_getrpcmethods_response_message(session, doc, doctmppool);

+    }

+    else if (TRstrcmp(method, CWMP_RPC_INFORMRESPONSE) == 0)

+    {

+        newdoc = NULL;

+    }

+    else if (TRstrcmp(method, CWMP_RPC_GETPARAMETERNAMES) == 0)

+    {

+        newdoc = cwmp_session_create_getparameternames_response_message(session, doc, doctmppool);

+    }

+    else if (TRstrcmp(method, CWMP_RPC_GETPARAMETERVALUES) == 0)

+    {

+        newdoc = cwmp_session_create_getparametervalues_response_message(session, doc, doctmppool);

+    }

+    else if (TRstrcmp(method, CWMP_RPC_SETPARAMETERVALUES) == 0)

+    {

+        newdoc = cwmp_session_create_setparametervalues_response_message(session, doc, doctmppool);

+    }

+    else if (TRstrcmp(method, CWMP_RPC_DOWNLOAD) == 0)

+    {

+        newdoc = cwmp_session_create_download_response_message(session, doc, doctmppool);

+    }

+    else if (TRstrcmp(method, CWMP_RPC_UPLOAD) == 0)

+    {

+        newdoc = cwmp_session_create_upload_response_message(session, doc, doctmppool);

+    }

+   else if (TRstrcmp(method, CWMP_RPC_TRANSFERCOMPLETERESPONSE) == 0)

+    {

+        newdoc = NULL;

+    }

+    else if (TRstrcmp(method, CWMP_RPC_REBOOT) == 0)

+    {

+        newdoc = cwmp_session_create_reboot_response_message(session, doc, doctmppool);

+    }

+    else if (TRstrcmp(method, CWMP_RPC_ADDOBJECT) == 0)

+    {

+        newdoc = cwmp_session_create_addobject_response_message(session, doc, doctmppool);

+    }

+    else if (TRstrcmp(method, CWMP_RPC_DELETEOBJECT) == 0)

+    {

+        newdoc = cwmp_session_create_deleteobject_response_message(session, doc, doctmppool);

+    }

+

+    else if (TRstrcmp(method, CWMP_RPC_FACTORYRESET) == 0)

+    {

+        newdoc = cwmp_session_create_factoryreset_response_message(session, doc, doctmppool);

+    }

+    else if (TRstrcmp(method, CWMP_RPC_GETPARAMETERATTRIBUTES) == 0)

+    {

+        newdoc = cwmp_session_create_getparamterattributes_response_message(session, doc, doctmppool);

+    }

+    else if (TRstrcmp(method, CWMP_RPC_SETPARAMETERATTRIBUTES) == 0)

+    {

+        newdoc = cwmp_session_create_setparamterattributes_response_message(session, doc, doctmppool);

+    }	

+    else if (TRstrcmp(method, CWMP_RPC_SCHEDULEINFORM) == 0)

+    {

+        schedule_inform_info_st si;

+		si.cwmp = session->cwmp;

+        newdoc = cwmp_session_create_scheduleinform_response_message(session, doc, doctmppool, &si);

+		int rc = schedule_inform_create_timer(&si);

+    }		

+    else

+    {

+    	//check event queue

+    	//newdoc = cwmp_session_create_event_response_message(session, doc, doctmppool);

+        cwmp_log_info("unknown method type:%s", method);

+    }

+

+    cwmp_log_info("----------------------------");

+

+//    cwmp_t * cwmp = session->cwmp;

+    if(newdoc == NULL)

+    {

+        cwmp_log_debug("agent analyse newdoc is null. ");

+

+eventcheck:

+    	{

+

+    		cwmp_log_debug("agent analyse begin check global event, %d", cwmp->event_global.event_flag);

+

+    		//check global event for transfercomplete

+

+    		if(cwmp->event_global.event_flag & EVENT_REBOOT_TRANSFERCOMPLETE_FLAG)

+    		{

+    			cwmp->event_global.event_flag &=  ~EVENT_REBOOT_TRANSFERCOMPLETE_FLAG;

+    			if(!doctmppool)

+    			{

+    				doctmppool = pool_create(POOL_DEFAULT_SIZE);

+    			}

+

+				if(!doctmppool)

+				{

+				    cwmp_log_error("doctmppool pool create return null");

+					return CWMP_ERROR;

+				}

+    			event_code_t ec;

+    			ec.event = INFORM_TRANSFERCOMPLETE;

+    			TRstrncpy(ec.command_key, cwmp->event_global.event_key, COMMAND_KEY_LEN);

+    			ec.fault_code = cwmp->event_global.fault_code;

+    			ec.start = cwmp->event_global.start;

+    			ec.end = cwmp->event_global.end;

+    			newdoc = cwmp_session_create_transfercomplete_message(session, &ec, doctmppool);	

+

+    		}

+

+    	}

+

+    }

+

+

+    cwmp_log_debug("newdoc %p, msglength: %d", newdoc, msglength );

+    if(newdoc != NULL) // || (newdoc == NULL && msglength == 0 && session->retry_count < 2))

+    {

+        session->newdata = CWMP_YES;

+        cwmp_write_doc_to_chunk(newdoc, session->writers,  session->envpool);

+	    rc = CWMP_OK;

+    }

+	else if(/*newdoc == NULL && */msglength != 0)

+	{

+        session->newdata = CWMP_YES;

+        cwmp_write_doc_to_chunk(newdoc, session->writers,  session->envpool);

+	    rc = CWMP_OK;	    

+	}

+	else

+    {  	

+	    rc = CWMP_ERROR;

+    }

+

+finished:

+	if(doctmppool  != NULL)

+	{

+	    pool_destroy(doctmppool);

+	}

+

+    return rc;

+}

+

+

+

+static void print_param(parameter_node_t * param, int level)

+{

+    if(!param) return; 

+

+    parameter_node_t * child;

+    char fmt[128];

+    //cwmp_log_debug("name: %s, type: %s, level: %d\n", param->name, cwmp_get_type_string(param->type), level);

+    int i=0;

+

+    snprintf(fmt, 127, "|%%-%ds%%s,  get:%%p set:%%p refresh:%%p\n", level*4);

+

+    cwmp_log_debug_src(fmt, "----", param->name, param->get, param->set, param->refresh);

+

+    child = param->child;

+

+    if(!child)

+  	return;

+    print_param(child, level+1);

+

+    parameter_node_t * next = child->next_sibling;

+

+    while(next)

+    {

+        print_param(next, level+1);

+        next = next->next_sibling;

+    }

+}

+

+

+

+void cwmp_agent_session(cwmp_t * cwmp)

+{

+    char name[1024] = {0};

+    char value[1024]= {0};

+    char local_ip[256];

+

+    char * envstr;

+    char * encstr;

+

+    envstr = "SOAP-ENV"; //cwmp_conf_get("cwmp:soap_env");

+    encstr = "SOAP-ENC"; // cwmp_conf_get("cwmp:soap_enc");

+

+    cwmp_set_envelope_ns(envstr, encstr);

+

+#if 0

+    if (cwmp_session_get_localip(local_ip) == -1)

+    {

+        cwmp_log_error("get local ip error. exited.\n");

+        exit(-1);

+    }

+#else

+    cwmp_session_get_localip(local_ip);	

+#endif	

+

+    print_param(cwmp->root, 0);

+

+    CWMP_SPRINTF_PARAMETER_NAME(name, 3, InternetGatewayDeviceModule, ManagementServerModule, URLModule);

+    cwmp_data_set_parameter_value(cwmp, cwmp->root, name, cwmp->acs_url, TRstrlen(cwmp->acs_url), cwmp->pool);

+

+    CWMP_SPRINTF_PARAMETER_NAME(name, 3, InternetGatewayDeviceModule, ManagementServerModule, ConnectionRequestURLModule);

+    TRsnprintf(value, 1024, "http://%s:%d", local_ip, cwmp->httpd_port);

+    cwmp_data_set_parameter_value(cwmp, cwmp->root, name, value, TRstrlen(value), cwmp->pool);

+    cwmp_log_debug("set request name:%s, value:%s", name, value);

+

+

+    CWMP_SPRINTF_PARAMETER_NAME(name, 3, InternetGatewayDeviceModule, DeviceInfoModule, ManufacturerModule);

+    cwmp_data_set_parameter_value(cwmp, cwmp->root, name, cwmp->cpe_mf, TRstrlen(cwmp->cpe_mf), cwmp->pool);

+

+

+    CWMP_SPRINTF_PARAMETER_NAME(name, 3, InternetGatewayDeviceModule, DeviceInfoModule, ManufacturerOUIModule);

+    cwmp_data_set_parameter_value(cwmp, cwmp->root, name, cwmp->cpe_oui, TRstrlen(cwmp->cpe_oui), cwmp->pool);

+

+    CWMP_SPRINTF_PARAMETER_NAME(name, 3, InternetGatewayDeviceModule, DeviceInfoModule, ProductClassModule);

+    cwmp_data_set_parameter_value(cwmp, cwmp->root, name, cwmp->cpe_pc, TRstrlen(cwmp->cpe_pc), cwmp->pool);

+

+    CWMP_SPRINTF_PARAMETER_NAME(name, 3, InternetGatewayDeviceModule, DeviceInfoModule, SerialNumberModule);

+    cwmp_data_set_parameter_value(cwmp, cwmp->root, name, cwmp->cpe_sn, TRstrlen(cwmp->cpe_sn), cwmp->pool);

+

+

+    cwmp_agent_start_session(cwmp);

+}

+

+

+/*

+int cwmp_agent_download_file(download_arg_t * dlarg)

+{

+    int faultcode = 0;

+    char url[255];

+    if (TRstrncasecmp(dlarg->url,  "ftp://", 6) == 0)

+    {

+        if (dlarg->username != NULL && strlen(dlarg->username) != 0)

+        {

+            TRsnprintf(url, 255, "ftp://%s:%s@%s", dlarg->username, dlarg->password, dlarg->url+6);

+        }

+        else

+        {

+            TRstrncpy(url, dlarg->url, 255);

+        }

+    }

+    else

+    {

+        TRstrncpy(url, dlarg->url, 255);

+    }

+

+    fetchIO * downfile =   fetchGetURL(url, "");

+    if (!downfile)

+    {

+        cwmp_log_debug("download file fail:  %s", url);

+        faultcode = 9001;

+    }

+    else

+    {

+        char readbuf[1024];

+        int readlen;

+        char targetfile[64];

+        if (dlarg->targetname != NULL && strlen(dlarg->targetname) != 0)

+        {

+            TRsnprintf(targetfile, 64, "/tmp/%s", dlarg->targetname);

+        }

+        else

+        {

+            TRsnprintf(targetfile, 64, "/tmp/%d.file", time(NULL));

+        }

+        FILE * df = fopen(targetfile, "wb+");

+        while (df != NULL)

+        {

+            readlen = fetchIO_read(downfile, readbuf, 1023);

+            if (readlen <= 0)

+            {

+                cwmp_log_debug("fetch io read zero. %s", readlen);

+                break;

+            }

+            readbuf[readlen] = 0;

+            fwrite(readbuf, readlen, 1, df);

+        }

+

+        if (df)

+        {

+            fclose(df);

+        }

+        else

+        {

+            faultcode = 9001;

+        }

+

+        cwmp_log_debug("download file ok:  %s, %s", url, targetfile);

+

+

+        fetchIO_close(downfile);

+    }

+

+

+    return faultcode;

+

+}

+

+

+

+int cwmp_agent_upload_file(upload_arg_t * ularg)

+{

+    int faultcode = 0;

+    char url[255];

+

+    if (TRstrncasecmp(ularg->url,  "ftp://", 6) == 0)

+    {

+        if (ularg->username != NULL && strlen(ularg->username) != 0)

+        {

+            TRsnprintf(url, 255, "ftp://%s:%s@%s", ularg->username, ularg->password, ularg->url+6);

+        }

+        else

+        {

+            TRstrncpy(url, ularg->url, 255);

+        }

+    }

+    else

+    {

+        TRstrncpy(url, ularg->url, 255);

+    }

+

+    fetchIO * uploadfile =   fetchPutURL(url, "");

+    if (!uploadfile)

+    {

+        cwmp_log_debug("upload file fail:  %s", url);

+        faultcode = 9001;

+    }

+    else

+    {

+        char readbuf[1024];

+        int readlen;

+	char targetfile[64];

+	FILE * uf;

+	int rc;

+	if(strcmp(ularg->filetype, "1 Vendor Configuration File") == 0)

+	{

+		//����ʵ������, �޸������������ļ�·��

+

+		uf = fopen("/tmp/mysystem.cfg", "rb");		

+	}

+	else if(strcmp(ularg->filetype, "2 Vendor Log File") == 0)

+	{

+		//����ʵ������, �޸������������ļ�·��

+		uf = fopen("/tmp/mysystem.log", "rb");	

+	}

+	else

+	{

+		uf = fopen("/tmp/mysystem.log", "rb");	

+	}

+

+

+        while (uf != NULL)

+        {

+            readlen = fread(readbuf, 1024, 1,  uf);

+            if (readlen <= 0)

+            {

+                cwmp_log_debug("fetch io read zero. %s", readlen);

+

+                break;

+            }

+            readbuf[readlen] = 0;

+

+	   rc = fetchIO_write(uploadfile, readbuf, readlen);

+	   if(rc <= 0)

+	   {

+		faultcode = 9001;

+		break;

+	   }

+

+        }

+

+	if(uf)

+	{

+		fclose(uf);

+	}

+	else

+	{

+		faultcode = 9001;

+	}

+

+

+

+        cwmp_log_debug("upload file finished:  %s, file:%s", url, targetfile);

+

+

+        fetchIO_close(uploadfile);

+    }

+

+

+    return faultcode;

+

+}

+*/

+

+

+

+int cwmp_agent_download_file(download_arg_t * dlarg)

+{

+    int faultcode = 0;

+    char * fromurl = dlarg->url;

+

+    char tofile[256+1] = {0};

+	char downloadroot[256+1] = {0};

+

+	FUNCTION_TRACE();

+

+    if(!fromurl)

+    {

+        cwmp_log_error("download src file path is null!");

+		return 9001;

+	}

+

+	if(NULL == dlarg->targetname)

+	{

+        if(TRstrcmp(dlarg->filetype, "1 Firmware Upgrade Image") == 0)

+        {

+    	    cwmp_conf_get("file:download_img_path", tofile);

+        }

+    	else if(TRstrcmp(dlarg->filetype, "3 Vendor Configuration File") == 0)

+    	{

+    	    cwmp_conf_get("file:download_cfg_path", tofile);

+    	}

+    	else

+    	{

+            cwmp_conf_get("file:download_unknown_path", tofile);

+    	}

+	}

+	else

+	{

+	    cwmp_conf_get("file:download_root", downloadroot);

+		TRsnprintf(tofile, 256, "%s/%s", downloadroot, dlarg->targetname);

+	}

+

+	cwmp_log_info("file type:%s, save file(%s) to path:%s", dlarg->filetype, fromurl, tofile);

+

+    if(/*dlarg->url &&*/ TRstrncasecmp("ftp://", dlarg->url, 6) == 0)

+    {

+	    cwmp_log_debug("Download url:%s", dlarg->url);

+	    return 9001;

+	}

+

+    faultcode = http_receive_file(fromurl, tofile);

+

+    if(faultcode != CWMP_OK)

+    {

+        cwmp_log_debug("faultcode:%d", faultcode);

+	    faultcode = 9001;

+    }

+

+    return faultcode;

+}

+

+

+

+int cwmp_agent_upload_file(upload_arg_t * ularg)

+{

+    int faultcode = 0;

+    FUNCTION_TRACE();

+    char * fromfile;

+

+	char cfg_path[256] = {0};

+	char log_path[256] = {0};

+

+	FUNCTION_TRACE();

+

+	cwmp_conf_get("file:upload_cfg_path", cfg_path);

+	cwmp_conf_get("file:upload_log_path", log_path);

+

+	if(TRstrcmp(ularg->filetype, "1 Vendor Configuration File") == 0)

+	{

+		fromfile = cfg_path;

+	}

+	else if(TRstrcmp(ularg->filetype, "2 Vendor Log File") == 0)

+	{

+		fromfile = log_path;

+	}

+	else

+	{

+		fromfile = cfg_path;

+	}

+

+	cwmp_log_info("upload type:%s, send file:%s, url:%s", ularg->filetype, fromfile, ularg->url);

+

+

+	faultcode = http_send_file(fromfile, ularg->url);

+

+    if(faultcode != CWMP_OK)

+    {  

+        cwmp_log_error("http send file return[%d], not CWMP_OK, set faultcode 9001", faultcode);

+	    faultcode = 9001;

+    }

+

+    return faultcode;

+}

+

+

+

+int cwmp_agent_run_tasks(cwmp_t * cwmp)

+{

+	void * data;

+	int tasktype = 0;;

+	int ok = CWMP_NO;

+	int rc = 0;

+

+	FUNCTION_TRACE();

+

+	while(1)

+	{

+		tasktype = queue_pop(cwmp->queue, &data);

+		if(tasktype == -1)

+		{

+			cwmp_log_debug("no more task to run");

+			break;

+		}

+		ok = CWMP_YES;

+		switch(tasktype)

+		{

+			case TASK_DOWNLOAD_TAG:

+				{

+					cwmp_log_debug("Download begin.....");

+

+					download_arg_t * dlarg = (download_arg_t*)data;

+					//begin download file

+					time_t starttime = time(NULL);

+					int faultcode = 0;

+

+					faultcode = cwmp_agent_download_file(dlarg);

+

+					time_t endtime = time(NULL);

+					cwmp_event_set_value(cwmp, INFORM_TRANSFERCOMPLETE, 1,dlarg->cmdkey, faultcode, starttime, endtime);

+

+

+					FREE(dlarg);

+

+					cwmp_log_debug("Download OK.....");

+				}

+				break;

+

+			case TASK_UPLOAD_TAG:

+				{

+					cwmp_log_debug("Upload begin.....");

+

+					upload_arg_t * ularg = (upload_arg_t*)data;

+					//begin download file

+					time_t starttime = time(NULL);

+					int faultcode = 0;

+

+					faultcode = cwmp_agent_upload_file(ularg);

+

+					time_t endtime = time(NULL);

+					cwmp_event_set_value(cwmp, INFORM_TRANSFERCOMPLETE, 1,ularg->cmdkey, faultcode, starttime, endtime);

+

+

+					FREE(ularg);

+

+					cwmp_log_debug("Upload OK.....");

+				}

+				break;

+

+			case TASK_REBOOT_TAG:

+				{

+					//begin reboot system

+					cwmp_log_debug("reboot ...");

+					cwmp_event_set_value(cwmp, INFORM_MREBOOT, 1, NULL, 0, 0, 0);

+					cwmp_event_clear_active(cwmp);

+

+                    // inorder to save file ok

+

+					sleep(20);

+

+					rc = restart_request(MODULE_ID_TR069);

+

+					if(0 != rc)

+					{

+					    cwmp_log_info("restart request fail! rc:%d", rc);

+					}

+				}

+				break;

+

+			case TASK_FACTORYRESET_TAG:

+				{

+					//begin factory reset system

+					cwmp_log_debug("factory reset  begin...");

+

+					cwmp_event_clear_active(cwmp);

+

+					rc = reset_request(MODULE_ID_TR069);

+

+					if(0 != rc)

+					{

+					    cwmp_log_info("reset request fail! rc:%d", rc);

+					}

+

+

+					cwmp_log_debug("factory reset OK.....");

+				}

+				break;

+

+			default:

+

+				break;

+

+		}

+	}

+

+	return ok;

+}

+

+

+

+

+

+

diff --git a/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/conf.c b/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/conf.c
new file mode 100755
index 0000000..bd9daa2
--- /dev/null
+++ b/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/conf.c
@@ -0,0 +1,99 @@
+/************************************************************************

+ *                                                                      *

+ * Netcwmp/Opencwmp Project                                             *

+ * A software client for enabling TR-069 in embedded devices (CPE).     *

+ *                                                                      *

+ * Copyright (C) 2013-2014  netcwmp.netcwmp group                            *

+ *                                                                      *

+ * This program is free software; you can redistribute it and/or        *

+ * modify it under the terms of the GNU General Public License          *

+ * as published by the Free Software Foundation; either version 2       *

+ * of the License, or (at your option) any later version.               *

+ *                                                                      *

+ * This program is distributed in the hope that it will be useful,      *

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of       *

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *

+ * GNU General Public License for more details.                         *

+ *                                                                      *

+ * You should have received a copy of the GNU Lesser General Public     *

+ * License along with this library; if not, write to the                *

+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,          *

+ * Boston, MA  02111-1307 USA                                           *

+ *                                                                      *

+ * Copyright 2013-2014  Mr.x(Mr.x) <netcwmp@gmail.com>          *

+ *                                                                      *

+ ***********************************************************************/

+

+#include "cwmp_module.h"

+#include <cwmp/cfg.h>

+

+

+

+void cwmp_conf_init(cwmp_t * cwmp)

+{

+    pool_t * pool;

+    FUNCTION_TRACE();

+    char acs_username[16] = {0};

+    char acs_password[16] = {0};

+    char acs_url[128] = {0};

+    char cpe_username[16] = {0};

+    char cpe_password[16] = {0};

+

+    pool = cwmp->pool;

+    cwmp->httpd_port =  cwmp_conf_get_int("cwmpd:httpd_port"); //cwmp_nvram_get_int("cwmp:httpd_port");

+

+    cwmp->acs_auth  =   cwmp_conf_get_int("cwmp:acs_auth");

+    cwmp->cpe_auth  =   cwmp_conf_get_int("cwmp:cpe_auth");

+

+    if(cwmp->acs_auth)

+    {

+        cfg_get_item("acs_username", acs_username, sizeof(acs_username));

+        cwmp->acs_user = malloc(strlen(acs_username) + 1);

+        sprintf(cwmp->acs_user, "%s", acs_username);

+

+        cfg_get_item("acs_password", acs_password, sizeof(acs_password));

+        cwmp->acs_pwd = malloc(strlen(acs_password) + 1);

+        sprintf(cwmp->acs_user, "%s", acs_password);

+        // cwmp->acs_user = cwmp_conf_pool_get(pool, "cwmp:acs_username");

+        // cwmp->acs_pwd = cwmp_conf_pool_get(pool, "cwmp:acs_password");

+    }

+

+	if(cwmp->cpe_auth)

+	{

+        cfg_get_item("cpe_username", cpe_username, sizeof(cpe_username));

+        cwmp->cpe_user = malloc(strlen(cpe_username) + 1);

+        sprintf(cwmp->cpe_user, "%s", cpe_username);

+

+        cfg_get_item("cpe_password", cpe_password, sizeof(cpe_password));

+        cwmp->cpe_pwd = malloc(strlen(cpe_password) + 1);

+        sprintf(cwmp->cpe_pwd, "%s", cpe_password);

+	    // cwmp->cpe_user = cwmp_conf_pool_get(pool, "cwmp:cpe_username");

+    	// 	cwmp->cpe_pwd = cwmp_conf_pool_get(pool, "cwmp:cpe_password");

+

+	}

+

+    cfg_get_item("acs_url", acs_url, sizeof(acs_url));

+    cwmp->acs_url = malloc(strlen(acs_url) + 1);

+    sprintf(cwmp->acs_url, "%s", acs_url);

+    //cwmp->acs_url   =   cwmp_conf_pool_get(pool, "cwmp:acs_url"); //  "http://192.168.0.69:8000/otnms/acs/webservice.action";//cwmp_nvram_getdup(pool, "cwmp:acs_url");

+

+    cwmp->cpe_mf    =   cwmp_conf_pool_get(pool, "cwmp:cpe_manufacture"); //     "ZTE"; //cwmp_nvram_getdup(pool, "cwmp:cpe_manufacture");

+

+    cwmp->cpe_oui   =   cwmp_conf_pool_get(pool, "cwmp:cpe_oui"); //   "00D0D0";cwmp_nvram_getdup(pool, "cwmp:cpe_oui");

+

+    cwmp->cpe_sn    =   cwmp_conf_pool_get(pool, "cwmp:cpe_sn"); //    "0410400AA11AA2255"; //cwmp_nvram_getdup(pool, "cwmp:cpe_sn");

+

+    cwmp->cpe_name  =   cwmp_conf_pool_get(pool, "cwmp:cpe_name"); //  "00D0D0"; //cwmp_nvram_getdup(pool, "cwmp:cpe_name");

+

+    cwmp->cpe_pc    =   cwmp_conf_pool_get(pool, "cwmp:cpe_pc"); //      "ZXECS EBG2100";

+

+    cwmp_log_debug("url:%s\nmf:%s\noui:%s\nsn:%s\nname:%s\npc:%s\nhttpd port:%d\n",    cwmp->acs_url, cwmp->cpe_mf, cwmp->cpe_oui, cwmp->cpe_sn, cwmp->cpe_name, cwmp->cpe_pc,

+                   cwmp->httpd_port);

+

+

+    cwmp->event_filename = cwmp_conf_pool_get(pool, "cwmp:event_filename");

+

+

+

+}

+

diff --git a/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/cwmpd.c b/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/cwmpd.c
new file mode 100755
index 0000000..85558e9
--- /dev/null
+++ b/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/cwmpd.c
@@ -0,0 +1,243 @@
+/************************************************************************

+ *                                                                      *

+ * Netcwmp/Opencwmp Project                                             *

+ * A software client for enabling TR-069 in embedded devices (CPE).     *

+ *                                                                      *

+ * Copyright (C) 2013-2014  netcwmp.netcwmp group                            *

+ *                                                                      *

+ * This program is free software; you can redistribute it and/or        *

+ * modify it under the terms of the GNU General Public License          *

+ * as published by the Free Software Foundation; either version 2       *

+ * of the License, or (at your option) any later version.               *

+ *                                                                      *

+ * This program is distributed in the hope that it will be useful,      *

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of       *

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *

+ * GNU General Public License for more details.                         *

+ *                                                                      *

+ * You should have received a copy of the GNU Lesser General Public     *

+ * License along with this library; if not, write to the                *

+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,          *

+ * Boston, MA  02111-1307 USA                                           *

+ *                                                                      *

+ * Copyright 2013-2014  Mr.x(Mr.x) <netcwmp@gmail.com>          *

+ *                                                                      *

+ ***********************************************************************/

+

+#include "cwmpd.h"

+

+#include <sys/ipc.h>

+

+#include <errno.h>

+

+

+

+

+

+#define CWMP_VALUE_UNSET -1

+

+

+

+int              cwmp_argc;

+char           **cwmp_argv;

+

+

+static pool_t * cwmp_global_pool;

+

+

+

+void cwmp_daemon()

+{

+    //daemon(0, 1);

+}

+

+

+

+

+void cwmp_getopt(int argc, char **argv)

+{

+

+}

+

+

+static int cwmp_save_argv( int argc, char *const *argv)

+{

+    cwmp_argv = (char **) argv;

+    cwmp_argc = argc;

+

+    return 0;

+}

+

+

+int cwmp_set_var(cwmp_t * cwmp)

+{

+    FUNCTION_TRACE();

+

+

+    cwmp_bzero(cwmp, sizeof(cwmp_t));

+    cwmp->new_request = CWMP_TRUE;

+    pool_t * pool = pool_create(POOL_DEFAULT_SIZE);

+	if(NULL == pool)

+	{

+	    cwmp_log_error("pool create return null, size:POOL_DEFAULT_SIZE");

+		return CWMP_ERROR;

+	}

+

+    cwmp->pool = pool;

+

+

+#if 0

+    cwmp_event_init(cwmp);

+

+    cwmp->queue = queue_create(pool);

+#endif

+

+    return CWMP_OK;

+}

+

+

+

+

+#ifdef USE_CWMP_OPENSSL

+void cwmp_init_ssl(cwmp_t * cwmp)

+{

+    char * cafile = cwmp_conf_pool_get(cwmp_global_pool, "cwmp:ca_file");

+    char * capasswd = cwmp_conf_pool_get(cwmp_global_pool, "cwmp:ca_password");   

+    cwmp->ssl_ctx = openssl_initialize_ctx(cafile, capasswd);

+}

+#endif

+

+

+static int copy_file(const char* src, const char* des)

+{

+	int rc = CWMP_OK;

+	FILE *psrc = NULL;

+	FILE *pdes = NULL;

+	psrc = fopen(src, "r");

+	pdes = fopen(des, "w+");

+

+

+	if (psrc && pdes)

+	{

+		int nLen = 0;

+		char szBuf[1024] = {0};

+		while((nLen = fread(szBuf, 1, sizeof szBuf, psrc)) > 0)

+		{

+			fwrite(szBuf, 1, nLen, pdes);

+		}

+		rc = CWMP_OK;

+	}

+	else

+	{

+		rc = CWMP_ERROR;

+	}

+

+

+	if (psrc)

+	{

+		fclose(psrc);

+		psrc = NULL;

+	}

+

+

+	if (pdes)

+	{

+		fclose(pdes);

+		pdes = NULL;

+	}

+

+

+	return rc;

+}

+

+

+cwmp_t *g_cwmp = NULL;

+

+

+#define RO_CWMP_CONF_PATH     "/etc_ro/cwmp.conf"

+#define RW_CWMP_CONF_PATH     "/cache/cwmp.conf"

+

+int main(int argc, char **argv)

+{

+    cwmp_pid_t pid;

+    cwmp_t * cwmp;

+

+	char cwmp_enable_value[4] = {0};

+    int syslog_enable = 0;

+    int cwmp_enable = 0;

+

+#ifdef WIN32

+    WSADATA wsaData;

+    WSAStartup(MAKEWORD(2, 2), &wsaData);

+#endif

+    pid = getpid();

+

+//    cwmp_log_init("/var/log/cwmpd.log", CWMP_LOG_DEBUG);

+    cwmp_log_init("/cache/cwmpd.log", CWMP_LOG_DEBUG_SQL);

+    cwmp_global_pool = pool_create(POOL_DEFAULT_SIZE);

+	if(NULL == cwmp_global_pool)

+	{

+	    cwmp_log_error("cwmp_global_pool pool create fail");

+		return -1; 

+	}

+

+

+    cwmp = pool_palloc(cwmp_global_pool, sizeof(cwmp_t));

+	if(NULL == cwmp)

+	{

+	    cwmp_log_error("cwmp pool palloc fail");

+		return -1; 

+	}

+

+

+	if(access(RW_CWMP_CONF_PATH, F_OK) != 0)

+	{

+		copy_file(RO_CWMP_CONF_PATH, RW_CWMP_CONF_PATH);

+		cwmp_log_info("%s not exist, copy %s to it", RW_CWMP_CONF_PATH, RO_CWMP_CONF_PATH);

+	}

+

+

+    cwmp_conf_open(RW_CWMP_CONF_PATH);

+

+	cfg_get_item("cwmp_enable", cwmp_enable_value, sizeof(cwmp_enable_value));

+	cwmp_enable = atoi(cwmp_enable_value);

+    //cwmp_enable=cwmp_conf_get_int("cwmp:enable");

+    if(!cwmp_enable)

+    {

+        cwmp_log_error("cwmp_enable:%d", cwmp_enable);

+		return -1;    

+    }

+

+    cwmp_getopt(argc, argv);

+

+    //cwmp_init_db(); 

+

+    cwmp_set_var(cwmp);

+    cwmp_daemon();

+

+    cwmp_conf_init(cwmp);

+

+

+    cwmp_event_init(cwmp);

+    cwmp->queue = queue_create(cwmp->pool);

+

+    g_cwmp = cwmp;

+

+	ini_periodic_info(cwmp);

+

+

+    init_pdp_type(cwmp);

+

+

+#ifdef USE_CWMP_OPENSSL

+    cwmp_init_ssl(cwmp);

+#endif

+

+    cwmp_model_load(cwmp, "/etc_ro/device.xml");

+    cwmp_process_start_master(cwmp);

+

+    return 0;

+}

+

+

+

diff --git a/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/modules/InternetGatewayDevice/DeviceInfo/DeviceInfo.c b/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/modules/InternetGatewayDevice/DeviceInfo/DeviceInfo.c
new file mode 100755
index 0000000..928fd1e
--- /dev/null
+++ b/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/modules/InternetGatewayDevice/DeviceInfo/DeviceInfo.c
@@ -0,0 +1,159 @@
+#include "cfg_api.h"

+

+

+

+//InternetGatewayDevice.DeviceInfo.Manufacturer

+int cpe_get_igd_di_manufacturer(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+    FUNCTION_TRACE();

+    *value = cwmp_conf_pool_get(pool, "cwmp:cpe_manufacture");

+    cwmp_log_debug("cpe_get_igd_di_manufacturer: value is %s", *value);

+    return	FAULT_CODE_OK;

+}

+

+//InternetGatewayDevice.DeviceInfo.ManufacturerOUI

+int cpe_get_igd_di_manufactureroui(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+    FUNCTION_TRACE();

+    *value = cwmp_conf_pool_get(pool, "cwmp:cpe_oui");

+    return	FAULT_CODE_OK;

+}

+

+//InternetGatewayDevice.DeviceInfo.ProductClass

+int cpe_get_igd_di_productclass(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+    FUNCTION_TRACE();

+    *value = cwmp_conf_pool_get(pool, "cwmp:cpe_pc");

+    return	FAULT_CODE_OK;

+}

+

+//InternetGatewayDevice.DeviceInfo.SerialNumber

+int cpe_get_igd_di_serialnumber(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+	FUNCTION_TRACE();

+	char sn[256+1] = {0};

+

+	cfg_get_item("serialnumber", sn, 256);

+

+    *value = pool_pstrdup(pool, sn);

+    return	FAULT_CODE_OK;

+}

+

+//InternetGatewayDevice.DeviceInfo.SpecVersion

+int cpe_get_igd_di_specversion(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+	FUNCTION_TRACE();

+    *value = cwmp_conf_pool_get(pool, "cwmp:cpe_specver");

+    return	FAULT_CODE_OK;

+}

+

+//InternetGatewayDevice.DeviceInfo.HardwareVersion

+int cpe_get_igd_di_hardwareversion(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+	FUNCTION_TRACE();

+    char hw[256+1] = {0};

+

+	cfg_get_item("hardware_version", hw, 256);

+

+	*value = pool_pstrdup(pool, hw);

+    return	FAULT_CODE_OK;

+}

+

+//InternetGatewayDevice.DeviceInfo.SoftwareVersion

+int cpe_get_igd_di_softwareversion(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+	FUNCTION_TRACE();

+    char sw[256+1] = {0};

+

+	cfg_get_item("wa_version", sw, 256);

+

+	*value = pool_pstrdup(pool, sw);

+

+    return	FAULT_CODE_OK;

+}

+

+//InternetGatewayDevice.DeviceInfo.ProvisioningCode

+int cpe_get_igd_di_provisioningcode(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+	FUNCTION_TRACE();

+    *value = cwmp_conf_pool_get(pool, "cwmp:cpe_pc");

+    return	FAULT_CODE_OK;

+}

+

+

+int cpe_set_igd_di_softwareversion(cwmp_t * cwmp, const char * name, const char * value, int length, callback_register_func_t callback_reg)

+{

+    cwmp_log_info("set softwareversion:%s", value);

+	cfg_set("wa_version", value);

+    return FAULT_CODE_OK;

+}

+

+

+

+int cpe_set_igd_di_hardwareversion(cwmp_t * cwmp, const char * name, const char * value, int length, callback_register_func_t callback_reg)

+{

+    cwmp_log_info("set hardwareversion:%s", value);

+	cfg_set("hardware_version", value);

+    return FAULT_CODE_OK;

+}

+

+

+

+//InternetGatewayDevice.DeviceInfo.VendorConfigFile.Name

+int cpe_get_igd_di_vc_name(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+	FUNCTION_TRACE();

+    *value = pool_pstrdup(pool, "cwmp.conf");

+    return	FAULT_CODE_OK;

+}

+

+//InternetGatewayDevice.DeviceInfo.VendorConfigFile.Version

+int cpe_get_igd_di_vc_version(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+	FUNCTION_TRACE();

+    *value = pool_pstrdup(pool, "V0.0.1");

+    return	FAULT_CODE_OK;

+}

+

+//InternetGatewayDevice.DeviceInfo.VendorConfigFile.Date

+int cpe_get_igd_di_vc_date(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+	FUNCTION_TRACE();

+	

+	struct stat info; 

+	char buff[64] = {0}; 

+	struct tm * timeinfo;

+	const char* unknown_date = "00 00 00:00";

+

+	if(stat("/cache/cwmp.conf", &info)<0)

+	{

+	    *value = pool_pstrdup(pool, (void *)unknown_date);

+	}

+	else

+	{

+    	timeinfo = localtime (&(info.st_mtime)); 

+    	if(NULL == timeinfo)

+    	{

+            *value = pool_pstrdup(pool, (void *)unknown_date);

+    	}

+    	else

+    	{

+    	    strftime(buff, sizeof(buff), "%b %d %H:%M", timeinfo); 

+            *value = pool_pstrdup(pool, buff);

+    	}

+	}

+	

+    return	FAULT_CODE_OK;

+}

+

+//InternetGatewayDevice.DeviceInfo.VendorConfigFile.Description

+int cpe_get_igd_di_vc_description(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+	FUNCTION_TRACE();

+    *value = pool_pstrdup(pool, "config file path: /cache/cwmp.conf");

+    return	FAULT_CODE_OK;

+}

+

+

+

+

diff --git a/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/modules/InternetGatewayDevice/LANDevice/LANDevice.c b/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/modules/InternetGatewayDevice/LANDevice/LANDevice.c
new file mode 100755
index 0000000..c20f3ef
--- /dev/null
+++ b/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/modules/InternetGatewayDevice/LANDevice/LANDevice.c
@@ -0,0 +1,115 @@
+

+int  cpe_refresh_igd_landevice(cwmp_t * cwmp, parameter_node_t * param_node, callback_register_func_t callback_reg)

+{

+    FUNCTION_TRACE();

+

+    if(!param_node)

+    {

+        return FAULT_CODE_9002;

+    }

+    parameter_node_t * tmp_param, *tmp_node, *child_param;

+    child_param = param_node->child;

+    if(child_param)

+    {

+        for(tmp_param=child_param->next_sibling; tmp_param; )

+        {

+            cwmp_log_info("refresh LANDevice node, delete param %s\n", tmp_param->name);

+            tmp_node = tmp_param->next_sibling;

+            cwmp_model_delete_parameter(tmp_param);

+            tmp_param = tmp_node;

+        }

+        child_param->next_sibling = NULL;

+                

+        parameter_node_t * lan1_param;

+        cwmp_model_copy_parameter(param_node, &lan1_param, 1);

+        

+//        parameter_node_t * lan2_param;

+//        cwmp_model_copy_parameter(param_node, &lan2_param, 2);

+       

+        cwmp_model_refresh_object(cwmp, param_node, 0, callback_reg); 

+    }

+    

+    return FAULT_CODE_OK;

+}

+

+int cpe_get_igd_ld_dhcpserverenable(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+	FUNCTION_TRACE();

+    char sw[256+1] = {0};

+

+	cfg_get_item("dhcpEnabled", sw, 256);

+

+	*value = pool_pstrdup(pool, sw);

+

+    return	FAULT_CODE_OK;

+}

+

+int cpe_get_igd_ld_minaddress(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+	FUNCTION_TRACE();

+    char sw[256+1] = {0};

+

+	cfg_get_item("dhcpStart", sw, 256);

+

+	*value = pool_pstrdup(pool, sw);

+

+    return	FAULT_CODE_OK;

+}

+

+int cpe_get_igd_ld_maxaddress(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+	FUNCTION_TRACE();

+    char sw[256+1] = {0};

+

+	cfg_get_item("dhcpEnd", sw, 256);

+

+	*value = pool_pstrdup(pool, sw);

+

+    return	FAULT_CODE_OK;

+}

+

+int cpe_get_igd_ld_subnetmask(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+	FUNCTION_TRACE();

+    char sw[256+1] = {0};

+

+	cfg_get_item("lan_netmask", sw, 256);

+

+	*value = pool_pstrdup(pool, sw);

+

+    return	FAULT_CODE_OK;

+}

+

+int cpe_get_igd_ld_iprouters(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+	FUNCTION_TRACE();

+    char sw[256+1] = {0};

+

+	cfg_get_item("lan_ipaddr", sw, 256);

+

+	*value = pool_pstrdup(pool, sw);

+

+    return	FAULT_CODE_OK;

+}

+

+int cpe_get_igd_ld_dhcpleasetime(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+	FUNCTION_TRACE();

+    char sw[256+1] = {0};

+

+	cfg_get_item("dhcpLease_hour", sw, 256);

+

+	*value = pool_pstrdup(pool, sw);

+

+    return	FAULT_CODE_OK;

+}

+

+

+

+

+

+

+

+

+

+

diff --git a/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/modules/InternetGatewayDevice/ManagementServer/ManagementServer.c b/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/modules/InternetGatewayDevice/ManagementServer/ManagementServer.c
new file mode 100755
index 0000000..42b669f
--- /dev/null
+++ b/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/modules/InternetGatewayDevice/ManagementServer/ManagementServer.c
@@ -0,0 +1,394 @@
+

+#include "cfg_api.h"

+

+

+int cpe_get_localip(const char * eth_name, char *hostip)

+{

+

+    cfg_get_item(eth_name, hostip, 256);

+

+    return CWMP_OK;

+

+

+#if 0

+    register int fd,intrface,retn=0;

+    struct ifreq buf[32];

+    struct ifconf ifc;

+    char domain_host[100] = {0};

+    char local_ip_addr[20] = {0};

+    char local_mac[20] = {0};

+    //Get Domain Name --------------------------------------------------

+    strcpy(local_ip_addr, "127.0.0.1");

+    if (!hostip)

+        return -1;

+    if (getdomainname(&domain_host[0], 100) != 0)

+    {

+        return -1;

+    }

+    //------------------------------------------------------------------

+    //Get IP Address & Mac Address ----------------------------------------

+    if ((fd=socket(AF_INET,SOCK_DGRAM,0))>=0)

+    {

+        ifc.ifc_len=sizeof buf;

+        ifc.ifc_buf=(caddr_t)buf;

+        if (!ioctl(fd,SIOCGIFCONF,(char*)&ifc))

+        {

+            intrface=ifc.ifc_len/sizeof(struct ifreq);

+            while (intrface-->0)

+            {

+                if (!(ioctl(fd,SIOCGIFFLAGS,(char*)&buf[intrface])))

+                {

+                    if (buf[intrface].ifr_flags&IFF_PROMISC)

+                    {

+                        retn++;

+                    }

+                }

+                //Get IP Address

+                if (!(ioctl(fd,SIOCGIFADDR,(char*)&buf[intrface])))

+                {

+		    if(strcmp(eth_name, buf[intrface].ifr_name) == 0)

+		    {

+                    sprintf(local_ip_addr, "%s", inet_ntoa(((struct sockaddr_in*)(&buf[intrface].ifr_addr))->sin_addr));

+

+		    break;

+		    }

+                }

+                //Get Hardware Address

+

+            }//While

+        }

+    }

+    if ( fd > 0 )

+    {

+        close(fd);

+    }

+

+    strcpy(hostip, local_ip_addr);

+

+    return CWMP_OK;

+#endif

+

+}

+

+//InternetGatewayDevice.ManagementServer.Username

+int cpe_get_igd_ms_username(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{   

+    FUNCTION_TRACE();

+    char acs_username[256+1] = {0};

+	cfg_get_item("acs_username", acs_username, 256);

+    *value = pool_pstrdup(pool, acs_username);

+

+    return FAULT_CODE_OK;

+}

+

+//InternetGatewayDevice.ManagementServer.Username

+int cpe_set_igd_ms_username(cwmp_t * cwmp, const char * name, const char * value, int length, callback_register_func_t callback_reg)

+{

+    FUNCTION_TRACE();

+	cwmp_log_info("set acs_username:%s", value);

+	cfg_set("acs_username", value);

+    return FAULT_CODE_OK;

+}

+

+//InternetGatewayDevice.ManagementServer.Password

+int cpe_get_igd_ms_password(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+    FUNCTION_TRACE();       

+    char acs_password[256+1] = {0};

+	cfg_get_item("acs_password", acs_password, 256);

+    *value = pool_pstrdup(pool, acs_password);

+

+	return FAULT_CODE_OK;

+}

+

+int cpe_set_igd_ms_password(cwmp_t * cwmp, const char * name, const char * value, int length, callback_register_func_t callback_reg)

+{

+    FUNCTION_TRACE();

+	cwmp_log_info("set acs_password:%s", value);

+	cfg_set("acs_password", value);

+

+    return FAULT_CODE_OK;

+}

+

+//InternetGatewayDevice.ManagementServer.URL

+int cpe_get_igd_ms_url(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{    

+    FUNCTION_TRACE();

+    char acs_url[256+1] = {0};

+	cfg_get_item("acs_url", acs_url, 256);

+    *value = pool_pstrdup(pool, acs_url);

+

+    return FAULT_CODE_OK;

+}

+

+//InternetGatewayDevice.ManagementServer.URL

+int cpe_set_igd_ms_url(cwmp_t * cwmp, const char * name, const char * value, int length, callback_register_func_t callback_reg)

+{

+    FUNCTION_TRACE();

+    cwmp_log_info("set acs_url:%s", value);

+	cfg_set("acs_url", value);	

+    return FAULT_CODE_OK;

+}

+

+

+int cpe_get_igd_ms_PeriodicInformEnable(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{    

+    FUNCTION_TRACE();

+	*value = cwmp_conf_pool_get(pool, "periodic:enable");

+    return FAULT_CODE_OK;

+}

+

+

+

+int cpe_set_igd_ms_PeriodicInformEnable(cwmp_t * cwmp, const char * name, const char * value, int length, callback_register_func_t callback_reg)

+{

+    FUNCTION_TRACE();

+    cwmp_log_info("set PeriodicInformEnable:%s", value);

+	cwmp_conf_set("periodic:enable", value);

+	update_periodic_info_enable(cwmp);

+    return FAULT_CODE_OK;

+}

+

+

+

+

+int cpe_set_igd_ms_PeriodicInformInterval(cwmp_t * cwmp, const char * name, const char * value, int length, callback_register_func_t callback_reg)

+{

+    FUNCTION_TRACE();

+    cwmp_log_info("set PeriodicInformInterval:%s", value);

+	cwmp_conf_set("periodic:interval", value);

+

+	update_periodic_info_interval(cwmp);

+

+    return FAULT_CODE_OK;

+}

+

+

+

+int cpe_get_igd_ms_PeriodicInformInterval(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{    

+    FUNCTION_TRACE();

+	*value = cwmp_conf_pool_get(pool, "periodic:interval");

+    return FAULT_CODE_OK;

+}

+

+//InternetGatewayDevice.ManagementServer.ConnectionRequestURL

+int cpe_get_igd_ms_connectionrequesturl(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+    char buf[512]={0};

+    char local_ip[256]={0};

+    FUNCTION_TRACE();

+

+    int port = cwmp_conf_get_int("cwmpd:httpd_port");

+    int family  = get_family_type();

+

+    if(family == AF_INET)

+    {

+        cpe_get_localip("wan1_ip", local_ip);

+        snprintf(buf, sizeof(buf), "http://%s:%d", local_ip, port);

+    }

+    else if(family == AF_INET6)

+    {

+        cpe_get_localip("ipv6_br0_addr", local_ip);

+        snprintf(buf, sizeof(buf), "http://[%s]:%d", local_ip, port);

+    }

+    else

+    {

+        cpe_get_localip("wan1_ip", local_ip);

+        snprintf(buf, sizeof(buf), "http://%s:%d", local_ip, port);

+        cwmp_log_error("unknown family type:%d", family);

+    }

+

+    cwmp_log_debug("connectionrequesturl:%s", buf);

+

+    *value = PSTRDUP(buf);

+    return FAULT_CODE_OK;

+}

+

+//InternetGatewayDevice.ManagementServer.ConnectionRequestUsername

+int cpe_get_igd_ms_connectionrequestusername(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+    FUNCTION_TRACE();

+    char cpe_username[256+1] = {0};

+	cfg_get_item("cpe_username", cpe_username, 256);

+    *value = pool_pstrdup(pool, cpe_username);

+

+    return FAULT_CODE_OK;

+}

+int cpe_set_igd_ms_connectionrequestusername(cwmp_t * cwmp, const char * name, const char * value, int length, callback_register_func_t callback_reg)

+{

+    FUNCTION_TRACE();

+	cwmp_log_info("set cpe_username:%s", value);

+	cfg_set("cpe_username", value);

+

+    return FAULT_CODE_OK;

+}

+

+

+//InternetGatewayDevice.ManagementServer.ConnectionRequestPassword

+int cpe_get_igd_ms_connectionrequestpassword(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{    

+    char cpe_password[256+1] = {0};

+	cfg_get_item("cpe_password", cpe_password, 256);

+    *value = pool_pstrdup(pool, cpe_password);

+

+    return FAULT_CODE_OK;

+}

+int cpe_set_igd_ms_connectionrequestpassword(cwmp_t * cwmp, const char * name, const char * value, int length, callback_register_func_t callback_reg)

+{

+    cwmp_log_info("set cpe_password:%s", value);

+	cfg_set("cpe_password", value);	

+

+    return FAULT_CODE_OK;

+}

+

+

+

+int cpe_get_igd_ms_STUNEnable(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{    

+    FUNCTION_TRACE();

+	*value = cwmp_conf_pool_get(pool, "test:stun_enable");

+

+    return FAULT_CODE_OK;

+}

+

+

+int cpe_set_igd_ms_STUNEnable(cwmp_t * cwmp, const char * name, const char * value, int length, callback_register_func_t callback_reg)

+{

+    FUNCTION_TRACE();

+    cwmp_conf_set("test:stun_enable", value);

+    return FAULT_CODE_OK;

+}

+

+

+int cpe_get_igd_ms_parameterkey(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{    

+    FUNCTION_TRACE();

+	*value = cwmp_conf_pool_get(pool, "test:parameterkey");

+

+    return FAULT_CODE_OK;

+}

+

+

+int cpe_set_igd_ms_parameterkey(cwmp_t * cwmp, const char * name, const char * value, int length, callback_register_func_t callback_reg)

+{

+    FUNCTION_TRACE();

+    cwmp_conf_set("test:parameterkey", value);

+    return FAULT_CODE_OK;

+}

+

+

+int cpe_get_igd_ms_stunserveraddress(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{    

+    FUNCTION_TRACE();

+	*value = cwmp_conf_pool_get(pool, "test:stun_serveraddress");

+

+    return FAULT_CODE_OK;

+}

+

+

+int cpe_set_igd_ms_stunserveraddress(cwmp_t * cwmp, const char * name, const char * value, int length, callback_register_func_t callback_reg)

+{

+    FUNCTION_TRACE();

+    cwmp_conf_set("test:stun_serveraddress", value);

+    return FAULT_CODE_OK;

+}

+

+int cpe_get_igd_ms_stunserverport(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{    

+    FUNCTION_TRACE();

+	*value = cwmp_conf_pool_get(pool, "test:stun_serverport");

+

+    return FAULT_CODE_OK;

+}

+

+

+int cpe_set_igd_ms_stunserverport(cwmp_t * cwmp, const char * name, const char * value, int length, callback_register_func_t callback_reg)

+{

+    FUNCTION_TRACE();

+    cwmp_conf_set("test:stun_serverport", value);

+    return FAULT_CODE_OK;

+}

+

+int cpe_get_igd_ms_stunusername(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{    

+    FUNCTION_TRACE();

+	*value = cwmp_conf_pool_get(pool, "test:stun_username");

+

+    return FAULT_CODE_OK;

+}

+

+

+int cpe_set_igd_ms_stunusername(cwmp_t * cwmp, const char * name, const char * value, int length, callback_register_func_t callback_reg)

+{

+    FUNCTION_TRACE();

+    cwmp_conf_set("test:stun_username", value);

+    return FAULT_CODE_OK;

+}

+

+int cpe_get_igd_ms_stunpassword(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{    

+    FUNCTION_TRACE();

+	*value = cwmp_conf_pool_get(pool, "test:stun_password");

+

+    return FAULT_CODE_OK;

+}

+

+

+int cpe_set_igd_ms_stunpassword(cwmp_t * cwmp, const char * name, const char * value, int length, callback_register_func_t callback_reg)

+{

+    FUNCTION_TRACE();

+    cwmp_conf_set("test:stun_password", value);

+    return FAULT_CODE_OK;

+}

+

+int cpe_get_igd_ms_stunmaximumkeepaliveperiod(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{    

+    FUNCTION_TRACE();

+	*value = cwmp_conf_pool_get(pool, "test:stun_maximumkeepaliveperiod");

+

+    return FAULT_CODE_OK;

+}

+

+

+int cpe_set_igd_ms_stunmaximumkeepaliveperiod(cwmp_t * cwmp, const char * name, const char * value, int length, callback_register_func_t callback_reg)

+{

+    FUNCTION_TRACE();

+    cwmp_conf_set("test:stun_maximumkeepaliveperiod", value);

+    return FAULT_CODE_OK;

+}

+

+

+int cpe_get_igd_ms_stunminimumkeepaliveperiod(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{    

+    FUNCTION_TRACE();

+	*value = cwmp_conf_pool_get(pool, "test:stun_minimumkeepaliveperiod");

+

+    return FAULT_CODE_OK;

+}

+

+

+int cpe_set_igd_ms_stunminimumkeepaliveperiod(cwmp_t * cwmp, const char * name, const char * value, int length, callback_register_func_t callback_reg)

+{

+    FUNCTION_TRACE();

+    cwmp_conf_set("test:stun_minimumkeepaliveperiod", value);

+    return FAULT_CODE_OK;

+}

+

+int cpe_get_igd_ms_natdetected(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{    

+    FUNCTION_TRACE();

+	*value = cwmp_conf_pool_get(pool, "test:natdetected");

+

+    return FAULT_CODE_OK;

+}

+

+

+int cpe_set_igd_ms_natdetected(cwmp_t * cwmp, const char * name, const char * value, int length, callback_register_func_t callback_reg)

+{

+    FUNCTION_TRACE();

+    cwmp_conf_set("test:natdetected", value);

+    return FAULT_CODE_OK;

+}

+

+

diff --git a/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/modules/InternetGatewayDevice/Time/Time.c b/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/modules/InternetGatewayDevice/Time/Time.c
new file mode 100755
index 0000000..8ac2ff4
--- /dev/null
+++ b/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/modules/InternetGatewayDevice/Time/Time.c
@@ -0,0 +1,146 @@
+#include "cfg_api.h"

+#include <time.h>

+

+//InternetGatewayDevice.Time

+

+int cpe_get_igd_time_ntpserver0(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+	FUNCTION_TRACE();

+    char tmp[64+1] = {0};

+

+	cfg_get_item("sntp_server0", tmp, sizeof(tmp)-1);

+

+	*value = pool_pstrdup(pool, tmp);

+

+    return	FAULT_CODE_OK;

+

+}

+

+

+int cpe_set_igd_time_ntpserver0(cwmp_t * cwmp, const char * name, const char * value, int length, callback_register_func_t callback_reg)

+{

+    FUNCTION_TRACE();

+	cfg_set("sntp_server0", value);

+	cfg_save();

+    return FAULT_CODE_OK;

+}

+

+

+int cpe_get_igd_time_ntpserver1(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+	FUNCTION_TRACE();

+    char tmp[64+1] = {0};

+

+	cfg_get_item("sntp_server1", tmp, sizeof(tmp)-1);

+

+	*value = pool_pstrdup(pool, tmp);

+

+    return	FAULT_CODE_OK;

+

+}

+

+int cpe_set_igd_time_ntpserver1(cwmp_t * cwmp, const char * name, const char * value, int length, callback_register_func_t callback_reg)

+{

+    FUNCTION_TRACE();

+	cfg_set("sntp_server1", value);

+	cfg_save();

+    return FAULT_CODE_OK;

+}

+

+

+int cpe_get_igd_time_ntpserver2(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+	FUNCTION_TRACE();

+    char tmp[64+1] = {0};

+

+	cfg_get_item("sntp_server2", tmp, sizeof(tmp)-1);

+

+	*value = pool_pstrdup(pool, tmp);

+

+    return	FAULT_CODE_OK;

+

+}

+

+

+

+int cpe_set_igd_time_ntpserver2(cwmp_t * cwmp, const char * name, const char * value, int length, callback_register_func_t callback_reg)

+{

+    FUNCTION_TRACE();

+	cfg_set("sntp_server2", value);

+	cfg_save();

+    return FAULT_CODE_OK;

+}

+

+

+

+int cpe_get_igd_time_currentlocaltime(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+	FUNCTION_TRACE();

+	char tmp[64+1] = {0};

+

+    struct tm *ptm;

+    time_t tn;

+

+    tn = time(NULL);

+#ifdef WIN32

+    cwmp_log_debug("inform datatime");

+    memset(t, 0, sizeof(struct tm));

+#else

+    ptm = localtime(&tn);

+    if(NULL == ptm)

+    {

+        cwmp_log_error("localtime return NULL");

+		*value = pool_pstrdup(pool, "1900-00-00T00:00:00");

+		return	FAULT_CODE_OK;

+    }

+#endif

+

+    TRsnprintf(tmp, sizeof(tmp)-1, "%4d-%02d-%02dT%02d:%02d:%02d",

+               ptm->tm_year + 1900,

+               ptm->tm_mon + 1,

+               ptm->tm_mday,

+               ptm->tm_hour,

+               ptm->tm_min,

+               ptm->tm_sec);	

+

+

+	*value = pool_pstrdup(pool, tmp);

+

+    return	FAULT_CODE_OK;

+}

+

+

+

+int cpe_get_igd_time_localtimezone(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+	FUNCTION_TRACE();

+    char tmp[64+1] = {0};

+

+	cfg_get_item("sntp_timezone_index", tmp, sizeof(tmp)-1);

+

+	*value = pool_pstrdup(pool, tmp);

+

+    return	FAULT_CODE_OK;

+

+}

+

+

+

+int cpe_get_igd_time_localtimezonename(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)

+{

+	FUNCTION_TRACE();

+    char tmp[64+1] = {0};

+

+	cfg_get_item("sntp_timezone", tmp, sizeof(tmp)-1);

+

+	*value = pool_pstrdup(pool, tmp);

+

+    return	FAULT_CODE_OK;

+

+}

+

+

+

+

+

+

diff --git a/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/modules/data_model.c b/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/modules/data_model.c
new file mode 100755
index 0000000..3e47089
--- /dev/null
+++ b/lynq/S300/ap/app/cwmp/netcwmp/cwmpd/src/modules/data_model.c
@@ -0,0 +1,157 @@
+#include "cwmp/model.h"

+#include "data_model.h"

+#include "cwmp_module.h"

+#include "InternetGatewayDevice/InternetGatewayDevice.c"

+

+

+model_func_t ModelFunction[] =

+{

+    //InternetGatewayDevice.DeviceInfo.

+    {"get_igd_di_manufacturer", cpe_get_igd_di_manufacturer},

+    {"get_igd_di_manufactureroui", cpe_get_igd_di_manufactureroui},

+    {"get_igd_di_productclass", cpe_get_igd_di_productclass},

+    {"get_igd_di_serialnumber", cpe_get_igd_di_serialnumber},

+    {"get_igd_di_specversion", cpe_get_igd_di_specversion},

+    {"get_igd_di_hardwareversion", cpe_get_igd_di_hardwareversion},

+    {"get_igd_di_softwareversion", cpe_get_igd_di_softwareversion},

+    {"get_igd_di_provisioningcode", cpe_get_igd_di_provisioningcode},

+    {"set_igd_di_softwareversion", cpe_set_igd_di_softwareversion},

+    {"set_igd_di_hardwareversion", cpe_set_igd_di_hardwareversion},	

+

+    //InternetGatewayDevice.DeviceInfo.VendorConfigFile.	

+    {"get_igd_di_vc_name", cpe_get_igd_di_vc_name},

+    {"get_igd_di_vc_version", cpe_get_igd_di_vc_version},

+    {"get_igd_di_vc_date", cpe_get_igd_di_vc_date},

+    {"get_igd_di_vc_description", cpe_get_igd_di_vc_description},    

+

+    //InternetGatewayDevice.ManagementServer.

+    {"get_igd_ms_username", cpe_get_igd_ms_username},

+    {"set_igd_ms_username", cpe_set_igd_ms_username},    

+    {"get_igd_ms_password", cpe_get_igd_ms_password},

+    {"set_igd_ms_password", cpe_set_igd_ms_password},   

+    {"get_igd_ms_url", cpe_get_igd_ms_url},

+    {"set_igd_ms_url", cpe_set_igd_ms_url},    

+    {"get_igd_ms_connectionrequesturl", cpe_get_igd_ms_connectionrequesturl},

+    {"get_igd_ms_connectionrequestusername", cpe_get_igd_ms_connectionrequestusername},

+    {"set_igd_ms_connectionrequestusername", cpe_set_igd_ms_connectionrequestusername},    

+    {"get_igd_ms_connectionrequestpassword", cpe_get_igd_ms_connectionrequestpassword},

+    {"set_igd_ms_connectionrequestpassword", cpe_set_igd_ms_connectionrequestpassword},

+    {"get_igd_ms_STUNEnable", cpe_get_igd_ms_STUNEnable},

+    {"set_igd_ms_STUNEnable", cpe_set_igd_ms_STUNEnable},

+    {"get_igd_ms_parameterkey", cpe_get_igd_ms_parameterkey},

+    {"set_igd_ms_parameterkey", cpe_set_igd_ms_parameterkey},  

+    {"get_igd_ms_stunserveraddress", cpe_get_igd_ms_stunserveraddress},

+    {"set_igd_ms_stunserveraddress", cpe_set_igd_ms_stunserveraddress},

+    {"get_igd_ms_stunserverport", cpe_get_igd_ms_stunserverport},

+    {"set_igd_ms_stunserverport", cpe_set_igd_ms_stunserverport},

+    {"get_igd_ms_stunusername", cpe_get_igd_ms_stunusername},

+    {"set_igd_ms_stunusername", cpe_set_igd_ms_stunusername},

+    {"get_igd_ms_stunpassword", cpe_get_igd_ms_stunpassword},

+    {"set_igd_ms_stunpassword", cpe_set_igd_ms_stunpassword},

+	{"get_igd_ms_stunmaximumkeepaliveperiod", cpe_get_igd_ms_stunmaximumkeepaliveperiod},

+	{"set_igd_ms_stunmaximumkeepaliveperiod", cpe_set_igd_ms_stunmaximumkeepaliveperiod},

+	{"get_igd_ms_stunminimumkeepaliveperiod", cpe_get_igd_ms_stunminimumkeepaliveperiod},

+	{"set_igd_ms_stunminimumkeepaliveperiod", cpe_set_igd_ms_stunminimumkeepaliveperiod},

+	{"get_igd_ms_natdetected", cpe_get_igd_ms_natdetected},

+	{"set_igd_ms_natdetected", cpe_set_igd_ms_natdetected},

+    {"get_igd_ms_PeriodicInformEnable", cpe_get_igd_ms_PeriodicInformEnable},

+    {"set_igd_ms_PeriodicInformEnable", cpe_set_igd_ms_PeriodicInformEnable},

+    {"get_igd_ms_PeriodicInformInterval", cpe_get_igd_ms_PeriodicInformInterval},

+    {"set_igd_ms_PeriodicInformInterval", cpe_set_igd_ms_PeriodicInformInterval},	    

+

+    {"add_igd_wanpppconnection", cpe_add_igd_wanpppconnection},

+    

+    {"del_igd_wanconnectiondevice", cpe_del_igd_wanconnectiondevice},

+

+	{"refresh_igd_landevice", cpe_refresh_igd_landevice},

+

+	//InternetGatewayDevice.Time

+	{"get_igd_time_ntpserver0", cpe_get_igd_time_ntpserver0},

+    {"get_igd_time_ntpserver1", cpe_get_igd_time_ntpserver1},

+    {"get_igd_time_ntpserver2", cpe_get_igd_time_ntpserver2},

+    {"set_igd_time_ntpserver0", cpe_set_igd_time_ntpserver0},

+    {"set_igd_time_ntpserver1", cpe_set_igd_time_ntpserver1},

+    {"set_igd_time_ntpserver2", cpe_set_igd_time_ntpserver2},    

+    {"get_igd_time_currentlocaltime", cpe_get_igd_time_currentlocaltime},

+    {"get_igd_time_localtimezone", cpe_get_igd_time_localtimezone},

+    {"get_igd_time_localtimezonename", cpe_get_igd_time_localtimezonename},

+

+	//InternetGatewayDevice.WANDevice

+	{"refresh_igd_wandevice", cpe_refresh_igd_wandevice},

+

+	//InternetGatewayDevice.WANDevice.WANConnectionDevice

+    {"refresh_igd_wd_wanconnectiondevice", cpe_refresh_igd_wd_wanconnectiondevice},

+

+	//InternetGatewayDevice.WANDevice.WANConnectionDevice.WANIPConnection

+    {"refresh_igd_wd_wcd_wanipconnection", cpe_refresh_igd_wd_wcd_wanipconnection},

+	{"get_igd_wd_wcd_wic_enable", cpe_get_igd_wd_wcd_wic_enable},

+    {"get_igd_wd_wcd_wic_rsrp", cpe_get_igd_wd_wcd_wic_rsrp},

+	{"get_igd_wd_wcd_wic_rssi", cpe_get_igd_wd_wcd_wic_rssi},

+

+    //InternetGatewayDevice.WANDevice.COM_WANInterfaceConfig

+    {"refresh_igd_wd_comwaninterfaceconfig", cpe_refresh_igd_wd_comwaninterfaceconfig},

+

+	//InternetGatewayDevice.WANDevice.WANEthernetInterfaceConfig

+    {"refresh_igd_wd_wanetherinterfaceconfig", cpe_refresh_igd_wd_wanetherinterfaceconfig},

+

+    //InternetGatewayDevice.LANDevice

+    {"refresh_igd_landevice", cpe_refresh_igd_landevice},

+

+    {"get_igd_ld_dhcpserverenable", cpe_get_igd_ld_dhcpserverenable},

+    {"get_igd_ld_minaddress", cpe_get_igd_ld_minaddress},

+    {"get_igd_ld_maxaddress", cpe_get_igd_ld_maxaddress},

+    {"get_igd_ld_subnetmask", cpe_get_igd_ld_subnetmask},

+    {"get_igd_ld_iprouters", cpe_get_igd_ld_iprouters},

+    {"get_igd_ld_dhcpleasetime", cpe_get_igd_ld_dhcpleasetime},

+

+	//InternetGatewayDevice.LANDevice.LANHostConfigManagement.IPInterface

+    {"refresh_igd_ld_lhcm_ipinterface", cpe_refresh_igd_ld_lhcm_ipinterface},

+

+	{"get_igd_ld_lhcm_ipinterfaceipaddress", cpe_get_igd_ld_lhcm_ipinterfaceipaddress},

+    {"set_igd_ld_lhcm_ipinterfaceipaddress", cpe_set_igd_ld_lhcm_ipinterfaceipaddress},

+    {"get_igd_ld_lhcm_ipinterfacesubnetMask", cpe_get_igd_ld_lhcm_ipinterfacesubnetMask},

+    {"set_igd_ld_lhcm_ipinterfacesubnetMask", cpe_set_igd_ld_lhcm_ipinterfacesubnetMask},

+

+    //InternetGatewayDevice.LANDevice.LANHostConfigManagement.DHCPStaticAddress

+    {"refresh_igd_ld_lhcm_dhcpstaticaddress", cpe_refresh_igd_ld_lhcm_dhcpstaticaddress},

+    

+    //InternetGatewayDevice.LANDevice.LANEthernetInterfaceConfig

+    {"refresh_igd_ld_lanethernetinterfaceconfig", cpe_refresh_igd_ld_lanethernetinterfaceconfig},

+

+	//InternetGatewayDevice.LANDevice.WLANConfiguration

+    {"refresh_igd_ld_wlanconfiguration", cpe_refresh_igd_ld_wlanconfiguration},	

+

+	{"get_igd_ld_wc_ssid", cpe_get_igd_ld_wc_ssid},

+

+    //InternetGatewayDevice.LANDevice.WLANConfiguration.WEPKey

+    {"refresh_igd_ld_wc_wepkey", cpe_refresh_igd_ld_wc_wepkey},

+

+    //InternetGatewayDevice.LANDevice.WLANConfiguration.PreSharedKey

+    {"refresh_igd_ld_wc_presharekey", cpe_refresh_igd_ld_wc_presharekey},

+};

+

+int get_index_after_paramname(parameter_node_t * param, const char * tag_name)

+{

+    parameter_node_t * parent;

+    parameter_node_t * tmp;

+    for(parent=param->parent, tmp = param; parent; tmp = parent, parent = parent->parent)

+    {

+        if(TRstrcmp(parent->name, tag_name) == 0)

+        {

+             if(is_digit(tmp->name) == 0)

+             {

+                return TRatoi(tmp->name);   

+             }

+        }        

+    }

+    return -1;

+}

+

+

+void cwmp_model_load(cwmp_t * cwmp, const char * xmlfile)

+{  

+

+    cwmp_model_load_xml(cwmp, xmlfile, ModelFunction, sizeof(ModelFunction)/sizeof(model_func_t));

+}

+

+

diff --git a/lynq/S300/ap/app/cwmp/netcwmp/libcwmp/include/cwmp/cwmp.h b/lynq/S300/ap/app/cwmp/netcwmp/libcwmp/include/cwmp/cwmp.h
new file mode 100755
index 0000000..117edf1
--- /dev/null
+++ b/lynq/S300/ap/app/cwmp/netcwmp/libcwmp/include/cwmp/cwmp.h
@@ -0,0 +1,589 @@
+/************************************************************************

+ *                                                                      *

+ * Netcwmp Project                                                      *

+ *                                                                      *

+ * A software client for enabling TR-069 in embedded devices (CPE).     *

+ *                                                                      *

+ * Copyright (C) 2013-2014  netcwmp.netcwmp group                         *

+ *                                                                      *

+ * Copyright 2013-2014           Mr.x() <netcwmp@gmail.com>          *

+ *                                                                      *

+ ***********************************************************************/

+

+#ifndef __CWMP_H__

+#define __CWMP_H__

+

+#include <cwmp/xmlet.h>

+#include <cwmp/types.h>

+#include <cwmp/util.h>

+#include <cwmp/memory.h>

+#include <cwmp/buffer.h>

+#include <cwmp/event.h>

+#include <cwmp/queue.h>

+

+

+#define ASSERT assert

+#define XMLCAST(x)  ((XmlChar *)(x))

+

+

+

+

+

+

+#define CWMP_HEAD_MAX   64

+#define CWMP_NAME_MAX   64

+#define CWMP_PARAMVALUE_SIZE	512

+

+#define SOAP_ENV_NS  "http://schemas.xmlsoap.org/soap/envelope/"

+#define SOAP_ENC_NS "http://schemas.xmlsoap.org/soap/encoding/"

+#define SOAP_XSI_NS  "http://www.w3.org/2001/XMLSchema-instance"

+#define SOAP_XSD_NS  "http://www.w3.org/2001/XMLSchema"

+#define SOAP_CWMP_NS "urn:dslforum-org:cwmp-1-0"

+

+

+

+#define SOAP_ENV_DEFAULT		"SOAP-ENV"

+#define SOAP_ENC_DEFAULT		"SOAP-ENC"

+#define SOAP_XML_HEADER			"Header"

+#define SOAP_XML_BODY	  		"Body"

+#define SOAP_XML_ENVELOPE  		"Envelope"

+#define SOAP_XML_FAULT			"Fault"

+

+

+

+#define CWMP_XML_HEADER_ID	         		"cwmp:ID"

+#define CWMP_XML_HEADER_HOLDREQUESTS	 	    "cwmp:HoldRequests"

+#define CWMP_XML_HEADER_NOMOREREQUESTS	 	    "cwmp:NoMoreRequests"

+#define CWMP_XML_INFORM_MAXENVELOPES	    "MaxEnvelopes"

+#define CWMP_XML_GETPARAMETERNAMES_PARAMETERPATH	 	    "ParameterPath"

+#define CWMP_XML_GETPARAMETERNAMES_NEXTLEVEL	 			"NextLevel"

+#define CWMP_XML_COMMANDKEY	"CommandKey"

+

+

+

+#define SOAP_XSI_TYPE            "xsi:type"

+#define SOAP_XSI_NAME            "xsi:name"

+

+#define SOAP_XSD_STRING          "xsd:string"

+#define SOAP_XSD_UNSIGNEDINT     "xsd:unsignedInt"

+#define SOAP_XSD_ANY             "xsd:any"

+#define SOAP_XSD_DATETIME        "xsd:dateTime"

+#define SOAP_TYPE_ARRAYTYPE        "arrayType"

+

+

+

+#define CWMP_XML_MUSTUNDERSTAND "mustUnderstand"

+

+#define CWMP_RPC_INFORM		 						"cwmp:Inform"

+#define CWMP_RPC_INFORMRESPONSE		 				"cwmp:InformResponse"

+#define CWMP_RPC_GETPARAMETERNAMES  				"cwmp:GetParameterNames"

+#define CWMP_RPC_GETPARAMETERNAMESRESPONSE          "cwmp:GetParameterNamesResponse"

+#define CWMP_RPC_GETPARAMETERVALUES  				"cwmp:GetParameterValues"

+#define CWMP_RPC_GETPARAMETERVALUESRESPONSE         "cwmp:GetParameterValuesResponse"

+#define CWMP_RPC_SETPARAMETERVALUES  				"cwmp:SetParameterValues"

+#define CWMP_RPC_SETPARAMETERVALUESRESPONSE         "cwmp:SetParameterValuesResponse"

+#define CWMP_RPC_GETRPCMETHODS  					"cwmp:GetRPCMethods"

+#define CWMP_RPC_GETRPCMETHODSRESPONSE  		    "cwmp:GetRPCMethodsResponse"

+#define CWMP_RPC_DOWNLOAD	 						"cwmp:Download"

+#define CWMP_RPC_DOWNLOADRESPONSE	 				"cwmp:DownloadResponse"

+#define CWMP_RPC_UPLOAD	 							"cwmp:Upload"

+#define CWMP_RPC_UPLOADRESPONSE	 					"cwmp:UploadResponse"

+#define CWMP_RPC_REBOOT	 							"cwmp:Reboot"

+#define CWMP_RPC_REBOOTRESPONSE	 					"cwmp:RebootResponse"

+#define CWMP_RPC_ADDOBJECT	 						"cwmp:AddObject"

+#define CWMP_RPC_ADDOBJECTRESPONSE	 				"cwmp:AddObjectResponse"

+#define CWMP_RPC_DELETEOBJECT	 					"cwmp:DeleteObject"

+#define CWMP_RPC_DELETEOBJECTRESPONSE	 			"cwmp:DeleteObjectResponse"

+#define CWMP_RPC_TRANSFERCOMPLETE	 			    "cwmp:TransferComplete"

+#define CWMP_RPC_TRANSFERCOMPLETERESPONSE 			"cwmp:TransferCompleteResponse"

+#define CWMP_RPC_FACTORYRESET                       "cwmp:FactoryReset"

+#define CWMP_RPC_FACTORYRESETRESPONSE               "cwmp:FactoryResetResponse"

+

+#define CWMP_RPC_GETPARAMETERATTRIBUTES  			"cwmp:GetParameterAttributes"

+#define CWMP_RPC_GETPARAMETERATTRIBUTESRESPONSE     "cwmp:GetParameterAttributesResponse"

+#define CWMP_RPC_SETPARAMETERATTRIBUTES  		    "cwmp:SetParameterAttributes"

+#define CWMP_RPC_SETPARAMETERATTRIBUTESRESPONSE     "cwmp:SetParameterAttributesResponse"

+

+#define CWMP_RPC_SCHEDULEINFORM  	         	    "cwmp:ScheduleInform"

+#define CWMP_RPC_SCHEDULEINFORMRESPONSE  	        "cwmp:ScheduleInformResponse"

+

+

+

+#define CWMP_INFORM_EVENT_CODE_0  "0 BOOTSTRAP"

+#define CWMP_INFORM_EVENT_CODE_1  "1 BOOT"

+#define CWMP_INFORM_EVENT_CODE_2  "2 PERIODIC"

+#define CWMP_INFORM_EVENT_CODE_3  "3 SCHEDULED"

+#define CWMP_INFORM_EVENT_CODE_4  "4 VALUE CHANGE"

+#define CWMP_INFORM_EVENT_CODE_5  "5 KICKED"

+#define CWMP_INFORM_EVENT_CODE_6  "6 CONNECTION REQUEST"

+#define CWMP_INFORM_EVENT_CODE_7  "7 TRANSFER COMPLETE"

+#define CWMP_INFORM_EVENT_CODE_8  "8 DIAGNOSTICS COMPLETE"

+#define CWMP_INFORM_EVENT_CODE_9  "9 REQUEST DOWNLOAD"

+#define CWMP_INFORM_EVENT_CODE_10  "10 AUTONOMOUS TRANSFER COMPLETE"

+#define CWMP_INFORM_EVENT_CODE_11  "M Reboot"

+#define CWMP_INFORM_EVENT_CODE_12  "M ScheduleInform"

+#define CWMP_INFORM_EVENT_CODE_13  "M Download"

+#define CWMP_INFORM_EVENT_CODE_14  "M Upload"

+#define CWMP_INFORM_EVENT_CODE_15  "M X_0_AccountChanged"

+#define CWMP_INFORM_EVENT_CODE_16  "M 16"

+#define CWMP_INFORM_EVENT_CODE_17  "M 17"

+

+#define FAULT_CODE_OK			0

+#define FAULT_CODE_9000              9000

+#define FAULT_CODE_9001              9001

+#define FAULT_CODE_9002              9002

+#define FAULT_CODE_9003              9003

+#define FAULT_CODE_9004              9004

+#define FAULT_CODE_9005              9005

+#define FAULT_CODE_9006              9006

+#define FAULT_CODE_9007              9007

+#define FAULT_CODE_9008              9008

+#define FAULT_CODE_9009              9009

+#define FAULT_CODE_9010              9010

+#define FAULT_CODE_9011              9011

+#define FAULT_CODE_9012              9012

+#define FAULT_CODE_9013              9013

+#define FAULT_CODE_9014              9014

+#define FAULT_CODE_9015              9015

+#define FAULT_CODE_9016              9016

+#define FAULT_CODE_9017              9017

+#define FAULT_CODE_9018              9018

+#define FAULT_CODE_9019              9019

+

+

+

+#define FAULT_STR_9000  "Method not supported"

+#define FAULT_STR_9001  "Request denied"

+#define FAULT_STR_9002  "Internal error"

+#define FAULT_STR_9003  "Invalid arguments"

+#define FAULT_STR_9004  "Resources exceeded"

+#define FAULT_STR_9005  "Invalid parameter name"

+#define FAULT_STR_9006  "Invalid parameter type"

+#define FAULT_STR_9007  "Invalid parameter value"

+#define FAULT_STR_9008  "Attempt to set a non-writable parameter"

+#define FAULT_STR_9009  "Notification request rejected"

+#define FAULT_STR_9010  "Download failure"

+#define FAULT_STR_9011  "Upload failure"

+#define FAULT_STR_9012  "File transfer server authentication failure"

+#define FAULT_STR_9013  "Unsupported protocol for file transfer"

+#define FAULT_STR_9014  "Download failure: unable to join multicast group"

+#define FAULT_STR_9015  "Download failure: unable to contact file server"

+#define FAULT_STR_9016  "Download failure: unable to access file"

+#define FAULT_STR_9017  "Download failure: unable to complete download"

+#define FAULT_STR_9018  "Download failure: file corrupted"

+#define FAULT_STR_9019  "Download failure: file authentication failure"

+

+#define FAULT_STRING(x)	cwmp_get_fault_string(x)

+

+

+#define InternetGatewayDeviceModule         "InternetGatewayDevice"

+#define DeviceSummaryModule                 "DeviceSummary"

+#define DeviceInfoModule                    "DeviceInfo"

+

+#define ManufacturerModule                  "Manufacturer"

+#define ManufacturerOUIModule               "ManufacturerOUI"

+#define ProductClassModule                  "ProductClass"

+#define DescriptionModule                   "Description"

+#define SerialNumberModule                  "SerialNumber"

+#define SpecVersionModule                   "SpecVersion"

+#define HardwareVersionModule               "HardwareVersion"

+#define SoftwareVersionModule               "SoftwareVersion"

+#define ProvisioningCodeModule              "ProvisioningCode"

+#define UpTimeModule                        "UpTime"

+#define DeviceLogModule                     "DeviceLog"

+

+

+#define ManagementServerModule              "ManagementServer"

+#define URLModule                           "URL"

+#define UsernameModule                      "Username"

+#define PasswordModule                      "Password"

+#define PeriodicInformIntervalModule        "PeriodicInformInterval"

+#define PeriodicInformTimeModule            "PeriodicInformTime"

+#define PeriodicInformEnableModule          "PeriodicInformEnable"

+#define ParameterKeyModule                  "ParameterKey"

+#define ConnectionRequestURLModule          "ConnectionRequestURL"

+#define ConnectionRequestUsernameModule     "ConnectionRequestUsername"

+#define ConnectionRequestPasswordModule     "ConnectionRequestPassword"

+#define UpgradesManagedModule               "UpgradesManaged"

+#define UDPConnectionRequestAddressModule   "UDPConnectionRequestAddress"

+#define STUNEnableModule                    "STUNEnable"

+#define STUNServerAddressModule             "STUNServerAddress"

+#define STUNServerPortModule                "STUNServerPort"

+#define STUNUsernameModule                  "STUNUsernameb"

+#define STUNPasswordModule                  "STUNPassword"

+#define NATDetectedModule                   "NATDetected"

+

+

+#define DeviceConfigModule                  "DeviceConfig"

+#define PersistentDataModule                "PersistentData"

+#define ConfigFileModule                    "ConfigFile"

+

+

+#define TimeModule                          "Time"

+#define NTPServer1Module                    "NTPServer1"

+#define NTPServer2Module                    "NTPServer2"

+#define CurrentLocalTimeModule              "CurrentLocalTime"

+#define LocalTimeZoneModule                 "LocalTimeZone"

+#define LocalTimeZoneNameModule             "LocalTimeZoneName"

+#define DaylightSavingsUsedModule           "DaylightSavingsUsed"

+#define DaylightSavingsStartModule          "DaylightSavingsStart"

+#define DaylightSavingsEndModule            "DaylightSavingsEnd"

+

+

+#define DeviceSummaryModule                 "DeviceSummary"

+

+#define WANDeviceModule                     "WANDevice"

+

+#define WANConnectionDeviceModule           "WANConnectionDevice"

+#define WANIPConnectionModule               "WANIPConnection"

+#define ExternalIPAddressModule             "ExternalIPAddress"

+

+

+

+

+

+

+

+

+typedef enum

+{

+	CWMP_EMPTY_METHOD,

+	CWMP_INFORM_METHOD,

+	CWMP_INFORMRESPONSE_METHOD,

+	CWMP_GETPARAMETERNAMES_METHOD,

+	CWMP_GETPARAMETERNAMESRESPONSE_METHOD,

+	CWMP_GETPARAMETERVALUES_METHOD,

+	CWMP_GETPARAMETERVALUESRESPONSE_METHOD,

+	CWMP_SETPARAMETERVALUES_METHOD,

+	CWMP_SETPARAMETERVALUESRESPONSE_METHOD,

+	CWMP_GETRPCMETHODS_METHOD,

+	CWMP_GETRPCMETHODSRESPONSE_METHOD,

+	CWMP_DOWNLOAD_METHOD,

+	CWMP_DOWNLOADRESPONSE_METHOD,

+	CWMP_UPLOAD_METHOD,

+	CWMP_UPLOADRESPONSE_METHOD,

+	CWMP_REBOOT_METHOD,

+	CWMP_REBOOTRESPONSE_METHOD,

+	CWMP_ADDOBJECT_METHOD,

+	CWMP_ADDOBJECTRESPONSE_METHOD,

+	CWMP_DELETEOBJECT_METHOD,

+	CWMP_DELETEOBJECTRESPONSE_METHOD

+

+

+}cwmp_method_t;

+

+

+

+

+enum cwmp_type_t

+{

+	TYPE_OBJECT=0,	//obj

+	TYPE_INT,	//int

+	TYPE_UNSIGNEDINT, //uint

+	TYPE_STRING,  	//s

+	TYPE_STRING16,	//s16

+	TYPE_STRING32,	//s32

+	TYPE_STRING64,	//s64

+	TYPE_STRING128,	//s128

+	TYPE_STRING256,	//s256

+	TYPE_STRING1024, //s1024

+	TYPE_DATETIME,	//dt

+	TYPE_BOOLEAN,	//bool

+	TYPE_BASE64,	//base

+	TYPE_ANY,

+	TYPE_UNKNOWN

+};

+

+enum InformEventType

+{

+	INFORM_BOOTSTRAP = 0,

+	INFORM_BOOT,

+	INFORM_PERIODIC,

+	INFORM_SCHEDULED,

+	INFORM_VALUECHANGE,

+	INFORM_KICKED,

+	INFORM_CONNECTIONREQUEST,

+	INFORM_TRANSFERCOMPLETE,

+	INFORM_DIAGNOSTICSCOMPLETE,

+	INFORM_REQUESTDOWNLOAD,

+	INFORM_AUTONOMOUSTRANSFERCOMPLETE,

+	INFORM_MREBOOT,

+	INFORM_MSCHEDULEINFORM,

+	INFORM_MDOWNLOAD,

+	INFORM_MUPLOAD,

+	INFORM_ACCOUNTCHANGE,

+	INFORM_MVENDORSPECRPC,

+	INFORM_XOUIEVENT,

+	INFORM_MAX

+};

+

+#define SESSION_RUNNING  (1)

+#define SESSION_NO_RUNNING  (0)

+

+typedef struct datatime_st

+{

+    unsigned int year;

+    unsigned int month;

+    unsigned int day;

+    unsigned int hour;

+    unsigned int min;

+    unsigned int sec;

+}datatime_st;

+

+

+typedef struct periodic_info_st

+{

+	int PeriodicInformEnable;

+	int PeriodicInformInterval;

+	datatime_st PeriodicInformTime;

+

+}periodic_info_st;

+

+

+

+struct cwmp_st

+{

+	cwmp_t			* old_cwmp;

+	int new_request;

+	int httpd_port;

+

+	int    cpe_auth;

+	int    acs_auth;

+

+	char * acs_url;

+	char * cpe_mf;

+	char * cpe_oui;

+	char * cpe_sn;

+	char * cpe_pc;

+	char * cpe_name;

+

+	char * acs_user;

+	char * acs_pwd;

+	char * cpe_user;

+	char * cpe_pwd;

+

+	char * event_filename;

+

+	pthread_mutex_t     event_mutex;

+	

+	event_list_t * el;

+

+	int	event_count;

+

+	event_global_t    event_global;

+

+	transfer_t    transfer_info;      //ÓÃÓÚDownloadºÍUpload

+

+	queue_t  *	queue;

+

+	pool_t * pool;

+	parameter_node_t * root;

+

+	int session_running;

+

+	

+

+#ifdef USE_CWMP_OPENSSL

+    SSL_CTX * ssl_ctx;

+#endif

+

+    int boot_flag;

+

+	periodic_info_st periodic_info;

+};

+

+

+

+

+typedef struct parameter_node_attr_st

+{

+	cwmp_byte_t   type;     /* 0:single 1:multi */

+	cwmp_byte_t   nc;             /* Notification,0:off,1:passive,2:active */

+	cwmp_uint64_t   acl;            /* access list */

+	cwmp_uint64_t	ext;

+}parameter_node_attr_st;

+

+#define PARAMETER_NODE_V_PADDING	0,0,0,0,0

+

+struct parameter_node_st

+{

+	char *    name;

+	cwmp_byte_t	rw;	//read / writable

+	cwmp_byte_t     type;	

+	

+	size_t		value_length;

+	char *          value;

+	parameter_node_attr_t attr;

+

+	parameter_node_t * parent;

+	parameter_node_t * child;

+	parameter_node_t * prev_sibling;

+	parameter_node_t * next_sibling;

+

+	parameter_get_handler_pt    	get;

+	parameter_set_handler_pt    	set;

+	parameter_notify_handler_pt 	notify;

+	parameter_add_handler_pt  	add;

+	parameter_del_handler_pt	del;

+	parameter_refresh_handler_pt	refresh;

+

+

+

+	cwmp_uint32_t	max;

+	cwmp_uint32_t	ext1;

+	cwmp_uint32_t	ext2;

+	cwmp_uint32_t	ext3;

+	cwmp_uint32_t	ext4;

+

+};

+

+

+

+

+

+struct download_arg_st

+{

+    char            *cmdkey;

+    char            *filetype;

+    char            *url;

+    char            *username;

+    char            *password;

+    char            *targetname;

+    char            *succurl;

+    char            *failurl;

+    unsigned int   delaysec;

+    unsigned int   filesize;

+};

+

+

+struct upload_arg_st

+{

+    char            *cmdkey;

+    char            *filetype;

+    char            *url;

+    char            *username;

+    char            *password;

+    unsigned int   delaysec;

+};

+

+

+struct fault_code_st

+{

+	int fault_code;

+	char * fault_string;

+};

+

+

+

+typedef struct schedule_inform_info_st

+{

+	cwmp_t * cwmp;

+

+	int delaytime;

+	char commandKey[COMMAND_KEY_LEN+1];

+	int timer_running;

+}schedule_inform_info_st;

+

+

+

+typedef struct  envelope_t envelope_t;

+

+

+void cwmp_set_envelope_ns(const char * envstr, const char * encstr);

+

+

+char * cwmp_xml_get_node_attribute(xmlnode_t * node, const char * name);

+

+

+parameter_list_t* cwmp_create_parameter_list(env_t * env );

+

+parameter_t* cwmp_create_parameter(env_t * env ,  const char * name, const char * value, size_t value_length, int type);

+parameter_t* cwmp_create_parameter_ex(env_t * env ,  const char * name, const char * value, size_t value_length, int type, parameter_node_attr_t *attr);

+

+

+

+int cwmp_create_parameter_node(env_t * env ,  parameter_node_t ** news, const char * name);

+

+download_arg_t * cwmp_clone_download_arg(download_arg_t * dlarg);

+upload_arg_t * cwmp_clone_upload_arg(upload_arg_t * ularg);

+

+xmldoc_t* cwmp_create_inform_message(env_t * env ,  header_t * header,

+		device_id_t * deviceid,

+		event_list_t *events,

+		datatime_t * currentt,

+		unsigned int max_envelope,

+		unsigned int retry_count,

+		parameter_list_t * pl);

+

+xmldoc_t* cwmp_create_getparameternames_response_message(env_t * env ,

+		header_t * header,

+		const char * path_name,

+		parameter_node_t * node,

+		unsigned int next_subset,

+		unsigned int next_level);

+

+xmldoc_t *  cwmp_create_getparametervalues_response_message(env_t * env ,

+    header_t * header,

+    parameter_list_t * pl);

+

+xmldoc_t *  cwmp_create_setparametervalues_response_message(env_t * env ,

+    header_t * header,

+    unsigned int status);

+

+xmldoc_t *  cwmp_create_getrpcmethods_response_message(env_t * env ,

+    header_t * header,

+    char ** methods,

+    unsigned int count);

+

+xmldoc_t *  cwmp_create_reboot_response_message(env_t * env ,

+    header_t * header);

+

+xmldoc_t * cwmp_create_download_response_message(env_t * env , header_t * header, int status);

+xmldoc_t * cwmp_create_upload_response_message(env_t * env , header_t * header, int status);

+xmldoc_t * cwmp_create_transfercomplete_message(env_t * env ,  header_t * header, event_code_t * evcode);

+xmldoc_t * cwmp_create_addobject_response_message(env_t * env , header_t * header, int instances, int status);

+xmldoc_t * cwmp_create_deleteobject_response_message(env_t * env , header_t * header, int status);

+xmldoc_t * cwmp_create_faultcode_response_message(env_t * env , header_t * header, fault_code_t * fault);

+xmldoc_t * cwmp_create_faultcode_setparametervalues_response_message(env_t * env , header_t * header, parameter_list_t * param_list, fault_code_t * fault);

+xmldoc_t * cwmp_create_factoryreset_response_message(env_t * env ,  header_t * header);

+

+event_code_t * cwmp_create_event_code(env_t * env );

+event_list_t * cwmp_create_event_list(env_t * env, int  size );

+

+int     cwmp_add_parameter_to_list(env_t * env ,  parameter_list_t * pl, parameter_t * parameter);

+void    cwmp_add_event_to_list(env_t * env ,  event_list_t * eventlist, event_code_t * event);

+

+int     cwmp_parse_getparameternames_message(env_t * env, xmldoc_t * doc, char ** path_name, unsigned int * next_level, fault_code_t *fault);

+int     cwmp_parse_getparametervalues_message(env_t * env ,   xmldoc_t * doc, parameter_node_t * root, parameter_list_t ** ppl, fault_code_t *fault);

+int     cwmp_parse_setparametervalues_message(env_t * env ,   xmldoc_t * doc, parameter_node_t * root, parameter_list_t ** ppl, fault_code_t *fault);

+int     cwmp_parse_reboot_message(env_t * env , xmldoc_t *doc, char ** key, fault_code_t *fault);

+int cwmp_parse_addobject_message(env_t * env , xmldoc_t *doc, parameter_node_t * root,  int * instances, int* status, fault_code_t *fault);

+int cwmp_parse_deleteobject_message(env_t * env , xmldoc_t *doc, parameter_node_t * root, int* status, fault_code_t *fault);

+

+xmlnode_t * cwmp_get_rpc_method_node(xmldoc_t *  doc);

+xmlnode_t * cwmp_get_header_node(xmldoc_t *  doc);

+

+int     cwmp_parse_header_node(xmlnode_t * node, header_t ** header, pool_t * pool);

+char *  cwmp_get_rpc_method_name(xmldoc_t *  doc);

+char *  cwmp_get_type_string(int type);

+int	cwmp_get_type_value(char * type);

+char *  cwmp_get_fault_string(int code);

+

+parameter_node_t * cwmp_get_parameter_node(parameter_node_t * root, const char * param_name);

+parameter_node_t * cwmp_get_parameter_path_node(parameter_node_t * parent, const char * param_name);

+

+int cwmp_get_parameter_node_value(cwmp_t * cwmp, parameter_node_t * node, const char * name, char ** value, pool_t * pool);

+int cwmp_set_parameter_node_value(cwmp_t * cwmp, parameter_node_t * node, const char * name, const char * value, int value_length);

+int     cwmp_write_doc_to_chunk(xmldoc_t *  doc, cwmp_chunk_t * chunk, pool_t * pool);

+

+xmldoc_t * cwmp_xml_parse_buffer(pool_t * pool, char * buffer);

+xmlnode_t * cwmp_xml_get_child_with_name(void * nodeptr, const char * nodeName);

+

+

+#define XmlNodeGetDocRoot(docptr)    XmlNodeGetFirstChild(XmlNodeGetFirstChild(& (docptr)->node))

+

+

+

+

+#endif // CWMP_H

+

diff --git a/lynq/S300/ap/app/fota_upi/src/upi_led.c b/lynq/S300/ap/app/fota_upi/src/upi_led.c
new file mode 100755
index 0000000..9820ab1
--- /dev/null
+++ b/lynq/S300/ap/app/fota_upi/src/upi_led.c
@@ -0,0 +1,311 @@
+/**
+* @file upi_led.c
+* @brief ÁÁµÆÏà¹Ø½Ó¿Ú
+*
+* Copyright (C) 2017 Sanechips Technology Co., Ltd.
+* @author
+*
+*/
+
+
+/*******************************************************************************
+ *                           Include header files                              *
+ ******************************************************************************/
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "upi_led.h"
+#include "update.h"
+
+
+// nv½Ó¿ÚÐèÒª
+#include "softap_api.h"
+
+#include "upi_cmd.h"
+#include "zxic_fs_interface.h"
+
+
+
+/*******************************************************************************
+ *                             Macro definitions                               *
+ ******************************************************************************/
+// LEDµÆÃû³Æ¶¨Òå
+#define WL_LED 						"/sys/class/leds/wl_led_en/"
+
+#define SIGNAL_1_LED 				"/sys/class/leds/signal_status1_led/"
+#define SIGNAL_2_LED				"/sys/class/leds/signal_status2_led/"
+#define SIGNAL_3_LED				"/sys/class/leds/signal_status3_led/"
+
+#define WIFI_LED				"/sys/class/leds/wifi_led/"
+#define RJ45_LED				"/sys/class/leds/eth_led/"
+
+
+#define BATTERY_RED_LED			"/sys/class/leds/battery_r_led/"
+#define BATTERY_GREEN_LED			"/sys/class/leds/battery_g_led/"
+#define BATTERY_BLUE_LED			"/sys/class/leds/battery_b_led/"
+
+#define SMS_LED						"/sys/class/leds/sms_led/"
+
+#define MODEM_RED_LED				"/sys/class/leds/modem_r_led/"
+#define MODEM_GREEN_LED			"/sys/class/leds/modem_g_led/"
+#define MODEM_BLUE_LED				"/sys/class/leds/modem_b_led/"
+
+// LEDµÆ²Ù×÷¶¨Òå
+#define BRIGHTNESS					"/brightness"     // µÆ×Ü¿ª¹Ø
+#define BLINKSWITDH					"/trigger"       // ÉÁ˸¿ª¹Ø
+#define BLINKTIMEON					"/delay_on"      // ÉÁ˸ÁÁµÆÊ±¼ä(ms)
+#define BLINKTIMEOFF				"/delay_off"    // ÉÁ˸ÃðµÆÊ±¼ä(ms)
+
+
+#define LEDON						(1)
+#define LEDOFF						(0)
+
+#define LEDBLINKON					"timer"
+#define LEDBLINKOFF					"none"
+
+#define FOTA_LED_BLINK_ON_MS		(300)
+#define FOTA_LED_BLINK_OFF_MS		(300)
+
+
+// system command max len
+//#define CMD_MAX_LEN				(256)
+
+
+// nv max len
+#define LED_NV_MAX_LEN				(256)
+
+
+
+/*******************************************************************************
+ *                             Type definitions                                *
+ ******************************************************************************/
+
+typedef enum {
+	SHOW_MODE_UNDEFINE = 0,
+	SHOW_MODE_LED = 1,
+	SHOW_MODE_LCD,
+	SHOW_MODE_ALL
+} E_zShowMode;
+
+
+/*******************************************************************************
+ *                       Global variable declarations                          *
+ ******************************************************************************/
+
+E_zShowMode			g_show_mode = SHOW_MODE_UNDEFINE;
+
+/*******************************************************************************
+ *                       Static function declarations                          *
+ ******************************************************************************/
+static int write_led_file(const char* filepath, const char* content)
+{
+	int ret = -1;
+	int fd  = -1;
+
+	fd = open(filepath, O_RDWR|O_TRUNC);
+	if (fd < 0)       
+	{
+		upi_err("open file fail [%s], error:%d[%s]\n", filepath,  errno, strerror(errno));
+		return -1;
+	}
+
+	ret = upi_writen(fd, content, strlen(content));
+	if (ret < 0)
+	{
+		upi_err("write fail ,file path:%s , error:%d[%s]\n", filepath,  errno, strerror(errno));
+		close(fd);
+		return -1;
+	}
+	else
+	{
+		upi_log("write counts: %d\n", ret);
+	}
+
+	ret = close(fd);
+	if(ret < 0)
+	{
+		upi_err("close file fail [%s], error:%d[%s]\n", filepath,  errno, strerror(errno));
+		return -1;
+	}
+
+	return 0;
+}
+
+
+/**
+ * @brief		ÉèÖÃLEDµÈÁÁÃð¼°ÉÁ˸
+ * @param	ledName:		LEDµÆÃû³Æ
+ * @param	brightNess:	µÆ×Ü¿ª¹Ø£¬0-¹Ø£¬1-¿ª
+ * @param	blinkSwitch:	ÉÁ˸¿ª¹Ø£¬0-¹Ø£¬1-¿ª
+ * @param	onMs:		ÉÁ˸ÁÁµÆºÁÃëÊý
+ * @param	offMs:		ÉÁ˸ÃðµÆºÁÃëÊý
+ */
+static int led_handle(const char *ledName, unsigned int brightNess,
+                      const char * blinkSwitch, unsigned int onMs, unsigned int offMs)
+{
+	char content[128] = {0};
+	char path[256] = {0};
+	int ret = -1;
+	int ret_1 = -1;
+	int ret_2 = -1;
+	int ret_3 = -1;
+
+	if (NULL == ledName) {
+		upi_err("set_led_blink NULL parameter ledName\n");
+		return -1;
+	}
+
+	if (0 != access(ledName, F_OK)) {
+		upi_err("set_led_blink led device [%s] does not exist!\n", ledName);
+		return -2;
+	}
+
+	switch (brightNess) {
+	case 0: 
+		{
+			memset(content, 0, sizeof(content));
+			memset(path, 0, sizeof(path));
+			snprintf(content, sizeof(content), "%d", brightNess);
+			snprintf(path, sizeof(path), "%s%s", ledName, BRIGHTNESS);
+			ret = write_led_file(path, content);
+			upi_log("set_led_blink set [%s] off :%d \n", ledName, ret);
+			break;
+		}
+
+	case 1: 
+		{
+			memset(content, 0, sizeof(content));
+			memset(path, 0, sizeof(path));
+			snprintf(content, sizeof(content), "%s", blinkSwitch);
+			snprintf(path, sizeof(path), "%s%s", ledName, BLINKSWITDH);
+			ret_1 = write_led_file(path, content);
+
+			memset(content, 0, sizeof(content));
+			memset(path, 0, sizeof(path));
+			snprintf(content, sizeof(content), "%d", onMs);
+			snprintf(path, sizeof(path), "%s%s", ledName, BLINKTIMEON);
+			ret_2 = write_led_file(path, content);
+
+			memset(content, 0, sizeof(content));
+			memset(path, 0, sizeof(path));
+			snprintf(content, sizeof(content), "%d", offMs);
+			snprintf(path, sizeof(path), "%s%s", ledName, BLINKTIMEOFF);
+			ret_3 = write_led_file(path, content);
+
+			upi_log("set_led_blink set [%s] blink: %dms on, %dms off, ret=%d|%d|%d \n", ledName, onMs, offMs, ret_1, ret_2, ret_3);
+			ret = (ret_1 & ret_2 & ret_3);
+
+			break;
+		}
+
+	default: 
+		{
+			upi_err("set_led_blink invalid parameter: MUST BE 0 or 1\n");
+			ret = -1;
+			break;
+		}
+	}
+
+
+	return ret;
+}
+
+
+
+
+/*******************************************************************************
+ *                       Global function declarations                          *
+ ******************************************************************************/
+
+/**
+ * @brief 	ÉèÖôò¿ªupiÉý¼¶ledÉÁµÆ
+ * @note		ÉèÖÃÉÁµÆÇ°ÐèÒªÏÈ¹Ø±ÕÆäËüÎÞ¹ØÉÁµÆ
+ */
+void set_upi_leds_on(void)
+{
+	int i   = 0;
+	char* led_list[] = {MODEM_GREEN_LED, WIFI_LED, BATTERY_GREEN_LED, RJ45_LED, NULL};
+	int led_list_len = sizeof(led_list) / sizeof(char*);
+
+
+	// ϨÃðÆäËûLEDµÆ
+	led_handle(WIFI_LED, 		LEDOFF, LEDBLINKOFF, 0, 0);
+	led_handle(RJ45_LED, 		LEDOFF, LEDBLINKOFF, 0, 0);
+
+	led_handle(BATTERY_RED_LED,	 	LEDOFF, LEDBLINKOFF, 0, 0);
+	led_handle(BATTERY_GREEN_LED, 	LEDOFF, LEDBLINKOFF, 0, 0);
+	led_handle(BATTERY_BLUE_LED, 	LEDOFF, LEDBLINKOFF, 0, 0);
+
+	led_handle(MODEM_RED_LED, 		LEDOFF, LEDBLINKOFF, 0, 0);
+	led_handle(MODEM_GREEN_LED, 	LEDOFF, LEDBLINKOFF, 0, 0);
+	led_handle(MODEM_BLUE_LED, 		LEDOFF, LEDBLINKOFF, 0, 0);
+
+	// FOTAÉý¼¶¹ý³ÌÖÐLEDµÆÉÁ˸ÓÅÏȼ¶ 300msÁÁ£¬300msÃð:
+	// 1. modemÀ¶µÆ 2. batteryÀ¶µÆ 3. wifiÀ¶µÆ 4. batteryÂÌµÆ 5. modemÂ̵Æ
+	for (i = 0; i < led_list_len; i++) {
+		if (NULL == led_list[i]) {
+			break;
+		}
+
+		if (0 == led_handle(led_list[i], LEDON, LEDBLINKON, FOTA_LED_BLINK_ON_MS, FOTA_LED_BLINK_OFF_MS)) {
+			upi_err("FOTA set led blink success, current led device file is %s! \n", led_list[i]);
+			//return;
+		}
+	}
+
+	//upi_log("FOTA set led blink failed! No blue and green led!\n");
+	upi_log("FOTA set led blink end!\n");
+}
+
+/**
+ * @brief 	ÉèÖùرÕupiÉý¼¶ledÉÁµÆ
+ * @note
+ */
+void set_upi_leds_off(void)
+{
+	led_handle(WIFI_LED, 		LEDOFF, LEDBLINKOFF, 0, 0);
+	led_handle(RJ45_LED, 		LEDOFF, LEDBLINKOFF, 0, 0);
+	led_handle(BATTERY_GREEN_LED,	LEDOFF, LEDBLINKOFF, 0, 0);
+	led_handle(BATTERY_BLUE_LED,	LEDOFF, LEDBLINKOFF, 0, 0);
+	led_handle(BATTERY_RED_LED,		LEDOFF, LEDBLINKOFF, 0, 0);
+	led_handle(MODEM_GREEN_LED,		LEDOFF, LEDBLINKOFF, 0, 0);
+	led_handle(MODEM_BLUE_LED,		LEDOFF, LEDBLINKOFF, 0, 0);
+	led_handle(MODEM_RED_LED,		LEDOFF, LEDBLINKOFF, 0, 0);
+}
+
+
+
+/**
+ * @brief 	»ñÈ¡ÏÔʾģʽ£¬Ö÷ÒªÅжÏÊÇ·ñÐèÒªLED
+ * @note
+ */
+
+int init_show_mode()
+{
+#if 0
+	char led_nv_value[LED_NV_MAX_LEN] = {0};
+
+	//ÉèÖÃmmiÏÔʾģʽȫ¾Ö±äÁ¿
+	cfg_get_item("mmi_showmode", led_nv_value, sizeof(led_nv_value));
+	if (0 == strcmp(led_nv_value, "led")) {
+		g_show_mode = SHOW_MODE_LED;
+	} else if (0 == strcmp(led_nv_value, "lcd")) {
+		g_show_mode = SHOW_MODE_LCD;
+	} else if (0 == strcmp(led_nv_value, "all")) {
+		g_show_mode = SHOW_MODE_ALL;
+	} else {
+		assert(0);
+		return -1;
+	}
+#endif
+
+	return 0;
+
+}
+
+
+
+
diff --git a/lynq/S300/ap/app/goahead/interface5.0/Makefile b/lynq/S300/ap/app/goahead/interface5.0/Makefile
new file mode 100755
index 0000000..e6d24a8
--- /dev/null
+++ b/lynq/S300/ap/app/goahead/interface5.0/Makefile
@@ -0,0 +1,189 @@
+# /*****************************************************************************
+#* °æÈ¨ËùÓÐ (C)2015, ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+#* 
+#* ÎļþÃû³Æ:     Makefile
+#* Îļþ±êʶ:     Makefile
+#* ÄÚÈÝÕªÒª:     Makefile of ZTE applications
+#* ʹÓ÷½·¨:     void
+#* 
+#* ÐÞ¸ÄÈÕÆÚ        °æ±¾ºÅ      Ð޸ıê¼Ç        ÐÞ¸ÄÈË          ÐÞ¸ÄÄÚÈÝ
+#* -----------------------------------------------------------------------------
+#* 2015/02/10      V1.0        Create          ÁõÑÇÄÏ          ´´½¨
+#* 
+# ******************************************************************************/
+
+#*******************************************************************************
+# include ZTE application makefile
+#*******************************************************************************
+include $(zte_app_mak)
+
+.PHONE: webuinet
+.PHONE: webuiwifi
+.PHONE: webuiother
+#*******************************************************************************
+# LIBWEBINTERFACE
+#*******************************************************************************
+LIBWEBINTERFACE = libwebinterface.a
+LIBWEBINTERFACE_SHARED = libwebinterface.so
+
+#*******************************************************************************
+# objects
+#*******************************************************************************
+OBJS    = zte_web_regist.o zte_web_util.o zte_web_mgmt.o \
+		zte_web_pbm.o \
+		zte_web_wan.o zte_web_sms.o \
+		zte_web_get_fw_para.o \
+		zte_web_httpshare.o zte_web_ussd.o \
+		zte_web_mc.o zte_web_rest.o zte_web_safe.o zte_web_cell_broadcast.o \
+		zte_web_cjson.o zte_web_sem.o
+
+#OBJS    += $(wildcard $(zte_lib_path)/libpthread/*.o) 
+export WEBUI=
+
+ifeq ($(WEBUI), orig)
+OBJS += 
+WEBOBJS :=
+else
+CFLAGS += -DMYWEBUI
+WEBOBJS := $(patsubst %.c,%.o,$(wildcard ./net/*.c))
+endif
+
+WIFIOBJS := $(patsubst %.c,%.o,$(wildcard ./wifi/*.c))
+
+OTHEROBJS   := $(patsubst %.c,%.o,$(wildcard ./other/*.c))
+#OBJS += $(WIFIOBJS)
+#*******************************************************************************
+# include path
+#*******************************************************************************
+CFLAGS	+= -DCONFIG_CHINA_UNICOM -DWEBS -DUEMF -DOS="LINUX" -DLINUX $(UMSW) $(DASW) $(SSLSW) $(IFMODSW)
+CFLAGS	+= -DWEBINSPECT_FIX
+CFLAGS  += -Wall -fno-strict-aliasing
+#CFLAGS	+= -I$(ROOTDIR)/lib/libnvram -I$(ROOTDIR)/$(LINUXDIR)/drivers/char -I$(ROOTDIR)/$(LINUXDIR)/include 
+#CFLAGS  += -I$(ROOTDIR)/$(LINUXDIR)/drivers/flash
+CFLAGS	+= -I$(zte_lib_path)/libnvram
+CFLAGS  += -I$(zte_lib_path)/libezxml
+CFLAGS  += -I$(zte_lib_path)/libmxml
+CFLAGS  += -I$(zte_lib_path)/zlib/install/include
+CFLAGS  += -I../../goahead/interface5.0/net
+CFLAGS  += -I../../goahead/interface5.0/wifi
+CFLAGS  += -I../../goahead/interface5.0/other
+CFLAGS  += -I../../goahead/interface5.0
+CFLAGS	+= -I../../include
+CFLAGS	+= -I../../wlan
+#CFLAGS	+= -I../../zte_sqlite
+#CFLAGS  += -I../../soft_timer
+CFLAGS	+= -I$(zte_lib_path)/libsqlite
+CFLAGS	+= -I$(zte_lib_path)/libsoft_timer
+CFLAGS  += -I../../at_server
+CFLAGS	 += -I../../awps/include
+CFLAGS	 += -I.
+
+#CFLAGS	+= -I../../sms
+
+ifeq ($(LINUX_TYPE),linux)
+CFLAGS  += -I$(USR_DIR)
+endif
+
+#CFLAGS  += -I$(USR_DIR)/zte_apps/soft_timer
+#CFLAGS  += -I$(USR_DIR)/zte_apps/at_server
+CFLAGS	+= -I../server
+CFLAGS	+= -fPIC  -shared -lc
+SHAREDFLAG := -fPIC -shared -lc
+#CFLAGS += -I$(LIB_DIR)/lib/sms_pbm
+
+ifeq ($(CONFIG_USE_WEBUI_SECURITY),yes)
+CFLAGS	+= -DWEBS_SECURITY
+endif
+ifeq ($(CONFIG_USE_WEBUI_SSL),yes)
+CFLAGS	+= -DWEBS_SSL_SUPPORT -DOPENSSL
+endif
+
+#*******************************************************************************
+# macro definition
+#*******************************************************************************
+ifeq ($(FEATURE_IPV6), YES)
+		CFLAGS	+= -DFEATURE_IPV4V6_MODE
+endif
+
+ifeq ($(FEATURE_SMS_MODE), CS)
+		CFLAGS	+= -DCS_SMS
+endif
+
+ifeq ($(CUSTOM_MODEL),MF253)
+	ifeq ($(CUSTOM_OPERATOR),VIVO_BR)
+		CFLAGS	+= -DCUSTOM_VERSION_MF253_VIVO_BR
+	endif
+endif
+
+ifeq ($(FEATURE_TSP_MODE), YES)
+	CFLAGS	+= -DFEATURE_TSP_MODEM
+endif
+
+ifeq ($(CUSTOM_MODEL), MF253S2)
+ifeq ($(CUSTOM_OPERATOR), CM_CN)
+CFLAGS	+= -DCUSTOM_VERSION_MF253S2_CM_CN
+endif
+endif
+
+#*******************************************************************************
+# library
+#*******************************************************************************
+LDLIBS += -lpthread -lgcc_s
+LDLIBS += -lnvram -lsoft_timer -lsqlite -lzte_pbm -lwlan_interface -llog
+
+#*******************************************************************************
+# library path
+#*******************************************************************************
+LDLIBS  += -L$(zte_lib_path)/libnvram
+LDLIBS  += -L$(zte_lib_path)/libsoft_timer
+LDLIBS  += -L$(zte_lib_path)/libsqlite
+LDLIBS  += -L$(zte_lib_path)/liblog
+LDLIBS  += -L$(zte_lib_path)/libzte_pbm
+LDLIBS  += -L$(zte_lib_path)/../libezxml
+LDLIBS  += -L$(zte_lib_path)/../libmxml
+LDLIBS  += -L$(zte_lib_path)/libwlan_interface
+
+CFLAGS += -I$(zte_lib_path)/libssl/install/include
+LDLIBS += -L$(zte_lib_path)/libssl/install/lib -lcrypto
+
+CFLAGS += -I$(zte_lib_path)/libcurl/install/include
+LDLIBS += -L$(zte_lib_path)/libcurl/install/lib -lcurl
+#*******************************************************************************
+# targets
+#*******************************************************************************
+all: $(LIBWEBINTERFACE) webuinet webuiwifi webuiother
+zte_web_util.o: webuinet webuiwifi webuiother
+#all:
+#	echo $(ROOTDIR) $(LINUXDIR) $(zte_lib_path)
+
+$(LIBWEBINTERFACE): $(OBJS) webuinet webuiwifi webuiother
+	$(AR) -rc $@ $(OBJS) $(WEBOBJS) $(WIFIOBJS) $(OTHEROBJS)
+	
+$(LIBWEBINTERFACE_SHARED): $(OBJS) webuinet webuiwifi webuiother
+	$(LD) $(SHAREDFLAG) -o $@ $^ $(LDLIBS) $(WEBOBJS) $(WIFIOBJS) $(OTHEROBJS)
+#	$(STRIP) $@
+	
+romfs:
+
+ifeq ($(WEBUI), orig)
+webuinet:
+	@echo
+else
+webuinet:
+	cd ./net; echo $$pwd ;$(MAKE) -C ./ all||exit $$?
+endif
+
+webuiwifi:
+	cd ./wifi; echo $$pwd ;$(MAKE) -C ./ all||exit $$?
+
+webuiother:
+	cd ./other; echo $$pwd ;$(MAKE) -C ./ all||exit $$?
+
+root_fs:
+#	$(ROMFSINST) -e CONFIG_USER_GOAHEAD /bin/$(LIBWEBINTERFACE)
+
+clean:
+	-rm -f $(LIBWEBINTERFACE) *.elf *.gdb *.o
+	-cd ./net && $(MAKE) -C ./ clean
+	-cd ./wifi && $(MAKE) -C ./ clean
+	-cd ./other && $(MAKE) -C ./ clean
diff --git a/lynq/S300/ap/app/goahead/interface5.0/zte_web_interface.h b/lynq/S300/ap/app/goahead/interface5.0/zte_web_interface.h
new file mode 100755
index 0000000..c3489a1
--- /dev/null
+++ b/lynq/S300/ap/app/goahead/interface5.0/zte_web_interface.h
@@ -0,0 +1,1122 @@
+/**
+ * @file zte_web_interface.h
+ * @brief Public APIs of Sanechips
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author Hong Wu <wu.hong@sanechips.com.cn>
+ * @defgroup si_ap_app_webserver_id si_ap_app_webserver
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+
+#ifndef ZTE_WEB_INTERFACE_H
+#define ZTE_WEB_INTERFACE_H
+
+/*******************************************************************************
+ *                           Include header files                              *
+ ******************************************************************************/
+#include <time.h>
+#include "../server/webs.h"
+#include "message.h"
+//#include "errorcode.h"
+#include "cfg_nv_def.h"
+#include "cfg_api.h"
+#include "zte_web_mgmt.h"
+#include <sys/ipc.h>
+#include <sys/msg.h>
+#include "softap_api.h"
+#include "netotherapi.h"
+#include "net/zte_web_net_lan.h"
+#include "net/zte_web_net_wan.h"
+#include "net/zte_web_net_other.h"
+
+/*******************************************************************************
+ *                             Macro definitions                               *
+ ******************************************************************************/
+#define cprintf(fmt, args...) do {  \
+    FILE *fp = fopen("/dev/console", "w");  \
+    if (fp) {   \
+        fprintf(fp, fmt, ## args);  \
+        fclose(fp); \
+    }   \
+} while (0)
+
+#define WEBLOG cprintf
+#define IFSTREQUAL(str1, str2) (strcmp((str1), (str2))?0:1)
+#define STR_EQUAL(a,b) ( strcmp((char*)a, (char*)b)==0 )
+#ifndef uint8
+#define uint8 unsigned char
+#endif
+
+#define ID "id"
+#define NAME "name"
+#define SITE "site"
+#define SUCCESS "success"
+#define FAILURE "failure"
+#define EXIST "exist"
+#define NOEXIST "noexist"
+#define PROCESSING "processing"
+#define MSG_INVALID_WEB_PARAM    "MSG_INVALID_WEB_PARAM"
+#define ZTE_MC_OK_S  (0)
+
+#define CFG_BUF_LENGTH 512
+#define CONFIG_DEFAULT_LENGTH  64
+
+#define DIAGLOG_DATA_PATH    "/etc_ro/web/diaglog"
+
+/*** define about NV ***/
+#define NV_ITEM_VALUE_DEFAULT_STRING_LEN 128
+#define NV_ITEM_VALUE_BOOLEAN_LEN 1
+#define NV_ITEM_VALUE_YES_NO_LEN 5
+#define NV_ITEM_VALUE_IP_LEN          20
+#define NV_ITEM_MODE_STRING_LEN   25
+#define NV_ITEM_ADMIN_STRING_LEN 25
+#define NV_ITEM_VALUE_APN_STRING_LEN 400
+#define NV_ITEM_VALUE_NW_LIST_STRING_LEN 700
+#define NV_ITEM_STRING_LEN_5  5
+#define NV_ITEM_STRING_LEN_10  10
+#define NV_ITEM_STRING_LEN_20  20
+#define NV_ITEM_STRING_LEN_50  50
+#define NV_ITEM_STRING_LEN_64  64
+#define NV_ITEM_STRING_LEN_150  150
+#define NV_ITEM_STRING_LEN_200  200
+#define NV_FW_RULE_MAX_LEN_V6 400
+#define NV_ITEM_VALUE_STRING_LEN 50
+#define NVIO_MAX_LEN 1500
+#define NVIO_TMP_LEN 512
+#define NVIO_DEFAULT_LEN 50
+#define NV_ITEM_VALUE_STRING_LEN 50
+#define NV_ITEM_VALUE_MAX_LEN        1024
+#define zte_web_write(xx_item, xx_value) zte_nvconfig_write(xx_item, xx_value,(int)strlen(xx_value))
+#define zte_web_read(xx_item, xx_value) zte_nvconfig_read(xx_item, xx_value,sizeof(xx_value)) //modified,-1 deleted
+
+/*webuiÕʺÅ*/
+#define LOGIN_SUCCESS "0"
+#define LOGIN_FAIL "1"
+#define LOGIN_DUPLICATE_USER "2"
+#define LOGIN_BAD_PASSWORD "3"
+#define LOGIN_ALREADY_LOGGED "4"
+#define LOGIN_USER_NAME_NOT_EXSIT  "5"
+#define LOGIN_TIMEOUT  600 //timeout after webui login 
+#define LOGIN_PSW_MIN_LEN 1
+#define LOGIN_PSW_MAX_LEN 32
+#define LOGIN_FAIL_LOCK_TIME 300//the lock time after  login failed
+#define LOGIN_FAIL_TIMES "5"
+#define LOGIN_RECORD_TIME  32
+
+#define COOKIE_SESSION_SIZE  32
+#define COOKIE_TOKEN_TIMEOUT  30
+
+#define NV_LANGUAGE "Language"
+#define NV_LOGINFO "loginfo"
+#define NV_USER_IP_ADDR "user_ip_addr"
+#define NV_LOGIN_LOCK_TIME "login_lock_time"
+#define NV_LAST_LOGIN_TIME "last_login_time"
+#define NV_USER_LOGIN_TIMEMARK "user_login_timemark"
+#define NV_COOKIE_ID "cookie_id"
+#define NV_WEB_TOKEN "web_token"
+
+/* ¿ìËÙÉèÖà */
+#define MAX_QUICK_SET_NUM 10
+
+/*Á÷Á¿Í³¼Æ*/
+#define ZTE_WEB_DATA_STATISTICS_CLEAR_ALL "ALL"
+#define ZTE_WEB_DATA_STATISTICS_CLEAR_TOTAL "TOTAL"
+#define ZTE_WEB_DATA_STATISTICS_CLEAR_CURRENT "CURRENT"
+
+
+
+//wan module
+#define ZTE_DAILNUM_LEN 8
+#define ZTE_ADDR_LEN 16
+#define ZTE_SEL_TYPE 8
+#define ZTE_PDP_TYPE_LEN 12
+#define ZTE_AUTH_TYPE_LEN 8
+#define ZTE_WAN_UMTS_MAX_PROFILE_NAME_LEN 32
+#define ZTE_WAN_UMTS_MAX_APN_STRING_LEN 104
+#define ZTE_WAN_UMTS_MAX_USERNAME_STRING_LEN 65
+#define ZTE_WAN_UMTS_MAX_PASSWD_STRING_LEN 65
+#define ZTE_USSD_DATA_TO_WEB_LEN  900
+#define CMD_CONNECTION_MODE  "ConnectionMode"
+
+//pbm module
+#define CMD_PBM_DATA_INFO "pbm_data_info"
+#define CMD_PBM_DATA_TOTAL "pbm_data_total"
+#define CMD_PBM_CAPACITY_INFO "pbm_capacity_info"
+
+//sms module
+#define CMD_SMS_PAGE_DATA "sms_page_data"
+#define CMD_SMS_PARAMETER_INFO "sms_parameter_info"
+#define CMD_SMS_STATUS_INFO "sms_cmd_status_info"
+#define CMD_SMS_CAPACITY_INFO "sms_capacity_info"
+#define CMD_SMS_STATUS_RPT_DATA "sms_status_rpt_data"
+#define CMD_SMS_DATA_TOTAL "sms_data_total"
+#define CMD_SMS_UNREAD_COUNT "sms_unread_count"
+#define CMD_BROADCAST_DATA "broadcast_data"
+#define NV_SMS_UNREAD_NUM  "sms_unread_num"
+
+//APN
+#define APN_SAVE_AND_SET_DEFAULT "0"
+#define APN_ONLY_SET_DEFAULT "1"
+#define ZTE_WEB_ACT_AUTO  "auto"
+#define ZTE_WEB_ACT_MANUAL "manual"
+#define ZTE_WEB_ACT_SAVE "save"
+#define ZTE_WEB_ACT_SETDEFAULT "set_default"
+#define ZTE_WEB_ACT_SAVE_AND_SETDEFAULT "set_save_and_default"
+#define ZTE_WEB_ACT_DELETE "delete"
+#define ZTE_WEB_DIAL_MODE_AUTO "auto_dial"
+#define ZTE_WEB_DIAL_MODE_MANUAL "manual_dial"
+#define ZTE_WEB_DIAL_MODE_DEMAND  "demand_dial"
+#define ZTE_WEB_MANUAL_DIAL_ACTION_CONN "connect"
+#define ZTE_WEB_MANUAL_DIAL_ACTION_DISCONN "disconnect"
+
+//nv for data limit settings
+#define NV_DATA_VOLUME_LIMIT_SWITCH "data_volume_limit_switch" /*0:disable;1:enable*/
+#define NV_DATA_VOLUME_LIMIT_UNIT  "data_volume_limit_unit" /*time/data*/
+#define NV_DATA_VOLUME_LIMIT_SIZE "data_volume_limit_size"
+#define NV_DATA_VOLUME_ALERT_PERCENT "data_volume_alert_percent"
+#define DATA_VOLUME_LIMIT_UNIT_TIME "time"
+#define DATA_VOLUME_LIMIT_UNIT_DATA "data"
+#define NV_HTTPSHARE_STATUS "HTTP_SHARE_STATUS"
+#define NV_HTTPSHARE_WR_AUTH "HTTP_SHARE_WR_AUTH"
+#define NV_HTTPSHARE_FILE "HTTP_SHARE_FILE"
+
+//other fluxstat
+#define NV_DATA_TRAFFIC_SIM_PROVINCE   "sim_home_location"
+#define NV_DATA_TRAFFIC_SWITCH              "is_traffic_aline_on"
+#define NV_DATA_TRAFFIC_MONTH_TOTAL   "traffic_month_total"
+#define NV_DATA_TRAFFIC_MONTH_USED   "traffic_month_used"
+
+//fota module
+#define FOTA_ACTION_CANCEL_DOWNLOAD "0"
+#define FOTA_ACTION_CONFIRM_DOWNLOAD "1"
+#define FOTA_ACTION_DOWNLOADING_USER_CLICK_CANCEL "2"
+//#define FOTA_UPDATE_VERSION "version"
+#define FOTA_UPGRADE_RESULT "upgrade_result"
+//#define FOTA_PACK_SIZE_INFO "pack_size_info"
+//#define FOTA_UPDATE_INFO "update_info"
+//#define FOTA_SETTINGS_INFO "GetUpgAutoSetting"
+//#define FOTA_NEW_VERSION_STATE "new_version_state"
+
+//NET
+#define HOSTANME "hostname"
+#define MAC "mac"
+#define ADDR "ip"
+#define DOMAIN "domain"
+#define MAC_ADDR "mac_addr"
+#define DEVICES "devices"
+#define SITELIST "siteList"
+#define CMD_LAN_STATION_LIST "lan_station_list"
+#define CMD_CHILDREN_DEVICE_LIST "childGroupList"
+#define CMD_WHITE_SITE_LIST "site_white_list"
+#define CMD_GET_USER_MAC_ADDR  "get_user_mac_addr"
+#define CMD_CURRENT_STATICADDR_LIST "current_static_addr_list"
+#define CMD_GET_POWERON_TIME     "get_poweron_time"
+#define CMD_GET_LAN_DEV_INFO     "get_lan_dev_info" //you wen ti
+#define CMD_GETDDNS_STATUS "getddns_status"
+#define CMD_USSD_DATA_INFO "ussd_data_info"
+#define CMD_GET_DEVICE_MODE  "get_device_mode"
+
+//SD
+#define STR_SDCARD_MODE_OPT "sdcard_mode_option"
+
+
+/*useradded module start*/
+#define CMD_GET_SAMPLE "station_list"
+/*useradded module end*/
+
+/****************************All the Goform ID************************************/
+
+//#define GOFORM_MGMT_SET_WEB_DATA "SET_WEB_DATA"
+//#define GOFORM_MGMT_GUEST_USER_CONTROL "GUEST_USER_CONTROL"
+#define GOFORM_MGMT_SET_EXTERNAL_NV  "SET_EXTERNAL_NV"
+/*management start*/
+#define GOFORM_MGMT_SET_WEB_LANGUAGE  "SET_WEB_LANGUAGE"
+#define GOFORM_MGMT_SET_DEVICEMODE "SET_DEVICE_MODE"
+#define GOFORM_MGMT_LOGIN_IP  "LOGIN"
+#define GOFORM_MGMT_LOGOUT_IP "LOGOUT"
+#define GOFORM_MGMT_CHANGE_PASSWORD  "CHANGE_PASSWORD"
+#define GOFORM_MGMT_CHANGE_ACCOUNT  "CHANGE_ACCOUNT"
+#define GOFORM_MGMT_RESTORE_FACTORY_SETTINGS  "RESTORE_FACTORY_SETTINGS"
+#define GOFORM_MGMT_REBOOT "REBOOT_DEVICE"
+#define GOFORM_MGMT_POWEROFF    "TURN_OFF_DEVICE"
+#define GOFORM_MGMT_POWER_ON_SPEED "MGMT_CONTROL_POWER_ON_SPEED"
+#define GOFORM_MGMT_QUICK_SETUP "QUICK_SETUP_EX"
+//#define GOFORM_SET_WORK_TYPE "SET_WORK_TYPE"
+#define GOFORM_MGMT_SNTP "SNTP"
+#define GOFORM_MGMT_SYSLOG  "SYSLOG"
+#define GOFORM_MGMT_SCHEDULE_SETTING "SCHEDULE_SETTING"
+//#define GOFORM_HTTP_REDIRECT "HTTP_REDIRECT"
+/*management end*/
+
+/*wan module start*/
+#define GOFORM_WAN_LOCK_FREQUENCY "LOCK_FREQUENCY"
+#define GOFORM_WAN_SET_NETWORK "SET_NETWORK"
+#define GOFORM_WAN_SET_CONNECTION_MODE "SET_CONNECTION_MODE"
+#define GOFORM_WAN_CONNECT_NETWORK "CONNECT_NETWORK"
+#define GOFORM_WAN_DISCONNECT_NETWORK "DISCONNECT_NETWORK"
+#define GOFORM_WAN_SCAN_NETWORK "SCAN_NETWORK"
+#define GOFORM_WAN_SET_BEARER_PREFERENCE "SET_BEARER_PREFERENCE"
+//#define GOFORM_WAN_SET_CONN_SETTING "SET_CONN_SETTING"
+//#define GOFORM_WAN_CANCEL_AUTO_RECONNECT "CANCEL_AUTO_RECONNECT"
+#define GOFORM_WAN_UNLOCK_NETWORK "UNLOCK_NETWORK"
+//statistics module
+#define GOFORM_WAN_RESET_DATA_COUNTER "RESET_DATA_COUNTER"
+#define GOFORM_WAN_DATA_LIMIT_SETTING "DATA_LIMIT_SETTING"
+#define GOFORM_WAN_DATA_FLOW_CALIBRATION_MANUAL "FLOW_CALIBRATION_MANUAL"
+#define GOFORM_SNTP_GETDATASTATIC  "SNTP_Getdatastatic"
+//pin,puk module
+#define GOFORM_MGMT_ENTER_PIN "ENTER_PIN"
+#define GOFORM_MGMT_DISABLE_PIN "DISABLE_PIN"
+#define GOFORM_MGMT_ENABLE_PIN "ENABLE_PIN"
+//#define GOFORM_MGMT_MODIFY_PIN "MODIFY_PIN"
+#define GOFORM_MGMT_ENTER_PUK "ENTER_PUK"
+#define GOFORM_MGMT_AUTO_PIN "AUTO_PIN"
+//pbm
+#define GOFORM_PBM_CONTACT_ADD "PBM_CONTACT_ADD"
+#define GOFORM_PBM_CONTACT_DEL "PBM_CONTACT_DEL"
+//sms module
+#define GOFORM_SMS_SET_MSG_CENTER  "SET_MESSAGE_CENTER"
+#define GOFORM_SMS_DELETE_SMS  "DELETE_SMS"
+#define GOFORM_SMS_DELETE_SMS_ALL  "ALL_DELETE_SMS"
+#define GOFORM_SMS_MOVE_TO_SIM  "MOVE_TO_SIM"
+#define GOFORM_SMS_SAVE_SMS  "SAVE_SMS"
+#define GOFORM_SMS_SEND_SMS  "SEND_SMS"
+#define GOFORM_SMS_SET_MSG_READ "SET_MSG_READ"
+//ussd module
+//#define GOFORM_USSD_SEND_CMD "SEND_USSD_CMD"
+#define GOFORM_USSD_PROCESS "USSD_PROCESS"
+//apn module
+#define GOFORM_WAN_APN_PROC_EX  "APN_PROC_EX"
+/*wan module end*/
+
+/*wifi module start*/
+#define GOFORM_WLAN_SET "SET_WIFI_INFO"
+//#define GOFORM_WIFI_SET_FOR_SLEEP "SET_WIFI_INFO_FOR_SLEEP"
+//#define GOFORM_SET_SHOW_SSID_KEY_OLED  "SET_SHOW_SSID_KEY_OLED"
+#define GOFORM_WLAN_MAC_FILTER "WIFI_MAC_FILTER"
+#define GOFORM_WLAN_WPS_SET "WIFI_WPS_SET"
+#define GOFORM_WLAN_SSID1_SET  "SET_WIFI_SSID1_SETTINGS"
+#define GOFORM_WLAN_SSID2_SET  "SET_WIFI_SSID2_SETTINGS"
+#define GOFORM_WLAN_WIFI_SLEEP_SET "SET_WIFI_SLEEP_INFO"
+#define GOFORM_WLAN_WIFI_COVERAGE_SET "SET_WIFI_COVERAGE"
+#define GOFORM_WLAN_SET_TSW "SAVE_TSW"
+#define GOFORM_PARENT_CONTROL_SET "SAVE_TIME_LIMITED"
+//wifi station start
+#define GOFORM_WLAN_WIFI_STA_CONTROL "WIFI_STA_CONTROL"
+#define GOFORM_WLAN_WIFI_SPOT_PROFILE_UPDATE "WIFI_SPOT_PROFILE_UPDATE"
+#define GOFORM_WLAN_SET_STA_CON "WLAN_SET_STA_CON"
+#define GOFORM_WLAN_SET_STA_DISCON "WLAN_SET_STA_DISCON"
+#define GOFORM_WLAN_SET_STA_REFRESH "WLAN_SET_STA_REFRESH"
+/*wifi module end*/
+
+/*router module start*/
+#define GOFORM_ROUTER_DEL_IP_PORT_FILETER "DEL_IP_PORT_FILETER"
+#define GOFORM_ROUTER_ADD_IP_PORT_FILETER_V4V6 "ADD_IP_PORT_FILETER_V4V6"//ÉèÖö˿ڹýÂËÐÅÏ¢
+#define GOFORM_ROUTER_DEL_IP_PORT_FILETER_V4V6 "DEL_IP_PORT_FILETER_V4V6"
+#define GOFORM_ROUTER_ADD_PORT_FORWARE "FW_FORWARD_ADD"
+#define GOFORM_ROUTER_DEL_PORT_FORWARE "FW_FORWARD_DEL"
+#define GOFORM_ROUTER_ADD_PORT_MAP "ADD_PORT_MAP"
+#define GOFORM_ROUTER_DEL_PORT_MAP "DEL_PORT_MAP"
+#define GOFORM_ROUTER_BASIC_SETTING "BASIC_SETTING"
+#define GOFORM_ROUTER_FORWARD_SETTING "VIRTUAL_SERVER"
+#define GOFORM_ROUTER_SYSTEM_SECURITY "FW_SYS"
+#define GOFORM_ROUTER_DHCP_SETTING "DHCP_SETTING"
+#define GOFORM_ROUTER_STATIC_DHCP_SETTING "STATIC_DHCP_SETTING"
+#define GOFORM_ROUTER_UPNP_SETTING  "UPNP_SETTING"
+#define GOFORM_ROUTER_DMZ_SETTING "DMZ_SETTING"
+#define GOFORM_ROUTER_EDIT_HOSTNAME "EDIT_HOSTNAME"
+#define GOFORM_BIND_STATIC_ADDRESS_SET "SET_BIND_STATIC_ADDRESS"
+#define GOFORM_BIND_STATIC_ADDRESS_ADD "BIND_STATIC_ADDRESS_ADD"
+#define GOFORM_BIND_STATIC_ADDRESS_DEL "BIND_STATIC_ADDRESS_DEL"
+#define GOFORM_ADD_CHILDREN_DEVICE "ADD_DEVICE"
+#define GOFORM_DEL_CHILDREN_DEVICE "DEL_DEVICE"
+#define GOFORM_ADD_WHITE_SITE "ADD_WHITE_SITE"
+#define GOFORM_REMOVE_WHITE_SITE "REMOVE_WHITE_SITE"
+#define GOFORM_URL_FILTER_DELETE "URL_FILTER_DELETE"
+#define GOFORM_URL_FILTER_ADD "URL_FILTER_ADD"
+#define GOFORM_DDNS "DDNS"
+//#define GOFORM_DNS_MODE_SET "SET_DNS_MODE"
+//#define GOFORM_DNS_SERVER_SET "SET_DNS_SERVER"
+
+// wan pppoe *
+#define GOFORM_SET_OPERATION_MODE    "OPERATION_MODE"
+//#define GOFORM_SET_WAN_GATEWAYMODE    "WAN_GATEWAYMODE"
+#define GOFORM_SET_WAN_GATEWAYMODE_PPPOE    "WAN_GATEWAYMODE_PPPOE"
+#define GOFORM_SET_WAN_GATEWAYMODE_DHCP    "WAN_GATEWAYMODE_DHCP"
+#define GOFORM_SET_WAN_GATEWAYMODE_STATIC    "WAN_GATEWAYMODE_STATIC"
+#define GOFORM_SET_WAN_GATEWAYMODE_AUTO    "WAN_GATEWAYMODE_AUTO"
+/*router module end*/
+
+/*httpShare module start*/
+#define GOFORM_HTTPSHARE_GETCARD_VAULE "HTTPSHARE_GETCARD_VALUE"
+#define GOFORM_HTTPSHARE_ENTERFOLD "HTTPSHARE_ENTERFOLD"
+#define GOFORM_HTTPSHARE_NEW "HTTPSHARE_NEW"
+#define GOFORM_HTTPSHARE_DEL "HTTPSHARE_DEL"
+#define GOFORM_HTTPSHARE_FILE_RENAME "HTTPSHARE_FILE_RENAME"
+#define GOFORM_HTTPSHARE_AUTH_SET "HTTPSHARE_AUTH_SET"
+#define GOFORM_HTTPSHARE_MODE_SET "HTTPSHARE_MODE_SET"
+#define GOFORM_HTTPSHARE_CHECK_FILE "GOFORM_HTTPSHARE_CHECK_FILE"
+#define CMD_HTTPSHARE_GETCARD_VAULE "HTTPSHARE_GETCARD_VALUE"
+#define CMD_HTTPSHARE_GETCARD_NMEA "HTTPSHARE_GETCARD_NAME"
+#define CMD_HTTPSHARE_AUTH_GET "HTTPSHARE_AUTH_GET"
+/*httpShare module end*/
+
+/*FOTA module start*/
+#define GOFORM_SET_FOTAAUTOUPDATE "IF_UPGRADE"
+#define GOFORM_SET_FOTASETTINGS "SetUpgAutoSetting"
+#define GOFORM_SET_FOTAMANUALUPG "SetUpgManualSetting"
+/*FOTA module end*/
+
+/*ping test*/
+#define GOFORM_PING_DIAGNOSTICS_START "PINT_DIAGNOSTICS_START"
+#define GOFORM_PING_DIAGNOSTICS_STOP "PINT_DIAGNOSTICS_STOP"
+/*ping test*/
+
+/*useradded module start*/
+#define GOFORM_SET_SAMPLE "GOFORM_SET_SAMPLE"
+/*useradded module end*/
+
+#define GOFORM_CWMP_SETTING "CWMP_SETTING"
+
+/****************************All the web pages' URL************************************/
+#define ZTE_WEB_PAGE_LOGIN_NAME   			"index.html"
+#define ZTE_WEB_MOBILE_PAGE_LOGIN_NAME      "mobile.html"
+
+#define ZTE_WEB_PAGE_MSG                	"/message.asp"
+#define ZTE_WEB_PAGE_NET_CONNECT       		"/air_network/net_connect.asp"
+#define ZTE_WEB_PAGE_PPP_CONNECTING  		"/air_network/pppconnect.asp"
+#define ZTE_WEB_PAGE_PPP_DISCONNECT  		"/air_network/pppdisconnect.asp"
+
+/*******************************************************************************
+ *                             Type definitions                                *
+ ******************************************************************************/
+/**
+ * @brief time
+ * @param sec second
+ * @param usec Microsecond
+ * @note
+ * @warning
+ */
+struct os_time {
+	long sec;
+	long usec;
+};
+
+
+/**
+ * @brief goform/cmd table's struct
+ * @param goform_id the message id extract from URL
+ * @param proc_func the handler of this goform_id
+ * @note
+ * @warning
+ */
+typedef struct web_goform_struct {
+	char goform_id[50];
+	void (*proc_func)(webs_t wp);
+} web_goform_type;
+
+/*******************************************************************************
+ *                       Global variable declarations                          *
+ ******************************************************************************/
+typedef enum _data_safe_result_type_t {
+	DATA_NO_SAFE = 0,
+	DATA_SAFE = 1
+} data_safe_result_type_t;
+
+typedef enum {
+	ZTE_NVIO_FAIL = 0,
+	ZTE_NVIO_DONE = 1,
+	ZTE_NVIO_BUSY = 2,
+	ZTE_NVIO_BADCMD = 3,
+	ZTE_NVIO_MAX
+} zte_topsw_state_e_type;
+
+
+
+/*******************************************************************************
+ *                       Global function declarations                          *
+ ******************************************************************************/
+/**
+* @brief Get current systime
+*
+* @param
+*
+* @return currentTime
+* @note
+* @warning
+*/
+int zte_web_getCurrentTime();
+
+/**
+* @brief the entry of zte code in goahead.
+*
+* @param
+*
+* @return currentTime
+* @note
+* @warning
+*/
+extern void zte_web_init();
+
+/**
+ * @brief Read the NV's value from the nv file.
+ *
+ * @param item  Pointer to the NV's name.
+ * @param data  Pointer to the NV's value.
+ * @param dataLen  data's length.
+ *
+ * @return zte_topsw_state_e_type result number
+ * @note
+ * @warning
+ */
+zte_topsw_state_e_type zte_nvconfig_read(char *item, char *data, int dataLen);
+
+/**
+* @brief Write the NV's name and value into the nv file.
+*
+* @param item  Pointer to the NV's name.
+* @param data  Pointer to the NV's value.
+* @param dataLen  data's length.
+*
+* @return zte_topsw_state_e_type result number
+* @note
+* @warning
+*/
+zte_topsw_state_e_type zte_nvconfig_write(char *item, char *data, int dataLen);
+
+/**
+* @brief goform entry from web pages to get fw para, call the related functions according to the cmd
+*
+* @param wp  HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+void zte_goform_get_cmd_process(webs_t wp, char *path, char *query);
+
+/**
+* @brief goform entry from web pages to set fw para, call the related functions according to the goformId
+*
+* @param wp  HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+void zte_goform_set_cmd_process(webs_t wp, char *path, char *query);
+
+/**
+* @brief Feed back web page at top location.
+*
+* @param i_wp HTTP Request Info.
+* @param i_pageName The page name.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_webs_feedback_top(webs_t i_wp, char *i_pageName);
+
+/**
+* @brief Check whether the login timeout.
+*
+* @param i_wp HTTP Request Info.
+* @param i_pageName The page name.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_mgmt_login_timeout_check();
+
+/**
+* @brief Send SMS.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_sms_send_msg_process(webs_t wp);
+
+/**
+* @brief Save SMS.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_sms_save_msg_process(webs_t wp);
+
+/**
+* @brief Delete message.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_sms_delete_msg_process(webs_t wp);
+
+/**
+* @brief Move message to SIM.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_sms_move_to_sim_msg_process(webs_t wp);
+
+/**
+* @brief Delete all messages.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_goform_sms_alldel_msg_process(webs_t wp);
+
+/**
+* @brief Set SMS related parameters.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_sms_set_message_center(webs_t wp);
+
+/**
+* @brief To set the viewed message as read.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_sms_view_msg_process(webs_t wp);
+
+/**
+* @brief Add new contact.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_goform_pbm_contact_add_process(webs_t wp);
+
+/**
+* @brief Delete contact.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_goform_pbm_contact_del_process(webs_t wp);
+
+/**
+* @brief Set WiFi basic parameter.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_basic_set(webs_t wp);
+
+/**
+* @brief Set WiFi MAC filter parameters.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_mac_filter_set(webs_t wp);
+
+/**
+* @brief Set WiFi WPS mode.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_wps_mode_set(webs_t wp);
+
+/**
+* @brief Set WiFi sleep and wake up at regular time.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_set_tsw(webs_t wp);
+
+/**
+* @brief Set WiFi SSID1 parameters.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_web_ssid1_set(webs_t wp);
+
+/**
+* @brief Set WiFi SSID2 parameters.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_ssid2_set(webs_t wp);
+
+/**
+* @brief To set the WiFi sleep mode.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_sleep_set(webs_t wp);
+
+/**
+* @brief Set WiFi coverage mode.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_coverage_set(webs_t wp);
+
+/**
+* @brief Set WiFi apstation parameters.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_station_set(webs_t wp);
+
+/**
+* @brief Update the wifi spot profile.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_station_spot_profile_update(webs_t wp);
+
+/**
+* @brief Connect to wifi spot.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_station_connect(webs_t wp);
+
+/**
+* @brief Disconnect wifi spot.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_station_disconnect(webs_t wp);
+
+/**
+* @brief Scan the wifi spot.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_station_refresh(webs_t wp);
+
+/**
+* @brief Get the wlan port's information.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_get_station_list(webs_t wp);
+extern void zte_wlan_get_wps_pin(webs_t wp);
+extern void zte_wlan_get_wps_defpin(webs_t wp);
+
+
+
+/**
+* @brief Register network after manual search.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wan_set_network(webs_t wp);
+
+/**
+* @brief Set connect mode.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wan_set_connection_mode(webs_t wp);
+
+/**
+* @brief Connect to the network.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wan_connect_network(webs_t wp);
+
+/**
+* @brief Disonnect the network.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wan_disconnect_network(webs_t wp);
+
+/**
+* @brief Scan the network.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wan_scan_network(webs_t wp);
+
+/**
+* @brief Set the mode of searching network.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wan_network_select(webs_t wp);
+
+/**
+* @brief Set the management of network flow.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wan_data_limit_setting(webs_t wp);
+
+/**
+* @brief Calibrate the network flow by manual.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wan_data_flow_calibration_manual(webs_t wp);
+
+
+/**
+* @brief Clear the network flow records.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wan_data_statistics_clear_process(webs_t wp, char_t *path, char_t *query);//11
+
+/**
+* @brief Init the httpshare.
+*
+* @param
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_httpshare_init();
+
+/**
+* @brief Get file list from httpshare's database.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_httpShare_enterFold(webs_t wp);
+
+/**
+* @brief Creat a new folder.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_httpShare_new(webs_t wp);
+
+/**
+* @brief Delete file or folder from SD card.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_httpShare_del(webs_t wp);
+
+/**
+* @brief Set the httpshare's configs.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_httpShare_auth_set(webs_t wp);
+
+/**
+* @brief Set the SD card's mode:usb mode or httpshare mode.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_httpShare_modeset(webs_t wp);
+
+/**
+* @brief Creat a new folder.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_httpShare_rename(webs_t wp);
+
+/**
+* @brief Check file exists.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_httpShare_check_file(webs_t wp);
+
+/**
+* @brief Get the httpshare's configs.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_httpShare_auth_get(webs_t wp);
+
+/**
+* @brief Get the SD card's name:"MicroSD Card".
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_httpShare_getcard_name(webs_t wp);
+
+/**
+* @brief Get the SD card's available capacity and total capacity.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_httpShare_getcard_value(webs_t wp);
+
+/**
+* @brief Ussd's operator process.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_goform_ussd_process(webs_t wp);
+
+/**
+* @brief Handle the auto or manual apn set for ipv4ipv6.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_form_multi_apn_proc_ex(webs_t wp);
+
+/**
+* @brief Set the user's selection:update or cancel.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_fota_update(webs_t wp);
+
+/**
+* @brief Set the fota's configs.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_fota_settings(webs_t wp);
+extern void zte_fota_manual_upgrade(webs_t wp);
+
+
+extern void zte_init_login_psw_time(void);
+extern int zte_apn_param_check(webs_t  wp, char * type);
+extern void zte_get_login_lock_time(webs_t wp);
+extern void zte_get_login_status_value(webs_t wp, char *login_status);
+extern void zte_get_ddns_status(webs_t wp);
+extern void zte_dhcpv6_state_set(webs_t wp);
+extern void zte_mtu_set(webs_t wp);
+extern void zte_dns_mode_set(webs_t wp);
+//extern void zte_dns_server_set(webs_t wp);
+extern void zte_ping_diagnostics_start(webs_t wp);
+extern void zte_ping_diagnostics_stop(webs_t wp);
+extern void zte_get_poweron_time(webs_t wp);
+extern void zte_get_lan_dev_info(webs_t wp);
+extern void zte_goform_set_external_nv(webs_t wp);
+extern void zte_goform_set_work_type(webs_t wp);
+
+//other sntp + fluxstat + parent_control_set
+extern void zte_goform_sntp_getdatastatic_process(webs_t wp);
+extern void zte_parent_control_set(webs_t wp);//parent mode time control
+
+/*useradded module start*/
+extern void zte_goform_set_sample(webs_t wp);
+/*useradded module end*/
+
+
+/**
+* @brief Data to be decoded.
+*
+* @param src Data to be decoded.
+* @param len Length of the data to be decoded.
+* @param out_len Pointer to output length variable.
+*
+* @return Allocated buffer of out_len bytes of decoded data,or NULL on failure
+* @note Caller is responsible for freeing the returned buffer.
+* @warning
+*/
+extern unsigned char * zte_base64_decode(const unsigned char *src, size_t len, size_t *out_len);
+#ifdef WEBS_SECURITY
+extern char *zte_base64_encode(const char *data, int data_len);
+#endif
+
+extern int zte_Safe_valid_SpecialChar(char single_data);
+extern int zte_Safe_valid_SpecialChar_other(char single_data);
+extern int zte_valid_length_str(char *string_s, int min, int max);
+
+extern data_safe_result_type_t zte_Safe_isMacValid(char *str);
+extern data_safe_result_type_t zte_Safe_isIpValid(char *str);
+extern data_safe_result_type_t zte_Safe_isNumOnly(char *str);
+extern data_safe_result_type_t zte_Safe_noSpecialChar(char *str);
+extern data_safe_result_type_t zte_Safe_noSpecialChar_other(char *str);
+extern data_safe_result_type_t zte_Safe_isStringOnly(char *str);
+extern data_safe_result_type_t zte_Safe_isNumorStringOnly(char *str);
+
+extern int web_set_pwd(char *buf);
+extern void web_init_pwd(void);
+extern int web_check_pwd(char* buf);
+
+extern int web_aes_init(void);
+
+#endif
+
diff --git a/lynq/S300/ap/app/goahead/interface5.0/zte_web_mgmt.c b/lynq/S300/ap/app/goahead/interface5.0/zte_web_mgmt.c
new file mode 100755
index 0000000..6109b9b
--- /dev/null
+++ b/lynq/S300/ap/app/goahead/interface5.0/zte_web_mgmt.c
@@ -0,0 +1,3923 @@
+/************************************************************************
+* °æÈ¨ËùÓÐ (C)2010, ÉîÛÚÊÐÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+*
+* ÎļþÃû³Æ£º zte_web_mgmt.c
+* Îļþ±êʶ£º
+* ÄÚÈÝÕªÒª£º
+* ÆäËü˵Ã÷£º
+* µ±Ç°°æ±¾£º V0.1
+* ×÷    Õߣº zyt
+* Íê³ÉÈÕÆÚ£º 2010-11-06
+*
+* Ð޸ļǼ1£º
+* ÐÞ¸ÄÄÚÈÝ£º³õʼ°æ±¾
+
+
+*  	ECµ¥ºÅ:EC616000235556  ¿ª·¢¹ÊÕÏ
+*   ¹ÊÕÏÖ÷Ìâ:¿ª»ú¸üÐÂʧ°ÜºóÁ¢¼´ÖØÆô£¬ÖØÆôºóÈÔÏÔʾ¸üÐÂʧ°ÜÎÊÌâ / Ôö¼Ówebui fota´¦Àílog
+*   ÐÞ¸Äʱ¼ä:20140715
+************************************************************************/
+#include <sys/time.h>
+#include <sys/types.h>
+#include <string.h>
+#include <pthread.h>
+#include <dirent.h>
+#include <stdlib.h>
+
+#include <signal.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+
+#include <openssl/aes.h>
+#include <curl/curl.h>
+
+#include "zte_web_interface.h"
+#include "zte_web_get_fw_para.h"
+#include "zte_web_mgmt_wifi.h"
+#include "fota_common.h"
+#include "nv_api.h"
+#include "libkey.h"
+
+/****************************************************************************
+* È«¾Ö±äÁ¿¶¨ÒåÇø
+****************************************************************************/
+/* password check result*/
+typedef enum _psw_check_result_type_t {
+	PSW_EMPTY = 0,
+	PSW_OK = 1,
+	PSW_TOO_LONG = 2,
+	PSW_TIME_OUT = 3,
+	PSW_OTHER = 4
+} psw_check_result_type_t;
+
+typedef enum {
+	PIN_MANAGE_DISABLE = 0,
+	PIN_MANAGE_ENABLE,
+	PIN_MANAGE_MODIFY
+} emPIN_MANAGE_ACTION;
+
+typedef struct UNLOCK_PARA {
+	char    unlock_code[20];
+} UNLOCK_PARA_ST;
+
+//quick setting
+typedef void (*funcWPType)(webs_t);
+
+pthread_mutex_t g_login_timemark_mutex = PTHREAD_MUTEX_INITIALIZER;
+#define TIME_SEM_KEY_1 0x0A2B
+#define TIME_SEM_KEY_2  0x3A4B
+
+//bsim
+typedef struct
+{
+	unsigned int pubKeyRsaE[32];
+	unsigned int pubKeyRsaN[32];
+	unsigned int secureFlag;
+	unsigned int pubKeyHash[4];
+	unsigned int secureDevId[3];
+}T_ZDrvEfuse_Secure;
+
+#define EFUSE_IOC_MAGIC 	'E'
+#define EFUSE_GET_DATA 		_IOWR(EFUSE_IOC_MAGIC, 1, char *)
+#define PPPOE_CODE_LEN 		32 //webui limit 30
+
+static unsigned char web_aes_key[16] = {0};
+
+#define APNCONFIG_NUM_MAX 10
+//bsim end
+
+/****************************************************************************
+* staticº¯ÊýÉùÃ÷Çø
+****************************************************************************/
+void deal_quick_setup_apn_ex(webs_t wp);
+void deal_quick_setup_wifi_basic(webs_t wp);
+void deal_quick_setup_wifi_security(webs_t wp);
+int zte_mgmt_handle_account(webs_t wp);
+void zte_setLastLoginTime();
+int zte_checkLoginTime();
+void zte_reduct_login_times();
+psw_check_result_type_t zte_password_check(webs_t wp, char* psw);
+static void wait_verify(char *wait_name, char *wait_value);
+static void zte_mgmt_enable_pin(webs_t wp, char_t *old_pin);
+static void zte_mgmt_modify_pin(webs_t wp, char_t *old_pin, char_t *new_pin);
+void deal_quick_setup_wifi_basic(webs_t wp);
+void deal_quick_setup_wifi_security(webs_t wp);
+static void deal_quick_setup_wps(webs_t wp);
+static char *split_str_by_sep(char *src, char *sep, char *dst, int len);
+static void set_apn_to_cfg(APN_PROFILE *apn_profile, IPV6_APN_PROFILE *ipv6_apn_profile);
+#ifdef WEBS_SECURITY
+static void js_aes_wifi_encode(void);
+#endif
+
+/* ¿ìËÙÉèÖà */
+const funcWPType G_ZQUICK_SET[MAX_QUICK_SET_NUM] = {
+	deal_quick_setup_apn_ex,
+	deal_quick_setup_wifi_basic,
+	deal_quick_setup_wifi_security,
+	zte_mgmt_handle_account,
+	quick_dhcp_set
+};
+
+/******************************************************
+* Function: void zte_mgmt_login(webs_t wp)
+* Description:  deal with the login goform
+* Input:  HTTP page info
+* Output:
+* Return:  none
+* Others:
+* Modify Date    Version   Author         Modification
+* 2010/11/26     V1.0      zyt            create
+*******************************************************/
+void zte_mgmt_login(webs_t wp)
+{
+	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User login!\n"));
+	char_t *psw = NULL;
+	char_t *user = NULL;
+	char_t  *save_flag = NULL;
+	char_t *ip_address = NULL;
+
+	int  user_name_len = 0;
+	char_t *pUser = NULL;
+	char user_name[CONFIG_DEFAULT_LENGTH] = {0};
+	int zte_password_len = 0;
+	char_t *zte_password = NULL;
+	char zte_psw_admin[CONFIG_DEFAULT_LENGTH] = {0};
+	psw_check_result_type_t psw_cheak_result = PSW_EMPTY;
+	char  buf[CONFIG_DEFAULT_LENGTH] = {0};
+
+	slog(MISC_PRINT, SLOG_DEBUG,"[login] zte_mgmt_login  enter====\n");
+	if (NULL == wp) {
+		slog(MISC_PRINT, SLOG_ERR,"[login] zte_mgmt_login: wp is null.");/*lint !e26*/
+		zte_write_result_to_web(wp, LOGIN_FAIL);
+		return;
+	}
+
+	psw = websGetVar(wp, T("password"), T(""));
+	user = websGetVar(wp, T("username"), NULL);
+
+	if ('\0' == (*psw)) {
+		slog(MISC_PRINT, SLOG_ERR,"[login] zte_mgmt_login: psw is empty.");/*lint !e26*/
+		zte_write_result_to_web(wp, LOGIN_FAIL);
+		return;
+	}
+
+	if (user != NULL) {
+		slog(MISC_PRINT, SLOG_DEBUG," zte_mgmt_login  user = %s\n", user);
+		pUser = (char *)zte_base64_decode((const unsigned char *)user, strlen(user), (unsigned int*)&user_name_len);
+		if (NULL == pUser) {
+			zte_write_result_to_web(wp, LOGIN_FAIL);
+			return;
+		}
+
+		//strncpy(user_name, pUser, user_name_len);
+		if(user_name_len < sizeof(user_name))
+			snprintf(user_name,user_name_len+1,"%s",pUser);
+		else
+			snprintf(user_name,sizeof(user_name),"%s",pUser);
+		free(pUser);
+
+		slog(MISC_PRINT, SLOG_DEBUG," zte_mgmt_login  user_name = %s\n", user_name);
+		cfg_get_item("admin_user", buf, sizeof(buf));
+		if (0 != strcmp(user_name, buf)) {
+			slog(MISC_PRINT, SLOG_ERR," zte_mgmt_login user_name fail \n");
+			zte_write_result_to_web(wp, LOGIN_USER_NAME_NOT_EXSIT);
+			return;
+		}
+		slog(MISC_PRINT, SLOG_DEBUG," zte_mgmt_login uername correct \n");
+	}
+	slog(MISC_PRINT, SLOG_DEBUG,"[login] login1 -> zte_password_encode:%s.\n", psw); /*lint !e26*/
+#ifdef WEBS_SECURITY
+	zte_password = js_aes_decode(psw, strlen(psw), (unsigned int*)&zte_password_len);
+#else
+	zte_password = (char *)zte_base64_decode((const unsigned char *)psw, strlen(psw), (unsigned int*)&zte_password_len);
+#endif
+	slog(MISC_PRINT, SLOG_DEBUG,"[login] login2 -> zte_password:%s.\n", zte_password); /*lint !e26*/
+
+	if (NULL == zte_password) {
+		slog(MISC_PRINT, SLOG_ERR,"[login] zte_mgmt_login: psw is empty.\n");/*lint !e26*/
+		zte_write_result_to_web(wp, LOGIN_FAIL);
+		return;
+	}
+	//zte_password will long than zte_password_len, then strncpy zte_password_len data to zte_psw_admin
+	if(zte_password_len < sizeof(zte_psw_admin))
+		snprintf(zte_psw_admin,zte_password_len+1,"%s",zte_password);
+	else
+		snprintf(zte_psw_admin,sizeof(zte_psw_admin),"%s",zte_password);
+	//strncpy(zte_psw_admin, zte_password, zte_password_len);
+	free(zte_password);
+	slog(MISC_PRINT, SLOG_DEBUG,"[login] login3 -> zte_psw_admin:%s.\n", zte_psw_admin); /*lint !e26*/
+	psw_cheak_result = zte_password_check(wp, zte_psw_admin);
+
+	if (psw_cheak_result != PSW_OK) {
+		slog(MISC_PRINT, SLOG_ERR,"[login] zte_mgmt_login psw_cheak_result != PSW_OK\n");
+		zte_write_result_to_web(wp, LOGIN_FAIL);
+		return;
+	}
+
+	//get request ip addr
+	ip_address = websGetRequestIpaddr(wp);
+#if 0 // kw 3	
+	if (NULL == ip_address) {
+		slog(MISC_PRINT, SLOG_ERR,"[login] zte_mgmt_login: ip_address is null.\n");/*lint !e26*/
+		zte_write_result_to_web(wp, LOGIN_FAIL);
+		return;
+	}
+#endif
+	//memset(&buf, 0, sizeof(buf));
+	//cfg_get_item("admin_Password", buf, sizeof(buf));
+	//if (0 == strcmp(zte_psw_admin, buf)) {
+	if (0 == web_check_pwd(zte_psw_admin)) {
+		save_flag = websGetVar(wp, T("save_login"), T(""));
+		if (('\0' != (*save_flag)) && (IFSTREQUAL("1", save_flag))) {
+			cfg_set("psw_save", zte_psw_admin);
+		}
+	} else {
+		zte_reduct_login_times();
+		slog(MISC_PRINT, SLOG_ERR,"[login] zte_mgmt_login: error pass.");/*lint !e26*/
+		zte_write_result_to_web(wp, LOGIN_BAD_PASSWORD);
+		security_log(MODULE_ID_WEB_CGI,"web login err pwd ip=%s",ip_address);
+		return;
+	}
+
+	if (zte_mgmt_login_timemark_set()) {
+		char id[COOKIE_SESSION_SIZE+1] = {0};
+		int ret = web_make_salt_base64(id, sizeof(id));
+		if(ret == 0)
+		{
+			slog(MISC_PRINT, SLOG_ERR,"[login] web_get_cookie_id fail\n");
+			zte_write_result_to_web(wp, LOGIN_FAIL);
+			return;
+		}
+		(void)zte_web_write(NV_USER_IP_ADDR, ip_address);
+		(void)zte_web_write(NV_LOGINFO, "ok");
+		(void)zte_web_write("save_login", save_flag);
+		(void)zte_web_write("psw_fail_num_str", LOGIN_FAIL_TIMES);
+		(void)zte_web_write(NV_COOKIE_ID, id);
+#ifdef WEBS_SECURITY
+		js_aes_wifi_encode();
+#endif
+		//zte_write_result_to_web(wp, LOGIN_SUCCESS);
+		websWrite(wp, T("HTTP/1.1 200 OK\n"));
+		websWrite(wp, T("Server: %s\r\n"), WEBS_NAME);
+#ifdef WEBINSPECT_FIX
+		websWrite(wp, T("X-Frame-Options: SAMEORIGIN\n"));
+#endif	
+		websWrite(wp, T("Pragma: no-cache\n"));
+		websWrite(wp, T("Cache-control: no-cache\n"));
+		websWrite(wp, T("Content-Type: text/html\n"));
+#ifdef WEBS_SECURITY
+		websWrite(wp, T("Expires: 0\n"));
+		if (websSSLIsOpen())
+			websWrite(wp, T("Set-Cookie: id=%s; secure; HttpOnly; SameSite=Lax;\n"),id);
+		else
+			websWrite(wp, T("Set-Cookie: id=%s; HttpOnly; SameSite=Lax;\n"),id);
+#endif		
+		websWrite(wp, T("\n"));
+		if (wp->flags & WEBS_XML_CLIENT_REQUEST) {
+			zte_rest_result_write(wp, LOGIN_SUCCESS);
+		} else {
+			websWrite(wp, T("{\"result\":\"%s\"}"), LOGIN_SUCCESS);
+		}
+		security_log(MODULE_ID_WEB_CGI,"web login suc ip=%s",ip_address);
+		return;
+	} else {
+		slog(MISC_PRINT, SLOG_ERR,"[login] zte_mgmt_login_timemark_set fail\n");
+		zte_write_result_to_web(wp, LOGIN_FAIL);
+		return;
+	}
+}
+/******************************************************
+* Function: int zte_mgmt_login_timemark_set()
+* Description:  save the setting operate time
+* Input:
+* Output:
+* Return:  none
+* Others:
+* Modify Date    Version   Author         Modification
+*******************************************************/
+int zte_mgmt_login_timemark_set()
+{
+	char_t login_timemark[NV_ITEM_STRING_LEN_64] = {0};
+	long timemark = 0;
+	int sem_id = -1;
+
+	int rc = TRUE;
+
+	sem_id = get_sem(TIME_SEM_KEY_2);
+	if (sem_id != -1) {
+		sem_p(sem_id);
+	}
+
+	timemark = time(0);
+	sprintf(login_timemark, "%ld", timemark);
+	if(ZTE_NVIO_DONE != zte_web_write(NV_USER_LOGIN_TIMEMARK, login_timemark))
+	{
+	    rc = FALSE; // kw 3
+	}
+
+	if (sem_id != -1) {
+		sem_v(sem_id);
+	}
+
+	return rc;
+}
+void zte_mgmt_login_timeout_check()
+{
+	char_t user_login_timemark[NV_ITEM_STRING_LEN_64] = {0};
+	char_t login_info[NV_ITEM_STRING_LEN_20] = {0};
+
+	long time_now = 0;
+	int sem_id = -1;
+	long luser_login_timemark = 0;
+
+	zte_web_read(NV_LOGINFO, login_info);
+
+	if (0 == strcmp(login_info, "ok")) {
+		zte_web_read(NV_USER_LOGIN_TIMEMARK, user_login_timemark);
+		luser_login_timemark =  atol(user_login_timemark);
+		if(luser_login_timemark < 0 || luser_login_timemark > LONG_MAX-1){
+            luser_login_timemark = LONG_MAX;
+			slog(MISC_PRINT, SLOG_DEBUG, "zte_mgmt_login_timemark_check: user_login_timemark is out of range [0, LONG_MAX).");
+		}
+
+		sem_id = get_sem(TIME_SEM_KEY_2);
+		if (sem_id != -1) {
+			sem_p(sem_id);
+		}
+		//timemark_check = time(0) - luser_login_timemark;
+		time_now = time(0);
+		if (sem_id != -1) {
+			sem_v(sem_id);
+		}
+
+		if ((time_now - luser_login_timemark) > LOGIN_TIMEOUT) {
+			slog(MISC_PRINT, SLOG_DEBUG, "zte_mgmt_login_timemark_check: the login is timeout .");
+			(void)zte_web_write(NV_USER_IP_ADDR, "");
+			(void)zte_web_write(NV_LOGINFO, "timeout");
+			(void)zte_web_write(NV_COOKIE_ID, "");
+			(void)zte_web_write(NV_WEB_TOKEN, "");
+			(void)zte_web_write(NV_USER_LOGIN_TIMEMARK, "0");
+			security_log(MODULE_ID_WEB_CGI,"web logout timeout");
+			return;
+		}
+#ifdef WEBS_SECURITY
+		static long time_update_token = 0;
+		if ((time_now - time_update_token) > COOKIE_TOKEN_TIMEOUT) {
+			time_update_token = time_now;
+			(void)zte_web_write(NV_WEB_TOKEN, "");
+		}
+#endif		
+	}
+
+}
+/******************************************************
+* Function: void zte_mgmt_logout(webs_t wp)
+* Description:  deal with the logout goform
+* Input:  HTTP page info
+* Output:
+* Return:  none
+* Others:
+* Modify Date    Version   Author         Modification
+* 2010/11/26     V1.0      zyt            create
+*******************************************************/
+void zte_mgmt_logout(webs_t wp)
+{
+	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User logout!\n"));
+
+	if (NULL == wp) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	cfg_set(NV_USER_IP_ADDR, "");
+	cfg_set(NV_LOGINFO, "");
+	cfg_set(NV_COOKIE_ID, "");
+	cfg_set(NV_WEB_TOKEN, "");
+	zte_write_result_to_web(wp, SUCCESS);
+	security_log(MODULE_ID_WEB_CGI,"web logout");
+}
+
+/******************************************************
+* Function: void zte_mgmt_set_language(webs_t wp)
+* Description:  deal with the set language goform
+* Input:  HTTP page info
+* Output:
+* Return:  none
+* Others:
+* Modify Date    Version   Author         Modification
+* 2010/11/26     V1.0      zyt              create
+*2012/09/14                  liuyingnan     modification
+*******************************************************/
+void zte_mgmt_set_language(webs_t wp)
+{
+	char_t* language = websGetVar(wp, T("Language"), T("en"));
+
+	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User set language!\n"));
+
+	cfg_set(NV_LANGUAGE, language);
+
+	cfg_save();
+	if ('\0' == (*language)) {
+		slog(MISC_PRINT, SLOG_ERR, "zte_mgmt_set_language: web para:[language] is empty string.\n"); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+
+	zte_write_result_to_web(wp, SUCCESS);
+	return;
+
+
+}
+
+
+/******************************************************
+* Function: void zte_mgmt_set_devicemode(webs_t wp)
+* Description:  user/develop mode switch
+* Input:  HTTP page info(debug_enable = 1 develop mode)
+* Output:
+* Return:  none
+* Others:
+* Modify Date    Version   Author         Modification
+* Feb 27, 2014    V1.0      jhy              create
+*******************************************************/
+void zte_mgmt_set_devicemode(webs_t wp)
+{
+	char_t* debug_enable = websGetVar(wp, T("debug_enable"), T(""));
+	char_t* auth = websGetVar(wp, T("auth"), T(""));
+
+	char strCfgGetItem[16] = {0};
+	nv_get_item(NV_RO, "usb_modetype", strCfgGetItem, sizeof(strCfgGetItem));
+
+	slog(MISC_PRINT, SLOG_NORMAL,"[goahead]debug_enable->%s current->%s\n", debug_enable, strCfgGetItem);
+	if((strcmp(strCfgGetItem,"user")== 0)&&(atoi(debug_enable) != 0))
+	{
+/*	 	if(verify_device_key(auth,strlen(auth),SEED,strlen(SEED)) != 1)
+	    {
+			slog(MISC_PRINT, SLOG_ERR, "zte_mgmt_set_devicemode: auth %s fail.\n",auth);
+			zte_write_result_to_web(wp, "set_devicemode fail:auth fail!");
+			return;
+	    }*/
+	}
+
+	if ('\0' == (*debug_enable)) {
+		slog(MISC_PRINT, SLOG_ERR, "zte_mgmt_set_devicemode: web para:[debug_enable] is empty string.\n");
+		zte_write_result_to_web(wp, "set_devicemode fail:parameter debug_enable is empty!");
+		return;
+	}
+
+	if (atoi(debug_enable) < 0 || atoi(debug_enable) > 3) {
+		slog(MISC_PRINT, SLOG_ERR, "zte_mgmt_set_devicemode: web para:[debug_enable] is illegal string.\n"); 
+		zte_write_result_to_web(wp, "set_devicemode fail:parameter debug_enable is illegal!");
+		return;
+	}
+    char ss[20] = {0};
+    unsigned char bootmode[] = {0x54,0x4D};
+	switch (atoi(debug_enable)) {
+	case 0:
+		slog(MISC_PRINT, SLOG_NORMAL,"[goahead]debug_enable->user\n");
+		nv_set_item(NV_RO, "usb_modetype", "user", 1);
+		bootmode[1] =0x00;
+		amt_set_bootmode(bootmode);
+		break;
+	case 1:
+		slog(MISC_PRINT, SLOG_NORMAL,"[goahead]debug_enable->debug\n");
+		nv_set_item(NV_RO, "usb_modetype", "debug", 1);
+		bootmode[1] =0x01;
+		amt_set_bootmode(bootmode);
+		break;
+	case 2:
+		slog(MISC_PRINT, SLOG_NORMAL,"[goahead]debug_enable->factory\n");
+		nv_set_item(NV_RO, "usb_modetype", "factory", 1);
+		bootmode[1] =0x02;
+		amt_set_bootmode(bootmode);
+		break;
+	case 3:
+		slog(MISC_PRINT, SLOG_NORMAL,"[goahead]debug_enable->amt\n");
+		//nv_set_item(NV_RO, "usb_modetype", "amt", 1);
+		amt_set_bootmode(bootmode);
+		break;
+	default:
+		slog(MISC_PRINT, SLOG_NORMAL,"[goahead]error!\n");
+		zte_write_result_to_web(wp, "set_devicemode fail:parameter debug_enable is illegal!");
+		return;;
+	}
+	nv_commit(NV_RO);////default_parameter_roÖеÄNV±£´æ±ØÐëÓÃnv_commit²»ÄÜÓÃcfg_save
+	zte_write_result_to_web(wp, "set_devicemode successfully!");
+
+}
+
+/******************************************************
+* Function: void zte_mgmt_restore(webs_t wp)
+* Description:  deal with the restore goform
+* Input:  HTTP page info
+* Output:
+* Return:  none
+* Others:
+* Modify Date    Version   Author         Modification
+* 2010/11/26     V1.0      zyt            create
+*******************************************************/
+void zte_mgmt_restore(webs_t wp)
+{
+	slog(MISC_PRINT, SLOG_NORMAL,"webui reset send message to blc\n");
+	ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_MAIN_CTRL, MSG_CMD_RESET_REQUEST, 0, NULL, 0);
+	system("sleep 2");//WH:delete?
+	zte_write_result_to_web(wp, SUCCESS);
+}
+
+
+/******************************************************
+* Function: void zte_mgmt_poweroff(webs_t wp)
+* Description:  deal with the poweroff goform
+* Input:  HTTP page info
+* Output:
+* Return:  none
+* Others:
+* Modify Date    Version   Author         Modification
+* 2015/5/26      V1.0      lsl            create
+*******************************************************/
+void zte_mgmt_poweroff(webs_t wp)
+{
+	zte_write_result_to_web(wp, SUCCESS);
+	slog(MISC_PRINT, SLOG_NORMAL,"webui poweroff send message to blc\n");
+	ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_MAIN_CTRL, MSG_CMD_POWEROFF_REQUEST, 0, NULL, 0);
+}
+
+/******************************************************
+* Function: void zte_mgmt_control_power_on_speed(webs_t wp)
+* Description:  deal with the power_on_speed goform
+* Input:  HTTP page info
+* Output:
+* Return:  none
+* Others:
+* Modify Date    Version   Author         Modification
+* 2015/5/26      V1.0      lsl            create
+*******************************************************/
+void zte_mgmt_control_power_on_speed(webs_t wp)
+{
+	char_t* mgmt_quicken_power_on = websGetVar(wp, T("mgmt_quicken_power_on"), T(""));
+
+	if ('\0' == (*mgmt_quicken_power_on)) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	} else if (strcmp(mgmt_quicken_power_on, "0") != 0 && strcmp(mgmt_quicken_power_on, "1") != 0) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	cfg_set("mgmt_quicken_power_on", mgmt_quicken_power_on);
+
+	zte_write_result_to_web(wp, SUCCESS);
+}
+
+/******************************************************
+* Function: void zte_goform_mgmt_reboot_process(webs_t wp)
+* Description:  deal with the restore goform
+* Input:  HTTP page info
+* Output:
+* Return:  none
+* Others:
+* Modify Date    Version   Author         Modification
+* 2010/11/26     V1.0      zyt            create
+*******************************************************/
+void zte_goform_mgmt_reboot_process(webs_t wp)
+{
+	MSG_BUF stMsg         = {0};
+	SINT32        iMsgSize      = sizeof(MSG_BUF) - sizeof(SINT32);
+	char buf[NV_ITEM_STRING_LEN_20] = {0};
+
+	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User reboot!\n"));
+	ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_MAIN_CTRL, MSG_CMD_RESTART_REQUEST, 0, NULL, 0);
+}
+
+
+void zte_goform_mgmt_syslog_process(webs_t wp)
+{
+	slog(MISC_PRINT, SLOG_DEBUG, "zte_goform_mgmt_syslog_process coming\n"); /*lint !e26*/
+	char_t *syslog_mode = NULL;
+	/* get value from web page */
+	syslog_mode = websGetVar(wp, T("syslog_mode"), T("all"));
+
+	char_t *syslog_flag = NULL;
+	/* get value from web page */
+	syslog_flag = websGetVar(wp, T("syslog_flag"), T("close"));
+
+	if (strcmp(syslog_flag, "close") == 0) {
+		cfg_set("debug_level", "0");
+		zte_write_result_to_web(wp, SUCCESS);
+	} else if (strcmp(syslog_flag, "delete") == 0) {
+		slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User delete syslog!\n"));
+		slog(MISC_PRINT, SLOG_DEBUG, "delete syslog====\n"); /*lint !e26*/
+		//system("cat /dev/null > /var/log/webshow_messages");
+		system("cat /dev/null > /usr/netlog/misc.log");
+		system("cat /dev/null > /etc_ro/web/webshow_messages");
+
+		zte_write_result_to_web(wp, SUCCESS);
+	} else {
+		//cfg_set("debug_level","7");/*added by jhy */
+		if (0 == strcmp("ufi", syslog_mode)) {
+			slog(MISC_PRINT, SLOG_DEBUG, "syslog_mode=====%s\n", syslog_mode); /*lint !e26*/
+			system("mkdir -p /etc_ro/web");
+			system("log.sh UFI");
+			cfg_set("syslog_mode", "ufi");
+		}/*added by jhy */
+		else if (0 == strcmp("wan_connect", syslog_mode)) {
+			slog(MISC_PRINT, SLOG_DEBUG, "syslog_mode=====%s\n", syslog_mode); /*lint !e26*/
+			system("log.sh wan_connect info");
+			cfg_set("syslog_mode", "wan_connect");
+		} else if (0 == strcmp("voip", syslog_mode)) {
+			slog(MISC_PRINT, SLOG_DEBUG, "syslog_mode=====%s\n", syslog_mode); /*lint !e26*/
+			system("log.sh voip info");
+			cfg_set("syslog_mode", "voip");
+		} else if (0 == strcmp("sms", syslog_mode)) {
+			slog(MISC_PRINT, SLOG_DEBUG, "syslog_mode=====%s\n", syslog_mode); /*lint !e26*/
+			system("log.sh sms info");
+			cfg_set("syslog_mode", "sms");
+		} else if (0 == strcmp("tr069", syslog_mode)) {
+			slog(MISC_PRINT, SLOG_DEBUG, "syslog_mode=====%s\n", syslog_mode); /*lint !e26*/
+			system("log.sh tr069 info");
+			cfg_set("syslog_mode", "tr069");
+		} else if (0 == strcmp("dlna", syslog_mode)) {
+			slog(MISC_PRINT, SLOG_DEBUG, "syslog_mode=====%s\n", syslog_mode); /*lint !e26*/
+			system("log.sh dlna info");
+			cfg_set("syslog_mode", "dlna");
+		} else if (0 == strcmp("wlan", syslog_mode)) {
+			slog(MISC_PRINT, SLOG_DEBUG, "syslog_mode=====%s\n", syslog_mode); /*lint !e26*/
+			system("log.sh wlan info");
+			cfg_set("syslog_mode", "wlan");
+		} else if (0 == strcmp("router", syslog_mode)) {
+			slog(MISC_PRINT, SLOG_DEBUG, "syslog_mode=====%s\n", syslog_mode); /*lint !e26*/
+			system("log.sh router info");
+			cfg_set("syslog_mode", "router");
+		} else {
+			slog(MISC_PRINT, SLOG_DEBUG, "syslog_mode=====%s\n", syslog_mode); /*lint !e26*/
+			system("log.sh all info");
+			cfg_set("syslog_mode", "all");
+		}
+
+		zte_write_result_to_web(wp, SUCCESS);
+	}
+
+}
+
+
+/******************************************************
+* Function: void zte_mgmt_change_password(webs_t wp)
+* Description:  deal with the user account modify goform
+* Input:  HTTP page info
+* Output:
+* Return:  none
+* Others:
+* Modify Date    Version   Author         Modification
+* 2010/11/26     V1.0      zyt            create
+*******************************************************/
+void zte_mgmt_change_password(webs_t wp)
+{
+	char_t *old_pass = NULL;
+	char_t *new_pass = NULL;
+	char_t *current_psw = NULL;
+	char_t *new_psw = NULL;
+	int current_psw_len = 0;
+	int new_psw_len = 0;
+	char new_psw_admin[CONFIG_DEFAULT_LENGTH] = {0};
+	char old_psw_admin[CONFIG_DEFAULT_LENGTH] = {0};
+	//char admin_psw_buf[CONFIG_DEFAULT_LENGTH] = {0};
+
+	old_pass = websGetVar(wp, T("oldPassword"), T(""));
+	new_pass = websGetVar(wp, T("newPassword"), T(""));
+
+	if (0 == strlen(old_pass) || 0 == strlen(new_pass)) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	slog(MISC_PRINT, SLOG_DEBUG, "user_modify:new_psw_encode:%s\n", new_pass); /*lint !e26*/
+#ifdef WEBS_SECURITY
+	current_psw = js_aes_decode(old_pass, strlen(old_pass), (unsigned int *)&current_psw_len);
+	new_psw = js_aes_decode(new_pass, strlen(new_pass), (unsigned int *)&new_psw_len);
+#else
+	current_psw = (char*)zte_base64_decode((const unsigned char *)old_pass, strlen(old_pass), (unsigned int *)&current_psw_len);
+	new_psw = (char*)zte_base64_decode((const unsigned char *)new_pass, strlen(new_pass), (unsigned int *)&new_psw_len);
+#endif
+
+	if (NULL == current_psw || NULL == new_psw) {
+		slog(MISC_PRINT, SLOG_ERR, "current_psw or new_psw is NULL\n"); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+		free(current_psw);
+		free(new_psw);
+		return;
+	}
+	slog(MISC_PRINT, SLOG_DEBUG, "user_modify:new_psw:%s\n", new_psw); /*lint !e26*/
+	slog(MISC_PRINT, SLOG_DEBUG, "user_modify:new_psw_len:%d\n", new_psw_len); /*lint !e26*/
+	if(current_psw_len < sizeof(old_psw_admin))
+		snprintf(old_psw_admin,current_psw_len+1,"%s",current_psw);
+	else
+		snprintf(old_psw_admin,sizeof(old_psw_admin),"%s",current_psw);
+	//strncpy(old_psw_admin, current_psw, CONFIG_DEFAULT_LENGTH-1);
+	if(new_psw_len < sizeof(new_psw_admin))
+		snprintf(new_psw_admin,new_psw_len+1,"%s",new_psw);
+	else
+		snprintf(new_psw_admin,sizeof(new_psw_admin),"%s",new_psw);
+	//strncpy(new_psw_admin, new_psw, CONFIG_DEFAULT_LENGTH-1);
+	free(current_psw);
+	free(new_psw);
+	slog(MISC_PRINT, SLOG_DEBUG, "user_modify:new_psw_admin:%s\n", new_psw_admin); /*lint !e26*/
+
+	if (LOGIN_PSW_MIN_LEN > new_psw_len || LOGIN_PSW_MAX_LEN < new_psw_len) {
+		slog(MISC_PRINT, SLOG_ERR, "new_psw_len is too long\n"); /*lint !e26*/
+		cfg_set("data_safe", "failed");
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+	if (DATA_NO_SAFE == zte_Safe_noSpecialChar(old_psw_admin)
+	    || DATA_NO_SAFE == zte_Safe_noSpecialChar(new_psw_admin)) {
+		slog(MISC_PRINT, SLOG_ERR, "Get Data is no Safe:old_pass:%s,new_pass:%s\n", old_psw_admin, new_psw_admin); /*lint !e26*/
+		cfg_set("data_safe", "failed");
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	//cfg_get_item("admin_Password", admin_psw_buf, sizeof(admin_psw_buf));
+	//if (0 != strcmp(old_psw_admin, admin_psw_buf)) {
+	if (0 != web_check_pwd(old_psw_admin)) {
+#ifdef WEBS_SECURITY
+		cfg_set(NV_USER_IP_ADDR, "");
+		cfg_set(NV_LOGINFO, "");
+		cfg_set(NV_COOKIE_ID, "");
+		cfg_set(NV_WEB_TOKEN, "");
+		security_log(MODULE_ID_WEB_CGI,"web changepwd fail logout");
+#endif		
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User change passwd!\n"));
+
+	//cfg_set("admin_Password", new_psw_admin);
+	web_set_pwd(new_psw_admin);
+	//cfg_set("user_save", "");
+	cfg_set("psw_save", "");
+	cfg_set("save_login", "");
+	cfg_set("psw_changed", "1");/*³õʼÃÜÂëÐ޸ıêʶ*/
+	cfg_save();
+/*
+	char cmd[82] = {0};
+	sprintf(cmd, "mksmbpasswd.sh \'%s\'", new_psw_admin);
+	system(cmd);
+	system("killall smbd");
+	system("killall nmbd");
+	system("smbd -D");
+	system("nmbd -D");
+*/	
+	zte_write_result_to_web(wp, SUCCESS);
+}
+
+int zte_mgmt_check_password(webs_t wp)
+{
+	char_t *tmp_old_psw = NULL;
+	char_t *old_psw = NULL;
+	int old_psw_len = 0;
+	char old_psw_admin[CONFIG_DEFAULT_LENGTH] = {0};
+	//char admin_psw_buf[CONFIG_DEFAULT_LENGTH] = {0};
+
+	tmp_old_psw = websGetVar(wp, T("oldPassword"), NULL);
+	if (NULL != tmp_old_psw) {
+		old_psw = (char*)zte_base64_decode((const unsigned char *)tmp_old_psw, strlen(tmp_old_psw), (unsigned int *)&old_psw_len);
+		if (NULL == old_psw) {
+			slog(MISC_PRINT, SLOG_DEBUG, "current_psw or new_psw is NULL\n"); /*lint !e26*/
+			return -1;
+		}
+		slog(MISC_PRINT, SLOG_NORMAL,"zte_mgmt_check_password  old_psw:%s!\n", old_psw);
+		if(old_psw_len < sizeof(old_psw_admin))
+			snprintf(old_psw_admin,old_psw_len+1,"%s",old_psw);
+		else
+			snprintf(old_psw_admin,sizeof(old_psw_admin),"%s",old_psw);
+		//strncpy(old_psw_admin, old_psw, CONFIG_DEFAULT_LENGTH-1);
+		free(old_psw);
+
+		if (DATA_NO_SAFE == zte_Safe_noSpecialChar(old_psw_admin)) {
+			slog(MISC_PRINT, SLOG_ERR,"zte_mgmt_check_password  old_psw_admin Get Data is no Safe!\n");
+			cfg_set("data_safe", "failed");
+			return -1;
+		}
+
+		//cfg_get_item("admin_Password", admin_psw_buf, sizeof(admin_psw_buf));
+		//if (0 != strcmp(old_psw_admin, admin_psw_buf)) {
+		if (0 != web_check_pwd(old_psw_admin)) {
+#ifdef WEBS_SECURITY
+			cfg_set(NV_USER_IP_ADDR, "");
+			cfg_set(NV_LOGINFO, "");
+			cfg_set(NV_COOKIE_ID, "");
+			cfg_set(NV_WEB_TOKEN, "");
+			security_log(MODULE_ID_WEB_CGI,"web checkpwd fail logout");
+#endif			
+			slog(MISC_PRINT, SLOG_ERR,"zte_mgmt_check_password  admin_Password fail!\n");
+			return -1;
+		}
+	}
+
+	return 0;
+}
+
+int zte_mgmt_handle_account(webs_t wp)
+{
+	char_t *tmp_new_user = NULL;
+	char_t *tmp_new_psw = NULL;
+	char_t *new_user = NULL;
+	char_t *new_psw = NULL;
+	int new_psw_len = 0;
+	int new_user_len = 0;
+	char new_user_admin[CONFIG_DEFAULT_LENGTH] = {0};
+	char new_psw_admin[CONFIG_DEFAULT_LENGTH] = {0};
+
+	tmp_new_psw = websGetVar(wp, T("newPassword"), NULL);
+	tmp_new_user = websGetVar(wp, T("newUserName"), NULL);
+
+	if (NULL == tmp_new_psw || NULL == tmp_new_user) {
+		return -1;
+	}
+
+	new_psw = (char*)zte_base64_decode((const unsigned char *)tmp_new_psw, strlen(tmp_new_psw), (unsigned int *)&new_psw_len);
+	if (NULL == new_psw) {
+		slog(MISC_PRINT, SLOG_ERR, "new_psw is NULL\n"); /*lint !e26*/
+		return -1;
+	}
+	new_user = (char*)zte_base64_decode((const unsigned char *)tmp_new_user, strlen(tmp_new_user), (unsigned int *)&new_user_len);
+
+	if (NULL == new_user) {
+		free(new_psw);
+		slog(MISC_PRINT, SLOG_ERR, "new_user is NULL\n"); /*lint !e26*/
+		return -1;
+	}
+
+	slog(MISC_PRINT, SLOG_DEBUG,"zte_mgmt_handle_account  new_psw:%s!\n", new_psw);
+	slog(MISC_PRINT, SLOG_DEBUG,"zte_mgmt_handle_account  new_user:%s!\n", new_user);
+	if(new_psw_len < sizeof(new_psw_admin))
+		snprintf(new_psw_admin,new_psw_len+1,"%s",new_psw);
+	else
+		snprintf(new_psw_admin,sizeof(new_psw_admin),"%s",new_psw);
+	//strncpy(new_psw_admin, new_psw, CONFIG_DEFAULT_LENGTH-1);
+	if(new_user_len < sizeof(new_user_admin))
+		snprintf(new_user_admin,new_user_len+1,"%s",new_psw);
+	else
+		snprintf(new_user_admin,sizeof(new_user_admin),"%s",new_psw);
+	//strncpy(new_user_admin, new_user, CONFIG_DEFAULT_LENGTH-1);
+	free(new_psw);
+	free(new_user);
+
+	if (LOGIN_PSW_MIN_LEN > new_psw_len || LOGIN_PSW_MAX_LEN < new_psw_len) {
+		slog(MISC_PRINT, SLOG_ERR,"zte_mgmt_handle_account  new_psw_len is too long!\n");
+		cfg_set("data_safe", "failed");
+		return -1;
+	}
+
+	if (LOGIN_PSW_MIN_LEN > new_user_len || LOGIN_PSW_MAX_LEN < new_user_len) {
+		slog(MISC_PRINT, SLOG_ERR,"zte_mgmt_handle_account  new_user_len is too long!\n");
+		cfg_set("data_safe", "failed");
+		return -1;
+	}
+
+	if (DATA_NO_SAFE == zte_Safe_noSpecialChar(new_psw_admin)
+	    || DATA_NO_SAFE == zte_Safe_noSpecialChar(new_user_admin)) {
+		slog(MISC_PRINT, SLOG_ERR,"zte_mgmt_handle_account  Get Data is no Safe!\n");
+		cfg_set("data_safe", "failed");
+		return -1;
+	}
+
+	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User change account!\n"));
+
+	cfg_set("admin_user", new_user_admin);
+	//cfg_set("admin_Password", new_psw_admin);
+	web_set_pwd(new_psw_admin);
+	//cfg_set("user_save", "");
+	cfg_set("psw_save", "");
+	cfg_set("save_login", "");
+	//cfg_save();
+/*
+	char cmd[82] = {0};
+	sprintf(cmd, "mksmbpasswd.sh \'%s\'", new_psw_admin);
+	system(cmd);
+	system("killall smbd");
+	system("killall nmbd");
+	system("smbd -D");
+	system("nmbd -D");
+*/	
+	slog(MISC_PRINT, SLOG_DEBUG,"zte_mgmt_handle_account  success!\n");
+	return 0;
+}
+
+void zte_mgmt_change_account(webs_t wp)
+{
+	slog(MISC_PRINT, SLOG_NORMAL,"zte_mgmt_change_account ====================!\n");
+
+	if (0 != zte_mgmt_check_password(wp)) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	if (0 != zte_mgmt_handle_account(wp)) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	zte_write_result_to_web(wp, SUCCESS);
+}
+
+
+/******************************************************
+* Function: void zte_mgmt_pin_input(webs_t wp)
+* Description:  deal with the pin code input goform
+* Input:  HTTP page info
+* Output:
+* Return:  none
+* Others:
+* Modify Date    Version   Author         Modification
+* 2010/11/26     V1.0      zyt            create
+*******************************************************/
+void zte_mgmt_pin_input(webs_t wp)
+{
+	char                *pPinCode   = NULL;
+	UINT32              length      = 0;
+	T_zAt_CpinPukSet    para        = {0};
+	UINT32              ret         = 0;
+	char                modem_main_state[NV_ITEM_STRING_LEN_50] = {0};
+
+	pPinCode    = websGetVar(wp, T("PinNumber"), T(""));
+	length      = strlen(pPinCode);
+	if (0 == length || length >= sizeof(para.pin)) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	strncpy(para.pin, pPinCode,sizeof(para.pin)-1);
+	cfg_set(NV_PIN_PUK_PROCESS, "begin");
+	ret = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_VERIFY_PIN_REQ, sizeof(T_zAt_CpinPukSet), (UCHAR *)&para, 0);
+	if (0 != ret) {
+		cfg_set(NV_PIN_PUK_PROCESS, "");
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	wait_verify(NV_PIN_PUK_PROCESS, "end");
+
+	(void)sleep(1);
+	(void)zte_web_read(NV_MODEM_MAIN_STATE, modem_main_state);
+
+	if (0 != strcmp(modem_main_state, "modem_waitpin")) {
+		zte_write_result_to_web(wp, SUCCESS);
+	} else {
+		zte_write_result_to_web(wp, FAILURE);
+	}
+}
+/******************************************************
+* Function: void zte_mgmt_puk_input(webs_t wp)
+* Description:  deal with the puk code input goform
+* Input:  HTTP page info
+* Output:
+* Return:  none
+* Others:
+* Modify Date    Version   Author         Modification
+* 2010/11/26     V1.0      zyt            create
+*******************************************************/
+void zte_mgmt_puk_input(webs_t wp)
+{
+	char                *pPukCode   = NULL;
+	char                *pNewPin    = NULL;
+	int                 length      = 0;
+	int                 ret         = 0;
+	T_zAt_CpinPukSet    para        = {0};
+	CHAR modem_main_state[NV_ITEM_STRING_LEN_50] = {0};
+
+	pPukCode    = websGetVar(wp, T("PUKNumber"), T(""));
+	pNewPin     = websGetVar(wp, T("PinNumber"), T(""));
+
+	length = strlen(pPukCode);
+	if (0 == length || length >= sizeof(para.pin)) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	length = strlen(pNewPin);
+	if (0 == length || length >= sizeof(para.newpin)) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	strncpy(para.pin, pPukCode,sizeof(para.pin)-1);
+	strncpy(para.newpin, pNewPin,sizeof(para.newpin)-1);
+	cfg_set(NV_PIN_PUK_PROCESS, "begin");
+	ret = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_VERIFY_PUK_REQ, sizeof(T_zAt_CpinPukSet), (UCHAR *)&para, 0);
+	if (0 != ret) {
+		cfg_set(NV_PIN_PUK_PROCESS, "");
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	wait_verify(NV_PIN_PUK_PROCESS, "end");
+
+	(void)sleep(1);
+	(void)zte_web_read("pinset_result", modem_main_state);
+
+	if (0 != strcmp(modem_main_state, "fail")) {
+		zte_write_result_to_web(wp, SUCCESS);
+	} else {
+		zte_write_result_to_web(wp, FAILURE);
+	}
+}
+
+void zte_mgmt_auto_pin(webs_t wp)
+{
+	char                *pPinEable   = NULL;
+	char                *pPinCode    = NULL;
+	int                 length      = 0;
+
+	pPinEable    = websGetVar(wp, T("auto_simpin"), T(""));
+	pPinCode     = websGetVar(wp, T("auto_simpin_code"), T(""));
+
+	length = strlen(pPinCode);
+	if (0 == length || length > 8) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	length = strlen(pPinEable);
+	if (1 != length) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	cfg_set("auto_simpin", pPinEable);
+	cfg_set("auto_simpin_code", pPinCode);
+	zte_write_result_to_web(wp, SUCCESS);
+
+}
+/******************************************************
+* Function: void zte_mgmt_unlock_network(webs_t wp)
+* Description:  deal with the unlock code input goform
+* Input:  HTTP page info
+* Output:
+* Return:  none
+* Others:
+* Modify Date    Version   Author         Modification
+* 2010/11/26     V1.0      zyt            create
+*******************************************************/
+void zte_mgmt_unlock_network(webs_t wp)
+{
+	char *unlock_code = NULL;
+	UNLOCK_PARA_ST para;
+	int length = 0;
+	int ret = 0;
+
+	memset(&para, 0, sizeof(UNLOCK_PARA_ST));
+
+	unlock_code = websGetVar(wp, T("unlock_network_code"), T(""));
+	slog(MISC_PRINT, SLOG_DEBUG, "unlock_code=%s", unlock_code); /*lint !e26*/
+	length = strlen(unlock_code);
+	if (0 == length || length >= sizeof(para.unlock_code)) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	strncpy(para.unlock_code, unlock_code,sizeof(para.unlock_code)-1);
+	ret = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_UNLOCK_REQ, sizeof(UNLOCK_PARA_ST), (UCHAR *)&para, 0);
+	if (0 != ret) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	wait_verify("unlock_at_wait", "0");
+	zte_write_result_to_web(wp, SUCCESS);
+}
+
+
+/*PINÂë½ûÓÃ*/
+void zte_mgmt_disable_pin(webs_t wp)
+{
+	char            *pOldPin    = NULL;
+	T_zAt_PinManage para        = {0};
+	int             length      = 0;
+	int             ret         = 0;
+	char            pin_manage_result[NV_ITEM_STRING_LEN_5] = {0};
+
+	pOldPin = websGetVar(wp, T("OldPinNumber"), T(""));
+	length = strlen(pOldPin);
+	if (0 == length || length >= sizeof(para.oldPin)) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+	strncpy(para.oldPin, pOldPin,sizeof(para.oldPin)-1);
+	para.action = PIN_MANAGE_DISABLE;
+
+	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User disable pin!\n"));
+
+	(void)zte_web_write("pin_manage_process", "begin");
+	slog(MISC_PRINT, SLOG_NORMAL, "zte_goform_mgmt_pin_mgmt_process send message: ZUFI_MODULE_ID_AT_MAIN, MSG_CMD_WEB_REQ_PIN_MANAGE");
+	ret = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_PIN_MANAGE_REQ, sizeof(T_zAt_PinManage), (UCHAR *)&para, 0);
+	if (0 != ret) {
+		cfg_set("pin_manage_process", "");
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	/*ÉèÖõȴýpinÂë¹ÜÀí¶¯×÷AT´¦Àí½áÊø*/
+	wait_verify("pin_manage_process", "end");
+
+	(void)zte_web_read("pin_manage_result", pin_manage_result);
+	(void)zte_web_write("pin_manage_result", "");
+
+	if (0 == strcmp(pin_manage_result, "0")) {
+		zte_write_result_to_web(wp, SUCCESS);
+	} else {
+		zte_write_result_to_web(wp, FAILURE);
+	}
+}
+
+/*PINÂëÆôÓûòÐÞ¸Ä*/
+void zte_mgmt_pin_enable_or_modify(webs_t wp)
+{
+	CHAR *pOldPin = NULL;
+	CHAR *pNewPin = NULL;
+
+	if (NULL == wp) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	pOldPin = websGetVar(wp, T("OldPinNumber"), T(""));
+	pNewPin = websGetVar(wp, T("NewPinNumber"), T(""));
+
+	slog(MISC_PRINT, SLOG_DEBUG, "web para:[OldPinNumber] is [%s].", pOldPin);
+	slog(MISC_PRINT, SLOG_DEBUG, "web para:[NewPinNumber] is [%s].", pNewPin);
+
+	if ('\0' == (*pOldPin)) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	if (0 == strcmp(pNewPin, "")) {
+		zte_mgmt_enable_pin(wp, pOldPin);
+	} else {
+		zte_mgmt_modify_pin(wp, pOldPin, pNewPin);
+	}
+
+
+}
+static void zte_mgmt_enable_pin(webs_t wp, CHAR *pOldPin)
+{
+	T_zAt_PinManage para                                    = {0};
+	int             ret                                     = 0;
+	char            pin_manage_result[NV_ITEM_STRING_LEN_5] = {0};
+
+
+	if ((NULL == wp) || (NULL == pOldPin)) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	strncpy(para.oldPin, pOldPin,sizeof(para.oldPin)-1);
+	para.action = PIN_MANAGE_ENABLE;
+	if ('\0' == (*pOldPin)) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User enable pin!\n"));
+
+	(void)zte_web_write("pin_manage_process", "begin");
+	slog(MISC_PRINT, SLOG_NORMAL, "zte_mgmt_enable_pin send message : ZUFI_MODULE_ID_AT_MAIN, MSG_CMD_WEB_REQ_PIN_MANAGE.");
+	ret = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_PIN_MANAGE_REQ, sizeof(T_zAt_PinManage), (UCHAR *)&para, 0);
+	if (0 != ret) {
+		cfg_set("pin_manage_process", "");
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	/*ÉèÖõȴýpinÂë¹ÜÀí¶¯×÷AT´¦Àí½áÊø*/
+	wait_verify("pin_manage_process", "end");
+
+	(void)zte_web_read("pin_manage_result", pin_manage_result);
+	(void)zte_web_write("pin_manage_result", "");
+
+	if (0 == strcmp(pin_manage_result, "0")) {
+		zte_write_result_to_web(wp, SUCCESS);
+	} else {
+		zte_write_result_to_web(wp, FAILURE);
+	}
+}
+
+/**********************************************************************
+* Function:         zte_mgmt_modify_pin
+* Description:      to modify pin
+* Input:           wp: the web para;old_pin: old pin number; new_pin:new pin number
+* Output:
+* Return:
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 2011/11/16    V1.0        chenyi       first version
+**********************************************************************/
+
+static void zte_mgmt_modify_pin(webs_t wp, CHAR *pOldPin, CHAR *pNewPin)
+{
+	int             length                                  = 0;
+	int             ret                                     = 0;
+	T_zAt_PinManage para                                    = {0};
+	char            pin_manage_result[NV_ITEM_STRING_LEN_5] = {0};
+
+	if ((NULL == wp) || (NULL == pOldPin) || (NULL == pNewPin)) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	if (('\0' == (*pOldPin)) || ('\0' == (*pNewPin))) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+	length = strlen(pNewPin);
+	if (0 == length || length >= sizeof(para.newPin)) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+
+	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User modify pin!\n"));
+
+	para.action = PIN_MANAGE_MODIFY;
+	strncpy(para.oldPin, pOldPin,sizeof(para.oldPin)-1);
+	strncpy(para.newPin, pNewPin,sizeof(para.newPin)-1);
+	(void)zte_web_write("pin_manage_process", "begin");
+	slog(MISC_PRINT, SLOG_NORMAL, "zte_mgmt_modify_pin send message : ZUFI_MODULE_ID_AT_MAIN, MSG_CMD_WEB_REQ_PIN_MANAGE.");
+	ret = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_PIN_MANAGE_REQ, sizeof(T_zAt_PinManage), (UCHAR *)&para, 0);
+	if (0 != ret) {
+		cfg_set("pin_manage_process", "");
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	/*ÉèÖõȴýpinÂë¹ÜÀí¶¯×÷AT´¦Àí½áÊø*/
+	wait_verify("pin_manage_process", "end");
+
+
+	(void)zte_web_read("pin_manage_result", pin_manage_result);
+	(void)zte_web_write("pin_manage_result", "");
+
+	if (0 == strcmp(pin_manage_result, "0")) {
+		zte_write_result_to_web(wp, SUCCESS);
+	} else {
+		zte_write_result_to_web(wp, FAILURE);
+	}
+}
+/******************************************************
+* Function: void zte_quick_setup(webs_t wp)
+* Description:  deal with the quick setup goform
+* Input:  HTTP page info
+* Output:
+* Return:  none
+* Others:
+* Modify Date    Version   Author         Modification
+* 2010/11/26     V1.0      zyt            create
+*******************************************************/
+void zte_quick_setup(webs_t wp)
+{
+	int iFunc = 0;
+
+	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User quick setup!\n"));
+
+	for (iFunc = 0; iFunc < MAX_QUICK_SET_NUM; iFunc++) {
+		if (G_ZQUICK_SET[iFunc] != NULL) {
+			G_ZQUICK_SET[iFunc](wp);
+		}
+	}
+	zte_write_result_to_web(wp, SUCCESS);
+}
+
+int save_data_to_file(char *file_path, unsigned char *data, int len)
+{
+	int file_fd = -1;
+	int ret  = -1;
+
+
+	if (NULL == file_path || NULL == data) {
+		slog(MISC_PRINT, SLOG_ERR,"Input para is invalid, null point!");
+		return -1;
+	}
+
+	// O_TRUNC:½«Îļþ³¤¶È½Ø¶ÏΪ0£¬×öΪÐÂÎļþдÈë
+	file_fd = open(file_path, O_RDWR | O_CREAT | O_TRUNC | O_SYNC, 777);
+	if (file_fd < 0) {
+		slog(MISC_PRINT, SLOG_ERR,"Open file fail, error:%s, file path:%s", strerror(errno), file_path);
+		return -1;
+	}
+
+	ret = write(file_fd, (void *)data, len);
+	if (ret != len) {
+		slog(MISC_PRINT, SLOG_ERR,"Write data to file fail, error:%s, file path:%s", strerror(errno), file_path);
+		goto error;
+	}
+
+	ret = fsync(file_fd);
+	if (ret < 0) {
+		slog(MISC_PRINT, SLOG_ERR,"Sync Failed:%s, file path:%s", strerror(errno), file_path);
+		goto error;
+	}
+
+
+	ret = 0;
+	goto end;
+
+error:
+	ret = -1;
+
+end:
+	close(file_fd);
+
+	file_fd = -1;
+
+	return ret;
+
+}
+
+void zte_goform_mgmt_schedule_setting_process(webs_t wp)
+{
+	char *schedule_enable = NULL;
+	char *schedule_hour = NULL;
+	char *schedule_minute = NULL;
+
+	schedule_enable = websGetVar(wp, T("scheduleEnabled"), T(""));
+
+	if(0 == strcmp("1", schedule_enable))
+	{
+		schedule_hour = websGetVar(wp, T("scheduleHour"), T(""));
+		schedule_minute = websGetVar(wp, T("scheduleMinute"), T(""));
+		cfg_set("schedule_restart_enable", schedule_enable);
+		cfg_set("schedule_restart_hour", schedule_hour);
+		cfg_set("schedule_restart_minute", schedule_minute);
+
+		zte_write_result_to_web(wp, SUCCESS);
+		return;
+	}
+	else if(0 == strcmp("0", schedule_enable))
+	{
+		cfg_set("schedule_restart_enable", schedule_enable);
+		cfg_set("schedule_restart_hour", "0");
+		cfg_set("schedule_restart_minute", "0");
+
+		zte_write_result_to_web(wp, SUCCESS);
+		return;
+	}
+
+	zte_write_result_to_web(wp, FAILURE);
+	return;
+}
+
+void zte_goform_mamt_cwmp_process(webs_t wp)
+{
+	char *cwmp_enable = NULL;
+	char *acs_url = NULL;
+	char *acs_username = NULL;
+	char *acs_password = NULL;
+	char *periodic_enable = NULL;
+	char *periodic_interval = NULL;
+	char *cpe_username = NULL;
+	char *cpe_password = NULL;
+
+	cwmp_enable = websGetVar(wp, T("cwmpEnabled"), T(""));
+
+	if(0 == strcmp("1", cwmp_enable))
+	{
+		acs_url = websGetVar(wp, T("acsUrl"), T(""));
+		acs_username = websGetVar(wp, T("acsUsername"), T(""));
+		acs_password = websGetVar(wp, T("acsPassword"), T(""));
+		periodic_enable = websGetVar(wp, T("periodicEnabled"), T(""));
+		if(0 == strcmp("1", periodic_enable))
+		{
+			periodic_interval = websGetVar(wp, T("periodicInterval"), T(""));
+			cfg_set("periodic_interval", periodic_interval);
+		}
+
+		cpe_username = websGetVar(wp, T("cpeUsername"), T(""));
+		cpe_password = websGetVar(wp, T("cpePassword"), T(""));
+
+		cfg_set("cwmp_enable", cwmp_enable);
+		cfg_set("acs_url", acs_url);
+		cfg_set("acs_username", acs_username);
+		cfg_set("acs_password", acs_password);
+		cfg_set("periodic_enable", periodic_enable);
+		cfg_set("cpe_username", cpe_username);
+		cfg_set("cpe_password", cpe_password);
+
+		system("killall cwmpd");
+		system("/bin/cwmpd &");
+		zte_write_result_to_web(wp, SUCCESS);
+	}
+	else if(0 == strcmp("0", cwmp_enable))
+	{
+		cfg_set("cwmp_enable", cwmp_enable);
+		cfg_set("acs_url", "");
+		cfg_set("acs_username", "");
+		cfg_set("acs_password", "");
+		cfg_set("periodic_enable", "");
+		cfg_set("periodic_interval", "300");
+		cfg_set("cpe_username", "");
+		cfg_set("cpe_password", "");
+		system("killall cwmpd");
+		zte_write_result_to_web(wp, SUCCESS);
+	}
+
+	cfg_save();
+}
+
+/******************************************************
+* Function: void zte_goform_mgmt_sntp_process(webs_t wp)
+* Description:  deal with the sntp
+* Input:  HTTP page info
+* Output:
+* Return:  none
+* Others:
+* Modify Date    Version   Author         Modification
+* 2011/04/13     V1.0      mengyuan            create
+*******************************************************/
+void zte_goform_mgmt_sntp_process(webs_t wp)
+{
+	MSG_BUF msg;
+	int lTgtMsgID = 0;
+	char *mode = NULL;
+	char *sntp_server0 = NULL;
+	char *sntp_server1 = NULL;
+	char *sntp_server2 = NULL;
+	char *sntp_timezone = NULL;
+	int result = 0;
+	LONG msgSize = sizeof(MSG_BUF) - sizeof(LONG);
+	char *ntp_server = NULL;
+	int sem_id = 0;
+	char state[NV_ITEM_STRING_LEN_20] = {0};
+	char sntp_timezone_tmp[NV_ITEM_STRING_LEN_64] = {0};
+	//char cmd[100] = {0};
+
+	memset(&msg, 1, sizeof(MSG_BUF));
+	mode = websGetVar(wp, T("manualsettime"), T(""));
+	cfg_set("sntp_time_set_mode", mode);
+
+	sntp_server0 = websGetVar(wp, T("sntp_server1_ip"), T(""));
+	sntp_server1 = websGetVar(wp, T("sntp_server2_ip"), T(""));
+	sntp_server2 = websGetVar(wp, T("sntp_server3_ip"), T(""));
+	cfg_set("sntp_server0", sntp_server0);
+	cfg_set("sntp_server1", sntp_server1);
+	cfg_set("sntp_server2", sntp_server2);
+
+
+	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User set sntp time!\n"));
+
+	if (strcmp(sntp_server0, "Other") == 0) {
+		cfg_set("sntp_other_server0", websGetVar(wp, T("sntp_other_server0"), T("")));
+	}
+	if (strcmp(sntp_server1, "Other") == 0) {
+		cfg_set("sntp_other_server1", websGetVar(wp, T("sntp_other_server1"), T("")));
+	}
+	if (strcmp(sntp_server2, "Other") == 0) {
+		cfg_set("sntp_other_server2", websGetVar(wp, T("sntp_other_server2"), T("")));
+	}
+	cfg_set("sntp_timezone_index", websGetVar(wp, T("sntp_timezone_index"), T("")));
+	//cfg_set("sntp_timezone", websGetVar(wp, T("timezone"), T("")));
+	cfg_set("sntp_dst_enable", websGetVar(wp, T("DaylightEnabled"), T("")));
+
+	cfg_set("manual_time_year", websGetVar(wp, T("time_year"), T("")));
+	cfg_set("manual_time_month", websGetVar(wp, T("time_month"), T("")));
+	cfg_set("manual_time_day", websGetVar(wp, T("time_day"), T("")));
+	cfg_set("manual_time_hour", websGetVar(wp, T("time_hour"), T("")));
+	cfg_set("manual_time_minute", websGetVar(wp, T("time_minute"), T("")));
+	cfg_set("manual_time_second", websGetVar(wp, T("time_second"), T("")));
+	//ÉèÖÃÊ±Çø
+	sntp_timezone = websGetVar(wp, T("timezone"), T(""));
+	cfg_set("sntp_timezone", sntp_timezone);
+
+	//memset(cmd, 0, 100);
+        //sprintf(cmd, "echo  \"%s\" > /etc_rw/TZ", sntp_timezone);
+    //system(cmd);
+    snprintf(sntp_timezone_tmp,sizeof(sntp_timezone_tmp),"%s\n",sntp_timezone);
+	save_data_to_file("/etc_rw/TZ",sntp_timezone_tmp,strlen(sntp_timezone_tmp));
+
+	if (strcmp(mode, "manual") == 0) {
+		sem_id = get_sem(TIME_SEM_KEY_1);
+		if (sem_id != -1) {
+			sem_p(sem_id);
+			slog(MISC_PRINT, SLOG_DEBUG,"[MANUAL] manual_set_time, sem_p, sem_id = %d\r\n", sem_id);
+		}
+
+		result = manual_set_time();
+
+		if (sem_id != -1) {
+			sem_v(sem_id);
+			slog(MISC_PRINT, SLOG_DEBUG,"[MANUAL] manual_set_time, sem_v, sem_id = %d\r\n", sem_id);
+		}
+
+		cfg_set("sntp_year", websGetVar(wp, T("time_year"), T("")));
+		cfg_set("sntp_month", websGetVar(wp, T("time_month"), T("")));
+		cfg_set("sntp_day", websGetVar(wp, T("time_day"), T("")));
+		cfg_set("sntp_hour", websGetVar(wp, T("time_hour"), T("")));
+		cfg_set("sntp_minute", websGetVar(wp, T("time_minute"), T("")));
+		cfg_set("sntp_second", websGetVar(wp, T("time_second"), T("")));
+		cfg_set("sntp_process_result", "success");
+		if (result < 0) {
+			zte_write_result_to_web(wp, FAILURE);
+		} else {
+			if (!zte_mgmt_login_timemark_set()) {
+				slog(MISC_PRINT, SLOG_ERR, "[ERROR]zte_goform_whitelist_check -> timemark set error .\n"); /*lint !e26*/
+			}
+			zte_write_result_to_web(wp, SUCCESS);
+		}
+	} else if (strcmp(mode, "auto") == 0) {
+		cfg_get_item("sntp_process_state", state, sizeof(state));
+		if (strcmp(state, "over") != 0) {
+			zte_write_result_to_web(wp, PROCESSING);
+			slog(MISC_PRINT, SLOG_DEBUG,"[SNTP] already runing return \n");
+			return;
+		}
+		cfg_set("sntp_process_state", "idle");
+		//cfg_set("systime_mode", "auto");
+		//cfg_set("sntp_cmd_from", "WEBUI");
+		cfg_set("sntp_process_result", "");
+		ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_SNTP, MSG_CMD_SNTP_START, 0, NULL, 0);
+		zte_write_result_to_web(wp, SUCCESS);
+	} else {
+		sem_id = get_sem(TIME_SEM_KEY_1);
+		if (sem_id != -1) {
+			sem_p(sem_id);
+			slog(MISC_PRINT, SLOG_DEBUG,"[MANUAL] manual_set_time, sem_p, sem_id = %d\r\n", sem_id);
+		}
+
+		result = manual_set_time();
+
+		if (sem_id != -1) {
+			sem_v(sem_id);
+			slog(MISC_PRINT, SLOG_DEBUG,"[MANUAL] manual_set_time, sem_v, sem_id = %d\r\n", sem_id);
+		}
+
+		cfg_set("sntp_year", websGetVar(wp, T("time_year"), T("")));
+		cfg_set("sntp_month", websGetVar(wp, T("time_month"), T("")));
+		cfg_set("sntp_day", websGetVar(wp, T("time_day"), T("")));
+		cfg_set("sntp_hour", websGetVar(wp, T("time_hour"), T("")));
+		cfg_set("sntp_minute", websGetVar(wp, T("time_minute"), T("")));
+		cfg_set("sntp_second", websGetVar(wp, T("time_second"), T("")));
+
+		if (result < 0) {
+			zte_write_result_to_web(wp, FAILURE);
+		} else {
+			if (!zte_mgmt_login_timemark_set()) {
+				slog(MISC_PRINT, SLOG_ERR, "[ERROR]zte_goform_whitelist_check -> timemark set error .\n"); /*lint !e26*/
+			}
+			zte_write_result_to_web(wp, SUCCESS);
+		}
+	}
+}
+
+static void wait_verify(char *wait_name, char *wait_value)
+{
+	int i = 0;
+	char buf[NV_ITEM_STRING_LEN_200] = {0};
+
+	if (NULL == wait_name || NULL == wait_value) {
+		return;
+	}
+
+	for (i = 0; i < 10; i++) {
+		sleep(2);
+		cfg_get_item(wait_name, buf, sizeof(buf));
+		if (0 == strcmp(wait_value, buf)) {
+			break;
+		}
+	}
+	return;
+}
+
+
+void deal_quick_setup_wifi_basic(webs_t wp)
+{
+	deal_quick_setup_wifi_basic_mgmt(wp);
+}
+static int deal_quick_setup_auto_apn_set()
+{
+	APN_PROFILE  newProfile = { 0 };
+	char ppp_status[NV_ITEM_STRING_LEN_50] = {0};
+
+	get_autoapn_profile(&newProfile);
+	set_apn_to_cfg(&newProfile, NULL);
+	cfg_set("ipv6_wan_apn", newProfile.apn_name); 
+
+	cfg_get_item("ppp_status", ppp_status, sizeof(ppp_status));
+	if (0 == strcmp("ppp_disconnected", ppp_status) || 0 == strcmp("ppp_ready", ppp_status)) {
+		ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_APN_SET_REQ, 0, NULL, 0);
+	}
+	return 0;
+}
+static void set_apn_to_cfg(APN_PROFILE *apn_profile, IPV6_APN_PROFILE *ipv6_apn_profile)
+{
+	if (apn_profile != NULL) {
+		cfg_set("m_profile_name", apn_profile->profile_name);
+		cfg_set("wan_apn", apn_profile->apn_name);
+		cfg_set("apn_select", apn_profile->apn_select);
+		cfg_set("wan_dial", apn_profile->dial_num);
+		cfg_set("ppp_auth_mode", apn_profile->ppp_auth_mode);
+		cfg_set("ppp_username", apn_profile->ppp_username);
+		cfg_set("ppp_passtmp", apn_profile->ppp_passwd);
+		cfg_set("pdp_type", apn_profile->pdp_type);
+		cfg_set("ipv6_pdp_type", apn_profile->pdp_type);
+		cfg_set("pdp_select", apn_profile->pdp_select);
+		cfg_set("pdp_addr", apn_profile->pdp_addr);
+		apn_encrypt_code();
+	}
+
+	if (ipv6_apn_profile != NULL) {
+		cfg_set("m_profile_name", ipv6_apn_profile->profile_name);
+		cfg_set("ipv6_wan_apn", ipv6_apn_profile->apn_name);
+		cfg_set("apn_select", ipv6_apn_profile->apn_select);
+		cfg_set("wan_dial", ipv6_apn_profile->dial_num);
+		cfg_set(NV_IPV6_PPP_AUTH_MODE, ipv6_apn_profile->ppp_auth_mode);
+		cfg_set("ipv6_ppp_username", ipv6_apn_profile->ppp_username);
+		cfg_set("ipv6_ppp_passtmp", ipv6_apn_profile->ppp_passwd);
+		cfg_set("pdp_type", ipv6_apn_profile->pdp_type);
+		cfg_set("ipv6_pdp_type", ipv6_apn_profile->pdp_type);
+		cfg_set("pdp_select", ipv6_apn_profile->pdp_select);
+		cfg_set("pdp_addr", ipv6_apn_profile->pdp_addr);
+		ipv6apn_encrypt_code();
+	}
+}
+
+
+static void deal_quick_setup_manual_apn_set(webs_t wp)
+{
+	IPV6_APN_PROFILE newIpv6Profile = { 0 };
+	APN_PROFILE      newProfile     = { 0 };
+	int              index_apn      = atoi(websGetVar(wp, "index", T("")));
+	char            *pdp_type       = websGetVar(wp, "pdp_type", T(""));
+	char            *apn_name      = websGetVar(wp, "wan_apn", T(""));
+	char            *ipv6_wan_apn      = websGetVar(wp, "ipv6_wan_apn", T(""));
+	char ppp_status[NV_ITEM_STRING_LEN_50] = {0};
+	char            *ppp_auth_mode      = websGetVar(wp, "ppp_auth_mode", T(""));
+	char            *ppp_username      = websGetVar(wp, "ppp_username", T(""));
+	char            *ppp_passwd      = websGetVar(wp, "ppp_passtmp", T(""));
+	char            *ipv6_pdp_auth_mode      = websGetVar(wp, NV_IPV6_PPP_AUTH_MODE, T(""));
+	char            *ipv6_ppp_username      = websGetVar(wp, "ipv6_ppp_username", T(""));
+	char            *ipv6_ppp_passwd      = websGetVar(wp, "ipv6_ppp_passtmp", T(""));
+
+	slog(MISC_PRINT, SLOG_NORMAL,"[goahead] deal_quick_setup_manual_apn_set wan_apn %s. %s.\n", apn_name,ppp_username);
+
+	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User manual apn set!\n"));
+	if (0 == strcmp(pdp_type, "IPv6")) {
+		get_ipv6apn_profile_by_index(index_apn, &newIpv6Profile);
+		strncpy(newIpv6Profile.apn_name, ipv6_wan_apn,sizeof(newIpv6Profile.apn_name)-1);
+		strncpy(newIpv6Profile.ppp_auth_mode, ipv6_pdp_auth_mode,sizeof(newIpv6Profile.ppp_auth_mode)-1);
+		strncpy(newIpv6Profile.ppp_username, ipv6_ppp_username,sizeof(newIpv6Profile.ppp_username)-1);
+		strncpy(newIpv6Profile.ppp_passwd, ipv6_ppp_passwd,sizeof(newIpv6Profile.ppp_passwd)-1);
+		set_ipv6_apn_profile_by_index(index_apn, &newIpv6Profile);
+		set_ipv6_apn_prof_aes_by_index(index_apn, &newIpv6Profile);
+
+		set_apn_to_cfg(NULL, &newIpv6Profile);
+	} else if (0 == strcmp(pdp_type, "IPv4v6")) {
+		get_ipv4v6apn_profile_by_index(index_apn, &newProfile, &newIpv6Profile);
+		strncpy(newProfile.apn_name, apn_name,sizeof(newProfile.apn_name)-1);
+		strncpy(newProfile.ppp_auth_mode, ppp_auth_mode,sizeof(newProfile.ppp_auth_mode)-1);
+		strncpy(newProfile.ppp_username, ppp_username,sizeof(newProfile.ppp_username)-1);
+		strncpy(newProfile.ppp_passwd, ppp_passwd,sizeof(newProfile.ppp_passwd)-1);
+
+		strncpy(newIpv6Profile.apn_name, ipv6_wan_apn,sizeof(newIpv6Profile.apn_name)-1);
+		strncpy(newIpv6Profile.ppp_auth_mode, ipv6_pdp_auth_mode,sizeof(newIpv6Profile.ppp_auth_mode)-1);
+		strncpy(newIpv6Profile.ppp_username, ipv6_ppp_username,sizeof(newIpv6Profile.ppp_username)-1);
+		strncpy(newIpv6Profile.ppp_passwd, ipv6_ppp_passwd,sizeof(newIpv6Profile.ppp_passwd)-1);
+		set_ipv4v6_apn_profile_by_index(index_apn, &newProfile, &newIpv6Profile);
+		set_ipv4v6_apn_prof_aes_by_index(index_apn, &newProfile, &newIpv6Profile);
+
+		set_apn_to_cfg(&newProfile, &newIpv6Profile);
+	} else {
+		get_apn_profile_by_index(index_apn, &newProfile);
+		strncpy(newProfile.apn_name, apn_name,sizeof(newProfile.apn_name)-1);
+		strncpy(newProfile.ppp_auth_mode, ppp_auth_mode,sizeof(newProfile.ppp_auth_mode)-1);
+		strncpy(newProfile.ppp_username, ppp_username,sizeof(newProfile.ppp_username)-1);
+		strncpy(newProfile.ppp_passwd, ppp_passwd,sizeof(newProfile.ppp_passwd)-1);
+		set_apn_profile_by_index(index_apn, &newProfile);
+		set_apn_prof_aes_by_index(index_apn, &newProfile);
+
+		set_apn_to_cfg(&newProfile, NULL);
+	}
+
+	cfg_get_item("ppp_status", ppp_status, sizeof(ppp_status));
+	if (0 == strcmp("ppp_disconnected", ppp_status) || 0 == strcmp("ppp_ready", ppp_status)) {
+		ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_APN_SET_REQ, 0, NULL, 0);
+	}
+}
+
+void deal_quick_setup_apn_ex(webs_t wp)
+{
+	if (strcmp(ZTE_WEB_ACT_MANUAL, websGetVar(wp, "apn_mode", T(""))) == 0) {
+		zte_web_write("apn_mode", ZTE_WEB_ACT_MANUAL);
+		deal_quick_setup_manual_apn_set(wp);
+	} else {
+		zte_web_write("apn_mode", ZTE_WEB_ACT_AUTO);
+		deal_quick_setup_auto_apn_set();  //  cov low, deal_quick_setup_auto_apn_set does not need parameter
+	}
+}
+
+void deal_quick_setup_wifi_security(webs_t wp)
+{
+	deal_quick_setup_wifi_security_mgmt(wp);
+}
+
+static void deal_quick_setup_wps(webs_t wp)
+{
+	deal_quick_setup_wps_mgmt(wp);
+}
+/******************************************************
+* Function: void get_apn_profile_by_index(int index, APN_PROFILE *profile)
+* Description:  get a apn profile by index from config
+* Input:  index:the index of apn profile which to get
+* Output: profile:the result of apn profile config after splited
+* Return:  none
+* Others:
+* Modify Date    Version   Author         Modification
+* 2010/11/26     V1.0      zyt            create
+*******************************************************/
+void get_apn_profile_by_index(int index, APN_PROFILE *profile)
+{
+	char cfg_name[PROFILE_MEMBER_LEN] = {0};
+	char cfg_value[APNCONFIG_MEMORY] = {0};
+	char *pos_begin = NULL;
+
+	if (NULL == profile) {
+		return;
+	}
+	//È¡Ã÷ÎÄAPN_configtmp,Õâʱ²»ÓÃÈ¡ÃÜÎÄ
+	sprintf(cfg_name, "APN_configtmp%d", index);
+
+	cfg_get_item(cfg_name, cfg_value, sizeof(cfg_value));
+	pos_begin = cfg_value;
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->profile_name, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->apn_name, PROFILE_APN_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->apn_select, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->dial_num, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_auth_mode, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_username, PROFILE_APN_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_passwd, PROFILE_APN_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_type, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_select, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_addr, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->dns_mode, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->prefer_dns_manual, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->standby_dns_manual, PROFILE_MEMBER_LEN);
+	return;
+}
+
+void get_ipv6apn_profile_by_index(int index, IPV6_APN_PROFILE *profile)
+{
+	char cfg_name[PROFILE_MEMBER_LEN] = {0};
+	char cfg_value[APNCONFIG_MEMORY] = {0};
+	char *pos_begin = NULL;
+
+	if (NULL == profile) {
+		return;
+	}
+
+	sprintf(cfg_name, "ipv6_APN_configtmp%d", index);
+
+	cfg_get_item(cfg_name, cfg_value, sizeof(cfg_value));
+	slog(MISC_PRINT, SLOG_DEBUG, "get_ipv6apn_profile_by_index  cfg_value=%s", cfg_value); /*lint !e26*/
+
+	pos_begin = cfg_value;
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->profile_name, PROFILE_MEMBER_LEN);
+	slog(MISC_PRINT, SLOG_DEBUG, "========= profile->profile_name=%s=======", profile->profile_name); /*lint !e26*/
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->apn_name, PROFILE_APN_LEN);
+	slog(MISC_PRINT, SLOG_DEBUG, "=========profile->apn_name=%s=======", profile->apn_name); /*lint !e26*/
+
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->apn_select, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->dial_num, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_auth_mode, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_username, PROFILE_APN_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_passwd, PROFILE_APN_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_type, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_select, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_addr, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->dns_mode, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->prefer_dns_manual, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->standby_dns_manual, PROFILE_MEMBER_LEN);
+	return;
+}
+
+
+void get_ipv4v6apn_profile_by_index(int index, APN_PROFILE *profile, IPV6_APN_PROFILE *ipv6profile)
+{
+	char cfg_name[PROFILE_MEMBER_LEN] = {0};
+	char cfg_value[APNCONFIG_MEMORY] = {0};
+	char *pos_begin = NULL;
+
+	char ipv6_cfg_name[PROFILE_MEMBER_LEN] = {0};
+	char ipv6_cfg_value[APNCONFIG_MEMORY] = {0};
+	char *ipv6_pos_begin = NULL;
+
+
+	if (NULL == profile) {
+		return;
+	}
+	if (NULL == ipv6profile) {
+		return;
+	}
+
+	sprintf(cfg_name, "APN_configtmp%d", index);
+	cfg_get_item(cfg_name, cfg_value, sizeof(cfg_value));
+	pos_begin = cfg_value;
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->profile_name, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->apn_name, PROFILE_APN_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->apn_select, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->dial_num, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_auth_mode, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_username, PROFILE_APN_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_passwd, PROFILE_APN_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_type, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_select, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_addr, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->dns_mode, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->prefer_dns_manual, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->standby_dns_manual, PROFILE_MEMBER_LEN);
+
+
+	sprintf(ipv6_cfg_name, "ipv6_APN_configtmp%d", index);
+	cfg_get_item(ipv6_cfg_name, ipv6_cfg_value, sizeof(ipv6_cfg_value));
+	ipv6_pos_begin = ipv6_cfg_value;
+	ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->profile_name, PROFILE_MEMBER_LEN);
+	ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->apn_name, PROFILE_APN_LEN);
+	ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->apn_select, PROFILE_MEMBER_LEN);
+	ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->dial_num, PROFILE_MEMBER_LEN);
+	ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->ppp_auth_mode, PROFILE_MEMBER_LEN);
+	ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->ppp_username, PROFILE_APN_LEN);
+	ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->ppp_passwd, PROFILE_APN_LEN);
+	ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->pdp_type, PROFILE_MEMBER_LEN);
+	ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->pdp_select, PROFILE_MEMBER_LEN);
+	ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->pdp_addr, PROFILE_MEMBER_LEN);
+	ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->dns_mode, PROFILE_MEMBER_LEN);
+	ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->prefer_dns_manual, PROFILE_MEMBER_LEN);
+	ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->standby_dns_manual, PROFILE_MEMBER_LEN);
+
+
+	return;
+}
+
+
+
+void get_autoapn_profile(APN_PROFILE *profile)
+{
+	char cfg_name[PROFILE_MEMBER_LEN] = {0};
+	char cfg_value[APNCONFIG_MEMORY] = {0};
+	char *pos_begin = NULL;
+	char buf[NV_ITEM_STRING_LEN_20] = {0};
+
+	int auto_apn_index = 0;
+	slog(MISC_PRINT, SLOG_DEBUG, "get_autoapn_profile\n"); /*lint !e26*/
+
+	cfg_get_item("auto_apn_index", buf, sizeof(buf));
+	auto_apn_index = atoi(buf);
+	slog(MISC_PRINT, SLOG_DEBUG, "auto_apn_index=%d\n", auto_apn_index); /*lint !e26*/
+	if (NULL == profile) {
+		return;
+	}
+
+	if (0 != auto_apn_index) {
+		sprintf(cfg_name, "apn_auto_config%d", auto_apn_index);
+	} else {
+		sprintf(cfg_name, "apn_auto_config");
+	}
+	slog(MISC_PRINT, SLOG_DEBUG, "cfg_name=%s\n", cfg_name); /*lint !e26*/
+
+	cfg_get_item(cfg_name, cfg_value, sizeof(cfg_value));
+	pos_begin = cfg_value;
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->profile_name, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->apn_name, PROFILE_APN_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->apn_select, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->dial_num, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_auth_mode, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_username, PROFILE_APN_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_passwd, PROFILE_APN_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_type, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_select, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_addr, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->dns_mode, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->prefer_dns_manual, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile->standby_dns_manual, PROFILE_MEMBER_LEN);
+	return;
+}
+
+/******************************************************
+* Function: void set_apn_profile_by_index(int index, APN_PROFILE *profile)
+* Description:  set a apn profile into config by index
+* Input:  index:the index of apn profile which to set
+*         profile:the struct of apn profile.
+* Output:
+* Return:  none
+* Others:
+* Modify Date    Version   Author         Modification
+* 2010/11/26     V1.0      zyt            create
+*******************************************************/
+void set_apn_profile_by_index(int index, APN_PROFILE *profile)
+{
+	char cfg_name[PROFILE_MEMBER_LEN] = {0};
+	char cfg_value[APNCONFIG_MEMORY] = {0};
+
+	if (NULL == profile) {
+		return;
+	}
+
+	sprintf(cfg_name, "APN_configtmp%d", index);
+	if (0 == strcmp(profile->pdp_type, "IPv6")) {
+		snprintf(cfg_value, APNCONFIG_MEMORY,
+		         "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+		         profile->profile_name,
+		         "",
+		         "",
+		         "",
+		         "",
+		         "",
+		         "",
+		         "",
+		         "",
+		         "",
+		         "",
+		         "",
+		         "");
+	} else {
+		snprintf(cfg_value, APNCONFIG_MEMORY,
+		         "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+		         profile->profile_name,
+		         profile->apn_name,
+		         profile->apn_select,
+		         profile->dial_num,
+		         profile->ppp_auth_mode,
+		         profile->ppp_username,
+		         profile->ppp_passwd,
+		         profile->pdp_type,
+		         profile->pdp_select,
+		         profile->pdp_addr,
+		         profile->dns_mode,
+		         profile->prefer_dns_manual,
+		         profile->standby_dns_manual);
+	}
+	cfg_set(cfg_name, cfg_value);
+
+	return;
+}
+
+void set_ipv6_apn_profile_by_index(int index, IPV6_APN_PROFILE *profile)
+{
+	char cfg_name[PROFILE_MEMBER_LEN] = {0};
+	char cfg_value[APNCONFIG_MEMORY] = {0};
+
+	if (NULL == profile) {
+		return;
+	}
+
+	sprintf(cfg_name, "ipv6_APN_configtmp%d", index);
+	if (0 == strcmp(profile->pdp_type, "IP")) {
+		slog(MISC_PRINT, SLOG_DEBUG, "pdp_type=IP  cpsnprintf "); /*lint !e26*/
+		snprintf(cfg_value, APNCONFIG_MEMORY,
+		         "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+		         profile->profile_name,
+		         "",
+		         "",
+		         "",
+		         "",
+		         "",
+		         "",
+		         "",
+		         "",
+		         "",
+		         "",
+		         "",
+		         "");
+	} else {
+		slog(MISC_PRINT, SLOG_DEBUG, "pdp_type=else  cpsnprintf "); /*lint !e26*/
+		slog(MISC_PRINT, SLOG_DEBUG, "profile->profile_name=%s ", profile->profile_name); /*lint !e26*/
+		snprintf(cfg_value, APNCONFIG_MEMORY,
+		         "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+		         profile->profile_name,
+		         profile->apn_name,
+		         profile->apn_select,
+		         profile->dial_num,
+		         profile->ppp_auth_mode,
+		         profile->ppp_username,
+		         profile->ppp_passwd,
+		         profile->pdp_type,
+		         profile->pdp_select,
+		         profile->pdp_addr,
+		         profile->dns_mode,
+		         profile->prefer_dns_manual,
+		         profile->standby_dns_manual);
+	}
+	slog(MISC_PRINT, SLOG_DEBUG, "cfg_value=%s", cfg_value); /*lint !e26*/
+	cfg_set(cfg_name, cfg_value);
+
+	return;
+}
+
+void set_ipv4v6_apn_profile_by_index(int index, APN_PROFILE *profile, IPV6_APN_PROFILE *ipv6profile)
+{
+	char cfg_name[PROFILE_MEMBER_LEN] = {0};
+	char cfg_value[APNCONFIG_MEMORY] = {0};
+
+	if (NULL == profile) {
+		return;
+	}
+
+	sprintf(cfg_name, "APN_configtmp%d", index);
+	snprintf(cfg_value, APNCONFIG_MEMORY,
+	         "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+	         profile->profile_name,
+	         profile->apn_name,
+	         profile->apn_select,
+	         profile->dial_num,
+	         profile->ppp_auth_mode,
+	         profile->ppp_username,
+	         profile->ppp_passwd,
+	         profile->pdp_type,
+	         profile->pdp_select,
+	         profile->pdp_addr,
+	         profile->dns_mode,
+	         profile->prefer_dns_manual,
+	         profile->standby_dns_manual);
+
+	cfg_set(cfg_name, cfg_value);
+
+	memset(cfg_name, 0, sizeof(cfg_name));
+	memset(cfg_value, 0, sizeof(cfg_value));
+	sprintf(cfg_name, "ipv6_APN_configtmp%d", index);
+	snprintf(cfg_value, APNCONFIG_MEMORY,
+	         "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+	         ipv6profile->profile_name,
+	         ipv6profile->apn_name,
+	         ipv6profile->apn_select,
+	         ipv6profile->dial_num,
+	         ipv6profile->ppp_auth_mode,
+	         ipv6profile->ppp_username,
+	         ipv6profile->ppp_passwd,
+	         ipv6profile->pdp_type,
+	         ipv6profile->pdp_select,
+	         ipv6profile->pdp_addr,
+	         ipv6profile->dns_mode,
+	         ipv6profile->prefer_dns_manual,
+	         ipv6profile->standby_dns_manual);
+
+	cfg_set(cfg_name, cfg_value);
+
+	return;
+}
+
+static char *split_str_by_sep(char *src, char *sep, char *dst, int len)
+{
+	char *pos_begin = NULL;
+	char *pos_end = NULL;
+
+	if (NULL == src || NULL == sep || NULL == dst || 0 == len) {
+		return NULL;
+	}
+
+	pos_begin = src;
+	pos_end = strstr(pos_begin, sep);
+
+	if (NULL == pos_end) {
+		return NULL;
+	}
+
+	if (len <= (pos_end - pos_begin)) {
+		return NULL;
+	}
+
+	strncpy(dst, pos_begin, pos_end - pos_begin);
+	pos_end += strlen(sep);
+	return pos_end;
+}
+
+void zte_mgmt_set_login_timemark()
+{
+	char login_timemark[NV_ITEM_STRING_LEN_20] = {0};
+	long now_timemark = time(0);
+
+	sprintf(login_timemark, "%ld", now_timemark);
+	zte_web_write(NV_USER_LOGIN_TIMEMARK, login_timemark);
+	slog(MISC_PRINT, SLOG_NORMAL,"[SNTP] [manual] timemark, user_login_timemark=%ld\n", now_timemark);
+}
+
+int manual_set_time()
+{
+	struct timeval tp;
+	time_t nowtime;
+	time_t SynBeforeTime = 0;
+	int ltime = 0, mtime = 0, ntime = 0;
+	char SynSystemTotal[16] = {0};
+	char SynPppTotal[16] = {0};
+	char SynSecond[16] = {0};
+	int year = 0, month = 0, day = 0;
+	int hour = 0, minute = 0, second = 0;
+	int days = 0;
+	int LeapYear = 0;
+	int CommonYear = 0;
+	int YearTotal = 0;
+	int count;
+	int flag = 0;
+	int i;
+	int ret = 0;
+	char buf[NV_ITEM_STRING_LEN_10] = {0};
+	char ppp_status[NV_ITEM_STRING_LEN_50] = {0};
+    struct tm timeToSet = {0};
+    int dataLen = 0;
+	cfg_get_item("manual_time_year", buf, sizeof(buf));
+	year = atoi(buf);
+	if(year < 1970 || year > 2100)//for kw
+	{
+		return -1;
+	}
+
+	memset(&buf, 0, sizeof(buf));
+	cfg_get_item("manual_time_month", buf, sizeof(buf));
+	month = atoi(buf);
+	if(month<1 || month>12)
+	{
+	    month = 1;
+	}
+
+	memset(&buf, 0, sizeof(buf));
+	cfg_get_item("manual_time_day", buf, sizeof(buf));
+	day = atoi(buf);
+	if(day<1 || day>31)
+	{
+	    day = 1;
+	}	
+
+	memset(&buf, 0, sizeof(buf));
+	cfg_get_item("manual_time_hour", buf, sizeof(buf));
+	hour = atoi(buf);
+	if(hour<0 || hour>24)
+	{
+	    hour = 0;
+	}	
+
+	memset(&buf, 0, sizeof(buf));
+	cfg_get_item("manual_time_minute", buf, sizeof(buf));
+	minute = atoi(buf);
+	if(minute<0 || minute>60)
+	{
+	    minute = 0;
+	}		
+
+	memset(&buf, 0, sizeof(buf));
+	cfg_get_item("manual_time_second", buf, sizeof(buf));
+	second = atoi(buf);
+	if(second<0 || second>60)
+	{
+	    second = 0;
+	}	
+
+	YearTotal = year - 1970;
+	for (count = 0; count < YearTotal; count++) {
+		i = 1971 + count;
+		if (i % 4 == 0 && i % 100 != 0) {
+			if (YearTotal == count + 1) {
+				CommonYear++;
+			} else {
+				LeapYear++;
+			}
+			continue;
+		} else if (i % 400 == 0) {
+			if (YearTotal == count + 1) {
+				CommonYear++;
+			} else {
+				LeapYear++;
+			}
+			continue;
+		} else {
+			CommonYear++;
+		}
+	}
+
+	/****************flag==1±íʾµ±ÄêΪÈòÄê*************************/
+	if (year % 4 == 0 && year % 100 != 0) {
+		flag = 1;
+	} else if (year % 400 == 0) {
+		flag = 1;
+	} else {
+		flag = 0;
+	}
+
+	switch (month - 1) {
+	case 0:
+		days = day;
+		break;
+	case 1:
+		days = 31 + day;
+		break;
+	case 2:
+		days = 31 + 28 + day;
+		break;
+	case 3:
+		days = 31 + 28 + 31 + day;
+		break;
+	case 4:
+		days = 31 + 28 + 31 + 30 + day;
+		break;
+	case 5:
+		days = 31 + 28 + 31 + 30 + 31 + day;
+		break;
+	case 6:
+		days = 31 + 28 + 31 + 30 + 31 + 30 + day;
+		break;
+	case 7:
+		days = 31 + 28 + 31 + 30 + 31 + 30 + 31 + day;
+		break;
+	case 8:
+		days = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + day;
+		break;
+	case 9:
+		days = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + day;
+		break;
+	case 10:
+		days = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + day;
+		break;
+	case 11:
+		days = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + day;
+		break;
+	}
+	if ((month - 1) >= 2 && 1 == flag) {
+		days++;
+	}
+
+
+	nowtime = COMMONYEARSEC * CommonYear + LEAPYEARSEC * LeapYear + (days - 1) * DAYSEC + hour * 3600 + minute * 60 + second;
+	tp.tv_usec = 0;
+	tp.tv_sec = nowtime;
+
+	time(&SynBeforeTime);
+	slog(MISC_PRINT, SLOG_DEBUG, "Now time  is %d", SynBeforeTime); /*lint !e26*/
+
+	cfg_get_item("syn_after_time", SynSecond, sizeof(SynSecond));
+	sscanf(SynSecond, "%d", &ltime);
+	if(ltime < 0 || ltime > INT_MAX-1)  // kw 3
+	{
+	    ltime = 0;
+	}	
+
+	cfg_get_item("syn_system_total", SynSystemTotal, sizeof(SynSystemTotal));
+
+	sscanf(SynSystemTotal, "%d", &mtime);
+	if(mtime < 0 || mtime > INT_MAX-1)  // kw 3
+	{
+	    mtime = 0;
+	}
+
+	if (0 != mtime) {
+		mtime += (SynBeforeTime - ltime);
+	} else {
+		mtime = (SynBeforeTime - JAN_2000);
+	}
+	sprintf(SynSystemTotal, "%d", mtime);
+	cfg_set("syn_system_total", SynSystemTotal);
+
+	cfg_get_item("ppp_status", ppp_status, sizeof(ppp_status));
+	if ((0 == strcmp(ppp_status, "ppp_connected")) || (0 == strcmp(ppp_status, "ipv6_connected")) || (0 == strcmp(ppp_status, "ipv4_ipv6_connected"))) {
+		cfg_get_item("syn_ppp_total", SynPppTotal, sizeof(SynPppTotal));
+
+		sscanf(SynPppTotal, "%d", &mtime);
+    	if(mtime < 0 || mtime >  INT_MAX-1)  // kw 3
+    	{
+    	    mtime = 0;
+    	}		
+		if (0 != mtime) {
+			mtime += (SynBeforeTime - ltime);
+		} else {
+			memset(&SynSecond, 0, sizeof(SynSecond));
+			cfg_get_item("ppp_start_time", SynSecond, sizeof(SynSecond));
+
+ 			sscanf(SynSecond, "%d", &ntime);
+        	if(ntime < 0 || ntime >  INT_MAX-1)  // kw 3
+        	{
+        	    ntime = 0;
+        	}	
+
+			mtime = SynBeforeTime - ntime;
+		}
+		sprintf(SynPppTotal, "%d", mtime);
+		cfg_set("syn_ppp_total", SynPppTotal);
+		cfg_set("syn_order_flag", "ppp_on");
+	} else {
+		cfg_set("syn_order_flag", "ppp_off");
+		cfg_set("syn_ppp_total", "0");
+	}
+
+    timeToSet.tm_year = year-1900;
+    timeToSet.tm_mon = month-1;
+    timeToSet.tm_mday = day;    
+    timeToSet.tm_hour = hour;
+    timeToSet.tm_min = minute; 
+    timeToSet.tm_sec = second; 
+    dataLen = sizeof(struct tm);
+    slog(MISC_PRINT, SLOG_DEBUG, "SetTime:year:%d, mon:%d, day:%d, hour:%d, min:%d, sec:%d \n", 
+            timeToSet.tm_year, timeToSet.tm_mon, timeToSet.tm_mday, 
+            timeToSet.tm_hour, timeToSet.tm_min, timeToSet.tm_sec );
+    ret = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_SNTP, MSG_CMD_SNTP_SET_TIME, 
+                                    dataLen, &timeToSet, 0);
+	if (0 != ret) {
+		slog(MISC_PRINT, SLOG_ERR, "send MSG_CMD_SNTP_SET_TIME to sntp fail!");
+	}
+
+	ret = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_SYCTIME_SET_REQ, 0, NULL, 0);
+	if (0 != ret) {
+		slog(MISC_PRINT, SLOG_ERR, "sync time to cp fail!");
+	}
+
+	memset(&buf, 0, sizeof(buf));
+	cfg_get_item("outdate_delete", buf, sizeof(buf));
+	if (0 == strcmp(buf, "1")) {
+		ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_SMS, MSG_CMD_SMS_OUTDATE_CHECK, 0, NULL, 0);
+	}
+
+	sprintf(SynSecond, "%d", (int)(time((time_t *)NULL)));
+	cfg_set("syn_after_time", SynSecond);
+	//cfg_set("systime_mode", "manual");
+	cfg_set("need_clear_traffic_data", "yes");
+	zte_mgmt_set_login_timemark();
+	return 0;
+}
+char * timei2s(int itime)
+{
+	static char buf[64];
+	int hours, min, sec;
+	memset(buf, 0, 64);
+
+	hours = itime / 3600;
+	min   = (itime / 60) % 60;
+	sec   = itime % 60;
+
+	sprintf(buf, "%d:%02d:%02d", hours, min, sec);
+	return buf ;
+}
+void timeen2ch(char *time)
+{
+	char timetmp[128] = {0};
+	char year[5] = {0};
+	char month[4] = {0};
+	char day[3] = {0};
+	char weekday[4] = {0};
+	char nowtime[16] = {0};
+	char hour[4] = {0};
+	char second[4] = {0};
+	char minute[4] = {0};
+	//int imonth;
+	char imonth[4] = {0};
+	strncpy(timetmp, time,sizeof(timetmp)-1);
+	char *loc = timetmp;
+	char *tmp = NULL;
+	memset(time, 0, 128);
+	char str_buf[10] = {0};
+	int temp;
+	int month_temp;
+
+	while (*loc == ' ') {
+		loc++;
+	}
+	tmp = strtok(loc, " ");
+	if(tmp == NULL) return;
+	strncpy(weekday, tmp, sizeof(weekday)-1);
+	tmp = strtok(NULL, " ");
+	if(tmp == NULL) return;
+	strncpy(month, tmp, sizeof(month)-1);
+	tmp = strtok(NULL, " ");
+	if(tmp == NULL) return;
+	strncpy(day, tmp, sizeof(day)-1);
+	slog(MISC_PRINT, SLOG_DEBUG, "strlen(tmp)=%d", strlen(tmp)); /*lint !e26*/
+	if (strlen(tmp) == 1) {
+		temp = atoi(tmp);
+		slog(MISC_PRINT, SLOG_DEBUG, "====temp=%d", temp); /*lint !e26*/
+		if(temp < 10 && temp > 0)
+			snprintf(day,sizeof(day), "0%d", temp);
+		slog(MISC_PRINT, SLOG_DEBUG, "====day=%s", day); /*lint !e26*/
+	} else {
+		strncpy(day, tmp,sizeof(day)-1);
+	}
+	tmp = strtok(NULL, " ");
+	if(tmp == NULL) return;
+	strncpy(nowtime, tmp, sizeof(nowtime)-1);
+	tmp = strtok(NULL, " ");
+	if(tmp == NULL) return;
+	strncpy(year, tmp, sizeof(year)-1);
+	if (0 == strcmp("Jan", month)) {
+		strncpy(imonth, "01", sizeof(imonth)-1);
+	} else if (0 == strcmp("Feb", month)) {
+		strncpy(imonth, "02", sizeof(imonth)-1);
+	} else if (0 == strcmp("Mar", month)) {
+		strncpy(imonth, "03", sizeof(imonth)-1);
+	} else if (0 == strcmp("Apr", month)) {
+		strncpy(imonth, "04", sizeof(imonth)-1);
+	} else if (0 == strcmp("May", month)) {
+		strncpy(imonth, "05", sizeof(imonth)-1);
+	} else if (0 == strcmp("Jun", month)) {
+		strncpy(imonth, "06", sizeof(imonth)-1);
+	} else if (0 == strcmp("Jul", month)) {
+		strncpy(imonth, "07", sizeof(imonth)-1);
+	} else if (0 == strcmp("Aug", month)) {
+		strncpy(imonth, "08", sizeof(imonth)-1);
+	} else if (0 == strcmp("Sep", month)) {
+		strncpy(imonth, "09", sizeof(imonth)-1);
+	} else if (0 == strcmp("Oct", month)) {
+		strncpy(imonth, "10", sizeof(imonth)-1);
+	} else if (0 == strcmp("Nov", month)) {
+		strncpy(imonth, "11", sizeof(imonth)-1);
+	} else if (0 == strcmp("Dec", month)) {
+		strncpy(imonth, "12", sizeof(imonth)-1);
+	}
+	sprintf(time, "%s-%s-%s&nbsp;&nbsp;&nbsp;%s", year, imonth, day, nowtime);
+	slog(MISC_PRINT, SLOG_DEBUG, "====nowtime=%s", nowtime); /*lint !e26*/
+
+
+	tmp = strtok(nowtime, ":");
+	if(tmp == NULL) return;
+	strncpy(hour, tmp,sizeof(hour)-1);
+	slog(MISC_PRINT, SLOG_DEBUG, "====hour=%s", hour); /*lint !e26*/
+	tmp = strtok(NULL, ":");
+	if(tmp == NULL) return;
+	strncpy(minute, tmp,sizeof(minute)-1);
+	slog(MISC_PRINT, SLOG_DEBUG, "====minute=%s", minute); /*lint !e26*/
+	tmp = strtok(NULL, ":");
+	if(tmp == NULL) return;
+	strncpy(second, tmp,sizeof(second)-1);
+	slog(MISC_PRINT, SLOG_DEBUG, "====second=%s", second); /*lint !e26*/
+	cfg_set("sntp_hour", hour);
+	cfg_set("sntp_minute", minute);
+	cfg_set("sntp_second", second);
+
+	cfg_set("sntp_year", year);
+	cfg_set("sntp_month", imonth);
+	cfg_set("sntp_day", day);
+}
+void datastatic(char *rec, char *send, char *onlinetime, char *runtime, char *localtime)
+{
+	char         Receive_Amount[20] = {0};
+	char		 Transmit_Amount[20] = {0};
+	char         syn_system_total[20] = {0};
+	char         syn_after_time[20] = {0};
+	char         syn_ppp_total[20] = {0};
+	char         ppp_start_time[20] = {0};
+	char		 timestr[128] = {0};
+	int  	     mtime;
+	int			 ltime;
+	int			 ntime;
+	int          otime;
+	time_t 		 timenow;
+	char  ppp_status[NV_ITEM_STRING_LEN_50] = {0};
+	char  buf[NV_ITEM_STRING_LEN_20] = {0};
+
+	cfg_get_item("syn_system_total", syn_system_total, sizeof(syn_system_total));
+
+	sscanf(syn_system_total, "%d", &ltime);
+    if(ltime < 0 || ltime >  INT_MAX-1)  // kw 3
+    {
+        ltime = 0;
+    }	
+	cfg_get_item("syn_after_time", syn_after_time, sizeof(syn_after_time));
+
+	sscanf(syn_after_time, "%d", &ntime);
+    if(ntime < 0 || ntime >  INT_MAX-1)  // kw 3
+    {
+        ntime = 0;
+    }		
+	cfg_get_item("ppp_start_time", ppp_start_time, sizeof(ppp_start_time));
+
+	sscanf(ppp_start_time, "%d", &otime);
+    if(otime < 0 || otime >  INT_MAX-1)  // kw 3
+    {
+        otime = 0;
+    }		
+
+	cfg_get_item("ppp_status", ppp_status, sizeof(ppp_status));
+	if ((0 != strcmp(ppp_status, "ppp_connected")) && (0 != strcmp(ppp_status, "ipv6_connected")) && (0 != strcmp(ppp_status, "ipv4_ipv6_connected"))) {
+		cfg_set("syn_ppp_total", "0");
+	}
+
+	cfg_get_item("syn_ppp_total", syn_ppp_total, sizeof(syn_ppp_total));
+
+	sscanf(syn_ppp_total, "%d", &mtime);
+    if(mtime < 0 || mtime >  INT_MAX-1)  // kw 3
+    {
+        mtime = 0;
+    }		
+
+	time(&timenow);
+	if (ntime == 0) {
+		strncpy(onlinetime, timei2s(timenow - otime), 63);
+		strncpy(runtime, timei2s(timenow - JAN_2000), 63);
+	} else {
+		cfg_get_item("syn_order_flag", buf, sizeof(buf));
+		if (0 == strcmp(buf, "ppp_on")) {
+			strncpy(onlinetime, timei2s(timenow - ntime + mtime), 63);
+		} else {
+			strncpy(onlinetime, timei2s(timenow - otime), 63);
+		}
+		strncpy(runtime, timei2s(timenow - ntime + ltime), 63);
+	}
+	slog(MISC_PRINT, SLOG_DEBUG, "----runtime=%s", runtime); /*lint !e26*/
+	strncpy(timestr, ctime(&timenow),sizeof(timestr)-1);
+	slog(MISC_PRINT, SLOG_DEBUG, "----timestr=%s", timestr); /*lint !e26*/
+	timeen2ch(timestr);
+	strncpy(localtime, timestr,sizeof(localtime)-1);
+	slog(MISC_PRINT, SLOG_DEBUG, "----localtime=%s", localtime); /*lint !e26*/
+
+}
+
+void zte_goform_sntp_getdatastatic_process(webs_t wp)
+{
+	char receive[30], send[30], onlinetime[64], runtime[64], localtime[128];
+
+	memset(receive, 0, 30);
+	memset(send, 0, 30);
+	memset(onlinetime, 0, 64);
+	memset(runtime, 0, 64);
+	memset(localtime, 0, 128);
+
+	datastatic(receive, send, onlinetime, runtime, localtime);
+
+	websWrite(wp, T("{\"receive\":\"%s\",\"send\":\"%s\",\"onlinetime\":\"%s\",\"runtime\":\"%s\",\"localtime\":\"%s\"}"), receive, send, onlinetime, runtime, localtime);
+}
+
+
+typedef struct LOG_FILES {
+	char filename[64];
+} LOG_FILES;
+
+int start_diaglog()
+{
+	int ret = 0;
+	slog(MISC_PRINT, SLOG_NORMAL, "start_diaglog"); /*lint !e26*/
+	system("/sbin/diaglog &");
+	return ret;
+}
+
+int stop_diaglog()
+{
+	int ret = 0;
+	slog(MISC_PRINT, SLOG_NORMAL, "get killall SIGINT"); /*lint !e26*/
+	system("killall -9 diaglog");//SIGINT=2
+	return ret;
+}
+#if 0
+int del_diaglog(char *fllename)
+{
+	slog(MISC_PRINT, SLOG_NORMAL, "del log name=%s", fllename); /*lint !e26*/
+	int ret = 0;
+	char cmd[128];
+	sprintf(cmd, "rm %s", fllename);
+	system(cmd);
+	return ret;
+}
+#endif
+
+int getDiaglogFile(LOG_FILES *files, int n_files)
+{
+	char ext[] = ".dlf";
+	int i = 0;
+
+	DIR *dp;
+	struct dirent *entry;
+
+	dp = opendir(DIAGLOG_DATA_PATH);
+	if (dp == NULL) {
+		slog(MISC_PRINT, SLOG_ERR, "dp==NULL");
+		return 0;
+	}
+
+	i = 0;
+	while ((entry = readdir(dp)) != NULL && (i < n_files)) {
+		{
+			int len = strlen(entry->d_name);
+			if ((len > strlen(ext)) && !strcmp(entry->d_name + len - strlen(ext), ext)) { //*.dlf *.zm
+				strncpy(files[i].filename, entry->d_name, sizeof(files[i].filename)-1);
+				slog(MISC_PRINT, SLOG_DEBUG, "entry->d_name=%s", entry->d_name);
+				i++;
+			}
+		}
+	}
+	closedir(dp);
+
+	return i;
+
+}
+
+
+void getdialog_url(int eid, webs_t wp, int argc, char_t **argv)
+{
+	char filename[128] = {0};
+	LOG_FILES files[10];
+	int n, i;
+	char *p = filename;
+	n = getDiaglogFile(files, 10);
+	i = 0;
+	if (n > 0) {
+		while (i < n) {
+			slog(MISC_PRINT, SLOG_DEBUG, "i=%d", i); /*lint !e26*/
+			strcpy(p, files[i].filename);
+			p += strlen(files[i].filename);
+			*p = ';';
+			p++;
+			slog(MISC_PRINT, SLOG_DEBUG, "filename=%s", files[i].filename); /*lint !e26*/
+			i++;
+		}
+		websWrite(wp, T(filename));
+	} else {
+		websWrite(wp, T(""));
+	}
+}
+
+/******************************************************
+* Function: zte_fota_get_upgrade_result
+* Description: get fota upgrade result
+* Input:  http request info
+* Output:
+* Return:
+* Others:
+* Modify Date    Version   Author         Modification
+* 2013/03/14        V1.0     chenyi        create
+*******************************************************/
+void zte_fota_get_upgrade_result(webs_t wp)
+{
+	zte_topsw_state_e_type nv_result = ZTE_NVIO_MAX;
+
+	char nv_upgrade_result[NV_ITEM_STRING_LEN_50] = {0};
+
+	nv_result = zte_web_read(NV_FOTA_UPGRADE_RESULT, nv_upgrade_result);
+	if (ZTE_NVIO_DONE != nv_result) {
+		slog(MISC_PRINT, SLOG_ERR,"read nv [%s] fail.\n", NV_FOTA_UPGRADE_RESULT);
+	}
+
+	web_feedback_header(wp);
+	(void)websWrite(wp, T("{\"%s\":\"%s\"}"), FOTA_UPGRADE_RESULT, nv_upgrade_result);
+
+	if ((0 == strcmp("success", nv_upgrade_result)) || (0 == strcmp("fail", nv_upgrade_result))) {
+		(void)zte_web_write(NV_FOTA_UPGRADE_RESULT, ""); //reset
+
+		// ÖØÖÃNVºó±£´æ¸ÃNV²ÎÊý£¬±ÜÃâÒò¿ìËÙÖØÆô£¬NVÐÂֵδ±£´æµ¼Öµĸüнá¹ûÖØ¸´Éϱ¨ÎÊÌâ
+		//cfg_save();
+	    slog(MISC_PRINT, SLOG_ERR,"reset nv [%s]. nv_upgrade_result:%s\n", NV_FOTA_UPGRADE_RESULT, nv_upgrade_result);
+	}
+}
+
+#if 0
+/******************************************************
+* Function: zte_fota_get_dp_pack_info
+* Description: get fota dp info
+* Input:  http request info
+* Output:
+* Return:
+* Others:
+* Modify Date    Version   Author         Modification
+* 2013/01/06        V1.0     chenyi        create
+*******************************************************/
+void zte_fota_get_dp_pack_info(webs_t wp)
+{
+	char dp_total_size[NV_ITEM_STRING_LEN_50] = {0};
+	char dp_download_size[NV_ITEM_STRING_LEN_50] = {0};
+
+	//get dp pack info
+	(void)zte_web_read(NV_FOTA_PKG_TOTAL_SIZE, dp_total_size);
+	(void)zte_web_read(NV_FOTA_PKG_DL_SIZE, dp_download_size);
+
+	web_feedback_header(wp);
+	(void)websWrite(wp, T("{\"%s\":\"%s\",\"%s\":\"%s\"}"), \
+	                NV_FOTA_PKG_TOTAL_SIZE, dp_total_size, NV_FOTA_PKG_DL_SIZE, dp_download_size);
+}
+#endif
+/**********************************************************************
+* Function:         zte_fota_update
+* Description:      send msg to fota update module
+* Input:            wp:the web para;
+* Output:
+* Return:
+* Others:         add from uFi
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+*
+**********************************************************************/
+int zte_fota_SendMsg2DM(int cmd)
+{
+	slog(MISC_PRINT, SLOG_NORMAL,"goahead  send cmd=%d to fota\n", cmd);
+	return ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_DM_WEBUI_AT, cmd, 0, NULL,  0);
+}
+
+void zte_fota_update(webs_t wp)
+{
+	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User check new version!\n"));
+	char *update_action = NULL;
+	zte_topsw_state_e_type nv_result = ZTE_NVIO_MAX;
+	char new_version_state[NV_ITEM_STRING_LEN_150] = {0};
+	BOOL new_state_version_check = FALSE;
+	int iDlPara = -1;
+
+	if (NULL == wp) {
+		return;
+	}
+
+	update_action = websGetVar(wp, T("select_op"), T(""));
+	slog(MISC_PRINT, SLOG_DEBUG,"websGetVar FOTA upgrade action[%s].\n", update_action);
+
+	if ('\0' == *update_action) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+
+	//ÓëdeviceUiµÄ»¥³â±£»¤´¦Àí
+	zte_web_read(NV_FOTA_NEW_VERSION_STATE, new_version_state);
+
+	if ((0 == strcmp(update_action, FOTA_ACTION_CONFIRM_DOWNLOAD)) || (0 == strcmp(update_action, FOTA_ACTION_CANCEL_DOWNLOAD))) {
+		if ((0 == strcmp(new_version_state, HAS_OPTIONAL)) || (0 == strcmp(new_version_state, HAS_CRITICAL))) {
+			new_state_version_check = TRUE;
+		}
+		if (!new_state_version_check) {
+			zte_write_result_to_web(wp, FAILURE);
+			return;
+		}
+	}
+
+	if (0 == strcmp(update_action, FOTA_ACTION_CONFIRM_DOWNLOAD)) {
+		zte_web_write(NV_FOTA_UPGRADE_SELECTOR, "accept");
+		//zte_web_write(NV_FOTA_NEED_USER_CONFIRM,"0");
+		slog(MISC_PRINT, SLOG_DEBUG,"web :zte_fota_update. update_action = FOTA_ACTION_CONFIRM_DOWNLOAD, set NV_FOTA_UPGRADE_SELECTOR accept!\n");
+		//zte_fota_SendMsg2DM(MSG_CMD_FOTA_WEBUI_START_DOWNLOAD);
+		//ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_DM_WEBUI_AT,MSG_CMD_FOTA_WEBUI_START_DOWNLOAD, 2, "1", 0);
+		iDlPara = 1;
+		ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_DM_WEBUI_AT, MSG_CMD_FOTADL_REQ, sizeof(iDlPara), (UCHAR *)(&iDlPara), 0);
+	} else if (0 == strcmp(update_action, FOTA_ACTION_CANCEL_DOWNLOAD)) {
+		(void)zte_web_write(NV_FOTA_UPGRADE_SELECTOR, "cancel");
+		zte_web_write(NV_FOTA_NEW_VERSION_STATE, IDLE);
+		zte_web_write(NV_FOTA_CURR_UPGRADE_STATE, IDLE);
+
+		slog(MISC_PRINT, SLOG_DEBUG,"web :zte_fota_update. update_action = FOTA_ACTION_CANCEL_DOWNLOAD, set NV_FOTA_UPGRADE_SELECTOR cancel!\n");
+		zte_write_result_to_web(wp, SUCCESS);
+		return; //no need to send msg to ota module
+	} else if (0 == strcmp(update_action, "check")) {
+		slog(MISC_PRINT, SLOG_DEBUG,"goahead :zte_fota_update.  begin to check!!\n");
+		zte_fota_SendMsg2DM(MSG_CMD_FOTA_WEBUI_START_FOTA);
+	}
+
+	zte_write_result_to_web(wp, SUCCESS);
+}
+
+/**********************************************************************
+* Function:         zte_fota_settings
+* Description:      to set fota settings
+* Input:            wp:the web para;dm_nextpollingtime;dm_pollingcycle;pollingswitch;
+* Output:
+* Return:
+* Others:         add from uFi
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+*
+**********************************************************************/
+void zte_fota_settings(webs_t wp)
+{
+	char_t *updateMode = NULL;
+	char_t *allowRoamingUpdate = NULL;
+	zte_topsw_state_e_type status = ZTE_NVIO_MAX;
+
+	if (NULL == wp) {
+		return;
+	}
+
+	updateMode = websGetVar(wp, T("UpgMode"), T(""));
+	allowRoamingUpdate = websGetVar(wp, T("UpgRoamPermission"), T(""));
+
+	slog(MISC_PRINT, SLOG_DEBUG,"zte_fota_settings web para:[updateMode] is [%s].\n", updateMode);
+	slog(MISC_PRINT, SLOG_DEBUG,"zte_fota_settings web para:[allowRoamingUpdate] is [%s].\n", allowRoamingUpdate);
+
+	if ('\0' == (*updateMode)) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	status = zte_web_write("fota_allowRoamingUpdate", allowRoamingUpdate);
+	if (ZTE_NVIO_DONE != status) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+
+	status = zte_web_write("fota_updateMode", updateMode);
+	if (ZTE_NVIO_DONE != status) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+	zte_fota_SendMsg2DM(MSG_CMD_FOTA_WEBUI_CHANGE_PARAMETER);
+	zte_write_result_to_web(wp, SUCCESS);
+}
+
+static int fota_is_file_exist(const char* path)
+{
+	if ( (path == NULL) || (*path == '\0') )
+		return FALSE;
+	if (access(path, R_OK) != 0)
+		return FALSE;
+
+	return TRUE;
+}
+
+static int fota_read_file(const char*path, char*buf, size_t sz)
+{
+	int fd = -1;
+	size_t cnt;
+
+	fd = open(path, O_RDONLY, 0);
+	if(fd < 0)
+	{
+		slog(MISC_PRINT, SLOG_DEBUG,"fota_read_file failed to open %s: %s\n", path, strerror(errno));
+		cnt = -1;
+		return cnt;
+	}
+	cnt = read(fd, buf, sz - 1);
+	if(cnt <= 0)
+	{
+		slog(MISC_PRINT, SLOG_DEBUG, "failed to read %s: %s\n", path, strerror(errno));
+		close(fd);
+		cnt = -1;
+		return cnt;
+	}
+	buf[cnt] = '\0';
+	if(buf[cnt - 1] == '\n')
+	{
+		cnt--;
+		buf[cnt] = '\0';
+	}
+	close(fd);
+
+	return cnt;
+}
+
+static int fota_read_file_int(const char* path, int *val)
+{
+	char buf[32];
+	char *end;
+	int ret;
+	int tmp;
+
+	ret = fota_read_file(path, buf, sizeof(buf));
+	if(ret < 0)
+		return -1;
+
+	errno = 0;
+	tmp = strtol(buf, &end, 0);
+	if (errno == ERANGE) {
+		slog(MISC_PRINT, SLOG_DEBUG, "strtol errno %d: %s\n", errno, strerror(errno));
+	}
+
+	if ((end == buf) || ((end < buf + sizeof(buf)) && (*end != '\0')))
+	{
+		return -1;
+	}
+
+	*val = tmp;
+
+	return 0;
+}
+
+static int fota_get_update_status(int *fota_status)
+{
+
+	int status = 0;
+	int ret = 0;
+	if(!fota_is_file_exist(FOTA_UPDATE_STATUS_FILE)) {
+		*fota_status = -1;
+		return -1;
+	}
+	ret = fota_read_file_int(FOTA_UPDATE_STATUS_FILE, &status);
+	if(ret < 0) {
+		*fota_status = -1;
+		return -1;
+	}
+	*fota_status = status;
+	return 0;
+}
+
+// »Øµ÷º¯Êý£¬ÓÃÓÚ½«ÏÂÔØµÄÊý¾ÝдÈëÎļþ
+size_t fota_upgrade_write_data(void *ptr, size_t size, size_t nmemb, FILE *stream)
+{
+	size_t written = fwrite(ptr, size, nmemb, stream);
+
+	return written;
+}
+
+void zte_fota_manual_upgrade(webs_t wp)
+{
+	int result;
+	int upgradeStatus;
+	char_t *url = NULL;
+	zte_topsw_state_e_type status = ZTE_NVIO_MAX;
+	CURL *curl;
+	CURLcode res;
+	FILE *fp;
+
+	if (NULL == wp) {
+		return;
+	}
+	url = websGetVar(wp, T("UpgURL"), T(""));
+	slog(MISC_PRINT, SLOG_DEBUG,"zte_fota_manual_upgrade web para:[UpgURL] is [%s].\n", url);
+	if ('\0' == (*url)) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	status = zte_web_write("fota_manualUpgradeURL", url);
+	if (ZTE_NVIO_DONE != status) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	curl_global_init(CURL_GLOBAL_DEFAULT);
+	curl = curl_easy_init();
+	if(curl)
+	{
+		system("rm -rf /cache/zte_fota");
+		system("mkdir /cache/zte_fota");
+		fp = fopen("/cache/zte_fota/delta.package", "w");
+		if (fp == NULL)
+		{
+			zte_write_result_to_web(wp, FAILURE);
+			curl_easy_cleanup(curl);
+			curl_global_cleanup();
+			return;
+		}
+		curl_easy_setopt(curl, CURLOPT_URL, url);
+		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fota_upgrade_write_data);
+		curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
+		// Ö´ÐÐÏÂÔØ
+		res = curl_easy_perform(curl);
+		if(res != CURLE_OK)
+		{
+			slog(MISC_PRINT, SLOG_DEBUG, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
+			fclose(fp);
+			curl_easy_cleanup(curl);
+			curl_global_cleanup();
+			zte_write_result_to_web(wp, FAILURE);
+			return;
+		}
+		fclose(fp);
+		curl_easy_cleanup(curl);
+	}
+
+	curl_global_cleanup();
+	system("fota_upi -u verify");
+	result = fota_get_update_status(&upgradeStatus);
+	if(result < 0)
+	{
+		slog(MISC_PRINT, SLOG_DEBUG, "failed to read the update_status file\n");
+		zte_write_result_to_web(wp, FAILURE);
+	}
+	else if(upgradeStatus != 0)
+	{
+		slog(MISC_PRINT, SLOG_DEBUG, "verify failed\n");
+		zte_write_result_to_web(wp, FAILURE);
+	}
+	else
+	{
+		zte_write_result_to_web(wp, SUCCESS);
+		sleep(1);
+		system("fota_upi -u recovery");
+	}
+}
+
+#if 0
+
+/**********************************************************************
+* Function:         zte_get_fota_settings
+* Description:      to get fota  settings
+* Input:            wp:the web para;
+* Output:
+* Return:
+* Others:         add from uFi
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+*
+**********************************************************************/
+void zte_get_fota_settings(webs_t wp)
+{
+	zte_topsw_state_e_type status = ZTE_NVIO_MAX;
+
+	char_t updateMode[NV_ITEM_STRING_LEN_20] = {0};
+	char_t updateIntervalDay[NV_ITEM_STRING_LEN_20] = {0};
+	char_t allowRoamingUpdate[NV_ITEM_STRING_LEN_20] = {0};
+
+	status = zte_web_read("fota_allowRoamingUpdate", allowRoamingUpdate);
+	if (ZTE_NVIO_DONE != status) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	status = zte_web_read("fota_updateIntervalDay", updateIntervalDay);
+	if (ZTE_NVIO_DONE != status) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	status = zte_web_read("fota_updateMode", updateMode);
+	if (ZTE_NVIO_DONE != status) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	WEBLOG("zte_get_fota_settings:[updateMode] is [%s].\n", updateMode);
+	WEBLOG("zte_get_fota_settings:[updateIntervalDay] is [%s].\n", updateIntervalDay);
+	WEBLOG("zte_get_fota_settings:[allowRoamingUpdate] is [%s].\n", allowRoamingUpdate);
+
+	web_feedback_header(wp);
+	zte_rest_cmd_write_head(wp);
+
+	if ('\0' != *updateMode)
+		zte_rest_cmd_write(wp, "UpgMode", updateMode, 1);
+	else
+		zte_rest_cmd_write(wp, "UpgMode", "0", 1);
+
+	if ('\0' != *updateIntervalDay)
+		zte_rest_cmd_write(wp, "UpgIntervalDay", updateIntervalDay, 1);
+	else
+		zte_rest_cmd_write(wp, "UpgIntervalDay", "1", 1);
+
+	if ('\0' != *allowRoamingUpdate)
+		zte_rest_cmd_write(wp, "UpgRoamPermission", allowRoamingUpdate, 0);
+	else
+		zte_rest_cmd_write(wp, "UpgRoamPermission", "0", 0);
+
+	zte_rest_cmd_write_foot(wp);
+}
+
+
+/******************************************************
+* Function: zte_fota_get_update_info
+* Description: get fota update info
+* Input:  http request info
+* Output:
+* Return:
+* Others:
+* Modify Date    Version   Author         Modification
+* 2013/01/06        V1.0     chenyi        create
+*******************************************************/
+void zte_fota_get_update_info(webs_t wp)
+{
+	char version[NV_ITEM_STRING_LEN_64 + 1] = {0};
+
+	(void)zte_web_read(NV_FOTA_VERSION, version);
+
+	web_feedback_header(wp);
+	(void)websWrite(wp, T("{\"%s\":\"%s\"}"), FOTA_UPDATE_VERSION, version);
+}
+#endif
+
+void zte_wan_lock_frequency_process(webs_t wp)
+{
+	slog(MISC_PRINT, SLOG_NORMAL, "zte_wan_lock_frequency_process coming");
+	CHAR *actionlte = NULL;
+	CHAR *uarfcnlte = NULL;
+	CHAR *cellParaIdlte = NULL;
+
+	/* get value from web page */
+	actionlte = websGetVar(wp, T("actionlte"), T(""));
+	uarfcnlte = websGetVar(wp, T("uarfcnlte"), T(""));
+	cellParaIdlte = websGetVar(wp, T("cellParaIdlte"), T(""));
+
+	cfg_set("actionlte", actionlte);
+	cfg_set("uarfcnlte", uarfcnlte);
+	cfg_set("cellParaIdlte", cellParaIdlte);
+	ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_CELL_LOCK_REQ, 0, NULL, 0);
+	zte_write_result_to_web(wp, SUCCESS);
+}
+
+void zte_setLastLoginTime()
+{
+	int curr_time = 0;
+	char login_time[LOGIN_RECORD_TIME] = {0};
+	curr_time = zte_web_getCurrentTime();
+	sprintf(login_time, "%d", curr_time);
+	(void)zte_web_write(NV_LAST_LOGIN_TIME, login_time);
+}
+
+int zte_checkLoginTime()
+{
+	char last_record_time[LOGIN_RECORD_TIME] = {0};
+	int last_record_time_num = 0;
+	int curr_record_time_num = 0;
+	int lock_time = 0;
+	zte_web_read(NV_LAST_LOGIN_TIME, last_record_time);
+	last_record_time_num = atoi(last_record_time);
+    if(last_record_time_num < 0 || last_record_time_num >  INT_MAX-1)  // kw 3
+    {
+        last_record_time_num = 0;
+    }	
+
+	curr_record_time_num = zte_web_getCurrentTime();
+	lock_time = curr_record_time_num - last_record_time_num;
+	if (lock_time < LOGIN_FAIL_LOCK_TIME) {
+		return -1;
+	} else {
+		return 1;
+	}
+}
+
+void zte_reduct_login_times()
+{
+	char psw_fail_num_str[12] = {0};
+	int login_times = 0;
+	zte_web_read("psw_fail_num_str", psw_fail_num_str);
+	login_times = atoi(psw_fail_num_str);
+    if(login_times < 0 || login_times >  INT_MAX-1)  // kw 3
+    {
+        login_times = 0;
+    }
+
+	login_times--;
+	sprintf(psw_fail_num_str, "%d", login_times);
+	(void)zte_web_write("psw_fail_num_str", psw_fail_num_str);
+}
+/******************************************************
+* Function: void zte_password_check(webs_t wp)
+* Description:  password check when login
+* Input:  HTTP page info
+* Output:
+* Return:  none
+* Others:
+* Modify Date    Version   Author         Modification
+*
+*******************************************************/
+psw_check_result_type_t zte_password_check(webs_t wp, char* psw)
+{
+	int psw_len = 0;
+	int psw_fail_num = 0;
+	char psw_fail_num_str[10] = {0};
+	int check_lock = 0;
+
+	if (NULL == psw) {
+		slog(MISC_PRINT, SLOG_DEBUG, "zte_mgmt_login: psw is empty.");
+		return PSW_EMPTY;
+	}
+
+	slog(MISC_PRINT, SLOG_DEBUG, "zte_mgmt_login:psw:%s", psw);
+	//don't foget add the nv psw_fail_num_str
+	zte_web_read("psw_fail_num_str", psw_fail_num_str);
+	psw_fail_num = atoi(psw_fail_num_str);
+	psw_len = strlen(psw);
+
+	if (0 == psw_len) {
+		slog(MISC_PRINT, SLOG_ERR, "zte_mgmt_login: psw is empty.");
+		return PSW_EMPTY;
+	}
+
+	if (psw_fail_num <= 0) {
+		check_lock = zte_checkLoginTime(); // check the current time if it is time out
+		if (check_lock < 0) {
+			slog(MISC_PRINT, SLOG_ERR, "zte_mgmt_login: psw number use out.");
+			return PSW_TIME_OUT;
+//		} else if (check_lock > 0) { // kw 3
+		}else{
+			slog(MISC_PRINT, SLOG_DEBUG, "zte_mgmt_login: login time out, can login.");
+			(void)zte_web_write("psw_fail_num_str", LOGIN_FAIL_TIMES);
+		}
+	}
+	zte_setLastLoginTime();  //record current time to nv
+	if (LOGIN_PSW_MIN_LEN > psw_len || LOGIN_PSW_MAX_LEN < psw_len) {
+		slog(MISC_PRINT, SLOG_ERR, "zte_mgmt_login: psw is too long.");
+		return PSW_TOO_LONG;
+	} else {
+		return PSW_OK;
+	}
+}
+
+void zte_get_ddns_status(webs_t wp)
+{
+	char * line = NULL;
+	size_t len = 0;
+	int lsize = 0; //klocwork
+	char path_conf[100] = {0};
+	char path_file[500] = {0};
+	cfg_get_item("path_conf", path_conf, sizeof(path_conf));
+	sprintf(path_file, "%s/inadyn.status", path_conf);
+	FILE *proc_file = fopen(path_file, "r");
+
+	if (proc_file == NULL) {
+		//websWrite(wp, T("4"));
+		websWrite(wp, T("{\"%s\":\"%s\"}"), "getddns_status", "4");
+		return;
+	}
+	if ((lsize = getline(&line, &len, proc_file)) != -1 && line) {
+		if (strstr(line, "RC_IP_INVALID_REMOTE_ADDR")) {
+			//websWrite(wp, T("2"));
+			websWrite(wp, T("{\"%s\":\"%s\"}"), "getddns_status", "2");
+		} else if (strstr(line, "RC_DYNDNS_RSP_NOTOK")) {
+			//websWrite(wp, T("1"));
+			websWrite(wp, T("{\"%s\":\"%s\"}"), "getddns_status", "1");
+		} else if (strstr(line, "RC_OK")) {
+			//websWrite(wp, T("0"));
+			websWrite(wp, T("{\"%s\":\"%s\"}"), "getddns_status", "0");
+		} else if (strstr(line, "RC_REGISTERING")) {
+			//websWrite(wp, T("3"));
+			websWrite(wp, T("{\"%s\":\"%s\"}"), "getddns_status", "3");
+		} else {
+			//websWrite(wp, T("5"));
+			websWrite(wp, T("{\"%s\":\"%s\"}"), "getddns_status", "5");
+		}
+	} else {
+		//websWrite(wp, T("-1"));
+		websWrite(wp, T("{\"%s\":\"%s\"}"), "getddns_status", "-1");
+	}
+	if (line) {
+		free(line);
+	}
+	fclose(proc_file);
+	return;
+
+}
+
+void zte_goform_set_work_type(webs_t wp)
+{
+	char_t *work_type = NULL;
+	work_type = websGetVar(wp, T("work_type"), T(""));
+
+	slog(MISC_PRINT, SLOG_DEBUG,"[zyl]zte_goform_set_work_type:work_type->%s\n", work_type);
+
+	if (work_type == NULL) {
+		slog(MISC_PRINT, SLOG_ERR,"[zyl]zte_goform_set_work_type:empty!\n");
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+	if ((strncmp(work_type, "0", 1) == 0) || (strncmp(work_type, "1", 1) == 0)) {
+		char LanEnable[5] = {0};
+		(void)zte_web_read("LanEnable", LanEnable);
+		if (strncmp(LanEnable, work_type, 1) == 0) {
+			return zte_write_result_to_web(wp, SUCCESS);
+		}
+		(void)zte_web_write("LanEnable", work_type);
+		slog(MISC_PRINT, SLOG_DEBUG,"[zyl]zte_goform_set_work_type:work_type->%s\n", work_type);
+		ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_MAIN_CTRL, MSG_CMD_RESTART_REQUEST, 0, NULL, 0);
+		slog(MISC_PRINT, SLOG_NORMAL,"[zyl]zte_goform_set_work_type:device reboot now\n");
+		zte_write_result_to_web(wp, SUCCESS);
+		return;
+	} else {
+		slog(MISC_PRINT, SLOG_ERR,"[zyl]zte_goform_set_work_type:work_type->%s error!\n", work_type);
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+}
+
+/******************************************************
+* Function: void zte_goform_set_sample(webs_t wp)
+* Description:  example function
+* Input:  HTTP page info
+* Output:
+* Return:  none
+* Others:
+* Modify Date    Version   Author         Modification
+*
+*******************************************************/
+void zte_goform_set_sample(webs_t wp)
+{
+	//´ÓWEBÇëÇóÖлñÈ¡²ÎÊý,ûÓвÎÊýÔò²»ÐèÒªÕâÒ»²½
+
+	// ÉèÖÃNV»ò·¢ÏûÏ¢¸øÏàӦģ¿é
+	//ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_PDP_ACT_REQ, 0, NULL, 0);
+
+	//·µ»ØJSON ¸ñʽ½á¹û£¬Èç¹ûÐèÒª²éѯÉèÖýá¹ûÔòÐèÒªwebuiͨ¹ý»ñÈ¡ppp_statusÕâ¸öNVÖµÀ´»ñÈ¡
+	zte_write_result_to_web(wp, SUCCESS);
+	return;
+}
+
+//bsim
+static int bs_string2bytes(const char* pSrc, unsigned char* pDst, int nSrcLength)
+{
+    int i=0;
+
+    //УÑé²ÎÊý
+    if(pSrc ==  NULL || pDst == NULL || nSrcLength < 0)
+    {
+        return -1;
+    }
+
+    for(i = 0; i < nSrcLength; i += 2)
+    {
+        // Êä³ö¸ß4λ
+        if(*pSrc >= '0' && *pSrc <= '9')
+        {
+            *pDst = (*pSrc - '0') << 4;
+        }
+        else
+        {
+            *pDst = ((toupper(*pSrc) - 'A') + 10) << 4;
+        }
+
+        pSrc++;
+
+        // Êä³öµÍ4λ
+        if(*pSrc >= '0' && *pSrc <= '9')
+        {
+            *pDst |= *pSrc - '0';
+        }
+        else
+        {
+            *pDst |= (toupper(*pSrc) - 'A') + 10;
+        }
+
+        pSrc++;
+        pDst++;
+    }
+
+    // ·µ»ØÄ¿±êÊý¾Ý³¤¶È
+    return nSrcLength / 2;
+}
+
+static int bs_bytes2string(const unsigned char* pSrc, char* pDst, int nSrcLength)
+{
+    const char tab[]="0123456789ABCDEF";	// 0x0-0xfµÄ×Ö·û²éÕÒ±í
+    int i = 0;
+
+    //УÑé²ÎÊý
+    if(pSrc ==  NULL || pDst == NULL || nSrcLength < 0)
+    {
+        return -1;
+    }
+
+    for(i=0; i<nSrcLength; i++)
+    {
+        *pDst++ = tab[*pSrc >> 4];		// Êä³öµÍ4λ
+        *pDst++ = tab[*pSrc & 0x0f];	// Êä³ö¸ß4λ
+        pSrc++;
+    }
+
+    // ·µ»ØÄ¿±ê×Ö·û´®³¤¶È
+    return nSrcLength * 2;
+}
+
+static int bs_aes_init_key(unsigned char *aes_key, int k_len)
+{
+	int efuse_fd = -1;
+	T_ZDrvEfuse_Secure efuse = {0};
+
+	memset(&efuse, 0, sizeof(efuse));
+	efuse_fd = open("/dev/efuse", O_RDWR);
+	if (efuse_fd < 0) {
+		printf("wifi_aes_init_key efuse open errno=%d\n", errno);
+		return 0;
+	}
+	if(ioctl(efuse_fd , EFUSE_GET_DATA, &efuse) != 0) {
+		printf("wifi_aes_init_key efuse ioctl errno=%d\n", errno);
+		close(efuse_fd);
+		return 0;
+	}
+	close(efuse_fd);
+	memcpy(aes_key, efuse.pubKeyHash, k_len);
+
+	return 1;
+}
+
+static int bs_aes_encrypt(char* in, int len, char* out, unsigned char* key, int key_len)
+{
+    if (!in || !out || !key || len <=0 || (len%AES_BLOCK_SIZE)!=0 || (key_len!=16 && key_len!=24 && key_len!=32)) {
+		printf("bs_aes_encrypt err in=%p out=%p key=%p len=%d key_len=%d\n",in,key,out,len,key_len);
+        return 0;
+    }
+
+    AES_KEY aes = {0}; //cov h
+    if (AES_set_encrypt_key(key, key_len*8, &aes) < 0) {
+		printf("bs_aes_encrypt AES_set_encrypt_key err\n");
+        return 0;
+    }
+
+    int en_len = 0;
+    while (en_len < len) {
+        AES_encrypt((unsigned char*)in, (unsigned char*)out, &aes);
+        in	+= AES_BLOCK_SIZE;
+        out += AES_BLOCK_SIZE;
+        en_len += AES_BLOCK_SIZE;
+    }
+
+    return 1;
+}
+
+static int bs_aes_decrypt(char* in, int len, char* out, char* key, int key_len)
+{
+    if (!in || !out || !key || len <=0 || (len%AES_BLOCK_SIZE)!=0 || (key_len!=16 && key_len!=24 && key_len!=32)) {
+		printf("bs_aes_decrypt err in=%p out=%p key=%p len=%d key_len=%d\n",in,key,out,len,key_len);
+        return 0;
+    }
+
+    AES_KEY aes = {0}; //cov h
+    if (AES_set_decrypt_key((unsigned char*)key, key_len*8, &aes) < 0) {
+		printf("bs_aes_decrypt AES_set_decrypt_key err\n");
+        return 0;
+    }
+
+    int en_len = 0;
+    while (en_len < len) {
+        AES_decrypt((unsigned char*)in, (unsigned char*)out, &aes);
+        in	+= AES_BLOCK_SIZE;
+        out += AES_BLOCK_SIZE;
+        en_len += AES_BLOCK_SIZE;
+    }
+
+    return 1;
+}
+
+static int bs_aes_cbc_encrypt(char* in, int len, char* out, unsigned char* key, int key_len)
+{
+    if (!in || !out || !key || len <=0 || (len%AES_BLOCK_SIZE)!=0 || (key_len!=16 && key_len!=24 && key_len!=32)) {
+		printf("bs_aes_encrypt err in=%p out=%p key=%p len=%d key_len=%d\n",in,key,out,len,key_len);
+        return 0;
+    }
+
+    AES_KEY aes = {0}; //cov h
+    if (AES_set_encrypt_key(key, key_len*8, &aes) < 0) {
+		printf("bs_aes_encrypt AES_set_encrypt_key err\n");
+        return 0;
+    }
+
+	unsigned char iv[AES_BLOCK_SIZE] = {0};
+	memcpy(iv, key, AES_BLOCK_SIZE);
+
+    AES_cbc_encrypt((unsigned char*)in, (unsigned char*)out, len, 
+			&aes, iv, AES_ENCRYPT);
+
+
+    return 1;
+}
+
+static int bs_aes_cbc_decrypt(char* in, int len, char* out, char* key, int key_len)
+{
+    if (!in || !out || !key || len <=0 || (len%AES_BLOCK_SIZE)!=0 || (key_len!=16 && key_len!=24 && key_len!=32)) {
+		printf("bs_aes_decrypt err in=%p out=%p key=%p len=%d key_len=%d\n",in,key,out,len,key_len);
+        return 0;
+    }
+
+    AES_KEY aes = {0}; //cov h
+    if (AES_set_decrypt_key((unsigned char*)key, key_len*8, &aes) < 0) {
+		printf("bs_aes_decrypt AES_set_decrypt_key err\n");
+        return 0;
+    }
+
+	unsigned char iv[AES_BLOCK_SIZE] = {0};
+	memcpy(iv, key, AES_BLOCK_SIZE);
+
+    AES_cbc_encrypt((unsigned char*)in, (unsigned char*)out, len, 
+			&aes, iv, AES_DECRYPT);
+
+    return 1;
+}
+
+
+static int apn_profile_encrypt_code(char *w_code, int len, char *b_aes, char *s_aes)
+{
+	bs_aes_encrypt(w_code, len, b_aes, web_aes_key, sizeof(web_aes_key));
+	bs_bytes2string(b_aes, s_aes, len);
+
+	printf("encrypt apn_profile w_code=%s, s_aes=%s\n", w_code, s_aes);
+
+	return 1;
+}
+
+void set_apn_prof_aes_by_index(int index, APN_PROFILE *profile)
+{
+	char cfg_name[PROFILE_MEMBER_LEN] = {0};
+	char cfg_value[APNCONFIG_MEMORY] = {0};
+
+	if (NULL == profile) {
+		return;
+	}
+
+	sprintf(cfg_name, "APN_config%d", index);
+	if (0 == strcmp(profile->pdp_type, "IPv6")) {
+		snprintf(cfg_value, APNCONFIG_MEMORY,
+				 "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+				 profile->profile_name,
+				 "",
+				 "",
+				 "",
+				 "",
+				 "",
+				 "",
+				 "",
+				 "",
+				 "",
+				 "",
+				 "",
+				 "");
+	} else {
+		char ppp_aes[PROFILE_APN_AES_LEN] = {0};
+		char ppp_aes_b[PROFILE_APN_LEN - 1] = {0};
+		apn_profile_encrypt_code(profile->ppp_passwd, PROFILE_APN_LEN - 1 , ppp_aes_b, ppp_aes);
+		snprintf(cfg_value, APNCONFIG_MEMORY,
+				 "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+				 profile->profile_name,
+				 profile->apn_name,
+				 profile->apn_select,
+				 profile->dial_num,
+				 profile->ppp_auth_mode,
+				 profile->ppp_username,
+				 ppp_aes,//profile->ppp_passwd,
+				 profile->pdp_type,
+				 profile->pdp_select,
+				 profile->pdp_addr,
+				 profile->dns_mode,
+				 profile->prefer_dns_manual,
+				 profile->standby_dns_manual);
+	}
+	cfg_set(cfg_name, cfg_value);
+
+	return;
+}
+
+void set_ipv6_apn_prof_aes_by_index(int index, IPV6_APN_PROFILE *profile)
+{
+	char cfg_name[PROFILE_MEMBER_LEN] = {0};
+	char cfg_value[APNCONFIG_MEMORY] = {0};
+
+	if (NULL == profile) {
+		return;
+	}
+
+	sprintf(cfg_name, "ipv6_APN_config%d", index);
+	if (0 == strcmp(profile->pdp_type, "IP")) {
+		slog(MISC_PRINT, SLOG_DEBUG, "pdp_type=IP  cpsnprintf "); /*lint !e26*/
+		snprintf(cfg_value, APNCONFIG_MEMORY,
+		         "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+		         profile->profile_name,
+		         "",
+		         "",
+		         "",
+		         "",
+		         "",
+		         "",
+		         "",
+		         "",
+		         "",
+		         "",
+		         "",
+		         "");
+	} else {
+		char ppp_aes[PROFILE_APN_AES_LEN] = {0};
+		char ppp_aes_b[PROFILE_APN_LEN - 1] = {0};
+		apn_profile_encrypt_code(profile->ppp_passwd, PROFILE_APN_LEN - 1 , ppp_aes_b, ppp_aes);
+		slog(MISC_PRINT, SLOG_DEBUG, "pdp_type=else  cpsnprintf "); /*lint !e26*/
+		slog(MISC_PRINT, SLOG_DEBUG, "profile->profile_name=%s ", profile->profile_name); /*lint !e26*/
+		snprintf(cfg_value, APNCONFIG_MEMORY,
+		         "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+		         profile->profile_name,
+		         profile->apn_name,
+		         profile->apn_select,
+		         profile->dial_num,
+		         profile->ppp_auth_mode,
+		         profile->ppp_username,
+		         ppp_aes,//profile->ppp_passwd,
+		         profile->pdp_type,
+		         profile->pdp_select,
+		         profile->pdp_addr,
+		         profile->dns_mode,
+		         profile->prefer_dns_manual,
+		         profile->standby_dns_manual);
+	}
+	slog(MISC_PRINT, SLOG_DEBUG, "cfg_value=%s", cfg_value); /*lint !e26*/
+	cfg_set(cfg_name, cfg_value);
+
+	return;
+}
+
+void set_ipv4v6_apn_prof_aes_by_index(int index, APN_PROFILE *profile, IPV6_APN_PROFILE *ipv6profile)
+{
+	char cfg_name[PROFILE_MEMBER_LEN] = {0};
+	char cfg_value[APNCONFIG_MEMORY] = {0};
+	char ppp_aes[PROFILE_APN_AES_LEN] = {0};
+	char ppp_aes_b[PROFILE_APN_LEN - 1] = {0};
+
+	if (NULL == profile) {
+		return;
+	}
+
+	sprintf(cfg_name, "APN_config%d", index);
+	apn_profile_encrypt_code(profile->ppp_passwd, PROFILE_APN_LEN - 1 , ppp_aes_b, ppp_aes);	
+	snprintf(cfg_value, APNCONFIG_MEMORY,
+	         "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+	         profile->profile_name,
+	         profile->apn_name,
+	         profile->apn_select,
+	         profile->dial_num,
+	         profile->ppp_auth_mode,
+	         profile->ppp_username,
+	         ppp_aes,//profile->ppp_passwd,
+	         profile->pdp_type,
+	         profile->pdp_select,
+	         profile->pdp_addr,
+	         profile->dns_mode,
+	         profile->prefer_dns_manual,
+	         profile->standby_dns_manual);
+	cfg_set(cfg_name, cfg_value);
+
+	memset(cfg_name, 0, sizeof(cfg_name));
+	memset(cfg_value, 0, sizeof(cfg_value));
+	memset(ppp_aes, 0, sizeof(ppp_aes));
+	memset(ppp_aes_b, 0, sizeof(ppp_aes_b));
+	sprintf(cfg_name, "ipv6_APN_config%d", index);
+	apn_profile_encrypt_code(ipv6profile->ppp_passwd, PROFILE_APN_LEN - 1 , ppp_aes_b, ppp_aes);	
+	snprintf(cfg_value, APNCONFIG_MEMORY,
+	         "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+	         ipv6profile->profile_name,
+	         ipv6profile->apn_name,
+	         ipv6profile->apn_select,
+	         ipv6profile->dial_num,
+	         ipv6profile->ppp_auth_mode,
+	         ipv6profile->ppp_username,
+	         ppp_aes,//ipv6profile->ppp_passwd,
+	         ipv6profile->pdp_type,
+	         ipv6profile->pdp_select,
+	         ipv6profile->pdp_addr,
+	         ipv6profile->dns_mode,
+	         ipv6profile->prefer_dns_manual,
+	         ipv6profile->standby_dns_manual);
+	cfg_set(cfg_name, cfg_value);
+
+	return;
+}
+
+//APN_config0~n
+static void apn_decode_profile_by_index(int index)
+{
+	char cfg_name[PROFILE_MEMBER_LEN] = {0};
+	char cfg_value[APNCONFIG_MEMORY] = {0};
+	char ppp_aes[PROFILE_APN_AES_LEN] = {0};
+	char b_aes[PROFILE_APN_LEN] = {0};
+	//char ppp_s[PROFILE_APN_LEN] = {0};
+	char *pos_begin = NULL;
+	APN_PROFILE profile = {0};
+
+	sprintf(cfg_name, "APN_config%d", index);
+	cfg_get_item(cfg_name, cfg_value, sizeof(cfg_value));
+	if (strlen(cfg_value) == 0)
+		return;
+	pos_begin = cfg_value;
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.profile_name, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.apn_name, PROFILE_APN_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.apn_select, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.dial_num, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.ppp_auth_mode, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.ppp_username, PROFILE_APN_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", ppp_aes, PROFILE_APN_AES_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.pdp_type, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.pdp_select, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.pdp_addr, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.dns_mode, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.prefer_dns_manual, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.standby_dns_manual, PROFILE_MEMBER_LEN);
+
+	if (strlen(ppp_aes) == (PROFILE_APN_AES_LEN - 1)) {
+		bs_string2bytes(ppp_aes, b_aes, PROFILE_APN_AES_LEN - 1);
+		bs_aes_decrypt(b_aes, PROFILE_APN_LEN - 1, profile.ppp_passwd, web_aes_key, sizeof(web_aes_key));
+//		printf("decrypt ppp_tmp[%d]=%s\n", index, profile.ppp_passwd);
+	} else if (strlen(ppp_aes) > 0){
+		//fotaÉý¼¶À´µÄÃ÷ÎÄ
+		strncpy(profile.ppp_passwd, ppp_aes,sizeof(profile.ppp_passwd)-1);
+		set_apn_prof_aes_by_index(index, &profile);
+//		printf("decrypt fota ppp_tmp[%d]=%s\n", index, profile.ppp_passwd);
+	}
+
+	set_apn_profile_by_index(index, &profile);
+
+	return;
+}
+
+static void ipv6apn_decode_profile_by_index(int index)
+{
+	char cfg_name[PROFILE_MEMBER_LEN] = {0};
+	char cfg_value[APNCONFIG_MEMORY] = {0};
+	char ppp_aes[PROFILE_APN_AES_LEN] = {0};
+	char b_aes[PROFILE_APN_LEN] = {0};
+	char *pos_begin = NULL;
+	IPV6_APN_PROFILE profile = {0};
+
+
+	sprintf(cfg_name, "ipv6_APN_config%d", index);
+	cfg_get_item(cfg_name, cfg_value, sizeof(cfg_value));
+	if (strlen(cfg_value) == 0)
+		return;
+	pos_begin = cfg_value;
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.profile_name, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.apn_name, PROFILE_APN_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.apn_select, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.dial_num, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.ppp_auth_mode, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.ppp_username, PROFILE_APN_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", ppp_aes, PROFILE_APN_AES_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.pdp_type, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.pdp_select, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.pdp_addr, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.dns_mode, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.prefer_dns_manual, PROFILE_MEMBER_LEN);
+	pos_begin = split_str_by_sep(pos_begin, "($)", profile.standby_dns_manual, PROFILE_MEMBER_LEN);
+
+	if (strlen(ppp_aes) == (PROFILE_APN_AES_LEN - 1)) {
+		bs_string2bytes(ppp_aes, b_aes, PROFILE_APN_AES_LEN - 1);
+		bs_aes_decrypt(b_aes, PROFILE_APN_LEN - 1, profile.ppp_passwd, web_aes_key, sizeof(web_aes_key));
+//		printf("decrypt ppp_v6tmp[%d]=%s\n", index, profile.ppp_passwd);
+	} else if (strlen(ppp_aes) > 0){
+		//fotaÉý¼¶À´µÄÃ÷ÎÄ
+		strncpy(profile.ppp_passwd, ppp_aes,sizeof(profile.ppp_passwd)-1);
+		set_ipv6_apn_prof_aes_by_index(index, &profile);
+//		printf("decrypt fota ppp_v6tmp[%d]=%s\n", index, profile.ppp_passwd);
+	}
+	set_ipv6_apn_profile_by_index(index, &profile);
+
+	return;
+}
+
+static int apn_profile_decrypt_code(void)
+{
+	int index = 0;//APN_config0ÊÇDefault,¿É²»´¦Àí?
+
+	for (index = 0; index < APNCONFIG_NUM_MAX; index++) {
+		apn_decode_profile_by_index(index);
+		ipv6apn_decode_profile_by_index(index);
+	} 
+
+	return 1;
+}
+
+int apn_encrypt_code(void)
+{
+	char w_code[PROFILE_APN_LEN] = {0};
+	char b_aes[PROFILE_APN_LEN] = {0};
+	char s_aes[PROFILE_APN_AES_LEN] = {0};
+
+	cfg_get_item("ppp_passtmp", w_code, sizeof(w_code));
+	bs_aes_encrypt(w_code, PROFILE_APN_LEN - 1, b_aes, web_aes_key, sizeof(web_aes_key));
+	bs_bytes2string(b_aes, s_aes, PROFILE_APN_LEN - 1);
+	cfg_set("ppp_passwd", s_aes);
+	printf("apn_encrypt_code w_code=%s, s_aes=%s\n", w_code, s_aes);
+
+	return 1;
+}
+
+int ipv6apn_encrypt_code(void)
+{
+	char w_code[PROFILE_APN_LEN] = {0};
+	char b_aes[PROFILE_APN_LEN] = {0};
+	char s_aes[PROFILE_APN_AES_LEN] = {0};
+
+	cfg_get_item("ipv6_ppp_passtmp", w_code, sizeof(w_code));
+	bs_aes_encrypt(w_code, PROFILE_APN_LEN - 1, b_aes, web_aes_key, sizeof(web_aes_key));
+	bs_bytes2string(b_aes, s_aes, PROFILE_APN_LEN - 1);
+	cfg_set("ipv6_ppp_passwd", s_aes);
+	printf("ipv6apn_encrypt_code w_code=%s, s_aes=%s\n", w_code, s_aes);
+
+	return 1;
+}
+#if 0
+//2±íʾfota´ÓÀϰ汾ÍùÉÏÉý¼¶£¬ppp_password´æµÄÊÇÃ÷ÎÄÃÜÂ룬а汾ÊÇÃÜÎÄ
+static int apn_decrypt_code(void)
+{
+	char w_code[PROFILE_APN_LEN]= {0};
+	char b_aes[PROFILE_APN_LEN] = {0};
+	char s_aes[PROFILE_APN_AES_LEN] = {0};
+	int flag = 0;
+
+	cfg_get_item("ppp_passwd", s_aes, sizeof(s_aes));
+	if (strlen(s_aes) == (PROFILE_APN_AES_LEN - 1)) {
+		bs_string2bytes(s_aes, b_aes, PROFILE_APN_AES_LEN - 1);
+		bs_aes_decrypt(b_aes, PROFILE_APN_LEN - 1, w_code, web_aes_key, sizeof(web_aes_key));
+		cfg_set("ppp_passtmp", w_code);
+		printf("apn_decrypt_code w_code=%s, s_aes=%s\n", w_code, s_aes);
+	} else if (strlen(s_aes) > 0){
+		cfg_set("ppp_passtmp", s_aes);
+		return 2;
+	}
+
+	return 1;
+}
+
+static int ipv6apn_decrypt_code(void)
+{
+	char w_code[PROFILE_APN_LEN]= {0};
+	char b_aes[PROFILE_APN_LEN] = {0};
+	char s_aes[PROFILE_APN_AES_LEN] = {0};
+	int flag = 0;
+
+	cfg_get_item("ipv6_ppp_passwd", s_aes, sizeof(s_aes));
+	if (strlen(s_aes) == (PROFILE_APN_AES_LEN - 1)) {
+		bs_string2bytes(s_aes, b_aes, PROFILE_APN_AES_LEN - 1);
+		bs_aes_decrypt(b_aes, PROFILE_APN_LEN - 1, w_code, web_aes_key, sizeof(web_aes_key));
+		cfg_set("ipv6_ppp_passtmp", w_code);
+		printf("apn_decrypt_code w_code=%s, s_aes=%s\n", w_code, s_aes);
+	} else if (strlen(s_aes) > 0){
+		cfg_set("ipv6_ppp_passtmp", s_aes);
+		return 2;
+	}
+
+	return 1;
+}
+#endif
+#ifdef WEBS_SECURITY
+static void js_aes_wifi_encode(void)
+{	
+	char js_aes_key[24 + 1]={0};
+	char imei_buf[15 + 1] = {0};
+	char rnum_buf[9 + 1] = {0};
+
+	char wificode[WIFI_PSW_DEFAULT_LENGTH] = {0};
+	char b_aes[WIFI_PSW_DEFAULT_LENGTH] = {0};
+	char *basestr = NULL;
+
+	cfg_get_item("imei", imei_buf, sizeof(imei_buf));
+	cfg_get_item("rnum_js", rnum_buf, sizeof(rnum_buf));
+	snprintf(js_aes_key, sizeof(js_aes_key), "%s%sFFFFFFFFFFFFFFF", rnum_buf, imei_buf);
+
+	cfg_get_item("WPAPSK1", wificode, sizeof(wificode));
+	bs_aes_cbc_encrypt(wificode, sizeof(wificode)-1, b_aes, js_aes_key, sizeof(js_aes_key)-1);
+	basestr = zte_base64_encode(b_aes, sizeof(b_aes)-1);
+	if (NULL == basestr) {
+		slog(MISC_PRINT, SLOG_ERR, "basestr is NULL.\n");/*lint !e26*/
+		return;
+	}
+	(void)zte_web_write("WPAPSK1_enaes", basestr);
+	free(basestr);
+	basestr = NULL;
+
+	memset(wificode, 0, sizeof(wificode));
+	cfg_get_item("m_WPAPSK1", wificode, sizeof(wificode));
+	bs_aes_cbc_encrypt(wificode, sizeof(wificode)-1, b_aes, js_aes_key, sizeof(js_aes_key)-1);
+	basestr = zte_base64_encode(b_aes, sizeof(b_aes)-1);
+	if (NULL == basestr) {
+		slog(MISC_PRINT, SLOG_ERR, "basestr-m is NULL.\n");/*lint !e26*/
+		return;
+	}
+	(void)zte_web_write("m_WPAPSK1_enaes", basestr);
+	free(basestr);
+	basestr = NULL;
+
+}
+
+
+static void js_aes_rand(void)
+{
+    char rstr[10] = {0};
+    unsigned int rnum = 0;
+
+    srand( (unsigned)time( NULL ) );
+    rnum = rand();
+    rnum %= 1000000000;   
+
+    snprintf((char *)rstr, sizeof(rstr), "%09ld", rnum);        
+    cfg_set("rnum_js", rstr);
+}
+//cbc
+char *js_aes_decode(char *src, size_t len, size_t *out_len)
+{
+	unsigned char *aes_password = NULL;
+	size_t aes_len = 0;
+
+	char *out = NULL;
+
+	char js_aes_key[24 + 1]={0};
+	char imei_buf[15 + 1] = {0};
+	char rnum_buf[9 + 1] = {0};
+
+	aes_password = (char *)zte_base64_decode((const unsigned char *)src, len, (unsigned int*)&aes_len);
+	if (aes_password == NULL)
+		return NULL;
+
+
+	out = malloc(aes_len + 1);
+	if (out == NULL) {
+		free(aes_password);
+		return NULL;
+	}
+	memset(out, 0, aes_len + 1);
+
+	cfg_get_item("imei", imei_buf, sizeof(imei_buf));
+	cfg_get_item("rnum_js", rnum_buf, sizeof(rnum_buf));
+	snprintf(js_aes_key, sizeof(js_aes_key), "%s%sFFFFFFFFFFFFFFF", rnum_buf, imei_buf);
+
+	bs_aes_cbc_decrypt(aes_password, aes_len, out, js_aes_key, sizeof(js_aes_key)-1);
+	//printf("decrypt js_aes_decode[%d]=%s\n", aes_len, out);
+
+	free(aes_password);
+
+	if (strlen(out) > aes_len) {
+		free(out);
+		return NULL;
+	}
+
+	*out_len = strlen(out);
+
+	return out;
+}
+#endif
+int web_aes_init(void)
+{
+	bs_aes_init_key(web_aes_key, sizeof(web_aes_key));
+	apn_profile_decrypt_code();
+#ifdef WEBS_SECURITY
+	js_aes_rand();
+#endif
+	return 1;
+}
+
diff --git a/lynq/S300/ap/app/goahead/interface5.0/zte_web_mgmt.h b/lynq/S300/ap/app/goahead/interface5.0/zte_web_mgmt.h
new file mode 100755
index 0000000..478be40
--- /dev/null
+++ b/lynq/S300/ap/app/goahead/interface5.0/zte_web_mgmt.h
@@ -0,0 +1,126 @@
+/************************************************************************
+* °æÈ¨ËùÓÐ (C)2010, ÉîÛÚÊÐÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+*
+* ÎļþÃû³Æ£º zte_web_mgmt.h
+* Îļþ±êʶ£º
+* ÄÚÈÝÕªÒª£º
+* ÆäËü˵Ã÷£º
+* µ±Ç°°æ±¾£º V0.1
+* ×÷    Õߣº zyt
+* Íê³ÉÈÕÆÚ£º 2010-11-24
+*
+* Ð޸ļǼ1£º
+* ÐÞ¸ÄÄÚÈÝ£º³õʼ°æ±¾
+************************************************************************/
+
+#ifndef ZTE_WEB_MGMT_H
+#define ZTE_WEB_MGMT_H
+
+#define APNCONFIG_MEMORY 1024
+#define PROFILE_MEMBER_LEN 32
+#define PROFILE_APN_LEN 65
+#define PROFILE_APN_AES_LEN 129
+#define DAYSEC 86400
+#define COMMONYEARSEC 31536000
+#define LEAPYEARSEC 31622400
+#define JAN_2000   946684791
+typedef struct tag_APN_PROFILE {
+	char profile_name[PROFILE_MEMBER_LEN];
+	char apn_name[PROFILE_APN_LEN];
+	char apn_select[PROFILE_MEMBER_LEN];
+	char dial_num[PROFILE_MEMBER_LEN];
+	char ppp_auth_mode[PROFILE_MEMBER_LEN];
+	char ppp_username[PROFILE_APN_LEN];
+	char ppp_passwd[PROFILE_APN_LEN];
+	char pdp_type[PROFILE_MEMBER_LEN];
+	char pdp_select[PROFILE_MEMBER_LEN];
+	char pdp_addr[PROFILE_MEMBER_LEN];
+	char dns_mode[PROFILE_MEMBER_LEN];
+	char prefer_dns_manual[PROFILE_MEMBER_LEN];
+	char standby_dns_manual[PROFILE_MEMBER_LEN];
+} APN_PROFILE;
+
+
+typedef struct tag_IPv6_APN_PROFILE {
+	char profile_name[PROFILE_MEMBER_LEN];
+	char apn_name[PROFILE_APN_LEN];
+	char apn_select[PROFILE_MEMBER_LEN];
+	char dial_num[PROFILE_MEMBER_LEN];
+	char ppp_auth_mode[PROFILE_MEMBER_LEN];
+	char ppp_username[PROFILE_APN_LEN];
+	char ppp_passwd[PROFILE_APN_LEN];
+	char pdp_type[PROFILE_MEMBER_LEN];
+	char pdp_select[PROFILE_MEMBER_LEN];
+	char pdp_addr[PROFILE_MEMBER_LEN];
+	char dns_mode[PROFILE_MEMBER_LEN];
+	char prefer_dns_manual[PROFILE_MEMBER_LEN];
+	char standby_dns_manual[PROFILE_MEMBER_LEN];
+} IPV6_APN_PROFILE;
+
+
+/* management */
+extern void zte_mgmt_login(webs_t wp);//11
+extern void zte_mgmt_logout(webs_t wp);//11
+extern void zte_mgmt_set_language(webs_t wp);//11
+extern void zte_mgmt_restore(webs_t wp);//11
+extern void zte_mgmt_poweroff(webs_t wp);
+extern void zte_mgmt_control_power_on_speed(webs_t wp);
+extern void zte_mgmt_change_password(webs_t wp);//11
+extern void zte_mgmt_change_account(webs_t wp);//
+extern void zte_goform_mgmt_set_not_login_process(webs_t wp);
+extern void zte_mgmt_disable_pin(webs_t wp);//11
+extern void zte_mgmt_pin_input(webs_t wp);//11
+extern void zte_mgmt_puk_input(webs_t wp);//11
+extern void zte_mgmt_auto_pin(webs_t wp);
+extern void zte_mgmt_pin_enable_or_modify(webs_t wp);//11
+extern void zte_mgmt_unlock_network(webs_t wp);//11
+extern void zte_goform_mgmt_pin_mgmt_process(webs_t wp);
+extern void zte_quick_setup(webs_t wp);//11
+//extern void zte_quick_set_first(webs_t wp);//11
+void deal_quick_setup_apn_ex(webs_t wp);
+extern void zte_mgmt_set_devicemode(webs_t wp);
+
+extern void zte_goform_mgmt_schedule_setting_process(webs_t wp);
+extern void zte_goform_mamt_cwmp_process(webs_t wp);
+
+extern void zte_goform_mgmt_sntp_process(webs_t wp);
+
+
+extern void zte_goform_mgmt_reboot_process(webs_t wp);
+extern void zte_goform_mgmt_syslog_process(webs_t wp);
+
+extern void get_autoapn_profile(APN_PROFILE *apn_profile);
+extern void get_apn_profile_by_index(int index, APN_PROFILE *profile);
+extern void get_ipv6apn_profile_by_index(int index, IPV6_APN_PROFILE *ipv6profile);
+extern void get_ipv4v6apn_profile_by_index(int index, APN_PROFILE *profile, IPV6_APN_PROFILE *ipv6profile);
+extern void get_autoapn_profile(APN_PROFILE *profile);
+extern void set_apn_profile_by_index(int index, APN_PROFILE *profile);
+extern void set_ipv6_apn_profile_by_index(int index, IPV6_APN_PROFILE *ipv6profile);
+extern void set_ipv4v6_apn_profile_by_index(int index, APN_PROFILE *profile, IPV6_APN_PROFILE *ipv6profile);
+extern void set_apn_prof_aes_by_index(int index, APN_PROFILE *profile);
+extern void set_ipv6_apn_prof_aes_by_index(int index, IPV6_APN_PROFILE *profile);
+extern void set_ipv4v6_apn_prof_aes_by_index(int index, APN_PROFILE *profile, IPV6_APN_PROFILE *ipv6profile);
+extern int apn_encrypt_code(void);
+extern int ipv6apn_encrypt_code(void);
+
+extern void zte_wan_lock_frequency_process(webs_t wp);
+
+extern int manual_set_time();
+
+extern void getdialog_url(int eid, webs_t wp, int argc, char_t **argv);
+extern void getddns_status(int eid, webs_t wp, int argc, char_t **argv);
+extern char * timei2s(int);
+extern void timeen2ch(char *);
+extern void datastatic(char *, char *, char *, char *, char *);
+
+extern int zte_fota_notifyPushMsg(int cmd);
+
+extern void zte_fota_get_upgrade_result(webs_t wp);
+extern void zte_fota_get_dp_pack_info(webs_t wp);
+extern void zte_fota_get_update_info(webs_t wp);
+//extern void zte_fota_get_dm_last_check_time(webs_t wp);
+#ifdef WEBS_SECURITY
+extern char *js_aes_decode(char *src, size_t len, size_t *out_len);
+#endif
+#endif
+
diff --git a/lynq/S300/ap/app/goahead/interface5.0/zte_web_pbm.c b/lynq/S300/ap/app/goahead/interface5.0/zte_web_pbm.c
new file mode 100755
index 0000000..a58d0a5
--- /dev/null
+++ b/lynq/S300/ap/app/goahead/interface5.0/zte_web_pbm.c
@@ -0,0 +1,965 @@
+/************************************************************************
+* °æÈ¨ËùÓÐ (C)2010, ÉîÛÚÊÐÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+*
+* ÎļþÃû³Æ£º zte_web_pbm.c
+* Îļþ±êʶ£º
+* ÄÚÈÝÕªÒª£º
+* ÆäËü˵Ã÷£º
+* µ±Ç°°æ±¾£º V0.1
+* ×÷    Õߣº zyt
+* Íê³ÉÈÕÆÚ£º 2010-11-06
+*
+* Ð޸ļǼ1£º
+* ÐÞ¸ÄÄÚÈÝ£º³õʼ°æ±¾
+************************************************************************/
+
+#include "zte_web_interface.h"
+//#include "../../phonebook/phonebook.h"
+#include "zte_web_get_fw_para.h"
+#include "zte_web_pbm.h"
+
+static void zte_web_pbm_feed_back_empty(webs_t wp);
+
+#define IFSTREQUAL(str1, str2) (strcmp((str1), (str2))?0:1)
+
+int zte_web_pbm_check_can_process()
+{
+	char flag[20] = {0};
+
+	(void)zte_web_read(ZTE_PBM_NV, flag);
+	if (0 == strcmp(flag, PBM_OPRATING)) {
+		slog(MISC_PRINT, SLOG_DEBUG,"[PB] zte_web_pbm_check_can_process flag=%s, not can process.\n", flag);
+		return 0;
+	} else {
+		slog(MISC_PRINT, SLOG_DEBUG,"[PB] zte_web_pbm_check_can_process flag=%s, can process.\n", flag);
+		return -1;
+	}
+}
+
+static data_safe_result_type_t zte_Safe_noSpecialChar_ucs2(char *str)
+{
+	int i = 0;
+	int len = 0;
+	if (NULL == str || strlen(str) < 4) {
+		return 0;
+	}
+	len = strlen(str);
+	for (i = 0; i < len; i=i+4) {
+		if (str[i] == '0' && str[i+1] == '0') {
+			if(str[i+2] == '2') {//"'/
+				if(str[i+3] == '2' || str[i+3] == '7' || str[i+3] == 'f' || str[i+3] == 'F')
+					return 0;
+			} else if(str[i+2] == '3') {//<>
+				if(str[i+3] == 'c' || str[i+3] == 'C' || str[i+3] == 'e' || str[i+3] == 'E')
+					return 0;
+			} else if(str[i+2] == '5') {/* \ */
+				if(str[i+3] == 'c' || str[i+3] == 'C')
+					return 0;
+			}
+		}
+	}
+	return 1;
+
+}
+
+/**********************************************************************
+* Function:         zte_web_pbm_contact_saveto_sim
+* Description:
+* Input:            wp:web para;sim_contact_location:save location
+* Output:
+* Return:           void
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 20120926    V1.0        liuyingnan        first version
+**********************************************************************/
+static void zte_web_pbm_contact_saveto_sim(webs_t wp, int sim_contact_location)
+{
+	/*contact added type*/
+	zte_pbm_create_ext_record_s_type sim_contact_add;
+	int ret_code = 0;
+	//add by liuyingnan for server safe start
+	char* pbm_name = NULL;
+	char* pbm_mobilephone_num = NULL;
+	//add by liuyingnan for server safe end
+
+	/*LOG*/
+	slog(MISC_PRINT, SLOG_DEBUG, "zte_web_pbm->zte_web_pbm_contact_saveto_sim()."); /*lint !e26*/
+
+	/*check input*/
+	if (NULL == wp) {
+		slog(MISC_PRINT, SLOG_ERR, "zte_web_pbm->zte_goform_pbm_contact_add_process(): invalid input.."); /*lint !e26*/
+		return;
+	}
+
+	//add by liuyingnan for server safe for xss attack start
+	pbm_name = websGetVar(wp, T("name"), T(""));
+	pbm_mobilephone_num = websGetVar(wp, T("mobilephone_num"), T(""));
+
+	if (PBM_MAX_TEXT_LENGTH < strlen(pbm_name) || PBM_MAX_NUM_LENGTH < strlen(pbm_mobilephone_num)
+		||DATA_NO_SAFE == zte_Safe_noSpecialChar_ucs2(pbm_name)
+		|| DATA_NO_SAFE == zte_Safe_noSpecialChar(pbm_mobilephone_num)
+		) {
+		slog(MISC_PRINT, SLOG_ERR, "Get Data is no Safe:pbm_name:%s\n", pbm_name); /*lint !e26*/
+		cfg_set("data_safe", "failed");
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+	//add by liuyingnan for server safe for xss attack end
+
+	/*init contact_add*/
+	memset(&sim_contact_add, 0, sizeof(sim_contact_add));
+	/*set struct value*/
+	sim_contact_add.zte_pbm_del_id = atoi(websGetVar(wp, T("delId"), T("-1")));
+	sim_contact_add.zte_pbm_location = sim_contact_location;
+	sim_contact_add.zte_pbm_id = atoi(websGetVar(wp, T("edit_index"), T("")));
+
+	memcpy(sim_contact_add.zte_pbm_name, websGetVar(wp, T("name"), T("")),
+	       sizeof(sim_contact_add.zte_pbm_name));
+	memcpy(sim_contact_add.zte_pbm_number, websGetVar(wp, T("mobilephone_num"), T("")),
+	       sizeof(sim_contact_add.zte_pbm_number));
+	memcpy(sim_contact_add.zte_pbm_anr, websGetVar(wp, T("homephone_num"), T("")),
+	       sizeof(sim_contact_add.zte_pbm_anr));
+	memcpy(sim_contact_add.zte_pbm_anr1, websGetVar(wp, T("officephone_num"), T("")),
+	       sizeof(sim_contact_add.zte_pbm_anr1));
+	memcpy(sim_contact_add.zte_pbm_email, websGetVar(wp, T("email"), T("")),
+	       sizeof(sim_contact_add.zte_pbm_email));
+	memcpy(sim_contact_add.zte_pbm_sne, websGetVar(wp, T("nick_name"), T("")),
+	       sizeof(sim_contact_add.zte_pbm_sne));
+	if (sim_contact_add.zte_pbm_number[ZTE_WEB_PBM_NUMBER_TYPE_START] ==
+	    ZTE_WEB_PBM_NUMBER_TYPE_SPLIT) {
+		sim_contact_add.zte_pbm_type = ZTE_WEB_PBM_NUMBER_TYPE_1;
+	} else {
+		sim_contact_add.zte_pbm_type = ZTE_WEB_PBM_NUMBER_TYPE_2;
+	}
+	slog(MISC_PRINT, SLOG_DEBUG, "zte_web_pbm_contact_saveto_sim:send messsage to mc start"); /*lint !e26*/
+	slog(MISC_PRINT, SLOG_DEBUG, "sim_contact_add.zte_pbm_id:%d", sim_contact_add.zte_pbm_id); /*lint !e26*/
+	slog(MISC_PRINT, SLOG_DEBUG, "sim_contact_add.name:%s", sim_contact_add.zte_pbm_name); /*lint !e26*/
+	slog(MISC_PRINT, SLOG_DEBUG, "sim_contact_add.mobilephone_num:%s", sim_contact_add.zte_pbm_number); /*lint !e26*/
+	slog(MISC_PRINT, SLOG_DEBUG, "sim_contact_add.zte_pbm_type:%d", sim_contact_add.zte_pbm_type); /*lint !e26*/
+
+	/*send msg to mc*/
+	//ret_code = zte_send_message(ZUFI_MODULE_ID_AT_LOCAL,ZTE_PBM_WRITE_REC_MSG, sizeof(sim_contact_add), (char*)&sim_contact_add);
+	(void)zte_web_write(ZTE_PBM_NV, PBM_OPRATING);
+	ret_code = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_PB, MSG_CMD_WRITE_PB, sizeof(sim_contact_add), (char*)&sim_contact_add, 0);
+	if (ret_code != 0) {
+		slog(MISC_PRINT, SLOG_ERR, "mc lib relay pbm  send create modify record  fail"); /*lint !e26*/
+		(void)zte_web_write(ZTE_PBM_NV, "14");
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	slog(MISC_PRINT, SLOG_NORMAL, "zte_web_pbm_contact_saveto_sim:send messsage to mc end"); /*lint !e26*/
+	/*goto web page*/
+	zte_write_result_to_web(wp, "success");
+	return;
+}
+/**********************************************************************
+* Function:         zte_web_pbm_contact_saveto_pc
+* Description:       wp:web para;pc_contact_location:save location
+* Input:            null
+* Output:           null
+* Return:           void
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 20120926    V1.0        liuyingnan        first version
+**********************************************************************/
+static void zte_web_pbm_contact_saveto_pc(webs_t wp, int pc_contact_location)
+{
+	/*contact added type*/
+	zte_pbm_create_ext_record_s_type pc_contact_add;
+	int ret_code = 0;
+	//add by liuyingnan for server safe start
+	char* pbm_name = NULL;
+	char* pbm_mobilephone_num = NULL;
+	//add by liuyingnan for server safe end
+	/*LOG*/
+	slog(MISC_PRINT, SLOG_DEBUG, "zte_web_pbm->zte_web_pbm_contact_saveto_pc()."); /*lint !e26*/
+	slog(MISC_PRINT, SLOG_DEBUG,"[PB] zte_web_pbm_contact_saveto_pc entry\n");
+	/*check input*/
+	if (NULL == wp) {
+		slog(MISC_PRINT, SLOG_ERR, "zte_web_pbm->zte_web_pbm_contact_saveto_pc(): invalid input.."); /*lint !e26*/
+		return;
+	}
+	//add by liuyingnan for server safe for xss attack start
+	pbm_name = websGetVar(wp, T("name"), T(""));
+	pbm_mobilephone_num = websGetVar(wp, T("mobilephone_num"), T(""));
+	slog(MISC_PRINT, SLOG_DEBUG,"[PB] zte_web_pbm_contact_saveto_pc entry1\n");
+	if (PBM_MAX_TEXT_LENGTH < strlen(pbm_name) || PBM_MAX_NUM_LENGTH < strlen(pbm_mobilephone_num)
+		||DATA_NO_SAFE == zte_Safe_noSpecialChar_ucs2(pbm_name)
+		|| DATA_NO_SAFE == zte_Safe_noSpecialChar(pbm_mobilephone_num)
+		) {
+		slog(MISC_PRINT, SLOG_ERR, "Get Data is no Safe:pbm_name:%s\n", pbm_name); /*lint !e26*/
+		cfg_set("data_safe", "failed");
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+	//add by liuyingnan for server safe for xss attack end
+	slog(MISC_PRINT, SLOG_DEBUG,"[PB] zte_web_pbm_contact_saveto_pc entry2\n");
+	/*init contact_add*/
+	memset(&pc_contact_add, 0, sizeof(pc_contact_add));
+	/*set struct value*/
+	pc_contact_add.zte_pbm_del_id = atoi(websGetVar(wp, T("delId"), T("-1")));
+	pc_contact_add.zte_pbm_location = pc_contact_location;
+	pc_contact_add.zte_pbm_id = atoi(websGetVar(wp, T("add_index_pc"), T("")));
+	memcpy(pc_contact_add.zte_pbm_name, websGetVar(wp, T("name"), T("")),
+	       sizeof(pc_contact_add.zte_pbm_name));
+	memcpy(pc_contact_add.zte_pbm_number, websGetVar(wp, T("mobilephone_num"), T("")),
+	       sizeof(pc_contact_add.zte_pbm_number));
+	memcpy(pc_contact_add.zte_pbm_anr, websGetVar(wp, T("homephone_num"), T("")),
+	       sizeof(pc_contact_add.zte_pbm_anr));
+	memcpy(pc_contact_add.zte_pbm_anr1, websGetVar(wp, T("officephone_num"), T("")),
+	       sizeof(pc_contact_add.zte_pbm_anr1));
+	memcpy(pc_contact_add.zte_pbm_email, websGetVar(wp, T("email"), T("")),
+	       sizeof(pc_contact_add.zte_pbm_email));
+	memcpy(pc_contact_add.zte_pbm_sne, websGetVar(wp, T("nick_name"), T("")),
+	       sizeof(pc_contact_add.zte_pbm_sne));
+	memcpy(pc_contact_add.zte_pbm_group, websGetVar(wp, T("groupchoose"), T("")),
+	       sizeof(pc_contact_add.zte_pbm_group));
+
+	if (pc_contact_add.zte_pbm_number[ZTE_WEB_PBM_NUMBER_TYPE_START] ==
+	    ZTE_WEB_PBM_NUMBER_TYPE_SPLIT) {
+		pc_contact_add.zte_pbm_type = ZTE_WEB_PBM_NUMBER_TYPE_1;
+	} else {
+		pc_contact_add.zte_pbm_type = ZTE_WEB_PBM_NUMBER_TYPE_2;
+	}
+	slog(MISC_PRINT, SLOG_DEBUG, "zte_web_pbm_contact_saveto_pc:send messsage to mc start"); /*lint !e26*/
+	slog(MISC_PRINT, SLOG_DEBUG, "sim_contact_add.zte_pbm_id:%d", pc_contact_add.zte_pbm_id); /*lint !e26*/
+	slog(MISC_PRINT, SLOG_DEBUG, "sim_contact_add.name:%s", pc_contact_add.zte_pbm_name); /*lint !e26*/
+	slog(MISC_PRINT, SLOG_DEBUG, "sim_contact_add.mobilephone_num:%s", pc_contact_add.zte_pbm_number); /*lint !e26*/
+	slog(MISC_PRINT, SLOG_DEBUG, "sim_contact_add.zte_pbm_type:%d", pc_contact_add.zte_pbm_type); /*lint !e26*/
+	printf("[PB] zte_web_pbm_contact_saveto_pc entry3\n");
+	/*send msg to mc*/
+	//ret_code = zte_send_message(ZUFI_MODULE_ID_AT_LOCAL,ZTE_PBM_WRITE_REC_MSG, sizeof(pc_contact_add), (char*)&pc_contact_add);
+	(void)zte_web_write(ZTE_PBM_NV, PBM_OPRATING);
+	ret_code = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_PB, MSG_CMD_WRITE_PB, sizeof(pc_contact_add), (char*)&pc_contact_add, 0);
+	if (ret_code != 0) {
+		slog(MISC_PRINT, SLOG_ERR, "mc lib relay pbm  send create modify record  fail"); /*lint !e26*/
+		(void)zte_web_write(ZTE_PBM_NV, "14");
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+	printf("zte_web_pbm_contact_saveto_pc:%d,%d,%d,%d\n", ret_code, MODULE_ID_WEB_CGI, MODULE_ID_PB, MSG_CMD_WRITE_PB);
+	slog(MISC_PRINT, SLOG_NORMAL, "zte_web_pbm_contact_saveto_pc:send messsage to mc end"); /*lint !e26*/
+	/*goto web page*/
+	zte_write_result_to_web(wp, "success");
+}
+
+/**********************************************************************
+* Function:         zte_web_pbm_utils_parseStr
+* Description:
+* Input:
+* Output:
+* Return:           void
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 20120409    V1.0        chenyi        first version
+**********************************************************************/
+static  int zte_web_pbm_utils_parseStr
+(
+    char *input,  char *output, int srcLen, int destLen, char separator
+)
+{
+	/*index*/
+	int input_ind = 0;
+	int dest_ind = 0;
+	int all_ind = 0;
+
+	/*check input*/
+	if (NULL == input || NULL == output || srcLen == 0 || destLen == 0) {
+		slog(MISC_PRINT, SLOG_ERR, "zte_web_pbm->zte_web_pbm_utils_parseStr():invalid input."); /*lint !e26*/
+		return 0;
+	}
+
+	/*handler*/
+	for (input_ind = 0; input_ind < srcLen; input_ind++) {
+		if ('\0' == input[input_ind]) {
+			*(output + destLen * dest_ind + all_ind) = '\0';
+			return dest_ind + 1;
+		}
+
+		if (separator == input[input_ind]) {
+			*(output + destLen * dest_ind + all_ind)  = '\0';
+			if ('\0' != input[input_ind + 1]) {
+				all_ind = 0;
+				dest_ind++;
+			}
+		} else {
+			*(output + destLen * dest_ind + all_ind)  = input[input_ind];
+			all_ind++;
+		}
+	}
+
+	/*return value*/
+	return dest_ind;
+}
+
+
+/**********************************************************************
+* Function:         zte_web_pbm_contact_del_part
+* Description:
+* Input:            web para
+* Output:
+* Return:           void
+*                   Others: reason of error.
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 20120409    V1.0        chenyi        first version
+**********************************************************************/
+static void zte_web_pbm_contact_del_part(webs_t wp)
+{
+	int ret_code = 0;
+	/*deleted index get from page*/
+	char del_index[PBM_WEB_MAX_CHAR_LEN] = {0};
+	/*split deleted index*/
+	char split_index[ZTE_PB_INDEX_MAX][ZTE_WEB_PBM_REC_LEN];
+	/*flag of contact number*/
+	/*index for for circle*/
+	int num_ind = 0;
+	/*data struct */
+	zte_pbm_del_multi_records_s_type sendto_data;
+
+	/*check input*/
+	if (NULL == wp) {
+		slog(MISC_PRINT, SLOG_ERR, "zte_web_pbm->zte_web_pbm_contact_del_part(): invalid input.."); /*lint !e26*/
+		return;
+	}
+
+	/*init*/
+	memset(del_index, 0, sizeof(del_index));
+	memset(&sendto_data, 0, sizeof(sendto_data));
+	memset(split_index, 0, sizeof(split_index));
+
+	/*set data struct*/
+	//sendto_data.zte_del_pbm_location = atoi(websGetVar(wp,T("savelocation1"), T("")));
+	memcpy(del_index, websGetVar(wp, T("delete_id"), T("")), sizeof(del_index));
+	sendto_data.zte_del_pbm_total = zte_web_pbm_utils_parseStr(del_index, (char *)split_index,
+	                                (int)ZTE_PB_INDEX_MAX, (int)ZTE_WEB_PBM_REC_LEN, (char)ZTE_WEB_PBM_INDEX_SPLIT_FLAG);
+	slog(MISC_PRINT, SLOG_DEBUG,"liuyingnan sendto_data.zte_del_pbm_total:%d", sendto_data.zte_del_pbm_total); /*lint !e26*/
+
+	/*del one contact*/
+	if (ZTE_WEB_PBM_DEL_MULT_OR_ONE_FLAG == sendto_data.zte_del_pbm_total) {
+		sendto_data.zte_del_pbm_id[ZTE_WEB_PBM_DEL_ONE_IND] = atoi(split_index[ZTE_WEB_PBM_DEL_ONE_IND]);
+
+#if 0
+		if (-1 == zte_mc_relay_pbm_del_one_record(&sendto_data)) {
+			slog(MISC_PRINT, SLOG_ERR, "zte_web_pbm->zte_web_pbm_contact_del_part():delete one contact failed."); /*lint !e26*/
+			zte_write_result_to_web(wp, FAILURE);
+			return;
+		}
+#endif
+		slog(MISC_PRINT, SLOG_NORMAL, "zte_web_pbm_contact_del_part:send messsage start"); /*lint !e26*/
+		//ret_code = zte_send_message(ZUFI_MODULE_ID_AT_LOCAL,ZTE_PBM_DEL_A_REC_MSG, sizeof(sendto_data), (char*)&sendto_data);
+		ret_code = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_PB, MSG_CMD_DEL_A_PB, sizeof(sendto_data), (char*)&sendto_data, 0);
+		slog(MISC_PRINT, SLOG_DEBUG, "zte_web_pbm_contact_del_part:send messsage end"); /*lint !e26*/
+		if (ret_code != 0) {
+			slog(MISC_PRINT, SLOG_ERR, "mc lib relay pbm  send DEL A record  fail"); /*lint !e26*/
+			zte_write_result_to_web(wp, FAILURE);
+			return;
+		}
+	} else {
+		/*handler*/
+		for (num_ind = 0; num_ind < sendto_data.zte_del_pbm_total; num_ind ++) {
+			sendto_data.zte_del_pbm_id[num_ind] = atoi(split_index[num_ind]);
+			printf("zte_web_pbm->zte_web_pbm_contact_del_part():split_index=[%d]", sendto_data.zte_del_pbm_id[num_ind]); /*lint !e26*/
+		}
+
+		/*handler*/
+#if 0
+		if (-1 == zte_mc_relay_pbm_del_multi_record(&sendto_data)) {
+			slog(MISC_PRINT, SLOG_ERR, "zte_web_pbm->zte_web_pbm_contact_del_part():delete mult contact failed."); /*lint !e26*/
+			zte_write_result_to_web(wp, FAILURE);
+			return;
+		}
+#endif
+		//ret_code = zte_send_message(ZUFI_MODULE_ID_AT_LOCAL,ZTE_PBM_DEL_MUTI_REC_MSG, sizeof(sendto_data), (char*)&sendto_data);
+		ret_code = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_PB, MSG_CMD_DEL_MUTI_PB, sizeof(sendto_data), (char*)&sendto_data, 0);
+		if (ret_code != 0) {
+			slog(MISC_PRINT, SLOG_ERR, "mc lib relay pbm  send DEL MUTI record  fail"); /*lint !e26*/
+			zte_write_result_to_web(wp, FAILURE);
+			return;
+		}
+	}
+	/*goto differ page*/
+	(void)zte_web_write(ZTE_PBM_NV, PBM_OPRATING);
+	zte_write_result_to_web(wp, "success");
+	//zte_web_pbm_goto_diff_page(wp,sendto_data.zte_del_pbm_location);
+}
+/**********************************************************************
+* Function:         zte_web_pbm_contact_del_all
+* Description:
+* Input:            web para
+* Output:           null
+* Return:           void
+*                   Others: reason of error.
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 20120409    V1.0        chenyi        first version
+**********************************************************************/
+static void zte_web_pbm_contact_del_all(webs_t wp)
+{
+	int ret_code = 0;
+	/*data struct*/
+	zte_pbm_del_multi_records_s_type sendto_data;
+
+	/*check input*/
+	if (NULL == wp) {
+		slog(MISC_PRINT, SLOG_ERR, "zte_web_pbm->zte_web_pbm_contact_del_all(): invalid input.."); /*lint !e26*/
+		return;
+	}
+
+	/*init*/
+	memset(&sendto_data, 0, sizeof(sendto_data));
+
+	/*set data struct*/
+	sendto_data.zte_del_pbm_location = atoi(websGetVar(wp, T("del_all_location"), T("")));
+	slog(MISC_PRINT, SLOG_DEBUG, "liuyingnan sendto_data.zte_del_pbm_location:%d", sendto_data.zte_del_pbm_location); /*lint !e26*/
+
+	/*handler del all*/
+	//(void)zte_mc_relay_pbm_del_all_record(&sendto_data);
+	slog(MISC_PRINT, SLOG_NORMAL, "zte_web_pbm_contact_del_all:send messsage start"); /*lint !e26*/
+	//ret_code = zte_send_message(ZUFI_MODULE_ID_AT_LOCAL,ZTE_PBM_DEL_ALL_REC_MSG, sizeof(sendto_data), (char*)&sendto_data);
+	ret_code = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_PB, MSG_CMD_DEL_ALL_PB, sizeof(sendto_data), (char*)&sendto_data, 0);
+	slog(MISC_PRINT, SLOG_DEBUG, "zte_web_pbm_contact_del_all:send messsage end"); /*lint !e26*/
+	if (ret_code != 0) {
+		slog(MISC_PRINT, SLOG_ERR, "mc lib relay pbm  send DEL ALL record  fail"); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+	/*goto differ page*/
+	(void)zte_web_write(ZTE_PBM_NV, PBM_OPRATING);
+	zte_write_result_to_web(wp, "success");
+	//zte_web_pbm_goto_diff_page(wp,sendto_data.zte_del_pbm_location);
+}
+/**********************************************************************
+* Function:         zte_web_pbm_contact_del_by_group
+* Description:
+* Input:            web para
+* Output:
+* Return:           void
+*                   Others: reason of error.
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 20120711    V1.0        chenyi        first version
+**********************************************************************/
+static void zte_web_pbm_contact_del_by_group(webs_t wp)
+{
+	int ret_code = 0;
+	zte_pbm_del_multi_records_s_type sendto_data;
+	char *group = NULL;
+
+	/*check input*/
+	if (NULL == wp) {
+		slog(MISC_PRINT, SLOG_ERR, "zte_web_pbm->zte_web_pbm_contact_del_by_group(): invalid input.."); /*lint !e26*/
+		return;
+	}
+
+	/*init*/
+	memset(&sendto_data, 0, sizeof(zte_pbm_del_multi_records_s_type));
+
+	group = websGetVar(wp, T("del_group"), T(""));
+	slog(MISC_PRINT, SLOG_DEBUG, "liuyingnan group:%s", group); /*lint !e26*/
+	if (0 == strcmp(group, "")) {
+		slog(MISC_PRINT, SLOG_ERR, "pbm:group is empty.\n"); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	/*set data struct*/
+	sendto_data.zte_del_pbm_location = atoi(websGetVar(wp, T("del_all_location"), T("0")));
+	slog(MISC_PRINT, SLOG_DEBUG, "liuyingnan sendto_data.zte_del_pbm_location:%d", sendto_data.zte_del_pbm_location); /*lint !e26*/
+
+	if (ZTE_NVIO_DONE != zte_web_write("pbm_group", group)) {
+		slog(MISC_PRINT, SLOG_ERR, "write the nv [pbm_group] failure.\n"); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	(void)zte_web_write(ZTE_PBM_NV, PBM_OPRATING);
+
+#if 0
+	if (ZTE_MC_OK_S != zte_mc_relay_pbm_del_all_record(&sendto_data)) {
+		slog(MISC_PRINT, SLOG_ERR, "call zte_mc_relay_pbm_del_all_record fail.\n"); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+	} else {
+		zte_write_result_to_web(wp, SUCCESS);
+	}
+#endif
+	slog(MISC_PRINT, SLOG_NORMAL, "zte_web_pbm_contact_del_by_group:send messsage start"); /*lint !e26*/
+	//ret_code = zte_send_message(ZUFI_MODULE_ID_AT_LOCAL,ZTE_PBM_DEL_ALL_REC_MSG, sizeof(sendto_data), (char*)&sendto_data);
+	ret_code = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_PB, MSG_CMD_DEL_ALL_PB, sizeof(sendto_data), (char*)&sendto_data, 0);
+	slog(MISC_PRINT, SLOG_DEBUG, "zte_web_pbm_contact_del_by_group:send messsage end"); /*lint !e26*/
+	if (ret_code != 0) {
+		slog(MISC_PRINT, SLOG_ERR, "mc lib relay pbm  send DEL record by group  fail"); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	zte_write_result_to_web(wp, "success");
+}
+
+
+/**********************************************************************
+* Function:         zte_goform_pbm_contact_add_process
+* Description:
+* Input:            null
+* Output:           null
+* Return:           void
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 20120926    V1.0        liuyingnan        first version
+**********************************************************************/
+void zte_goform_pbm_contact_add_process(webs_t wp)
+{
+	/*contact location*/
+	int contact_location = 0;
+
+	/*check input*/
+	if (NULL == wp) {
+		slog(MISC_PRINT, SLOG_ERR, "zte_web_pbm->zte_goform_pbm_contact_add_process(): invalid input.."); /*lint !e26*/
+		return;
+	}
+
+	if (0 == zte_web_pbm_check_can_process()) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	/*get the saved mem*/
+	contact_location = atoi(websGetVar(wp, T("location"), T("")));
+	slog(MISC_PRINT, SLOG_DEBUG,"[PB] zte_web_pbm_check_can_process contact_location=%d, can process.\n", contact_location);
+	/*goto different mem handler*/
+	switch (contact_location) {
+	case ZTE_WEB_PBM_CONTACT_SIM: { /*goto sim mem handler*/
+		slog(MISC_PRINT, SLOG_DEBUG,"[PB] zte_web_pbm_check_can_process sim=%d, can process.\n", ZTE_WEB_PBM_CONTACT_SIM);
+		zte_web_pbm_contact_saveto_sim(wp, ZTE_WEB_PBM_CONTACT_SIM);
+		break;
+	}
+	case ZTE_WEB_PBM_CONTACT_PC: { /*goto pc mem handler*/
+		slog(MISC_PRINT, SLOG_DEBUG,"[PB] zte_web_pbm_check_can_process pc=%d, can process.\n", ZTE_WEB_PBM_CONTACT_PC);
+		zte_web_pbm_contact_saveto_pc(wp, ZTE_WEB_PBM_CONTACT_PC);
+		break;
+	}
+
+	default: { /*unknown mem*/
+		slog(MISC_PRINT, SLOG_ERR, "zte_web_pbm->zte_goform_pbm_contact_add_process():unknown pbm mem."); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+	}
+	}
+}
+
+void zte_goform_pbm_contact_del_process(webs_t wp)
+{
+	/*check input*/
+	if (NULL == wp) {
+		slog(MISC_PRINT, SLOG_ERR, "zte_web_pbm->zte_web_pbm_contact_del_all(): invalid input.."); /*lint !e26*/
+		return;
+	}
+
+	if (0 == zte_web_pbm_check_can_process()) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	/*del the given index contact in specified mem*/
+	if (0 == strcmp(websGetVar(wp, T("del_option"), T("")), ZTE_WEB_PBM_PAGE_DEL_PART)) {
+		zte_web_pbm_contact_del_part(wp);
+	}
+
+	/*del all the contact in specified mem*/
+	else if (0 == strcmp(websGetVar(wp, T("del_option"), T("")), ZTE_WEB_PBM_PAGE_DEL_ALL)) {
+		zte_web_pbm_contact_del_all(wp);
+	}
+	//delete the pbm data by group
+	else if (0 == strcmp(websGetVar(wp, T("del_option"), T("")), ZTE_WEB_PBM_DEL_BY_GROUP)) {
+		zte_web_pbm_contact_del_by_group(wp);
+	}
+
+	else {
+		slog(MISC_PRINT, SLOG_ERR, "zte_web_pbm->zte_goform_pbm_contact_del_process():unknown pbm del."); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+	}
+
+}
+
+
+/**********************************************************************
+* Function:         zte_get_pbm_data
+* Description:      to get the pbm data info
+* Input:            the web para
+* Output:
+* Return:
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 2012/04/10    V1.0        chenyi       first version
+**********************************************************************/
+void zte_get_pbm_data(webs_t wp)
+{
+	zte_pbm_query_req_s_type pbm_query_req;
+	zte_pbm_query_resp_s_type *p_pbm_query_result = NULL;
+	int result = 0;
+	int i = 0;
+	char_t *page = NULL;
+	char_t *data_per_page = NULL;
+	char_t *mem_store = NULL;
+
+	memset(&pbm_query_req, 0, sizeof(zte_pbm_query_req_s_type));
+
+	page = websGetVar(wp, "page", T(""));
+	data_per_page = websGetVar(wp, "data_per_page", T(""));
+	mem_store = websGetVar(wp, "mem_store", T(""));
+
+	if (('\0' == *page) || ('\0' == *data_per_page) || ('\0' == *mem_store)) {
+		slog(MISC_PRINT, SLOG_ERR, "zte_get_pbm_data: invalid web para.\n"); /*lint !e26*/
+		zte_web_pbm_feed_back_empty(wp);
+		return ;
+	}
+	int tmp_page = atoi(page);
+	int tmp_num_per_page = atoi(data_per_page);
+	int location = atoi(mem_store);
+	if((tmp_page < 0 || tmp_page > 255)
+		||(tmp_num_per_page < 0 || tmp_num_per_page > 255)
+		||(location < PBM_LOCATION_SIM || location > PBM_LOCATION_MAX)){
+		slog(MISC_PRINT, SLOG_ERR, "zte_get_pbm_data:err[%d,%d,%d]\n", tmp_page,tmp_num_per_page,location); /*lint !e26*/
+		zte_web_pbm_feed_back_empty(wp);
+		return ;
+	}
+	pbm_query_req.page = (uint8)tmp_page;
+	pbm_query_req.num_per_page = (uint8)tmp_num_per_page;
+	pbm_query_req.location = (zte_pbm_location_e_type)location; //0:sim;1:device
+
+	slog(MISC_PRINT, SLOG_DEBUG, "pbm_query_req:[%u,%u,%d].\n", pbm_query_req.page, pbm_query_req.num_per_page, pbm_query_req.location); /*lint !e26*/
+
+	p_pbm_query_result = (zte_pbm_query_resp_s_type*)malloc(4 + sizeof(zte_pbm_create_ext_record_s_type) * (pbm_query_req.num_per_page));
+	if (NULL == p_pbm_query_result) {
+		slog(MISC_PRINT, SLOG_ERR, "malloc pbm result mem fail.\n"); /*lint !e26*/
+		zte_web_pbm_feed_back_empty(wp);
+		return ;/*lint !e429*/
+	}
+
+	memset(p_pbm_query_result, 0, (4 + sizeof(zte_pbm_create_ext_record_s_type) * (pbm_query_req.num_per_page)));	/*lint !e668*/
+
+	slog(MISC_PRINT, SLOG_DEBUG, "GET PBM DATA FROM DB START.\n"); /*lint !e26*/
+	result = zte_libpbm_get_rec_data(&pbm_query_req, p_pbm_query_result);
+	slog(MISC_PRINT, SLOG_DEBUG, "GET PBM DATA FROM DB END.\n"); /*lint !e26*/
+
+	if (-1 == result) {
+		slog(MISC_PRINT, SLOG_ERR, "call zte_libpbm_get_rec_data fail.\n"); /*lint !e26*/
+		zte_web_pbm_feed_back_empty(wp);
+		//free
+//		if (NULL != p_pbm_query_result) {  // kw 3
+			free(p_pbm_query_result);
+			p_pbm_query_result = NULL;
+//		}
+		return ;
+	}
+
+	slog(MISC_PRINT, SLOG_DEBUG, "total query count [%u].\n", (*p_pbm_query_result).count); /*lint !e26*/
+
+	if (0 == (*p_pbm_query_result).count) {
+		zte_web_pbm_feed_back_empty(wp);
+		//free
+//		if (NULL != p_pbm_query_result) {  kw 3
+			free(p_pbm_query_result);
+			p_pbm_query_result = NULL;
+//		}
+		return ;
+	}
+
+	//write the pbm data to web
+	for (i = 0; i < (*p_pbm_query_result).count; i++) {
+		if (0 == i) {
+			web_feedback_header(wp);
+			zte_rest_get_pbm_data_head(wp);
+			if (0 == pbm_query_req.location) {
+				zte_rest_get_pbm_data_sim(wp, p_pbm_query_result, i, 0);
+			} else {
+				zte_rest_get_pbm_data_other(wp, p_pbm_query_result, i, 0);
+			}
+		} else {
+			if (0 == pbm_query_req.location) {
+				zte_rest_get_pbm_data_sim(wp, p_pbm_query_result, i, 1);
+			} else {
+				zte_rest_get_pbm_data_other(wp, p_pbm_query_result, i, 1);
+			}
+		}
+	}
+	zte_rest_get_pbm_data_foot(wp);
+	//(void)websWrite(wp, T("]}"));
+
+	//free
+//	if (NULL != p_pbm_query_result) { // kw 3
+		free(p_pbm_query_result);
+		p_pbm_query_result = NULL;
+//	}
+}
+
+/**********************************************************************
+* Function:         zte_get_pbm_data_total
+* Description:      to get the total pbm data
+* Input:            the web para
+* Output:
+* Return:
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 2012/04/10    V1.0        chenyi       first version
+**********************************************************************/
+void zte_get_pbm_data_total(webs_t wp)
+{
+	zte_pbm_query_req_s_type pbm_query_req;
+	zte_pbm_query_resp_s_type *p_pbm_query_result = NULL;
+	int result = 0;
+	int i = 0;
+	char_t *page = NULL;
+	char_t *data_per_page = NULL;
+	char_t *mem_store = NULL;
+	char *pbm_group = NULL;
+
+	int total_pages = 0;
+	int leave_nums = 0;
+	int curr_page = 0;
+	int total_pbm = 0;
+
+	int idata_per_page = 0;
+
+	memset(&pbm_query_req, 0, sizeof(zte_pbm_query_req_s_type));
+
+	page = websGetVar(wp, "page", T(""));
+	data_per_page = websGetVar(wp, "data_per_page", T(""));
+	mem_store = websGetVar(wp, "mem_store", T(""));
+	pbm_group = websGetVar(wp, "pbm_group", T("")); //not to check whether is empty
+
+	if (('\0' == *page) || ('\0' == *data_per_page) || ('\0' == *mem_store)) {
+		slog(MISC_PRINT, SLOG_ERR, "zte_get_pbm_data: invalid web para.\n"); /*lint !e26*/
+		zte_web_pbm_feed_back_empty(wp);
+		return ;
+	}
+
+
+#if 0
+    //calculate the total pages
+    total_pages = (atoi(data_per_page)) / PBM_PAGE_RECORD_MAX_NUM;
+    leave_nums = (atoi(data_per_page)) % PBM_PAGE_RECORD_MAX_NUM;
+    
+    if (0 != leave_nums) {
+    	total_pages++;
+    }
+
+#else
+	idata_per_page = atoi(data_per_page);
+	if(idata_per_page < 0 || idata_per_page >  INT_MAX-1)
+	{
+	    total_pages = 1;
+		leave_nums = 0;
+	}
+	else
+	{
+    	//calculate the total pages
+    	total_pages = idata_per_page / PBM_PAGE_RECORD_MAX_NUM;
+    	leave_nums = idata_per_page % PBM_PAGE_RECORD_MAX_NUM;
+    
+    	if (0 != leave_nums) {
+    		total_pages++;
+    	}
+	}
+#endif
+
+	slog(MISC_PRINT, SLOG_DEBUG, "pbm:total_pages,leave_nums:[%d][%d]", total_pages, leave_nums); /*lint !e26*/
+
+	p_pbm_query_result = (zte_pbm_query_resp_s_type*)malloc(4 + sizeof(zte_pbm_create_ext_record_s_type) * PBM_PAGE_RECORD_MAX_NUM);
+	if (NULL == p_pbm_query_result) {
+		slog(MISC_PRINT, SLOG_ERR, "malloc pbm result mem fail.\n"); /*lint !e26*/
+		zte_web_pbm_feed_back_empty(wp);
+		return ;/*lint !e429*/
+	}
+
+	(void)zte_web_write("pbm_group", pbm_group); //only wrtite one time
+
+	for (curr_page = 0; curr_page < total_pages; curr_page++) {
+
+		//reset
+		memset(&pbm_query_req, 0, sizeof(zte_pbm_query_req_s_type));
+
+		pbm_query_req.page = curr_page;
+		pbm_query_req.num_per_page = PBM_PAGE_RECORD_MAX_NUM;
+		/*lint -e64*/
+		pbm_query_req.location = atoi(mem_store); //0:sim;1:device
+
+		slog(MISC_PRINT, SLOG_DEBUG, "pbm_query_req:[%u,%u,%d].\n", pbm_query_req.page, pbm_query_req.num_per_page, pbm_query_req.location); /*lint !e26*/
+
+		//reset
+		memset(p_pbm_query_result, 0, 4 + sizeof(zte_pbm_create_ext_record_s_type)*PBM_PAGE_RECORD_MAX_NUM); /*lint !e668*/
+
+		slog(MISC_PRINT, SLOG_NORMAL, "GET PBM DATA FROM DB START.\n"); /*lint !e26*/
+		result = zte_libpbm_get_rec_data(&pbm_query_req, p_pbm_query_result);
+		slog(MISC_PRINT, SLOG_DEBUG, "GET PBM DATA FROM DB END.\n"); /*lint !e26*/
+
+		if (-1 == result) {
+			slog(MISC_PRINT, SLOG_DEBUG, "read pbm page [%d] fail.\n", curr_page); /*lint !e26*/
+			//free
+//			if (NULL != p_pbm_query_result) {  // kw 3
+				free(p_pbm_query_result);
+				p_pbm_query_result = NULL;
+//			}
+
+			if (0 == curr_page) {
+				zte_web_pbm_feed_back_empty(wp);
+				return ;
+			} else {
+				break;
+			}
+		}
+
+		slog(MISC_PRINT, SLOG_DEBUG, "pbm:total query count [%u].\n", (*p_pbm_query_result).count); /*lint !e26*/
+
+		if (0 == (*p_pbm_query_result).count) {
+			//free
+//			if (NULL != p_pbm_query_result) {  // kw 3
+				free(p_pbm_query_result);
+				p_pbm_query_result = NULL;
+//			}
+
+			if (0 == curr_page) {
+				zte_web_pbm_feed_back_empty(wp);
+				return ;
+			} else {
+				break;
+			}
+		}
+
+		//write the pbm data to web
+		for (i = 0; (i < (*p_pbm_query_result).count) && (total_pbm < atoi(data_per_page)); i++, total_pbm++) {
+			if ((0 == i) && (0 == curr_page)) {
+				web_feedback_header(wp);
+				zte_rest_get_pbm_data_head(wp);
+				if (0 == pbm_query_req.location) {
+					zte_rest_get_pbm_data_sim(wp, p_pbm_query_result, i, 0);
+				} else {
+					zte_rest_get_pbm_data_other(wp, p_pbm_query_result, i, 0);
+				}
+			} else {
+				if (0 == pbm_query_req.location) {
+					zte_rest_get_pbm_data_sim(wp, p_pbm_query_result, i, 1);
+				} else {
+					zte_rest_get_pbm_data_other(wp, p_pbm_query_result, i, 1);
+				}
+			}
+		}
+
+	}
+
+
+	zte_rest_get_pbm_data_foot(wp);
+	//free
+//	if (NULL != p_pbm_query_result) {  // kw 3
+		free(p_pbm_query_result);
+		p_pbm_query_result = NULL;
+//	}
+}
+
+/**********************************************************************
+* Function:         zte_get_pbm_parameter_info
+* Description:      to get the pbm parameter info
+* Input:            the web para
+* Output:
+* Return:
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 2012/04/10    V1.0        chenyi       first version
+**********************************************************************/
+void zte_get_pbm_parameter_info(webs_t wp)
+{
+	zte_pbm_query_req_s_type pbm_para_query_info;
+	zte_pbm_sim_capability_s_type pbm_sim_capability_s;
+	zte_pbm_device_capability_s_type pbm_device_capability_s;
+	char *pbm_location = NULL;
+	int result = 0;
+
+	//initialize
+	memset(&pbm_para_query_info, 0, sizeof(zte_pbm_query_req_s_type));
+	memset(&pbm_sim_capability_s, 0, sizeof(zte_pbm_sim_capability_s_type));
+	memset(&pbm_device_capability_s, 0, sizeof(zte_pbm_device_capability_s_type));
+
+	pbm_location = websGetVar(wp, "pbm_location", T(""));
+
+	if (0 == strcmp(pbm_location, "")) {
+		slog(MISC_PRINT, SLOG_ERR, "pbm_location is empty.\n"); /*lint !e26*/
+		zte_web_pbm_feed_back_empty(wp);
+		return;
+	}
+
+	slog(MISC_PRINT, SLOG_DEBUG, "pbm_location is [%s].\n", pbm_location); /*lint !e26*/
+
+	if (0 == strcmp(pbm_location, PBM_NATIVE)) {
+		pbm_para_query_info.location = PBM_LOCATION_DEVICE;
+	} else if (0 == strcmp(pbm_location, PBM_SIM)) {
+		pbm_para_query_info.location = PBM_LOCATION_SIM;
+	} else {
+		slog(MISC_PRINT, SLOG_ERR, "invalid pbm_location[%s].\n", pbm_location); /*lint !e26*/
+		zte_web_pbm_feed_back_empty(wp);
+		return;
+	}
+	slog(MISC_PRINT, SLOG_NORMAL, "GET PBM DATA FROM DB START.\n"); /*lint !e26*/
+	result = zte_libpbm_get_capability(&pbm_para_query_info, &pbm_sim_capability_s, &pbm_device_capability_s);
+	slog(MISC_PRINT, SLOG_DEBUG, "GET PBM DATA FROM DB END.\n"); /*lint !e26*/
+	if (-1 == result) {
+		slog(MISC_PRINT, SLOG_ERR, "call zte_libpbm_get_capability fail.\n"); /*lint !e26*/
+		zte_web_pbm_feed_back_empty(wp);
+		return ;
+	}
+
+	web_feedback_header(wp);
+	if (0 == strcmp(pbm_location, PBM_NATIVE)) {
+		zte_rest_cmd_write_head(wp);
+		zte_rest_cmd_write_int(wp, PBM_DEV_MAX_RECORD_NUM, pbm_device_capability_s.max_record_number, 1);
+		zte_rest_cmd_write_int(wp, PBM_DEV_USED_RECORD_NUM, pbm_device_capability_s.used_record_number, 0);
+		zte_rest_cmd_write_foot(wp);
+	} else {
+		zte_rest_cmd_write_head(wp);
+		zte_rest_cmd_write_int(wp, PBM_SIM_SIM_TYPE, pbm_sim_capability_s.sim_type, 1);
+		zte_rest_cmd_write_int(wp, PBM_SIM_MAX_RECORD_NUM, pbm_sim_capability_s.max_record_number, 1);
+		zte_rest_cmd_write_int(wp, PBM_SIM_USED_RECORD_NUM, pbm_sim_capability_s.used_record_number, 1);
+		zte_rest_cmd_write_int(wp, PBM_SIM_MAX_NAME_LEN, pbm_sim_capability_s.max_name_len, 1);
+		zte_rest_cmd_write_int(wp, PBM_SIM_MAX_NUMBER_LEN, pbm_sim_capability_s.max_number_len, 0);
+		zte_rest_cmd_write_foot(wp);
+	}
+}
+
+/**********************************************************************
+* Function:         zte_web_pbm_feed_back_empty
+* Description:      to write empty info to web
+* Input:            the web para
+* Output:
+* Return:
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 2012/04/10    V1.0        chenyi       first version
+**********************************************************************/
+
+static void zte_web_pbm_feed_back_empty(webs_t wp)
+{
+	if (NULL == wp) {
+		return;
+	}
+
+	web_feedback_header(wp);
+	if (wp->flags & WEBS_XML_CLIENT_REQUEST) {
+		websWrite(wp, T("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"));
+		websWrite(wp, T("<%s>empty</%s>\n"), PBM_DATA, PBM_DATA);
+	} else {
+		(void)websWrite(wp, T("{\"%s\":[]}"), PBM_DATA);
+	}
+	//(void)websWrite(wp, T("{\"%s\":[]}"),PBM_DATA);
+}
+//added by chenyi for handle the http request end 20111118
+
diff --git a/lynq/S300/ap/app/goahead/interface5.0/zte_web_sms.c b/lynq/S300/ap/app/goahead/interface5.0/zte_web_sms.c
new file mode 100755
index 0000000..42b59aa
--- /dev/null
+++ b/lynq/S300/ap/app/goahead/interface5.0/zte_web_sms.c
@@ -0,0 +1,1699 @@
+/************************************************************************
+* °æÈ¨ËùÓÐ (C)2010, ÉîÛÚÊÐÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+*
+* ÎļþÃû³Æ£º zte_web_mgmt.c
+* Îļþ±êʶ£º
+* ÄÚÈÝÕªÒª£º
+* ÆäËü˵Ã÷£º
+* µ±Ç°°æ±¾£º V0.1
+* ×÷    Õߣº zyt
+* Íê³ÉÈÕÆÚ£º 2010-11-06
+*
+* Ð޸ļǼ1£º
+* ÐÞ¸ÄÄÚÈÝ£º³õʼ°æ±¾
+************************************************************************/
+
+/**************************************************************************
+* Ð޸ıàºÅ : й¦ÄÜ
+* ÐÞ ¸Ä ÈË : chenjie10092374
+* ÐÞ¸ÄÈÕÆÚ : 2014.6.24
+* ÐÞ¸ÄÄÚÈÝ : Ìí¼ÓÖ§³Öufi monitor¹¦ÄÜ´¦Àí´úÂë
+**************************************************************************/
+
+#include "zte_web_interface.h"
+//#include "sms_com.h"
+#include "zte_web_get_fw_para.h"
+#include "zte_web_sms.h"
+
+
+#define  UPCASE( c ) ( ((c) >= 'a' && (c) <= 'z') ? ((c) - 0x20) : (c) )
+
+extern void zte_rest_get_sms_data_head(webs_t wp);
+extern void zte_rest_get_sms_data_foot(webs_t wp);
+extern void zte_rest_get_bro_data_head(webs_t wp);
+extern void zte_rest_get_bro_data_foot(webs_t wp);
+extern void zte_rest_get_sms_data(webs_t wp, zte_sms_query_result *p_sms_query_result, int i, int tag);
+extern void zte_rest_sms_parameter(webs_t wp, T_zUfiSms_ParaInfo sms_parameter_info);
+extern void zte_rest_sms_status_rpt(webs_t wp, zte_sms_query_result *p_sms_query_result, int i, int tag);
+extern void zte_rest_boradcast_data(webs_t wp, zte_wms_cell_bro_s_type *p_bro_query_result);
+static void zte_web_feed_back_empty(webs_t wp);
+static unsigned int parseStrBySeparator(unsigned char *input, unsigned char *output,  int destLen, unsigned char separator);
+//static int asc_util_atoi(unsigned int *val_arg_ptr,  const unsigned char *s, unsigned int r);
+//static int  sms_util_asc_to_hex(unsigned char  *in_ptr, unsigned char *out_ptr, int   len);
+
+#define WebSms_LOG(priority,...) do {  \
+	printf(__VA_ARGS__); \
+} while(0)
+
+
+VOID zte_sms_handle_DB_status_whenSend(int cmd_status)
+{
+	T_zUfiSms_StatusInfo statusInfo;
+	memset((void*)&statusInfo, 0, sizeof(T_zUfiSms_StatusInfo));
+	statusInfo.cmd = WMS_SMS_CMD_MSG_SEND;
+	statusInfo.cmd_status = cmd_status;
+	statusInfo.err_code = ZTE_SMS_CMS_NONE;
+	statusInfo.send_failed_count = 0;
+	statusInfo.delete_failed_count = 0;
+
+	zte_libwms_setSmsCmdStatus(&statusInfo);
+}
+
+VOID zte_sms_handle_DB_status(int cmd, int cmd_status)
+{
+	T_zUfiSms_StatusInfo statusInfo;
+	memset((void*)&statusInfo, 0, sizeof(T_zUfiSms_StatusInfo));
+	statusInfo.cmd = cmd;
+	statusInfo.cmd_status = cmd_status;
+	statusInfo.err_code = ZTE_SMS_CMS_NONE;
+	statusInfo.send_failed_count = 0;
+	statusInfo.delete_failed_count = 0;
+
+	zte_libwms_setSmsCmdStatus(&statusInfo);
+}
+
+/*
+*Ôö¼Ó´Ëº¯ÊýÅжÏÖ÷ÒªÊÇÒòΪÁ÷Á¿Ð£×¼¹¦ÄÜÒ²»á·¢¶ÌÐÅ
+*ΪÁ˱£Ö¤ATSERVERÁ÷³Ì´¦ÀíµÄÒ»ÖÂÐÔ£¬¼Ó´ËÅжÏ
+*/
+int zte_sms_check_can_send_sms()
+{
+	T_zUfiSms_StatusInfo cmd_status_info = {0};
+	int result = 0;
+	char buf1[NV_ITEM_STRING_LEN_10] = {0};
+	char buf2[NV_ITEM_STRING_LEN_10] = {0};
+	char buf3[NV_ITEM_STRING_LEN_20] = {0};
+
+	/*
+	*ÒÔϼ¸ÖÖÇé¿ö¿ÉÒÔ²»ÅжÏ:
+	*(1)Á÷Á¿Ð£×¼¹¦ÄÜδ´ò¿ª;
+	*(2)Á÷Á¿Ð£×¼¹¦ÄÜÒÑ´ò¿ª£¬µ«ÊÇĿǰ²»ÔÚÔËÐÐÖУ»
+	*(3)Á÷Á¿Ð£×¼¹¦ÄÜÒÑ´ò¿ªÇÒÔÚÔËÐÐÖУ¬µ«²»ÔÚ·¢ËͶÌÐŹý³ÌÖУ»
+	*×¢:ʵ¼ÊÉÏÊöÈýµãÌõ¼þ¶¼¿ÉÒÔ¹éΪÌõ¼þ(3)Ò»Ìõ½øÐÐÅжϼ´¿É£¬
+	*       µ«´Ë´¦ÎªÁ˱ãÓÚÀí½âά»¤£¬»¹ÊÇÔÚ´úÂë²ãÃæ·ÖÈý¸öÌõ¼þÅжϴ¦Àí¡£
+	*/
+	cfg_get_item(NV_DATA_TRAFFIC_SWITCH, &buf1, sizeof(buf1));
+	cfg_get_item("is_traffic_alining", buf2, sizeof(buf2));
+	cfg_get_item("traffic_sms_number", buf3, sizeof(buf3));
+
+	if ((0 != strcmp(buf1, "yes"))
+	    || (0 == strcmp(buf2, "no"))
+	    || (0 == strcmp(buf3, "0"))) {
+		slog(MISC_PRINT, SLOG_DEBUG,"[traffic] zte_sms_check_can_send_sms, no need to check!\n");
+		return  0;
+	}
+
+	cmd_status_info.cmd = WMS_SMS_CMD_MSG_SEND;
+	result = zte_libwms_get_cmd_status(&cmd_status_info);
+	if (result == -1) {
+		return 0;
+	}
+
+	if (cmd_status_info.cmd_status == WMS_CMD_PROCESSING) {
+		return -1;
+	}
+
+	return 0;
+}
+
+int hex_check(char *buf)
+{
+	int i = 0;
+	int len = strlen(buf);
+	for (i = 0; i < len; i++) {
+		if(!isxdigit(buf[i]))
+			return -1;
+	}
+	return i;
+}
+
+void zte_sms_send_msg_process(webs_t wp)
+{
+	unsigned int i = 0;
+	//int j = 0;
+	int message_content_len = 0;
+	unsigned int   rec_count = 0;
+	unsigned char encode_type = 0;
+	char_t *sms_encode_type = NULL;
+	char_t *msg_id = NULL;
+	unsigned char *msg_content_web = NULL;
+	//char_t *which_page = NULL;
+	char_t *sms_time = NULL;
+	int s_flag = 0; //to distinguish time field from time string
+	int index = 0;
+	unsigned char *rec_number = NULL;
+	unsigned char rec_separate[ZTE_WMS_SEND_NUM_MAX][ZTE_WMS_ADDRESS_LEN_MAX + 1] = {0};
+	T_zUfiSms_SendReq  MSG_SEND_ST;
+
+	memset(&MSG_SEND_ST, 0, sizeof(T_zUfiSms_SendReq));
+	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User send msg!\n"));
+	//which_page = websGetVar(wp, "which_cgi", T(""));
+	rec_number = websGetVar(wp, "Number", T(""));
+	msg_content_web = websGetVar(wp, "MessageBody", T(""));
+	msg_id = websGetVar(wp, "ID", T(""));
+	sms_encode_type = websGetVar(wp, "encode_type", T(""));
+	sms_time = websGetVar(wp, "sms_time", T(""));
+
+	//add by liuyingnan for server safe for xss attack start
+	if (DATA_NO_SAFE == zte_Safe_noSpecialChar(msg_content_web)
+	    || DATA_NO_SAFE == zte_Safe_noSpecialChar(rec_number)
+	    || hex_check(msg_content_web) < 0) {
+		cfg_set("data_safe", "failed");
+		slog(MISC_PRINT, SLOG_ERR,"Get Data is no Safe:msg_content_web:%s\n", msg_content_web); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+	//add by liuyingnan for server safe for xss attack end
+
+	/* adjust the number and contents' form */
+	message_content_len = strlen(msg_content_web) / 2;
+	slog(MISC_PRINT, SLOG_DEBUG, "goahead==message_content_len=%d", message_content_len); /*lint !e26*/
+	rec_count = parseStrBySeparator(rec_number, (unsigned char *)rec_separate, ZTE_WMS_ADDRESS_LEN_MAX + 1, SEPARATOR_CHARACTER);
+
+	if (0 == strcmp("ASCII", sms_encode_type)) { //not include chinese
+		encode_type = DCS_ASC;
+	} else if (0 == strcmp("UNICODE", sms_encode_type)) {
+		encode_type = DCS_UNICODE;
+	} else if (0 == strcmp("GSM7_span", sms_encode_type)) {
+		encode_type = DCS_SPANISH;
+	} else if (0 == strcmp("GSM7_default", sms_encode_type)) {
+		slog(MISC_PRINT, SLOG_DEBUG, "goahead==GSM7_default==sms_encode_type=%s", sms_encode_type); /*lint !e26*/
+		encode_type = DCS_GSM7_DEFAULT;
+		slog(MISC_PRINT, SLOG_DEBUG,"goahead==end==encode_type=%d", encode_type); /*lint !e26*/
+	} else if (0 == strcmp("GSM7_turkey", sms_encode_type)) {
+		encode_type = DCS_TURKISH;
+	} else {
+		slog(MISC_PRINT, SLOG_DEBUG, "invalid sms_encode_type [%s]! \n", sms_encode_type); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	//parse the time field
+	for (i = 0; i < strlen(sms_time); i++) {
+		if (';' == sms_time[i]) {
+			s_flag++;
+			index = 0;
+			continue;
+		}
+
+		if ((0 == s_flag) && (index < (sizeof(MSG_SEND_ST.date.year) - 1))) {
+			MSG_SEND_ST.date.year[index++] = sms_time[i];
+		} else if ((1 == s_flag) && (index < (sizeof(MSG_SEND_ST.date.month) - 1))) {
+			MSG_SEND_ST.date.month[index++] = sms_time[i];
+		} else if ((2 == s_flag) && (index < (sizeof(MSG_SEND_ST.date.day) - 1))) {
+			MSG_SEND_ST.date.day[index++] = sms_time[i];
+		} else if ((3 == s_flag) && (index < (sizeof(MSG_SEND_ST.date.hour) - 1))) {
+			MSG_SEND_ST.date.hour[index++] = sms_time[i];
+		} else if ((4 == s_flag) && (index < (sizeof(MSG_SEND_ST.date.min) - 1))) { /*lint !e123*/
+			MSG_SEND_ST.date.min[index++] = sms_time[i];/*lint !e123*/
+		} else if ((5 == s_flag) && (index < (sizeof(MSG_SEND_ST.date.sec) - 1))) {
+			MSG_SEND_ST.date.sec[index++] = sms_time[i];
+		} else if ((6 == s_flag) && (index < (sizeof(MSG_SEND_ST.date.timezone) - 1))) {
+			MSG_SEND_ST.date.timezone[index++] = sms_time[i];
+		}
+
+	}
+
+	slog(MISC_PRINT, SLOG_DEBUG,"zte_sms_send_msg_process:year is [%s];"\
+	           "month is [%s];day is [%s];hour is [%s];minute is [%s];second is [%s];timezone is [%s].\n", \
+	           MSG_SEND_ST.date.year, MSG_SEND_ST.date.month, MSG_SEND_ST.date.day, \
+	           MSG_SEND_ST.date.hour, MSG_SEND_ST.date.min, MSG_SEND_ST.date.sec, \
+	           MSG_SEND_ST.date.timezone);/*lint !e26 !e123 */
+
+	/* stuff the struct which is sending to mc */
+	slog(MISC_PRINT, SLOG_DEBUG, "goahead==============msg_content_web==========%s", msg_content_web); /*lint !e26*/
+	slog(MISC_PRINT, SLOG_DEBUG, "goahead=========message_content_len=%d", message_content_len); /*lint !e26*/
+//  concat sms
+	zte_libwms_db_write_send_msg_content_data(msg_content_web);
+	//doSystem("sleep 1");
+	slog(MISC_PRINT, SLOG_NORMAL, "Send message to database succesful!\n"); /*lint !e26*/
+#if 0  // Ô­À´²»Ö§³Ö¼¶Áª¶ÌÐŵĴúÂë
+	(void)sms_util_asc_to_hex(msg_content_web, MSG_SEND_ST.msg_content, message_content_len);
+#endif
+	MSG_SEND_ST.msg_len = message_content_len;
+
+	MSG_SEND_ST.dcs = encode_type;
+
+	MSG_SEND_ST.receiver_count = rec_count;
+	memcpy(MSG_SEND_ST.dest_num, rec_separate, sizeof(rec_separate));
+
+	//handle whether to delete the old sms begin
+	if (0 != strcmp(msg_id, "")) {
+		MSG_SEND_ST.id = atol(msg_id); //-1:new msg
+	} else {
+		slog(MISC_PRINT, SLOG_ERR, "invalid msg_id [%s]! \n", msg_id); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+	//handle whether to delete the old sms end
+
+#if 0
+	if (0 == strcmp(which_page, NEW_MESSAGE)) {
+		MSG_SEND_ST.db = ZTE_WMS_TABLE_NV;
+	} else if (0 == strcmp(which_page, NATIVE_INBOX) || 0 == strcmp(which_page, NATIVE_DRAFTBOX)) {
+		MSG_SEND_ST.db = ZTE_WMS_TABLE_NV;
+	} else if (0 == strcmp(which_page, SIM_INBOX) || 0 == strcmp(which_page, SIM_DRAFTBOX)) {
+		MSG_SEND_ST.db = ZTE_WMS_TABLE_SIM;
+	} else {
+		WebSms_LOG(LOG_INFO, "invalid which_page [%s]! \n", which_page); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+#endif
+
+	if (0 != zte_sms_check_can_send_sms()) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	/* mc interface */
+	zte_sms_handle_DB_status_whenSend(WMS_CMD_PROCESSING);
+	if (ZTE_MC_OK_S == zte_mc_relay_sms_send_msg((T_zUfiSms_SendReq*)(&MSG_SEND_ST))) {
+		slog(MISC_PRINT, SLOG_NORMAL, "zte_sms_send_msg_process:Send message to mc successful!\n"); /*lint !e26*/
+		zte_write_result_to_web(wp, SUCCESS);
+	} else {
+		zte_sms_handle_DB_status_whenSend(WMS_CMD_FAILED);
+		slog(MISC_PRINT, SLOG_ERR, "zte_sms_send_msg_process:Send message to mc fail!\n"); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+	}
+
+}
+void zte_sms_save_msg_process(webs_t wp)
+{
+	//int j = 0;
+	unsigned int i = 0;
+	unsigned int   rec_count = 0;
+	unsigned char *rec_number = NULL;
+	char_t *msg_id = NULL;
+	int message_content_len = 0;
+	unsigned char encode_type = 0;
+	unsigned char *msg_content_web = NULL;
+	char_t *sms_encode_type = NULL;
+	//char_t *which_page = NULL;
+	char_t *sms_time = NULL;
+	int s_flag = 0; //to distinguish time field from time string
+	int index = 0;
+	unsigned char rec_separate[ZTE_WMS_SEND_NUM_MAX][ZTE_WMS_ADDRESS_LEN_MAX + 1] = {0};   //separate receiver phone number
+	T_zUfiSms_SaveReq  MSG_SAVE_ST;
+	char_t *mem_store = NULL;
+	char_t *tags = NULL;
+	char_t *draft_group_id = NULL;
+
+	memset(&MSG_SAVE_ST, 0, sizeof(T_zUfiSms_SaveReq));
+	mem_store = websGetVar(wp, "location", T("1"));
+	tags = websGetVar(wp, "tags", T("4"));
+	//which_page = websGetVar(wp, "which_cgi", T(""));
+	msg_content_web = websGetVar(wp, "SMSMessage", T(""));
+	rec_number = websGetVar(wp, "SMSNumber", T(""));
+	msg_id = websGetVar(wp, "Index", T(""));
+	sms_encode_type = websGetVar(wp, "encode_type", T(""));
+	sms_time = websGetVar(wp, "sms_time", T(""));
+	draft_group_id = websGetVar(wp, "draft_group_id", T(""));
+
+	//add by liuyingnan for server safe for xss attack start
+	if (DATA_NO_SAFE == zte_Safe_noSpecialChar(msg_content_web)
+	    || DATA_NO_SAFE == zte_Safe_noSpecialChar(rec_number) 
+	    || hex_check(msg_content_web) < 0) {
+		cfg_set("data_safe", "failed");
+		slog(MISC_PRINT, SLOG_DEBUG, "Get Data is no Safe:msg_content_web:%s\n", msg_content_web); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+	//add by liuyingnan for server safe for xss attack end
+
+	/* adjust the contents' form */
+	message_content_len = strlen(msg_content_web) / 2;
+
+	if (0 == strcmp("ASCII", sms_encode_type)) { //not include chinese
+		encode_type = DCS_ASC;
+	} else if (0 == strcmp("UNICODE", sms_encode_type)) {
+		encode_type = DCS_UNICODE;
+	} else if (0 == strcmp("GSM7_span", sms_encode_type)) {
+		encode_type = DCS_SPANISH;
+	} else if (0 == strcmp("GSM7_default", sms_encode_type)) {
+		encode_type = DCS_GSM7_DEFAULT;
+	} else if (0 == strcmp("GSM7_turkey", sms_encode_type)) {
+		encode_type = DCS_TURKISH;
+	} else {
+		slog(MISC_PRINT, SLOG_DEBUG, "invalid sms_encode_type [%s]! \n", sms_encode_type); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	//parse the time field
+	for (i = 0; i < strlen(sms_time); i++) {
+		if (';' == sms_time[i]) {
+			s_flag++;
+			index = 0;
+			continue;
+		}
+
+		if ((0 == s_flag) && (index < (sizeof(MSG_SAVE_ST.date.year) - 1))) {
+			MSG_SAVE_ST.date.year[index++] = sms_time[i];
+		} else if ((1 == s_flag) && (index < (sizeof(MSG_SAVE_ST.date.month) - 1))) {
+			MSG_SAVE_ST.date.month[index++] = sms_time[i];
+		} else if ((2 == s_flag) && (index < (sizeof(MSG_SAVE_ST.date.day) - 1))) {
+			MSG_SAVE_ST.date.day[index++] = sms_time[i];
+		} else if ((3 == s_flag) && (index < (sizeof(MSG_SAVE_ST.date.hour) - 1))) {
+			MSG_SAVE_ST.date.hour[index++] = sms_time[i];
+		} else if ((4 == s_flag) && (index < (sizeof(MSG_SAVE_ST.date.min) - 1))) { /*lint !e123*/
+			MSG_SAVE_ST.date.min[index++] = sms_time[i];/*lint !e123*/
+		} else if ((5 == s_flag) && (index < (sizeof(MSG_SAVE_ST.date.sec) - 1))) {
+			MSG_SAVE_ST.date.sec[index++] = sms_time[i];
+		} else if ((6 == s_flag) && (index < (sizeof(MSG_SAVE_ST.date.timezone) - 1))) {
+			MSG_SAVE_ST.date.timezone[index++] = sms_time[i];
+		}
+
+	}
+
+	slog(MISC_PRINT, SLOG_DEBUG, "zte_sms_save_msg_process:year is [%s];"\
+	           "month is [%s];day is [%s];hour is [%s];minute is [%s];second is [%s];timezone is [%s].\n", \
+	           MSG_SAVE_ST.date.year, MSG_SAVE_ST.date.month, MSG_SAVE_ST.date.day, \
+	           MSG_SAVE_ST.date.hour, MSG_SAVE_ST.date.min, MSG_SAVE_ST.date.sec, \
+	           MSG_SAVE_ST.date.timezone);/*lint !e26 !e123 */
+//CONCAT_SMS
+	zte_libwms_db_write_send_msg_content_data(msg_content_web);
+	//doSystem("sleep 1");
+	slog(MISC_PRINT, SLOG_DEBUG, "Send message to database succesful!\n"); /*lint !e26*/
+#if 0  // Ô­À´²»Ö§³Ö¼¶Áª¶ÌÐŵĴúÂë
+	/* stuff the struct which is sending to mc */
+	(void)sms_util_asc_to_hex(msg_content_web, MSG_SAVE_ST.msg_content, message_content_len);
+#endif
+
+	MSG_SAVE_ST.msg_len = message_content_len;
+	rec_count = parseStrBySeparator(rec_number, (unsigned char *)rec_separate, ZTE_WMS_ADDRESS_LEN_MAX + 1, SEPARATOR_CHARACTER);
+
+
+	MSG_SAVE_ST.receiver_count = rec_count;
+	memcpy(MSG_SAVE_ST.dest_num, rec_separate, sizeof(rec_separate));
+	memcpy(MSG_SAVE_ST.draft_group_id, draft_group_id, sizeof(MSG_SAVE_ST.draft_group_id));
+
+	MSG_SAVE_ST.dcs = encode_type;
+	MSG_SAVE_ST.mem_store = (unsigned char)atoi(mem_store);
+	MSG_SAVE_ST.tags = (unsigned char)atoi(tags);
+	//handle whether to delete the old sms begin
+	if (0 != strcmp(msg_id, "")) {
+		MSG_SAVE_ST.id = atol(msg_id); //-1:new msg
+	} else {
+		slog(MISC_PRINT, SLOG_DEBUG, "invalid msg_id [%s]! \n", msg_id); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+	//handle whether to delete the old sms end
+
+#if 0
+	if (0 == strcmp(which_page, NEW_MESSAGE)) {
+		MSG_SAVE_ST.db = ZTE_WMS_TABLE_NV;
+	} else if (0 == strcmp(which_page, NATIVE_INBOX) || 0 == strcmp(which_page, NATIVE_DRAFTBOX)) {
+		MSG_SAVE_ST.db = ZTE_WMS_TABLE_NV;
+	} else if (0 == strcmp(which_page, SIM_INBOX) || 0 == strcmp(which_page, SIM_DRAFTBOX)) {
+		MSG_SAVE_ST.db = ZTE_WMS_TABLE_SIM;
+	} else {
+		WebSms_LOG(LOG_INFO, "invalid which_page [%s]! \n", which_page); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+#endif
+
+	/* print log */
+	for (i = 0; i < rec_count; i++) {
+		slog(MISC_PRINT, SLOG_DEBUG, "MSG_SAVE_ST.dest_num = [%s]\n", MSG_SAVE_ST.dest_num[i]); /*lint !e26*/
+	}
+
+	slog(MISC_PRINT, SLOG_DEBUG, "web_sms:message_content_len = [%d]\n", message_content_len);	/*lint !e26*/
+#if 0
+	for (j = 0; j < message_content_len; j++) {
+		WebSms_LOG(LOG_INFO, "web_sms:MSG_SAVE_ST content=[%x]\n", MSG_SAVE_ST.msg_content[j]); /*lint !e26*/
+	}
+#endif
+	/* mc interface */
+
+	if (ZTE_MC_OK_S == zte_mc_relay_sms_write_msg((T_zUfiSms_SaveReq*)(&MSG_SAVE_ST))) {
+		slog(MISC_PRINT, SLOG_NORMAL, "web_sms:Send message to mc successful!(save msg)\n"); /*lint !e26*/
+		zte_write_result_to_web(wp, SUCCESS);
+	} else {
+		slog(MISC_PRINT, SLOG_ERR, "web_sms:Send message to mc fail!(save msg)\n"); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+	}
+
+	//zte_write_result_to_web(wp,SUCCESS);
+}
+
+void zte_sms_delete_msg_process(webs_t wp)
+{
+	unsigned int i = 0;
+	unsigned int j = 0;
+	unsigned int   msg_id_count = 0;
+	unsigned char *msg_id = NULL;                                             //receiver phone number get from web
+	unsigned char msg_id_separate[ZTE_WMS_DELETE_COUNT_MAX][WMS_MODULE_ID_LEN] = {0};             //separate receiver phone number
+	T_zUfiSms_DelReq  del_sms_setting;
+	//char_t *which_page = NULL;
+	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User delete msg!\n"));
+	WebSms_LOG(LOG_INFO, T("[SMS] User delete msg!"));
+
+	memset(&del_sms_setting, 0, sizeof(T_zUfiSms_DelReq));
+
+	msg_id = websGetVar(wp, "msg_id", T(""));
+	//which_page = websGetVar(wp, "which_cgi", T(""));
+
+	slog(MISC_PRINT, SLOG_DEBUG, "web para:[msg_id] is [%s].\n", msg_id); /*lint !e26*/
+	//WebSms_LOG(LOG_INFO,"web para:[which_page] is [%s].\n",which_page);/*lint !e26*/
+
+	msg_id_count = parseStrBySeparator(msg_id, (unsigned char *)msg_id_separate, WMS_MODULE_ID_LEN, SEPARATOR_CHARACTER);
+	slog(MISC_PRINT, SLOG_DEBUG,"!!!!goahead enter delete msg!!msg_id:%s/msg_id_count:%d.\n", msg_id, msg_id_count);
+
+	del_sms_setting.all_or_count = msg_id_count;
+	for (i = 0; i < msg_id_count; i++) {
+		del_sms_setting.id[i] = atoi(msg_id_separate[i]);
+	}
+
+	for (j = 0; j < msg_id_count; j++) {
+		slog(MISC_PRINT, SLOG_DEBUG,"zte_sms_delete_msg_process:delete msg number:[%lu]\n", del_sms_setting.id[j]);/*lint !e26*/
+	}
+	/* mc interface */
+
+	zte_sms_handle_DB_status(WMS_SMS_CMD_MSG_DELETE, WMS_CMD_PROCESSING);
+	if (ZTE_MC_OK_S == zte_mc_relay_sms_delete_msg((T_zUfiSms_DelReq*)(&del_sms_setting))) {
+		slog(MISC_PRINT, SLOG_DEBUG,"zte_sms_delete_msg_process:send delete sms cmd to mc success.\n");/*lint !e26*/
+		zte_write_result_to_web(wp, SUCCESS);
+	} else {
+		slog(MISC_PRINT, SLOG_DEBUG,"zte_sms_delete_msg_process:send delete sms cmd to mc fail.\n");/*lint !e26*/
+		zte_sms_handle_DB_status(WMS_SMS_CMD_MSG_DELETE, WMS_CMD_FAILED);
+		zte_write_result_to_web(wp, FAILURE);
+	}
+
+	//zte_write_result_to_web(wp,SUCCESS);
+}
+
+void zte_sms_move_to_sim_msg_process(webs_t wp)
+{
+	unsigned int i = 0;
+	unsigned int j = 0;
+	unsigned int   msg_id_count = 0;
+	unsigned char *msg_id = NULL;                                             //receiver phone number get from web
+	unsigned char msg_id_separate[ZTE_WMS_DELETE_COUNT_MAX][WMS_MODULE_ID_LEN] = {0};             //separate receiver phone number
+	T_zUfiSms_DelReq  del_sms_setting;
+	//char_t *which_page = NULL;
+
+	memset(&del_sms_setting, 0, sizeof(T_zUfiSms_DelReq));
+
+	msg_id = websGetVar(wp, "msg_id", T(""));
+	//which_page = websGetVar(wp, "which_cgi", T(""));
+
+	slog(MISC_PRINT, SLOG_DEBUG,"web para:[msg_id] is [%s].\n", msg_id);
+	//WEBLOG("web para:[which_page] is [%s].\n",which_page);
+
+	msg_id_count = parseStrBySeparator(msg_id, (unsigned char *)msg_id_separate, WMS_MODULE_ID_LEN, SEPARATOR_CHARACTER);
+
+	del_sms_setting.all_or_count = msg_id_count;
+	for (i = 0; i < msg_id_count; i++) {
+		del_sms_setting.id[i] = atoi(msg_id_separate[i]);
+	}
+
+	slog(MISC_PRINT, SLOG_DEBUG, "zte_sms_move_to_sim_msg_process:del_sms_setting.all_or_count is [%lu]\n", del_sms_setting.all_or_count);
+
+	for (j = 0; j < msg_id_count; j++) {
+		slog(MISC_PRINT, SLOG_DEBUG, "zte_sms_move_to_sim_msg_process:move msg number:[%lu]\n", del_sms_setting.id[j]);
+	}
+	/* mc interface */
+
+
+	if (ZTE_MC_OK_S == zte_mc_relay_sms_move_to_sim_msg((T_zUfiSms_DelReq*)(&del_sms_setting))) {
+		slog(MISC_PRINT, SLOG_NORMAL, "zte_sms_move_to_sim_msg_process:send move sms cmd to mc success.\n");
+		zte_write_result_to_web(wp, SUCCESS);
+	} else {
+		slog(MISC_PRINT, SLOG_ERR, "zte_sms_move_to_sim_msg_process:send move sms cmd to mc fail.\n");
+		zte_write_result_to_web(wp, FAILURE);
+	}
+
+	//zte_write_result_to_web(wp,SUCCESS);
+}
+void zte_goform_sms_alldel_msg_process(webs_t wp)
+{
+	int ret = 0;
+	char strPage[16] = {0};
+	WEB_DEL_SMS_BY_TYPE  MSG_DEL_TYPE_ST;
+	memset(&MSG_DEL_TYPE_ST, 0, sizeof(WEB_DEL_SMS_BY_TYPE));
+
+	strncpy(strPage, websGetVar(wp, "which_page", T("")),sizeof(strPage)-1);
+	if (0 == strcmp(strPage, "inbox")) {
+		MSG_DEL_TYPE_ST.eLocation = SMS_LOCATION_SIM;
+		MSG_DEL_TYPE_ST.eBoxName = SMS_INBOX;
+	} else if (0 == strcmp(strPage, "outbox")) {
+		MSG_DEL_TYPE_ST.eLocation = SMS_LOCATION_SIM;
+		MSG_DEL_TYPE_ST.eBoxName = SMS_OUTBOX;
+	} else if (0 == strcmp(strPage, "draftbox")) {
+		MSG_DEL_TYPE_ST.eLocation = SMS_LOCATION_SIM;
+		MSG_DEL_TYPE_ST.eBoxName = SMS_DRAFTBOX;
+	} else if (0 == strcmp(strPage, "me_inbox")) {
+		MSG_DEL_TYPE_ST.eLocation = SMS_LOCATION_ME;
+		MSG_DEL_TYPE_ST.eBoxName =  SMS_INBOX;
+	} else if (0 == strcmp(strPage, "me_outbox")) {
+		MSG_DEL_TYPE_ST.eLocation = SMS_LOCATION_ME;
+		MSG_DEL_TYPE_ST.eBoxName =  SMS_OUTBOX;
+	} else if (0 == strcmp(strPage, "me_draftbox")) {
+		MSG_DEL_TYPE_ST.eLocation = SMS_LOCATION_ME;
+		MSG_DEL_TYPE_ST.eBoxName = SMS_DRAFTBOX;
+	}
+	slog(MISC_PRINT, SLOG_NORMAL, "zte_goform_sms_alldel_msg_process send message: MODULE_ID_SMS, MSG_CMD_DEL_SMS_BY_TYPE");/*lint !e26*/
+	//ret = zte_send_message(MODULE_ID_SMS, MSG_CMD_DEL_SMS_BY_TYPE,sizeof(WEB_DEL_SMS_BY_TYPE),(UCHAR *)&MSG_DEL_TYPE_ST);  /*lint !e26 !e55*/
+	ret = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_SMS, MSG_CMD_DEL_SMS_BY_TYPE, sizeof(WEB_DEL_SMS_BY_TYPE), (UCHAR *)&MSG_DEL_TYPE_ST, 0);
+	if (0 != ret) {
+		zte_write_result_to_web(wp, FAILURE);
+		WebSms_LOG(LOG_ERR, "Delete all the message to sms failed(send msg)\n");/*lint !e26*/
+		return;
+	}
+	zte_write_result_to_web(wp, SUCCESS);
+}
+void zte_sms_set_message_center(webs_t wp)
+{
+	T_zUfiSms_ParaInfo sms_setting_st;
+	char_t *sms_center_number = NULL;
+	char_t *mem_store = NULL;
+	char_t *validity_period = NULL;
+	char_t *status_report = NULL;
+	char_t *send_retry = NULL;
+	char_t *outdate_delete = NULL;
+	char_t *default_store = NULL;
+
+	memset(&sms_setting_st, 0, sizeof(T_zUfiSms_ParaInfo));
+	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User set message center!\n"));
+
+	sms_center_number = websGetVar(wp, "MessageCenter", T(""));
+	mem_store = websGetVar(wp, "save_location", T(""));
+	validity_period = websGetVar(wp, "save_time", T(""));
+	status_report = websGetVar(wp, "status_save", T(""));
+	send_retry = websGetVar(wp, "sendfail_retry", T(""));
+	outdate_delete = websGetVar(wp, "outdate_delete", T(""));
+	default_store = websGetVar(wp, "default_store", T(""));
+
+	if (('\0' == (*sms_center_number)) || ('\0' == (*mem_store))
+	    || ('\0' == (*validity_period)) || ('\0' == (*status_report))) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	if (('\0' != (*send_retry)) || ('\0' != (*outdate_delete))
+	    || ('\0' != (*default_store))) {
+		sms_setting_st.sendfail_retry_on = atoi(send_retry);       //open--->1;close--->0;
+		sms_setting_st.outdate_delete_on = atoi(outdate_delete);       //open--->1;close--->0;
+	}
+	strncpy(sms_setting_st.default_store, default_store,sizeof(sms_setting_st.default_store)-1);
+
+	strncpy(sms_setting_st.sca, sms_center_number,sizeof(sms_setting_st.sca)-1);
+	sms_setting_st.status_report_on = atoi(status_report);        //open--->1;close--->0;
+	slog(MISC_PRINT, SLOG_DEBUG, "sms_setting_st.sca=%s", sms_setting_st.sca); /*lint !e26*/
+	slog(MISC_PRINT, SLOG_DEBUG, "sms_setting_st.status_report_on=%d", sms_setting_st.status_report_on); /*lint !e26*/
+
+	if (!strcmp(mem_store, "native")) {                    //location of saving message
+		sms_setting_st.mem_store = 1;
+	} else if (!strcmp(mem_store, "sim_card")) {
+		sms_setting_st.mem_store = 0;
+	} else {
+		slog(MISC_PRINT, SLOG_ERR,"zte_sms_set_message_center: invalid mem_store.\n"); /*lint !e26*/
+		sms_setting_st.mem_store = 1;
+	}
+	slog(MISC_PRINT, SLOG_DEBUG, "sms_setting_st.mem_store=%d", sms_setting_st.mem_store); /*lint !e26*/
+
+	if (0 == strcmp(validity_period, "twelve_hours")) { //according to 3GPP technical specification
+		sms_setting_st.tp_validity_period = 143;
+	} else if (0 == strcmp(validity_period, "one_day")) {
+		sms_setting_st.tp_validity_period = 167;
+	} else if (0 == strcmp(validity_period, "one_week")) {
+		sms_setting_st.tp_validity_period = 173;
+	} else if (0 == strcmp(validity_period, "largest")) {
+		sms_setting_st.tp_validity_period = 255;
+	} else if (0 == strcmp(validity_period, "cdma_largest")) {
+		sms_setting_st.tp_validity_period = 244;
+	} else {
+		slog(MISC_PRINT, SLOG_ERR, "zte_sms_set_message_center: invalid validity_period.\n"); /*lint !e26*/
+		sms_setting_st.tp_validity_period = 255;
+	}
+
+	slog(MISC_PRINT, SLOG_DEBUG, " sms_setting_st.tp_validity_period=%d", sms_setting_st.tp_validity_period); /*lint !e26*/
+	slog(MISC_PRINT, SLOG_DEBUG, "zte_sms_set_message_center:The center number is:[%s].\n", sms_setting_st.sca); /*lint !e26*/
+
+	/* mc interface */
+	if (ZTE_MC_OK_S == zte_mc_relay_sms_set_parameter((T_zUfiSms_ParaInfo*)(&sms_setting_st))) {
+		slog(MISC_PRINT, SLOG_NORMAL, "zte_sms_set_message_center: send msg to mc success.\n"); /*lint !e26*/
+		cfg_save();

+		zte_write_result_to_web(wp, SUCCESS);
+	} else {
+		slog(MISC_PRINT, SLOG_ERR, "zte_sms_set_message_center: send msg to mc fail.\n"); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+	}
+	//zte_write_result_to_web(wp,SUCCESS);
+}
+
+/**********************************************************************
+* Function:         zte_sms_view_msg_process
+* Description:      to set the viewed msg as read
+* Input:            the web para
+* Output:
+* Return:
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 2011/11/16    V1.0        chenyi       first version
+**********************************************************************/
+
+void zte_sms_view_msg_process(webs_t wp)
+{
+	char_t *msg_id = NULL;
+	char_t *tag = NULL;
+	T_zUfiSms_ModifyFlag modify_tag_ptr;
+
+	unsigned int total_id = 0;
+	unsigned char id[WMS_MODULE_ID_LEN] = {0};
+	int i = 0;
+	int index = 0;
+
+	memset(&modify_tag_ptr, 0, sizeof(T_zUfiSms_ModifyFlag));
+
+	/* get value from web */
+	msg_id = websGetVar(wp, "msg_id", T(""));
+	tag = websGetVar(wp, "tag", T(""));
+
+	if (('\0' == (*msg_id)) || ('\0' == (*tag))) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	modify_tag_ptr.tags = (unsigned char)atoi(tag);
+	//parse id list
+	for (i = 0; i < strlen(msg_id); i++) {
+		if (';' == msg_id[i]) {
+			if (total_id < (sizeof(modify_tag_ptr.id) / sizeof(unsigned long))) {
+				modify_tag_ptr.id[total_id] = atoi(id);
+			}
+			total_id++;
+			index = 0;
+			memset(id, 0, sizeof(id)); //reset
+			continue;
+		}
+
+		if (index < (sizeof(id) - 1)) {
+			id[index++] = msg_id[i];
+		}
+	}
+
+	modify_tag_ptr.total_id = total_id;
+
+	slog(MISC_PRINT, SLOG_DEBUG, " modify_tag_ptr.tags=%d", modify_tag_ptr.tags); /*lint !e26*/
+	slog(MISC_PRINT, SLOG_DEBUG, "  modify_tag_ptr.total_id =%d",  modify_tag_ptr.total_id); /*lint !e26*/
+
+#if 0
+	//msg print
+	for (i = 0 ; i < total_id; i++) {
+		WebSms_LOG(LOG_INFO, "view msg id[%d]= [%lu]\n", i, modify_tag_ptr.id[i]); /*lint !e26*/
+	}
+
+	WebSms_LOG(LOG_INFO, "view msg:tag[%c],total_id[%lu]\n", modify_tag_ptr.tags, modify_tag_ptr.total_id); /*lint !e26*/
+
+	WebSms_LOG(LOG_INFO, "view size:[%d]", (sizeof(modify_tag_ptr.id) / sizeof(unsigned long))); /*lint !e26*/
+#endif
+
+	if (wp->flags & WEBS_XML_CLIENT_REQUEST) {
+		modify_tag_ptr.type = 1;
+	} else {
+		modify_tag_ptr.type = 0;
+	}
+	/* mc interface */
+	if (ZTE_MC_OK_S == zte_mc_relay_sms_modify_tag(&modify_tag_ptr)) {
+		slog(MISC_PRINT, SLOG_NORMAL, "web_sms:Send message to mc successful!(view message)\n"); /*lint !e26*/
+		zte_write_result_to_web(wp, SUCCESS);
+	} else {
+		slog(MISC_PRINT, SLOG_ERR, "web_sms:Send message to mc fail!(view message)\n"); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+	}
+
+	//zte_write_result_to_web(wp,SUCCESS);
+}
+
+/**********************************************************************
+* Function:         zte_get_sms_data
+* Description:      to get the sms data info
+* Input:            the web para
+* Output:
+* Return:
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 2012/09/03    V1.0        liuyingnan       first version
+**********************************************************************/
+
+void zte_get_sms_data(webs_t wp)
+{
+	zte_sms_query_req sms_query_req;
+	zte_sms_query_result *p_sms_query_result = NULL;
+	int result = 0;
+	int i = 0;
+	char_t *page = NULL;
+	char_t *data_per_page = NULL;
+	char_t *mem_store = NULL;
+	char_t *tags = NULL;
+	char_t *order_by = NULL;
+	T_zUfiSms_ModifyFlag modify_tag_ptr;
+	int  index = 0;
+	memset(&modify_tag_ptr, 0, sizeof(T_zUfiSms_ModifyFlag));
+	memset(&sms_query_req, 0, sizeof(zte_sms_query_req));
+
+	page = websGetVar(wp, "page", T(""));
+	data_per_page = websGetVar(wp, "data_per_page", T(""));
+	mem_store = websGetVar(wp, "mem_store", T(""));
+	tags = websGetVar(wp, "tags", T(""));
+	order_by = websGetVar(wp, "order_by", T(""));
+
+	if (('\0' == *page) || ('\0' == *data_per_page) || ('\0' == *mem_store) || ('\0' == *tags) || ('\0' == *order_by)) {
+		slog(MISC_PRINT, SLOG_ERR, "zte_get_sms_data: invalid input.\n"); /*lint !e26*/
+		zte_web_feed_back_empty(wp);
+		return ;
+	}
+
+#if 0 // kw 3
+	sms_query_req.page = (uint8)atoi(page);
+#else
+    int temp_page = atoi(page);
+	if(temp_page > 255 || temp_page < 0){
+		return;
+	}
+
+	sms_query_req.page = temp_page;
+#endif
+
+	int tmp_data_per_page = atoi(data_per_page);
+	if(tmp_data_per_page > 255 || tmp_data_per_page < 0)
+		return;
+	sms_query_req.data_per_page = (uint8)tmp_data_per_page;
+
+	sms_query_req.mem_store = (uint8)atoi(mem_store);
+	sms_query_req.tags = (uint8)atoi(tags);
+	//sms_query_req.order_by = (uint8)atoi(order_by);
+	strncpy(sms_query_req.order_by, order_by, sizeof(sms_query_req.order_by) - 1);
+
+	slog(MISC_PRINT, SLOG_DEBUG, "sms_query_req:[%u,%u,%u,%u,%s].\n", sms_query_req.page, sms_query_req.data_per_page, sms_query_req.mem_store, \
+	           sms_query_req.tags, sms_query_req.order_by); /*lint !e26*/
+
+	//handle special condition:if the @data_per_page is 0
+	if (0 == sms_query_req.data_per_page) {
+		slog(MISC_PRINT, SLOG_ERR,"to get 0 sms record.\n"); /*lint !e26*/
+		zte_web_feed_back_empty(wp);
+		return ;
+	}
+
+	p_sms_query_result = (zte_sms_query_result*)malloc(4 + sizeof(zte_sms_data) * (sms_query_req.data_per_page));
+	if (NULL == p_sms_query_result) {
+		slog(MISC_PRINT, SLOG_ERR, "malloc sms result mem fail.\n"); /*lint !e26*/
+		zte_web_feed_back_empty(wp);
+		return ;
+	}
+
+	//reset,which is important
+	memset(p_sms_query_result, 0, 4 + sizeof(zte_sms_data) * (sms_query_req.data_per_page));
+
+	slog(MISC_PRINT, SLOG_NORMAL, "SMS_DATA GET DATA FROM DB START.\n"); /*lint !e26*/
+	result = zte_libwms_get_sms_data(&sms_query_req, p_sms_query_result);
+	slog(MISC_PRINT, SLOG_DEBUG, "SMS_DATA GET DATA FROM DB END.\n"); /*lint !e26*/
+
+	if (-1 == result) {
+		slog(MISC_PRINT, SLOG_ERR, "call zte_wms_db_get_sms_data fail.\n"); /*lint !e26*/
+		zte_web_feed_back_empty(wp);
+		//free
+//		if (NULL != p_sms_query_result) {   // kw 3
+			free(p_sms_query_result);
+			p_sms_query_result = NULL;
+//		}
+		return ;
+	}
+
+	slog(MISC_PRINT, SLOG_DEBUG, "total query count [%u].\n", (*p_sms_query_result).count); /*lint !e26*/
+
+	if (0 == (*p_sms_query_result).count) {
+		zte_web_feed_back_empty(wp);
+		//free
+//		if (NULL != p_sms_query_result) {  // kw 3
+			free(p_sms_query_result);
+			p_sms_query_result = NULL;
+//		}
+		return ;
+	}
+	//write the sms data to web
+	for (i = 0; i < (*p_sms_query_result).count; i++) {
+		if (0 == i) {
+			web_feedback_header(wp);
+			zte_rest_get_sms_data_head(wp);
+			zte_rest_get_sms_data(wp, p_sms_query_result, i, 0);
+#if 0
+			(void)websWrite(wp, T("{\"%s\":[{\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s,%s,%s,%s,%s,%s,%s\",\"%s\":\"%s\"}"), SMS_MESSAGES, SMS_ID, \
+			                (*p_sms_query_result).data[i].id, SMS_NUMBER, (*p_sms_query_result).data[i].number, SMS_CONTENT, (*p_sms_query_result).data[i].sms_content, \
+			                SMS_TAG, (*p_sms_query_result).data[i].tag, \
+			                SMS_DATE, (*p_sms_query_result).data[i].date.year, (*p_sms_query_result).data[i].date.month, (*p_sms_query_result).data[i].date.day, \
+			                (*p_sms_query_result).data[i].date.hour, (*p_sms_query_result).data[i].date.min, (*p_sms_query_result).data[i].date.sec, \
+			                (*p_sms_query_result).data[i].date.timezone, SMS_DRAFT_GROUP_ID, (*p_sms_query_result).data[i].draft_group_id);
+#endif
+		} else {
+			zte_rest_get_sms_data(wp, p_sms_query_result, i, 1);
+#if 0
+			(void)websWrite(wp, T(",{\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s,%s,%s,%s,%s,%s,%s\",\"%s\":\"%s\"}"), SMS_ID, \
+			                (*p_sms_query_result).data[i].id, SMS_NUMBER, (*p_sms_query_result).data[i].number, SMS_CONTENT, (*p_sms_query_result).data[i].sms_content, \
+			                SMS_TAG, (*p_sms_query_result).data[i].tag, \
+			                SMS_DATE, (*p_sms_query_result).data[i].date.year, (*p_sms_query_result).data[i].date.month, (*p_sms_query_result).data[i].date.day, \
+			                (*p_sms_query_result).data[i].date.hour, (*p_sms_query_result).data[i].date.min, (*p_sms_query_result).data[i].date.sec, \
+			                (*p_sms_query_result).data[i].date.timezone, SMS_DRAFT_GROUP_ID, (*p_sms_query_result).data[i].draft_group_id);
+#endif
+		}
+		/*
+			    if(sms_query_req.mem_store == 0 && atoi(p_sms_query_result->data[i].tag) == 1)
+			    {
+			        modify_tag_ptr.id[index] = atoi(p_sms_query_result->data[i].id);
+			        modify_tag_ptr.total_id ++;
+			        index ++;
+			    }
+		*/
+	}
+	/*
+	        if(sms_query_req.mem_store == 0 && modify_tag_ptr.total_id > 0)
+		    {
+		        modify_tag_ptr.tags = 0;
+		        zte_mc_relay_sms_modify_tag(&modify_tag_ptr);
+		    }
+	*/
+	zte_rest_get_sms_data_foot(wp);
+	//(void)websWrite(wp, T("]}"));
+
+	//free
+//	if (NULL != p_sms_query_result) {  // kw 3
+		free(p_sms_query_result);
+		p_sms_query_result = NULL;
+//	}
+}
+
+/**********************************************************************
+* Function:         zte_get_sms_data_total
+* Description:      to get the total sms
+* Input:            the web para
+* Output:
+* Return:
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 2012/09/03    V1.0        liuyingnan       first version
+**********************************************************************/
+
+void zte_get_sms_data_total(webs_t wp)
+{
+	zte_sms_query_req sms_query_req;
+	zte_sms_query_result *p_sms_query_result = NULL;
+	int result = 0;
+	int i = 0;
+	char_t *page = NULL;
+	char_t *data_per_page = NULL;
+	char_t *mem_store = NULL;
+	char_t *tags = NULL;
+	char_t *order_by = NULL;
+
+	int idata_per_page = 0;
+
+	int total_pages = 0;
+	int leave_nums = 0;
+	int curr_page = 0;
+	int total_sms = 0;
+	T_zUfiSms_ModifyFlag modify_tag_ptr;
+	int  index = 0;
+	memset(&sms_query_req, 0, sizeof(zte_sms_query_req));
+
+	page = websGetVar(wp, "page", T(""));
+	data_per_page = websGetVar(wp, "data_per_page", T(""));
+	mem_store = websGetVar(wp, "mem_store", T(""));
+	tags = websGetVar(wp, "tags", T(""));
+	order_by = websGetVar(wp, "order_by", T(""));
+
+	if (('\0' == *page) || ('\0' == *data_per_page) || ('\0' == *mem_store) || ('\0' == *tags) || ('\0' == *order_by)) {
+		slog(MISC_PRINT, SLOG_ERR, "zte_get_sms_data: invalid input.\n"); /*lint !e26*/
+		zte_web_feed_back_empty(wp);
+		return ;
+	}
+#if 0
+	//calculate the total pages
+	total_pages = (atoi(data_per_page)) / SMS_READ_RECORD_MAX_NUM;
+	leave_nums = (atoi(data_per_page)) % SMS_READ_RECORD_MAX_NUM;
+
+	if (0 != leave_nums) {
+		total_pages++;
+	}
+
+#else
+	idata_per_page = atoi(data_per_page);
+	if(idata_per_page < 0 || idata_per_page >  INT_MAX-1)
+	{
+	    total_pages = 1;
+		leave_nums = 0;
+	}
+	else
+	{
+    	//calculate the total pages
+    	total_pages = idata_per_page / SMS_READ_RECORD_MAX_NUM;
+    	leave_nums = idata_per_page % SMS_READ_RECORD_MAX_NUM;
+
+    	if (0 != leave_nums) {
+    		total_pages++;
+    	}
+	}
+#endif	
+
+	slog(MISC_PRINT, SLOG_DEBUG, "total_pages,leave_nums:[%d][%d]", total_pages, leave_nums); /*lint !e26*/
+
+	p_sms_query_result = (zte_sms_query_result*)malloc(4 + sizeof(zte_sms_data) * SMS_READ_RECORD_MAX_NUM);
+	if (NULL == p_sms_query_result) {
+		slog(MISC_PRINT, SLOG_ERR, "malloc sms result mem fail.\n"); /*lint !e26*/
+		zte_web_feed_back_empty(wp);
+		return ;
+	}
+
+	for (curr_page = 0; curr_page < total_pages; curr_page++) {
+
+		//reset
+		index = 0;
+		memset(&modify_tag_ptr, 0, sizeof(T_zUfiSms_ModifyFlag));
+		memset(&sms_query_req, 0, sizeof(zte_sms_query_req));
+		sms_query_req.page = curr_page;
+#if 0
+		if (((total_pages - 1) == curr_page) && (0 != leave_nums)) {
+			sms_query_req.data_per_page = leave_nums;//last page
+		} else {
+			sms_query_req.data_per_page = SMS_READ_RECORD_MAX_NUM;
+		}
+#endif
+		sms_query_req.data_per_page = SMS_READ_RECORD_MAX_NUM;
+		sms_query_req.mem_store = (uint8)atoi(mem_store);
+		sms_query_req.tags = (uint8)atoi(tags);
+		//sms_query_req.order_by = (uint8)atoi(order_by);
+		strncpy(sms_query_req.order_by, order_by, sizeof(sms_query_req.order_by) - 1);
+
+		slog(MISC_PRINT, SLOG_DEBUG, "sms_query_req:[%u,%u,%u,%u,%s].\n", sms_query_req.page, sms_query_req.data_per_page, sms_query_req.mem_store, \
+		           sms_query_req.tags, sms_query_req.order_by); /*lint !e26*/
+
+		//reset,which is important
+		memset(p_sms_query_result, 0, 4 + sizeof(zte_sms_data)*SMS_READ_RECORD_MAX_NUM);
+
+		slog(MISC_PRINT, SLOG_NORMAL, "SMS_DATA_TOTAL GET DATA FROM DB START.\n"); /*lint !e26*/
+		slog(MISC_PRINT, SLOG_DEBUG, "curr_page[%d]", sms_query_req.page); /*lint !e26*/
+		slog(MISC_PRINT, SLOG_DEBUG, "total_sms[%d]", total_sms); /*lint !e26*/
+		slog(MISC_PRINT, SLOG_DEBUG, " atoi(data_per_page)=%d", atoi(data_per_page)); /*lint !e26*/
+
+		result = zte_libwms_get_sms_data(&sms_query_req, p_sms_query_result);
+
+		slog(MISC_PRINT, SLOG_DEBUG, "SMS_DATA_TOTAL GET DATA FROM DB END.\n"); /*lint !e26*/
+
+		if (-1 == result) {
+			WebSms_LOG(LOG_DEBUG, "read sms page [%d] fail.\n", curr_page); /*lint !e26*/
+			//free
+//			if (NULL != p_sms_query_result) {  // kw 3
+				free(p_sms_query_result);
+				p_sms_query_result = NULL;
+//			}
+
+			if (0 == curr_page) {
+				zte_web_feed_back_empty(wp);
+				return ;
+			} else {
+				break;
+			}
+		}
+
+		slog(MISC_PRINT, SLOG_DEBUG, "total query count [%u].\n", (*p_sms_query_result).count); /*lint !e26*/
+
+		if (0 == (*p_sms_query_result).count) {
+			//free
+//			if (NULL != p_sms_query_result) {   // kw 3
+				free(p_sms_query_result);
+				p_sms_query_result = NULL;
+//			}
+
+			if (0 == curr_page) {
+				zte_web_feed_back_empty(wp);
+				return ;
+			} else {
+				break;
+			}
+		}
+
+		//write the sms data to web
+		for (i = 0; (i < (*p_sms_query_result).count) && (total_sms < atoi(data_per_page)); i++) {
+			if ((0 == i) && (0 == curr_page)) {
+				web_feedback_header(wp);
+				zte_rest_get_sms_data_head(wp);
+				zte_rest_get_sms_data(wp, p_sms_query_result, i, 0);
+#if 0
+				(void)websWrite(wp, T("{\"%s\":[{\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s,%s,%s,%s,%s,%s,%s\",\"%s\":\"%s\"}"), SMS_MESSAGES, SMS_ID, \
+				                (*p_sms_query_result).data[i].id, SMS_NUMBER, (*p_sms_query_result).data[i].number, SMS_CONTENT, (*p_sms_query_result).data[i].sms_content, \
+				                SMS_TAG, (*p_sms_query_result).data[i].tag, \
+				                SMS_DATE, (*p_sms_query_result).data[i].date.year, (*p_sms_query_result).data[i].date.month, (*p_sms_query_result).data[i].date.day, \
+				                (*p_sms_query_result).data[i].date.hour, (*p_sms_query_result).data[i].date.min, (*p_sms_query_result).data[i].date.sec, \
+				                (*p_sms_query_result).data[i].date.timezone, SMS_DRAFT_GROUP_ID, (*p_sms_query_result).data[i].draft_group_id);
+				total_sms ++;
+#endif
+			} else {
+				zte_rest_get_sms_data(wp, p_sms_query_result, i, 1);
+#if 0
+				(void)websWrite(wp, T(",{\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s,%s,%s,%s,%s,%s,%s\",\"%s\":\"%s\"}"), SMS_ID, \
+				                (*p_sms_query_result).data[i].id, SMS_NUMBER, (*p_sms_query_result).data[i].number, SMS_CONTENT, (*p_sms_query_result).data[i].sms_content, \
+				                SMS_TAG, (*p_sms_query_result).data[i].tag, \
+				                SMS_DATE, (*p_sms_query_result).data[i].date.year, (*p_sms_query_result).data[i].date.month, (*p_sms_query_result).data[i].date.day, \
+				                (*p_sms_query_result).data[i].date.hour, (*p_sms_query_result).data[i].date.min, (*p_sms_query_result).data[i].date.sec, \
+				                (*p_sms_query_result).data[i].date.timezone, SMS_DRAFT_GROUP_ID, (*p_sms_query_result).data[i].draft_group_id);
+				total_sms ++;
+#endif
+			}
+			/*
+				        if(sms_query_req.mem_store == 0 && atoi(p_sms_query_result->data[i].tag) == 1)
+				        {
+				            modify_tag_ptr.id[index] = atoi(p_sms_query_result->data[i].id);
+			                modify_tag_ptr.total_id ++;
+				            index ++;
+				        }
+			*/
+		}
+		/*
+		        if(sms_query_req.mem_store == 0 && modify_tag_ptr.total_id > 0
+					&& !(wp->flags & WEBS_XML_CLIENT_REQUEST))
+			    {
+			        modify_tag_ptr.tags = 0;
+			        zte_mc_relay_sms_modify_tag(&modify_tag_ptr);
+			    }
+		*/
+	}
+	zte_rest_get_sms_data_foot(wp);
+	//(void)websWrite(wp, T("]}"));
+
+	//free
+//	if (NULL != p_sms_query_result) {  // kw 3
+		free(p_sms_query_result);
+		p_sms_query_result = NULL;
+//	}
+}
+
+/**********************************************************************
+* Function:         zte_get_sms_parameter_info
+* Description:      to get the sms parameter info
+* Input:            the web para
+* Output:
+* Return:
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 2012/09/03    V1.0        liuyingnan       first version
+**********************************************************************/
+
+void zte_get_sms_parameter_info(webs_t wp)
+{
+	T_zUfiSms_ParaInfo sms_parameter_info;
+	int result = 0;
+
+	memset(&sms_parameter_info, 0, sizeof(T_zUfiSms_ParaInfo));
+
+	slog(MISC_PRINT, SLOG_NORMAL, "SMS_PARAMETER_INFO GET DATA FROM DB START.\n"); /*lint !e26*/
+	result = zte_libwms_get_parameter(&sms_parameter_info);
+	slog(MISC_PRINT, SLOG_DEBUG, "SMS_PARAMETER_INFO GET DATA FROM DB END.\n"); /*lint !e26*/
+	if (-1 == result) {
+		slog(MISC_PRINT, SLOG_ERR, "call zte_libwms_get_parameter fail.\n"); /*lint !e26*/
+		zte_web_feed_back_empty(wp);
+		return ;
+	}
+
+	web_feedback_header(wp);
+	zte_rest_sms_parameter(wp, sms_parameter_info);
+#if 0
+	(void)websWrite(wp, T("{\"%s\":\"%s\",\"%s\":\"%d\",\"%s\":\"%u\",\"%s\":\"%u\"}"), SMS_PARAMETER_SCA, sms_parameter_info.sca, SMS_PARAMETER_MEM_STORE, sms_parameter_info.mem_store, \
+	                SMS_PARAMETER_VALIDITY_PERIOD, sms_parameter_info.tp_validity_period, \
+	                SMS_PARAMETER_STATUS_REPORT, sms_parameter_info.status_report_on);
+#endif
+}
+
+
+/**********************************************************************
+* Function:         zte_get_sms_cmd_status_info
+* Description:      to get the sms cmd status info
+* Input:            the web para
+* Output:
+* Return:
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 2012/09/03    V1.0        liuyingnan       first version
+**********************************************************************/
+
+void zte_get_sms_cmd_status_info(webs_t wp)
+{
+	T_zUfiSms_StatusInfo cmd_status_info;
+	int result = 0;
+	char *sms_cmd = NULL;
+
+	memset(&cmd_status_info, 0, sizeof(T_zUfiSms_StatusInfo));
+
+	//read sms_cmd
+	sms_cmd = websGetVar(wp, "sms_cmd", T(""));
+	if ('\0' == *sms_cmd) {
+		slog(MISC_PRINT, SLOG_ERR, "sms_cmd is empty.\n"); /*lint !e26*/
+		zte_web_feed_back_empty(wp);
+		return ;
+	}
+
+	/*lint -e64*/
+	int cmd = atoi(sms_cmd);
+	if(cmd >= WMS_SMS_CMD_NONE && cmd <= WMS_SMS_CMD_WMS_MAX){
+		cmd_status_info.cmd = (T_zUfiSms_CmdType)cmd;
+	} else {
+		slog(MISC_PRINT, SLOG_ERR, "sms_cmd is %d.\n",cmd);
+		zte_web_feed_back_empty(wp);
+		return ;
+	}
+
+	slog(MISC_PRINT, SLOG_NORMAL, "sms_cmd_status_info GET DATA FROM DB START.\n"); /*lint !e26*/
+	result = zte_libwms_get_cmd_status(&cmd_status_info);
+	slog(MISC_PRINT, SLOG_DEBUG, "sms_cmd_status_info GET DATA FROM DB END.\n"); /*lint !e26*/
+	if (-1 == result) {
+		slog(MISC_PRINT, SLOG_ERR, "call zte_libwms_get_cmd_status fail.\n"); /*lint !e26*/
+		zte_web_feed_back_empty(wp);
+		return ;
+	}
+
+	web_feedback_header(wp);
+	zte_rest_cmd_write_head(wp);
+	zte_rest_cmd_write(wp, SMS_CMD, sms_cmd, 1);
+	zte_rest_cmd_write_int(wp, SMS_CMD_STATUS_RESULT, cmd_status_info.cmd_status, 0);
+	zte_rest_cmd_write_foot(wp);
+	//(void)websWrite(wp, T("{\"%s\":\"%s\",\"%s\":\"%d\"}"),SMS_CMD,sms_cmd,SMS_CMD_STATUS_RESULT,cmd_status_info.cmd_status);
+}
+
+
+int  zte_get_sms_remain_capacity()
+{
+	int sms_remain = 0;
+	int sms_nv_total = 0;
+	int sms_sim_total = 0;
+	int sms_nv_rev_total = 0;
+	int sms_nv_send_total = 0;
+	int sms_nv_draftbox_total = 0;
+	char default_store[NV_ITEM_STRING_LEN_10] = {0};
+
+	cfg_get_item("default_store", default_store, sizeof(default_store));
+	if (0 == strcmp(default_store, "sim")) {
+		sms_sim_total = zte_libwms_get_sms_capability(0);//sim
+		//¿¨²à´æ´¢ÈÝÁ¿ÒԶμÆË㣬ÎÞ·¨°´Ìõͳ¼Æ
+		//Òò´ËÈç¹ûжÌÐÅ´æ´¢ÔÚ¿¨²à£¬ÄÇô¾Í²»½øÐÐÅжÏ
+		//´Ë´¦¸³ÖµÎª10£¬´óÓÚµ÷Óñ¾º¯ÊýʱÅжϵÄ5Ìõ
+		//¿¨²à¿Õ¼äÊÇ·ñ³ä×ãÄܽÓÊÕÁ÷Á¿Ð£×¼¶ÌÐŵÄÅжÏ
+		//½»ÓÉЭÒéÕ»Åжϴ¦Àí
+		sms_remain = 10;
+		slog(MISC_PRINT, SLOG_DEBUG,"[traffic] zte_get_sms_remain_capacity, default_store = %s, total = %d!\n", default_store, sms_sim_total);
+	} else {
+		sms_nv_total = zte_libwms_get_sms_capability(1);//nv
+		sms_nv_rev_total = zte_libwms_get_sms_used(1, 0); //nv rev read
+		sms_nv_rev_total += zte_libwms_get_sms_used(1, 1); //nv rev not read
+		sms_nv_send_total = zte_libwms_get_sms_used(1, 2); //nv send
+		sms_nv_draftbox_total = zte_libwms_get_sms_used(1, 3); //nv draftbox 1,not send
+		sms_nv_draftbox_total += zte_libwms_get_sms_used(1, 4); //nv draftbox 2,write
+
+		if(sms_nv_total < 0 || sms_nv_total > INT_MAX -1){
+            sms_nv_total = INT_MAX;
+		}
+
+		sms_remain = sms_nv_total - sms_nv_rev_total - sms_nv_send_total - sms_nv_draftbox_total;
+		slog(MISC_PRINT, SLOG_DEBUG,"[traffic] zte_get_sms_remain_capacity, default_store = %s, total = %d, rev= %d, send= %d, draft= %d!\n", default_store, sms_nv_total, sms_nv_rev_total, sms_nv_send_total, sms_nv_draftbox_total);
+	}
+	slog(MISC_PRINT, SLOG_DEBUG,"[traffic] zte_get_sms_remain_capacity, default_store = %s, sms_remain = %d!\n", default_store, sms_remain);
+	return sms_remain;
+}
+
+
+/**********************************************************************
+* Function:         zte_get_sms_capacity_info
+* Description:      to get the sms capacity info
+* Input:            the web para
+* Output:
+* Return:
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 2012/09/03    V1.0        liuyingnan       first version
+**********************************************************************/
+
+void zte_get_sms_capacity_info(webs_t wp)
+{
+	int sms_nv_total = 0;
+	int sms_sim_total = 0;
+
+	//int sms_nv_used = 0;
+	//int sms_sim_used = 0;
+
+	int sms_nv_rev_total = 0;
+	int sms_nv_send_total = 0;
+	int sms_nv_draftbox_total = 0;
+	int sms_sim_rev_total = 0;
+	int sms_sim_send_total = 0;
+	int sms_sim_draftbox_total = 0;
+
+	//WebSms_LOG(LOG_INFO,"sms_capacity_info GET DATA FROM DB START.\n");
+
+
+	sms_nv_total = zte_libwms_get_sms_capability(1);//nv
+	sms_sim_total = zte_libwms_get_sms_capability(0);//sim
+
+	sms_nv_rev_total = zte_libwms_get_sms_used(1, 0); //nv rev read
+	sms_nv_rev_total += zte_libwms_get_sms_used(1, 1); //nv rev not read
+	sms_nv_send_total = zte_libwms_get_sms_used(1, 2); //nv send
+	sms_nv_draftbox_total = zte_libwms_get_sms_used(1, 3); //nv draftbox 1,not send
+	sms_nv_draftbox_total += zte_libwms_get_sms_used(1, 4); //nv draftbox 2,write
+
+	sms_sim_rev_total = zte_libwms_get_sms_used(0, 0); //sim rev read
+	sms_sim_rev_total += zte_libwms_get_sms_used(0, 1); //sim rev not read
+	sms_sim_send_total = zte_libwms_get_sms_used(0, 2); //sim send
+	sms_sim_draftbox_total = zte_libwms_get_sms_used(0, 3); //sim draftbox 1,not send
+	sms_sim_draftbox_total += zte_libwms_get_sms_used(0, 4); //sim draftbox 2,write
+
+	//WebSms_LOG(LOG_INFO,"sms_capacity_info GET DATA FROM DB END.\n");/*lint !e26*/
+
+	web_feedback_header(wp);
+	zte_rest_cmd_write_head(wp);
+	zte_rest_cmd_write_int(wp, SMS_NV_TOTAL, sms_nv_total, 1);
+	zte_rest_cmd_write_int(wp, SMS_SIM_TOTAL, sms_sim_total, 1);
+	zte_rest_cmd_write_int(wp, SMS_NV_REV_TOTAL, sms_nv_rev_total, 1);
+	zte_rest_cmd_write_int(wp, SMS_NV_SEND_TOTAL, sms_nv_send_total, 1);
+	zte_rest_cmd_write_int(wp, SMS_NV_DRAFTBOX_TOTAL, sms_nv_draftbox_total, 1);
+	zte_rest_cmd_write_int(wp, SMS_SIM_REV_TOTAL, sms_sim_rev_total, 1);
+	zte_rest_cmd_write_int(wp, SMS_SIM_SEND_TOTAL, sms_sim_send_total, 1);
+	zte_rest_cmd_write_int(wp, SMS_SIM_DRAFTBOX_TOTAL, sms_sim_draftbox_total, 0);
+	zte_rest_cmd_write_foot(wp);
+
+	cfg_set("sms_db_change", "0");
+	slog(MISC_PRINT, SLOG_DEBUG, "nv  set sms_db_change=0.\n"); /*lint !e26*/
+#if 0
+	(void)websWrite(wp, T("{\"%s\":\"%d\",\"%s\":\"%d\",\"%s\":\"%d\",\"%s\":\"%d\",\"%s\":\"%d\",\"%s\":\"%d\",\"%s\":\"%d\",\"%s\":\"%d\"}"), \
+	                SMS_NV_TOTAL, sms_nv_total, SMS_SIM_TOTAL, sms_sim_total, \
+	                SMS_NV_REV_TOTAL, sms_nv_rev_total, SMS_NV_SEND_TOTAL, sms_nv_send_total, SMS_NV_DRAFTBOX_TOTAL, sms_nv_draftbox_total, \
+	                SMS_SIM_REV_TOTAL, sms_sim_rev_total, SMS_SIM_SEND_TOTAL, sms_sim_send_total, SMS_SIM_DRAFTBOX_TOTAL, sms_sim_draftbox_total \
+	               );
+#endif
+}
+
+/**********************************************************************
+* Function:         zte_get_sms_status_rpt_data
+* Description:      to get the sms status report data
+* Input:            the web para
+* Output:
+* Return:
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 2012/09/03    V1.0        liuyingnan       first version
+**********************************************************************/
+void zte_get_sms_status_rpt_data(webs_t wp)
+{
+	zte_sms_query_req sms_query_req;
+	zte_sms_query_result *p_sms_query_result = NULL;
+	int result = 0;
+	int i = 0;
+	char_t *page = NULL;
+	char_t *data_per_page = NULL;
+
+	memset(&sms_query_req, 0, sizeof(zte_sms_query_req));
+
+	page = websGetVar(wp, "page", T(""));
+	data_per_page = websGetVar(wp, "data_per_page", T(""));
+
+	if (('\0' == *page) || ('\0' == *data_per_page)) {
+		slog(MISC_PRINT, SLOG_ERR, "zte_get_sms_data: invalid input.\n"); /*lint !e26*/
+		zte_web_feed_back_empty(wp);
+		return ;
+	}
+	int tmp_page = atoi(page);
+	int tmp_data_per_page = atoi(data_per_page);
+	if((tmp_page > 255 || tmp_page < 0)
+		||(tmp_data_per_page > 255 || tmp_data_per_page < 0)){
+		slog(MISC_PRINT, SLOG_ERR, "sms_query_req:err[%d,%d].\n", tmp_page, tmp_data_per_page); /*lint !e26*/
+		zte_web_feed_back_empty(wp);
+		return ;
+	}
+	sms_query_req.page = (uint8)tmp_page;
+	sms_query_req.data_per_page = (uint8)tmp_data_per_page;
+
+	slog(MISC_PRINT, SLOG_DEBUG, "sms_query_req:[%u,%u].\n", sms_query_req.page, sms_query_req.data_per_page); /*lint !e26*/
+
+	p_sms_query_result = (zte_sms_query_result*)malloc(1 + sizeof(zte_sms_data) * (sms_query_req.data_per_page));
+	if (NULL == p_sms_query_result) {
+		slog(MISC_PRINT, SLOG_ERR, "malloc sms result mem fail.\n"); /*lint !e26*/
+		zte_web_feed_back_empty(wp);
+		return ;
+	}
+
+	//reset,which is important
+	memset(p_sms_query_result, 0, 1 + sizeof(zte_sms_data) * (sms_query_req.data_per_page));
+	slog(MISC_PRINT, SLOG_NORMAL, "sms_status_rpt_data GET DATA FROM DB START.\n"); /*lint !e26*/
+	result = zte_libwms_get_sms_report(&sms_query_req, p_sms_query_result);
+	slog(MISC_PRINT, SLOG_DEBUG, "sms_status_rpt_data GET DATA FROM DB END.\n"); /*lint !e26*/
+	if (-1 == result) {
+		slog(MISC_PRINT, SLOG_ERR, "call zte_libwms_get_sms_report fail.\n"); /*lint !e26*/
+		zte_web_feed_back_empty(wp);
+		//free
+//		if (NULL != p_sms_query_result) {  // kw 3
+			free(p_sms_query_result);
+		    p_sms_query_result =  NULL;
+//		}
+		return ;
+	}
+
+	slog(MISC_PRINT, SLOG_DEBUG, "total query count for status rpt: [%u].\n", (*p_sms_query_result).count); /*lint !e26*/
+
+	if (0 == (*p_sms_query_result).count) {
+		zte_web_feed_back_empty(wp);
+		//free
+//		if (NULL != p_sms_query_result) {  // kw 3
+			free(p_sms_query_result);
+		    p_sms_query_result = NULL;
+//		}
+		return ;
+	}
+	//write the sms data to web
+	for (i = 0; i < (*p_sms_query_result).count; i++) {
+		if (0 == i) {
+			web_feedback_header(wp);
+			zte_rest_get_sms_data_head(wp);
+			zte_rest_sms_status_rpt(wp, p_sms_query_result, i, 0);
+#if 0
+			(void)websWrite(wp, T("{\"%s\":[{\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s,%s,%s,%s,%s,%s,%s\"}"), SMS_MESSAGES, SMS_ID, \
+			                (*p_sms_query_result).data[i].id, SMS_NUMBER, (*p_sms_query_result).data[i].number, SMS_CONTENT, (*p_sms_query_result).data[i].sms_content, \
+			                SMS_DATE, (*p_sms_query_result).data[i].date.year, (*p_sms_query_result).data[i].date.month, (*p_sms_query_result).data[i].date.day, \
+			                (*p_sms_query_result).data[i].date.hour, (*p_sms_query_result).data[i].date.min, (*p_sms_query_result).data[i].date.sec, \
+			                (*p_sms_query_result).data[i].date.timezone);
+#endif
+
+		} else {
+			zte_rest_sms_status_rpt(wp, p_sms_query_result, i, 1);
+#if 0
+			(void)websWrite(wp, T(",{\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s,%s,%s,%s,%s,%s,%s\"}"), SMS_ID, \
+			                (*p_sms_query_result).data[i].id, SMS_NUMBER, (*p_sms_query_result).data[i].number, SMS_CONTENT, (*p_sms_query_result).data[i].sms_content, \
+			                SMS_DATE, (*p_sms_query_result).data[i].date.year, (*p_sms_query_result).data[i].date.month, (*p_sms_query_result).data[i].date.day, \
+			                (*p_sms_query_result).data[i].date.hour, (*p_sms_query_result).data[i].date.min, (*p_sms_query_result).data[i].date.sec, \
+			                (*p_sms_query_result).data[i].date.timezone);
+#endif
+
+		}
+	}
+	zte_rest_get_sms_data_foot(wp);
+	//(void)websWrite(wp, T("]}"));
+
+	//free
+//	if (NULL != p_sms_query_result) {  // kw 3
+		free(p_sms_query_result);
+	    p_sms_query_result = NULL;
+//	}
+}
+
+/**********************************************************************
+* Function:         zte_get_sms_unread_count
+* Description:      to get the unread sms count
+* Input:            the web para
+* Output:
+* Return:
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 2012/09/03    V1.0        liuyingnan       first version
+**********************************************************************/
+void zte_get_sms_unread_count(webs_t wp)
+{
+	int sms_dev_unread_count = 0;
+	int sms_sim_unread_count = 0;
+	slog(MISC_PRINT, SLOG_NORMAL, "sms_unread_count GET DATA FROM DB START.\n"); /*lint !e26*/
+	sms_dev_unread_count = zte_libwms_get_sms_used(1, 1); //nv unread
+	sms_sim_unread_count = zte_libwms_get_sms_used(0, 1); //sim unread
+	slog(MISC_PRINT, SLOG_DEBUG, "sms_unread_count GET DATA FROM DB END.\n"); /*lint !e26*/
+
+
+	web_feedback_header(wp);
+	zte_rest_cmd_write_head(wp);
+
+	if (wp->flags & WEBS_XML_CLIENT_REQUEST) {
+		zte_rest_cmd_write_int(wp, CMD_SMS_UNREAD_COUNT, sms_dev_unread_count, 0);
+		zte_rest_cmd_write_int(wp, SMS_DEV_UNREAD_COUNT, sms_dev_unread_count, 1);
+		zte_rest_cmd_write_int(wp, SMS_SIM_UNREAD_COUNT, sms_sim_unread_count, 0);
+	} else {
+		(void)websWrite(wp, T("\"%s\":\"%d\",\"%s\":\"%d\",\"%s\":\"%d\""), \
+		                CMD_SMS_UNREAD_COUNT, sms_dev_unread_count, \
+		                SMS_DEV_UNREAD_COUNT, sms_dev_unread_count, \
+		                SMS_SIM_UNREAD_COUNT, sms_sim_unread_count);
+	}
+
+	zte_rest_cmd_write_foot(wp);
+
+}
+
+/**********************************************************************
+* Function:         zte_get_sms_unread_num
+* Description:      to get the unread sms num
+* Input:            the web para
+* Output:
+* Return:
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 2012/09/03    V1.0        liuyingnan       first version
+**********************************************************************/
+void zte_get_sms_unread_num(webs_t wp)
+{
+	int sms_dev_unread_count = 0;
+	sms_dev_unread_count = zte_libwms_get_sms_used(1, 1); //nv unread
+
+	if (wp->flags & WEBS_XML_CLIENT_REQUEST) {
+		zte_rest_cmd_write_int(wp, NV_SMS_UNREAD_NUM, sms_dev_unread_count, 0);
+	} else {
+		(void)websWrite(wp, T("\"%s\":\"%d\""), NV_SMS_UNREAD_NUM, sms_dev_unread_count);
+	}
+}
+
+/**********************************************************************
+* Function:         zte_web_feed_back_empty
+* Description:      to write empty info to web
+* Input:            the web para
+* Output:
+* Return:
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 2012/09/03    V1.0        liuyingnan       first version
+**********************************************************************/
+
+static void zte_web_feed_back_empty(webs_t wp)
+{
+	if (NULL == wp) {
+		return;
+	}
+
+	web_feedback_header(wp);
+	if (wp->flags & WEBS_XML_CLIENT_REQUEST) {
+		websWrite(wp, T("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"));
+		websWrite(wp, T("<%s>empty</%s>\n"), SMS_MESSAGES, SMS_MESSAGES);
+	} else {
+		(void)websWrite(wp, T("{\"%s\":[]}"), SMS_MESSAGES);
+	}
+
+}
+
+/******************************************************
+* Function: parseStrBySeparator()
+* Description: separate the string by a specific character
+* Input:
+* Output:
+* Return: -1--->failed, 0--->successful
+* Others:
+* Modify Date    Version   Author         Modification
+* 2010/10/27        V1.0     huangmin        create
+2012/06/20        v2.0       chenyi             modify
+*******************************************************/
+static unsigned int parseStrBySeparator
+(
+    unsigned char* input,
+    unsigned char* output,
+    int destLen,
+    unsigned char separator
+)
+{
+	int i, j, k;
+	int srcLen = 0;
+	i = j = k = 0;
+
+	if (NULL == input || NULL == output || destLen == 0 || strlen(input) == 0) {
+		slog(MISC_PRINT, SLOG_ERR, "parseStrBySemicolon: param is null!\n"); /*lint !e26*/
+		return 0;
+	}
+
+	srcLen = strlen(input) + 1;//which contains the '\0'
+
+	for (i = 0; i < srcLen; i++) {
+		if ('\0' == input[i]) {
+			if (k <= (destLen - 1)) {
+				*(output + destLen * j + k)  = '\0';
+			} else {
+				*(output + destLen * j + (destLen - 1))  = '\0';
+			}
+
+			return j + 1;
+		}
+
+		if (separator == input[i]) {
+			if (k <= (destLen - 1)) {
+				*(output + destLen * j + k)  = '\0';
+			} else {
+				*(output + destLen * j + (destLen - 1))  = '\0';
+			}
+
+			if ('\0' != input[i + 1]) {
+				k = 0;
+				j++;
+			}
+		} else {
+			if (k < (destLen - 1)) {
+				*(output + destLen * j + k)  = input[i];
+				k++;
+			}
+		}
+	}
+
+	return j;
+}
+
+#if 0
+/******************************************************
+* Function: sms_util_asc_to_hex()
+* Description: transform the ASCII string of SMS code to hex
+* Input:
+* Output:
+* Return: -1--->failed, 0--->successful
+* Others:
+* Modify Date    Version   Author         Modification
+* 2010/10/27        V1.0     huangmin        create
+*******************************************************/
+static int  sms_util_asc_to_hex                 /*lint !e528*/
+(
+    unsigned char  *in_ptr,    	/* IN: Pointer to the Hex data (in ASCII format)    */
+    unsigned char  *out_ptr,   /* OUT: Pointer to the result buffer(converted data) */
+    int   len                       	/* IN: Length of the input data pointer (Hex data)  */
+)
+{
+	unsigned char *str;
+	unsigned char temp_buf[3];
+	int i;
+	unsigned int num_val;
+	int result = 0;
+
+	str = in_ptr;
+
+	len = len * 2;
+
+	//WebSms_LOG(LOG_INFO,"in sms_util_asc_to_hex\n");/*lint !e26*/
+	while (len > 0) {
+		for (i = 0; (i < 2) && (*str != '\0'); i++) {
+			temp_buf[i] = *str++;
+		}
+		temp_buf[i] = '\0';
+		if (asc_util_atoi(&num_val, temp_buf, 16) != 0) {
+			/* We got a out of range value */
+			result = -1;
+		}
+		*out_ptr++ = (unsigned char)num_val;
+		// WebSms_LOG(LOG_INFO,"goahead=====middle===out_ptr===%s",out_ptr);/*lint !e26*/
+		len -= i;
+	}
+	WebSms_LOG(LOG_INFO, "leave sms_util_asc_to_hex\n"); /*lint !e26*/
+
+	return result;
+} /* ZTE_dsat707sms_asscii_to_is637_data */
+
+
+/******************************************************
+* Function: asc_util_atoi()
+* Description: transform the ASCII string to integer
+* Input:
+* Output:
+* Return: -1--->failed, 0--->successful
+* Others:
+* Modify Date    Version   Author         Modification
+* 2010/10/27        V1.0     huangmin        create
+*******************************************************/
+static int asc_util_atoi
+(
+    unsigned int *val_arg_ptr,      /*  value returned  */
+    const unsigned char *s,                        /*  points to string to eval  */
+    unsigned int r                        /*  radix */
+)
+{
+	int err_ret = 0;
+	unsigned char c;
+	unsigned int val, val_lim, dig_lim;
+
+	val = 0;
+	val_lim = (unsigned int)((unsigned int)0xFFFFFFFF / r);
+	dig_lim = (unsigned int)((unsigned int)0xFFFFFFFF % r);
+
+	while ((c = *s++) != '\0') {
+		if (c != ' ') {
+			c = (unsigned char) UPCASE(c);
+			if (c >= '0' && c <= '9') {
+				c -= '0';
+			} else if (c >= 'A') {
+				c -= 'A' - 10;
+			} else {
+				err_ret = -1;  /*  char code too small */
+				break;
+			}
+
+			if (c >= r || val > val_lim
+			    || (val == val_lim && c > dig_lim)) {
+				err_ret = -1;  /*  char code too large */
+				break;
+			} else {
+				err_ret = 0;            /*  arg found: OK so far*/
+				val = (unsigned int)(val * r + c);
+			}
+		}
+		*val_arg_ptr =  val;
+	}
+
+	return err_ret;
+}
+#endif
+void zte_get_boradcast_data(webs_t wp)
+{
+	zte_wms_cell_bro_s_type *p_bro_query_result = NULL;
+
+	int result = 0;
+
+	slog(MISC_PRINT, SLOG_NORMAL, "zte_get_boradcast_data GET DATA FROM DB START.\n");
+	p_bro_query_result = (zte_wms_cell_bro_s_type*)malloc(1 + sizeof(zte_wms_cell_bro_s_type));
+	if(p_bro_query_result == NULL) return;
+	result = zte_libwms_get_cell_bro(p_bro_query_result);
+
+	slog(MISC_PRINT, SLOG_DEBUG, "zte_get_boradcast_data GET DATA FROM DB END.\n");
+	if (-1 == result) {
+		slog(MISC_PRINT, SLOG_ERR, "call zte_libwms_get_cell_bro fail.\n");
+		zte_web_feed_back_empty(wp);
+		//cov
+		free(p_bro_query_result);
+		p_bro_query_result = NULL;
+		return ;
+	}
+	web_feedback_header(wp);
+	zte_rest_get_bro_data_head(wp);
+	zte_rest_boradcast_data(wp, p_bro_query_result);
+	zte_rest_get_bro_data_foot(wp);
+
+
+
+
+	//if (NULL != p_bro_query_result) {
+		free(p_bro_query_result);
+		p_bro_query_result = NULL;
+	//}
+
+}
diff --git a/lynq/S300/ap/app/goahead/interface5.0/zte_web_util.c b/lynq/S300/ap/app/goahead/interface5.0/zte_web_util.c
new file mode 100755
index 0000000..76f0e37
--- /dev/null
+++ b/lynq/S300/ap/app/goahead/interface5.0/zte_web_util.c
@@ -0,0 +1,864 @@
+/**
+ * @file zte_web_util.c
+ * @brief goform mesage processing
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author Hong Wu <wu.hong@sanechips.com.cn>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+
+/*******************************************************************************
+ *                           Include header files                              *
+ ******************************************************************************/
+
+#include	<stdio.h>
+#include	<stdlib.h>
+#include	<sys/ioctl.h>
+#include	<arpa/inet.h>
+#include	<net/if.h>
+#include	<net/route.h>
+#ifdef CONFIG_DEFAULTS_KERNEL_2_6_21
+#include	<linux/types.h>
+#include	<linux/socket.h>
+#endif
+#include    <string.h>
+#include    <dirent.h>
+#include	"webs.h"
+//#include	"linux/autoconf.h"
+#include    <sys/time.h>
+#include    <signal.h>
+#include    "zte_web_interface.h"
+#include    "zte_web_get_fw_para.h"
+
+/*******************************************************************************
+ *                             Macro definitions                               *
+ ******************************************************************************/
+
+#define MAX_MOBILE_KEY_WORD_SIZE    20  /*¹Ø¼ü×Ö³¤¶ÈÔݶ¨20*/
+#define MAX_PAGE_PATH_SIZE          128
+//#define MAX_GOFORM_TABLE_SIZE       256
+
+/*******************************************************************************
+ *                        Local function declarations                          *
+ ******************************************************************************/
+static int getSysUptime(int eid, webs_t wp, int argc, char_t **argv);
+static int zte_goform_whitelist_check(webs_t wp);
+static int zte_goform_blacklist_check(webs_t wp);
+/*******************************************************************************
+ *                         Local variable definitions                          *
+ ******************************************************************************/
+/****Define the HEADER and FOOTER of web page****/
+static const char * const zte_web_page_header =
+    "<head>"
+    "<title>-</title>"
+    "</head>"
+    "<body bgcolor=white>"
+    "<p>"
+    "<font size=3 face=arial>"
+    "<p>"
+    "<font size=2 face=arial>"
+    ;
+
+static const char * const zte_web_page_footer =
+    "<p>"
+    "<p>"
+    "<font face=arial></b></font><br>"
+    "<script> "
+    " timer = setTimeout('location.replace(\"%s\")', 100) "
+    "</script> "
+    "<p>"
+    "</body>"
+    ;
+
+static const char * const zte_web_page_top =
+    "<p>"
+    "<p>"
+    "<font face=arial></b></font><br>"
+    "<script> "
+    " timer = setTimeout('top.location.replace(\"%s\")', 100) "
+    "</script> "
+    "<p>"
+    "</body>"
+    ;
+//multi_dataΪ¿Õ£¬ÇÒÒѵǽ²ÅÄÜ»ñÈ¡µ½,¸ÃÁÐ±í²»¿ÉËæÒâÔö¼Ó¾¡Á¿ÓÃNV
+static web_goform_type web_goform_get_cmd_table[] = {
+	/**********  ¹²Í¬ ***********/
+	//{CMD_GET_DEVICE_MODE, zte_get_device_mode},//debug_enable
+	//{CMD_GET_POWERON_TIME, zte_get_poweron_time},//¿ª»úʱ¼ä
+	//{CMD_GET_LAN_DEV_INFO, zte_get_lan_dev_info},//»ñÈ¡ÄÚÍøÐÅÏ¢
+	{CMD_GET_USER_MAC_ADDR, zte_lan_user_mac_get},
+	{CMD_CONNECTION_MODE, zte_get_connection_mode},
+	/**********  PBM module  ***********/
+	{CMD_PBM_DATA_INFO, zte_get_pbm_data},
+	{CMD_PBM_DATA_TOTAL, zte_get_pbm_data_total},
+	{CMD_PBM_CAPACITY_INFO, zte_get_pbm_parameter_info},
+	/**********  sms module  ***********/
+	{CMD_SMS_PAGE_DATA, zte_get_sms_data},
+	{CMD_SMS_DATA_TOTAL, zte_get_sms_data_total},
+	{CMD_SMS_PARAMETER_INFO, zte_get_sms_parameter_info},
+	{CMD_SMS_STATUS_INFO, zte_get_sms_cmd_status_info},
+	{CMD_SMS_CAPACITY_INFO, zte_get_sms_capacity_info},
+	{CMD_SMS_STATUS_RPT_DATA, zte_get_sms_status_rpt_data},
+	{CMD_SMS_UNREAD_COUNT, zte_get_sms_unread_count},
+	{CMD_BROADCAST_DATA, zte_get_boradcast_data},
+	/**********  wifi module  ***********/
+	{CMD_WIFI_STATION_LIST, zte_wlan_get_station_list},
+	{CMD_WIFI_WPS_AP_PIN, zte_wlan_get_wps_pin},
+	{CMD_WIFI_WPS_AP_DEF_PIN, zte_wlan_get_wps_defpin},
+	/**********  net module  ***********/
+	{CMD_HOSTNAME_LIST, zte_get_hostnamelist},
+	{CMD_CURRENT_STATICADDR_LIST, zte_get_current_static_addr_list},
+	{CMD_LAN_STATION_LIST, zte_get_lan_station_list},
+	{CMD_CHILDREN_DEVICE_LIST, zte_get_children_device_list},
+	{CMD_WHITE_SITE_LIST, zte_get_white_site_list},
+	/**********  DDNS  ***********/
+	//{CMD_GETDDNS_STATUS, zte_get_ddns_status},
+	/**********  USSD  ***********/
+	{CMD_USSD_DATA_INFO, zte_get_ussd_data_info},
+	/**********  FOTA  ***********/
+	{FOTA_UPGRADE_RESULT, zte_fota_get_upgrade_result}, //¶ÁÈ¡ºóÐèÒªÌØÊâ´¦Àí £¬ËùÒÔ²»ÄܸijÉÖ±½Ó¶ÁNV
+
+	/**********  httpshare  ***********/
+	{CMD_HTTPSHARE_GETCARD_VAULE, zte_httpShare_getcard_value},
+	{CMD_HTTPSHARE_GETCARD_NMEA, zte_httpShare_getcard_name},
+	{CMD_HTTPSHARE_AUTH_GET, zte_httpShare_auth_get},
+};
+
+
+/*******************************************************************************
+*                        Global variable definitions                          *
+******************************************************************************/
+//extern web_goform_type web_goform_set_cmd_table[MAX_GOFORM_TABLE_SIZE];
+web_goform_type web_goform_set_cmd_table[] = {
+	/**********  management module ***********/
+	{GOFORM_MGMT_SET_WEB_LANGUAGE, zte_mgmt_set_language},                      //webuiÓïÑÔÏÔʾÉèÖÃ
+#ifndef WEBS_SECURITY
+	{GOFORM_MGMT_SET_DEVICEMODE, zte_mgmt_set_devicemode},                      //¹¤×÷ģʽ
+#endif
+	{GOFORM_MGMT_LOGIN_IP, zte_mgmt_login},                                     //怫
+	{GOFORM_MGMT_LOGOUT_IP, zte_mgmt_logout},                                   //µÇ³ö
+	{GOFORM_MGMT_CHANGE_PASSWORD, zte_mgmt_change_password},                    //ÃÜÂëÐÞ¸Ä
+	{GOFORM_MGMT_CHANGE_ACCOUNT, zte_mgmt_change_account},                      //Õ˺ÅÐÞ¸Ä
+	{GOFORM_MGMT_QUICK_SETUP, zte_quick_setup},                                 //¿ìËÙÉèÖÃ
+	{GOFORM_MGMT_RESTORE_FACTORY_SETTINGS, zte_mgmt_restore},                   //»Ö¸´³ö³¡ÉèÖÃ
+	{GOFORM_MGMT_REBOOT, zte_goform_mgmt_reboot_process},                       //REBOOT
+	{GOFORM_MGMT_POWEROFF, zte_mgmt_poweroff},                                  //poweroff
+	{GOFORM_MGMT_POWER_ON_SPEED, zte_mgmt_control_power_on_speed},              //¿ìËÙ¿ª¹Ø»úÉèÖÃ
+	//{GOFORM_MGMT_SET_EXTERNAL_NV, zte_goform_set_external_nv},
+	{GOFORM_MGMT_SCHEDULE_SETTING, zte_goform_mgmt_schedule_setting_process},
+	{GOFORM_MGMT_SNTP, zte_goform_mgmt_sntp_process},                           //SNTPÉèÖÃ
+	{GOFORM_SNTP_GETDATASTATIC, zte_goform_sntp_getdatastatic_process},         //´¥·¢serverУ׼ʱ¼ä
+	//{GOFORM_MGMT_SYSLOG, zte_goform_mgmt_syslog_process},                       //ϵͳLOG
+
+	/**********  wan module start***********/
+	{GOFORM_WAN_SET_NETWORK, zte_wan_set_network},                              //ÊÖ¶¯ËÑÍø×¢²á
+	{GOFORM_WAN_SET_CONNECTION_MODE, zte_wan_set_connection_mode},              //ÉèÖò¦ºÅģʽ
+	{GOFORM_WAN_CONNECT_NETWORK, zte_wan_connect_network},                      //PDP ²¦ºÅÇëÇó
+	{GOFORM_WAN_DISCONNECT_NETWORK, zte_wan_disconnect_network},                //PDP ²¦ºÅ¶Ï¿ªÇëÇó
+	{GOFORM_WAN_SET_BEARER_PREFERENCE, zte_wan_network_select},                 //ÉèÖÃÕÒÍø·½Ê½MSG_CMD_NET_SELECT_REQ
+	{GOFORM_WAN_SCAN_NETWORK, zte_wan_scan_network},                            //ÊÖ¶¯ËÑÍø
+	{GOFORM_WAN_UNLOCK_NETWORK, zte_mgmt_unlock_network},                       //½âËøÍøÂç
+	//{GOFORM_WAN_LOCK_FREQUENCY, zte_wan_lock_frequency_process},                //LTEÏÂËø»ò½âËøÆµÇëÇó£¬ATÔÝδ´¦Àí
+	/**********  apn module ***********/
+	{GOFORM_WAN_APN_PROC_EX, zte_form_multi_apn_proc_ex},                        //APNÉèÖÃ
+	/**********  pin,puk module ***********/
+	{GOFORM_MGMT_ENTER_PIN, zte_mgmt_pin_input},                                 //ÑéÖ¤PINÂëÊäÈë
+	{GOFORM_MGMT_DISABLE_PIN, zte_mgmt_disable_pin},                             //¹Ø±ÕPIN
+	{GOFORM_MGMT_ENABLE_PIN, zte_mgmt_pin_enable_or_modify},                     //¿ªÆô»òÐÞ¸ÄPIN
+	{GOFORM_MGMT_ENTER_PUK, zte_mgmt_puk_input},                                 //PUK
+	{GOFORM_MGMT_AUTO_PIN, zte_mgmt_auto_pin},                                   //×Ô¶¯PIN
+	/**********  statistics module ***********/
+	{GOFORM_WAN_DATA_LIMIT_SETTING, zte_wan_data_limit_setting},                    //Á÷Á¿¹ÜÀíÉèÖÃ
+	{GOFORM_WAN_DATA_FLOW_CALIBRATION_MANUAL, zte_wan_data_flow_calibration_manual},//ÊÖ¶¯Ð£×¼Á÷Á¿
+	{GOFORM_WAN_RESET_DATA_COUNTER, zte_wan_data_statistics_clear_process},         //Çå³ýÁ÷Á¿ÐÅÏ¢
+	/**********  ussd module ***********/
+	{GOFORM_USSD_PROCESS, zte_goform_ussd_process},                               //USSDÉèÖÃ
+	/**********  wan module end***********/
+
+	/**********  wifi module ***********/
+	{GOFORM_WLAN_SET, zte_wlan_basic_set},                                        //WIFI »ù´¡ÉèÖÃ
+	{GOFORM_WLAN_MAC_FILTER, zte_wlan_mac_filter_set},                            //ÉèÖÃmac¹ýÂ˹¦ÄÜ
+	{GOFORM_WLAN_WPS_SET, zte_wlan_wps_mode_set},                                 //WPS
+	{GOFORM_WLAN_SSID1_SET, zte_wlan_web_ssid1_set},                              //SSID1
+	{GOFORM_WLAN_SSID2_SET, zte_wlan_ssid2_set},                                  //SSID2
+	{GOFORM_WLAN_WIFI_SLEEP_SET, zte_wlan_sleep_set},                             //ÐÝÃß
+	{GOFORM_WLAN_SET_TSW, zte_wlan_set_tsw},                                      //¶¨Ê±ÐÝÃß»½ÐÑ
+	{GOFORM_WLAN_WIFI_COVERAGE_SET, zte_wlan_coverage_set},                       //¸²¸Ç·¶Î§
+	{GOFORM_WLAN_WIFI_STA_CONTROL, zte_wlan_station_set},                         //wifi station
+	{GOFORM_WLAN_WIFI_SPOT_PROFILE_UPDATE, zte_wlan_station_spot_profile_update}, //wifi station
+	{GOFORM_WLAN_SET_STA_CON, zte_wlan_station_connect},                          //wifi station
+	{GOFORM_WLAN_SET_STA_DISCON, zte_wlan_station_disconnect},                    //wifi station
+	{GOFORM_WLAN_SET_STA_REFRESH, zte_wlan_station_refresh},                      //wifi station
+
+	/**********  router module ***********/
+	{GOFORM_ROUTER_DEL_IP_PORT_FILETER, zte_fw_ipport_filter_del},
+	{GOFORM_ROUTER_ADD_IP_PORT_FILETER_V4V6, zte_fw_ipport_filter_add},           /*for v4 and v6*/
+	{GOFORM_ROUTER_DEL_IP_PORT_FILETER_V4V6, zte_fw_ipport_filter_del_v4_v6},     /*for v4 and v6*/
+	{GOFORM_ROUTER_ADD_PORT_FORWARE, zte_fw_port_forward_add},
+	{GOFORM_ROUTER_DEL_PORT_FORWARE, zte_fw_port_forward_del},
+	{GOFORM_ROUTER_ADD_PORT_MAP, zte_fw_port_map_add},
+	{GOFORM_ROUTER_DEL_PORT_MAP, zte_fw_port_map_del},
+	{GOFORM_ROUTER_BASIC_SETTING, zte_fw_basic_setting},
+	{GOFORM_ROUTER_FORWARD_SETTING, zte_fw_forward_setting},
+	{GOFORM_ROUTER_SYSTEM_SECURITY, zte_fw_sys_security_setting},
+	{GOFORM_ROUTER_DHCP_SETTING, zte_dhcp_set},
+	{GOFORM_ROUTER_STATIC_DHCP_SETTING, zte_static_dhcp_set},
+	{GOFORM_ROUTER_UPNP_SETTING, zte_fw_upnp_set},                                //CPEÈÚºÏÔÚ·ÓÉÉèÖÃÖÐ
+	{GOFORM_ROUTER_DMZ_SETTING, zte_fw_dmz},
+	{GOFORM_ROUTER_EDIT_HOSTNAME, zte_edit_hostname},
+	{GOFORM_URL_FILTER_DELETE, zte_goform_url_filter_delete_process},             //URL ¹ýÂË
+	{GOFORM_URL_FILTER_ADD, zte_goform_url_filter_add_process},
+	{GOFORM_BIND_STATIC_ADDRESS_SET, zte_set_bind_static_address},
+	{GOFORM_BIND_STATIC_ADDRESS_ADD, zte_bind_static_address_add},
+	{GOFORM_BIND_STATIC_ADDRESS_DEL, zte_bind_static_address_del},
+	{GOFORM_ADD_CHILDREN_DEVICE, zte_add_children_device},                        //¼Ò³¤¿ØÖÆ
+	{GOFORM_DEL_CHILDREN_DEVICE, zte_del_children_device},
+	{GOFORM_ADD_WHITE_SITE, zte_add_white_site},
+	{GOFORM_REMOVE_WHITE_SITE, zte_remove_white_site},
+	{GOFORM_PARENT_CONTROL_SET, zte_parent_control_set},
+	//{GOFORM_DDNS, zte_goform_ddns},
+	//{GOFORM_DNS_MODE_SET, zte_dns_mode_set},									 //ÉèÖÃÊÖ¶¯DNS mode
+	//{GOFORM_DNS_SERVER_SET, zte_dns_server_set},								 //ÉèÖÃÊÖ¶¯DNS server
+	/**********  wan pppoe ***********/
+	{GOFORM_SET_OPERATION_MODE, zte_goform_set_operation_mode},                   //RJ45ģʽÇл»ÉèÖÃ
+	{GOFORM_SET_WAN_GATEWAYMODE_PPPOE, zte_goform_set_wan_gatewaymode_PPPOE},
+	{GOFORM_SET_WAN_GATEWAYMODE_DHCP, zte_goform_set_wan_gatewaymode_DHCP},
+	{GOFORM_SET_WAN_GATEWAYMODE_STATIC, zte_goform_set_wan_gatewaymode_STATIC},
+	{GOFORM_SET_WAN_GATEWAYMODE_AUTO, zte_goform_set_wan_gatewaymode_AUTO},
+
+	/**********  httpShare module ***********/
+	{GOFORM_HTTPSHARE_ENTERFOLD, zte_httpShare_enterFold},                        //get SD's filelist
+	{GOFORM_HTTPSHARE_NEW, zte_httpShare_new},                                    //creat a new folder
+	{GOFORM_HTTPSHARE_DEL, zte_httpShare_del},                                    //delete file or folder
+	{GOFORM_HTTPSHARE_AUTH_SET, zte_httpShare_auth_set},                          //httpshare setting
+	{GOFORM_HTTPSHARE_MODE_SET, zte_httpShare_modeset},                           //set SD card's mode:usb mode or httpshare mode
+	{GOFORM_HTTPSHARE_FILE_RENAME, zte_httpShare_rename},                         //rename the file
+	{GOFORM_HTTPSHARE_CHECK_FILE, zte_httpShare_check_file},                      //check file exists
+
+	/**********  PBM module ***********/
+	{GOFORM_PBM_CONTACT_ADD, zte_goform_pbm_contact_add_process},
+	{GOFORM_PBM_CONTACT_DEL, zte_goform_pbm_contact_del_process},
+
+	/**********  sms module ***********/
+	{GOFORM_SMS_SET_MSG_CENTER, zte_sms_set_message_center},
+	{GOFORM_SMS_DELETE_SMS, zte_sms_delete_msg_process},
+	{GOFORM_SMS_DELETE_SMS_ALL, zte_goform_sms_alldel_msg_process},
+	{GOFORM_SMS_MOVE_TO_SIM, zte_sms_move_to_sim_msg_process},
+	{GOFORM_SMS_SAVE_SMS, zte_sms_save_msg_process},
+	{GOFORM_SMS_SEND_SMS, zte_sms_send_msg_process},
+	{GOFORM_SMS_SET_MSG_READ, zte_sms_view_msg_process},
+
+	/**********  fota module ***********/
+	{GOFORM_SET_FOTAAUTOUPDATE, zte_fota_update},                                  //Óû§Ñ¡ÔñÊÇ·ñ½øÐÐÉý¼¶ºÍÉý¼¶ÖÐÈ¡Ïû
+	{GOFORM_SET_FOTASETTINGS, zte_fota_settings},                                  //×Ô¶¯¼ì²â
+	{GOFORM_SET_FOTAMANUALUPG, zte_fota_manual_upgrade},                           // ÊÖ¶¯otaÉý¼¶
+
+	/**********  ping test   ***********/
+	//{GOFORM_PING_DIAGNOSTICS_START, zte_ping_diagnostics_start},					// ping°ü¼ì²â¹¦ÄÜ¿ªÆô
+	//{GOFORM_PING_DIAGNOSTICS_STOP, zte_ping_diagnostics_stop},						// ping°ü¼ì²â¹¦ÄܹرÕ
+
+	/********** ¿Í»§¶þ´Î¿ª·¢½Ó¿ÚÇëÔÚÏÂÃæÌí¼Ó ***********/
+	{GOFORM_SET_SAMPLE, zte_goform_set_sample},                                    //¿Í»§¶þ´Î¿ª·¢½Ó¿ÚʾÀý
+	/**********  cwmp module ***********/

+	{GOFORM_CWMP_SETTING, zte_goform_mamt_cwmp_process},

+};
+
+/*******************************************************************************
+ *                      Local function implementations                         *
+ ******************************************************************************/
+
+//WH://»ñȡϵͳ×î½üÒ»´ÎÉϵçºó³ÖÐøÔËÐÐʱ¼ä
+static int getSysUptime(int eid, webs_t wp, int argc, char_t **argv)
+{
+	struct tm *utime;
+	time_t usecs;
+
+	char syn_system_total[20] = {0};
+	char syn_after_time[20] = {0};
+	int ltime = 0;
+	int ntime = 0;
+
+	cfg_get_item("syn_system_total", syn_system_total, sizeof(syn_system_total));
+
+	sscanf(syn_system_total, "%d", &ltime);
+	if(ltime < 0 || ltime >  INT_MAX-1)  // kw 3
+	{
+		ltime = 0;
+	}	
+	ltime += JAN_2000;
+
+	cfg_get_item("syn_after_time", syn_after_time, sizeof(syn_after_time));
+
+	sscanf(syn_after_time, "%d", &ntime);
+	if(ntime < 0 || ntime >  INT_MAX-1)  // kw 3
+	{
+		ntime = 0;
+	}	
+	time(&usecs);
+	if (ntime == 0) {
+		utime = localtime(&usecs);
+	} else {
+		time_t use;
+		use = (time_t)(usecs - ntime + ltime);
+		utime = localtime(&use);
+	}
+	if(utime == NULL)
+		return -1;
+	if (utime->tm_yday > 0) {
+		return websWrite(wp, T("%d day%s, %d hour%s, %d min%s, %d sec%s"),
+		                 utime->tm_yday, (utime->tm_yday == 1) ? "" : "s",
+		                 utime->tm_hour, ((utime->tm_hour == 1) || (utime->tm_hour == 0)) ? "" : "s",
+		                 utime->tm_min, ((utime->tm_min == 1) || (utime->tm_min == 0)) ? "" : "s",
+		                 utime->tm_sec, ((utime->tm_sec == 1) || (utime->tm_sec == 0)) ? "" : "s");
+	} else if (utime->tm_hour > 0) {
+		return websWrite(wp, T("%d hour%s, %d min%s, %d sec%s"),
+		                 utime->tm_hour, (utime->tm_hour == 1) ? "" : "s",
+		                 utime->tm_min, ((utime->tm_min == 1) || (utime->tm_min == 0)) ? "" : "s",
+		                 utime->tm_sec, ((utime->tm_sec == 1) || (utime->tm_sec == 0)) ? "" : "s");
+	} else if (utime->tm_min > 0) {
+		return websWrite(wp, T("%d min%s, %d sec%s"),
+		                 utime->tm_min, (utime->tm_min == 1) ? "" : "s",
+		                 utime->tm_sec, ((utime->tm_sec == 1) || (utime->tm_sec == 0)) ? "" : "s");
+	} else {
+		return websWrite(wp, T("%d sec%s"),
+		                 utime->tm_sec, ((utime->tm_sec == 1) || (utime->tm_sec == 0)) ? "" : "s");
+	}
+
+}
+
+static int zte_goform_whitelist_check(webs_t wp)
+{
+
+	char login_info[NV_ITEM_STRING_LEN_20] = {0};
+	char_t nv_ipaddr[40] = {0};
+	//zte_topsw_state_e_type status = ZTE_NVIO_MAX;
+	char_t *ip_address = NULL;
+
+	int result = FALSE;
+
+	zte_web_read(NV_LOGINFO, login_info);
+
+	//get request ip addr
+	ip_address = websGetRequestIpaddr(wp);
+#if 0 // kw 3 	 NVARIANT_CONDITION.UNREACH
+	if (NULL == ip_address) {
+		slog(MISC_PRINT, SLOG_ERR, "zte_goform_whitelist_check: ip_address is null.\n"); /*lint !e26*/
+		return FALSE;
+	}
+#endif	
+	(void)zte_web_read(NV_USER_IP_ADDR, nv_ipaddr);
+	if ((0 == strncmp(login_info, "ok", sizeof(login_info))) && (0 == strncmp(ip_address, nv_ipaddr, sizeof(nv_ipaddr)))) {
+		result = TRUE; //to update the timemark
+	}
+	if (result == TRUE) {
+		if (!zte_mgmt_login_timemark_set()) {
+			slog(MISC_PRINT, SLOG_ERR, "[ERROR]zte_goform_whitelist_check -> timemark set error .\n"); /*lint !e26*/
+		}
+	}
+
+	return result;
+}
+
+/******************************************************
+* Function: zte_goform_blacklist_check
+* Description:goform entry for handling set cmd
+* Input:   HTTP Request Info
+* Output:
+* Return:
+* Others:
+* Modify Date       Version    Author         Modification
+* 2013/01/21      V1.0        Liuyingnan          create
+*******************************************************/
+static int zte_goform_blacklist_check(webs_t wp)
+{
+	//char login_info[NV_ITEM_STRING_LEN_20] = {0};
+	char_t *zte_goform_id = NULL;
+	//zte_web_read(NV_LOGINFO, login_info);
+
+	zte_goform_id = websGetVar(wp, T("goformId"), T(""));
+	if (zte_goform_id == NULL) {
+		slog(MISC_PRINT, SLOG_ERR, "zte_goform_whitelist_check: zte_goform_id is null.\n"); /*lint !e26*/
+		return -1;
+	}
+
+	if ((0 == strncmp(GOFORM_MGMT_SET_WEB_LANGUAGE, zte_goform_id, strlen(GOFORM_MGMT_SET_WEB_LANGUAGE)))
+	    || (0 == strncmp(GOFORM_MGMT_LOGIN_IP, zte_goform_id, strlen(GOFORM_MGMT_LOGIN_IP)))
+	    || (0 == strncmp(GOFORM_MGMT_ENTER_PIN, zte_goform_id, strlen(GOFORM_MGMT_ENTER_PIN)))
+	    || (0 == strncmp(GOFORM_MGMT_ENTER_PUK, zte_goform_id, strlen(GOFORM_MGMT_ENTER_PUK)))
+	    || (0 == strncmp(GOFORM_HTTPSHARE_CHECK_FILE, zte_goform_id, strlen(GOFORM_HTTPSHARE_CHECK_FILE)))
+	    || (0 == strncmp(GOFORM_HTTPSHARE_ENTERFOLD, zte_goform_id, strlen(GOFORM_HTTPSHARE_ENTERFOLD)))
+	    || (0 == strncmp(GOFORM_HTTPSHARE_FILE_RENAME, zte_goform_id, strlen(GOFORM_HTTPSHARE_FILE_RENAME)))
+	    || (0 == strncmp(GOFORM_HTTPSHARE_NEW, zte_goform_id, strlen(GOFORM_HTTPSHARE_NEW)))
+	    || (0 == strncmp(GOFORM_HTTPSHARE_DEL, zte_goform_id, strlen(GOFORM_HTTPSHARE_DEL)))
+#ifndef WEBS_SECURITY
+	    || (0 == strncmp(GOFORM_MGMT_LOGOUT_IP, zte_goform_id, strlen(GOFORM_MGMT_LOGOUT_IP)))
+	    || (0 == strncmp(GOFORM_MGMT_SET_DEVICEMODE, zte_goform_id, strlen(GOFORM_MGMT_SET_DEVICEMODE)))
+	    || (0 == strncmp(GOFORM_MGMT_REBOOT, zte_goform_id, strlen(GOFORM_MGMT_REBOOT)))
+#endif
+	    ) {
+		slog(MISC_PRINT, SLOG_DEBUG, "zte_goform_whitelist_check: zte_goform_id:[%s] is OK.\n", zte_goform_id); /*lint !e26*/
+		return 1;
+	} else {
+		slog(MISC_PRINT, SLOG_ERR, "zte_goform_whitelist_check: zte_goform_id:[%s] is black.\n", zte_goform_id); /*lint !e26*/
+		return -1;
+	}
+
+}
+
+static int isMobileReq(webs_t wp)
+{
+	int  iMobileKW = 0;
+	const char MOBILE_KEYWORD[][MAX_MOBILE_KEY_WORD_SIZE] = {"Mobile", "mobile", "MOBILE"};
+
+	if (wp->userAgent == NULL) {
+		return 0;
+	}
+	for (iMobileKW = 0; iMobileKW < sizeof(MOBILE_KEYWORD) / MAX_MOBILE_KEY_WORD_SIZE; iMobileKW++) {
+		if (strstr(wp->userAgent, MOBILE_KEYWORD[iMobileKW]) != NULL) {
+			return 1;
+		}
+	}
+	return 0;
+}
+static int isPageExist(char *page)
+{
+	char *defaultDir    = websGetDefaultDir();
+	char *fullPagePath  = NULL;
+	int  fullPathSize   = 0;
+	int  hasPageExist   = 0;
+
+	if (defaultDir == NULL || page == NULL) {
+		return 0;
+	}
+	fullPathSize = strlen(defaultDir) + strlen(page) + 2;
+	fmtAlloc(&fullPagePath, fullPathSize, T("%s/%s"), defaultDir, page);
+	hasPageExist = (access(fullPagePath, F_OK) == 0);
+	bfreeSafe(B_L, fullPagePath);
+	return hasPageExist;
+}
+
+int is_print_str(char *str, int len)
+{
+	int i = 0;
+	if (str == NULL || len <= 0 || strlen(str) < len) {
+		return 0;
+	}
+	for (i = 0; i < len; i++) {
+		if (!isprint(str[i])) {
+			return 0;
+		}
+		if(str[i] == '%' && (i+2) < len && isxdigit(str[i+1]) && isxdigit(str[i+2]))
+		{
+			if(str[i+1] < '2' || str[i+1] > '7' ||(str[i+1] == '7' && (str[i+2] == 'f' || str[i+2] == 'F')))
+			{
+				return 0;
+			}
+		}
+	}
+	return 1;
+}
+
+/*******************************************************************************
+ *                      Global function implementations                        *
+ ******************************************************************************/
+
+/******************************************************
+* Function: void zte_web_init()
+* Description:  the entry of zte code in goahead
+* Input:
+* Output:
+* Return:
+* Others:
+* Modify Date    Version   Author         Modification
+* 2010/8/5         V1.0     LiuWei        create
+* 2010/11/4        V1.1     ZYT           modify
+*******************************************************/
+void zte_web_init()
+{
+	cfg_set(NV_LOGINFO, "");
+	websFormDefine(T("proc_get"), zte_goform_get_cmd_process);
+	websFormDefine(T("proc_post"), zte_goform_set_cmd_process);
+	zte_init_login_psw_time(); //WH:³õʼ»¯×î´óµÇ½´ÎÊý
+}
+
+/*
+ * description: parse va and do system
+ */
+#if 0 
+int doSystem(char_t *fmt, ...)
+{
+	va_list	vargs;
+	char_t	*cmd = NULL;
+	int	rc = 0;
+
+	va_start(vargs, fmt);/*lint !e530*/
+	if (fmtValloc(&cmd, WEBS_BUFSIZE, fmt, vargs) >= WEBS_BUFSIZE) {
+		trace(0, T("doSystem: lost data, buffer overflow\n"));
+	}
+	va_end(vargs);
+
+	if (cmd) {
+		trace(0, T("%s\n"), cmd);
+		rc = system(cmd);
+		bfree(B_L, cmd);
+	}
+	return rc;
+}
+#endif
+/******************************************************
+* Function: void zte_webs_feedback_top(webs_t wp, char *fileName)
+* Description:  feed back web page at top location
+* Input:
+* Output:
+* Return:
+* Others:
+* Modify Date    Version   Author         Modification
+* 2010/9/10         V1.0     LiuWei        create
+* 2010/11/15        V1.1     zyt           modify
+*******************************************************/
+void zte_webs_feedback_top(webs_t i_wp, char *i_pageName)
+{
+	char dest_page[64] = {0};
+	char language[64] = {0};
+
+	if (NULL == i_pageName) {
+		slog(MISC_PRINT, SLOG_ERR, "zte_webs_feedback_top para null.\n"); /*lint !e26*/
+		return;
+	}
+
+	cfg_get_item(NV_LANGUAGE, language, sizeof(language));
+	websWrite(i_wp, T("HTTP/1.1 200 OK\n"));
+	websWrite(i_wp, T("Pragma: no-cache\n"));
+	websWrite(i_wp, T("Cache-control: no-cache\n"));
+	websWrite(i_wp, T("Connection: Close\n"));
+	websWrite(i_wp, T("Content-Type: text/html\n"));
+	websWrite(i_wp, T("Set-Cookie: mLangage=%s;"" path=/;"" Expires=Mon, 1 Jan 2050 00:00:00 GMT\n"), language);
+	websWrite(i_wp, T("\n"));
+	websWrite(i_wp, T("<html>\n"));
+	websWrite(i_wp, T(zte_web_page_header));
+	websWrite(i_wp, T(zte_web_page_top), i_pageName);
+	websWrite(i_wp, T("</html>"));
+}
+
+
+
+/******************************************************
+* Function: zte_goform_get_cmd_process()
+* Description:goform entry from web pages to get fw para, call the related functions according to the cmd
+* Input:   HTTP Request Info
+* Output:
+* Return:
+* Others:
+* Modify Date      Version    Author         Modification
+* 2012/08/08      V1.0         liuyingnan           create
+*******************************************************/
+void zte_goform_get_cmd_process(webs_t wp, char *path, char *query)
+{
+	char_t *cmd = NULL;
+	char_t *multi_data = NULL;
+	char login_info[NV_ITEM_STRING_LEN_20] = {0};
+	UINT32 ticks = 0;
+	int goform_index = 0;
+	int max_goform_index = (int)(sizeof(web_goform_get_cmd_table) / sizeof(web_goform_type));
+
+	zte_get_login_status_value(wp, login_info);
+
+	cmd = websGetVar(wp, T("cmd"), T(""));
+	multi_data = websGetVar(wp, T("multi_data"), T(""));
+
+	slog(MISC_PRINT, SLOG_DEBUG, "[goahead] zte_goform_get_cmd_process multi_data = %s, cmd = %s\n", multi_data, cmd);
+
+	zte_mgmt_login_timeout_check();
+
+	if (0 == strcmp(cmd, "")) {
+		websDone(wp, 0);
+		return;
+	}
+#ifdef WEBINSPECT_FIX		
+	if (query && (strstr(query, "%3d%2f")
+		|| strstr(query, "%3c%2f")
+		|| strstr(query, "=/")
+		|| strstr(query, "</")
+		|| strstr(query, "%27")
+		|| strstr(query, "'")
+#ifdef WEBS_SECURITY
+		|| strstr(query, "%2f")
+		|| strstr(query, "/")
+		|| strstr(query, "%5c")
+		|| strstr(query, "\\")
+		|| strstr(query, "%3c")
+		|| strstr(query, "<")
+		|| strstr(query, "%3e")
+		|| strstr(query, ">")
+		|| strstr(query, "%28")
+		|| strstr(query, "(")
+		|| strstr(query, "%29")
+		|| strstr(query, ")")
+		|| strstr(query, "%25")
+#endif		
+		)) {
+		//slog(MISC_PRINT, SLOG_ERR,"[goahead]e qry:%s\n",query);
+		slog(MISC_PRINT, SLOG_ERR,"[goahead]e 1\n");
+		websDone(wp, 0);
+		return;
+	}
+	if (strstr(cmd, "=/") || strstr(cmd, "</")
+#ifdef WEBS_SECURITY
+	|| strstr(cmd, "/") || strstr(cmd, "\\") || strstr(cmd, "<") || strstr(cmd, ">")
+#endif	
+		|| strstr(cmd, "'")) {
+		//slog(MISC_PRINT, SLOG_ERR,"[goahead]e cmd:%s\n",cmd);
+		slog(MISC_PRINT, SLOG_ERR,"[goahead]e 2\n");
+		websDone(wp, 0);
+		return;
+	}
+#ifdef WEBS_SECURITY
+	char token[COOKIE_SESSION_SIZE+1] = {0};
+	char cook_id[COOKIE_SESSION_SIZE+1] = {0};
+	(void)zte_web_read(NV_COOKIE_ID, cook_id);
+	(void)zte_web_read(NV_WEB_TOKEN, token);
+	if (strlen(cook_id) && wp->cookie && strlen(wp->cookie) > strlen(token)
+		&& (strstr(wp->cookie, token) == NULL)) {
+		//slog(MISC_PRINT, SLOG_ERR,"[goahead]e cmd:%s\n",cmd);
+		//slog(MISC_PRINT, SLOG_ERR,"[goahead]e token:%s\n",token);
+		//slog(MISC_PRINT, SLOG_ERR,"[goahead]e cookie:%s\n",wp->cookie);
+		slog(MISC_PRINT, SLOG_ERR,"[goahead]e 3\n");
+		websDone(wp, 0);
+		cfg_set(NV_WEB_TOKEN, "");
+		return;
+	}
+	if(query && !is_print_str(query,strlen(query)))
+	{
+		slog(MISC_PRINT, SLOG_ERR,"[goahead]g print_str\n");
+		websDone(wp, 0);
+		return;
+	}
+#endif
+#endif
+	if ((0 == strcmp("ok", login_info)) || (0 == strcmp(GOFORM_HTTPSHARE_GETCARD_VAULE, cmd))) {
+		if (0 == strcmp(multi_data, "")) {
+			for (goform_index = 0; goform_index < max_goform_index; goform_index++) {
+				if (0 == strcmp(web_goform_get_cmd_table[goform_index].goform_id, cmd)) {
+					(*(web_goform_get_cmd_table[goform_index].proc_func))(wp);
+					websDone(wp, 200);
+					return;
+				}
+			}
+			zte_web_get_para_xml(wp, (char_t *)cmd);
+		} else {
+			zte_get_request_process_xml(wp, cmd);
+		}
+	} else {
+		if (0 == strcmp(multi_data, "")) {
+			zte_web_get_para_nologin(wp, (char_t *)cmd);
+		} else {
+			zte_get_request_process_nologin(wp, (char_t *)cmd);
+		}
+	}
+	websDone(wp, 0);
+	return;
+
+}
+
+/******************************************************
+* Function: zte_goform_set_cmd_process()
+* Description:goform entry from web pages to set firmware para
+* Input:   HTTP Request Info
+* Output:
+* Return:
+* Others:
+* Modify Date      Version    Author         Modification
+* 2012/08/08      V1.0         liuyingnan           create
+*******************************************************/
+
+void zte_goform_set_cmd_process(webs_t wp, char *path, char *query)
+{
+	char_t *zte_goform_id = NULL;
+	int goform_index = 0;
+	int max_goform_index = (int)(sizeof(web_goform_set_cmd_table) / sizeof(web_goform_type));
+	int blacklist_result = 0;
+	char login_info[NV_ITEM_STRING_LEN_20] = {0};
+
+	zte_get_login_status_value(wp, login_info);
+	zte_goform_id = websGetVar(wp, T("goformId"), T(""));
+
+    slog(MISC_PRINT, SLOG_DEBUG,"[goahead] zte_goform_set_cmd_process zte_goform_id = %s,login_info=%s!\n", zte_goform_id, login_info);
+#ifdef WEBINSPECT_FIX		
+		if (query && (strstr(query, ")(") 
+/*			|| strstr(query, "%26%26")
+			|| strstr(query, "&&") 
+			|| strstr(query, "%7C%7C") 
+			|| strstr(query, "||")
+			|| strstr(query, "%3B")
+			|| strstr(query, ";")*/
+			)) {
+			//slog(MISC_PRINT, SLOG_ERR,"[goahead]e sqry:%s\n",query);
+			slog(MISC_PRINT, SLOG_ERR,"[goahead]e 4\n");
+			websDone(wp, 0);
+			return;
+		}
+#ifdef WEBS_SECURITY
+		if (!(wp->flags & WEBS_POST_REQUEST)||(query && (strstr(query, "%2f") 
+			|| strstr(query, "/") 
+			|| strstr(query, "%5c") 
+			|| strstr(query, "\\")
+			|| strstr(query, "%3c") 
+			|| strstr(query, "<")
+			|| strstr(query, "%3e") 
+			|| strstr(query, ">")
+			|| strstr(query, "%27")
+			|| strstr(query, "'")
+			|| strstr(query, "%28")
+			|| strstr(query, "(")
+			|| strstr(query, "%29")
+			|| strstr(query, ")")
+			|| strstr(query, "%25")
+			))) {
+			//slog(MISC_PRINT, SLOG_ERR,"[goahead]e qry:%s\n",query);
+			slog(MISC_PRINT, SLOG_ERR,"[goahead]e 5\n");
+			websDone(wp, 0);
+			return;
+		}
+		char token[COOKIE_SESSION_SIZE+1] = {0};
+		char cook_id[COOKIE_SESSION_SIZE+1] = {0};
+		(void)zte_web_read(NV_COOKIE_ID, cook_id);
+		(void)zte_web_read(NV_WEB_TOKEN, token);
+		if (strlen(cook_id) && wp->cookie && strlen(wp->cookie) > strlen(token)
+			&& (strstr(wp->cookie, token) == NULL)) {
+			//slog(MISC_PRINT, SLOG_ERR,"[goahead]e goform:%s\n",zte_goform_id);
+			//slog(MISC_PRINT, SLOG_ERR,"[goahead]e token:%s\n",token);
+			//slog(MISC_PRINT, SLOG_ERR,"[goahead]e cookie:%s\n",wp->cookie);
+			slog(MISC_PRINT, SLOG_ERR,"[goahead]e 6\n");
+			websDone(wp, 0);
+			cfg_set(NV_WEB_TOKEN, "");
+			return;
+		}
+		if(query && !is_print_str(query,strlen(query)))
+		{
+			slog(MISC_PRINT, SLOG_ERR,"[goahead]s print_str\n");
+			zte_write_result_to_web(wp, FAILURE);
+			websDone(wp, 200);
+			return;
+		}
+#endif	
+#endif	
+
+	if (0 != strcmp("ok", login_info)) {
+		blacklist_result = zte_goform_blacklist_check(wp);
+		if (blacklist_result < 0) {
+            slog(MISC_PRINT, SLOG_ERR,"[ERROR]zte_goform_blacklist_check -> black goform id:[%s].\n", zte_goform_id);
+			zte_write_result_to_web(wp, FAILURE);
+			websDone(wp, 200);
+			return;
+		}
+	}
+
+	zte_mgmt_login_timemark_set();
+
+	for (goform_index = 0; goform_index < max_goform_index; goform_index++) {
+		if (0 == strcmp(web_goform_set_cmd_table[goform_index].goform_id, zte_goform_id)) {
+			(void)zte_goform_whitelist_check(wp);//not to check the return value, only A has logged in,then update the timemark
+			(*(web_goform_set_cmd_table[goform_index].proc_func))(wp);
+			break;
+		}
+	}
+
+	if (goform_index == max_goform_index) {
+        slog(MISC_PRINT, SLOG_ERR,"[ERROR]zte_goform_set_cmd_process -> unknown goform id:[%s].\n", zte_goform_id);
+		zte_write_result_to_web(wp, FAILURE);
+	}
+
+	websDone(wp, 200);
+	return;
+}
+
+zte_topsw_state_e_type zte_nvconfig_read(char *item, char *data, int dataLen)
+{
+	if (NULL == item || NULL == data) {
+		slog(MISC_PRINT, SLOG_ERR, "input is NULL."); /*lint !e26*/
+		return ZTE_NVIO_FAIL;
+	}
+
+	if (dataLen > NV_ITEM_VALUE_MAX_LEN) {
+		slog(MISC_PRINT, SLOG_ERR, "data of [%s] too long.", item); /*lint !e26*/
+		return ZTE_NVIO_FAIL;
+	}
+    // kw 3
+	if(0 == cfg_get_item(item, data, dataLen))
+	{
+    	return ZTE_NVIO_DONE;
+	}
+
+	return ZTE_NVIO_FAIL;
+}
+
+zte_topsw_state_e_type zte_nvconfig_write(char *item, char *data, int dataLen)
+{
+	if (NULL == item || NULL == data) {
+		slog(MISC_PRINT, SLOG_ERR, "input is NULL."); /*lint !e26*/
+		return ZTE_NVIO_FAIL;
+	}
+
+	if ((strlen(data) + 1) > NV_ITEM_VALUE_MAX_LEN || dataLen > NV_ITEM_VALUE_MAX_LEN) {
+		slog(MISC_PRINT, SLOG_ERR, "value is too long, name=%s.", item); /*lint !e26*/
+		return ZTE_NVIO_FAIL;
+	}
+
+	if(0 == cfg_set(item, data))
+	{
+	    return ZTE_NVIO_DONE;
+	}
+
+	return ZTE_NVIO_FAIL;
+}
+
+void zte_init_login_psw_time(void)
+{
+	(void)zte_web_write("psw_fail_num_str", LOGIN_FAIL_TIMES);
+}
+
+void zte_goform_set_external_nv(webs_t wp)
+{
+	char_t *nv_name = NULL;
+	char_t *nv_value = NULL;
+	nv_name = websGetVar(wp, T("external_nv_name"), T(""));
+	nv_value = websGetVar(wp, T("external_nv_value"), T(""));
+
+	if (nv_value == NULL || nv_name == NULL) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	if (0 != strncmp(nv_name, "external", 8)) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	cfg_set(nv_name, nv_value);
+	zte_write_result_to_web(wp, SUCCESS);
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: zte_web_get_login_page
+* ¹¦ÄÜÃèÊö: ×ÔÊÊÓ¦ÖÕ¶Ëä¯ÀÀÆ÷
+* ²ÎÊý˵Ã÷: (IN)
+*           (OUT)
+* ·µ »Ø Öµ:
+* ÆäËü˵Ã÷:
+**************************************************************************/
+const char* zte_web_get_login_page(webs_t wp)
+{
+	if (isMobileReq(wp) && isPageExist(ZTE_WEB_MOBILE_PAGE_LOGIN_NAME)) {
+		return ZTE_WEB_MOBILE_PAGE_LOGIN_NAME;
+	} else {
+		return ZTE_WEB_PAGE_LOGIN_NAME;
+	}
+}
+
+
+
diff --git a/lynq/S300/ap/app/goahead/interface5.0/zte_web_wan.c b/lynq/S300/ap/app/goahead/interface5.0/zte_web_wan.c
new file mode 100755
index 0000000..38b4903
--- /dev/null
+++ b/lynq/S300/ap/app/goahead/interface5.0/zte_web_wan.c
@@ -0,0 +1,1131 @@
+/************************************************************************
+* °æÈ¨ËùÓÐ (C)2010, ÉîÛÚÊÐÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+*
+* ÎļþÃû³Æ£º zte_web_wan.c
+* Îļþ±êʶ£º
+* ÄÚÈÝÕªÒª£º
+* ÆäËü˵Ã÷£º
+* µ±Ç°°æ±¾£º V0.1
+* ×÷    Õߣº zyt
+* Íê³ÉÈÕÆÚ£º 2010-11-06
+*
+* Ð޸ļǼ1£º
+* ÐÞ¸ÄÄÚÈÝ£º³õʼ°æ±¾
+************************************************************************/
+
+/**************************************************************************
+* Ð޸ıàºÅ : EC:617002790374
+* ÐÞ ¸Ä ÈË : chenjie10092374
+* ÐÞ¸ÄÈÕÆÚ : 2014.6.13
+* ÐÞ¸ÄÄÚÈÝ : Ìí¼ÓÓû§ÉèÖÃÊÖ¶¯²¦ºÅÇÒ´ËÊ±ÍøÂç¶Ï¿ªÊ±Äܼ°Ê±ÖÐÖ¹×Ô¶¯²¦ºÅ¹ý³ÌµÄ´úÂë
+**************************************************************************/
+
+/**************************************************************************
+* Ð޸ıàºÅ : EC:617002790374
+* ÐÞ ¸Ä ÈË : chenjie10092374
+* ÐÞ¸ÄÈÕÆÚ : 2014.6.23
+* ÐÞ¸ÄÄÚÈÝ : Ìí¼ÓÓû§È¡Ïû×Ô¶¯ÖØÁ¬¹¦ÄÜ
+**************************************************************************/
+/**************************************************************************
+* Ð޸ıàºÅ : EC:616000235589
+* ÐÞ ¸Ä ÈË : chenjie10092374
+* ÐÞ¸ÄÈÕÆÚ : 2014.7.16
+* ÐÞ¸ÄÄÚÈÝ : Ìí¼ÓÕÒÍø·½Ê½Á÷³Ì±£»¤
+**************************************************************************/
+#include "zte_web_interface.h"
+
+/************************************************************/
+#define FEATRUE_WEB_DEBUG
+#define FEATRUE_QMI_CONNECT
+
+/************ALL the WAN CFG para****************************/
+#define N_PPP_APN_MODEL            "apn_select"
+#define V_PPP_APN_MODEL_AUTO       "auto"
+#define V_PPP_APN_MODEL_MANUAL     "manual"
+#define N_PPP_APN_NAME             "wan_apn"
+#define N_PPP_DIAL_NUM             "wan_dial"
+#define V_PPP_DNS_MODEL_AUTO       "auto"
+#define V_PPP_DNS_MODEL_MANUAL     "manual"
+#define N_PPP_PDP_TYPE             "pdp_type"
+#define N_PPP_PDP_MODEL            "pdp_select"
+#define V_PPP_PDP_MODEL_AUTO       "auto"
+#define V_PPP_PDP_MODEL_MANUAL     "manual"
+#define N_PPP_PDP_ADDR             "pdp_addr"
+#define N_PPP_AUTH_MODEL           "ppp_auth_mode"
+#define V_PPP_AUTH_MODEL_PAP       "pap"
+#define V_PPP_AUTH_MODEL_CHAP      "chap"
+#define N_PPP_USER_NAME            "ppp_username"
+#define N_PPP_PASSWORD             "ppp_passtmp"
+#define N_NET_SELECT               "net_select"
+//#define N_NET_SELECT_NAME          "net_select_name"
+#define N_NO_MODEM                 "modem_undetected"
+
+#define TIME_STEP                         1
+#define APNCONFIG_NUM_MAX                 10
+#define APNCONFIG_ELEMENT_NUM             14
+#define APNCONFIG_MEMORY                  1024
+#define APNCONFIG_ELEMENT_MEMORY          64
+#define IFSTREQUAL(str1, str2) (strcmp((str1), (str2))?0:1)
+#define IFSTRNEQUAL(str1, str2, n) (strncmp((str1), (str2), (n))?0:1)
+
+
+
+typedef struct {
+	CHAR pre_mode[64];
+	CHAR net_select_mode[64];
+	CHAR net_select[64];
+	CHAR m_netselect_save[64];
+	CHAR m_netselect_contents[64];
+	CHAR m_netselect_status[64];
+} netSelectCfgNv;
+/*************************function define******************************/
+
+void apn_save_process_ex(webs_t wp);
+void apn_delete_process_ex(webs_t wp);
+void apn_set_default_with_profile_index_ex(webs_t wp);
+void apn_set_default_process_ex(webs_t wp);
+void apn_set_default_with_new_profile_ex(webs_t wp);
+static void set_apn_to_cfg(APN_PROFILE *apn_profile);
+static void set_ipv6_apn_to_cfg(IPV6_APN_PROFILE *apn_profile);
+static void set_ipv4v6_apn_to_cfg(APN_PROFILE *apn_profile, IPV6_APN_PROFILE *ipv6_apn_profile);
+static void get_apn_para_form_web(webs_t wp, APN_PROFILE *apn_profile);
+static void get_ipv6_apn_para_form_web(webs_t wp, IPV6_APN_PROFILE *apn_profile);
+static int zte_wan_auto_apn_set();
+static int zte_wan_util_set_dial_roam_switch(const char_t *roam_set);
+
+
+void zte_wan_connect_network(webs_t wp)
+{
+	char traffic_limit[NV_ITEM_STRING_LEN_10] = {0};
+	char flux_month_total[NV_ITEM_STRING_LEN_50] = {0};
+	char traffic_alined_delta[NV_ITEM_STRING_LEN_50] = {0};
+	char traffic_month_total[NV_ITEM_STRING_LEN_50] = {0};
+	long long int llflux_month_total = 0;
+	long long int lltraffic_alined_delta = 0;
+	long long int lltraffic_month_total = 0;
+
+	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User connect network!\n"));
+
+	cfg_set("user_initiate_disconnect", "0");  //Óû§Ö÷¶¯Á¬½Ó״̬£¬Í˳ö¸ÉԤģʽ
+	ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_PDP_ACT_REQ, 0, NULL, 0);
+
+	cfg_get_item("is_traffic_limit_on", &traffic_limit, sizeof(traffic_limit));
+	cfg_get_item("flux_month_total", &flux_month_total, sizeof(flux_month_total));
+	cfg_get_item("traffic_alined_delta", &traffic_alined_delta, sizeof(traffic_alined_delta));
+	cfg_get_item("traffic_month_total", &traffic_month_total, sizeof(traffic_month_total));
+
+	llflux_month_total = atoll(&flux_month_total);
+	lltraffic_alined_delta = atoll(&traffic_alined_delta);
+	lltraffic_month_total = atoll(&traffic_month_total);
+
+	if(llflux_month_total < 0 || llflux_month_total > LLONG_MAX-1){
+        llflux_month_total = LLONG_MAX;
+	}
+
+	if(lltraffic_alined_delta < 0 || lltraffic_alined_delta > LLONG_MAX-1){
+        lltraffic_alined_delta = LLONG_MAX;
+	}
+
+	if(lltraffic_month_total < 0 || lltraffic_month_total > LLONG_MAX-1){
+        lltraffic_month_total = LLONG_MAX;
+	}	
+
+	if (0 == strcmp(&traffic_limit, "yes")
+	    && llflux_month_total + lltraffic_alined_delta >= lltraffic_month_total * 1024 * 1024) {
+		cfg_set("keep_online_when_limited", "yes");
+	}
+	zte_write_result_to_web(wp, SUCCESS); //"success"
+}
+
+/*ÊÖ¶¯¶ÏÍø*/
+void zte_wan_disconnect_network(webs_t wp)
+{
+
+	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User disconnect network!\n"));
+	cfg_set("user_initiate_disconnect", "1");   //Óû§Ö÷¶¯¶Ï¿ª×´Ì¬£¬¸ÉԤģʽ
+
+	ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_PDP_DEACT_REQ, 0, NULL, 0);
+	zte_write_result_to_web(wp, SUCCESS);
+}
+
+/*ÊÖ¶¯ËÑÍøºóÉèÖÃÍøÂç*/
+void zte_wan_set_network(webs_t wp)
+{
+
+	CHAR *pMccmnc       = NULL;
+	CHAR *pNetType      = NULL;
+	CHAR *pSubType      = NULL;
+	CHAR curMccmnc[20]  = {0};
+	CHAR curNetType[5]  = {0};
+	CHAR curSubType[5]	= {0};
+
+	pMccmnc     = websGetVar(wp, T("NetworkNumber"), T(""));
+	pNetType    = websGetVar(wp, T("Rat"), T(""));
+	pSubType	= websGetVar(wp, T("nSubrat"), T(""));
+
+	if (('\0' == (*pMccmnc)) || ('\0' == (*pNetType))) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User set network %s!\n"), pMccmnc);
+	slog(MISC_PRINT, SLOG_DEBUG,"LPC: zte_wan_set_network, pSubType = %s \n", pSubType);
+	(void)zte_web_read("current_rat", curNetType); //0:2G; 2:3G
+	(void)zte_web_read("str_num_rplmn", curMccmnc);
+	(void)zte_web_read("current_subrat", curSubType);
+
+	if ((0 == strcmp(pMccmnc, curMccmnc)) && (0 == strcmp(pNetType, curNetType)) && (0 == strcmp(pSubType, curSubType))) {
+		slog(MISC_PRINT, SLOG_DEBUG, "zte_wan_set_network: to set network is equal to registered network."); /*lint !e26*/
+		(void)zte_web_write("manual_netsel_flag", "1");
+	} else {
+		(void)zte_web_write("manual_netsel_flag", "");
+	}
+	(void)zte_web_write(NV_M_NETSELECT_CONTENTS, "");
+	(void)zte_web_write("current_rat_tmp", pNetType);
+	(void)zte_web_write("str_num_rplmn_tmp", pMccmnc);
+	(void)zte_web_write("current_subrat_tmp", pSubType);
+	//slog(MISC_PRINT,SLOG_DEBUG, "zte_wan_set_network send message:ZUFI_MODULE_ID_AT_MAIN MSG_CMD_SET_NETWORK.");
+	ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_NETWORK_SET_REQ, 0, NULL, 0);
+	zte_write_result_to_web(wp, SUCCESS);
+}
+
+
+/*ÉèÖò¦ºÅģʽ*/
+void zte_wan_set_connection_mode(webs_t wp)
+{
+	CHAR *pConnMode = NULL;
+	CHAR *pRoamOption = NULL; //dial roam
+	char_t ppp_status[CONFIG_DEFAULT_LENGTH] = {0};
+	char traffic_limit[NV_ITEM_STRING_LEN_10] = {0};
+	char flux_month_total[NV_ITEM_STRING_LEN_50] = {0};
+	char traffic_alined_delta[NV_ITEM_STRING_LEN_50] = {0};
+	char traffic_month_total[NV_ITEM_STRING_LEN_50] = {0};
+	char pdp_dial_mode[NV_ITEM_STRING_LEN_10] = {0};
+
+	long long int llflux_month_total = 0;
+	long long int lltraffic_alined_delta = 0;
+	long long int lltraffic_month_total = 0;	
+
+	cfg_get_item("ppp_status", &ppp_status, sizeof(ppp_status));
+
+
+	pConnMode    = websGetVar(wp, "ConnectionMode", T(""));
+	pRoamOption  = websGetVar(wp, T(NV_ROAM_SETTING_OPTION), NULL);
+
+	if ('\0' == (*pConnMode)) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User set connection mode %s!\n"), pConnMode);
+	(void)zte_web_write(NV_DIAL_MODE, pConnMode);
+
+	if (IFSTREQUAL(ppp_status, "ppp_disconnected")
+	    && IFSTREQUAL(pConnMode, "manual_dial")) {
+		cfg_set("auto_reconnect", "0");
+	}
+
+	cfg_get_item("is_traffic_limit_on", &traffic_limit, sizeof(traffic_limit));
+	cfg_get_item("flux_month_total", &flux_month_total, sizeof(flux_month_total));
+	cfg_get_item("traffic_alined_delta", &traffic_alined_delta, sizeof(traffic_alined_delta));
+	cfg_get_item("traffic_month_total", &traffic_month_total, sizeof(traffic_month_total));
+
+	llflux_month_total = atoll(&flux_month_total);
+	lltraffic_alined_delta = atoll(&traffic_alined_delta);
+	lltraffic_month_total = atoll(&traffic_month_total);
+
+	if(llflux_month_total < 0 || llflux_month_total > LLONG_MAX-1 ){
+        llflux_month_total = LLONG_MAX;
+	}
+
+	if(lltraffic_alined_delta < 0 || lltraffic_alined_delta > LLONG_MAX-1){
+        lltraffic_alined_delta = LLONG_MAX;
+	}
+
+	if(lltraffic_month_total < 0 || lltraffic_month_total > LLONG_MAX-1){
+        lltraffic_month_total = LLONG_MAX;
+	}	
+
+	if (0 == strcmp(&traffic_limit, "yes")
+	    && llflux_month_total + lltraffic_alined_delta >= lltraffic_month_total * 1024 * 1024) {
+		cfg_get_item(NV_DIAL_MODE, &pdp_dial_mode, sizeof(pdp_dial_mode));
+
+		if (0 == strcmp(&pdp_dial_mode, "manual_dial")) {
+			cfg_set("auto_connect_when_limited", "no");
+		} else if (0 == strcmp(&pdp_dial_mode, "auto_dial")) {
+			cfg_set("auto_connect_when_limited", "yes");
+		}
+	}
+	//set dial roam switch
+	if (-1 == zte_wan_util_set_dial_roam_switch(pRoamOption)) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	cfg_save();
+	zte_write_result_to_web(wp, SUCCESS);
+	slog(MISC_PRINT, SLOG_DEBUG, "ZUFI_MODULE_ID_AT_MAIN!!!!set ppp_dial Mode:%s.\n", pConnMode);
+
+}
+
+/*ÉèÖÃ×Ô¶¯Ñ¡ÍøµÄÍøÂçÖÆÊ½*/
+void zte_wan_network_select(webs_t wp)
+{
+	char_t *netSelect = NULL;
+	char_t *pre_mode = NULL;
+	char_t ppp_status[CONFIG_DEFAULT_LENGTH] = {0};
+	int tryCount = 0;
+	netSelectCfgNv netSelectPreCfg = {0};
+	char select_result[NV_ITEM_STRING_LEN_20] = {0};
+	char buf[NV_ITEM_STRING_LEN_10] = {0};
+
+	netSelect = websGetVar(wp, T("BearerPreference"), T(""));
+	pre_mode = websGetVar(wp, T("pre_mode"), T(""));
+
+	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User set network select %s!\n"), netSelect);
+	if ('\0' == (*netSelect)) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	cfg_get_item("ppp_status", &ppp_status, sizeof(ppp_status));
+	if (ppp_status[0] != '\0') {
+		if (!IFSTREQUAL(ppp_status, "ppp_disconnected") && !IFSTREQUAL(ppp_status, "ppp_ready")) {
+			zte_write_result_to_web(wp, FAILURE);
+			return;
+		}
+	}
+
+	(void)zte_web_read("pre_mode", netSelectPreCfg.pre_mode);
+	(void)zte_web_read("net_select_mode", netSelectPreCfg.net_select_mode);
+	(void)zte_web_read(N_NET_SELECT, netSelectPreCfg.net_select);
+	(void)zte_web_read("m_netselect_save", netSelectPreCfg.m_netselect_save);
+	(void)zte_web_read(NV_M_NETSELECT_CONTENTS, netSelectPreCfg.m_netselect_contents);
+	(void)zte_web_read("m_netselect_status", netSelectPreCfg.m_netselect_status);
+
+	(void)zte_web_write("pre_mode", pre_mode);
+	(void)zte_web_write("net_select_mode", "auto_select");
+	(void)zte_web_write(N_NET_SELECT, netSelect);
+	(void)zte_web_write("m_netselect_save", "");
+	(void)zte_web_write(NV_M_NETSELECT_CONTENTS, "");
+	(void)zte_web_write("m_netselect_status", "");
+	cfg_set("net_select_result", "");
+	ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_NET_SELECT_REQ, 0, NULL, 0);
+
+	while (tryCount++ < 200) {
+		memset(select_result, 0, sizeof(select_result));
+		cfg_get_item("net_select_result", select_result, sizeof(select_result));
+		if (strcmp("", select_result) != 0) {
+			break;
+		}
+
+		// 200*1000us
+		usleep(200000);
+	}
+
+	slog(MISC_PRINT, SLOG_DEBUG,"zte_wan_network_select: net_select_result = %s \n", select_result);
+	if (strcmp("sucess", select_result) == 0) {
+		zte_write_result_to_web(wp, SUCCESS);
+	} else {
+		(void)zte_web_write("pre_mode", netSelectPreCfg.pre_mode);
+		(void)zte_web_write("net_select_mode", netSelectPreCfg.net_select_mode);
+		(void)zte_web_write(N_NET_SELECT, netSelectPreCfg.net_select);
+		(void)zte_web_write("m_netselect_save", netSelectPreCfg.m_netselect_save);
+		(void)zte_web_write(NV_M_NETSELECT_CONTENTS, netSelectPreCfg.m_netselect_contents);
+		(void)zte_web_write("m_netselect_status", netSelectPreCfg.m_netselect_status);
+		zte_write_result_to_web(wp, FAILURE);
+	}
+
+}
+
+/*ÊÖ¶¯ËÑÍø*/
+void zte_wan_scan_network(webs_t wp)
+{
+	if (NULL == wp) {
+		return;
+	}
+
+	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User scan network!\n"));
+
+	(void)zte_web_write("net_select_mode", "manual_select");
+	slog(MISC_PRINT, SLOG_NORMAL, "zte_wan_scan_network send message ZUFI_MODULE_ID_AT_MAIN,MSG_CMD_WEB_REQ_NET_SELECT");
+	(void)zte_web_write("m_netselect_status", "manual_selecting");
+	ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_NET_SELECT_REQ, 0, NULL, 0);
+	zte_write_result_to_web(wp, SUCCESS);
+
+}
+
+/*Á÷Á¿¹ÜÀíÉèÖÃ*/
+void zte_wan_data_limit_setting(webs_t wp)
+{
+	char *data_limit_switch = NULL;
+	char *data_limit_type = NULL;
+	char *data_limit_size = NULL;
+	char *data_limit_percent = NULL;
+
+	if (NULL == wp) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	data_limit_switch = websGetVar(wp, T("data_volume_limit_switch"), T(""));    /*0:disable;1:enable*/
+	if (0 == strcmp(data_limit_switch, "0")) {
+		slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User disable net data statistics!\n"));
+		cfg_set(NV_DATA_VOLUME_LIMIT_SWITCH, "0");
+		ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_MMI, MSG_CMD_TRAFFIC_INFO_RESET, 0, NULL, 0);
+		zte_write_result_to_web(wp, SUCCESS);
+	} else if (0 == strcmp(data_limit_switch, "1")) {
+		slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User enable net data statistics!\n"));
+		data_limit_type = websGetVar(wp, T("data_volume_limit_unit"), T(""));    /*time/data*/
+		data_limit_size = websGetVar(wp, T("data_volume_limit_size"), T(""));
+		data_limit_percent = websGetVar(wp, T("data_volume_alert_percent"), T(""));    /*1-100*/
+
+		//param validation check
+		if ((0 != strcmp(data_limit_type, DATA_VOLUME_LIMIT_UNIT_TIME))
+		    && (0 != strcmp(data_limit_type, DATA_VOLUME_LIMIT_UNIT_DATA))) {
+
+			slog(MISC_PRINT, SLOG_ERR, "invalid value for data_limit_type:[%s]\n", data_limit_type); /*lint !e26*/
+			zte_write_result_to_web(wp, FAILURE);
+			return;
+		}
+
+		if ((0 == strcmp(data_limit_size, "")) || (0 == strcmp(data_limit_percent, ""))) {
+			slog(MISC_PRINT, SLOG_ERR, "invalid value :[%s,%s]\n", data_limit_size, data_limit_percent); /*lint !e26*/
+			zte_write_result_to_web(wp, FAILURE);
+			return;
+		}
+
+		cfg_set(NV_DATA_VOLUME_LIMIT_SWITCH, "1");
+		cfg_set(NV_DATA_VOLUME_LIMIT_UNIT, data_limit_type);
+		cfg_set(NV_DATA_VOLUME_LIMIT_SIZE, data_limit_size);
+		cfg_set(NV_DATA_VOLUME_ALERT_PERCENT, data_limit_percent);
+		ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_MMI, MSG_CMD_TRAFFIC_INFO_RESET, 0, NULL, 0);
+		zte_write_result_to_web(wp, SUCCESS);
+	} else {
+		slog(MISC_PRINT, SLOG_ERR, "invalid value for data_limit_switch:[%s]\n", data_limit_switch); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+	}
+}
+
+
+/**********************************************************************
+* Function:         apn_save_process_ex
+* Description:      save the APN
+* Input:            NULL
+* Output:           NULL
+* Return:           0 is invalid, 1 is valid
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 2010/11/17   V1.0         maquan          first version
+**********************************************************************/
+void apn_save_process_ex(webs_t wp)
+{
+	int index_apn = 0;
+	char currentApnIndex[8] = {0};
+	APN_PROFILE newApn;
+	IPV6_APN_PROFILE newIPV6Apn;
+	memset(&newApn, 0, sizeof(APN_PROFILE));
+	memset(&newIPV6Apn, 0, sizeof(IPV6_APN_PROFILE));
+
+	slog(MISC_PRINT, SLOG_NORMAL, "come get_apn_para_form_web \n"); /*lint !e26*/
+	get_apn_para_form_web(wp, &newApn);
+	get_ipv6_apn_para_form_web(wp, &newIPV6Apn);
+
+	index_apn = atoi(websGetVar(wp, "index", T("")));
+	slog(MISC_PRINT, SLOG_DEBUG, "index_apn=%d \n", index_apn); /*lint !e26*/
+	snprintf(currentApnIndex, sizeof(currentApnIndex) , "%d", index_apn);
+	slog(MISC_PRINT, SLOG_DEBUG, "come set_apn_profile_by_index \n"); /*lint !e26*/
+
+	set_apn_profile_by_index(index_apn, &newApn);
+	set_apn_prof_aes_by_index(index_apn, &newApn);
+	set_ipv6_apn_profile_by_index(index_apn, &newIPV6Apn);
+	set_ipv6_apn_prof_aes_by_index(index_apn, &newIPV6Apn);
+
+}
+
+/**********************************************************************
+* Function:         apn_delete_process_ex
+* Description:      delete apn
+* Input:            NULL
+* Output:           NULL
+* Return:           NULL
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 2010/11/17   V1.0         maquan          first version
+* 2011/01/15   V1.0         qiuzhenhui      modify
+**********************************************************************/
+void apn_delete_process_ex(webs_t wp)
+{
+	char apn_default_index[APNCONFIG_ELEMENT_MEMORY] = {0};
+	char apn_buf[APNCONFIG_ELEMENT_MEMORY] = {0};
+	int i;
+
+	int apn_index = atoi(websGetVar(wp, "index", T("")));
+	if(apn_index<0 || apn_index> INT_MAX-1)
+	{
+	    apn_index = 0;
+	}
+	
+	cfg_get_item("apn_index", &apn_buf, sizeof(apn_buf));
+	int apn_index_setdefault = atoi(&apn_buf);
+	if(apn_index_setdefault<0 || apn_index_setdefault> INT_MAX-1)
+	{
+	    apn_index_setdefault = 0;
+	}
+
+	for (i = apn_index; i < APNCONFIG_NUM_MAX; i++) {
+		char profile1[APNCONFIG_MEMORY] = {0};
+		char profile2[APNCONFIG_MEMORY] = {0};
+		char ipv6profile1[APNCONFIG_MEMORY] = {0};
+		char ipv6profile2[APNCONFIG_MEMORY] = {0};
+		char next_profile[APNCONFIG_MEMORY] = {0};
+		char ipv6_next_profile[APNCONFIG_MEMORY] = {0};
+
+		sprintf(profile1, "APN_config%d", i);
+		sprintf(profile2, "APN_config%d", i + 1);
+
+		sprintf(ipv6profile1, "ipv6_APN_config%d", i);
+		sprintf(ipv6profile2, "ipv6_APN_config%d", i + 1);
+
+		cfg_get_item(profile2, &next_profile, sizeof(next_profile));
+		cfg_get_item(ipv6profile2, &ipv6_next_profile, sizeof(ipv6_next_profile));
+
+
+#ifdef FEATRUE_WEB_DEBUG
+		slog(MISC_PRINT, SLOG_DEBUG, "profile1=%s\n", profile1); /*lint !e26*/
+		slog(MISC_PRINT, SLOG_DEBUG, "profile2=%s\n", profile2); /*lint !e26*/
+		slog(MISC_PRINT, SLOG_DEBUG, "next_profile=%s\n", next_profile); /*lint !e26*/
+#endif
+		if (strcmp(next_profile, "")) {
+			cfg_set(profile1, next_profile);
+		} else {
+			cfg_set(profile1, "");
+		}
+
+
+		if (strcmp(ipv6_next_profile, "")) {
+			cfg_set(ipv6profile1, ipv6_next_profile);
+		} else {
+			cfg_set(ipv6profile1, "");
+		}
+
+
+	} //endof delete
+	for (i = apn_index; i < APNCONFIG_NUM_MAX; i++) {
+		char profile1[APNCONFIG_MEMORY] = {0};
+		char profile2[APNCONFIG_MEMORY] = {0};
+		char ipv6profile1[APNCONFIG_MEMORY] = {0};
+		char ipv6profile2[APNCONFIG_MEMORY] = {0};
+		char next_profile[APNCONFIG_MEMORY] = {0};
+		char ipv6_next_profile[APNCONFIG_MEMORY] = {0};
+
+		sprintf(profile1, "APN_configtmp%d", i);
+		sprintf(profile2, "APN_configtmp%d", i + 1);
+
+		sprintf(ipv6profile1, "ipv6_APN_configtmp%d", i);
+		sprintf(ipv6profile2, "ipv6_APN_configtmp%d", i + 1);
+
+		cfg_get_item(profile2, &next_profile, sizeof(next_profile));
+		cfg_get_item(ipv6profile2, &ipv6_next_profile, sizeof(ipv6_next_profile));
+
+
+#ifdef FEATRUE_WEB_DEBUG
+		slog(MISC_PRINT, SLOG_DEBUG, "profile1tmp=%s\n", profile1); /*lint !e26*/
+		slog(MISC_PRINT, SLOG_DEBUG, "profile2tmp=%s\n", profile2); /*lint !e26*/
+		slog(MISC_PRINT, SLOG_DEBUG, "next_profiletmp=%s\n", next_profile); /*lint !e26*/
+#endif
+		if (strcmp(next_profile, "")) {
+			cfg_set(profile1, next_profile);
+		} else {
+			cfg_set(profile1, "");
+		}
+
+
+		if (strcmp(ipv6_next_profile, "")) {
+			cfg_set(ipv6profile1, ipv6_next_profile);
+		} else {
+			cfg_set(ipv6profile1, "");
+		}
+
+
+	} //endof delete
+	if (0 < apn_index_setdefault - apn_index) {
+		apn_index_setdefault -= 1;
+		sprintf(apn_default_index, "%d", apn_index_setdefault);
+		cfg_set("apn_index", apn_default_index);
+	} else if (apn_index_setdefault == apn_index) {
+		apn_index_setdefault = 0;
+		sprintf(apn_default_index, "%d", apn_index_setdefault);
+		cfg_set("apn_index", apn_default_index);
+	}
+#ifdef FEATRUE_WEB_DEBUG
+    memset(apn_buf, 0, sizeof(apn_buf));
+    cfg_get_item("apn_index", apn_buf, sizeof(apn_buf));
+    slog(MISC_PRINT, SLOG_DEBUG, "Del action apn_index=%s\n", apn_buf); /*lint !e26*/
+
+#endif
+
+}
+
+/**********************************************************************
+* Function:         apn_delete_process
+* Description:      delete apn
+* Input:            NULL
+* Output:           NULL
+* Return:           NULL
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 2010/11/17   V1.0         maquan          first version
+* 2011/01/15   V1.0         qiuzhenhui      modify
+**********************************************************************/
+void apn_set_default_with_profile_index_ex(webs_t wp)
+{
+	int index_apn = 0;
+	char_t *pdp_type = NULL;
+
+	pdp_type = websGetVar(wp, T("pdp_type"), T(""));
+
+	APN_PROFILE  newProfile;
+	IPV6_APN_PROFILE  newIpv6Profile;
+	memset(&newProfile, 0, sizeof(APN_PROFILE));
+	memset(&newIpv6Profile, 0, sizeof(IPV6_APN_PROFILE));
+	char_t *apn_mode = NULL;
+
+	index_apn = atoi(websGetVar(wp, "index", T("")));
+	apn_mode = websGetVar(wp, T("apn_mode"), T(""));
+
+	cfg_set("auto_apn_index", websGetVar(wp, "auto_apn_index", T("0")));
+	if (0 == strcmp(apn_mode, "auto")) {
+		slog(MISC_PRINT, SLOG_DEBUG, "apn_mode=%s\n", apn_mode); /*lint !e26*/
+		get_autoapn_profile(&newProfile);
+		set_apn_to_cfg(&newProfile);
+	} else {
+		if (0 == strcmp(pdp_type, "IPv6")) {
+			slog(MISC_PRINT, SLOG_DEBUG, "come to get_ipv6apn_profile_by_index"); /*lint !e26*/
+
+			get_ipv6apn_profile_by_index(index_apn, &newIpv6Profile);
+			set_ipv6_apn_to_cfg(&newIpv6Profile);
+
+		} else if (0 == strcmp(pdp_type, "IPv4v6")) {
+
+			slog(MISC_PRINT, SLOG_DEBUG, "come to get_ipv4v6apn_profile_by_index"); /*lint !e26*/
+			get_ipv4v6apn_profile_by_index(index_apn, &newProfile, &newIpv6Profile);
+			set_ipv4v6_apn_to_cfg(&newProfile, &newIpv6Profile);
+		} else {
+			slog(MISC_PRINT, SLOG_DEBUG, "come to get_ipv4apn_profile_by_index"); /*lint !e26*/
+			get_apn_profile_by_index(index_apn, &newProfile);
+			set_apn_to_cfg(&newProfile);
+		}
+		cfg_set("apn_index", websGetVar(wp, "index", T("")));
+	}
+
+
+	//send message to MainControl to infrom modify apn
+	//zte_send_message(ZUFI_MODULE_ID_AT_MAIN,MSG_CMD_WEB_REQ_APN_SET,0,0);
+	ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_APN_SET_REQ, 0, NULL, 0);
+}
+
+/**********************************************************************
+* Function:         get_apn_para_form_web
+* Description:      get apn parametre from web
+* Input:            wp
+* Output:           apn para struct pointer
+* Return:           NULL
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 2010/11/17   V1.0         maquan          first version
+**********************************************************************/
+static void get_apn_para_form_web(webs_t wp, APN_PROFILE *apn_profile)
+{
+	if (NULL == wp) {
+		slog(MISC_PRINT, SLOG_ERR, "NULL para input"); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	if (zte_apn_param_check(wp, "ipv4") < 0) {
+		slog(MISC_PRINT, SLOG_ERR, "ipv4 para input is no safe"); /*lint !e26*/
+		return;
+	}
+
+	strncpy(apn_profile->profile_name, websGetVar(wp, T("profile_name"), T("")), sizeof(apn_profile->profile_name)-1);
+	strncpy(apn_profile->apn_name, websGetVar(wp, T("wan_apn"), T("")), sizeof(apn_profile->apn_name)-1);
+	strncpy(apn_profile->apn_select, websGetVar(wp, T("apn_select"), T("")), sizeof(apn_profile->apn_select)-1);
+	strncpy(apn_profile->dial_num, websGetVar(wp, T("wan_dial"), T("")), sizeof(apn_profile->dial_num)-1);
+	strncpy(apn_profile->ppp_auth_mode, websGetVar(wp, T("ppp_auth_mode"), T("")), sizeof(apn_profile->ppp_auth_mode)-1);
+	strncpy(apn_profile->ppp_username, websGetVar(wp, T("ppp_username"), T("")), sizeof(apn_profile->ppp_username)-1);
+	strncpy(apn_profile->ppp_passwd, websGetVar(wp, T("ppp_passtmp"), T("")), sizeof(apn_profile->ppp_passwd)-1);
+    strncpy(apn_profile->pdp_type, websGetVar(wp, T("pdp_type"), T("")), sizeof(apn_profile->pdp_type)-1);
+	strncpy(apn_profile->pdp_select, websGetVar(wp, T("pdp_select"), T("")), sizeof(apn_profile->pdp_select)-1);
+	strncpy(apn_profile->pdp_addr, websGetVar(wp, T("pdp_addr"), T("")), sizeof(apn_profile->pdp_addr)-1);
+	strncpy(apn_profile->dns_mode, websGetVar(wp, T("dns_mode"), T("")), sizeof(apn_profile->dns_mode)-1);
+	strncpy(apn_profile->prefer_dns_manual, websGetVar(wp, T("prefer_dns_manual"), T("")), sizeof(apn_profile->prefer_dns_manual)-1);
+	strncpy(apn_profile->standby_dns_manual, websGetVar(wp, T("standby_dns_manual"), T("")), sizeof(apn_profile->standby_dns_manual)-1);
+
+	return;
+}
+
+
+static void get_ipv6_apn_para_form_web(webs_t wp, IPV6_APN_PROFILE *apn_profile)
+{
+	if (NULL == wp) {
+		slog(MISC_PRINT, SLOG_ERR, "NULL para input"); /*lint !e26*/
+		return;
+	}
+
+	if (zte_apn_param_check(wp, "ipv6") < 0) {
+		slog(MISC_PRINT, SLOG_ERR, "ipv6 para input is no safe"); /*lint !e26*/
+		return;
+	}
+
+	strncpy(apn_profile->profile_name, websGetVar(wp, T("profile_name"), T("")), sizeof(apn_profile->profile_name)-1);
+	strncpy(apn_profile->apn_name, websGetVar(wp, T("ipv6_wan_apn"), T("")), sizeof(apn_profile->apn_name)-1);
+	strncpy(apn_profile->apn_select, websGetVar(wp, T("apn_select"), T("")), sizeof(apn_profile->apn_select)-1);
+	strncpy(apn_profile->dial_num, websGetVar(wp, T("wan_dial"), T("")), sizeof(apn_profile->dial_num)-1);
+	strncpy(apn_profile->ppp_auth_mode, websGetVar(wp, T(NV_IPV6_PPP_AUTH_MODE), T("")), sizeof(apn_profile->ppp_auth_mode)-1);
+	strncpy(apn_profile->ppp_username, websGetVar(wp, T("ipv6_ppp_username"), T("")), sizeof(apn_profile->ppp_username)-1);
+	strncpy(apn_profile->ppp_passwd, websGetVar(wp, T("ipv6_ppp_passtmp"), T("")), sizeof(apn_profile->ppp_passwd)-1);
+	strncpy(apn_profile->pdp_type, websGetVar(wp, T("pdp_type"), T("")), sizeof(apn_profile->pdp_type)-1);
+	strncpy(apn_profile->pdp_select, websGetVar(wp, T("pdp_select"), T("")), sizeof(apn_profile->pdp_select)-1);
+	strncpy(apn_profile->pdp_addr, websGetVar(wp, T("pdp_addr"), T("")), sizeof(apn_profile->pdp_addr)-1);
+	strncpy(apn_profile->dns_mode, websGetVar(wp, T("ipv6_dns_mode"), T("")), sizeof(apn_profile->dns_mode)-1);
+	strncpy(apn_profile->prefer_dns_manual, websGetVar(wp, T("ipv6_prefer_dns_manual"), T("")), sizeof(apn_profile->prefer_dns_manual)-1);
+	strncpy(apn_profile->standby_dns_manual, websGetVar(wp, T("ipv6_standby_dns_manual"), T("")), sizeof(apn_profile->standby_dns_manual)-1);
+
+	return;
+}
+
+int zte_apn_param_check(webs_t  wp, char * type)
+{
+	char *profile_name = NULL;
+	char *wan_apn = NULL;
+	char *ppp_username = NULL;
+	char *ppp_passwd = NULL;
+
+	if (0 == strcmp("ipv4", type)) {
+		profile_name = websGetVar(wp, T("profile_name"), T(""));
+		wan_apn = websGetVar(wp, T("wan_apn"), T(""));
+		ppp_username = websGetVar(wp, T("ppp_username"), T(""));
+		ppp_passwd = websGetVar(wp, T("ppp_passtmp"), T(""));
+		if (DATA_NO_SAFE == zte_Safe_noSpecialChar(profile_name)
+		    || DATA_NO_SAFE == zte_Safe_noSpecialChar(wan_apn)
+		    || DATA_NO_SAFE == zte_Safe_noSpecialChar(ppp_username)
+		    || DATA_NO_SAFE == zte_Safe_noSpecialChar(ppp_passwd)
+		   ) {
+			slog(MISC_PRINT, SLOG_ERR, "Get Data is no Safe:ivp4\n"); /*lint !e26*/
+			return -1;
+		} else {
+			slog(MISC_PRINT, SLOG_DEBUG, "Get Data is Safe:ivp6\n"); /*lint !e26*/
+			return 1;
+		}
+	} else if (0 == strcmp("ipv6", type)) {
+		profile_name = websGetVar(wp, T("profile_name"), T(""));
+		wan_apn = websGetVar(wp, T("ipv6_wan_apn"), T(""));
+		ppp_username = websGetVar(wp, T("ipv6_ppp_username"), T(""));
+		ppp_passwd = websGetVar(wp, T("ipv6_ppp_passtmp"), T(""));
+		if (DATA_NO_SAFE == zte_Safe_noSpecialChar(profile_name)
+		    || DATA_NO_SAFE == zte_Safe_noSpecialChar(wan_apn)
+		    || DATA_NO_SAFE == zte_Safe_noSpecialChar(ppp_username)
+		    || DATA_NO_SAFE == zte_Safe_noSpecialChar(ppp_passwd)
+		   ) {
+			slog(MISC_PRINT, SLOG_ERR, "Get Data is no Safe:ipv6\n"); /*lint !e26*/
+			return -1;
+		} else {
+			slog(MISC_PRINT, SLOG_DEBUG, "Get Data is Safe:ipv6\n"); /*lint !e26*/
+			return 1;
+		}
+	}
+	slog(MISC_PRINT, SLOG_DEBUG, "Get Data is Safe:no ipv4 or ivp6\n"); /*lint !e26*/
+	return 0;
+}
+
+
+
+/**********************************************************************
+* Function:         set_apn_to_cfg
+* Description:      set apn para to CFG
+* Input:            apn parametre struct pointer
+* Output:           NULL
+* Return:           NULL
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 2010/11/17   V1.0         maquan          first version
+**********************************************************************/
+static void set_apn_to_cfg(APN_PROFILE *apn_profile)
+{
+
+	if (NULL == apn_profile) {
+		slog(MISC_PRINT, SLOG_ERR, " NULL para input!!"); /*lint !e26*/
+		return;
+	}
+	slog(MISC_PRINT, SLOG_DEBUG, "wan_apn==%s", apn_profile->apn_name); /*lint !e26*/
+	cfg_set("m_profile_name", apn_profile->profile_name);
+	cfg_set("wan_apn", apn_profile->apn_name);
+	cfg_set("apn_select", apn_profile->apn_select);
+	cfg_set("wan_dial", apn_profile->dial_num);
+	cfg_set("ppp_auth_mode", apn_profile->ppp_auth_mode);
+	cfg_set("ppp_username", apn_profile->ppp_username);
+	cfg_set("ppp_passtmp", apn_profile->ppp_passwd);
+	cfg_set("pdp_type", apn_profile->pdp_type);
+	cfg_set("ipv6_pdp_type", apn_profile->pdp_type);
+	cfg_set("pdp_select", apn_profile->pdp_select);
+	cfg_set("pdp_addr", apn_profile->pdp_addr);
+	apn_encrypt_code();
+
+	return;
+}
+
+static void set_ipv6_apn_to_cfg(IPV6_APN_PROFILE *apn_profile)
+{
+	slog(MISC_PRINT, SLOG_DEBUG, "set_ipv6_apn_to_cfg"); /*lint !e26*/
+	if (NULL == apn_profile) {
+		slog(MISC_PRINT, SLOG_ERR, " NULL para input!!"); /*lint !e26*/
+		return;
+	}
+	slog(MISC_PRINT, SLOG_DEBUG, "wan_apn==%s", apn_profile->apn_name); /*lint !e26*/
+	cfg_set("m_profile_name", apn_profile->profile_name);
+	cfg_set("ipv6_wan_apn", apn_profile->apn_name);
+	cfg_set("apn_select", apn_profile->apn_select);
+	cfg_set("wan_dial", apn_profile->dial_num);
+	cfg_set(NV_IPV6_PPP_AUTH_MODE, apn_profile->ppp_auth_mode);
+	cfg_set("ipv6_ppp_username", apn_profile->ppp_username);
+	cfg_set("ipv6_ppp_passtmp", apn_profile->ppp_passwd);
+	cfg_set("pdp_type", apn_profile->pdp_type);
+	cfg_set("ipv6_pdp_type", apn_profile->pdp_type);
+	cfg_set("pdp_select", apn_profile->pdp_select);
+	cfg_set("pdp_addr", apn_profile->pdp_addr);
+	ipv6apn_encrypt_code();
+
+	return;
+}
+
+
+static void set_ipv4v6_apn_to_cfg(APN_PROFILE *apn_profile, IPV6_APN_PROFILE *ipv6_apn_profile)
+{
+
+	if (NULL == apn_profile) {
+		slog(MISC_PRINT, SLOG_ERR, " NULL para input!!"); /*lint !e26*/
+		return;
+	}
+	cfg_set("m_profile_name", apn_profile->profile_name);
+	cfg_set("wan_apn", apn_profile->apn_name);
+	cfg_set("apn_select", apn_profile->apn_select);
+	cfg_set("wan_dial", apn_profile->dial_num);
+	cfg_set("ppp_auth_mode", apn_profile->ppp_auth_mode);
+	cfg_set("ppp_username", apn_profile->ppp_username);
+	cfg_set("ppp_passtmp", apn_profile->ppp_passwd);
+	cfg_set("pdp_type", apn_profile->pdp_type);
+	cfg_set("ipv6_pdp_type", apn_profile->pdp_type);
+	cfg_set("pdp_select", apn_profile->pdp_select);
+	cfg_set("pdp_addr", apn_profile->pdp_addr);
+	apn_encrypt_code();
+
+	if (NULL == ipv6_apn_profile) {
+		slog(MISC_PRINT, SLOG_ERR, " NULL para input!!"); /*lint !e26*/
+		return;
+	}
+	cfg_set("m_profile_name", ipv6_apn_profile->profile_name);
+	cfg_set("ipv6_wan_apn", ipv6_apn_profile->apn_name);
+	cfg_set("apn_select", ipv6_apn_profile->apn_select);
+	cfg_set("wan_dial", ipv6_apn_profile->dial_num);
+	cfg_set(NV_IPV6_PPP_AUTH_MODE, ipv6_apn_profile->ppp_auth_mode);
+	cfg_set("ipv6_ppp_username", ipv6_apn_profile->ppp_username);
+	cfg_set("ipv6_ppp_passtmp", ipv6_apn_profile->ppp_passwd);
+	cfg_set("pdp_type", apn_profile->pdp_type);
+	cfg_set("ipv6_pdp_type", ipv6_apn_profile->pdp_type);
+	cfg_set("pdp_select", ipv6_apn_profile->pdp_select);
+	cfg_set("pdp_addr", ipv6_apn_profile->pdp_addr);
+	ipv6apn_encrypt_code();
+	return;
+}
+
+/**********************************************************************
+* Function:         zte_wan_data_statistics_clear_process
+* Description:      to clear the statistics
+* Input:            the web para
+* Output:
+* Return:
+* Others:         add form uFi
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+
+**********************************************************************/
+void zte_wan_data_statistics_clear_process(webs_t wp, char_t *path, char_t *query)
+{
+	long nowtime;
+	if (NULL == wp) {
+		return;
+	}
+
+	slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User clear net data statistics!\n"));
+	/*start added by jhy Nov 28, 2013*/
+	(void)zte_web_write("realtime_tx_thrpt", "0");
+	(void)zte_web_write("realtime_rx_thrpt", "0");
+
+	(void)zte_web_write("realtime_tx_bytes", "0");
+	(void)zte_web_write("realtime_rx_bytes", "0");
+	(void)zte_web_write("CTotal_vol", "0");
+	(void)zte_web_write("realtime_time", "0");
+
+
+	time(&nowtime);
+	char lastConectedTimeStr[16] = {0};
+	sprintf(lastConectedTimeStr, "%d", nowtime);
+	cfg_set("ppp_start_time", lastConectedTimeStr);
+	cfg_set("syn_ppp_total", "0");
+
+	(void)zte_web_write("monthly_tx_bytes", "0");
+	(void)zte_web_write("monthly_rx_bytes", "0");
+	(void)zte_web_write("flux_month_total", "0");
+	(void)zte_web_write("monthly_time", "0");
+	(void)zte_web_write("MonthlyConTime_Last", "0");
+	(void)zte_web_write("traffic_alined_delta", "0");
+	(void)zte_web_write("duraConTime_before_time_modify", "0");
+
+	ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_MMI, MSG_CMD_TRAFFIC_INFO_RESET, 0, NULL, 0);
+	slog(MISC_PRINT, SLOG_NORMAL, "zte_wan_data_statistics_clear_process: send ZTE_CURR_TOTAL_WIFI_DATA to mc success."); /*lint !e26*/
+	zte_write_result_to_web(wp, SUCCESS);
+}
+
+
+/**********************************************************************
+ * Function:         zte_form_multi_apn_proc_ex
+ * Description:      to handle the auto or manual apn set for ipv4ipv6
+ * Input:            the web para
+ * Output:
+ * Return:
+ * Others:
+ * Modify Date   Version     Author          Modification
+ * -----------------------------------------------
+ *
+ **********************************************************************/
+
+void zte_form_multi_apn_proc_ex(webs_t wp)
+{
+	char_t *apn_mode  = NULL;
+	char_t *apn_action = NULL;
+	//int result = 0;
+
+	// Get the params from pages
+	apn_mode = websGetVar(wp, T("apn_mode"), T(""));  /* auto | manual  */
+	apn_action = websGetVar(wp, T("apn_action"), T(""));  // save | delete | set_default
+
+	slog(MISC_PRINT, SLOG_DEBUG, "apn_mode:[%s], apn_action[%s] \n", apn_mode, apn_action); /*lint !e26*/
+
+	//not to check apn_action,auto apn will not need it
+	if ('\0' == *apn_mode) {
+		slog(MISC_PRINT, SLOG_ERR, "apn_mode is empty. \n"); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+	/* AUTO APN */
+	if (0 == strcmp(ZTE_WEB_ACT_AUTO, apn_mode)) {
+		cfg_set("auto_apn_index", websGetVar(wp, "auto_apn_index", T("0")));
+		if (0 == zte_wan_auto_apn_set()) {
+			zte_write_result_to_web(wp, SUCCESS);
+		} else {
+			zte_write_result_to_web(wp, FAILURE);
+		}
+		return;
+	} else if (0 == strcmp(ZTE_WEB_ACT_MANUAL, apn_mode)) {
+		if (0 == strcmp(apn_action, ZTE_WEB_ACT_SAVE)) {
+			slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User save apn! \n"));
+			apn_save_process_ex(wp);
+		} else if (0 == strcmp(apn_action, ZTE_WEB_ACT_SETDEFAULT)) {
+			slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User set default apn! \n"));
+			zte_web_write("apn_mode", ZTE_WEB_ACT_MANUAL);
+			apn_set_default_process_ex(wp);
+			//apn_set_default_with_profile_index_ex(wp);
+		} else if (0 == strcmp(apn_action, ZTE_WEB_ACT_DELETE)) {
+			slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User delete apn! \n"));
+			apn_delete_process_ex(wp);
+		} else {
+			slog(MISC_PRINT, SLOG_ERR, "invalid apn_action. \n"); /*lint !e26*/
+			zte_write_result_to_web(wp, FAILURE);
+			return;
+		}
+	} else {
+		slog(MISC_PRINT, SLOG_ERR, "invalid apn_mode. \n"); /*lint !e26*/
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+
+	zte_write_result_to_web(wp, SUCCESS);
+
+	return;
+
+}
+
+
+static int zte_wan_auto_apn_set()
+{
+	//int count = 0;
+	APN_PROFILE  newProfile;
+	zte_web_write("apn_mode", ZTE_WEB_ACT_AUTO);
+	memset(&newProfile, 0, sizeof(newProfile));
+	slog(MISC_PRINT, SLOG_NORMAL,"LPC: zte_wan_auto_apn_set enter! \n");
+	get_autoapn_profile(&newProfile);
+	set_apn_to_cfg(&newProfile);
+	//send message to MainControl to infrom modify apn
+#if 0	// kw 3
+	ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_APN_SET_REQ, 0, NULL, 0);
+	return 0;
+#else
+    return ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_APN_SET_REQ, 0, NULL, 0);
+#endif
+}
+
+
+
+void apn_set_default_process_ex(webs_t wp)
+{
+	char_t *webAction = NULL;
+	webAction = websGetVar(wp, T("set_default_flag"), T(""));
+	slog(MISC_PRINT, SLOG_NORMAL, "goahead apn_set_default_process apn_action=%s.\n", webAction);
+
+	if (0 == strcmp(webAction, APN_ONLY_SET_DEFAULT)) { //profile_name
+		apn_set_default_with_profile_index_ex(wp);
+	} else if (0 == strcmp(webAction, APN_SAVE_AND_SET_DEFAULT)) {
+		apn_set_default_with_new_profile_ex(wp);
+	} else {
+		slog(MISC_PRINT, SLOG_DEBUG, "invalid set_default_flag[%s].", webAction);
+		return ;
+	}
+
+}
+void apn_set_default_with_new_profile_ex(webs_t wp)
+{
+	int index_apn = 0;
+	APN_PROFILE newApn;
+	IPV6_APN_PROFILE  newIpv6Profile;
+
+	char_t *pdp_type = NULL;
+
+	pdp_type = websGetVar(wp, T("pdp_type"), T(""));
+
+
+
+	memset(&newApn, 0, sizeof(APN_PROFILE));
+	memset(&newIpv6Profile, 0, sizeof(IPV6_APN_PROFILE));
+
+	index_apn = atoi(websGetVar(wp, "index", T("")));
+
+	get_apn_para_form_web(wp, &newApn);
+	set_apn_profile_by_index(index_apn, &newApn);
+	set_apn_prof_aes_by_index(index_apn, &newApn);
+
+	get_ipv6_apn_para_form_web(wp, &newIpv6Profile);
+	set_ipv6_apn_profile_by_index(index_apn, &newIpv6Profile);
+	set_ipv6_apn_prof_aes_by_index(index_apn, &newIpv6Profile);
+
+	if (0 == strcmp(pdp_type, "IPv6")) {
+		set_ipv6_apn_to_cfg(&newIpv6Profile);
+	} else if (0 == strcmp(pdp_type, "IPv4v6")) {
+		set_ipv4v6_apn_to_cfg(&newApn, &newIpv6Profile);
+	} else {
+		set_apn_to_cfg(&newApn);
+	}
+
+
+	slog(MISC_PRINT, SLOG_NORMAL, "apn_set_default_with_new_profile_ex index_apn=%d", index_apn);
+
+	cfg_set("apn_index", websGetVar(wp, "index", T("")));
+	//send message to MainControl to infrom modify apn
+	ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_APN_SET_REQ, 0, NULL, 0);
+
+}
+
+/**********************************************************************
+* Function:         zte_wan_util_set_dial_roam_switch
+* Description:      to set the dial roam switch
+* Input:            roam_set: to set value
+* Output:
+* Return:           -1:fail;0:success
+* Others:
+* Modify Date   Version     Author          Modification
+* -----------------------------------------------
+* 2012/09/19    V1.0        chenyi       first version
+**********************************************************************/
+static int zte_wan_util_set_dial_roam_switch(const char_t *roam_set)
+{
+	if (NULL == roam_set) {
+		return 0;//user don't care it ,so return 0
+	}
+
+	if ('\0' == (*roam_set)) {
+		slog(MISC_PRINT, SLOG_ERR, "dial roam set is empty."); /*lint !e26*/
+		return -1;
+	}
+
+	if (ZTE_NVIO_DONE != zte_web_write(NV_ROAM_SETTING_OPTION, roam_set)) { /*lint !e605*/
+		slog(MISC_PRINT, SLOG_ERR, "write nv [%s] fail.", NV_ROAM_SETTING_OPTION); /*lint !e26*/
+		return -1;
+	} else {
+		ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_ROAM_SET_REQ, 0, NULL, 0);
+		return 0;
+	}
+}
+
+
+void zte_wan_data_flow_calibration_manual(webs_t wp)
+{
+	char *p_data = NULL;
+	float time = 0;
+	char buf[NV_ITEM_STRING_LEN_50] = {0};
+	unsigned long long data = 0;
+	if (NULL == wp) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	p_data = websGetVar(wp, T("calibration_way"), NULL);
+
+	slog(MISC_PRINT, SLOG_NORMAL,"zte_wan_data_flow_calibration_manual calibration_way = %s\n", p_data);
+	if (p_data == NULL) {
+		zte_write_result_to_web(wp, FAILURE);
+		return;
+	}
+
+	if (0 == strcmp(p_data, "time")) {
+		p_data = websGetVar(wp, T("time"), NULL);
+		if (p_data != NULL) {
+			time = atof(p_data);
+			sprintf(buf, "%ld", (long)(time * 60 * 60));
+			cfg_set("monthly_time", buf);
+			slog(MISC_PRINT, SLOG_DEBUG,"zte_wan_data_flow_calibration_manual time:value = %f, buf = %s\n", time, buf);
+			zte_write_result_to_web(wp, SUCCESS);
+			ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_MMI, MSG_CMD_TRAFFIC_INFO_RESET, 0, NULL, 0);
+			return;
+		}
+	} else if (0 == strcmp(p_data, "data")) {
+		p_data = websGetVar(wp, T("data"), NULL);
+		if (p_data != NULL) {
+			float data_tmp = 0;
+			data_tmp = atof(p_data);
+			//data = strtoll(p_data,NULL,10);
+			data = (unsigned long long)(data_tmp * 1024 * 1024);
+			errno = 0;
+			long long ret_strtoll = strtoll(p_data, NULL, 10);
+			if (errno == ERANGE)// kw ERRNO.NOT_CHECKED
+			{
+				slog(MISC_PRINT, SLOG_ERR,"strtoll errno %d: %s\n", errno, strerror(errno));
+			}
+			slog(MISC_PRINT, SLOG_DEBUG,"zte_wan_data_flow_calibration_manual data:111 data = %lld, %lld\n", data, ret_strtoll);
+			sprintf(buf, "%lld", data);
+			cfg_set("monthly_tx_bytes", "0");
+			cfg_set("monthly_rx_bytes", buf);
+			cfg_set("flux_month_total", buf);
+			zte_write_result_to_web(wp, SUCCESS);
+			//flux_call_cb(CB_MSG_MMI_TRAFFIC_INFO_RESET, NULL ,0);
+			ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_MMI, MSG_CMD_TRAFFIC_INFO_RESET, 0, NULL, 0);
+			return;
+		}
+	}
+
+	zte_write_result_to_web(wp, FAILURE);
+}
diff --git a/lynq/S300/ap/app/goahead/server/Makefile b/lynq/S300/ap/app/goahead/server/Makefile
new file mode 100755
index 0000000..2a29d2d
--- /dev/null
+++ b/lynq/S300/ap/app/goahead/server/Makefile
@@ -0,0 +1,248 @@
+# /*****************************************************************************
+#* °æÈ¨ËùÓÐ (C)2015, ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+#* 
+#* ÎļþÃû³Æ:     Makefile
+#* Îļþ±êʶ:     Makefile
+#* ÄÚÈÝÕªÒª:     Makefile of ZTE applications
+#* ʹÓ÷½·¨:     void
+#* 
+#* ÐÞ¸ÄÈÕÆÚ        °æ±¾ºÅ      Ð޸ıê¼Ç        ÐÞ¸ÄÈË          ÐÞ¸ÄÄÚÈÝ
+#* -----------------------------------------------------------------------------
+#* 2015/02/10      V1.0        Create          ÁõÑÇÄÏ          ´´½¨
+#* 
+# ******************************************************************************/
+
+#*******************************************************************************
+# include ZTE application makefile
+#*******************************************************************************
+include $(zte_app_mak)
+
+#*******************************************************************************
+# execute
+#*******************************************************************************
+EXEC    = goahead
+
+
+# User Management switch
+#UMSW	= -DUSER_MANAGEMENT_SUPPORT
+CPU_PUB_ROOT=$(TOPDIR_AP)/../pub
+INTERFACEDIR = ../interface5.0
+INTERFACELIB = $(INTERFACEDIR)/libwebinterface.a
+#*******************************************************************************
+# objects asp.o ejlex.o ejparse.o umui.o
+#*******************************************************************************
+OBJS    =		  balloc.o base64.o cgi.o default.o \
+				  form.o \
+				  h.o handler.o mime.o misc.o page.o  \
+				  ringq.o \
+				  sock.o sockGen.o \
+				  sym.o uemf.o value.o \
+				  webs.o websuemf.o goahead.o
+
+#*******************************************************************************
+# include path
+#*******************************************************************************
+CFLAGS	+= -DWEBS -DUEMF -DOS="LINUX" -DLINUX $(UMSW) $(DASW) $(SSLSW) $(IFMODSW)
+CFLAGS  += -Wall -fno-strict-aliasing -I../interface5.0/net -I.
+#CFLAGS	+= -I$(ROOTDIR)/lib/libnvram -I$(ROOTDIR)/$(LINUXDIR)/drivers/char -I$(ROOTDIR)/$(LINUXDIR)/include
+#CFLAGS  += -I$(ROOTDIR)/$(LINUXDIR)/drivers/flash -I$(INTERFACEDIR)
+
+#OTHERS	= -DB_STATS -DB_FILL -DDEBUG
+CFLAGS	+= -I../../include -g
+#CFLAGS	+= -I../../zte_sqlite
+#CFLAGS  += -I../../soft_timer
+CFLAGS	+= -I$(zte_lib_path)/libsqlite
+CFLAGS	+= -I$(zte_lib_path)/libsoft_timer
+CFLAGS  += -I../../at_server
+CFLAGS	+= -I$(zte_lib_path)/libnvram
+CFLAGS  += -I$(zte_lib_path)/libezxml
+CFLAGS  += -I$(zte_lib_path)/libmxml
+ifeq ($(CONFIG_USE_WEBUI_SSL),yes)
+OBJS += websSSL.o
+CFLAGS  += -I$(zte_lib_path)/libssl/install/include
+CFLAGS  += -I$(CPU_PUB_ROOT)/project/zx297520v3/include/nv
+CFLAGS	+= -DWEBS_SSL_SUPPORT -DOPENSSL
+LDLIBS += -L$(zte_lib_path)/libssl/install/lib -lssl -lcrypto
+LDLIBS += -ldl
+endif
+CFLAGS	+= -DWEBINSPECT_FIX
+LDLIBS += -lpthread
+LDLIBS += -lsoftap -L$(zte_lib_path)/libsoftap
+LDLIBS  += -lsoft_timer -L$(zte_lib_path)/libsoft_timer
+#LDLIBS  += -lkey -L$(zte_lib_path)/libkey
+LDLIBS  += -lamt -L$(zte_lib_path)/libamt
+LDLIBS  += -lcpnv -L$(zte_lib_path)/libcpnv
+
+ifeq ($(CONFIG_USE_WEBUI_SECURITY),yes)
+CFLAGS	+= -DWEBS_SECURITY
+endif
+#*******************************************************************************
+# macro definition
+#*******************************************************************************
+ifeq ($(CONFIG_USE_WEBUI_ZIP),yes)
+OBJS += ioapi.o unzip.o
+CFLAGS	+= -D_USE_WEBUI_ZIP
+CFLAGS  += -I$(zte_lib_path)/zlib/install/include
+LDFLAGS += -L$(zte_lib_path)/zlib/install/lib -lz
+endif
+
+ifeq ($(CUSTOM_MODEL), MF253S2)
+ifeq ($(CUSTOM_OPERATOR), CM_CN)
+CFLAGS	+= -DCUSTOM_VERSION_MF253S2_CM_CN
+endif
+endif
+
+##changed by huangmin10103007 for new partition, 20130116 begin
+ifeq ($(FEATURE_ZTE_CPE_CFG), YES)
+CFLAGS += -D_ZTE_CFG_
+endif
+##changed by huangmin10103007 for new partition, 20130116 end
+# Digest Access switch
+# DASW	= -DDIGEST_ACCESS_SUPPORT
+
+# SSL switches
+ifeq ("$(CONFIG_USER_GOAHEAD_SSL)", "y")
+SSLPATCHFILE = matrix_ssl.o sslSocket.o
+MATRIXDIR = $(ROOTDIR)/user/matrixssl-1.8.3
+SSLINC = $(MATRIXDIR)
+SSLLIB = $(MATRIXDIR)/src/libmatrixsslstatic.a
+SSLSW = -DWEBS_SSL_SUPPORT -DMATRIX_SSL -I$(SSLINC)
+endif
+
+#CONF_H	= $(ROOTDIR)/$(LINUXDIR)/include/linux/autoconf.h
+#CONF_H	= $(LINUX_DIR)/include/linux/autoconf.h
+#UCONF_H	= $(ROOTDIR)/config/autoconf.h
+
+#BUSYCONF_H = $(USR_DIR)/busybox-1.15.0/include/autoconf.h
+#UCONF_H	= $(CFG_DIR)/autoconf.h
+
+ifeq ($(FEATURE_DLNA), YES)
+# DLNA settings(libztedlna.so)
+LDLIBS += -L../../DMS -lztedlna -lpthread
+endif
+
+#*******************************************************************************
+# library
+#*******************************************************************************
+LDLIBS	+= -lnvram -lzte_pbm -lsqlite -lwlan_interface
+ifeq ($(LINUX_TYPE),uClinux)
+LDLIBS	+= -lpthread
+else
+LDLIBS	+= -lpthread
+endif
+
+
+ifeq ($(FEATURE_DLNA), YES)
+LDLIBS	+= -L../../DMS -lztedlna
+endif
+
+LDFLAGS	+= $(SSLLIB) $(IFMODLIB) $(INTERFACELIB) -lm -lgcc_s
+
+#LDFLAGS += -Wl,-elf2flt=-s131072
+
+CFLAGS += -I$(zte_lib_path)/libssl/install/include
+LDLIBS += -L$(zte_lib_path)/libssl/install/lib -lcrypto
+CFLAGS += -I$(zte_lib_path)/libcurl/install/include
+LDLIBS += -L$(zte_lib_path)/libcurl/install/lib -lcurl
+
+#*******************************************************************************
+# library path
+#*******************************************************************************
+LDLIBS  += -L$(zte_lib_path)/libnvram
+#LDLIBS  += -L$(zte_lib_path)/libsoft_timer
+LDLIBS  += -L$(zte_lib_path)/libsqlite
+LDLIBS  += -L$(zte_lib_path)/libzte_pbm
+LDLIBS  += -L$(zte_lib_path)/libmxml
+LDLIBS  += -L$(zte_lib_path)/libwlan_interface
+
+#*******************************************************************************
+# targets
+#*******************************************************************************
+all:$(EXEC)
+
+#
+#	Primary link
+#
+#$(CC) -o $@ $(OBJS) $(LDFLAGS) $(EXTRALIBS) $(LDLIBS)
+$(EXEC): $(OBJS) $(INTERFACELIB)
+	#$(LD)  -o $@ $(OBJS) $(LDFLAGS)  $(LDLIBS)
+	$(CC) -o $@ $(OBJS) $(LDFLAGS) $(EXTRALIBS) $(LDLIBS)
+
+root_fs:
+	cp $(EXEC) $(EXEC).elf
+	$(ROMFSINST) /bin/$(EXEC)
+
+romfs:
+	cp $(EXEC) $(EXEC).elf
+	$(ROMFSINST)  /bin/$(EXEC)
+
+clean:
+	-rm -f $(EXEC) *.o *.elf
+
+#
+#	Dependencies
+#
+asp.o:  webs.h wsIntrn.h ej.h ejIntrn.h uemf.h
+
+balloc.o: balloc.c uemf.h
+
+base64.o:  base64.c webs.h wsIntrn.h  ej.h ejIntrn.h uemf.h
+
+cgi.o:  webs.h wsIntrn.h uemf.h
+
+default.o:  default.c webs.h wsIntrn.h ej.h ejIntrn.h uemf.h $(CONF_H)
+
+ejlex.o:  ejlex.c ej.h ejIntrn.h uemf.h
+
+ejparse.o:  ejparse.c ej.h ejIntrn.h uemf.h
+
+emfdb.o:  emfdb.h wsIntrn.h uemf.h
+
+form.o:  form.c webs.h wsIntrn.h ej.h ejIntrn.h uemf.h
+
+h.o:  h.c uemf.h
+
+handler.o:  handler.c webs.h wsIntrn.h ej.h ejIntrn.h uemf.h
+
+md5c.o:  md5.h wsIntrn.h uemf.h
+
+mime.o:  mime.c webs.h wsIntrn.h ej.h ejIntrn.h uemf.h
+
+misc.o:  misc.c uemf.h
+
+page.o:  page.c webs.h wsIntrn.h ej.h ejIntrn.h uemf.h
+
+ringq.o:  ringq.c uemf.h
+
+rom.o:  rom.c webs.h wsIntrn.h ej.h ejIntrn.h uemf.h
+
+security.o:  security.c webs.h wsIntrn.h ej.h ejIntrn.h uemf.h
+
+sock.o:  sock.c uemf.h
+
+sockGen.o:  sockGen.c uemf.h $(CONF_H)
+
+sym.o:  sym.c uemf.h
+
+uemf.o:  uemf.c uemf.h
+
+um.o:  webs.h wsIntrn.h um.h uemf.h
+
+umui.o:  webs.h wsIntrn.h um.h uemf.h
+
+url.o:  url.c webs.h wsIntrn.h ej.h ejIntrn.h uemf.h
+
+value.o:  value.c uemf.h
+
+webrom.o:  webrom.c webs.h wsIntrn.h uemf.h
+
+webs.o:  webs.c webs.h wsIntrn.h ej.h ejIntrn.h uemf.h $(CONF_H)
+
+websda.o:  webs.h wsIntrn.h websda.h uemf.h
+
+websuemf.o:  websuemf.c webs.h wsIntrn.h ej.h ejIntrn.h uemf.h
+
+websSSL.o:  websSSL.c websSSL.h wsIntrn.h ej.h ejIntrn.h uemf.h
+
+#goahead.o:  goahead.c wsIntrn.h webs.h ej.h ejIntrn.h uemf.h $(CONF_H) $(UCONF_H) $(BUSYCONF_H)
+goahead.o:  goahead.c wsIntrn.h webs.h ej.h ejIntrn.h uemf.h $(CONF_H) $(BUSYCONF_H)
diff --git a/lynq/S300/ap/app/include/mmi_msg.h b/lynq/S300/ap/app/include/mmi_msg.h
new file mode 100755
index 0000000..dc820b7
--- /dev/null
+++ b/lynq/S300/ap/app/include/mmi_msg.h
@@ -0,0 +1,92 @@
+/**
+ * @file mmi_msg.h
+ * @brief ÌṩÁËmmiÏûÏ¢½Ó¿ÚºÍÏûÏ¢½á¹¹¶¨Òå
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#ifndef __MMI_MSG_H__
+#define __MMI_MSG_H__
+#include "message.h"
+
+
+/*ϵͳÐÅÏ¢²éѯ*/
+typedef struct {
+	signed long     srvStatus;        /*ϵͳ·þÎñ״̬  */
+	signed long     srvDomain;        /*ϵͳ·þÎñÓò    */
+	signed long     roamStatus;       /*ÂþÓÎ״̬      */
+	signed long     sysMode;          /*ϵͳģʽ      */
+	signed long     simState;         /*SIM¿¨×´Ì¬     */
+	signed long     reserve;          /*±£ÁôÖµ       */
+	signed long     sysSubmode;       /*ϵͳ×Óģʽ    */
+} T_zAt_SysinfoRes;
+
+
+/* ÏûÏ¢½á¹¹Ìå */
+typedef struct {
+	unsigned char sms_unread_ind; //0:ÎÞδ¶Á¶ÌÐÅ£» 1:ÓÐδ¶Á¶ÌÐÅ
+	unsigned char sms_memory_full_ind; //0:²»Âú; 1: Âú
+	unsigned char sms_new_ind;
+	unsigned char sms_is_reading;
+	unsigned char sms_unread_count;
+} T_zUfi_SmsStatusInfoInd;
+
+/* ¹Ø»úÖØÆôÏûϢʵ¼Ê²Ù×÷Öµ */
+typedef enum {
+	Ext_Cmd_Base = 0,
+	Ext_Cmd_REBOOT,
+	Ext_Cmd_POWEROFF,
+	Ext_Cmd_POWEROFF_CHARGING,
+	Ext_Cmd_POWEROFF_FAKE,
+	Ext_Cmd_POWEROFF_CLOCK,
+	Ext_Cmd_MAX
+} T_zUfi_ExtCmd;
+
+struct ext_msg_data {
+	int cmd;
+};
+
+//autotest ×Ô¶¯»¯²âÊÔÏûÏ¢Êý¾Ý
+typedef struct  {
+	SINT32 code;
+	SINT32 value;
+} autotest_key_rspmsg;
+
+//ÇëÎâºì½«mmiÄÚ²¿ÏûϢʹÓõÄÏûÏ¢Â룬ҲÌí¼Óµ½ÕâÀï
+enum mmi_msg_cmd {
+	MSG_CMD_CHANNEL_NETWORK_MODE = MSG_CMD_MMI_BASE,
+	MSG_CMD_MULTI_CONNECT_STATUS,//ÊÇ·ñ´æÔÚ¶à·PDP¼¤»î
+	MSG_CMD_CHANNEL_CONNECT_STATUS,
+	MSG_CMD_SMS_STATUS_INFO_IND,
+	MSG_CMD_OUT_REG_GET_SIGNAL_NUM,
+	MSG_CMD_MODIFY_SSID_KEY,
+	MSG_CMD_GET_TRAFFIC_INFO_START,
+	MSG_CMD_GET_TRAFFIC_INFO_END,
+	MSG_CMD_TRAFFIC_INFO_RESET,
+	MSG_CMD_GET_NET_PROVIDER,
+	MSG_CMD_SET_USB_MODE,
+	MSG_CMD_VOIP_STATUS_INFO,
+	MSG_CMD_STA_COUNT_CHANGE,
+	MSG_CMD_POWEROFF_PLUGOUT_RESULT,
+	MSG_CMD_SOCKET_STATE_CHANGE,    //ÄÚÖÃsocket connect state
+	MSG_CMD_MCUSOCKET_STATE_CHANGE, //ÍâÖÃsocket connect state
+	MSG_CMD_MMIGET_WIFI_STANUM,//ÏÂÃæÊÇMMI ÄÚ²¿Ê¹ÓõÄÏûÏ¢
+	MSG_CMD_MMISTART_BACKLIGHTOFF_TIMER,
+	MSG_CMD_MMICHECK_TIP_INFO,
+	MSG_CMD_MMISHOW_SSID_INFO,
+	MSG_CMD_MMIGET_WIFI_DATA,
+	MSG_CMD_RJ11_STATUS_INFO, //ҢԶcpe
+	MSG_CMD_RJ45_STATUS_INFO,
+//#ifdef _ENABLE_AUTOTEST
+	MSG_CMD_AUTOTEST_KEY_REQ,
+//#endif
+};
+
+#endif
+
diff --git a/lynq/S300/ap/app/nvro/Makefile b/lynq/S300/ap/app/nvro/Makefile
new file mode 100755
index 0000000..1608992
--- /dev/null
+++ b/lynq/S300/ap/app/nvro/Makefile
@@ -0,0 +1,62 @@
+#*******************************************************************************

+# include ZTE application makefile

+#*******************************************************************************

+include $(zte_app_mak)

+

+##############USER COMIZE BEGIN################

+EXEC = nvro

+C_SOURCE = $(wildcard ./*.c)

+OBJS = $(subst .c,.o,$(C_SOURCE))

+

+CFLAGS += -I$(zte_app_path)/include

+CFLAGS += -I$(zte_lib_path)/libnvram

+CFLAGS += -I$(zte_lib_path)/libsqlite

+CFLAGS += -I$(zte_lib_path)/libnetapi

+CFLAGS += -I$(zte_lib_path)/libzcore/std/inc/pal/dm

+CFLAGS += -I$(zte_lib_path)/libzcore/std/inc/zCore/gui

+CFLAGS += -g

+CFLAGS += -Wextra -Wall

+#CFLAGS += -I../../../linux-3.4.x

+CFLAGS += -I$(LINUX_DIR)/include

+CFLAGS += -I/$(TOPDIR)/pub/project/$(CHIP_NAME)/include/nv

+CFLAGS += -I$(zte_lib_path)/libamt

+ifeq ($(USE_VOICE_SUPPORT),yes)

+CFLAGS += -I$(zte_lib_path)/libtinyalsa/include

+endif

+LDLIBS = -lpthread -lm

+LDLIBS += -lnvram -L$(zte_lib_path)/libnvram

+LDLIBS += -lsoftap -L$(zte_lib_path)/libsoftap

+LDLIBS += -lsoft_timer -L$(zte_lib_path)/libsoft_timer

+LDLIBS += -lcpnv -L$(zte_lib_path)/libcpnv

+LDLIBS += -lamt -L$(zte_lib_path)/libamt

+ifeq ($(USE_VOICE_SUPPORT),yes)

+LDLIBS += -ltinyalsa -L$(zte_lib_path)/libtinyalsa

+endif

+

+ifeq ($(USE_VOICE_SUPPORT),yes)

+CFLAGS += -D_USE_VOICE_SUPPORT

+endif

+

+#wifi

+ifeq ($(CONFIG_WIFI_MODULE),ssv6x5x)

+CFLAGS	 += -D__SSV_6X5X_CHIP__

+else ifeq ($(CONFIG_WIFI_MODULE),aic8800)

+CFLAGS	 += -D__AIC_8800DW_CHIP__

+endif

+

+##############USER COMIZE END##################

+

+#*******************************************************************************

+# targets

+#*******************************************************************************

+all: $(EXEC)

+

+$(EXEC): $(OBJS)

+	$(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) -Wl,--end-group

+	@cp $@ $@.elf

+

+romfs:

+	$(ROMFSINST) $(EXEC) /bin/$(EXEC)

+

+clean:

+	-rm -f $(EXEC) *.elf *.gdb *.o

diff --git a/lynq/S300/ap/app/nvro/nvro.c b/lynq/S300/ap/app/nvro/nvro.c
new file mode 100644
index 0000000..fe48f6d
--- /dev/null
+++ b/lynq/S300/ap/app/nvro/nvro.c
@@ -0,0 +1,22 @@
+#include <stdio.h>  
+#include <stdlib.h>  
+#include <string.h>  
+#include <fcntl.h>  
+#include <unistd.h>
+#include "amtnv.h"
+  
+int main(int argc, char *argv[]) {  
+    if(argc == 2 && strlen(argv[1]) < 10)
+    {
+        amt_nvro_user_write(0,10,argv[1]);
+    }
+    else
+    {
+        char nvro_read[10];
+        amt_nvro_user_read(0,10,nvro_read);
+        printf("nvro_read :%s\n",nvro_read);
+        return strtol(nvro_read,NULL,10);
+    }
+  
+    return 0;  
+}
\ No newline at end of file
diff --git a/lynq/S300/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c b/lynq/S300/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c
new file mode 100755
index 0000000..9e774e2
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c
@@ -0,0 +1,786 @@
+/*******************************************************************************

+*À©Õ¹ATÃüÁîʵÏַǵçÐÅÏà¹ØÒµÎñ ʵÀý 

+*À©Õ¹ATÃüÁ¼ÈÖ§³ÖsoftapÖ®ÉϵÄÓû§½ø³Ìͨ¹ýptyÉ豸Óëat_ctl½øÐÐÀ©Õ¹AT½»»¥£¬Ò²Ö§³Ö¿Í»§µÄMCUͨ¹ýuart»òUSBµÈ´®¿ÚͨµÀͨ¹ýÀ©Õ¹ATÃüÁîÓëat_ctl½øÐн»»¥£¬½ø¶øÊµÏÖÓû§¶ÔsoftapµÄͳһ»¯¿ØÖÆ

+*À©Õ¹ATÃüÁîÓësoftapi¶ÔÍâÌṩµÄapiÏûÏ¢Ò»Ò»¶ÔÓ¦£¬ATÃüÁîµÄ¾ßÌå²ÎÊý£¬±£³ÖÓëÏûÏ¢ÌåÄÚÈÝÍêȫһÖÂ

+

+* ºóÐøÐÂÔöÀ©Õ¹ATÃüÁî×¢²á£¬¿ÉÒԲο¼ÈçÏ´úÂëʵÏÖ

+**********************************************************************************/

+#include <sys/wait.h>

+#include "softap_api.h"

+#include "at_com.h"

+#include "at_context.h"

+

+int g_atv = 0;

+int g_atq = 0;

+int g_at_d = 0;

+

+/* ½«À©Õ¹ATÃüÁî²ÎÊý½âÎö³Éreq_msg_id¶ÔÓ¦µÄÏûÏ¢½á¹¹Ì壬Èç¹ûÏûϢûÓÐÄÚÈÝ£¬res_msg=NULL£¬res_msglen=0

+·µ»ØAT_END_AND_MSG£¬ÓÉ¿ò¼ÜÍùat_fdÖÐд\r\nOK\r\n£¬²¢½«req_msg_id·¢Ë͵½·þÎñ¶Ëapp*/

+struct wifi_opt

+{

+	int  status;

+};

+

+char *  wlan_auth[] = 

+{

+	"OPEN",

+	"WPAPSK",

+	"WPA2PSK",

+	"WPAPSKWPA2PSK",

+	"WPA3Personal",

+	"WPA2WPA3",

+};

+

+char *  wlan_encrp[] = 

+{

+	"NONE",

+	"TKIP",

+	"AES",

+	"TKIPAES",

+};

+

+#if (APP_OS_TYPE == APP_OS_TOS)

+extern SINT32 mmiLcReset(VOID);

+extern UINT32 zOss_ResetNVFactory(VOID);

+#endif

+

+//»Ö¸´³ö³§ÉèÖÃ

+void ext_reset_proc()

+{

+#if (APP_OS_TYPE == APP_OS_TOS)

+#if (PRODUCT_TYPE == PRODUCT_PHONE)

+	mmiLcReset();

+#else

+	zOss_ResetNVFactory();

+#endif

+	//send_soc_msg(FAR_PS, MODULE_ID_MAIN_CTRL, MSG_CMD_RESET_RSP, 0, NULL);

+	platform_send_msg(MODULE_ID_CP_AT_CTL,MODULE_ID_MAIN_CTRL, MSG_CMD_RESET_RSP, 0, NULL);

+#endif

+}

+

+/*

+typedef int (*ser_req_func)(int at_fd, char *at_paras, void ** res_msg, int *res_msglen);

+*/

+int ext_wifi_switch_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)

+{

+	char *opt = (char *)malloc(sizeof(int));

+	if(opt == NULL)

+		return AT_END;

+	memset(opt, 0 , sizeof(int));

+	strcpy(opt, at_paras);

+	printf("at_paras=%s, opt=%s\n", at_paras, opt);

+	*res_msg = opt;

+	*res_msglen = strlen(opt);

+	return AT_CONTINUE;

+}

+

+/*

+typedef int (*app_rsp_proc)(void *rsp_msg, void**ret, int *retlen);

+

+*/

+int ext_wifi_operate_rsp(void *rsp_msg, void**ret, int *retlen)

+{

+

+	char *at_str = NULL;

+

+	if(AT_RSP_ERR == atoi(rsp_msg))

+	{

+		at_str = at_err_build(ATERR_PROC_FAILED);	

+	}

+	else

+	{

+		at_str = at_ok_build();

+

+	}

+

+	*ret = at_str;

+	*retlen = strlen(at_str);

+

+	 return AT_END;

+}

+

+int ext_wifi_cfg_ssid_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)

+{

+	wlan_basic_info *opt = (wlan_basic_info *)malloc(sizeof(wlan_basic_info));

+	if(opt == NULL)

+		return AT_END;

+	memset(opt, 0 , sizeof(wlan_basic_info));

+	void *p[1] = {opt->ssid};

+	parse_param2("%s", at_paras, p);

+

+	printf("ssid=%s,auth=%s, encrypt=%s, pwd=%s, max_access=%s, hidessid=%s\n",opt->ssid, opt->authmode, opt->encrypt, opt->pwd, opt->max_access_num, opt->hidessid);

+	*res_msg = opt;

+	*res_msglen = sizeof(wlan_basic_info);

+	return AT_CONTINUE;

+}

+

+int ext_wifi_cfg_auth_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)

+{

+	wlan_basic_info *opt = (wlan_basic_info *)malloc(sizeof(wlan_basic_info));

+	if(opt == NULL)

+		return AT_END;

+	memset(opt, 0 , sizeof(wlan_basic_info));

+

+	void *p[3] = {opt->authmode, opt->encrypt, opt->pwd};

+	parse_param2("%20s,%10s,%65s", at_paras, p);

+

+	unsigned int auth_index = atoi(opt->authmode);

+	unsigned int encrp_index = atoi(opt->encrypt);

+	if(auth_index < (sizeof(wlan_auth)/sizeof(char *)) && encrp_index < (sizeof(wlan_encrp)/sizeof(char *))){

+	sprintf(opt->authmode, "%s",  wlan_auth[auth_index]);

+	sprintf(opt->encrypt, "%s",  wlan_encrp[encrp_index]);

+	}

+	printf("ssid=%s,auth=%s, encrypt=%s, pwd=%s, max_access=%s, hidessid=%s\n",opt->ssid, opt->authmode, opt->encrypt, opt->pwd, opt->max_access_num, opt->hidessid);

+

+

+	*res_msg = opt;

+	*res_msglen = sizeof(wlan_basic_info);

+	return AT_CONTINUE;

+}

+

+

+int ext_reset_req(int at_fd,char * at_paras,void **res_msg,int * res_msglen)

+{

+	restart_info *opt  = (restart_info *)malloc(sizeof(restart_info));

+	if(opt == NULL)

+		return AT_END;

+	memset(opt, 0 , sizeof(restart_info));

+	opt->action = Restart_Action_RESET;

+	opt->subaction = Operate_By_MCU;

+	printf("ext_reset_req action=%d,subaction=%d\n",opt->action, opt->subaction);

+	*res_msg = opt;

+	*res_msglen = sizeof(restart_info);  

+	return AT_CONTINUE;

+}

+

+int ext_restart_req(int at_fd,char * at_paras,void **res_msg,int * res_msglen)

+{

+	restart_info *opt  = (restart_info *)malloc(sizeof(restart_info));

+	if(opt == NULL)

+		return AT_END;

+	memset(opt, 0 , sizeof(restart_info));

+	void *p[2] = {&opt->action, &opt->subaction}; 

+	

+	parse_param2("%d,%d", at_paras, p);

+	

+	if (3 != strlen(at_paras) || opt->action < Restart_Action_RESTART || opt->action > Restart_Action_RESET || opt->subaction < Operate_By_MCU || opt->subaction > Operate_By_SOC)

+	{

+		*res_msg = at_err_build(ATERR_PARAM_INVALID);

+		*res_msglen = strlen(*res_msg);

+		return AT_END;

+	}

+	

+	printf("ext_restart_req action=%d,subaction=%d ,len=%d \n",opt->action, opt->subaction,strlen(at_paras));

+	*res_msg = opt;

+	*res_msglen = sizeof(restart_info);

+	return AT_CONTINUE;

+}

+

+int ext_restart_rsp(void *rsp_msg, void**ret, int *retlen)

+{

+	char *at_str = NULL;

+

+	at_str = at_ok_build();

+

+	*ret = at_str;

+	*retlen = strlen(at_str);

+

+	return AT_END;

+}

+

+int ext_tc_control_func(char *at_paras, void ** res_msg)

+{

+	int ret = 0;

+	struct tc_control_info my_tc_info = {0};

+	void *p[2] = {&my_tc_info.tc_downlink,&my_tc_info.tc_uplink};

+	ret = parse_param("%d,%d", at_paras, p);

+	if (ret != AT_PARSE_OK)

+		return AT_END;

+	ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_MAIN_CTRL,MSG_CMD_NET_TC_CTRL,sizeof(struct tc_control_info), (unsigned char *)&my_tc_info,0);

+	return AT_CONTINUE;

+}

+

+int ext_atv_set_func(char *at_paras, void ** res_msg)

+{

+	if(at_paras && strlen(at_paras) <= 1)

+	{

+		if(*at_paras == '\0' || *at_paras == '0')

+		{

+			g_atv = 1;

+			return AT_END;

+		}

+		else if( *at_paras == '1')

+		{

+			g_atv = 0;

+			return AT_END;

+		}

+	}

+	*res_msg = at_err_build(ATERR_PARAM_INVALID);;

+	return AT_END;

+}

+

+int ext_atq_set_func(char *at_paras, void ** res_msg)

+{

+	if(at_paras && strlen(at_paras) <= 1)

+	{

+		if(*at_paras == '\0' || *at_paras == '0')

+		{

+			g_atq = 0;

+			return AT_END;

+		}

+		else if( *at_paras == '1')

+		{

+			g_atq = 1;

+			return AT_END;

+		}

+	}

+	*res_msg = at_err_build(ATERR_PARAM_INVALID);;

+	return AT_END;

+}

+

+int ext_at_w_set_func(char *at_paras, void ** res_msg)

+{

+	char nv_atv[12] = {0};

+	char nv_atq[12] = {0};

+	char nv_at_d[12] = {0};

+

+	snprintf(nv_atv,12,"%d",g_atv);

+	snprintf(nv_atq,12,"%d",g_atq);

+	snprintf(nv_at_d,12,"%d",g_at_d);

+	

+	cfg_set("at_atv", nv_atv);

+	cfg_set("at_atq", nv_atq);

+	cfg_set("at_at_d", nv_at_d);

+	cfg_save();

+	

+	return AT_END;

+}

+

+int ext_at_d0_set_func(char *at_paras, void ** res_msg)

+{

+	g_at_d = 0;

+	return AT_END;

+}

+

+int ext_at_d1_set_func(char *at_paras, void ** res_msg)

+{

+	g_at_d = 1;

+	return AT_END;

+}

+

+int ext_at_d2_set_func(char *at_paras, void ** res_msg)

+{

+	g_at_d = 2;

+	return AT_END;

+}

+

+int ext_at_mac_manage_set_func(char *at_paras, void ** res_msg)

+{

+	char *at_str = malloc(64);

+	int ret = -1;

+	char n1[10] = {0};

+	char n2[10] = {0};

+	char n3[18] = {0};

+	void *p[] = {n1,n2,n3};

+	ret = parse_param("%s,%s,%s", at_paras, p);

+	if (ret != AT_PARSE_OK)

+	{

+		sprintf(at_str,"\r\n+CME ERROR: %d\r\n",ret);

+		return AT_END;

+	}

+	if(strcmp(n1,"read") == 0)

+	{

+		if(strcmp(n2,"wlan") == 0)

+		{

+			char wifi_wlan[18] = {0};

+			cfg_get_item("mac_wlan0", wifi_wlan, sizeof(wifi_wlan));

+			sprintf(at_str,"\r\n+MAC_MANAGE: %s\r\nOK\r\n",wifi_wlan);

+		}

+		else

+			sprintf(at_str,"\r\n+CME ERROR: %d\r\n",100);

+	}

+	else if(strcmp(n1,"write") == 0)

+	{

+		if(strcmp(n2,"wlan") == 0)

+		{

+			char wifi_wlan[20] = {0};

+			sprintf(wifi_wlan,"%c%c:%c%c:%c%c:%c%c:%c%c:%c%c",

+			n3[0],n3[1],n3[2],n3[3],n3[4],n3[5],n3[6],n3[7],n3[8],n3[9],n3[10],n3[11]);

+			cfg_set("mac_wlan0", wifi_wlan);

+			cfg_save();

+			sprintf(at_str,"\r\nOK\r\n");

+		}

+		else

+			sprintf(at_str,"\r\n+CME ERROR: %d\r\n",101);

+		

+	}

+	else

+		sprintf(at_str,"\r\n+CME ERROR: %d\r\n",102);

+		

+	*res_msg = at_str;

+	return AT_END;

+}

+

+int ext_at_wifi_info_set_func(char *at_paras, void ** res_msg)

+{

+	char *at_str = malloc(64);

+	int ret = -1;

+	char n1[10] = {0};

+	char n2[18] = {0};

+	void *p[] = {n1,n2};

+	ret = parse_param("%s,%s", at_paras, p);

+	if (ret != AT_PARSE_OK)

+	{

+		sprintf(at_str,"\r\n+CME ERROR: %d\r\n",ret);

+		return AT_END;

+	}

+	if(strcmp(n1,"read") == 0)

+	{

+		if(strcmp(n2,"host_ssid_2.4G") == 0)

+		{

+			char wifi_ssid[18] = {0};

+			cfg_get_item("SSID1", wifi_ssid, sizeof(wifi_ssid));

+			sprintf(at_str,"\r\n+WIFI_INFO: %s\r\nOK\r\n",wifi_ssid);

+		}

+		else if(strcmp(n2,"host_passwd_2.4G") == 0)

+		{

+			char wifi_wpapsk[18] = {0};

+			cfg_get_item("WPAPSK1", wifi_wpapsk, sizeof(wifi_wpapsk));

+			sprintf(at_str,"\r\n+WIFI_INFO: %s\r\nOK\r\n",wifi_wpapsk);

+		}

+		else if(strcmp(n2,"host_ssid_5G") == 0)

+		{

+			sprintf(at_str,"\r\n+CME ERROR: %d\r\n",100);

+		}

+		else if(strcmp(n2,"host_passwd_5G") == 0)

+		{

+			sprintf(at_str,"\r\n+CME ERROR: %d\r\n",100);

+		}

+		else if(strcmp(n2,"guest_ssid") == 0)

+		{

+			char wifi_ssid[18] = {0};

+			cfg_get_item("SSID1", wifi_ssid, sizeof(wifi_ssid));

+			sprintf(at_str,"\r\n+WIFI_INFO: %s\r\nOK\r\n",wifi_ssid);

+		}

+		else if(strcmp(n2,"guest_passwd") == 0)

+		{

+			char wifi_wpapsk[18] = {0};

+			cfg_get_item("WPAPSK1", wifi_wpapsk, sizeof(wifi_wpapsk));

+			sprintf(at_str,"\r\n+WIFI_INFO: %s\r\nOK\r\n",wifi_wpapsk);

+		}

+		else

+			sprintf(at_str,"\r\n+CME ERROR: %d\r\n",100);

+	}

+	else

+		sprintf(at_str,"\r\n+CME ERROR: %d\r\n",102);

+		

+	*res_msg = at_str;

+	return AT_END;

+}

+

+int ext_at_flag_manage_set_func(char *at_paras, void ** res_msg)

+{

+	char *at_str = malloc(64);

+	int ret = -1;

+	char n1[10] = {0};

+	char n2[16] = {0};

+	char n3[18] = {0};

+	void *p[] = {n1,n2,n3};

+	ret = parse_param("%s,%s,%s", at_paras, p);

+	if (ret != AT_PARSE_OK)

+	{

+		sprintf(at_str,"\r\n+CME ERROR: %d\r\n",ret);

+		return AT_END;

+	}

+	if(strcmp(n1,"read") == 0)

+	{

+		if(strcmp(n2,"wifi_ft") == 0)

+		{

+			char wifi_wlan[18] = {0};

+			cfg_get_item("wifi_ft", wifi_wlan, sizeof(wifi_wlan));

+			sprintf(at_str,"\r\n+FLAG_MANAGE: %s\r\nOK\r\n",wifi_wlan);

+		}

+		else if(strcmp(n2,"wifi_coupling") == 0)

+		{

+			char wifi_wlan[18] = {0};

+			cfg_get_item("wifi_coupling", wifi_wlan, sizeof(wifi_wlan));

+			sprintf(at_str,"\r\n+FLAG_MANAGE: %s\r\nOK\r\n",wifi_wlan);

+		}

+		else

+			sprintf(at_str,"\r\n+CME ERROR: %d\r\n",100);

+	}

+	else if(strcmp(n1,"write") == 0)

+	{

+		if(strcmp(n2,"wifi_ft") == 0)

+		{

+			cfg_set("wifi_ft", n3);

+			cfg_save();

+			sprintf(at_str,"\r\nOK\r\n");

+		}

+		else if(strcmp(n2,"wifi_coupling") == 0)

+		{

+			cfg_set("wifi_coupling", n3);

+			cfg_save();

+			sprintf(at_str,"\r\nOK\r\n");

+		}

+		else

+			sprintf(at_str,"\r\n+CME ERROR: %d\r\n",101);

+		

+	}

+	else

+		sprintf(at_str,"\r\n+CME ERROR: %d\r\n",102);

+		

+	*res_msg = at_str;

+	return AT_END;

+}

+

+static int lynq_ping(const char *address)

+{

+    char command[32] = "";

+    int exit_status = 0;

+

+    // ¹¹ÔìpingÃüÁî

+    snprintf(command, sizeof(command), "ping -c 1 -w 1 %s", address);

+

+    // ʹÓÃsystemµ÷ÓÃpingÃüÁÔÚping֮ǰdownµôusbÍø¿Ú£¬·ÀÖ¹ping usbÍø¿ÚµØÖ·

+    system("ifconfig usblan0 down");

+    exit_status = system(command);

+    system("ifconfig usblan0 up");

+

+    // systemº¯Êý·µ»ØÖµ½âÎö

+    if (exit_status == 0)

+    {

+        return 0; // ³É¹¦

+    }

+    else if (WIFEXITED(exit_status))

+    {

+        return WEXITSTATUS(exit_status); // ·Ç0Í˳öÂ룬ʧ°Ü

+    }

+    else

+    {

+        return -1; // ´íÎó

+    }

+}

+

+int ext_at_ping_set_func(char *at_paras, void ** res_msg)

+{

+	if(at_paras && strlen(at_paras) > 0 && strlen(at_paras) < 16)

+	{

+		int ret = lynq_ping(at_paras);

+		if(0 == ret)

+		{

+			char *at_str = malloc(16);

+			if(NULL == at_str)

+			{

+				return AT_END;

+			}

+			strcpy(at_str,"\r\nOK\r\n");

+			*res_msg = at_str;

+		}

+		else

+		{

+			*res_msg = at_err_build(ATERR_PROC_FAILED);

+		}

+		return AT_END;

+	}

+	*res_msg = at_err_build(ATERR_PARAM_INVALID);

+	return AT_END;

+}

+

+void set_led_states(char *led_list[], int start_index, int count, int state)

+{

+	int i = 0;

+	char cmd[128];

+	for (i = start_index; i < start_index + count; i++)

+	{

+		memset(cmd, 0, sizeof(cmd));

+		sprintf(cmd,"echo %d > /sys/class/leds/%s/brightness", state , led_list[i]);

+		system(cmd);

+	}

+}

+

+int ext_at_led_func(char *at_paras, void ** res_msg)

+{

+	int i = 0;

+	char *led_list[7] = {

+					"battery_g_led",

+					"modem_g_led",

+					"eth_led",

+					"wifi_led",

+					"battery_r_led",

+					"modem_r_led",

+					"modem_b_led",};			

+	set_led_states(led_list, 0, 7, 0); // turn off all leds

+	set_led_states(led_list, 0, 4, 1); // turn on all green leds

+	usleep(500000);

+	set_led_states(led_list, 0, 4, 0); // turn off all green leds

+	set_led_states(led_list, 4, 2, 1); // turn on all red leds

+	usleep(500000);

+	set_led_states(led_list, 4, 2, 0); // turn off all red leds

+	set_led_states(led_list, 6, 1, 1); // turn on all blue leds

+	usleep(500000);

+	set_led_states(led_list, 6, 1, 0); // turn off all blue leds

+	return AT_END;

+}

+

+#define BATTERY_VALUE "cat /sys/class/power_supply/battery/voltage_now"

+#define BATTERY_STATE "cat /sys/class/power_supply/charger/status"

+

+char *exec_battery_cmd(char *cmd, char *flag)

+{

+	char out_put[32];

+	char *at_str = malloc(128);

+	if (at_str == NULL)

+	{  

+        return NULL;

+	}

+	FILE *fp;

+	fp = popen(cmd, "r");

+	if (fp == NULL)

+	{

+		free(at_str);

+		return NULL;

+	}

+	if (fgets(out_put, sizeof(out_put), fp) != NULL)

+	{

+		sprintf(at_str, "\r\n+%s: %s\r\nOK\r\n", flag, out_put);

+	}

+	pclose(fp);

+	return at_str;

+}

+int ext_at_battery_func(char *at_paras, void ** res_msg)

+{

+	system("echo 0 > /sys/class/power_supply/charger/charge_enabled"); //¶ÁÈ¡µçѹʱÏȽûÓóäµç

+	*res_msg = exec_battery_cmd(BATTERY_VALUE,"BATTERY_VALUE");

+	if (*res_msg == NULL)

+	{

+		*res_msg = at_err_build(ATERR_PROC_FAILED);

+	}

+	system("echo 1 > /sys/class/power_supply/charger/charge_enabled");//¶ÁÈ¡Íê³ÉºóʹÄܳäµç

+	return AT_END;

+}

+

+int ext_at_battery_state_func(char *at_paras, void ** res_msg)

+{

+	*res_msg = exec_battery_cmd(BATTERY_STATE,"BATTERY_STATE");

+	if (*res_msg == NULL)

+	{

+		*res_msg = at_err_build(ATERR_PROC_FAILED);

+	}

+	return AT_END;

+}

+

+/**

+ * ¶ÁÈ¡ÎļþÄÚÈݵ½×Ö·û´®ÖУ¬°´ÐжÁÈ¡

+ * @param filename ÎļþÃû

+ * @return ¶¯Ì¬·ÖÅäµÄ×Ö·û´®£¬°üº¬ÎļþÄÚÈÝ£¬»òÕßÔÚʧ°Üʱ·µ»ØNULL

+ */

+char* read_file_to_string_by_line(const char* filename) {

+    FILE *file = fopen(filename, "r");

+    if (file == NULL) 

+	{

+        return NULL;

+    }

+

+    // ÏÈ»ñÈ¡Îļþ´óС

+    fseek(file, 0, SEEK_END);

+    size_t file_size = ftell(file);

+    rewind(file);

+

+    // ·ÖÅä³õʼÄÚ´æ

+    char *buffer = (char*)malloc(file_size + 1);

+    if (buffer == NULL) 

+	{

+        fclose(file);

+        return NULL;

+    }

+

+    char line[256] = {0};

+    char fileds[5][256] = {0}; // ÁÙʱ´æ´¢Ã¿Ò»ÐеÄ×Ö¶Î

+    size_t buffer_size = 0;

+	char *token = NULL;

+	int i = 0;

+

+    // ¶ÁÈ¡µÚÒ»Ðе«²»Ê¹ÓÃ

+    if (fgets(line, sizeof(line), file) != NULL) 

+	{

+

+    }

+

+    while (fgets(line, sizeof(line), file) != NULL) 

+	{

+		if(buffer_size >= file_size)

+		{

+			break;

+		}

+		

+        token = strtok(line, " \t");

+        i = 0;

+        while(token != NULL && i < 5) 

+		{

+            strcpy(fileds[i], token);

+            token = strtok(NULL, " \t");

+            i++;

+        }

+        if (i >= 5) 

+		{

+            buffer_size += snprintf(buffer + buffer_size, file_size - buffer_size, "+WLAN_STA:%s,%s,%s,%s\n", fileds[0], fileds[1], fileds[2], fileds[4]);

+        }

+    }

+

+    // È·±£×Ö·û´®ÒÔnullÖÕÖ¹

+    buffer[buffer_size] = '\0';

+

+    fclose(file);

+    return buffer;

+}

+

+int ext_at_wlan_station_func(char *at_paras, void ** res_msg)

+{

+	int count = 0;

+	char scan_finish[4] = {0};

+	char *ap_list = NULL;

+	char *at_str = NULL;

+

+	cfg_set("wifi_sta_connection", "1");

+	cfg_set("scan_finish", "0");

+	cfg_set("EX_APLIST", "");

+	ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_WIFI, MSG_CMD_WIFI_STATION_OPEN, 0, NULL, 0);

+	ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_WIFI, MSG_CMD_WIFI_STATION_SCAN, 0, NULL, 0);

+

+	while(1)

+	{

+		count++;

+		sleep(1);

+		cfg_get_item("scan_finish", scan_finish, sizeof(scan_finish));

+		

+		if(6 == count)

+		{

+			at_str = malloc(128);

+			sprintf(at_str, "\r\n+WLAN_STA\r\nDo no have any station\r\nOK\r\n");

+			*res_msg = at_str;

+			break;

+		}

+

+		if(1 == atoi(scan_finish))

+		{

+			ap_list = read_file_to_string_by_line("/tmp/scan_results");

+			if(NULL == ap_list)

+			{

+				at_str = malloc(128);

+				sprintf(at_str, "\r\n+WLAN_STA\r\nDo no have any station\r\nOK\r\n");

+				*res_msg = at_str;

+				break;

+			}

+			at_str = malloc(strlen(ap_list) + 32);

+			sprintf(at_str, "\r\n%s\r\nOK\r\n", ap_list);

+			*res_msg = at_str;

+			break;

+		}

+	}

+	

+	cfg_set("wifi_sta_connection", "0");

+	cfg_save();

+	ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_WIFI, MSG_CMD_WIFI_STATION_CLOSE, 0, NULL, 0);

+	free(ap_list);

+

+	return AT_END;

+}

+

+int ext_at_wlan_calibrate_func(char *at_paras, void ** res_msg)

+{

+	char *at_str = malloc(64);

+	int v1 = WEXITSTATUS(system("nvro"));

+	int v2 = WEXITSTATUS(system("/sbin/rtl8192_calibrate.sh 3"));

+	if(v1 < v2)

+	{

+		sprintf(at_str, "\r\n%d,%d\r\n%s\r\n", v1,v2,"ERROR");

+	}

+	else if(v1 > v2)

+	{

+		sprintf(at_str, "\r\n%d,%d\r\n%s\r\n", v1,v2,"OK");

+	}

+	else

+	{

+		int exit_status = system("/sbin/rtl8192_calibrate.sh 0");

+		sprintf(at_str, "\r\n%d,%d\r\n%s\r\n", v1,v2,exit_status == 0 ?"OK":"ERROR");

+	}

+	*res_msg = at_str;

+	return AT_END;

+}

+

+int ext_at_lan_ip_func(char *at_paras, void ** res_msg)

+{

+	char *at_str = malloc(64);

+	char buf[32] = {0};

+

+	cfg_get_item("lan_ipaddr", buf, sizeof(buf));

+	sprintf(at_str, "\r\n+LAN_IP:%s\r\nOK\r\n", buf);

+	*res_msg = at_str;

+

+	return AT_END;

+}

+

+void ext_notelcom_regist()

+{

+    register_serv_func2("ZWIFI=", MODULE_ID_WIFI, 

+							MSG_CMD_WIFI_SWITCH_REQ, 

+							MSG_CMD_WIFI_SWITCH_RSP, 

+							ext_wifi_switch_req, ext_wifi_operate_rsp);

+    register_serv_func2("ZWSSID=", MODULE_ID_WIFI, 

+							MSG_CMD_WIFI_CFG_SSID_REQ, 

+							MSG_CMD_WIFI_CFG_SSID_RSP, 

+							ext_wifi_cfg_ssid_req, ext_wifi_operate_rsp);

+    register_serv_func2("ZWAUTH=", MODULE_ID_WIFI, 

+							MSG_CMD_WIFI_CFG_PWD_REQ, 

+							MSG_CMD_WIFI_CFG_PWD_RSP, 

+							ext_wifi_cfg_auth_req, ext_wifi_operate_rsp);

+

+	

+	register_serv_func2("ZRESET",MODULE_ID_MAIN_CTRL,MSG_CMD_RESET_REQUEST,MSG_CMD_RESTART_RSP,ext_reset_req,ext_restart_rsp);//½ö¹©Éú²ú²âÊÔÓÃ

+	register_serv_func2("ZRESTART=",MODULE_ID_MAIN_CTRL,MSG_CMD_RESTART_REQUEST,MSG_CMD_RESTART_RSP,ext_restart_req,ext_restart_rsp);//ZRESTART=0,0,²ÎÊý1±íʾRESET /RESTART£¬²ÎÊý2±íʾʵ¼ÊÖØÆô²Ù×÷ÊÇ·ñÓɱ¾ºË×Ô¼ºÊµÏÖ

+	register_serv_func("TC_CONTROL=",MODULE_ID_MAIN_CTRL,ext_tc_control_func);

+	register_serv_func("ATV", 0, ext_atv_set_func);

+	register_serv_func("ATQ", 0, ext_atq_set_func);

+	register_serv_func("W", 0, ext_at_w_set_func);

+	register_serv_func("W0", 0, ext_at_w_set_func);

+	register_serv_func("D", 0, ext_at_d0_set_func);

+	register_serv_func("D0", 0, ext_at_d0_set_func);

+	register_serv_func("D1", 0, ext_at_d1_set_func);

+	register_serv_func("D2", 0, ext_at_d2_set_func);

+	register_serv_func("mac_manage=", 0, ext_at_mac_manage_set_func);

+	register_serv_func("wifi_info=", 0, ext_at_wifi_info_set_func);

+	register_serv_func("flag_manage=", 0, ext_at_flag_manage_set_func);

+	register_serv_func("PING=", 0, ext_at_ping_set_func);

+	register_serv_func("LED", 0, ext_at_led_func);

+	register_serv_func("BATTERY=?", 0, ext_at_battery_func);

+	register_serv_func("BATTERY?", 0, ext_at_battery_state_func);

+	register_serv_func("WLAN_STA", 0, ext_at_wlan_station_func);

+	register_serv_func("WLAN_CALIBRATE?", 0, ext_at_wlan_calibrate_func);

+	register_serv_func("LAN_IP?", 0, ext_at_lan_ip_func);

+}

+

+void at_comm_init(void)

+{

+	char nv_atv[8] = {0};

+	char nv_atq[8] = {0};

+	char nv_at_d[8] = {0};

+

+	cfg_get_item("at_atv", nv_atv, sizeof(nv_atv));

+	cfg_get_item("at_atq", nv_atq, sizeof(nv_atq));

+	cfg_get_item("at_at_d", nv_at_d, sizeof(nv_at_d));

+	g_atv = atoi(nv_atv);

+	if(g_atv < 0 || g_atv > 1) { 

+		g_atv = 0;

+	}

+	g_atq = atoi(nv_atq);

+	if(g_atq < 0 || g_atq > 1) { 

+		g_atq = 0;

+	}

+	g_at_d = atoi(nv_at_d);

+	if(g_at_d < 0 || g_at_d > 2) { 

+		g_at_d = 0;

+	}

+	at_print(AT_NORMAL, "atv:%d, atq:%d, at&d:%d \n", g_atv, g_atq, g_at_d);

+}

+

diff --git a/lynq/S300/ap/app/zte_comm/at_ctl/src/atconfig/ps_normal.c b/lynq/S300/ap/app/zte_comm/at_ctl/src/atconfig/ps_normal.c
new file mode 100755
index 0000000..57944da
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/at_ctl/src/atconfig/ps_normal.c
@@ -0,0 +1,5825 @@
+

+/************************************************************************

+*¹¦ÄܽéÉÜ£ºat_ctlºÍPSÏà¹ØµÄʼþʵÏÖºÍÃüÁî´¦Àí½Ó¿Ú£¬°üÀ¨¿ª»ú×Ô¶¯²¦ºÅµÄʼþÁ÷¡¢web ui¾ßÌåµÄÒµÎñ´¦Àí

+*¸ºÔðÈË£º

+*ÐÞ¸ÄÈÕ£º

+*ÐÞ¸ÄÄÚÈÝ£º

+*°æ±¾ºÅ£º

+************************************************************************/

+

+#include "ps_normal.h"

+#include "ps_pdp.h"

+#include "at_context.h"

+#include <sys/time.h>

+#include <time.h>

+#include <limits.h>

+

+#include "rtc_timer.h"

+#if (APP_OS_TYPE == APP_OS_TOS)

+#include "zctrm_ext_locknet.h"

+#endif

+

+//bsim

+#include <openssl/aes.h>

+

+typedef struct

+{

+	unsigned int pubKeyRsaE[32];

+	unsigned int pubKeyRsaN[32];

+	unsigned int secureFlag;

+	unsigned int pubKeyHash[4];

+	unsigned int secureDevId[3];

+}T_ZDrvEfuse_Secure;

+

+#define EFUSE_IOC_MAGIC 	'E'

+#define EFUSE_GET_DATA 		_IOWR(EFUSE_IOC_MAGIC, 1, char *)

+#define PPPOE_CODE_LEN 		32 //webui limit 30

+

+static unsigned char atctl_aes_key[16] = {0};

+

+#define PROFILE_APN_LEN 65

+#define PROFILE_APN_AES_LEN 129

+

+static int apn_encrypt_code(void);

+static int ipv6apn_encrypt_code(void);

+//bsim end

+

+/*CNUMÉϱ¨*/

+typedef struct

+{

+    char    alpha[80];

+    char    number[80];

+    unsigned char  type;

+} T_zAt_CnumRes;

+

+struct time_info{

+	SINT32 time_zone;

+	SINT32 sav_time;

+	char univer_time[64];

+};

+

+//extern AT_PDP_ACT_REQ_INFO * g_pdp_set_info;

+psnormal_state psinfo={0};

+static T_zAt_Zsec_Res g_LockZsec = {0};

+static int cfun_state=0;//ÓÃÓÚ±ê¼Çcfun״̬

+static int g_plmnLen = 5;//ccmnc³¤¶È

+static char mccNum[10] 		= {0};

+static char mncNum[10] 		= {0};

+static int g_zUfi_Mode=-1;//ModeÉϱ¨±ä»¯£¬Óбä³É²Å²éѯSysinfo

+static int g_zUfi_SubMode=-1;//ModeÉϱ¨±ä»¯£¬Óбä³É²Å²éѯSysinfo

+static int g_zUfi_Stat=-1;//CEREG\CREG\CGREG±ä»¯£¬Óб仯²Å²éѯSysinfo

+static int g_isSearchingNetwork = FALSE;

+static int g_zUfi_canPdpDail = TRUE;

+static int g_zUfi_firstCsq = TRUE;

+static char *crsmrsp=NULL;//ÓÃÓڼǼcrsm»Ø¸´½á¹û

+static char *mactozssid=NULL;//¼Ç¼ÊÕµ½µÄMACµØÖ·

+static BOOL g_SimSlotFlag = TRUE;//¼Ç¼sim¿¨²åÈë°Î³ö״̬

+static int sysinfo_flag = 0;

+int g_modem_model = 0;

+int g_support_sms = 0;

+int g_support_pb = 0;

+int g_smspb_init = 0;//Éϱ¨pbÍê³É³õʼ»¯±êÖ¾ 0:δÉϱ¨ 1:ÒÑÉϱ¨

+int g_need_smspb_init = 0;//smsºÍpbÊÇ·ñ¿ÉÒÔ½øÐгõʼ»¯£¬Ã¿´Î¿ª»ú½öÄܽøÐÐÒ»´Î³õʼ»¯²Ù×÷£¬ÖÃΪ0ʱ±íʾ¿ÉÒÔ³õʼ»¯£¬Ò»µ©³õʼ»¯ºó£¬ÖÃΪ1

+#if (APP_OS_TYPE == APP_OS_TOS)

+extern T_zCtrm_LockListPara simLockListPara;

+extern T_zCtrm_SIMPara simPara;

+extern SINT32 g_Sec_Status;

+extern int crsm_reason;

+#endif

+extern struct defcid_mng_t g_defcid_mng;

+char imsi[50] = {0};

+//zdm ÇëÕ×·áÈ·ÈÏÊÇ·ñÐèҪͬ²½µ½AP²à

+//ºóÐøÓÃËøÍøÌæ´ú£¬ÆÕͨ°æ±¾²»Ëø

+char* zurdy_convert_cmd(void *msg,struct at_context *context)

+{   

+    char *at_str = NULL;

+    

+    at_str = (char *)malloc(20);

+    if(at_str == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    strcpy(at_str, "AT+ZSCHPLMN=1\r\n");

+    return at_str;

+}

+

+int zmmi_auto_act(char *at_paras ,int is_query_report)

+{

+	

+	char mode[10] = {0};

+	struct time_info timeinfo = {0};

+	struct tm set_tm = {0};

+	struct timeval time_tv = {0};

+	char temp1[256] = {0};

+	char temp2[256] = {0};

+	void *p[5] = {&timeinfo.time_zone,&timeinfo.sav_time,temp1,temp2,timeinfo.univer_time};

+	int time_zone = 0;

+	

+    cfg_get_item("sntp_time_set_mode", mode, sizeof(mode));

+	if(strcmp(mode, "manual") == 0)

+	{

+		at_print(AT_ERR,"zmmi_auto_act: do not need to nitz \n");

+		return AT_END;

+	}

+	parse_param2("%d,%d,%256s,%256s,%64s", at_paras, p);

+	time_zone = timeinfo.time_zone;// / 4;time_zoneµÄ¼ÆË㷽ʽ²»¶Ô£¬Èç¹ûÊ±ÇøÊÇ+22µÄ»°£¬¾Í»á¶ªÊ§0.5£¬¸Äµ½ÏÂÃæ³ý

+	set_tm.tm_isdst = timeinfo.sav_time;

+	if(0 == strlen(timeinfo.univer_time))

+	{

+		at_print(AT_ERR,"zmmi_auto_act,univer_time invalid");

+		return AT_END;

+	}

+	sscanf(timeinfo.univer_time,"%2d/%2d/%2d,%2d:%2d:%2d",&set_tm.tm_year,

+		&set_tm.tm_mon,&set_tm.tm_mday,&set_tm.tm_hour,&set_tm.tm_min,&set_tm.tm_sec);

+	

+	at_print(AT_ERR, "zmmi_auto_act, year:%d, month:%d, day:%d, hour:%d, min:%d, sec:%d, wday:%d \n", 

+		set_tm.tm_year, set_tm.tm_mon, set_tm.tm_mday, set_tm.tm_hour, set_tm.tm_min, set_tm.tm_sec, set_tm.tm_wday);

+

+	if(set_tm.tm_year < 0 || set_tm.tm_year > INT_MAX-1) // kw 3

+	{

+		set_tm.tm_year = 0;

+	}

+

+	if(set_tm.tm_mon < 0 || set_tm.tm_mon > INT_MAX-1)

+	{

+		set_tm.tm_mon = 0;

+	}

+

+		

+	set_tm.tm_year = set_tm.tm_year + 100;

+	set_tm.tm_mon = set_tm.tm_mon - 1;	

+

+	time_tv.tv_sec = mktime(&set_tm);

+	time_tv.tv_sec = time_tv.tv_sec +	time_zone * 3600 /4;

+		

+	

+	if (0 != settimeofday(&time_tv,NULL))

+	{

+		at_print(AT_ERR,"zmmi_auto_act,set time of system wrong");

+		return AT_END;

+	}

+	rtc_set_time(MODULE_ID_AT_CTL);

+	return AT_END;

+}

+

+char* normal_getsysconfigread()

+{

+    char *at_next=NULL;

+    at_next=malloc(AT_CMD_MAX);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,AT_CMD_MAX);

+    sprintf(at_next,"AT^SYSCONFIG?\r\n");

+	return at_next;

+}

+

+/***********atÃüÁî»ñÈ¡****************/

+//pin/pukÂëÊ£Óà´ÎÊý²éѯÃüÁî

+char* normal_getzrapread()

+{

+    char *at_next=NULL;

+    at_next=malloc(20);

+	if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,20);

+	sprintf(at_next,"AT+ZRAP?\r\n");

+	return at_next;

+}

+

+//pinÂë²éѯÃüÁî

+char* normal_getcpinread()

+{

+    char *at_next=NULL;

+    at_next=malloc(16);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,16);

+	sprintf(at_next,"AT+CPIN?\r\n");

+	return at_next;

+}

+

+//pinÂëÉèÖÃÃüÁî

+char* normal_getcpinset(char *pin)

+{

+    if(pin == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    char *at_next=NULL;

+    at_next=malloc(AT_CMD_MAX);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,AT_CMD_MAX);

+	sprintf(at_next,"AT+CPIN=\"%s\"\r\n",pin);

+	return at_next;

+}

+

+//½âpukÂëÃüÁî

+char* normal_getcpukset(char *puk,char *newpin)

+{

+    if(puk == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    char *at_next=NULL;

+    at_next=malloc(AT_CMD_MAX);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,AT_CMD_MAX);

+	sprintf(at_next,"AT+CPIN=\"%s\",\"%s\"\r\n",puk,newpin);

+	return at_next;

+}

+

+//IMEIºÅ»ñÈ¡ÃüÁî

+char* normal_getcgsn()

+{

+    char *at_next=NULL;

+    at_next=malloc(20);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,20);

+	sprintf(at_next,"AT+CGSN\r\n");

+	return at_next;

+}

+

+//ZICCID»ñÈ¡

+char* normal_getziccid()

+{

+    char *at_next=NULL;

+    at_next=malloc(AT_CMD_MAX);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,AT_CMD_MAX);

+	sprintf(at_next,"AT+ZICCID?\r\n");

+	return at_next;

+}

+

+//ÉèÖÃÓÐÏÞSIM¿¨·ÃÎÊ£¬µ±Ç°×÷ÓÃÖ÷ÒªÊÇ»ñÈ¡PLMNµÄλÊý

+char* normal_getcrsmset(char *param)

+{

+    if(param == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    char *at_next=NULL;

+    at_next=malloc(AT_CMD_MAX);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,AT_CMD_MAX);

+	sprintf(at_next,"AT+CRSM=%s\r\n",param);

+	return at_next;

+}

+

+//IMSIºÅ»ñÈ¡

+char* normal_getcimi()

+{

+    char *at_next=NULL;

+    at_next=malloc(20);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,20);

+	sprintf(at_next,"AT+CIMI\r\n");

+	return at_next;

+}

+

+//Óû§ºÅÂë»ñÈ¡£¬Ä¿Ç°·µ»ØµÄ¶àΪERROR

+char* normal_CnumRead()

+{

+    char *at_next=NULL;

+    at_next=malloc(AT_CMD_MAX);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,AT_CMD_MAX);

+	sprintf(at_next,"AT+CNUM\r\n");

+    if(AT_CMD_MAX <= strlen(at_next)){softap_assert("");}

+	return at_next;

+}

+

+/*¸ù¾Ýµ±Ç°NVÖµ,·µ»ØsysconfigÉèÖÃÃüÁî*/

+char* normal_getsysconfigset()

+{

+    char *at_next=NULL;

+    int mode = ZAT_SYSCONFIG_MODE_AUTO;

+    int acqorder = ZAT_SYSCONFIG_PREF_ACQ_AUTO;

+	int roam = 1;

+    normal_getsysconfigsetParam(&mode, &acqorder, &roam);

+    at_next=malloc(AT_CMD_MAX);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,AT_CMD_MAX);

+    sprintf(at_next,"AT^SYSCONFIG=%d,%d,%d,2\r\n", mode, acqorder, roam);

+	return at_next;

+}

+

+/*¸ù¾Ýµ±Ç°NVÖµ,·µ»Øcgdcont PDPÉÏÏÂÎÄÉèÖÃÃüÁî*/

+char* normal_getcgdcontset(int cid)

+{

+    char *at_next=NULL;

+    char strPdptype[10] = {0};

+    char strAPN[APN_MAX_LEN] = {0};

+    at_next=malloc(AT_CMD_MAX);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,AT_CMD_MAX);

+    at_print(AT_DEBUG,"normal_getcgdcontset cid=%d\n",cid);

+    //ÉèÖÃipv4v6µÄÖ§³Ö

+    cfg_get_item(NV_PDP_TYPE,strPdptype,sizeof(strPdptype));

+    cfg_get_item(NV_WAN_APN,strAPN,sizeof(strAPN)); 

+    if(strcmp("IPV6", strPdptype) == 0 || strcmp(strPdptype,"IPv6") == 0)

+    {

+        strncpy(strPdptype, "IPV6",sizeof(strPdptype)-1);

+        cfg_get_item(NV_IPV6_WAN_APN,strAPN,sizeof(strAPN)); 

+    }

+    else if(strcmp(strPdptype,"IPV4V6") == 0 || strcmp(strPdptype,"IPv4v6") == 0)

+    {

+        strncpy(strPdptype, "IPV4V6",sizeof(strPdptype)-1);

+        cfg_get_item(NV_IPV6_WAN_APN,strAPN,sizeof(strAPN)); 

+    }

+    sprintf(at_next,"AT+CGDCONT=%d,\"%s\",\"%s\"\r\n", cid, strPdptype, strAPN);

+    return at_next;

+}

+

+/*¸ù¾Ýµ±Ç°NVÖµ,·µ»Øzgpcoauth¼øÈ¨ÉèÖÃÃüÁî*/

+char* normal_getzgpcoauthset(int cid)

+{

+    char *at_next=NULL;

+    char strAuthtype[10]             = {0};

+    char strPdptype[20 ]  = {0};

+    char strUsename[PDP_AUTH_USER_PWD_LENGTH]  = {0};

+    char strPawd[PDP_AUTH_USER_PWD_LENGTH] = {0};

+    int auth_type = -1;

+    at_print(AT_DEBUG,"normal_getzgpcoauthset cid=%d\n",cid);

+

+    cfg_get_item(NV_PDP_TYPE,strPdptype,sizeof(strPdptype));

+    

+    if(strcmp("IPV6", strPdptype) == 0 || strcmp(strPdptype,"IPv6") == 0)

+    {

+        cfg_get_item(NV_IPV6_PPP_AUTH_MODE,strAuthtype,sizeof(strAuthtype));

+    	cfg_get_item(NV_IPV6_PPP_USERNAME,strUsename,sizeof(strUsename));

+    	cfg_get_item(NV_IPV6_PPP_PASSWD,strPawd,sizeof(strPawd));

+    

+    }

+    else if(strcmp(strPdptype,"IPV4V6") == 0 || strcmp(strPdptype,"IPv4v6") == 0)

+    {

+        cfg_get_item(NV_IPV6_PPP_AUTH_MODE,strAuthtype,sizeof(strAuthtype));

+    	cfg_get_item(NV_IPV6_PPP_USERNAME,strUsename,sizeof(strUsename));

+    	cfg_get_item(NV_IPV6_PPP_PASSWD,strPawd,sizeof(strPawd));

+    }

+    else 

+    {

+

+        cfg_get_item(NV_PPP_AUTH_MODE,strAuthtype,sizeof(strAuthtype));

+        cfg_get_item(NV_PPP_USERNAME,strUsename,sizeof(strUsename));

+        cfg_get_item(NV_PPP_PASSWD,strPawd,sizeof(strPawd));

+    }

+    auth_type = normal_getauthtype(strAuthtype);

+

+    at_next=malloc(AT_CMD_MAX);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,AT_CMD_MAX);

+    sprintf(at_next,"AT+ZGPCOAUTH=%d,\"%s\",\"%s\",%d\r\n", cid, strUsename, strPawd, auth_type);

+    return at_next;

+}

+

+

+char* normal_getcfunset(char *cmdtype)

+{

+    char *at_next=NULL;

+

+    at_next=malloc(128);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,128);

+    if(cmdtype != ZUFI_NULL)//ÅжÏÊÇ¿ªÉ䯵»¹ÊǽøÈë·ÉÐÐģʽ²Ù×÷

+    {  

+        if(memcmp(cmdtype, ZAT_POWEROFF, strlen(ZAT_POWEROFF)) == 0)

+        {

+            cfun_state=0;

+        }

+        else if(memcmp(cmdtype, ZAT_AIRMODE, strlen(ZAT_AIRMODE)) == 0)

+        {

+            cfun_state=4;

+			cfg_set(NV_NETWORK_TYPE, "No Service");

+			cfg_set(NV_SUB_NETWORK_TYPE, "No Service");

+        }

+        else

+        {

+            cfun_state=1;

+        }

+    }

+	else

+	{

+        cfun_state=1;	

+	}

+	if(cfun_state == 1)

+    {   	    

+	   	sprintf(at_next,"AT+ZSCHPLMN=1;+CFUN=%d\r\n",cfun_state);

+    }

+	else

+	    sprintf(at_next,"AT+CFUN=%d\r\n",cfun_state);

+	cfg_set("cfun_work", "work");

+	return at_next;

+}

+

+//ÉèÖÃCGREGÖ÷¶¯Éϱ¨

+char* normal_getcgregset(char *param)

+{

+    char *at_next=NULL;

+    at_next=malloc(AT_CMD_MAX);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,AT_CMD_MAX);

+	sprintf(at_next,"AT+CGREG=%s\r\n",param);

+	return at_next;

+}

+

+//ÉèÖÃCEREGÖ÷¶¯Éϱ¨

+char* normal_getceregset(char *param)

+{

+    char *at_next=NULL;

+    at_next=malloc(16);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,16);

+	sprintf(at_next,"AT+CEREG=%s\r\n",param);

+	return at_next;

+}

+

+//×Ô¶¯ËÑÍø»òÊÖ¶¯ËÑÍøÉèÖÃ

+char* normal_getcopsset(int paramnum,...)

+{

+    char *at_next=NULL;

+    at_next=malloc(AT_CMD_MAX);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,AT_CMD_MAX);

+    va_list ap;    

+    va_start(ap, paramnum);

+    if(paramnum==1)

+    {

+        sprintf(at_next,"AT+COPS=%s\r\n",va_arg(ap,char*));//ÉèÖÃÑ¡ÍøÄ£Ê½£¬Ò»°ã²ÎÊýÖÃΪ0£¬±íʾ×Ô¶¯ËÑÍø

+    }

+    else if(paramnum==2)

+    {

+        sprintf(at_next,"AT+COPS=1,2,\"%s\",%d\r\n",va_arg(ap,char*),va_arg(ap,int));//ÊÖ¶¯ËÑÍøÉèÖ㬲»Ð¯´ø×ÓÖÆÊ½

+    }

+    else if(paramnum==3)

+    {

+        sprintf(at_next,"AT+COPS=1,2,\"%s\",%d,%d\r\n",va_arg(ap,char*),va_arg(ap,int),va_arg(ap,int));	//ÊÖ¶¯ËÑÍøÉèÖã¬Ð¯´ø×ÓÖÆÊ½

+    }

+    else

+    {

+    	free(at_next);

+		va_end(ap);

+        return NULL;

+    }

+    va_end(ap);

+    at_print(AT_DEBUG,"normal_getcopsset %s!\n",at_next);

+    return at_next;

+}

+

+//ÊÖ¶¯ËÑÍøÊ±£¬»ñÈ¡µ±Ç°ÍøÂçÖдæÔÚµÄÔËÓªÉÌÁбí

+char* normal_getcopstest()

+{

+    char *at_next=NULL;

+    at_next=malloc(20);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,20);

+	sprintf(at_next,"AT+COPS=?\r\n");

+	return at_next;

+}

+

+//·µ»Øµ±Ç°µÄÍøÂçģʽ

+char* normal_getcopsread()

+{

+    char *at_next=NULL;

+    at_next=malloc(20);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,20);

+	sprintf(at_next,"AT+COPS?\r\n");

+	return at_next;

+}

+

+//²éѯÐźÅÇ¿¶È

+char* normal_getcsq()

+{

+    char *at_next=NULL;

+    at_next=malloc(20);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,20);

+	sprintf(at_next,"AT+CSQ\r\n");

+    cfg_set(NV_CSQ_DONE, "1");

+	return at_next;

+}

+

+//²éѯÈí¼þÄÚ²¿°æ±¾ºÅÃüÁî

+char* normal_getzversion()

+{

+    char *at_next=NULL;

+    at_next=malloc(20);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,20);

+	sprintf(at_next,"AT^ZVERSION\r\n");

+	return at_next;

+}

+

+//ÉèÖÃʱ¼äÃüÁî

+char* normal_getsyctimeset(long sec,long usec)

+{

+    char *at_next=NULL;

+    at_next=malloc(AT_CMD_MAX);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,AT_CMD_MAX);

+    sprintf(at_next,"AT+SYCTIME=%ld,%ld\r\n",sec,usec);

+    return at_next;

+}

+

+//ÉèÖÃmtnet²âÊÔÃüÁî

+char* normal_getmtnetset(char *mcc)

+{

+    char *at_next=NULL;

+	char mcc_list[256] = {0};

+	

+    cfg_get_item("mtnet_test_mcc", mcc_list, sizeof(mcc_list));

+    at_next=malloc(AT_CMD_MAX);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,AT_CMD_MAX);

+	if(strlen(mcc_list) > 3 && mcc && strlen(mcc) == 3 && strstr(mcc_list,mcc) != NULL)

+	{

+		sprintf(at_next,"AT+ZSET=\"MTNET_TEST\",1\r\n");

+	}

+	else

+	{

+		sprintf(at_next,"AT+ZSET=\"MTNET_TEST\",0\r\n");

+	}

+    return at_next;

+}

+

+//¶ÁÈ¡°åºÅ(Ŀǰ½á¹ûΪ¿Õ£¬ÊÇ·ñÊDZØÐëÃüÁî??)

+char* normal_getboardnumread()

+{

+    char *at_next=NULL;

+    at_next=malloc(20);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,20);

+	sprintf(at_next,"AT+BOARDNUM?\r\n");

+	return at_next;

+}

+

+//ϵͳÐÅÏ¢»ñÈ¡

+char* normal_getsysinfo()

+{

+    char *at_next=NULL;

+    at_next=malloc(20);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,20);

+	sprintf(at_next,"AT^SYSINFO\r\n");

+	return at_next;

+}

+

+//USSDÈ¡ÏûÃüÁî

+char* normal_getcusdset_clean()

+{

+    char *at_next=NULL;

+    at_next=malloc(20);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,20);

+	sprintf(at_next,"AT+CUSD=2\r\n");

+	return at_next;

+}

+

+//USSD·¢ËÍÃüÁî

+char* normal_getcusdset(char *param)

+{

+    char *at_next=NULL;

+    at_next=malloc(AT_CMD_MAX);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,AT_CMD_MAX);

+	sprintf(at_next,"AT+CUSD=1,\"%s\",15\r\n",param);

+	return at_next;

+}

+

+char* normal_getclckset(int paramnum,...)

+{

+    char *at_next=NULL;

+    at_next=malloc(AT_CMD_MAX);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,AT_CMD_MAX);

+    va_list ap;    

+    va_start(ap, paramnum);

+    if(paramnum==2)//²éѯµ±Ç°SIM¿¨×´Ì¬

+    {

+        sprintf(at_next,"AT+CLCK=\"%s\",%d\r\n",va_arg(ap,char*),va_arg(ap,int));

+    }

+    else if(paramnum==3)//¹Ø±Õ»òÕß´ò¿ªPINÂ빦ÄÜ

+    {

+        sprintf(at_next,"AT+CLCK=\"%s\",%d,\"%s\"\r\n",va_arg(ap,char*),va_arg(ap,int),va_arg(ap,char*));

+    }

+    else

+    {

+    	free(at_next);

+		va_end(ap);

+        return NULL;

+    }

+    va_end(ap);

+    return at_next;

+}

+

+char* normal_getcpwdset(char *type,char *oldPin,char *newPin)

+{

+    char *at_next=NULL;

+    at_next=malloc(AT_CMD_MAX);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,AT_CMD_MAX);

+	sprintf(at_next,"AT+CPWD=\"%s\",\"%s\",\"%s\"\r\n",type,oldPin,newPin);

+	return at_next;

+}

+

+char* normal_getmacread()

+{

+    char *at_next=NULL;

+    at_next=malloc(20);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,20);

+	sprintf(at_next,"AT+MAC?\r\n");

+	return at_next;

+}

+

+char* normal_getmac2read()

+{

+    char *at_next=NULL;

+    at_next=malloc(20);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,20);

+	sprintf(at_next,"AT+MAC2?\r\n");

+	return at_next;

+}

+

+//LTEËøÆµ,δʹÓÃ

+char *normal_getzltelcset()

+{

+    char *at_next=NULL;

+    T_zAt_ZltelcPara zltelcPara = {0};

+    char actionLte[30] = {0};

+    char uarfcnLte[30] = {0};

+    char cellPara[30] = {0};

+    at_next=malloc(AT_CMD_MAX);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,AT_CMD_MAX);

+    cfg_get_item(NV_ACTIONLTE,actionLte,sizeof(actionLte));

+    cfg_get_item(NV_UARFCNLTE,uarfcnLte,sizeof(uarfcnLte));

+	cfg_get_item(NV_CELLPARAIDLTE,cellPara,sizeof(cellPara));

+    zltelcPara.actionlte        = atoi(actionLte);

+    zltelcPara.uarfcnlte        = atoi(uarfcnLte);

+    zltelcPara.cellParaIdlte    = atoi(cellPara); 

+    sprintf(at_next,"AT+ZLTELC=%d,%d,%d\r\n", (int)zltelcPara.actionlte, (int)zltelcPara.uarfcnlte, (int)zltelcPara.cellParaIdlte); 

+    return at_next;

+}

+/***********atÃüÁî»ñÈ¡****************/

+//»ñÈ¡cidʱÐè´«Èëpdpsetinfo

+int normal_getcurparam(struct pdp_act_req *pdpsetinfo)

+{

+    char strPdptype[10] = {0};

+    char strAPN[APN_MAX_LEN] = {0};

+    //pdpsetinfo->pdp_type=PDP_NORMAL;

+    

+    cfg_get_item(NV_PDP_TYPE,strPdptype,sizeof(strPdptype));

+    cfg_get_item(NV_WAN_APN,strAPN,sizeof(strAPN)); 

+    if(strcmp("IPV6", strPdptype) == 0 || strcmp(strPdptype,"IPv6") == 0)

+    {

+        strncpy(strPdptype, "IPV6",sizeof(strPdptype)-1);

+        cfg_get_item(NV_IPV6_WAN_APN,strAPN,sizeof(strAPN)); 

+    }

+    else if(strcmp(strPdptype,"IPV4V6") == 0 || strcmp(strPdptype,"IPv4v6") == 0)

+    {

+        strncpy(strPdptype, "IPV4V6",sizeof(strPdptype)-1);

+        cfg_get_item(NV_IPV6_WAN_APN,strAPN,sizeof(strAPN)); 

+    }

+    strncpy(pdpsetinfo->comm_info.apn,strAPN,sizeof(pdpsetinfo->comm_info.apn)-1);

+    strncpy(pdpsetinfo->comm_info.ip_type,strPdptype,sizeof(pdpsetinfo->comm_info.ip_type)-1);

+    at_print(AT_DEBUG,"normal_getcurparam apn=%s,apntype=%s\n",pdpsetinfo->comm_info.apn,pdpsetinfo->comm_info.ip_type);

+    

+    char strAuthtype[10]             = {0};

+    char strUsename[PDP_AUTH_USER_PWD_LENGTH]  = {0};

+    char strPawd[PDP_AUTH_USER_PWD_LENGTH] = {0};

+    if(strcmp("IPV6", strPdptype) == 0 || strcmp(strPdptype,"IPv6") == 0)

+    {

+        cfg_get_item(NV_IPV6_PPP_AUTH_MODE,strAuthtype,sizeof(strAuthtype));

+        cfg_get_item(NV_IPV6_PPP_USERNAME,strUsename,sizeof(strUsename));

+        cfg_get_item(NV_IPV6_PPP_PASSWD,strPawd,sizeof(strPawd));

+        

+    }

+    else if(strcmp(strPdptype,"IPV4V6") == 0 || strcmp(strPdptype,"IPv4v6") == 0)

+    {

+        cfg_get_item(NV_IPV6_PPP_AUTH_MODE,strAuthtype,sizeof(strAuthtype));

+        cfg_get_item(NV_IPV6_PPP_USERNAME,strUsename,sizeof(strUsename));

+        cfg_get_item(NV_IPV6_PPP_PASSWD,strPawd,sizeof(strPawd));

+    }

+    else 

+    {

+        

+        cfg_get_item(NV_PPP_AUTH_MODE,strAuthtype,sizeof(strAuthtype));

+        cfg_get_item(NV_PPP_USERNAME,strUsename,sizeof(strUsename));

+        cfg_get_item(NV_PPP_PASSWD,strPawd,sizeof(strPawd));

+    }

+    pdpsetinfo->comm_info.auth_type = normal_getauthtype(strAuthtype);

+    strncpy(pdpsetinfo->comm_info.username,strUsename,sizeof(pdpsetinfo->comm_info.username)-1);

+    strncpy(pdpsetinfo->comm_info.password,strPawd,sizeof(pdpsetinfo->comm_info.password)-1);

+    at_print(AT_DEBUG,"normal_getcurparam authtype=%d,user=%s,psw=%s\n",pdpsetinfo->comm_info.auth_type,pdpsetinfo->comm_info.username,pdpsetinfo->comm_info.password);

+    return 0;

+}

+

+DbResult noraml_dbopen(char *filename, sqlite3**pDb)

+{

+	//zdm tosÁ¬½Ó²»¹ý

+	#if (APP_OS_TYPE == APP_OS_LINUX)

+    sqlite3* pTmpDb = NULL;

+    if(NULL == pDb)

+    {

+        at_print(AT_ERR,"noraml_dbopen:invalide inputs.");/*lint  !e26*/

+        return DB_ERROR_INVALIDPTR;

+    }

+    at_print(AT_DEBUG,"noraml_dbopen:sqlite3_open call");/*lint  !e26*/

+    if(sqlite3_open(filename, &pTmpDb))

+    {

+        at_print(AT_DEBUG,"noraml_dbopen:can not open db,sqlite3_errmsg:%s.",sqlite3_errmsg(pTmpDb));

+        (VOID) sqlite3_close(pTmpDb);

+        return DB_ERROR_NOTOPENDB;

+    }

+    *pDb = pTmpDb;

+	#else

+    softap_assert("");

+	#endif

+	

+    return DB_OK;

+}

+

+DbResult normal_dbclose(sqlite3 *pDb)

+{

+	#if (APP_OS_TYPE == APP_OS_LINUX)

+	

+    if(sqlite3_close(pDb))

+    {

+        at_print(AT_ERR,"normal_dbclose:can not close db");/*lint  !e26*/

+        return DB_ERROR;

+    }

+	#else

+		softap_assert("");

+	#endif

+    return DB_OK;

+}

+

+DbResult normal_execdbsql(char *filename, const char *pSql, sqlite3_callback callback,VOID *pFvarg)

+{

+    sqlite3 *pDb = NULL;

+    char dbErrMsg[128] = {0};

+	#if (APP_OS_TYPE == APP_OS_LINUX)

+    

+    if(DB_OK != noraml_dbopen(filename, &pDb))

+    {

+        at_print(AT_ERR,"normal_execdbsql:open pbm.db failed.");

+        return DB_ERROR_NOTOPENDB;

+    }

+    at_print(AT_DEBUG,"normal_execdbsql:atPb_ExecDbSql:%s\n",pSql);

+    if(sqlite3_exec(pDb,pSql,callback,pFvarg,NULL))

+    {

+        strncpy(dbErrMsg,sqlite3_errmsg(pDb),sizeof(dbErrMsg)-1);

+        at_print(AT_ERR,"normal_execdbsql:can not exec sql,sqlite3_errmsg:%s.",dbErrMsg);

+        (VOID)sqlite3_close(pDb);

+        return DB_ERROR;

+    }

+    (VOID)normal_dbclose(pDb);

+	#else

+		softap_assert("");

+	#endif

+    return DB_OK;

+}

+

+int normal_count_callback(void *fvarg,int line,char **zresult,char **lname)

+{

+	if(1 > line)

+	{

+		at_print(AT_DEBUG,"atBase:record no data.");

+		return -1;

+	}

+	*(int*)fvarg = atoi(zresult[0]);

+	return 0;

+}

+

+/*¸ù¾ÝÉ豸ÐͺźÍplmn,²éѯlocknet.db*/

+int normal_islocknetwhitelist(char *pmodel, char *pplmn)

+{

+    char sql[128] = {0};

+	int lcount = 0;

+    int result = DB_OK;

+    

+    snprintf(sql,128-1,"select count(*) from net_list where product_model=\'%s\' and plmn=\'%s\'", pmodel, pplmn);

+    result = normal_execdbsql(ZLOCKNET_DB_PATH, sql, normal_count_callback, &lcount);

+    if(DB_OK != result)

+    {

+        at_print(AT_DEBUG,"atBase_isLockNetWhiteList error:%d !\n", result); 

+        return -1;

+    }

+    if(lcount > 0)

+    {

+        at_print(AT_DEBUG,"atBase_isLockNetWhiteList succ:%d !\n", lcount); 

+		return 0;

+	}

+	at_print(AT_DEBUG,"atBase_isLockNetWhiteList not int list:%d, model:%s, plmn:%s !\n", lcount, pmodel, pplmn); 

+    return -1;

+}

+

+/*ËøÍø¼ì²â*/

+BOOL normal_locknetmatch(const char* mcc, const char* mnc)

+{

+	char plmn[LOCK_NET_PLMN_LEN] = {0};

+	char product_model[LOCK_NET_PLMN_LEN] = {0};

+	char useLockNet[10] = {0};

+	snprintf(plmn, LOCK_NET_PLMN_LEN-1, "%s%s", mcc, mnc);

+	cfg_get_item("product_model", product_model, sizeof(product_model));

+    cfg_get_item("use_lock_net", useLockNet, sizeof(useLockNet));

+	if(0 == strcmp("yes", useLockNet))

+	{

+		if(normal_islocknetwhitelist(product_model, plmn) == 0)

+		{

+			return TRUE;

+		}

+		return FALSE;

+	}

+	else

+	{

+		return TRUE;

+	}	

+}

+

+/*Ñ¡ÔñÓëwebui NVÅäÖÃÒ»ÖµÄsysconfig²ÎÊý*/

+int normal_getsysconfigsetParam(int *mode, int *acqOrder, int *roam)

+{

+    long  i                           = 0;

+    char    netSelect[20]  = {0};

+    char    modeSelect[20] = {0};

+    long  tableSize                   = sizeof(G_ZAT_SYSCONFIG_CFGPARA_SET)/sizeof(T_zAt_SysConfigParaSet);

+	char needTds[50] = {0};

+    char needGsm[50] = {0};

+    char roamSet[10] = {0};

+    

+    cfg_get_item(NV_NET_SELECT,netSelect,sizeof(netSelect));

+    cfg_get_item(NV_PRE_MODE,modeSelect,sizeof(modeSelect));

+    cfg_get_item(NV_NETWORK_NEED_TDS,needTds,sizeof(needTds));

+    cfg_get_item(NV_NETWORK_NEED_GSM,needGsm,sizeof(needGsm));

+    cfg_get_item(NV_ROAM_SETTING_OPTION,roamSet,sizeof(roamSet));

+	at_print(AT_DEBUG,"atBase_AtSysconfigSet:netSelect:%s! modeSelect:%s roamSet:%s.\n",netSelect,modeSelect,roamSet);

+    if(0 == strcmp(roamSet, "on"))

+	{

+		*roam = 1;

+	}

+	else if(0 == strcmp(roamSet, "off"))

+	{

+		*roam = 0;

+	}

+	else

+	{

+		*roam = 2;

+	}

+    if(0 == strcmp(netSelect, "NETWORK_auto"))  

+    {

+        if(0 == strcmp(modeSelect, "LTE_TD_pre"))

+        {

+            *mode       = ZAT_SYSCONFIG_MODE_GSM_TD_LTE;

+            *acqOrder   = ZAT_SYSCONFIG_PREF_ACQ_LTEPRE;

+            return TRUE;

+        }

+        else if(0 == strcmp(modeSelect, "TD_GSM_pre"))

+        {

+            *mode       = ZAT_SYSCONFIG_MODE_GSM_TD_LTE;

+            *acqOrder   = ZAT_SYSCONFIG_PREF_ACQ_TDPRE;

+            return TRUE;

+        }

+		else if(0 == strcmp(modeSelect, "")) 

+        {        	

+			char auto_acqorder[50] = {0};

+        	

+			cfg_get_item("auto_acqorder",auto_acqorder,sizeof(auto_acqorder));

+

+			//Óû§Ñ¡Ôñ×Ô¶¯ËÑÍø£¬Ê¹ÓÃNV±£´æµÄÍøÂç½ÓÈë´ÎÐò£¬¸ÃNVÓ¦ÔÚ°æ±¾¿ª»úµÚÒ»´Î±£´æÆðÀ´ÁË

+			if(0 == strlen(auto_acqorder))

+			{

+				//softap_assert("");

+				at_print(AT_ERR,"normal_getsysconfigsetParam auto_acqorder null\n");

+			}

+			*mode       = ZAT_SYSCONFIG_MODE_AUTO;

+            *acqOrder   = atoi(auto_acqorder);

+#if 0

+			if((strcmp("yes", needTds) == 0) && (strcmp("yes", needGsm) == 0))

+			{

+				*mode       = ZAT_SYSCONFIG_MODE_AUTO;

+                *acqOrder   = ZAT_SYSCONFIG_PREF_ACQ_AUTO;

+			}

+			else if(strcmp("yes", needGsm) == 0)

+			{

+				*mode       = ZAT_SYSCONFIG_MODE_W_GSM_LTE;

+                *acqOrder   = ZAT_SYSCONFIG_PREF_ACQ_AUTO;

+			}

+			else if(strcmp("yes", needTds) == 0)

+			{

+				*mode       = ZAT_SYSCONFIG_MODE_TD_W_LTE;

+                *acqOrder   = ZAT_SYSCONFIG_PREF_ACQ_AUTO;

+			}

+			else

+			{

+				*mode       = ZAT_SYSCONFIG_MODE_WCDMA_LTE;

+                *acqOrder   = ZAT_SYSCONFIG_PREF_ACQ_LTE_W_GSM;

+			}			

+            return TRUE;

+#endif

+        }

+        else

+        {

+            at_print(AT_DEBUG,"atBase_AtSysconfigSet Value Is not support!\n");

+            return FALSE;

+        }

+    }

+    else

+    {

+        for(i = 0; i < tableSize; i++)

+        {

+            if( 0 ==  strcmp(G_ZAT_SYSCONFIG_CFGPARA_SET[i].netselect, netSelect))

+            {

+                *mode       = G_ZAT_SYSCONFIG_CFGPARA_SET[i].modeValue;

+                *acqOrder   = G_ZAT_SYSCONFIG_CFGPARA_SET[i].acqOrder;

+                

+                at_print(AT_DEBUG,"atBase_AtSysconfigSet:mode:%d/acqOrder:%d.\n",*mode,*acqOrder);

+                return TRUE;

+            }

+        }

+        at_print(AT_DEBUG,"atBase_AtSysconfigSet Error\n");

+        return FALSE;

+    }

+	return FALSE;

+}

+

+int normal_getauthtype(char* pAuthType)

+{

+

+	if(strcmp(PDP_AUTH_TYPE_PAP, pAuthType) == 0 || strcmp("PAP", pAuthType) == 0)

+	{

+		return PAP_AUTH;

+	}

+	else if(strcmp(PDP_AUTH_TYPE_CHAP, pAuthType) == 0 || strcmp("CHAP", pAuthType) == 0)

+	{

+		return CHAP_AUTH;

+	}

+	else if(strcmp(PDP_AUTH_TYPE_PAP_CHAP, pAuthType) == 0)

+	{

+		return PAP_CHAP_AUTH;

+	}

+

+	return NONE_AUTH;

+}

+

+

+//10Ãë²é´ÎÐźţ¬pdpÖØ²¦Ê±ÑÓ0S,5S,10S,10S...

+VOID  *normal_pdptimeractstart(VOID *arg)

+{

+    static UINT32  iCount = 0;

+    iCount++;

+    if(iCount%10 == 0)

+    {

+        char csqDone[50]={0};

+        char networkType[50]={0};

+        cfg_get_item(NV_CSQ_DONE,csqDone,sizeof(csqDone));

+        cfg_get_item(NV_NETWORK_TYPE,networkType,sizeof(networkType));

+        if(0==strcmp("1",csqDone)&&strcmp("No Service",networkType))

+        {   

+            cfg_set(NV_CSQ_DONE, "0");

+            if(0!=ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_AT_CTL,MSG_CMD_QUERY_CSQ_REQ, 0, NULL,04000))

+            {

+                cfg_set(NV_CSQ_DONE, "1");

+            }

+        }	

+    }

+    return ZUFI_NULL;

+}

+

+void normal_cfunOkSet()

+{

+#if(APP_OS_TYPE == APP_OS_TOS)

+	softap_assert("");

+#else 

+    /*´´½¨¶¨Ê±PDPÔÚÏß¶¨Ê±Æ÷*/

+    CreateSoftTimer(PdpTimerID,

+                        TIMER_FLAG_RESTART,

+                        PdpTimer_INTERVAL,

+                        normal_pdptimeractstart,

+                        NULL);

+#endif   

+}

+

+void* normal_copstimeractstart(VOID *arg)

+{

+    static UINT32  iCount = 0;

+    iCount++;

+    if(iCount>=2)

+    {

+        at_print(AT_DEBUG,"normal_copstimeractstart Timeout!\n");

+        struct at_context * context = context_head[NEAR_PS];

+        char at_str[AT_CMD_MAX]="AT\r\n";//¸ù¾Ýmsg_bufÉú³ÉatÖжÏÃüÁÍõÕ׷ḺÔð

+        for(;context;context = context->next)

+        {

+            if(context->context_type == AT_CLIENT && 0 == at_strcmp(context->at_cmd_prefix,"COPS=?"))

+            {

+                at_print(AT_DEBUG,"normal_copstimeractstart write AT!\n");

+                write(context->at_channel->at_fd,at_str, strlen(at_str));//for cov ¶¨Ê±Æ÷Àï²»ÄÜÓÐsleep

+                //at_write(context->at_channel->at_fd,at_str, strlen(at_str));//·¢ËÍÖÕÖ¹at£¬ÍõÕ׷ḺÔðÌîд¾ßÌåµÄat_stlÈ¡ÏûÃüÁî

+            }

+        }

+        iCount=0;

+    }

+    cfg_set(NV_NET_NUM, "0");

+    cfg_set(NV_M_NETSELECT_STATUS, "manual_search_fail");

+    return 0;

+}

+

+void normal_copstest_timerout(void *msg)

+{

+	//zdm º¯Êý¼´Ê¹²»²ÎÓëµ÷Óã¬Ò²»áÁ¬½Ó²»¹ý£¬ÐèÒªÇëÖ§³Ö°ïæ½â¾ö

+	#if (APP_OS_TYPE == APP_OS_LINUX)

+    /*AT+COPS=?¶¨Ê±Æ÷*/

+    CreateSoftTimer(CopstestTimerID,

+                        TIMER_FLAG_RESTART,

+                        CopstestTimer_INTERVAL,

+                        normal_copstimeractstart,

+                        NULL);

+	#endif

+}

+

+void normal_getsignalbarinfo(T_zAt_SignalBarInfo* signalBarInfo, T_zAt_SignalBar_Type signalBarType)

+{

+	UINT8 tableSize = 0;

+	int i, prefixIndex = -1;

+	char signalBarName[30] = {0};

+	int signalBarVal[SIGNALBAR_NUM_MAX] = {0};

+	char strSigbar[10] = { 0 };	

+	       

+	prefixIndex = (int)	signalBarType; 	

+	tableSize = sizeof(suffixSignalBarNV) / 20;

+    at_print(AT_DEBUG,"atBase_GetSignalBarInfo enter, tableSize = %d, prefixIndex = %d!\n", tableSize, prefixIndex); 

+#if 0  // kw 3 UNREACH.RETURN  

+    if(tableSize > SIGNALBAR_NUM_MAX)

+	{

+		return;

+	}

+#endif    

+	for(i = 0; i < tableSize; i++)

+	{

+		memset(strSigbar, 0, 10);

+		memset(signalBarName, 0, 30);

+		snprintf(signalBarName, 30, "%s%s", prefixSignalBarNV[prefixIndex], suffixSignalBarNV[i]);	

+			    

+		cfg_get_item(signalBarName, strSigbar,sizeof(strSigbar));

+		if(strlen(strSigbar) > 0)

+		{

+			signalBarVal[i] = atoi(strSigbar);

+		}

+		else

+		{

+			signalBarVal[i] = -1;

+		}

+	}

+   signalBarInfo->signalbar0_low =  signalBarVal[0];

+   signalBarInfo->signalbar0_high = signalBarVal[1];

+   signalBarInfo->signalbar1_low =  signalBarVal[2];

+   signalBarInfo->signalbar1_high = signalBarVal[3];

+   signalBarInfo->signalbar2_low =  signalBarVal[4];

+   signalBarInfo->signalbar2_high = signalBarVal[5];

+   signalBarInfo->signalbar3_low =  signalBarVal[6];

+   signalBarInfo->signalbar3_high = signalBarVal[7];

+   signalBarInfo->signalbar4_low =  signalBarVal[8];

+   signalBarInfo->signalbar4_high = signalBarVal[9];

+   signalBarInfo->signalbar5_low =  signalBarVal[10];

+   signalBarInfo->signalbar5_high = signalBarVal[11];

+}

+

+/**

+**                 RSSI < - 115dBm     1¸ñ(0-25)

+**  -115dBm <= RSSI < -108 dBm   2¸ñ(26-32)

+**  -108dBm <= RSSI < -102 dBm   3¸ñ(33-38)    

+**  -102dBm <= RSSI < -96 dBm     4¸ñ(39-44)    

+**  -96dBm <= RSSI                      5¸ñ(>=45)    

+**  

+**/

+void normal_calcltesignalbar(long rssi)

+{

+	T_zAt_SignalBarInfo signalBarInfo = {0};

+	normal_getsignalbarinfo(&signalBarInfo, ZAT_SIGNALBAR_TYPE_LTE);

+    printf("atBase_CalcLteSignalBar: %d <= sigbar0 <= %d, %d <= sigbar1 <= %d, %d <= sigbar2 <= %d, %d <= sigbar3 <= %d,%d <= sigbar4 <= %d, %d <= sigbar5 <= %d,!\n", \

+		         signalBarInfo.signalbar0_low, signalBarInfo.signalbar0_high, signalBarInfo.signalbar1_low, signalBarInfo.signalbar1_high,signalBarInfo.signalbar2_low, \

+				 signalBarInfo.signalbar2_high,signalBarInfo.signalbar3_low,signalBarInfo.signalbar3_high,signalBarInfo.signalbar4_low, signalBarInfo.signalbar4_high, \

+		         signalBarInfo.signalbar5_low, signalBarInfo.signalbar5_high); 

+	if((rssi >= signalBarInfo.signalbar0_low) && (rssi <= signalBarInfo.signalbar0_high))

+    {

+        cfg_set("signalbar", "0");

+    }

+	else if((rssi >= signalBarInfo.signalbar1_low) && (rssi <= signalBarInfo.signalbar1_high))

+    {

+        cfg_set("signalbar", "1");

+    }

+    else if((rssi >= signalBarInfo.signalbar2_low) && (rssi <= signalBarInfo.signalbar2_high))

+    {

+        cfg_set("signalbar", "2");

+    }

+    else if((rssi >= signalBarInfo.signalbar3_low) && (rssi <= signalBarInfo.signalbar3_high))

+    {

+        cfg_set("signalbar", "3");

+    }

+    else if((rssi >= signalBarInfo.signalbar4_low) && (rssi <= signalBarInfo.signalbar4_high))

+    {

+        cfg_set("signalbar", "4");

+    }

+	else if(rssi==99)

+    {

+        normal_calcunknowsignalbar();	

+        return;

+    }		

+    else

+    {

+        cfg_set("signalbar", "5");

+    }   

+}

+

+/**

+**            RSSI <= -110dBm   0¸ñ(0-6)

+**  -110dBm < RSSI <= -104 dBm  1¸ñ(7-12)

+**  -104dBm < RSSI <= -98 dBm   2¸ñ(13-18)    

+**  -98dBm < RSSI <= -90 dBm    3¸ñ(19-26)    

+**  -90dBm < RSSI <= -80 dBm    4¸ñ(27-36)    

+**  -80dBm < RSSI               5¸ñ(>=37   )

+**/

+void normal_calctdsignalbar(long rssi)

+{

+	T_zAt_SignalBarInfo signalBarInfo = {0};

+	normal_getsignalbarinfo(&signalBarInfo, ZAT_SIGNALBAR_TYPE_TDS);

+    printf("atBase_CalcTdSignalBar: %d <= sigbar0 <= %d, %d <= sigbar1 <= %d, %d <= sigbar2 <= %d, %d <= sigbar3 <= %d,%d <= sigbar4 <= %d, %d <= sigbar5 <= %d!\n", \

+		         signalBarInfo.signalbar0_low, signalBarInfo.signalbar0_high, signalBarInfo.signalbar1_low, signalBarInfo.signalbar1_high,signalBarInfo.signalbar2_low, \

+				 signalBarInfo.signalbar2_high,signalBarInfo.signalbar3_low,signalBarInfo.signalbar3_high,signalBarInfo.signalbar4_low, signalBarInfo.signalbar4_high, \

+		         signalBarInfo.signalbar5_low, signalBarInfo.signalbar5_high); 

+	if((rssi >= signalBarInfo.signalbar0_low) && (rssi <= signalBarInfo.signalbar0_high))

+    {

+        cfg_set("signalbar", "0");

+    }

+	else if((rssi >= signalBarInfo.signalbar1_low) && (rssi <= signalBarInfo.signalbar1_high))

+    {

+        cfg_set("signalbar", "1");

+    }

+    else if((rssi >= signalBarInfo.signalbar2_low) && (rssi <= signalBarInfo.signalbar2_high))

+    {

+        cfg_set("signalbar", "2");

+    }

+    else if((rssi >= signalBarInfo.signalbar3_low) && (rssi <= signalBarInfo.signalbar3_high))

+    {

+        cfg_set("signalbar", "3");

+    }

+    else if((rssi >= signalBarInfo.signalbar4_low) && (rssi <= signalBarInfo.signalbar4_high))

+    {

+        cfg_set("signalbar", "4");

+    }

+	else if(rssi==99)

+    {

+        normal_calcunknowsignalbar();	

+        return;

+    }

+    else

+    {

+        cfg_set("signalbar", "5");

+    }  

+}

+

+/**

+**                 RSSI <= -110dBm   0¸ñ(0-1)

+**  -110dBm < RSSI <= -104 dBm  1¸ñ(2-4)

+**  -104dBm < RSSI <= -98 dBm   2¸ñ(5-7)    

+**  -98dBm < RSSI <= -90 dBm    3¸ñ(8-11)    

+**  -90dBm < RSSI <= -80 dBm    4¸ñ(12-16)    

+**  -80dBm < RSSI               5¸ñ(>=17   )

+**/

+void normal_calcothersignalbar(long rssi)

+{

+	T_zAt_SignalBarInfo signalBarInfo = {0};

+

+	normal_getsignalbarinfo(&signalBarInfo, ZAT_SIGNALBAR_TYPE_GSM);

+    printf("atBase_CalcOtherSignalBar: %d <= sigbar0 <= %d, %d <= sigbar1 <= %d, %d <= sigbar2 <= %d, %d <= sigbar3 <= %d,%d <= sigbar4 <= %d, %d <= sigbar5 <= %d,!\n", \

+		         signalBarInfo.signalbar0_low, signalBarInfo.signalbar0_high, signalBarInfo.signalbar1_low, signalBarInfo.signalbar1_high,signalBarInfo.signalbar2_low, \

+				 signalBarInfo.signalbar2_high,signalBarInfo.signalbar3_low,signalBarInfo.signalbar3_high,signalBarInfo.signalbar4_low, signalBarInfo.signalbar4_high, \

+		         signalBarInfo.signalbar5_low, signalBarInfo.signalbar5_high); 

+    if(rssi==99)

+    {

+		normal_calcunknowsignalbar();			

+        return;

+    }

+	if((rssi >= signalBarInfo.signalbar0_low) && (rssi <= signalBarInfo.signalbar0_high))

+    {

+        cfg_set("signalbar", "0");

+    }

+	else if((rssi >= signalBarInfo.signalbar1_low) && (rssi <= signalBarInfo.signalbar1_high))

+    {

+        cfg_set("signalbar", "1");

+    }

+    else if((rssi >= signalBarInfo.signalbar2_low) && (rssi <= signalBarInfo.signalbar2_high))

+    {

+        cfg_set("signalbar", "2");

+    }

+    else if((rssi >= signalBarInfo.signalbar3_low) && (rssi <= signalBarInfo.signalbar3_high))

+    {

+        cfg_set("signalbar", "3");

+    }

+    else if((rssi >= signalBarInfo.signalbar4_low) && (rssi <= signalBarInfo.signalbar4_high))

+    {

+        cfg_set("signalbar", "4");

+    }

+    else if((rssi>=signalBarInfo.signalbar5_low) && (rssi<=signalBarInfo.signalbar5_high))

+    {

+        cfg_set("signalbar", "5");

+    }

+}

+

+void normal_calcunknowsignalbar(void)

+{

+    char signalbar_99[30] = {0};

+    char netType[50]={0};

+    cfg_get_item(NV_NETWORK_TYPE,netType,sizeof(netType));

+    cfg_get_item("signalbar_99", signalbar_99,sizeof(signalbar_99));

+    if(strcmp("0", signalbar_99) == 0)

+    {

+        cfg_set("signalbar", "0");

+    }

+    else if (g_zUfi_firstCsq

+            &&0!=strcmp("No Service",netType)

+            &&0!=strcmp("Limited Service",netType)

+            &&0!=strcmp(NETWORK_TYPE_INIT,netType))

+    {

+        cfg_set("signalbar", "3");

+    }

+}

+

+void normal_calcsignalbar(T_zAt_SignalBar_Type signalBarType)

+{	

+    char netType[30] = {0};

+    char strRssi[30] = { 0 };

+    long  csq  = 0;

+    at_print(AT_DEBUG,"normal_calcsignalbar!\n");

+    UINT32 signalbar = 0;

+    char oldSignalbar[10] = {0};

+    char newSignalbar[10] = {0};

+    cfg_get_item("signalbar",oldSignalbar,sizeof(oldSignalbar));

+    at_print(AT_DEBUG,"oldSignalbar=%s!\n",oldSignalbar);

+    

+    cfg_get_item("csq",strRssi,sizeof(strRssi));

+    csq = atoi(strRssi);

+	if(csq < 0 || csq > INT_MAX-1) // kw 3

+	{

+	    csq = 0;

+	}

+    cfg_get_item("network_type",netType,sizeof(netType));

+    if(signalBarType == ZAT_SIGNALBAR_TYPE_LTE)

+    {

+        normal_calcltesignalbar(csq - 100);

+    }

+    else if(signalBarType == ZAT_SIGNALBAR_TYPE_WCDMA)

+    {

+        normal_calctdsignalbar(csq - 100);

+    }

+    else if(signalBarType == ZAT_SIGNALBAR_TYPE_TDS)

+    {

+        normal_calctdsignalbar(csq - 100);

+    }

+    else if(signalBarType == ZAT_SIGNALBAR_TYPE_GSM)

+    {

+        normal_calcothersignalbar(csq);

+    }

+    else if(signalBarType == ZAT_SIGNALBAR_TYPE_NONE)

+    {

+        if(csq == 99 || csq == 199)

+        {

+            normal_calcunknowsignalbar();	

+        }

+    }

+    cfg_get_item("signalbar",newSignalbar,sizeof(newSignalbar));

+    at_print(AT_DEBUG,"newSignalbar=%s!\n",newSignalbar);

+    if(strcmp(newSignalbar, oldSignalbar))

+    {

+        signalbar = atoi(newSignalbar);

+    	if(signalbar > UINT_MAX-1)  // kw 3 cov M

+    	{

+    	    signalbar = UINT_MAX;

+    	}		

+        int result = ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_MMI,MSG_CMD_OUT_REG_GET_SIGNAL_NUM, sizeof(signalbar), (UINT8 *)&signalbar,0);

+        at_print(AT_DEBUG,"normal_calcsignalbar %d!\n", result);

+    }

+}

+

+void normal_calcltesignalstrength(long rssi)

+{

+	CHAR rssi_buf[20] = {0};

+	int dbm_val = 0;

+	if(0 == rssi)

+    {

+        snprintf(rssi_buf, 20, "%s", "<-140");		

+    }

+	else if(97 == rssi)

+	{

+		snprintf(rssi_buf, 20, "%s", ">=-44");

+	}

+	else if(99 == rssi)

+	{

+       return;

+	}

+	else if((rssi > 0) && (rssi < 97))

+	{

+		dbm_val = 141 - rssi;

+		snprintf(rssi_buf, 20, "-%d", dbm_val);

+	}

+	cfg_set("lte_rsrp", rssi_buf);

+	cfg_set("rssi", rssi_buf);

+}

+

+void normal_calctdsignalstrength(long rssi)

+{

+	char rssi_buf[20] = {0};

+	int dbm_val = 0;

+	if(0 == rssi)

+    {

+        snprintf(rssi_buf, 20, "%s", "<-115");		

+    }

+	else if(91 == rssi)

+	{

+		snprintf(rssi_buf, 20, "%s", ">=-25");

+	}

+	else if(99 == rssi)

+	{

+       return;

+	}

+	else if((rssi > 0) && (rssi < 91))

+	{

+		dbm_val = 116 - rssi;

+		snprintf(rssi_buf, 20, "-%d", dbm_val);

+	}

+	cfg_set("rscp", rssi_buf);

+	cfg_set("rssi", rssi_buf);

+	cfg_set("lte_rsrp", "");

+}

+

+void normal_calcothersignalstrength(long rssi)

+{

+	char rssi_buf[20] = {0};

+	int dbm_val = 0;

+	if(0 == rssi)

+    {

+        snprintf(rssi_buf, 20, "%s", "<=-113");		

+    }

+	else if(31 == rssi)

+	{

+		snprintf(rssi_buf, 20, "%s", ">=-51");

+	}

+	else if(99 == rssi)

+	{

+       return;

+	}

+	else if((rssi > 0) && (rssi < 31))

+	{

+		dbm_val = 113 - 2*rssi;

+		snprintf(rssi_buf, 20, "-%d", dbm_val);

+	}

+	cfg_set("rssi", rssi_buf);

+	cfg_set("lte_rsrp", "");

+}

+

+void normal_calcsignalstrength(T_zAt_SignalBar_Type signalBarType, long  rssi)

+{	

+	if(signalBarType == ZAT_SIGNALBAR_TYPE_LTE)

+	{

+		normal_calcltesignalstrength(rssi - 100);

+	}

+    else if((signalBarType == ZAT_SIGNALBAR_TYPE_WCDMA) || (signalBarType == ZAT_SIGNALBAR_TYPE_TDS))

+    {

+        normal_calctdsignalstrength(rssi - 100);

+	}

+	else if(signalBarType == ZAT_SIGNALBAR_TYPE_GSM)

+	{

+		normal_calcothersignalstrength(rssi);

+	}

+}

+

+VOID normal_sysinfosysmodecfgset(long sysModeIn, long sysSubModeIn)

+{

+    UINT32 i            =   0;

+    UINT32 tableSize = sizeof(G_ZAT_SYSINFO_SET_NETTYPE)/sizeof(T_zAt_SysInfoSetNetType);

+

+	for(i = 0; i < tableSize; i++)

+    {

+        if(G_ZAT_SYSINFO_SET_NETTYPE[i].sysmode == sysModeIn)

+        {

+            cfg_set(NV_NETWORK_TYPE,G_ZAT_SYSINFO_SET_NETTYPE[i].netType);

+        }

+    }

+	

+	tableSize = sizeof(G_ZAT_SYSINFO_SET_SUBNETTYPE)/sizeof(T_zAt_SysInfoSetNetType);

+	for(i = 0; i < tableSize; i++)

+    {

+        if(G_ZAT_SYSINFO_SET_SUBNETTYPE[i].sysmode == sysSubModeIn)

+        {

+            cfg_set(NV_SUB_NETWORK_TYPE,G_ZAT_SYSINFO_SET_SUBNETTYPE[i].netType);

+        }

+    }

+	

+	return;

+}

+

+VOID normal_sysinfonetworktypeSet(long sysMode,long sysSubmode)

+{

+    UINT32 i            =   0;

+    UINT32 tableSize = sizeof(G_ZAT_SYSINFO_CMCC_NETTYPE)/sizeof(T_zAt_SysInfoSetNetType);

+    if(sysMode==ZAT_SYSINFORES_SYSMODE_GSM && sysSubmode==3)

+    {

+        cfg_set(NV_NETWORK_TYPE,"E");

+        return;

+    }

+    for(i = 0; i < tableSize; i++)

+    {

+        if(G_ZAT_SYSINFO_CMCC_NETTYPE[i].sysmode == sysMode)

+        {

+            cfg_set(NV_NETWORK_TYPE,G_ZAT_SYSINFO_CMCC_NETTYPE[i].netType);

+        }

+    }

+}

+

+long normal_isroam(char *sim_plmn, char *net_plmn)

+{

+    char sql[128] = {0};

+	int lcount = 0;

+    int result = DB_OK;

+	

+    if(ZUFI_NULL == sim_plmn || ZUFI_NULL == net_plmn)

+    {

+		at_print(AT_DEBUG,"atBase_IsRoam paraments error !\n"); 

+        return -1;

+    }

+

+    snprintf(sql,128-1,"select count(*) from roam_list where sim_plmn=\'%s\' and net_plmn=\'%s\'", sim_plmn, net_plmn);

+    result = normal_execdbsql(ZROAM_DB_PATH, sql, normal_count_callback, &lcount);

+    if(DB_OK != result)

+    {

+        at_print(AT_DEBUG,"atBase_IsRoam error:%d !\n", result); 

+        return -1;

+    }

+    if(lcount > 0)

+    {

+        at_print(AT_DEBUG,"atBase_IsRoam succ:%d !\n", lcount); 

+		return 0;

+	}

+	at_print(AT_DEBUG,"atBase_IsRoam not int list:%d, sim_plmn:%s, net_plmn:%s !\n", lcount, sim_plmn, net_plmn); 

+    return -1;

+}

+

+BOOL normal_checkroam(const char* mcc, const char* mnc)

+{

+    char imcc[10] = {0};

+    char imnc[10] = {0};

+	char checkRoam[10] = {0};

+	char sim_plmn[10] = {0};

+	char net_plmn[10] = {0};

+

+    cfg_get_item("check_roam", checkRoam,sizeof(checkRoam));

+	cfg_get_item("mcc", imcc,sizeof(imcc));

+	cfg_get_item("mnc", imnc,sizeof(imnc));

+	if(0 == strcmp("yes", checkRoam))

+	{

+	    snprintf(sim_plmn, 10-1, "%s%s", mcc, mnc);

+	    snprintf(net_plmn, 10-1, "%s%s", imcc, imnc);

+		

+		if(normal_isroam(sim_plmn, net_plmn) == 0)

+		{

+			return TRUE;

+		}

+

+		return FALSE;

+	}

+	else

+	{

+		return FALSE;

+	}	

+

+}

+

+VOID normal_simcardcfgreset()

+{

+	cfg_set(NV_MODEM_MAIN_STATE,"modem_sim_undetected");

+    cfg_set("lte_pci", "");

+	cfg_set("lte_earfcn", "");

+	cfg_set("lte_rsrp", "");

+	cfg_set("lte_sinr", "");

+	cfg_set("sim_zpbic_status","no_card");

+	cfg_set(NV_MSISDN,"");

+	cfg_set(NV_SIMCARD_TYPE,"");

+	cfg_set(NV_IMEI, "");

+	cfg_set(NV_OPER_NUM, "");

+	cfg_set(NV_PDP_STATUS, "0");

+    cfg_set(NV_NETWORK_PROVIDER, "");

+    cfg_set(NV_NETWORK_TYPE, "");

+	cfg_set(NV_SUB_NETWORK_TYPE, "");

+    cfg_set(NV_SIMCARD_ROAM, "");

+    cfg_set(NV_CSQ, "");

+    cfg_set(NV_RSSI, "");

+    cfg_set(NV_ECIO, "");

+    cfg_set(NV_LAC_CODE,"");

+    cfg_set(NV_CELL_ID,"");

+    cfg_set(NV_WAN_IPADDR, "0.0.0.0");

+    cfg_set(NV_WAN_NETMASK,"0.0.0.0");

+    cfg_set(NV_WAN_GATEWAY,"0.0.0.0");

+    cfg_set(NV_PREFER_DNS_AUTO, "0.0.0.0");

+    cfg_set(NV_STANDBY_DNS_AUTO, "0.0.0.0");

+    cfg_set(NV_SIM_PIN, "0");

+    cfg_set(NV_SIM_PUK, "0");

+    cfg_set(NV_PIN_MANAGE_RESULT,"");

+    cfg_set(NV_PINNUMBER,"3");

+    cfg_set(NV_PUKNUMBER,"10");

+    cfg_set(NV_PIN_STATUS,"");

+    cfg_set(NV_PIN_PUK_PROCESS,"");

+    cfg_set(NV_PIN_MANAGE_PROCESS,"");

+    cfg_set(NV_UNLOCK_AT_WAIT,"0");

+    cfg_set(NV_SIM_SPN,"");

+    cfg_set(NV_SEND_PIN_FLAG,"0"); //0:±íʾ±£´æµÄPINÂëûÓз¢ËÍ  £¬1±íʾÒѾ­·¢ËÍ

+    cfg_set(NV_MCC,"");

+    cfg_set(NV_MNC,"");

+    cfg_set(NV_LOCK_UI,"" );

+    cfg_set(NV_ACTION,"");

+    cfg_set(NV_UARFCN,"");

+    cfg_set(NV_CELLPARAID,"");

+    cfg_set(NV_BANDLOCKSET,"");

+    cfg_set(NV_BANDLOCKSTATE,"UnLocked");

+    cfg_set(NV_PPP_DIAL,"");

+    cfg_set(NV_ZCELL_RESULT,"");

+    cfg_set(NV_ZCONSTAT_UP_RESULT, "");

+    cfg_set(NV_CGATT_SET_RESULT, "");

+    cfg_set(NV_ZGIPDNS_RESULT_DEFAULTCID,"0");

+    cfg_set(NV_ZGIPDNS_RESULT_PPPDCID,"0");

+	cfg_set(NV_ZGACT_RESULT_DEFAULTCID,"0");

+	cfg_set(NV_ZGACT_RESULT_PPPDCID,"0");

+    cfg_set(NV_RESETMODEM,"");

+    cfg_set(NV_SIGNALBAR,"");// ÇåÁ㣬·ÀÖ¹²»²åsim¿¨ÖØÆôºó»¹ÓÐÐźŸñÊý

+    //cfg_set(NV_AUTO_RECONNECT,"");//·ÀÖ¹×Ô¶¯²¦ºÅʧ°Ü

+    cfg_set(NV_IPV6_WAN_IPADDR,"");

+    cfg_set(NV_IPV6_WAN_DEFAULT_GW_ADDR,"");

+    cfg_set(NV_IPV6_PREFER_DNS_AUTO,"");

+    cfg_set(NV_IPV6_STANDBY_DNS_AUTO,"");

+    cfg_set(NV_CFUN_STATE,"1");

+    cfg_set(NV_CSQ_DONE, "1");

+    //cfg_set(NV_SD_CARD_STATE,"0");	

+    cfg_set(NV_SIM_IMSI, "");

+    cfg_set(NV_SIM_ICCID,"");

+	cfg_set(NV_ZICCID,"");

+    cfg_set(NV_M_NETSELECT_MODE, "0");

+    cfg_set(NV_SYS_MODE, "");

+    cfg_set(NV_SYS_SUBMODE, "");

+    cfg_set(NV_DAIL_STEP, "1");

+

+    cfg_set(LOCK_CELL_STATE_FLAG, "0");

+    cfg_set("ussd_cancel_flag","no");//ussd

+	

+}

+

+char *normal_findsubstr(const char *pStr, const char *pSubStr)

+{

+    long  i = 0;

+    long  flg = 0;

+    long  nLengthStr = 0;

+    long  nLengthSubStr = 0;

+    const char *pchTemp = ZUFI_NULL;

+    

+    /* È¡µÃÁ½¸ö×Ö·û´®µÄ³¤¶È */

+    nLengthStr      = (long)strlen(pStr);

+    nLengthSubStr   = (long)strlen(pSubStr);

+    if (nLengthStr < nLengthSubStr)

+    {

+        return NULL;

+    }

+    pchTemp = pStr;

+    /* ¿ªÊ¼²éÕÒ */

+    for (i = 0; i <= nLengthStr - nLengthSubStr; i++)

+    {

+        if ('"' == *pchTemp)

+        {

+            if (0 == flg)

+            {

+                flg = 1;

+            }

+            else

+            {

+                flg = 0;

+            }

+        }

+        if ((*pchTemp == *pSubStr) && (0 == flg))

+        {

+            if (0 == at_strncmp(pchTemp, pSubStr, (UINT32)nLengthSubStr))

+            {

+                return (char *) pchTemp;

+            }

+        }

+        pchTemp++;

+    }

+    return NULL;

+}

+

+/*Ô¤´¦Àí*/

+VOID normal_preprocresparalineex(char *pParaLine,int paraSize)

+{

+    UINT32 i = 0;

+    UINT32 length = 0;

+    char *pSource = ZUFI_NULL;

+    char *pDest = ZUFI_NULL;

+    char strDestLine[AT_CMD_MAX] = {0};

+	

+    if (AT_CMD_MAX <= strlen(pParaLine)) /* ²ÎÊý¼ì²é ¡¢³¤¶È¼ì²é*/

+    {

+    	softap_assert("");

+        return;

+    }

+	if(0 == strlen(pParaLine))

+		return;

+    length = (UINT32)strlen(pParaLine);

+    pSource = pParaLine;                /* Ñ­»·´¦Àí */

+    pDest = strDestLine;

+    for (i = 0; i < length; i++)

+    {

+        if ('(' == *pSource)

+        {

+            ;                           /* ×óÀ¨»¡ ɾ³ý */

+        }

+        else if (')' == *pSource)

+        {

+            if (',' == *(pSource + 1))  /* ÓÒÀ¨»¡,ÅжϽô¸úÆäºóµÄÊÇ·ñ¶ººÅ                    */

+            {

+                pSource++;              /* ÊǶººÅ£¬É¾³ýÓÒÀ¨»¡²¢ÔÚÄ¿µÄ´®Öн«¶ººÅת»»Îª·ÖºÅ   */

+                *pDest = ';';

+                pDest++;

+            }

+        }

+        else

+        {

+            *pDest = *pSource;

+            pDest++;

+        }

+        pSource++;

+    }

+    /* ½«Ô¤´¦ÀíºóµÄÄÚÈÝ¿½±´»Ø²ÎÊýÐÐÖÐ */

+    memset(pParaLine, 0, paraSize);

+    strncpy(pParaLine, strDestLine,paraSize-1);

+}

+

+/*Ô¤´¦Àí*/

+void normal_preprocresparalist(T_zAt_RES_PARAS_LIST *pParaList, const char *pParas)

+{

+    long i = 0;

+    char *pHead = ZUFI_NULL;

+    char *pEnd = ZUFI_NULL;

+	

+	if(!at_strcmp(pParas, "OK"))

+	{

+		pParaList->listCount = 0;

+		return;

+	}

+	

+    /* Ñ­»·²éÕÒ';' */

+	

+    pHead = pEnd = (char *) pParas;

+    pEnd = normal_findsubstr(pHead, ";");

+    while (pEnd != ZUFI_NULL)

+    {

+        /* ÕÒµ½';' */

+        /* Ô½½ç±£»¤ */

+        if ((pParaList->listCount >= ZAT_RES_PARAM_MAX_NUM)

+            || (pEnd - pHead >= ZAT_RES_PARAM_MAX_LEN))

+        {

+            return;

+        }

+        /* ¿½±´ÄÚÈÝ */

+        strncpy(pParaList->strParasLine[i], pHead, (UINT32)(pEnd - pHead));

+        pParaList->listCount++;

+        i++;

+        pHead = pEnd + 1;

+        pEnd = normal_findsubstr(pHead, ";");// yx  new  add  2013-5-20

+    }

+	

+    if ((strlen(pHead) != 0) && (pParaList->listCount < ZAT_RES_PARAM_MAX_NUM))

+    {

+        strncpy(pParaList->strParasLine[i], pHead,ZAT_RES_PARAM_MAX_LEN-1);

+        pParaList->listCount++;

+    }

+}

+

+//cops=?ÃüÁîÉϱ¨½á¹û´¦Àí

+VOID normal_recvcopstestrsp(char *at_paras)

+{

+	UINT32 listIndex = 0;

+	UINT32 copsIndex = 0;

+	T_zAt_CopsTestRes		 tPara		 = {0};

+	T_zAt_RES_PARAS_LIST	tParasList	= {0};

+	const char *pCopHeader = NULL;

+	char *pCopEnd = NULL;

+	int len = 0;

+			

+	pCopHeader = at_paras;

+	pCopEnd = normal_findsubstr(pCopHeader, ",,");

+	{

+		char copsContent[AT_CMD_MAX] = {0};

+		if(pCopEnd == NULL)

+		{

+			strncpy(copsContent, at_paras,sizeof(copsContent)-1);

+		}

+		else

+		{

+		    if(pCopEnd - pCopHeader >= sizeof(copsContent))

+			{

+			    len = sizeof(copsContent)-1;

+			}

+		    else

+			{

+			    len = pCopEnd - pCopHeader;

+			}

+			snprintf(copsContent,len+1,"%s",at_paras);

+			//strncpy(copsContent, at_paras, len);

+		}

+		

+		normal_preprocresparalineex(copsContent,sizeof(copsContent));			   /* Ô¤´¦Àí¸´ÔÓ²ÎÊýÐÐ */

+		normal_preprocresparalist(&tParasList, copsContent);   /* Ô¤´¦Àí²ÎÊýÁÐ±í   */

+	}

+	{

+		char operatorInfo[256]	= {0};

+		char copsList[512] = {0};

+		char copsList_tmp[512] = {0};

+		for(listIndex = 0; listIndex < tParasList.listCount; listIndex++)

+		{	

+			void *p[6] = {&tPara.oplist[copsIndex].stat,tPara.oplist[copsIndex].lalphaOper,tPara.oplist[copsIndex].salphaOper,

+					tPara.oplist[copsIndex].numericOper,&tPara.oplist[copsIndex].netType,&tPara.oplist[copsIndex].subType};

+			at_print(AT_DEBUG,"normal_recvcopstestrsp at_paras=%s!\n",tParasList.strParasLine[listIndex]);

+		    parse_param2("%d,%s,%s,%s,%d,%d", tParasList.strParasLine[listIndex], p);

+		    at_print(AT_DEBUG,"normal_recvcopstestrsp stat=%d,lalphaOper=%s,salphaOper=%s,numericOper=%s,netType=%d,subType=%d!\n",

+		    tPara.oplist[copsIndex].stat,tPara.oplist[copsIndex].lalphaOper,tPara.oplist[copsIndex].salphaOper,

+			tPara.oplist[copsIndex].numericOper,tPara.oplist[copsIndex].netType,tPara.oplist[copsIndex].subType);  

+			

+			if(0 == tPara.oplist[copsIndex].stat && 0 ==strcmp("", tPara.oplist[copsIndex].numericOper))

+			{

+				continue;

+			}

+			snprintf(operatorInfo, sizeof(operatorInfo), "%d,%s,%s,%d,%d", 

+				tPara.oplist[copsIndex].stat, tPara.oplist[copsIndex].salphaOper, 

+				tPara.oplist[copsIndex].numericOper, tPara.oplist[copsIndex].netType, tPara.oplist[copsIndex].subType);

+			if(0 == copsIndex)

+			{

+				snprintf(copsList,sizeof(copsList),"%s", operatorInfo);	

+			}

+			else

+			{

+				memcpy(copsList_tmp,copsList,sizeof(copsList_tmp));

+				snprintf(copsList,sizeof(copsList),"%s;%s", copsList_tmp ,operatorInfo); 

+			}

+		    copsIndex++;

+		}

+		char strValue[20] = {0};

+		snprintf(strValue,sizeof(strValue), "%ld", copsIndex);

+		cfg_set(NV_NET_NUM, strValue);

+		cfg_set(NV_M_NETSELECT_CONTENTS, copsList);

+		cfg_set(NV_M_NETSELECT_STATUS, "manual_selected");

+	}

+}

+

+int normal_netprovider_callback(void *fvarg,int line,char **zresult,char **lname)

+{

+	T_zAt_OperatorName operatorName = {0};

+	if(1 > line)

+	{

+		at_print(AT_DEBUG,"atBase: NetProvider record no data.");

+		return -1;

+	}

+    if(zresult[0] != NULL)

+    {

+    	strncpy(operatorName.OperFullName,  zresult[0], sizeof(operatorName.OperFullName)-1);

+    }

+    if(zresult[1] != NULL)

+	{

+    	strncpy(operatorName.OperShortName, zresult[1], sizeof(operatorName.OperShortName)-1);

+		

+	}

+	memcpy(fvarg,&operatorName,sizeof(operatorName));

+	return 0;

+}

+

+

+long normal_number2networkprovider(char *pplmn, T_zAt_OperatorName *opraName)

+{

+    char sql[128] = {0};

+	T_zAt_OperatorName operatorName = {0};

+    int result = DB_OK;

+	

+    if(ZUFI_NULL == pplmn)

+    {

+        return -1;

+    }

+

+    snprintf(sql,128-1,"select full_name,short_name from net_list where plmn=\'%s\' limit 1", pplmn);

+    result = normal_execdbsql(ZNETPROVIDER_DB_PATH, sql, normal_netprovider_callback, &operatorName);

+    if(DB_OK != result)

+    {

+        return ZUFI_FAIL;

+    }

+    at_print(AT_DEBUG,"normal_number2networkprovider OperShortName=%s\n",operatorName.OperShortName);

+	strncpy(opraName->OperShortName, operatorName.OperShortName, sizeof(opraName->OperShortName)-1);

+    if(operatorName.OperFullName[0] == '\0')

+    {

+        return ZUFI_FAIL;

+    }

+	strncpy(opraName->OperFullName, operatorName.OperFullName, sizeof(opraName->OperFullName)-1);

+		

+	return ZUFI_SUCC;

+

+}

+

+long normal_getnetworkprovidername(char *MCC, char *MNC,char *Net_Provider_Name,int len)

+{

+    long   listSize       = 0;

+    long   iCount         = 0;

+    long   mccNum         = 0;

+    long   mncNum         = 0;

+    long   qualListMcc    = 0;

+    long   quallistMnc    = 0;

+	

+    if(ZUFI_NULL == MCC || ZUFI_NULL == MNC ||  ZUFI_NULL == Net_Provider_Name)

+    {

+        at_print(AT_ERR,"the paraments of function is wrong!");

+        return ZUFI_FAIL;

+    }

+    mccNum = atoi( MCC );

+    mncNum = atoi( MNC );

+	

+    listSize = sizeof(G_ZAT_QUALCOMMLISTNODE)/sizeof(T_zAt_QualcommListNode);

+	

+    for(iCount = 0; iCount< listSize; iCount++)

+    {

+        qualListMcc = atoi( G_ZAT_QUALCOMMLISTNODE[iCount].mcc );

+        quallistMnc = atoi( G_ZAT_QUALCOMMLISTNODE[iCount].mnc );

+        if( (qualListMcc == mccNum)  && (quallistMnc == mncNum))

+        {

+            strncpy(Net_Provider_Name,G_ZAT_QUALCOMMLISTNODE[iCount].networkProvider,len-1);

+            break;

+        }

+    }

+	

+    if (iCount < listSize)

+    {

+        /* ÕÒµ½Æ¥ÅäÔËÓªÉÌÃû³Æ */

+        at_print(AT_DEBUG,"get provider name in list  ok !\n");

+        return ZUFI_SUCC;

+    }

+    else

+    {

+        /* δÕÒµ½Æ¥ÅäÔËÓªÉÌÃû³Æ */

+        at_print(AT_DEBUG,"can not get provider name in list!\n");

+        return  ZUFI_FAIL;

+    }

+}

+

+

+VOID normal_recvcopsreadrsp(char * at_paras)

+{

+    char sProvider[70]       = {0};

+    char netProviderName[70] = {0};

+    char sMCC[10]            = {0};

+    char sMNC[10]            = {0};

+	char needCopsNumFormat[10] = {0};

+	T_zAt_CopsReadRes  copsReadPara = {0};

+	T_zAt_OperatorName operatorName = {0};

+	

+	void *p[5] = {&copsReadPara.mode,&copsReadPara.format,copsReadPara.oper,&copsReadPara.act,&copsReadPara.subact};

+	at_print(AT_DEBUG,"normal_recvcopsreadrsp at_paras=%s!\n",at_paras);

+	parse_param2("%d,%d,%s,%d,%d", at_paras, p);

+	at_print(AT_DEBUG,"normal_recvcopsreadrsp mode=%ld,format=%ld,oper=%s,act=%ld,subact=%ld!\n",

+	copsReadPara.mode,copsReadPara.format,copsReadPara.oper,copsReadPara.act,copsReadPara.subact);	

+

+    strncpy(sProvider, copsReadPara.oper, sizeof(sProvider)-1);

+	

+    strncpy(sMCC, sProvider, 3);

+    at_print(AT_DEBUG,"MCC is %s\n", sMCC);

+	

+    strncpy(sMNC, sProvider+3,sizeof(sMNC)-1);

+    at_print(AT_DEBUG,"MNC is %s\n", sMNC);

+	

+    cfg_set(NV_MCC, sMCC);

+    cfg_set(NV_MNC, sMNC);

+    cfg_set(NV_OPER_NUM, copsReadPara.oper);

+    cfg_get_item("need_cops_number_format", needCopsNumFormat, sizeof(needCopsNumFormat));

+    if(0 == strcmp("yes", needCopsNumFormat))

+	{

+		if(2 == copsReadPara.format && ZUFI_SUCC == normal_number2networkprovider(sProvider, &operatorName))

+		{

+			strncpy(netProviderName,operatorName.OperFullName,sizeof(netProviderName)-1);

+			cfg_set("network_provider",netProviderName);

+            at_print(AT_DEBUG,"operator brand found in the Qualcomm list ! \n");

+		}

+		else

+	    {

+	        if(0 == strcmp(copsReadPara.oper,"CHINA MOBILE"))

+	        {

+	            strcpy(copsReadPara.oper, "China Mobile");

+	        }

+	        cfg_set("network_provider",copsReadPara.oper);

+	        at_print(AT_DEBUG,"operator brand not found in the Qualcomm list ! \n");

+	    }

+	}

+	else

+    {

+        if(2 == copsReadPara.format && ZUFI_SUCC == normal_getnetworkprovidername(sMCC, sMNC,netProviderName,sizeof(netProviderName)))

+        {

+            cfg_set(NV_NETWORK_PROVIDER,netProviderName);

+        }

+        else

+        {

+            if(0 == strcmp(copsReadPara.oper,"CHINA MOBILE"))

+            {

+                strncpy(copsReadPara.oper, "China Mobile",sizeof(copsReadPara.oper)-1);

+            }

+            cfg_set(NV_NETWORK_PROVIDER,copsReadPara.oper);    

+            at_print(AT_DEBUG,"operator brand not found in the Qualcomm list ! \n");

+        }

+    }

+    at_print(AT_DEBUG,"normal_recvcopsreadrsp send to mmi MSG_CMD_GET_NET_PROVIDER\n");

+    ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_MMI,MSG_CMD_GET_NET_PROVIDER, 0, NULL,0);   

+}

+

+

+int normal_getautoapn_callback(void *fvarg,int line,char **zresult,char **lname)

+{

+    T_zAt_APN_PROFILE para = {0};

+    if(1 > line)

+    {

+        at_print(AT_DEBUG,"zte_sms:record no data.\n");

+        cfg_get_item(NV_PDP_TYPE,para.pdp_type,sizeof(para.pdp_type));

+        return -1;

+    }

+    if(zresult[0] != NULL)

+    {

+        strncpy(para.profile_name, zresult[0], ZAT_PROFILE_MEMBER_LEN - 1);

+    }

+    if(zresult[1] != NULL)

+    {

+        strncpy(para.apn_name, zresult[1], ZAT_PROFILE_MEMBER_LEN - 1);

+        at_print(AT_DEBUG,"atBase_GetAutoApn_Callback: apn_name != NULL!\n");

+    }

+    if(zresult[2] != NULL)

+    {

+        strncpy(para.dial_num, zresult[2], ZAT_PROFILE_MEMBER_LEN - 1);

+    }

+    if(zresult[3] != NULL)

+    {

+        strncpy(para.ppp_auth_mode, zresult[3], ZAT_PROFILE_MEMBER_LEN - 1);

+    }

+    if(zresult[4] != NULL)

+    {

+        strncpy(para.ppp_username, zresult[4], ZAT_PROFILE_MEMBER_LEN - 1);

+        at_print(AT_DEBUG,"atBase_GetAutoApn_Callback: para.ppp_username != NULL!\n");

+    }

+    if(zresult[5] != NULL)

+    {

+        strncpy(para.ppp_passwd, zresult[5], ZAT_PROFILE_MEMBER_LEN - 1);

+    }

+    if(zresult[6] != NULL)

+    {

+        strncpy(para.pdp_type, zresult[6], ZAT_PROFILE_MEMBER_LEN - 1);

+    }    

+    memcpy(fvarg,&para,sizeof(para));

+    

+    return 0;

+}

+

+void normal_get_cardtype(char *ccmnc)

+{

+	if (strcmp(ccmnc, "46000") == 0 || 

+        strcmp(ccmnc, "46002") == 0 || 

+        strcmp(ccmnc, "46007") == 0 ||

+        strcmp(ccmnc, "46008") == 0)

+	{

+		cfg_set(NV_SIMCARD_TYPE, "1");

+	}

+	else if (strcmp(ccmnc, "46001") == 0 || 

+        strcmp(ccmnc, "46006") == 0)

+	{

+		cfg_set(NV_SIMCARD_TYPE, "2");

+	}

+	else if (strcmp(ccmnc, "46003") == 0 || 

+        strcmp(ccmnc, "46005") == 0 ||

+        strcmp(ccmnc, "46011") == 0 )

+	{

+		cfg_set(NV_SIMCARD_TYPE, "3");

+	}

+	else

+	{

+		cfg_set(NV_SIMCARD_TYPE, "4");

+

+	}

+

+}

+

+/*»ñÈ¡auto apn*/

+long normal_getautoapn(char *CCMNC)

+{

+    char sql[128] = {0};

+    char apn_auto_config[256];

+    T_zAt_APN_PROFILE apnpara = {0};

+    DbResult result = DB_OK;

+    char apnMode[50] = {0};

+    cfg_get_item(NV_APN_MODE,apnMode,sizeof(apnMode));

+    

+    snprintf(sql,sizeof(sql),"select ConfigFileName,APN,LoginNumber,AuthType,UserName,Password,PDPType from apn_list where CCMNC='%s' limit 1",CCMNC);

+    result = normal_execdbsql(ZAPN_DB_PATH,sql, normal_getautoapn_callback, &apnpara);

+	

+    at_print(AT_DEBUG,"atBase_GetAutoApn CCMNC:%s!\n",CCMNC);

+    if(DB_OK != result)

+    {

+        return -1;

+    }

+	if(strlen(apnpara.profile_name) == 0)

+	{

+		at_print(AT_ERR,"normal_getautoapn no item CCMNC:%s!\n",CCMNC);

+		return -1;

+	}

+    if(strlen(apnpara.pdp_type) == 0)

+    {

+        strncpy(apnpara.pdp_type, "IP", ZAT_PROFILE_MEMBER_LEN - 1);

+    }

+    

+    if(0 == strcmp("auto", apnMode))

+    {

+        cfg_set(NV_PDP_TYPE, apnpara.pdp_type);

+        if(strcmp("IPv6", apnpara.pdp_type) == 0 || strcmp(apnpara.pdp_type, "IPv4v6") == 0)

+        {

+            cfg_set(NV_IPV6_WAN_APN, apnpara.apn_name);

+    	    cfg_set(NV_IPV6_PDP_TYPE, apnpara.pdp_type);

+    	    cfg_set(NV_WAN_APN, apnpara.apn_name);

+    	    cfg_set(NV_IPV6_PPP_AUTH_MODE, apnpara.ppp_auth_mode);

+			cfg_set(NV_IPV6_PPP_USERNAME,apnpara.ppp_username);

+			cfg_set(NV_IPV6_PPP_PASSWD,apnpara.ppp_passwd);

+			ipv6apn_encrypt_code();

+        }

+        else

+        {

+            cfg_set(NV_WAN_APN, apnpara.apn_name);

+	        cfg_set(NV_PPP_AUTH_MODE, apnpara.ppp_auth_mode);

+			cfg_set(NV_PPP_USERNAME,apnpara.ppp_username);

+			cfg_set(NV_PPP_PASSWD,apnpara.ppp_passwd);

+			apn_encrypt_code();

+        }	

+        cfg_set(NV_M_PROFILE_NAME, apnpara.profile_name);

+		if(g_modem_model)

+		{

+			cfg_set("default_apn", apnpara.apn_name);

+			MSG_BUF *buf=normal_getmsg(MODULE_ID_AT_CTL,MODULE_ID_AT_CTL,MSG_CMD_APN_SET_REQ,0,NULL);

+			rcv_clt_req_msg_proc(buf);

+			free(buf);

+		}

+    }

+    snprintf(apn_auto_config, sizeof(apn_auto_config),"%s($)%s($)auto($)%s($)%s($)%s($)%s($)%s($)auto($)($)auto($)($)", 

+		apnpara.profile_name, apnpara.apn_name, apnpara.dial_num, apnpara.ppp_auth_mode, apnpara.ppp_username, 

+		apnpara.ppp_passwd, apnpara.pdp_type);	

+    at_print(AT_DEBUG,"atBase_GetAutoApn apn_auto_config = %s!\n",apn_auto_config);

+    cfg_set(NV_APN_AUTO_CONFIG, apn_auto_config);

+#ifdef MULTI_CPU

+	sync_default_apn(NULL);

+#endif

+    return 0;

+}

+

+void normal_recvzrapok()

+{

+    char modemState[50] = {0};

+    char pinProcess[50] = {0};

+    char pinManage[50] = {0};

+    cfg_get_item(NV_MODEM_MAIN_STATE,modemState,sizeof(modemState));

+    cfg_get_item(NV_PIN_PUK_PROCESS,pinProcess,sizeof(pinProcess));

+    cfg_get_item(NV_PIN_MANAGE_PROCESS,pinManage,sizeof(pinManage));

+    

+    if(strcmp(pinProcess,"begin") == 0

+	    &&0 == strcmp("modem_init_complete",modemState))

+    {

+        cfg_set(NV_PIN_PUK_PROCESS, "end");

+        printf("pin_puk_process = end --- modem_init_complete"); 

+    }

+    /*web pin¡¢pukÂëÑéÖ¤¶¯×÷½áÊøºó£¬·¢ZAT_SYSCONFIGREAD_CMD*/

+    else if(strcmp(pinProcess,"begin") == 0)

+    {

+        cfg_set(NV_PIN_PUK_PROCESS, "end");

+        printf("pin_puk_process = end"); 

+    }

+		

+    /*web pinÂë¹ÜÀí¶¯×÷´¥·¢ZrapºóÎÞÏÂÒ»ÌõAT£¬½«ATÃüÁîÔ´¸³ÖµÎªATMIAN*/

+    if(strcmp(pinManage,"begin") == 0)

+    {

+        printf("pin_manage_process = end");        

+        cfg_set(NV_PIN_MANAGE_PROCESS, "end");

+    }

+}

+

+MSG_BUF *normal_getmsg(unsigned short src_id,unsigned short dst_id,unsigned short Msg_cmd,unsigned short us_DataLen,unsigned char *pData)

+{

+    MSG_BUF *buf=malloc(sizeof(MSG_BUF));

+    if(buf == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(buf, 0, sizeof(MSG_BUF));

+    buf->ulMagic = MSG_MAGIC_WORD;

+    buf->lMsgType = MSG_TYPE_DEFAULT;

+    buf->src_id = src_id;

+    buf->dst_id = dst_id;

+    buf->usMsgCmd = Msg_cmd;

+    buf->usDataLen = us_DataLen;

+    if(us_DataLen > 0)

+    {

+        memcpy(buf->aucDataBuf, pData, us_DataLen);

+    }

+    return buf;

+}

+

+char* normal_zschplmnset(int mode)

+{

+	char *at_next=NULL;

+	at_next=malloc(20);

+ 	if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+ 	memset(at_next,0,20);

+	snprintf(at_next,20,"AT+ZSCHPLMN=%d\r\n",mode);

+	return at_next;

+

+}

+

+int zupci_auto_act(char *at_paras ,int is_query_report)

+{

+    at_print(AT_ERR,"zupci=%s\n",at_paras);

+	MSG_BUF *buf=NULL;

+	buf=normal_getmsg(MODULE_ID_AT_CTL,MODULE_ID_AT_CTL,MSG_CMD_ZUTR_REQ,strlen(at_paras),(unsigned char *)at_paras);

+	rcv_clt_req_msg_proc(buf);

+	free(buf);

+    return AT_END;

+}

+

+char* start_zutr_cmd(void *msg,struct at_context *context)

+{

+	int cmd_type=0;

+	int cmd_num=0;

+	int cmd_qual=0;

+	MSG_BUF *buf=NULL;

+	char *at_paras=malloc(strlen((char *)((MSG_BUF*)msg)->aucDataBuf)+1);

+	if(at_paras == NULL)

+		return NULL;

+	memset(at_paras,0,strlen((char *)((MSG_BUF*)msg)->aucDataBuf)+1);

+	strcpy(at_paras,(char *)((MSG_BUF*)msg)->aucDataBuf);

+	

+	void *p[3] = {&cmd_type,&cmd_num,&cmd_qual};

+	at_print(AT_DEBUG,"start_zutr_cmd at_paras=%s!\n",at_paras);

+	parse_param2("%d,%d,%d", at_paras, p);

+	at_print(AT_ERR,"start_zutr_cmd %d,%d,%d!\n",cmd_type,cmd_num,cmd_qual);

+	free(at_paras);

+

+	if(cmd_type == 33 || cmd_type == 34 || cmd_type == 35 || cmd_type == 36 || cmd_type == 37)

+	{

+		char *at_next=NULL;

+		at_next=malloc(64);

+		if(at_next == NULL){

+			softap_assert("");

+			return NULL;

+		}

+		memset(at_next,0,64);

+		if(cmd_type == 33)

+			snprintf(at_next,64,"AT+ZUTR=%d,%d,%d,0\r\n",cmd_type,cmd_qual,cmd_num);

+		else

+			snprintf(at_next,64,"AT+ZUTR=%d,%d,%d,32\r\n",cmd_type,cmd_qual,cmd_num);

+		return at_next;

+	}

+		

+	return NULL;

+}

+

+int zmsri_auto_act(char *at_paras ,int is_query_report)

+{

+    at_print(AT_DEBUG,"modem init start!\n");

+	MSG_BUF *buf=NULL;

+	//int guodian = 0;

+	normal_simcardcfgreset();

+	buf=normal_getmsg(MODULE_ID_AT_CTL,MODULE_ID_AT_CTL,ATCTL_INNER_ZCHNELSET_MSG,0,NULL);

+	rcv_clt_req_msg_proc(buf);

+	free(buf);

+	

+	buf = normal_getmsg(MODULE_ID_AT_CTL,MODULE_ID_AT_CTL,MSG_CMD_IMEI_REQ,0,NULL);//modem³õʼ»¯Íê³Éºó£¬²éѯimeiºÅ

+	rcv_clt_req_msg_proc(buf);

+	free(buf);

+	buf = NULL;

+//#ifdef GUODIAN

+//	guodian = 1;

+//#endif

+	if(g_customer_type)

+	{

+		buf=normal_getmsg(MODULE_ID_AT_CTL,MODULE_ID_AT_CTL,ATCTL_INNER_CVMOD_MSG,0,NULL);

+		rcv_clt_req_msg_proc(buf);

+		free(buf);

+	}

+	if(g_modem_model || g_customer_type)

+	{

+		buf=normal_getmsg(MODULE_ID_AT_CTL,MODULE_ID_AT_CTL,ATCTL_INNER_ZMSRI_MSG,0,NULL);

+		rcv_clt_req_msg_proc(buf);

+		free(buf);

+	}

+	if(!g_modem_model)

+	{

+		buf=normal_getmsg(MODULE_ID_AT_CTL,MODULE_ID_AT_CTL,MSG_CMD_NITZ_REQ,2,"1");

+		rcv_clt_req_msg_proc(buf);

+		free(buf);

+	}

+    return AT_END;

+}

+

+int zrefreshind_auto_act(char *at_paras ,int is_query_report)

+{

+	at_print(AT_ERR,"zrefreshind start!\n");

+	if(g_modem_model)

+	{

+		char needrestart[50]  = {0};

+		cfg_get_item("need_restart_when_sim_insert",needrestart,sizeof(needrestart));

+		if(strcmp("yes", needrestart) == 0)//ÖØÆô²Ù×÷

+		{

+			at_print(AT_DEBUG,"zrefreshind_auto_act RESTART\n");

+			ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_MAIN_CTRL, MSG_CMD_RESTART_REQUEST, 0, NULL,0);

+		}

+		else//²»ÖØÆô²Ù×÷£¬ÖØÐÂ×ßÒ»±é¿ª»úÁ÷³Ì£¬TODO

+		{

+			MSG_BUF *buf=NULL;

+			T_zAt_ZuslotRes zuslotPara = {0};//¸´Óðο¨Á÷³Ì

+			if(g_support_sms)	

+			ipc_send_message2(MODULE_ID_AT_CTL,MODULE_ID_SMS,MSG_CMD_ZUSLOT_IND,sizeof(zuslotPara),(unsigned char *)&zuslotPara,0);

+			if(g_support_pb)	

+			ipc_send_message2(MODULE_ID_AT_CTL,MODULE_ID_PB,MSG_CMD_ZUSLOT_IND,sizeof(zuslotPara),(unsigned char *)&zuslotPara,0);

+			buf=normal_getmsg(MODULE_ID_AT_CTL,MODULE_ID_AT_CTL,ATCTL_INNER_ZMSRI_MSG,0,NULL);

+			rcv_clt_req_msg_proc(buf);

+			free(buf);

+		}

+	}

+	return AT_END;

+}

+

+int zuslot_auto_act(char *at_paras ,int is_query_report)

+{

+    at_print(AT_DEBUG,"zuslot:%s start!\n",at_paras);

+	if(g_modem_model)

+	{

+		MSG_BUF *buf=NULL;

+		buf=normal_getmsg(MODULE_ID_AT_CTL,MODULE_ID_AT_CTL,ATCTL_INNER_ZUSLOT_MSG,strlen(at_paras),(unsigned char *)at_paras);

+		rcv_clt_req_msg_proc(buf);

+		free(buf);

+	}

+	else

+	{

+		cfg_set(NV_AUTO_RECONNECT,"");

+	}

+    return AT_END;

+}

+

+char* start_start_zmsri(void *msg,struct at_context *context)

+{

+	cfg_set("ppp_status", "ppp_disconnected");

+    //psinfo.zrap_state = ZRAP_READ_FIR_CMD;

+    //return normal_getzrapread();

+    return normal_getcfunset(ZAT_POWERON);

+}

+

+//²éѯÐźÅÇ¿¶Èat+csq

+char* start_query_csq(void *msg,struct at_context *context)

+{

+    return normal_getcsq();

+}

+

+

+char* start_verifypin_cmd(void *msg,struct at_context *context)

+{

+    char modemState[50] = {0};

+    if (msg == NULL)

+    {

+        return NULL;

+    }

+    cfg_get_item(NV_MODEM_MAIN_STATE,modemState,sizeof(modemState));

+    at_print(AT_DEBUG,"VerifyPin %s.modem_main_state is %s.\n",((MSG_BUF*)msg)->aucDataBuf,modemState);

+    if(0 == strcmp("modem_waitpin",modemState))//ÐèÒªpinÂë

+    {

+        if(strcmp((char *)((MSG_BUF*)msg)->aucDataBuf, "") != 0)

+        {

+            return normal_getcpinset((char *)((MSG_BUF*)msg)->aucDataBuf);

+        }

+    }

+    return NULL;

+}

+

+char* start_verifypuk_cmd(void *msg,struct at_context *context)

+{

+    T_zAt_CpinPukSet tCpinSet = {0};

+    char modemState[50]   = {0};

+    char pinNumber[50] = {0};

+	

+    if (msg == ZUFI_NULL)

+    {

+		return NULL;

+    }

+    cfg_get_item(NV_MODEM_MAIN_STATE,modemState,sizeof(modemState));

+    cfg_get_item(NV_PINNUMBER,pinNumber,sizeof(pinNumber));

+	at_print(AT_DEBUG,"VerifyPuk modem_main_state is %s.\n", modemState);

+ 	if(0 == strcmp("modem_waitpuk",modemState) || 0 == strcmp("0",pinNumber)) //ÐèÒªpukÂë

+	{

+		memcpy(&tCpinSet,((MSG_BUF*)msg)->aucDataBuf, sizeof(T_zAt_CpinPukSet));

+		

+		at_print(AT_DEBUG,"VerifyPuk puk=%s,newpin=%s\n", tCpinSet.pin, tCpinSet.newpin);

+		if (0 != strcmp(tCpinSet.pin,"") && 0 != strcmp(tCpinSet.newpin,""))

+		{        

+            return normal_getcpukset(tCpinSet.pin, tCpinSet.newpin);

+        }

+    }

+    return NULL;

+}

+

+char* start_netselect_cmd(void *msg,struct at_context *context)

+{

+    char *at_next = NULL;

+    char netMode[50] = {0};

+    cfg_get_item(NV_NET_SELECT_MODE,netMode,sizeof(netMode));

+    if(0 == strcmp("manual_select", netMode))//ÊÖ¶¯ËÑÍø

+    {

+        at_print(AT_DEBUG,"atWeb_NetSelect manual_select!\n");

+        cfg_set("manual_search_network_status", "searching");

+        at_next=normal_getcopstest();

+        normal_copstest_timerout(msg);

+    }

+    else if(0 == strcmp("auto_select", netMode))

+    {

+        at_print(AT_DEBUG,"atWeb_NetSelect auto_select!\n");

+        at_next=normal_getcfunset(ZAT_AIRMODE);

+    }

+	else

+	{

+        at_print(AT_DEBUG,"atWeb_NetSelect ???!\n");

+        at_next=normal_getcfunset(ZAT_AIRMODE);

+	}

+    return at_next;

+}

+

+char *start_pinmanage_cmd(void *msg,struct at_context *context)

+{

+    char *at_next=NULL;

+    char pinMode[10] = {0};

+    T_zAt_PinManage *ptPara = ZUFI_NULL;

+    if(msg == NULL)

+    {

+        return NULL;

+    }

+    ptPara = (T_zAt_PinManage*)(((MSG_BUF*)msg)->aucDataBuf);

+	at_print(AT_DEBUG,"start_pinmanage_webui action=%d,pincode=%s,newpincode=%s!\n",ptPara->action,ptPara->oldPin,ptPara->newPin);

+    if(ZAT_PIN_MANAGE_ENABLE == ptPara->action || ZAT_PIN_MANAGE_DISABLE == ptPara->action)

+    {

+        at_next=normal_getclckset(3,"SC",ptPara->action,ptPara->oldPin);

+        psinfo.clck_state=CLCK_SET_CMD;

+        snprintf(pinMode,sizeof(pinMode), "%d",ptPara->action);

+        cfg_set(NV_CLCK_SET_MODE,pinMode);

+    }

+    else if (ZAT_PIN_MANAGE_MODIFY == ptPara->action)

+    {

+        at_next=normal_getcpwdset("SC",ptPara->oldPin,ptPara->newPin);

+    }

+    return at_next;

+}

+

+char* start_setnetwork_cmd(void *msg,struct at_context *context)

+{

+    char *at_next=NULL;

+    char subType[10] = {0};

+    T_zAt_CopsSet copsSetPara = {0};

+    char netType[30] = {0};

+    cfg_get_item("current_subrat_tmp",subType,sizeof(subType));

+    cfg_get_item(NV_STR_NUM_RPLMN_TMP,copsSetPara.oper,sizeof(copsSetPara.oper));

+    cfg_get_item(NV_CURRENT_RAT_TMP,netType,sizeof(netType));

+    copsSetPara.nettype=atoi(netType);

+    if(0 == strcmp(subType, ""))

+    {

+        copsSetPara.subtype = -1;;

+    }

+    else

+    {

+        copsSetPara.subtype = atoi(subType);

+    }

+    at_print(AT_DEBUG, "atWeb_NetManualselect: %s,--%ld--,%ld\n",copsSetPara.oper,copsSetPara.nettype,copsSetPara.subtype);

+    if(-1 == copsSetPara.subtype)

+    {

+        at_next=normal_getcopsset(2,copsSetPara.oper,copsSetPara.nettype);

+    }

+    else

+    {

+        at_next=normal_getcopsset(3,copsSetPara.oper,copsSetPara.nettype,copsSetPara.subtype);			

+    }	

+    cfg_set(NV_NETWORK_TYPE, "No Service");

+	cfg_set(NV_SUB_NETWORK_TYPE, "No Service");

+

+    return at_next;

+}

+

+char* start_syctimeset_cmd(void *msg,struct at_context *context)

+{

+    struct timeval tp;

+

+    if (0 != gettimeofday(&tp,NULL))

+    {

+        at_print(AT_ERR,"get time of system wrong");

+        return NULL;

+    }

+    return normal_getsyctimeset(tp.tv_sec, tp.tv_usec);

+}

+

+char *start_ussdset_cmd(void *msg,struct at_context *context)

+{

+    char networktype[50]  = {0};

+    char ussdstring[50]  = {0};

+	cfg_get_item("network_type",networktype,sizeof(networktype));

+    if((strcmp("No Service",networktype) == 0) || (strcmp("Limited Service",networktype) == 0) || (strcmp("Searching",networktype) == 0))

+    {

+        cfg_set("ussd_write_flag","1");

+        return NULL;

+    }

+    cfg_get_item("ussd_string",ussdstring,sizeof(ussdstring));

+    return normal_getcusdset(ussdstring);

+}

+

+char *start_ussdcancel_cmd(void *msg,struct at_context *context)

+{

+    char *at_next=NULL;

+    char cancelflag[50]  = {0};

+	cfg_get_item("ussd_cancel_flag",cancelflag,sizeof(cancelflag));

+    if(strcmp(cancelflag,"yes") == 0)

+    {

+        at_next=normal_getcusdset_clean();

+    }

+    else

+    {

+        cfg_set("ussd_write_flag","13");

+    }

+    return at_next;

+}

+

+char *start_airmode_cmd(void *msg,struct at_context *context)

+{

+    char *at_next=NULL;

+    int par = *((int *)(((MSG_BUF*)msg)->aucDataBuf));

+    if(1 == par)

+    {

+        at_next=normal_getcfunset(ZAT_AIRMODE);

+    }

+    else if(0 == par)

+    {

+        at_next=normal_getcfunset(ZAT_POWERON);

+    }

+    return at_next;

+}

+

+//LTEËøÆµ,δʹÓÃ

+char *start_celllock_cmd(void *msg,struct at_context *context)

+{

+    return normal_getzltelcset();

+}

+

+char *start_imeireq_cmd(void *msg,struct at_context *context)

+{

+    return normal_getcgsn();

+}

+

+char *start_zversionreq_cmd(void *msg,struct at_context *context)

+{

+    return normal_getzversion();

+}

+

+char *start_cgdcontset_cmd(void *msg,struct at_context *context)

+{

+	char creg_stat[20] = {0};

+	char cereg_stat[20] = {0};

+	

+	cfg_get_item("cgreg_stat", creg_stat, sizeof(creg_stat));

+	cfg_get_item("cereg_stat", cereg_stat, sizeof(cereg_stat));

+	at_print(AT_ERR,"cgdcontset cgreg =%s, cereg =%s!\n",creg_stat,cereg_stat);

+	if(1 != atoi(creg_stat) && 5 != atoi(creg_stat) && 1 != atoi(cereg_stat) && 5 != atoi(cereg_stat))

+	{//ûËѵ½ÍøÔòÒªÁ¢¼´ÅäÖÃAPN£¬autoapnºÍwebuiÅäÖÃʱÓÐЧ

+		return normal_getcgdcontset(1);

+	}

+	return NULL;

+}

+

+//ϵͳÐÅÏ¢»ñÈ¡ÃüÁîat^sysinfo

+char *start_query_sysinfo(void *msg,struct at_context *context)

+{

+    return normal_getsysinfo();

+}

+

+//zuslotÖ÷¶¯Éϱ¨ÃüÁîµÄ´¦Àí

+char *start_start_zuslot(void *msg,struct at_context *context)

+{

+    T_zAt_ZuslotRes   zuslotPara = {0};

+    char needrestart[50]  = {0};

+    MSG_BUF *buf=NULL;

+    char *at_paras=malloc(strlen((char *)((MSG_BUF*)msg)->aucDataBuf)+1);

+	if(at_paras == NULL)

+		return NULL;

+    memset(at_paras,0,strlen((char *)((MSG_BUF*)msg)->aucDataBuf)+1);

+    strcpy(at_paras,(char *)((MSG_BUF*)msg)->aucDataBuf);

+	

+	void *p[2] = {&zuslotPara.slot,&zuslotPara.slot_state};

+	at_print(AT_DEBUG,"start_start_zuslot at_paras=%s!\n",at_paras);

+	parse_param2("%d,%d", at_paras, p);

+	at_print(AT_DEBUG,"start_start_zuslot slot=%ld,slot_state=%ld!\n",zuslotPara.slot,zuslotPara.slot_state);

+    free(at_paras);

+    if(zuslotPara.slot_state == 0)//°Î¿¨²Ù×÷

+    {	

+        at_print(AT_DEBUG,"zuslot simcard plugout\n");

+        cfg_set(NV_NEED_SIM_PIN,"");

+	    g_SimSlotFlag = FALSE;

+        normal_simcardcfgreset();

+        //¸øsms¡¢pbÄ£¿é·¢ÏûÏ¢£¬nvÖØÖ㬿¨²à¶ÌÐÅ¡¢ÁªÏµÈËɾ³ý

+	    if(g_modem_model)

+	    {

+			if(g_support_sms)	

+            ipc_send_message2(MODULE_ID_AT_CTL,MODULE_ID_SMS,MSG_CMD_ZUSLOT_IND,sizeof(zuslotPara),(unsigned char *)&zuslotPara,0);

+			if(g_support_pb)	

+            ipc_send_message2(MODULE_ID_AT_CTL,MODULE_ID_PB,MSG_CMD_ZUSLOT_IND,sizeof(zuslotPara),(unsigned char *)&zuslotPara,0);

+	    }

+        //psinfo.powersave_state=POWERSAVE_CARDREMOVE_CMD;

+        //return normal_getpowersave();

+    }

+    else if(zuslotPara.slot_state == 1)//²å¿¨²Ù×÷

+    {

+        at_print(AT_DEBUG,"zuslot simcard plugin\n");

+        cfg_get_item("need_restart_when_sim_insert",needrestart,sizeof(needrestart));

+        if(strcmp("yes", needrestart) == 0)//ÖØÆô²Ù×÷

+        {

+            at_print(AT_DEBUG,"zuslot simcard plugin,sendmsg to MODULE_ID_MAIN_CTRL\n");

+            ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_MAIN_CTRL, MSG_CMD_RESTART_REQUEST, 0, NULL,0);

+        }

+        else//²»ÖØÆô²Ù×÷£¬ÖØÐÂ×ßÒ»±é¿ª»úÁ÷³Ì

+        {

+            g_SimSlotFlag = TRUE;

+		    g_zUfi_canPdpDail = TRUE;

+			g_need_smspb_init = 0;

+            buf=normal_getmsg(MODULE_ID_AT_CTL,MODULE_ID_AT_CTL,ATCTL_INNER_ZMSRI_MSG,0,NULL);

+            rcv_clt_req_msg_proc(buf);

+            free(buf);

+        }

+    }	

+    return NULL;

+}

+

+char *start_setroam_cmd(void *msg,struct at_context *context)

+{

+    return normal_getsysconfigset();

+}

+

+int sysconfigread_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    at_print(AT_DEBUG,"sysconfigread_ok_act msg_id=%x!\n",context->msg_id);

+    switch(context->msg_id)

+    {

+        case ATCTL_INNER_ZMSRI_MSG:

+        {

+            psinfo.zrap_state = ZRAP_READ_FIR_CMD;

+            *next_req = normal_getzrapread();

+			if(*next_req){

+            *next_len = strlen(*next_req);

+            return AT_CONTINUE;

+			}

+        }

+    }

+    return AT_END;

+}

+

+int sysconfigread_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    at_print(AT_DEBUG,"zrap_err_act msg_id=%x!\n",context->msg_id);

+    switch(context->msg_id)

+    {

+        case ATCTL_INNER_ZMSRI_MSG:

+        {

+            psinfo.zrap_state = ZRAP_READ_FIR_CMD;

+            *next_req = normal_getzrapread();

+			if(*next_req){

+            *next_len = strlen(*next_req);

+            return AT_CONTINUE;

+			}

+        }

+    }

+    return AT_END;

+}

+

+int  zrap_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    at_print(AT_DEBUG,"zrap_ok_act msg_id=%x!\n",context->msg_id);

+    switch(context->msg_id)

+    {

+        case ATCTL_INNER_ZMSRI_MSG:

+        case MSG_CMD_VERIFY_PIN_REQ:

+        case MSG_CMD_VERIFY_PUK_REQ:

+        {

+            if(psinfo.zrap_state == ZRAP_READ_FIR_CMD)//¿ª»úÁ÷³Ì×ߵķÖÖ§

+            {

+                *next_req = normal_getcpinread();

+				if(*next_req){

+                *next_len = strlen(*next_req);

+                return AT_CONTINUE;

+				}

+            }

+            else if(psinfo.zrap_state == ZRAP_READ_SEC_CMD)//pinºÍpukÂëÑéÖ¤ºó×ߵķÖÖ§

+            {

+                char pinSet[50]={0};

+                normal_recvzrapok();

+                cfg_get_item(NV_PINSET_RESULT,pinSet,sizeof(pinSet));

+                if(0 == strcmp(pinSet,"succ"))

+                {

+                    *next_req = normal_getcgsn();

+					if(*next_req){

+                        *next_len = strlen(*next_req);

+                        return AT_CONTINUE;

+					}

+                }

+            }

+            psinfo.zrap_state=ZRAP_OTHER_CMD;

+            return AT_END;

+        }

+        case MSG_CMD_PIN_NUM_REQ:

+        {

+            *next_req=malloc(10);

+			if(*next_req){

+                *next_len=10;

+                cfg_get_item("pinnumber",*next_req, 10-1);

+                return AT_END;

+			}

+			break; // cov 	M

+        }

+        case MSG_CMD_PIN_MANAGE_REQ:

+        {

+            normal_recvzrapok();

+            return AT_END;

+        }

+    }

+    return AT_END;

+}

+

+int  zrap_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    switch(context->msg_id)

+    {

+        case ATCTL_INNER_ZMSRI_MSG:

+        case MSG_CMD_PIN_MANAGE_REQ:

+        case MSG_CMD_VERIFY_PIN_REQ:

+        case MSG_CMD_VERIFY_PUK_REQ:

+        {

+            psinfo.zrap_state=ZRAP_OTHER_CMD;

+            if ((0 == strcmp(at_str, "10"))    /*no sim card*/

+                             ||(0 == strcmp(at_str, "13"))    /*card initialize failed*/

+                             ||(0 == strcmp(at_str, "15")))    /*card error*/

+            {

+                if(0 == strcmp(at_str, "13"))

+                {

+                    cfg_set(NV_MODEM_MAIN_STATE,"modem_sim_destroy");

+                    at_print(AT_DEBUG,"modem_sim_destroy:%s\n",at_str);

+                }

+                else

+                {

+                    cfg_set(NV_MODEM_MAIN_STATE,"modem_sim_undetected");

+                    at_print(AT_DEBUG,"modem_sim_undetected:%s\n",at_str);

+                }

+

+				

+				ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_MMI, MSG_CMD_SIM_ABNORMAL_IND, 0, NULL,0);

+				

+                /*³õʼ»¯pbmµÄAP ²àµç»°±¾×¼±¸³É¹¦£¬·ñÔòÎÞ¿¨Ê±webuiתȦ*/

+                cfg_set("pbm_init_flag","0");

+                

+                //½ø·ÉÐÐģʽ

+                //*next_req = normal_getpowersave();

+                //*next_len = strlen(*next_req);

+                //psinfo.powersave_state=POWERSAVE_CARDERROR_CMD;

+                /*struct timeval tp;

+                if (0 != gettimeofday(&tp,NULL))

+                {

+                    at_print(AT_DEBUG,"get time of system wrong");

+                    return AT_END;

+                }

+                *next_req = normal_getsyctimeset(tp.tv_sec, tp.tv_usec);*/

+				*next_req = normal_getmtnetset(mccNum);

+				if(*next_req){

+                *next_len = strlen(*next_req);

+                return AT_CONTINUE;

+				}

+            }

+            return AT_END;

+        }

+        case MSG_CMD_PIN_NUM_REQ:

+        {

+            *next_req=malloc(10);

+			if(*next_req){

+            *next_len=10;

+            strcpy(*next_req,"0");

+            return AT_END;

+			}

+        }

+    }

+    return AT_END;

+}

+

+int sysconfig_auto_act( char *at_paras ,int is_query_report)

+{

+    int mode = ZAT_SYSCONFIG_MODE_AUTO;

+    int acqorder = ZAT_SYSCONFIG_PREF_ACQ_AUTO;

+    int  modenow = -1;

+    int  acqordernow = -1;

+    int  roam = -1;

+    int  roamnow = -1;

+    int  srvdomain = -1;	

+	char auto_acqorder[50] = {0};

+	char strTemp[10] = {0};

+	

+	cfg_get_item("auto_acqorder",auto_acqorder,sizeof(auto_acqorder));

+

+	at_print(AT_DEBUG,"sysconfig_auto_act\n");	

+    sscanf(at_paras,"%d,%d,%d,%d",&modenow,&acqordernow,&roamnow,&srvdomain);

+

+	at_print(AT_DEBUG,"sysconfig_auto_act modenow=%d, acqordernow=%d, auto_acqorder=%s\n",modenow, acqordernow, auto_acqorder);	

+

+	//×Ô¶¯ËÑÍøµÄÍøÂç½ÓÈë´ÎÐòΪ¿Õ£¬¶øµ±Ç°²éѯµ½µÄËÑÍø·½Ê½ÊÇ×Ô¶¯£¬Ôò±£´æÍøÂç½ÓÈë´ÎÐò

+	if(0 == strlen(auto_acqorder) && modenow == 2)

+	{		

+	    snprintf(strTemp, sizeof(strTemp), "%d", acqordernow);

+	    cfg_set("auto_acqorder", strTemp);

+	}

+	

+	normal_getsysconfigsetParam(&mode, &acqorder, &roam);

+	if(mode != modenow || acqorder != acqordernow || roam != roamnow)

+	{

+		MSG_BUF *msg_buf = NULL;

+		msg_buf=normal_getmsg(MODULE_ID_AT_CTL, MODULE_ID_AT_CTL, MSG_CMD_NET_SELECT_REQ, 0, NULL);

+		rcv_msg_proc(msg_buf);

+		free(msg_buf);

+	}

+

+    return AT_END;

+}

+

+int zrap_auto_act( char *at_paras ,int is_query_report)

+{

+    char strTemp[10] = {0};

+    int  pinNum1 = -1;

+    int  pinNum2 = -1;

+    int  pukNum1 = -1;

+    int  pukNum2 = -1;

+    at_print(AT_DEBUG,"zrap_auto_act\n");	

+    sscanf(at_paras,"%d,%d,%d,%d",&pinNum1,&pinNum2,&pukNum1,&pukNum2);

+

+    snprintf(strTemp, sizeof(strTemp),"%d", pinNum1);

+    cfg_set(NV_PINNUMBER, strTemp);

+	

+    snprintf(strTemp, sizeof(strTemp),"%d", pukNum1);

+    cfg_set(NV_PUKNUMBER, strTemp);

+    return AT_END;

+}

+

+//cpin²éѯ·µ»Øok´¦Àíº¯Êý

+int cpin_read_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    switch(context->msg_id)

+    {

+

+        case ATCTL_INNER_ZMSRI_MSG:

+        {

+            char simPin[50] = {0};

+            char simPuk[50] = {0};

+            char autoSimpin[50] = {0};

+            char autoCode[50] = {0};

+            char pinNumber[50] = {0};

+            cfg_get_item(NV_SIM_PIN,simPin,sizeof(simPin));

+            cfg_get_item(NV_SIM_PUK,simPuk,sizeof(simPuk));

+            

+            /*²»ÐèÒªPINÂ룬·¢CGSN²éѯÃüÁî*/

+            if(strcmp("0",simPin) == 0 && strcmp("0",simPuk) == 0 )

+            {	

+				*next_req = normal_getcgregset("2");

+				if(*next_req){

+                *next_len = strlen(*next_req);

+                return AT_CONTINUE;

+				}

+            }

+            /*ÐèÒªÑéÖ¤*/

+            else if(strcmp("1",simPin)==0)

+            {

+            	ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_MMI, MSG_CMD_SIM_ABNORMAL_IND, 0, NULL,0);

+

+                cfg_get_item(NV_AUTO_SIMPIN,autoSimpin,sizeof(autoSimpin));

+                cfg_get_item(NV_AUTO_SIMPIN_CODE,autoCode,sizeof(autoCode));

+                cfg_get_item(NV_PINNUMBER,pinNumber,sizeof(pinNumber));

+                /*×Ô¶¯pinÂëÑéÖ¤*/

+                if((0 == strcmp(autoSimpin,"1")) && (strcmp(autoCode,"") != 0))

+                {

+                    *next_req = normal_getcpinset(autoCode);

+					if(*next_req){

+                    *next_len = strlen(*next_req);

+                    return AT_CONTINUE;

+					}

+                }

+                /*ÈôpinµÄÊ£Óà´ÎÊýΪ0£¬Ôò½«ÊÇ·ñÐèÒªPukÂë¸ÄΪ1*/

+                else if(strcmp("0",pinNumber)==0)

+                {

+                    cfg_set(NV_MODEM_MAIN_STATE,"modem_waitpuk");

+                    return AT_END;

+                }

+                return AT_END;

+            }

+

+			break; // cov M MISSING_BREAK

+        }

+        case MSG_CMD_PIN_STATUS_REQ:

+        {

+            char simPin[50] = {0};

+            char simPuk[50] = {0};

+            

+            cfg_get_item("sim_pin",simPin,sizeof(simPin));

+            cfg_get_item("sim_puk",simPuk,sizeof(simPuk));  

+            *next_req=malloc(10);

+			if(*next_req){

+            *next_len=10;

+            if(strcmp("0", simPin) == 0 && strcmp("0", simPuk) == 0 )

+            {

+                sprintf(*next_req,"%d", PIN_STATUS_NO_PIN);

+            }

+            else if(strcmp("1", simPin)==0)

+            {

+                sprintf(*next_req,"%d", PIN_STATUS_PIN1);

+            }  

+            else if(strcmp("1", simPuk)==0)

+            {

+                sprintf(*next_req,"%d", PIN_STATUS_PUK1);

+            }  

+            return AT_END;

+			}

+        }

+    }

+    return AT_END;

+}

+

+int cpin_read_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    switch(context->msg_id)

+    {

+        case ATCTL_INNER_ZMSRI_MSG:

+        {

+            if ((0 == strcmp(at_str, "10"))    /*no sim card*/

+                             ||(0 == strcmp(at_str, "13"))    /*card initialize failed*/

+                             ||(0 == strcmp(at_str, "15")))    /*card error*/

+            {

+                if(0 == strcmp(at_str, "13"))

+                {

+                    cfg_set(NV_MODEM_MAIN_STATE,"modem_sim_destroy");

+                    at_print(AT_DEBUG,"modem_sim_destroy:%s\n",at_str);

+                }

+                else

+                {

+                    cfg_set(NV_MODEM_MAIN_STATE,"modem_sim_undetected");

+                    at_print(AT_DEBUG,"modem_sim_undetected:%s\n",at_str);					

+                }

+

+				ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_MMI, MSG_CMD_SIM_ABNORMAL_IND, 0, NULL,0);

+

+                /*³õʼ»¯pbmµÄAP ²àµç»°±¾×¼±¸³É¹¦£¬·ñÔòÎÞ¿¨Ê±webuiתȦ*/

+                cfg_set("pbm_init_flag","0");

+                

+                //½ø·ÉÐÐģʽ

+                //*next_req = normal_getpowersave();

+                //*next_len = strlen(*next_req);

+                /*struct timeval tp;

+                if (0 != gettimeofday(&tp,NULL))

+                {

+                    at_print(AT_DEBUG,"get time of system wrong");

+                    return AT_END;

+                }

+                *next_req = normal_getsyctimeset(tp.tv_sec, tp.tv_usec);*/

+				*next_req = normal_getmtnetset(mccNum);

+				if(*next_req){

+                *next_len = strlen(*next_req);

+                //psinfo.powersave_state=POWERSAVE_CARDERROR_CMD;

+                return AT_CONTINUE;

+				}

+            }

+            return AT_END;

+        }

+        case MSG_CMD_PIN_STATUS_REQ:

+        {

+            *next_req=malloc(10);

+			if(*next_req){

+            *next_len=10;

+            sprintf(*next_req,"%d", PIN_STATUS_NO_PIN);

+            return AT_END;

+			}

+        }

+    }

+    return AT_END;

+}

+

+

+int cpin_set_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    switch(context->msg_id)

+    {

+        case ATCTL_INNER_ZMSRI_MSG:

+        case MSG_CMD_VERIFY_PIN_REQ:

+        {

+            char pinProcess[50] = {0};

+            MSG_BUF *buf=NULL;

+            cfg_get_item(NV_PIN_PUK_PROCESS,pinProcess,sizeof(pinProcess));

+            if(strcmp(pinProcess,"begin") == 0)

+            {

+                cfg_set(NV_PIN_PUK_PROCESS, "end");        

+            }

+            cfg_set(NV_PINSET_RESULT,"succ");

+            cfg_set(NV_MODEM_MAIN_STATE,"modem_ready");

+            /*at_next=malloc(AT_CMD_MAX);

+            //PINÂëÉèÖóɹ¦£¬·¢AT+ZRAP?ÊÇΪÁ˸üÐÂPINÂëºÍpukÂëÊ£Óà´ÎÊý

+            sprintf(at_next,"AT+ZRAP?\r\n");

+            *next_req = at_next;

+            *next_len = strlen(at_next);

+            psinfo.zrap_state = ZRAP_READ_SEC_CMD;

+            return AT_CONTINUE;*/

+            buf=normal_getmsg(MODULE_ID_AT_CTL,MODULE_ID_AT_CTL,ATCTL_INNER_ZMSRI_MSG,0,NULL);

+            rcv_clt_req_msg_proc(buf);

+            free(buf);

+            return AT_END;

+        }

+        case MSG_CMD_VERIFY_PUK_REQ:

+        {

+            char modemState[50] = {0};

+			char pinProcess[50] = {0};

+

+			cfg_set(NV_PINSET_RESULT,"succ");

+			cfg_get_item(NV_PIN_PUK_PROCESS,pinProcess,sizeof(pinProcess));

+			if(strcmp(pinProcess,"begin") == 0)

+		    {

+		        cfg_set(NV_PIN_PUK_PROCESS, "end");

+		    }

+            

+            cfg_get_item(NV_MODEM_MAIN_STATE,modemState,sizeof(modemState));

+            if(strcmp("modem_init_complete",modemState))

+            {

+                cfg_set(NV_MODEM_MAIN_STATE,"modem_ready");

+            }

+            *next_req = normal_getclckset(2,"SC",2);

+			if(*next_req){

+                *next_len = strlen(*next_req);

+                return AT_CONTINUE;

+			}

+			break;

+        }

+        case MSG_CMD_PIN_VERIFY_REQ:

+        {

+            *next_req=malloc(10);

+			if(*next_req){

+                *next_len=10;

+                strcpy(*next_req,"0");

+                return AT_END;

+			}

+			break;

+        }

+    }

+    return AT_END;

+}

+

+int cpin_set_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    switch(context->msg_id)

+    {

+        case ATCTL_INNER_ZMSRI_MSG:

+        case MSG_CMD_VERIFY_PIN_REQ://PINÂëÑéÖ¤

+        {

+            char autoSimpin[50] = {0};

+            cfg_get_item(NV_AUTO_SIMPIN,autoSimpin,sizeof(autoSimpin));

+            if(0 == strcmp(autoSimpin,"1"))

+            {

+                cfg_set(NV_AUTO_SIMPIN,"0");

+            }

+            if(0 == strcmp(at_str, "16"))

+            {

+                cfg_set(NV_MODEM_MAIN_STATE,"modem_waitpin");

+            }

+            else if (0 == strcmp(at_str, "12"))	

+            {

+                /*Êä´í3´Îpin£¬½«±äΪwaitpuk*/

+                cfg_set(NV_MODEM_MAIN_STATE,"modem_waitpuk");

+            }

+            cfg_set(NV_PINSET_RESULT,"fail");

+            *next_req = normal_getzrapread();

+			if(*next_req){

+                *next_len = strlen(*next_req);

+                psinfo.zrap_state = ZRAP_READ_SEC_CMD;

+                return AT_CONTINUE;

+			}

+

+			break; // cov M MISSING_BREAK

+        }

+        case MSG_CMD_VERIFY_PUK_REQ://PUKÂëÑéÖ¤

+        {

+            char modemState[50] = {0};

+            if (0 == strcmp(at_str, "16"))       

+            {

+                cfg_get_item(NV_MODEM_MAIN_STATE,modemState,sizeof(modemState));

+                if(strcmp("modem_init_complete",modemState))

+        	    {

+                    cfg_set(NV_MODEM_MAIN_STATE,"modem_waitpuk");

+        	    }		

+            }

+			else if (0 == strcmp(at_str, "13"))

+            {

+                cfg_set(NV_MODEM_MAIN_STATE,"modem_sim_destroy");

+                at_print(AT_DEBUG,"modem_sim_destroy:%s\n",at_str);

+            }

+        	cfg_set(NV_PINSET_RESULT,"fail");

+            *next_req = normal_getzrapread();

+			if(*next_req){

+                *next_len = strlen(*next_req);

+                psinfo.zrap_state = ZRAP_READ_SEC_CMD;

+                return AT_CONTINUE;

+			}

+

+			break; // cov M MISSING_BREAK

+        }

+        case MSG_CMD_PIN_VERIFY_REQ://wifiÄ£¿é·¢¹ýÀ´µÄÏûÏ¢

+        {

+            *next_req=malloc(10);

+			if(*next_req){

+                *next_len=10;

+                strcpy(*next_req,"1");

+                return AT_END;

+			}

+

+			break;

+        }

+    }

+    return AT_END;

+}

+

+//ÀàËÆcopsÅжÏǰ׺£¬·À´íÎó´¦Àí

+int cpin_auto_act(char *at_paras ,int is_query_report)

+{

+    /*ÏìӦΪReady£¬²»ÐèÒªPInÂëÑéÖ¤*/

+    if (strcmp("READY", at_paras) == 0)

+    {

+        cfg_set(NV_SIM_PIN, "0");

+        cfg_set(NV_SIM_PUK, "0");

+		//cfg_set(NV_NEED_SIM_PIN,"");

+    }

+    /*Èç¹ûµ±Ç°ÃÜÂëÊäÈëÇëÇóΪPIN»òPIN2£¬ÔòÊäÈë+CPIN=<pin>½øÐÐУÑé*/

+    else if(strcmp("SIM PIN",at_paras) == 0 || strcmp("SIM PIN2",at_paras) == 0)

+    {

+        cfg_set(NV_SIM_PIN, "1");

+        cfg_set(NV_MODEM_MAIN_STATE,"modem_waitpin");

+		cfg_set(NV_NEED_SIM_PIN,"yes");

+    }

+    /*Èç¹ûµ±Ç°ÃÜÂëÊäÈëÇëÇóΪPUK»òPUK2£¬ÔòÊäÈë+CPIN=<pin>,<newpin>½øÐнâËø*/

+    else if(strcmp("SIM PUK",at_paras) == 0 || strcmp("SIM PUK2",at_paras) == 0)

+    {

+        cfg_set(NV_SIM_PUK, "1");

+        cfg_set(NV_MODEM_MAIN_STATE,"modem_waitpuk");

+		cfg_set(NV_NEED_SIM_PIN,"yes");

+    }

+

+    return AT_END;

+}

+

+

+int  cgsn_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    switch(context->msg_id)

+    {

+        case MSG_CMD_GET_MAC_REQ:

+        {

+#if 0        

+            *next_req=normal_getmacread();

+            *next_len=strlen(*next_req);

+            return AT_CONTINUE;

+#endif			

+        }

+    }

+    return AT_END;

+}

+

+int  cgsn_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    switch(context->msg_id)

+    {

+        case MSG_CMD_GET_MAC_REQ:

+        {

+#if 0        

+            *next_req=normal_getmacread();

+            *next_len=strlen(*next_req);

+            return AT_CONTINUE;

+#endif			

+        }

+    }

+    return AT_END;

+}

+

+int cgsn_auto_act(char *at_paras ,int is_query_report)

+{

+	at_print(AT_DEBUG,"cgsn_auto_act\n");	

+    cfg_set(NV_IMEI,at_paras);

+    return AT_END;

+}

+

+int ziccid_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    switch(context->msg_id)

+    {        

+		case MSG_CMD_MODEMREG_INFO_REQ:

+		{

+			*next_req = normal_getcimi();

+			if(*next_req){

+			*next_len = strlen(*next_req);

+			return AT_CONTINUE;

+			}

+		}

+    }

+    return AT_END;

+}

+

+int ziccid_auto_act( char *at_paras ,int is_query_report)

+{

+    cfg_set(NV_ZICCID, at_paras);

+    return AT_END;

+}

+

+int  crsm_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    at_print(AT_DEBUG,"crsm_ok_act msg_id=%d\n",context->msg_id);

+    switch(context->msg_id)

+    {

+        case ATCTL_INNER_ZMSRI_MSG:

+        {

+            char strPlmn[70] = {0};

+            char *pRes=NULL;

+            char strPlmnLast[10] = {0};

+            cfg_get_item("crsm_plmn", strPlmn, sizeof(strPlmn));

+            pRes = strstr(strPlmn, "144,0,");//±íʾÕýÈ·¶ÁÈ¡

+            if(0 == strlen(strPlmn) || NULL == pRes)

+            {

+                g_plmnLen = 5;

+            }

+            strncpy(strPlmnLast, &strPlmn[strlen(strPlmn)-2], 2);

+            if(0 == strcmp("03", strPlmnLast))

+            {

+                g_plmnLen = 6;

+            }

+            else

+            {

+                g_plmnLen = 5;

+            }

+            at_print(AT_DEBUG,"crsm_ok_act, g_plmnLen = %d \n", g_plmnLen);

+            *next_req = normal_getcimi();;

+			if(*next_req){

+                *next_len = strlen(*next_req);

+                return  AT_CONTINUE;

+			}

+			break; // cov M MISSING_BREAK

+        }

+        case MSG_CMD_CRSM_REQ:

+        {

+            if(crsmrsp == NULL){

+				softap_assert("");

+				return AT_END;

+			}

+            *next_req=crsmrsp;

+            *next_len=strlen(*next_req);

+            return AT_END;

+        }

+    }

+    return AT_END;

+}

+

+int  crsm_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    switch(context->msg_id)

+    {

+        case ATCTL_INNER_ZMSRI_MSG:

+        {

+            at_print(AT_DEBUG,"Recv CrsmPlmnlen ERR.\n");

+            *next_req = normal_getcimi();

+			if(*next_req){

+            *next_len = strlen(*next_req);

+            return  AT_CONTINUE;

+			}

+        }

+        case MSG_CMD_CRSM_REQ:

+        {

+            return AT_END;

+        }

+    }

+    return AT_END;

+}

+

+

+int crsm_auto_act(char *at_paras ,int is_query_report)

+{  

+    struct at_context *context = (struct at_context *)is_query_report;

+

+    if(context == NULL)

+        return AT_END;   

+    

+    at_print(AT_DEBUG,"crsm_auto_act msg_id=%x,at_paras=%s!\n",context->msg_id,at_paras);

+    switch(context->msg_id)

+    {

+        case ATCTL_INNER_ZMSRI_MSG:

+        {

+            cfg_set("crsm_plmn",at_paras);

+            return AT_END;

+        }

+        case MSG_CMD_CRSM_REQ:

+        {

+            crsmrsp=malloc(256);

+            if(crsmrsp == NULL){

+				softap_assert("");

+				return AT_END;

+			}

+            memset(crsmrsp,0,256);

+            sprintf(crsmrsp,at_paras);

+            return AT_END;

+        }

+    }

+    return AT_END;

+}

+

+int  cimi_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    switch(context->msg_id)

+    {

+        case ATCTL_INNER_ZMSRI_MSG:

+        {

+            if(normal_locknetmatch(mccNum, mncNum) == TRUE)

+            {

+	            /*struct timeval tp;

+	            if (0 != gettimeofday(&tp,NULL))

+	            {

+	                at_print(AT_DEBUG,"get time of system wrong");

+	                return AT_END;

+	            }

+	            *next_req = normal_getsyctimeset(tp.tv_sec, tp.tv_usec);*/

+				*next_req = normal_getmtnetset(mccNum);

+				if(*next_req){

+    	            *next_len = strlen(*next_req);

+    	            return AT_CONTINUE;

+				}

+	        }

+            else

+            {

+                cfg_set("modem_main_state","modem_imsi_waitnck"); 

+                return  AT_END;

+            }

+

+			break; // cov M

+        }

+        case MSG_CMD_CIMI_REQ:

+        {

+            *next_req=malloc(50);

+			if(*next_req){

+                *next_len=50;

+                cfg_get_item(NV_SIM_IMSI,*next_req,50);

+                return AT_END;

+			}

+

+			break; // cov M

+        }

+		case MSG_CMD_MODEMREG_INFO_REQ:

+		{

+			*next_req = normal_CnumRead();

+			if(*next_req){

+                *next_len = strlen(*next_req);

+    			return AT_CONTINUE;

+			}

+

+			break; // cov M

+		}

+    }

+    return AT_END;

+}

+

+int  cimi_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    switch(context->msg_id)

+    {

+        case ATCTL_INNER_ZMSRI_MSG:

+        {

+            if(normal_locknetmatch(mccNum, mncNum) == TRUE)

+            {

+	            /*struct timeval tp;

+	            if (0 != gettimeofday(&tp,NULL))

+	            {

+	                at_print(AT_DEBUG,"get time of system wrong");

+	                return AT_END;

+	            }

+	            *next_req = normal_getsyctimeset(tp.tv_sec, tp.tv_usec);*/

+				*next_req = normal_getmtnetset(mccNum);

+				if(*next_req){

+    	            *next_len = strlen(*next_req);

+    	            return AT_CONTINUE;

+				}

+	        }

+            else

+            {

+                cfg_set("modem_main_state","modem_imsi_waitnck"); 

+                return  AT_END;

+            }

+

+			break; // cov M MISSING_BREAK

+        }

+        case MSG_CMD_CIMI_REQ:

+        {

+            return AT_END;

+        }

+		case MSG_CMD_MODEMREG_INFO_REQ:

+		{

+			*next_req = normal_CnumRead();

+			if(*next_req){

+                *next_len = strlen(*next_req);

+    			return AT_CONTINUE;

+			}

+

+			break; // cov M MISSING_BREAK

+		}

+    }

+    return AT_END;

+}

+

+/*

+int  zapnsave_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    switch(context->msg_id)

+    {

+        case MSG_CMD_INNER_PDP_INIT:

+        {

+            return AT_END;

+        }

+		//case MSG_CMD_SET_DEFAULT_APN_REQ:

+        //{

+        //    return AT_END;

+        //}

+        default:

+            softap_assert("");

+        

+    }

+    return AT_END;

+}

+

+int  zapnsave_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    softap_assert("");

+    return AT_END;

+}

+*/

+int cimi_auto_act(char *at_paras, int is_query_report)

+{  

+    char ccmncNum[10]         = {0};

+    struct at_context *context = (struct at_context *)is_query_report;

+    

+    strncpy(imsi,at_paras,sizeof(imsi)-1);

+	imsi[49]=0;

+    strncpy(mccNum, imsi, 3);

+    at_print(AT_DEBUG,"mcc is %s", mccNum);

+#if (APP_OS_TYPE == APP_OS_LINUX)	

+    if(6 == g_plmnLen)

+	{

+		strncpy(mncNum, imsi+3, 3);

+	}

+	else

+	{

+		strncpy(mncNum, imsi+3, 2);

+	}

+    

+    snprintf(ccmncNum, 10-1, "%s%s", mccNum, mncNum);

+	cfg_set(NV_SIM_IMSI, imsi);

+	normal_get_cardtype(ccmncNum);

+    switch(context->msg_id)

+    {		

+		case ATCTL_INNER_ZMSRI_MSG:

+		case MSG_CMD_CIMI_REQ:

+		{

+			normal_getautoapn(ccmncNum);

+			break;

+		}

+	  	default:

+        {           

+            break;

+        }

+    }

+#endif

+    return AT_END;

+}

+

+int sysconfig_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    switch(context->msg_id)

+    {

+        case MSG_CMD_NET_SELECT_REQ:

+        {

+            *next_req = normal_getcfunset(ZAT_POWERON);

+			if(*next_req){

+                *next_len = strlen(*next_req);

+                cfg_set(NV_NET_SELECT_RESULT, "sucess");

+                return  AT_CONTINUE;

+			}

+

+			break; // cov M MISSING_BREAK

+        }

+

+		default:

+		{

+		    break;

+		}

+    }

+    return AT_END;

+}

+

+int sysconfig_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+     switch(context->msg_id)

+     {

+        case MSG_CMD_NET_SELECT_REQ:

+        {

+            *next_req = normal_getcfunset(ZAT_POWERON);

+			if(*next_req){

+                *next_len = strlen(*next_req);

+                cfg_set(NV_NET_SELECT_RESULT, "fail");

+                return  AT_CONTINUE;

+			}

+

+			break; // cov M MISSING_BREAK

+        }

+

+		default:

+		{

+		    break;

+		}

+     }

+     return AT_END;

+}

+

+int cfun_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+	cfg_set("cfun_work", "none");

+    switch(context->msg_id)

+    {

+        //¿ª»úÁ÷³ÌÖÐAT+CFUN=1

+        case ATCTL_INNER_ZMSRI_MSG:

+        {

+            char modemState[50]  = {0};

+            normal_cfunOkSet();

+            cfg_get_item(NV_MODEM_MAIN_STATE,modemState,sizeof(modemState));

+            if(0 == strcmp("modem_syscfg_exption",modemState))

+            {

+                cfg_set(NV_MODEM_MAIN_STATE,"modem_destroy"); 

+            }

+            else

+            {

+                cfg_set(NV_MODEM_MAIN_STATE,"modem_init_complete");      

+            }

+            //*next_req = normal_getcgregset("2");

+            //psinfo.zrap_state = ZRAP_READ_FIR_CMD;

+            //*next_req = normal_getzrapread();

+        //#ifdef GUODIAN

+            if(g_customer_type == CUSTOMER_GUODIAN || g_customer_type == CUSTOMER_NANDIAN)

+            {

+			    return  AT_END;

+            }

+		//#else

+		    else

+            {      

+    			*next_req = normal_getsysconfigread();

+				if(*next_req){

+                    *next_len = strlen(*next_req);

+                    return  AT_CONTINUE;

+				}

+            }

+

+			break; // cov M MISSING_BREAK

+		//#endif

+        }

+        //×Ô¶¯ËÑÍø

+        case MSG_CMD_NET_SELECT_REQ:

+        {

+            if(cfun_state==4)

+            {

+                *next_req = normal_getsysconfigset();

+				if(*next_req){

+                    *next_len = strlen(*next_req);

+                    return  AT_CONTINUE;

+				}

+            }

+            else if(cfun_state==1)

+            {

+                char mMode[50] = {0};

+                cfg_get_item(NV_M_NETSELECT_MODE,mMode,sizeof(mMode));

+                if(0 == strcmp("1", mMode))

+                {

+                    *next_req = normal_getcopsset(1,"0");

+					if(*next_req){

+                    *next_len = strlen(*next_req);

+                    return  AT_CONTINUE;

+					}

+                }

+                else

+                {

+                    return AT_END;

+                }

+            }

+			

+            return AT_END;

+        }

+        case MSG_CMD_AIRMODE_SET_REQ:

+        {

+            return AT_END;

+        }

+    }

+    return AT_END;

+}

+

+int cfun_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+	cfg_set("cfun_work", "none");

+    switch(context->msg_id)

+    {

+        //¿ª»úÁ÷³ÌÖÐAT+CFUN=1

+        case ATCTL_INNER_ZMSRI_MSG:

+        {

+            cfg_set(NV_MODEM_MAIN_STATE,"modem_destroy");

+            return  AT_END;

+        }

+        //×Ô¶¯ËÑÍø

+        case MSG_CMD_NET_SELECT_REQ:

+        {

+            if(cfun_state==4)

+            {

+                *next_req = normal_getsysconfigset();

+				if(*next_req){

+                    *next_len = strlen(*next_req);

+                    return  AT_CONTINUE;

+				}

+            }

+            else if(cfun_state==1)

+            {

+                char mMode[50] = {0};

+                cfg_get_item(NV_M_NETSELECT_MODE,mMode,sizeof(mMode));

+                if(0 == strcmp("1", mMode))

+                {

+                    *next_req = normal_getcopsset(1,"0");

+					if(*next_req){

+                    *next_len = strlen(*next_req);

+                    return  AT_CONTINUE;

+					}

+                }

+                else

+                {

+                    return AT_END;

+                }

+            }

+            return AT_END;

+        }

+        case MSG_CMD_AIRMODE_SET_REQ:

+        {

+            return AT_END;

+        }

+    }

+    return AT_END;

+}

+

+int cgreg_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    *next_req = normal_getceregset("2");

+	if(*next_req)

+    *next_len = strlen(*next_req);

+    return  AT_CONTINUE;

+}

+

+int cgreg_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    *next_req = normal_getceregset("2");

+	if(*next_req)

+    *next_len = strlen(*next_req);

+    return  AT_CONTINUE;

+}

+

+int cereg_set_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+

+    char *at_next = NULL;

+    

+    //at_next=normal_getcgmr();

+    at_next=normal_getcrsmset("176,28589,0,0,4");

+

+    *next_req = at_next;

+    //*next_req = normal_getzsqrset("0");

+	if(*next_req)

+    *next_len = strlen(*next_req);

+    return  AT_CONTINUE;

+}

+

+int cereg_set_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    char *at_next = NULL;

+    

+    //at_next=normal_getcgmr();

+    at_next=normal_getcrsmset("176,28589,0,0,4");

+    

+    *next_req = at_next;

+    //*next_req = normal_getzsqrset("0");

+	if(*next_req)

+    *next_len = strlen(*next_req);

+    return  AT_CONTINUE;

+}

+

+int zsqr_auto_act(char *at_paras ,int is_query_report)

+{

+    char strBuf[10] = {0};

+    T_zAt_CsqUnSolicite zsqrResPara = {0};

+    sscanf(at_paras, "%ld,%ld,%ld", &zsqrResPara.rssi, &zsqrResPara.ber, &zsqrResPara.act);

+

+#if 1    // kw 3 SV.TAINTED.CALL.BINOP

+    if(zsqrResPara.rssi < 0 || zsqrResPara.rssi > LONG_MAX-1)

+    {

+        zsqrResPara.rssi = 0;

+    }

+

+    if(zsqrResPara.ber < 0 || zsqrResPara.ber > LONG_MAX-1)

+    {

+        zsqrResPara.ber = 0;

+    }

+

+    if(zsqrResPara.act < 0 || zsqrResPara.act > LONG_MAX-1)

+    {

+        zsqrResPara.act = 0;

+    }    

+#endif 

+

+    snprintf(strBuf, sizeof(strBuf),"%ld", zsqrResPara.rssi);

+    cfg_set(NV_CSQ, strBuf);

+    if(zsqrResPara.act == 3) 

+	{

+		normal_calcsignalbar(ZAT_SIGNALBAR_TYPE_GSM);

+		normal_calcsignalstrength(ZAT_SIGNALBAR_TYPE_GSM, zsqrResPara.rssi);

+	}

+	else if(zsqrResPara.act == 5)

+	{

+		normal_calcsignalbar(ZAT_SIGNALBAR_TYPE_WCDMA);

+		normal_calcsignalstrength(ZAT_SIGNALBAR_TYPE_WCDMA, zsqrResPara.rssi);

+	}

+	else if(zsqrResPara.act == 15)

+	{

+		normal_calcsignalbar(ZAT_SIGNALBAR_TYPE_TDS);

+		normal_calcsignalstrength(ZAT_SIGNALBAR_TYPE_TDS, zsqrResPara.rssi);

+	}

+	else if(zsqrResPara.act == 17)

+	{		

+		normal_calcsignalbar(ZAT_SIGNALBAR_TYPE_LTE);

+		normal_calcsignalstrength(ZAT_SIGNALBAR_TYPE_LTE, zsqrResPara.rssi);

+	}

+    else if(zsqrResPara.act == 0)

+    {

+        normal_calcsignalbar(ZAT_SIGNALBAR_TYPE_NONE);

+    }

+    return AT_END;

+}

+

+int cops_set_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    switch(context->msg_id)

+    {

+        case MSG_CMD_QUERY_SYSINFO_REQ:

+        {

+            //*next_req = normal_getcgmr();

+			*next_req = normal_getcopsread();

+			if(*next_req){

+                *next_len = strlen(*next_req);

+                return AT_CONTINUE;

+			}

+			break; // cov M

+        }

+        case MSG_CMD_NET_SELECT_REQ:

+        {

+            cfg_set(NV_M_NETSELECT_MODE, "0");

+            return AT_END;

+        }

+        case MSG_CMD_NETWORK_SET_REQ:

+        {

+            char    rplmnTmp[50]  = {0};

+            char    ratTmp[50]  = {0};

+            cfg_get_item(NV_STR_NUM_RPLMN_TMP,rplmnTmp,sizeof(rplmnTmp));

+            cfg_get_item(NV_CURRENT_RAT_TMP,ratTmp,sizeof(ratTmp));

+            cfg_set(NV_M_NETSELECT_RESULT, "manual_success");

+            cfg_set(NV_STR_NUM_RPLMN,rplmnTmp);

+            cfg_set(NV_CURRENT_RAT,ratTmp);

+            cfg_set(NV_M_NETSELECT_MODE, "1");

+            *next_req = normal_getsysinfo();

+			if(*next_req){

+                *next_len = strlen(*next_req);

+                return AT_CONTINUE;

+			}

+

+			break; // cov M

+        }

+    }

+    return AT_END;

+}

+

+int cops_set_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    switch(context->msg_id)

+    {

+        case MSG_CMD_QUERY_SYSINFO_REQ:

+        {

+            //*next_req = normal_getcgmr();

+			*next_req = normal_getcopsread();

+			if(*next_req){

+            *next_len = strlen(*next_req);

+            return AT_CONTINUE;

+			}

+        }

+        case MSG_CMD_NET_SELECT_REQ:

+        {

+            return AT_END;

+        }

+        case MSG_CMD_NETWORK_SET_REQ:

+        {

+            cfg_set(NV_M_NETSELECT_RESULT, "manual_fail");

+            *next_req = normal_getsysinfo();

+			if(*next_req){

+            *next_len = strlen(*next_req);

+            return AT_CONTINUE;

+			}

+        }

+    }

+    return AT_END;

+}

+

+int cops_read_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    at_print(AT_DEBUG,"cops_read_ok_act %x\n",context->msg_id);

+    switch(context->msg_id)

+    {

+        case MSG_CMD_QUERY_SYSINFO_REQ:

+        case MSG_CMD_NETWORK_SET_REQ:

+        {

+            if(g_zUfi_firstCsq)

+            {

+                g_zUfi_firstCsq = FALSE;

+                *next_req = normal_getcsq();

+				if(*next_req){

+                *next_len = strlen(*next_req);

+                return  AT_CONTINUE;

+				}

+            }

+            return AT_END;

+        }

+	}

+    return AT_END;

+}

+

+int cops_read_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    at_print(AT_DEBUG,"cops_read_ok_act %x\n",context->msg_id);

+    switch(context->msg_id)

+    {

+        case MSG_CMD_QUERY_SYSINFO_REQ:

+        {

+            if(g_zUfi_firstCsq)

+            {

+                g_zUfi_firstCsq = FALSE;

+                *next_req = normal_getcsq();

+				if(*next_req){

+                *next_len = strlen(*next_req);

+                return  AT_CONTINUE;

+				}

+            }

+            return AT_END;

+        }

+		case MSG_CMD_MODEMREG_INFO_REQ:

+		{

+			*next_req = normal_getcsq();

+			if(*next_req){

+            *next_len = strlen(*next_req);

+            return  AT_CONTINUE;

+			}

+		}

+    }

+    return AT_END;

+}

+

+int cops_test_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    cfg_set("manual_search_network_status", "finished");

+    return AT_END;

+}

+

+int cops_test_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    cfg_set(NV_NET_NUM, "0");

+    cfg_set(NV_M_NETSELECT_STATUS, "manual_search_fail");

+    DeleteSoftTimer(CopstestTimerID);

+    return AT_END;

+}

+

+int cops_auto_act(char *at_paras ,int is_query_report)

+{

+    //at+cops=?·µ»ØÖµ

+    //zdm ²»µ÷Óã¬Ò²Á¬½Ó²»¹ý

+    #if (APP_OS_TYPE == APP_OS_TOS)

+		softap_assert("");

+	#else

+    

+    struct at_context *context = (struct at_context *)is_query_report;

+

+    if(context == NULL)

+        return AT_END;   

+

+    at_print(AT_DEBUG,"cops_auto_act prefix=%s!\n",context->at_cmd_prefix);

+    if(strstr(context->at_cmd_prefix,"=?"))

+    {

+#if (APP_OS_TYPE == APP_OS_LINUX)	

+		DeleteSoftTimer(CopstestTimerID);

+#elif (APP_OS_TYPE == APP_OS_TOS)	

+		zOss_StopTimer(CopstestTimerID);

+#endif

+        at_print(AT_DEBUG,"come in222!\n");

+        normal_recvcopstestrsp(at_paras);

+    }

+    else if(strstr(context->at_cmd_prefix,"?"))

+    {

+        normal_recvcopsreadrsp(at_paras);

+    }

+	#endif

+    return AT_END;

+}

+

+int  zversion_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    at_print(AT_DEBUG,"zversion_ok_act\n");

+/*

+    switch(context->msg_id)

+    {

+        case ATCTL_INNER_ZMSRI_MSG:

+        {

+            struct timeval tp;

+            if (0 != gettimeofday(&tp,NULL))

+            {

+                at_print(AT_DEBUG,"get time of system wrong");

+                return AT_END;

+            }

+            *next_req = normal_getsyctimeset(tp.tv_sec, tp.tv_usec);

+			if(*next_req){

+            *next_len = strlen(*next_req);

+            return AT_CONTINUE;

+			}

+        }

+	}

+*/	

+    return AT_END;

+}

+

+int  zversion_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    at_print(AT_DEBUG,"zversion_err_act\n");

+/*

+    switch(context->msg_id)

+    {

+        case ATCTL_INNER_ZMSRI_MSG:

+        {

+            struct timeval tp;

+            if (0 != gettimeofday(&tp,NULL))

+            {

+                at_print(AT_DEBUG,"get time of system wrong");

+                return AT_END;

+            }

+            *next_req = normal_getsyctimeset(tp.tv_sec, tp.tv_usec);

+			if(*next_req){

+            *next_len = strlen(*next_req);

+            return AT_CONTINUE;

+			}

+        }

+    }

+*/	

+    return AT_END;

+}

+

+int zversion_auto_act(char *at_paras ,int is_query_report)

+{

+    cfg_set(NV_CR_INNER_VERSION,at_paras);

+    return AT_END;

+}

+

+int  syctime_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    switch(context->msg_id)

+    {

+        case ATCTL_INNER_ZMSRI_MSG:

+        {

+            *next_req = normal_getclckset(2,"SC",2);

+			if(*next_req){

+            *next_len = strlen(*next_req);

+            return AT_CONTINUE;

+			}

+        }

+        case MSG_CMD_SYCTIME_SET_REQ:

+        {

+            return AT_END;

+        }

+    }

+    return AT_END;

+}

+

+int  syctime_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    switch(context->msg_id)

+    {

+        case ATCTL_INNER_ZMSRI_MSG:

+        {

+            *next_req = normal_getclckset(2,"SC",2);

+			if(*next_req){

+            *next_len = strlen(*next_req);

+            return AT_CONTINUE;

+			}

+        }

+        case MSG_CMD_SYCTIME_SET_REQ:

+        {

+            return AT_END;

+        }

+    }

+    return AT_END;

+}

+

+int  zsetmtnet_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    switch(context->msg_id)

+    {

+        case ATCTL_INNER_ZMSRI_MSG:

+        {

+            *next_req = normal_getclckset(2,"SC",2);

+			if(*next_req){

+            *next_len = strlen(*next_req);

+            return AT_CONTINUE;

+			}

+        }

+        default:

+        {

+            return AT_END;

+        }

+    }

+    return AT_END;

+}

+

+int  zsetmtnet_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    switch(context->msg_id)

+    {

+        case ATCTL_INNER_ZMSRI_MSG:

+        {

+            *next_req = normal_getclckset(2,"SC",2);

+			if(*next_req){

+            *next_len = strlen(*next_req);

+            return AT_CONTINUE;

+			}

+        }

+        default:

+        {

+            return AT_END;

+        }

+    }

+    return AT_END;

+}

+

+int  mac_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    at_print(AT_DEBUG,"mac_ok_act\n");

+    *next_req=normal_getmac2read();

+	if(*next_req)

+    *next_len=strlen(*next_req);

+    return AT_CONTINUE;

+}

+

+int  mac_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    at_print(AT_ERR,"mac_err_act\n");

+    if(mactozssid != NULL)

+        free(mactozssid);

+    mactozssid=NULL;

+    return AT_END;

+}

+

+int  mac2_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    at_print(AT_DEBUG,"mac2_ok_act\n");

+    cfg_set("at_wifi_mac",mactozssid);

+	cfg_save();

+    free(mactozssid);

+    mactozssid=NULL;

+    return AT_END;

+}

+

+int  mac2_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    at_print(AT_ERR,"mac2_err_act\n");

+    if(mactozssid != NULL)

+        free(mactozssid);

+    mactozssid=NULL;

+    return AT_END;

+}

+

+int  zltelc_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    long action = 0;

+    char actionLte[30]= {0};

+    cfg_get_item(NV_ACTIONLTE,actionLte,sizeof(actionLte));

+    action  = atoi(actionLte);

+    cfg_set(NV_CELLLOCKSET,"CellSuccess");

+    if(1 == action)

+    {

+        cfg_set(NV_CELLLOCKSTATE,"Locked");

+    }

+    else if(0 == action)

+    {

+        cfg_set(NV_CELLLOCKSTATE,"UnLocked");

+    }

+    return AT_END;

+}

+

+int  zltelc_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    cfg_set(NV_CELLLOCKSET,"CellFail");

+    return AT_END;

+}

+

+int  sysinfo_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    char netType[50]={0};

+	char needCopsNumFormt[10] = {0};

+    cfg_get_item(NV_NETWORK_TYPE,netType,sizeof(netType));

+    cfg_get_item("need_cops_number_format",needCopsNumFormt,sizeof(needCopsNumFormt));

+	sysinfo_flag = 0;

+    if (0!=strcmp("No Service",netType)&&0!=strcmp("Limited Service",netType)

+        &&0!=strcmp(NETWORK_TYPE_INIT,netType))

+    {

+        if(0 == strcmp("yes", needCopsNumFormt) && context->msg_id != MSG_CMD_NETWORK_SET_REQ)//ÉèÖÃÔËÓªÉÌÐÅÏ¢¸ñʽ

+        {

+            *next_req =normal_getcopsset(1,"3,2");

+			if(*next_req)

+			*next_len = strlen(*next_req);

+        }

+        else

+        {

+            *next_req = normal_getcopsread();

+			if(*next_req)

+            *next_len = strlen(*next_req);

+        }

+        return AT_CONTINUE;

+    }

+    return AT_END;

+}

+

+int  sysinfo_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    char netType[50]={0};

+	char needCopsNumFormt[10] = {0};

+    cfg_get_item(NV_NETWORK_TYPE,netType,sizeof(netType));

+	cfg_get_item("need_cops_number_format",needCopsNumFormt,sizeof(needCopsNumFormt));

+	sysinfo_flag = 0;

+    if (0!=strcmp("No Service",netType)&&0!=strcmp("Limited Service",netType)

+        &&0!=strcmp(NETWORK_TYPE_INIT,netType))

+    {

+        if(0 == strcmp("yes", needCopsNumFormt))//ÉèÖÃÔËÓªÉÌÐÅÏ¢¸ñʽ

+        {

+            *next_req =normal_getcopsset(1,"3,2");

+			if(*next_req)

+			*next_len = strlen(*next_req);

+        }

+        else

+        {

+            *next_req = normal_getcopsread();

+			if(*next_req)

+            *next_len = strlen(*next_req);

+        }

+        return AT_CONTINUE;

+    }

+    return AT_END;

+}

+

+int  cusd_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    cfg_set("ussd_write_flag","4");

+    cfg_set("ussd_cancel_flag","no");

+    return AT_END;

+}

+

+int  clck_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    switch(context->msg_id)

+    {

+        case MSG_CMD_PIN_MANAGE_REQ:

+        {

+            if(psinfo.clck_state==CLCK_SET_CMD)

+            {

+                char clckMode[10] = {0};

+                cfg_get_item(NV_CLCK_SET_MODE,clckMode,sizeof(clckMode));

+                if (0==strcmp(clckMode,"0"))

+                {

+                    cfg_set(NV_NEED_SIM_PIN,"");

+                }

+                else if (0==strcmp(clckMode,"1"))

+                {

+                    cfg_set(NV_NEED_SIM_PIN,"yes");

+                }

+                cfg_set(NV_PIN_MANAGE_RESULT, "0");

+                *next_req=normal_getclckset(2,"SC",2);

+				if(*next_req){

+                *next_len=strlen(*next_req);

+                psinfo.clck_state=CLCK_REQ_CMD;

+                return AT_CONTINUE;

+				}

+            }

+            else if(psinfo.clck_state==CLCK_REQ_CMD)

+            {

+                *next_req=normal_getzrapread();

+				if(*next_req){

+                *next_len=strlen(*next_req);

+                psinfo.clck_state=CLCK_OTHER_CMD;

+                return AT_CONTINUE;

+				}

+            }

+            return AT_END;

+        }

+        case MSG_CMD_VERIFY_PUK_REQ:

+        {

+            MSG_BUF *buf=NULL;

+            buf=normal_getmsg(MODULE_ID_AT_CTL,MODULE_ID_AT_CTL,ATCTL_INNER_ZMSRI_MSG,0,NULL);

+            rcv_clt_req_msg_proc(buf);

+            free(buf);

+            return AT_END;

+        }

+#if (APP_OS_TYPE == APP_OS_LINUX)

+		case MSG_CMD_CLCK_REQ:

+		{

+//			return atCcapp_RecvOk(at_str,context,next_req,next_len);

+		}

+#endif		

+    }

+    return AT_END;

+}

+

+int  clck_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    switch(context->msg_id)

+    {

+        case MSG_CMD_PIN_MANAGE_REQ:

+        {

+            if(psinfo.clck_state==CLCK_SET_CMD)

+            {

+                cfg_set(NV_PIN_MANAGE_RESULT, "1");

+                *next_req=normal_getzrapread();

+				if(*next_req){

+                *next_len=strlen(*next_req);

+                psinfo.clck_state=CLCK_OTHER_CMD;

+                return AT_CONTINUE;

+				}

+            }

+            else if(psinfo.clck_state==CLCK_REQ_CMD)

+            {

+                cfg_set(NV_PIN_MANAGE_RESULT, "1");

+                *next_req=normal_getzrapread();

+				if(*next_req){

+                *next_len=strlen(*next_req);

+                psinfo.clck_state=CLCK_OTHER_CMD;

+                return AT_CONTINUE;

+				}

+            }

+            return AT_END;

+        }

+        

+        case MSG_CMD_VERIFY_PUK_REQ:

+        {

+            MSG_BUF *buf=NULL;

+            buf=normal_getmsg(MODULE_ID_AT_CTL,MODULE_ID_AT_CTL,ATCTL_INNER_ZMSRI_MSG,0,NULL);

+            rcv_clt_req_msg_proc(buf);

+            return AT_END;

+        }

+#if (APP_OS_TYPE == APP_OS_LINUX)

+		case MSG_CMD_CLCK_REQ:

+		{

+// for porting at_ctrl 

+// 			return atCcapp_RecvErr(at_str,context,next_req,next_len);

+		}

+#endif		

+    }

+    return AT_END;

+}

+

+int  cpwd_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    switch(context->msg_id)

+    {

+        case MSG_CMD_PIN_MANAGE_REQ:

+        {

+            cfg_set(NV_PIN_MANAGE_RESULT, "0");

+            *next_req=normal_getzrapread();

+			if(*next_req){

+            *next_len=strlen(*next_req);

+            return AT_CONTINUE;

+			}

+        }

+    }

+    return AT_END;

+}

+

+int  cpwd_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    switch(context->msg_id)

+    {

+        case MSG_CMD_PIN_MANAGE_REQ:

+        {

+            cfg_set(NV_PIN_MANAGE_RESULT, "1");

+            *next_req=normal_getzrapread();

+			if(*next_req){

+            *next_len=strlen(*next_req);

+            return AT_CONTINUE;

+			}	

+        }

+    }

+    return AT_END;

+}

+

+int mode_auto_act(char *at_paras ,int is_query_report)

+{

+    T_zUfi_ModeInfoInd   tAtRes      = {0};

+    char strTemp[10]    = {0};

+    char cfunState[50] = {0};

+	char versionmode[2] = {0};

+    MSG_BUF *buf=NULL;

+    

+    at_print(AT_DEBUG,"atBase_RecvModeRsp MODE \n");

+    cfg_get_item(NV_CFUN_STATE,cfunState,sizeof(cfunState));

+    if(!strcmp(cfunState,"0"))

+    {

+        return AT_END;

+    }

+	

+    void *p[2] = {&tAtRes.sys_mode, &tAtRes.sys_submode};

+    at_print(AT_DEBUG,"mode_auto_act at_paras=%s!\n",at_paras);

+    parse_param2("%d,%d", at_paras, p);

+    at_print(AT_DEBUG,"mode_auto_act sys_mode=%ld,sys_submode=%ld!\n",tAtRes.sys_mode,tAtRes.sys_submode);  

+    

+    snprintf(strTemp, sizeof(strTemp),"%ld", tAtRes.sys_mode);

+    cfg_set(NV_SYS_MODE, strTemp);

+    memset(strTemp, 0, 10);

+    snprintf(strTemp, sizeof(strTemp),"%ld", tAtRes.sys_submode);

+    cfg_set(NV_SYS_SUBMODE, strTemp);

+    

+    at_print(AT_DEBUG,"atBase_RecvModeRsp per=%d,cur=%ld!\n",g_zUfi_Mode,tAtRes.sys_mode);

+	//оƬÈÏÖ¤´úÂë

+	cfg_get_item("version_mode", versionmode, sizeof(versionmode));

+	if(0 == strcmp(versionmode, "0"))

+	{

+		if(g_zUfi_Mode != tAtRes.sys_mode || g_zUfi_SubMode != tAtRes.sys_submode)

+	    {

+	        g_zUfi_Mode = tAtRes.sys_mode;

+			g_zUfi_SubMode = tAtRes.sys_submode;

+			if(sysinfo_flag == 0)

+			{

+		        buf=normal_getmsg(MODULE_ID_AT_CTL,MODULE_ID_AT_CTL,MSG_CMD_QUERY_SYSINFO_REQ,0,NULL);

+		        rcv_clt_req_msg_proc(buf);

+		        free(buf);

+				sysinfo_flag = 1;//sysinfoÖ»·¢Ò»´Î

+			}

+	    }

+	}

+    return AT_END;

+}

+

+int cereg_auto_act(char *at_paras ,int is_query_report)

+{

+    T_zAt_CeregRes tAtRes = {0};

+    MSG_BUF *buf=NULL;

+	int tac = 0, ci = 0;

+    char strBuf[20] = {0};

+	char versionmode[2] = {0};

+

+    void *p[5] = {&tAtRes.stat, tAtRes.tac, tAtRes.ci, &tAtRes.act,&tAtRes.subact};

+    at_print(AT_DEBUG,"atBase_RecvCeregRsp at_paras=%s!\n",at_paras);

+    parse_param2("%d,%s,%s,%d,%d", at_paras, p);

+    at_print(AT_DEBUG,"atBase_RecvCeregRsp stat=%d,tac=%s,ci=%s,res=%d,sub=%d!\n",

+    tAtRes.stat, tAtRes.tac, tAtRes.ci, tAtRes.act,tAtRes.subact);  

+    sprintf(strBuf, "%d", tAtRes.stat);

+    cfg_set("cereg_stat", strBuf);

+

+	if(tAtRes.act == 7)

+	{

+		trans_Str2Value(tAtRes.tac, FALSE, &tac);

+		memset(strBuf, 0x00, 20);

+		sprintf(strBuf, "%d", tac);

+		cfg_set(NV_TAC_CODE, strBuf);

+		

+		trans_Str2Value(tAtRes.ci, FALSE, &ci);

+		memset(strBuf, 0x00, 20);

+		sprintf(strBuf, "%d", ci);

+		cfg_set(NV_CELL_ID, strBuf);

+	}

+	

+    /*×¢²áÁËÂþÓÎÍøÂç»ò±¾µØÍøÂç*/

+    if( (5 == tAtRes.stat ) || ( 1 == tAtRes.stat ))

+    {

+		buf=normal_getmsg(MODULE_ID_AT_CTL,MODULE_ID_AT_CTL,MSG_CMD_QUERY_CGCONTRDP_REQ,0,NULL);

+		rcv_clt_req_msg_proc(buf);

+		free(buf);

+        cfg_set(NV_REG_STATUS,"ok");

+		//zhangfen 1106 EPSÍøÂç×¢²á³É¹¦½øÐÐPDP×Ô¶¯²¦ºÅ

+		if(g_modem_model)

+    	{

+			start_pdp_auto_dial();//Æô¶¯¶¨Ê±Æ÷½øÐÐpdp¼¤»î

+    	}

+    }

+    else

+    {

+        cfg_set(NV_REG_STATUS,"no");

+    }

+    at_print(AT_DEBUG,"atBase_RecvCeregRsp per=%d,cur=%d!\n",g_zUfi_Stat,tAtRes.stat);

+

+	//оƬÈÏÖ¤´úÂë

+	cfg_get_item("version_mode", versionmode, sizeof(versionmode));

+	if(0 == strcmp(versionmode, "0"))

+	{

+		if(g_zUfi_Stat != tAtRes.stat)

+		{

+	        g_zUfi_Stat = tAtRes.stat;

+			if(sysinfo_flag == 0)

+			{

+		        buf=normal_getmsg(MODULE_ID_AT_CTL,MODULE_ID_AT_CTL,MSG_CMD_QUERY_SYSINFO_REQ,0,NULL);

+		        rcv_clt_req_msg_proc(buf);

+		        free(buf);

+				sysinfo_flag = 1;//sysinfoÖ»·¢Ò»´Î

+			}

+	    }

+		else

+		{

+			char networkType[50] = {0};

+        	cfg_get_item(NV_NETWORK_TYPE,networkType,sizeof(networkType));

+			if((5 == tAtRes.stat || 1 == tAtRes.stat) && (0 == strcmp("No Service",networkType) || 0 == strcmp("Limited Service",networkType)))

+			{

+				if(sysinfo_flag == 0)

+				{

+			        buf=normal_getmsg(MODULE_ID_AT_CTL,MODULE_ID_AT_CTL,MSG_CMD_QUERY_SYSINFO_REQ,0,NULL);

+			        rcv_clt_req_msg_proc(buf);

+			        free(buf);

+					sysinfo_flag = 1;//sysinfoÖ»·¢Ò»´Î

+				}

+			}

+		}

+	}

+    return AT_END;

+}

+

+int can_poweron_dail = 0;

+extern int apn_is_ims;

+int cgreg_auto_act(char *at_paras ,int is_query_report)

+{

+    T_zAt_CgregRes   tAtRes  = {0};

+    MSG_BUF *buf=NULL;

+    char strBuf[10] = {0};

+	char versionmode[2] = {0};

+

+    void *p[6] = {&tAtRes.stat, tAtRes.lac, tAtRes.rac, &tAtRes.act, tAtRes.ci, &tAtRes.subact};

+    at_print(AT_DEBUG,"cgreg_auto_act at_paras=%s!\n",at_paras);

+    parse_param2("%d,%s,%s,%d,%s,%d", at_paras, p);

+    at_print(AT_DEBUG,"cgreg_auto_act stat=%d,lac=%s,rac=%s,act=%d,ci=%s,subact=%d!\n",

+    tAtRes.stat, tAtRes.lac, tAtRes.rac, tAtRes.act, tAtRes.ci, tAtRes.subact);  

+

+    snprintf(strBuf,sizeof(strBuf),"%d", tAtRes.stat);

+    cfg_set("cgreg_stat", strBuf);

+	

+    if(cfun_state==0)

+    {

+        at_print(AT_ERR,"query cgreg err!\n");

+        return AT_END;

+    }

+    /*×¢²áÁËÂþÓÎÍøÂç»ò±¾µØÍøÂç*/

+    if( (5 == tAtRes.stat ) || ( 1 == tAtRes.stat ))

+    {

+		MSG_BUF *msg_buf = NULL;

+		char ppp_status[20] = {0};

+		cfg_get_item(NV_PPP_STATUS, ppp_status, sizeof(ppp_status));

+		//Ö»Óе±Ê״請úºó£¬Ö÷¿ØÔø¾­Ö÷¶¯·¢Æð¹ý²¦ºÅ²¢ÇÒûÓв¦ºÅ³É¹¦£¬´ËʱÔÚÓÐÍøÂçºó

+		//at_ctlÄ£Äâ³ÉÖ÷¿ØÖØÐ·¢Æðpdp¼¤»î

+		if((can_poweron_dail == 0) && (g_defcid_mng.modid == MODULE_ID_MAIN_CTRL) && (0 == strcmp(PPP_DISCONNECTED, ppp_status)))

+		{

+			can_poweron_dail = 1;

+			at_print(AT_ERR,"cgreg_auto_act begin dial!!!\n");

+			msg_buf=normal_getmsg(g_defcid_mng.modid ,MODULE_ID_AT_CTL,MSG_CMD_PDP_ACT_REQ, 0, NULL);

+			rcv_msg_proc(msg_buf);

+			free(msg_buf);

+			msg_buf = NULL;

+		}

+    	if(g_modem_model)

+    	{

+			start_pdp_auto_dial();

+    	}

+        cfg_set(NV_TDREG_STATUS,"ok");

+		//apn_is_ims=-1;//4GºÍ2-3G¿ÉÄÜͬʱ´æÔÚEC:616000620973

+    }

+    else

+    {

+        cfg_set(NV_TDREG_STATUS,"no");

+    }

+    at_print(AT_DEBUG,"atBase_RecvCgregRsp per=%d,cur=%d!\n",g_zUfi_Stat,tAtRes.stat);

+

+	//оƬÈÏÖ¤´úÂë

+	cfg_get_item("version_mode", versionmode, sizeof(versionmode));

+	if(0 == strcmp(versionmode, "0"))

+	{

+	    if(g_zUfi_Stat != tAtRes.stat && g_modem_model)

+	    {

+	        g_zUfi_Stat = tAtRes.stat;

+			if(sysinfo_flag == 0)

+			{

+		        buf=normal_getmsg(MODULE_ID_AT_CTL,MODULE_ID_AT_CTL,MSG_CMD_QUERY_SYSINFO_REQ,0,NULL);

+		        rcv_clt_req_msg_proc(buf);

+		        free(buf);

+				sysinfo_flag = 1;//sysinfoÖ»·¢Ò»´Î

+			}

+	    }

+		else

+		{

+			char networkType[50] = {0};

+        	cfg_get_item(NV_NETWORK_TYPE,networkType,sizeof(networkType));

+			if((5 == tAtRes.stat || 1 == tAtRes.stat) && (0 == strcmp("No Service",networkType) || 0 == strcmp("Limited Service",networkType)))

+			{

+				if(sysinfo_flag == 0)

+				{

+			        buf=normal_getmsg(MODULE_ID_AT_CTL,MODULE_ID_AT_CTL,MSG_CMD_QUERY_SYSINFO_REQ,0,NULL);

+			        rcv_clt_req_msg_proc(buf);

+			        free(buf);

+					sysinfo_flag = 1;//sysinfoÖ»·¢Ò»´Î

+				}

+			}

+		}

+	}

+    return AT_END;

+}

+

+

+int creg_auto_act(char *at_paras ,int is_query_report)

+{

+    T_zAt_CregRes   tAtRes      = {0};

+    MSG_BUF *buf=NULL;

+	int lac = 0, ci = 0;

+    char strBuf[20] = {0};

+	char versionmode[2] = {0};

+	

+    void *p[5] = {&tAtRes.stat, tAtRes.tac, tAtRes.ci, &tAtRes.act,&tAtRes.subact};

+    at_print(AT_DEBUG,"creg_auto_act at_paras=%s!\n",at_paras);

+    parse_param2("%d,%s,%s,%d,%d", at_paras, p);

+    at_print(AT_DEBUG,"creg_auto_act stat=%d,tac=%s,ci=%s,act=%d,subact=%d!\n",

+    tAtRes.stat, tAtRes.tac, tAtRes.ci, tAtRes.act, tAtRes.subact);  

+

+    sprintf(strBuf, "%d", tAtRes.stat);

+    cfg_set("creg_stat", strBuf);

+

+	if(tAtRes.act != 7)

+	{

+		trans_Str2Value(tAtRes.tac, FALSE, &lac);

+		memset(strBuf, 0x00, 20);

+		sprintf(strBuf, "%d", lac);

+		cfg_set(NV_LAC_CODE, strBuf);

+		

+		trans_Str2Value(tAtRes.ci, FALSE, &ci);

+		memset(strBuf, 0x00, 20);

+		sprintf(strBuf, "%d", ci);

+		cfg_set(NV_CELL_ID, strBuf);

+	}

+	

+    /*×¢²áÁËÂþÓÎÍøÂç»ò±¾µØÍøÂç*/

+    if( (5 == tAtRes.stat ) || ( 1 == tAtRes.stat ))

+    {

+    	if(g_modem_model)

+    	{

+			start_pdp_auto_dial();

+    	}

+    	//zhangfen for PDP

+		//ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_MAIN_CTRL, MSG_CMD_NET_AUTO_DIAL, 0, NULL, 0);

+        cfg_set(NV_REG_STATUS,"ok");

+

+		ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_DMREG, MSG_CMD_CREG_IND, 0, NULL, 0);

+    }

+    else

+    {

+        cfg_set(NV_REG_STATUS,"no");

+    }

+    at_print(AT_DEBUG,"atBase_RecvCregRsp per=%d,cur=%d!\n",g_zUfi_Stat,tAtRes.stat);

+	

+    //оƬÈÏÖ¤´úÂë

+	cfg_get_item("version_mode", versionmode, sizeof(versionmode));

+	if(0 == strcmp(versionmode, "0"))

+	{

+	    if(g_zUfi_Stat != tAtRes.stat)

+	    {

+			if(cfun_state==0 && g_modem_model)

+		    {

+		        at_print(AT_ERR,"query creg err!\n");

+		        return AT_END;

+		    }

+	        g_zUfi_Stat = tAtRes.stat;

+			if(sysinfo_flag == 0)

+			{

+		        buf=normal_getmsg(MODULE_ID_AT_CTL,MODULE_ID_AT_CTL,MSG_CMD_QUERY_SYSINFO_REQ,0,NULL);

+		        rcv_clt_req_msg_proc(buf);

+		        free(buf);

+				sysinfo_flag = 1;//sysinfoÖ»·¢Ò»´Î

+			}

+	    }

+		else

+		{

+			char networkType[50] = {0};

+        	cfg_get_item(NV_NETWORK_TYPE,networkType,sizeof(networkType));

+			if((5 == tAtRes.stat || 1 == tAtRes.stat) && (0 == strcmp("No Service",networkType) || 0 == strcmp("Limited Service",networkType)))

+			{

+				if(sysinfo_flag == 0)

+				{

+			        buf=normal_getmsg(MODULE_ID_AT_CTL,MODULE_ID_AT_CTL,MSG_CMD_QUERY_SYSINFO_REQ,0,NULL);

+			        rcv_clt_req_msg_proc(buf);

+			        free(buf);

+					sysinfo_flag = 1;//sysinfoÖ»·¢Ò»´Î

+				}

+			}

+		}

+	}

+    return AT_END;

+}

+

+//»ñÈ¡ÍøÂçÐźÅ״̬£¬ÖÃNV

+int sysinfo_auto_act(char *at_paras ,int is_query_report)

+{

+    T_zAt_SysinfoRes tPara                       = {0};

+	UINT32 signalbar = 0;

+	char needDispSearching[10] = {0};

+	char modemMainState[50] = {0};

+	char networkCategoryBasedOn[10] = {0};

+	char strSignalbar[10] = {0};

+	char perRoamStatus[10] = {0};

+	char curRoamStatus[10] = {0};

+

+    void *p[7] = {&tPara.srvStatus, &tPara.srvDomain,&tPara.roamStatus,&tPara.sysMode, &tPara.simState,&tPara.reserve,&tPara.sysSubmode};

+    at_print(AT_DEBUG,"sysinfo_auto_act at_paras=%s!\n",at_paras);

+    parse_param2("%d,%d,%d,%d,%d,%d,%d", at_paras, p);

+    at_print(AT_DEBUG,"sysinfo_auto_act srvStatus=%ld,srvDomain=%ld,roamStatus=%ld,sysMode=%ld,simState=%ld,reserve=%ld,sysSubmode=%ld!\n",

+    tPara.srvStatus,tPara.srvDomain,tPara.roamStatus,tPara.sysMode,tPara.simState,tPara.reserve,tPara.sysSubmode);  

+

+	cfg_get_item("need_display_searching_status", needDispSearching, sizeof(needDispSearching));

+	cfg_get_item("modem_main_state", modemMainState, sizeof(modemMainState));

+	cfg_get_item("network_category_based_on", networkCategoryBasedOn, sizeof(networkCategoryBasedOn));

+	if(0 == tPara.srvStatus)//ÎÞ·þÎñ

+    {

+	    if(0 == strcmp("yes", needDispSearching))

+		{

+			if(g_isSearchingNetwork == TRUE)

+			{

+	            if(strcmp(modemMainState,"modem_init_complete") == 0)

+	            {

+					cfg_set(NV_NETWORK_TYPE, NETWORK_TYPE_INIT);

+					cfg_set(NV_SUB_NETWORK_TYPE, NETWORK_TYPE_INIT);

+	            }

+				else

+				{

+					cfg_set(NV_NETWORK_TYPE, "No Service");

+					cfg_set(NV_SUB_NETWORK_TYPE, "No Service");

+				}

+			}

+			else

+			{

+	        	cfg_set(NV_NETWORK_TYPE, "No Service");

+				cfg_set(NV_SUB_NETWORK_TYPE, "No Service");

+			}

+		}		

+		else

+		{

+			cfg_set(NV_NETWORK_TYPE, "No Service");

+			cfg_set(NV_SUB_NETWORK_TYPE, "No Service");

+		}  		

+		signalbar = 0;

+        ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_MMI,MSG_CMD_OUT_REG_GET_SIGNAL_NUM, sizeof(signalbar), (UINT8 *)&signalbar,0);

+    }

+    else if( 1 == tPara.srvStatus )

+    {

+        if(0 == strcmp("yes", needDispSearching))

+		{

+			if(g_isSearchingNetwork == TRUE)

+			{

+				if(strcmp(modemMainState,"modem_init_complete") == 0)

+	            {

+					cfg_set(NV_NETWORK_TYPE, NETWORK_TYPE_INIT);

+					cfg_set(NV_SUB_NETWORK_TYPE, NETWORK_TYPE_INIT);

+	            }

+				else

+				{

+					cfg_set(NV_NETWORK_TYPE, "Limited Service");

+					cfg_set(NV_SUB_NETWORK_TYPE, "Limited Service");

+                }

+			}

+			else

+			{

+	 	       cfg_set(NV_NETWORK_TYPE, "Limited Service");

+			   cfg_set(NV_SUB_NETWORK_TYPE, "Limited Service");

+ 			}

+		}		

+		else

+		{

+			cfg_set(NV_NETWORK_TYPE, "Limited Service");

+			cfg_set(NV_SUB_NETWORK_TYPE, "Limited Service");

+		}		

+		signalbar = 0;

+        ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_MMI,MSG_CMD_OUT_REG_GET_SIGNAL_NUM, sizeof(signalbar), (UINT8 *)&signalbar,0);

+    }

+    else

+    {

+    	if(0 == strcmp("yes", needDispSearching))

+	    {

+			g_isSearchingNetwork = FALSE;

+        }

+        char    netCategory[50]  = {0};

+        char    connectLogic[50]  = {0};

+        cfg_get_item(NV_NETWORK_CATEGORY_BASED_ON,netCategory,sizeof(netCategory));

+        cfg_get_item(NV_CONNECT_LOGIC,connectLogic,sizeof(connectLogic));

+        

+        //normal_sysinfosetdomainstat(tPara.srvDomain);

+        if(0 == strcmp("act", netCategory))

+		{

+			normal_sysinfosysmodecfgset(tPara.sysMode,tPara.sysSubmode);

+		}

+        else

+        {

+			normal_sysinfonetworktypeSet(tPara.sysMode,tPara.sysSubmode);

+		}

+        

+        //if(0!=strcmp("cpe",connectLogic) && 0!=strcmp("five_times",connectLogic))

+        //{

+        //    normal_sysinfodomainpdpdail(tPara.srvDomain);

+        //}

+		cfg_get_item("signalbar", strSignalbar, sizeof(strSignalbar));

+        signalbar = atoi(strSignalbar);

+        ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_MMI,MSG_CMD_OUT_REG_GET_SIGNAL_NUM, sizeof(signalbar), (UINT8 *)&signalbar,0);

+

+		//zhangfen for PDP

+		//ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_MAIN_CTRL, MSG_CMD_NET_AUTO_DIAL, 0, NULL, 0);

+				

+		if(g_modem_model)

+		{

+			//static int can_poweron_dail = 0;

+			MSG_BUF *msg_buf = NULL;

+			char ppp_status[20] = {0};

+			cfg_get_item(NV_PPP_STATUS, ppp_status, sizeof(ppp_status));

+			//Ö»Óе±Ê״請úºó£¬Ö÷¿ØÔø¾­Ö÷¶¯·¢Æð¹ý²¦ºÅ²¢ÇÒûÓв¦ºÅ³É¹¦£¬´ËʱÔÚÓÐÍøÂçºó

+			//at_ctlÄ£Äâ³ÉÖ÷¿ØÖØÐ·¢Æðpdp¼¤»î

+			if((can_poweron_dail == 0) && (g_defcid_mng.modid == MODULE_ID_MAIN_CTRL) && (0 == strcmp(PPP_DISCONNECTED, ppp_status)))

+		    {

+				char creg_stat[20] = {0};

+				char cereg_stat[20] = {0};

+				

+				cfg_get_item("cgreg_stat", creg_stat, sizeof(creg_stat));

+				cfg_get_item("cereg_stat", cereg_stat, sizeof(cereg_stat));

+				at_print(AT_DEBUG,"@@@@@@@@@@@@@sysinfo_auto_act  creg stat=%s, cereg stat=%s!\n",creg_stat,cereg_stat);

+				//zpr 1218 GPRSS&EPSûע²áºÃ£¬²»·¢Æð

+				if(1 != atoi(creg_stat) && 5 != atoi(creg_stat) && 1 != atoi(cereg_stat) && 5 != atoi(cereg_stat))

+				{

+					//return 0;

+				}

+				else

+				{

+		        can_poweron_dail = 1;

+				#if 0

+		        struct pdp_act_req *pdpsetinfo=NULL;

+		        pdpsetinfo=malloc(sizeof(struct pdp_act_req));

+		        if(pdpsetinfo == NULL){softap_assert("");}

+		        memset(pdpsetinfo,0,sizeof(struct pdp_act_req));

+		        normal_getcurparam(pdpsetinfo);

+		        cfg_set("auto_reconnect", "1");

+				#endif

+				

+				at_print(AT_ERR,"sysinfo_auto_act begin dial!!!\n");

+				msg_buf=normal_getmsg(g_defcid_mng.modid ,MODULE_ID_AT_CTL,MSG_CMD_PDP_ACT_REQ, 0, NULL);

+				rcv_msg_proc(msg_buf);

+				free(msg_buf);

+				msg_buf = NULL;

+				}

+		    }

+		}

+	}

+

+	cfg_get_item(NV_SIMCARD_ROAM, perRoamStatus, sizeof(perRoamStatus));

+    if(0 == tPara.roamStatus)

+    {

+		cfg_set(NV_SIMCARD_ROAM,"Home");

+	}

+	else

+	{

+		if(TRUE == normal_checkroam(mccNum, mncNum))

+		{

+		    cfg_set(NV_SIMCARD_ROAM,"Home");

+			tPara.roamStatus = 0;

+		}

+	    else

+		{

+		    cfg_set(NV_SIMCARD_ROAM,"Internal"); 

+		}

+    }

+

+	cfg_get_item(NV_SIMCARD_ROAM, curRoamStatus, sizeof(curRoamStatus));

+	if(strcmp(perRoamStatus, curRoamStatus) != 0)

+	{

+		ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_DMREG, MSG_CMD_ROAM_STATUS_IND, 0, NULL, 0);

+	}

+	

+    if(0 == strcmp("yes", needDispSearching))

+	{

+	   if(g_isSearchingNetwork == FALSE)

+	   {

+			at_print(AT_DEBUG,"atBase_RecvSysInfoRsp, MSG_MMICHANNEL_NETWORK_MODE, tPara.srvStatus = %ld \n", tPara.srvStatus);

+		    ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_MMI,MSG_CMD_CHANNEL_NETWORK_MODE, sizeof(tPara), (UCHAR *)&tPara,0);

+	   }

+	}   

+	else

+    {

+        ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_MMI,MSG_CMD_CHANNEL_NETWORK_MODE, sizeof(tPara), (UCHAR *)&tPara,0);

+    }

+    return AT_END;

+}

+

+int mac_auto_act(char *at_paras ,int is_query_report)

+{

+    mactozssid=malloc(128);

+    if(mactozssid == NULL){

+		softap_assert("");

+		return AT_END;

+	}

+    memset(mactozssid, 0, 128);    

+    snprintf(mactozssid,128,"+MAC:%s",at_paras);

+    return AT_END;

+}

+

+int mac2_auto_act(char *at_paras ,int is_query_report)

+{

+    if(mactozssid == NULL || strlen(mactozssid) >= 128){

+		softap_assert("");

+		return AT_END;

+	}

+    snprintf(mactozssid+strlen(mactozssid),128-strlen(mactozssid),";%s",at_paras);

+    return AT_END;

+}

+

+int clck_auto_act(char *at_paras ,int is_query_report)

+{

+    char strMode[10] = {0};

+    T_zAt_ClckSet_RES clckRspPara = {0};

+    int classVale = 0;

+    int status = 0;

+    sscanf(at_paras, "%d,%d",&status,&classVale);

+    clckRspPara.uclass  = (unsigned char)classVale;

+    clckRspPara.status  = (unsigned char)status;

+    sprintf(strMode,"%d", clckRspPara.status);

+    at_print(AT_DEBUG,"clck_auto_act uclass=%d,status=%d\n",status,classVale);

+    /*0£ºÎ´¼¤»î, 1£º¼¤»î*/

+    cfg_set(NV_PIN_STATUS, strMode);

+    return AT_END;

+}

+

+int zpbic_auto_act(char *at_paras ,int is_query_report)

+{

+    T_zAt_ZpbicRes AtRes = {0};

+    char ismsSwitch[2] = {0};

+    sscanf(at_paras, "%ld,%ld", &AtRes.result, &AtRes.opertype);

+    at_print(AT_DEBUG,"zpbic_auto_act str:%s,result:%ld,opertype:%ld\n",at_paras,AtRes.result, AtRes.opertype);

+

+    if((1 == AtRes.result) && (1 == AtRes.opertype))

+    {

+    	cfg_set("zpbic_pb", "ready");

+	    if(g_modem_model)

+	    {

+	    	g_smspb_init |= (1<<AtRes.opertype);

+			at_print(AT_NORMAL,"1.sms_pb init flag: %d\n", g_smspb_init);

+			if(((g_smspb_init & 0x03) == 0x03) && (g_need_smspb_init == 0))

+			{

+				char ppp_status[20] = {0};

+				cfg_get_item(NV_PPP_STATUS, ppp_status, sizeof(ppp_status));

+				if(0 == strcmp("ppp_connected", ppp_status))

+					pbsms_init_msg_proc();//Èç¹ûÒѾ­²¦ºÅ³É¹¦£¬Ö±½Ó¸øpbºÍsmsÓ¦Ó÷¢Æð³õʼ»¯ÏûÏ¢

+				else

+					pbsms_init_timerout(&AtRes);//pbºÍsms¶¼³õʼ»¯Íê³Éºó²ÅÄÜÆð¶¨Ê±Æ÷

+			}

+	    }

+		

+		char versionmode[2] = {0};

+		MSG_BUF *buf = NULL;

+        //оƬÈÏÖ¤´úÂë

+		cfg_get_item("version_mode", versionmode, sizeof(versionmode));

+		if(0 == strcmp(versionmode, "0"))	

+		{

+	    	buf = normal_getmsg(MODULE_ID_AT_CTL,MODULE_ID_AT_CTL,MSG_CMD_MODEMREG_INFO_REQ,0,NULL);

+	    	rcv_clt_req_msg_proc(buf);

+	    	free(buf);

+		}

+

+        at_print(AT_DEBUG,"zpbic_auto_act cnum\n");

+    }

+    else if((1 == AtRes.result) && (0 == AtRes.opertype))

+    {

+        at_print(AT_DEBUG,"zpbic_auto_act sms\n");

+#if (APP_OS_TYPE == APP_OS_LINUX)			

+#if 1 

+        cfg_get_item("isms_enable",ismsSwitch,sizeof(ismsSwitch));

+        if(1 == AtRes.result && 0==strcmp(ismsSwitch, "1"))

+        {

+/*        	cfg_set("isms_state", "0");

+            if(fork() == 0)

+            {

+        		cfg_set("isms_state", "1");

+                if(execv("/bin/zte_isms", NULL) < 0)

+                {

+        			cfg_set("isms_state", "2");

+                    at_print(AT_DEBUG,"execv error(%d)\n", errno);

+                    exit(0);

+                }

+            }

+            

+        	cfg_set("isms_state", "3");*/

+			if(system("/bin/zte_isms &") == 0)

+			{

+				cfg_set("isms_state", "3");

+			}

+			else

+			{

+				cfg_set("isms_state", "2");

+			}

+        }

+#endif

+#endif

+	    if(g_modem_model)

+	    {

+	    	g_smspb_init |= (1<<AtRes.opertype);

+	    	at_print(AT_NORMAL,"2.sms_pb init flag: %d\n", g_smspb_init);

+	    	if(((g_smspb_init & 0x03) == 0x03) && (g_need_smspb_init == 0))

+			{

+				char ppp_status[20] = {0};

+				cfg_get_item(NV_PPP_STATUS, ppp_status, sizeof(ppp_status));

+				if(0 == strcmp("ppp_connected", ppp_status))

+					pbsms_init_msg_proc();//Èç¹ûÒѾ­²¦ºÅ³É¹¦£¬Ö±½Ó¸øpbºÍsmsÓ¦Ó÷¢Æð³õʼ»¯ÏûÏ¢

+				else

+					pbsms_init_timerout(&AtRes);//pbºÍsms¶¼³õʼ»¯Íê³Éºó²ÅÄÜÆð¶¨Ê±Æ÷

+			}

+	    }

+    }

+    return AT_END;

+}

+//add corem0620 begin

+#define ZAT_CUSD_MAXLEN                     320

+#define ZAT_MAX_LEN                 7168 //1024

+#define AT_USSD_DATA_TO_WEB_LEN  900//ussd

+#define ZAT_TAB_REPLACE                     ((unsigned char )(0xFC))    /* ÖÆ±í·ûÌæ»»·û     */

+#define ZAT_NULL_FILL                       ((unsigned char )(0xFD))    /* ¿Õ´®Õ¼Î»·û       */

+#define ZAT_SPACE_REPLACE                   ((unsigned char )(0xFE))    /* ¿Õ¸ñÌæ»»·û       */

+#define ZAT_LF_REPLACE                      ((unsigned char )(0xFB))    /* LFÌæ»»·û         */

+#define ZAT_CR_REPLACE                      ((unsigned char )(0xFA))    /* CRÌæ»»·û */

+

+typedef struct

+{

+    SINT16  replyMsg;

+    CHAR    cusdDataStr[ZAT_CUSD_MAXLEN + 1];

+    SINT16  bDcs;

+} T_zAt_CusdRes;

+

+typedef enum

+{

+    ZAT_GSM7BIT = 0,

+    ZAT_8BIT,

+    ZAT_UCS2,

+    ZAT_INVALID,

+} T_zAt_CBSCodeType;

+VOID atBase_PreProcRes(CHAR *pParaLine, int paraSize)

+{

+    SINT32  flg                                     = 0;

+    UINT32  i                                       = 0;

+    UINT32  length                                  = 0;

+    CHAR    *pSource                                = pParaLine;

+    CHAR    *pDest                                  = NULL;

+    

+    CHAR    *pStrDestMalloc = (CHAR *)malloc(ZAT_MAX_LEN);

+    if(NULL == pStrDestMalloc)

+    {

+        return;

+    }

+    memset(pStrDestMalloc, 0, ZAT_MAX_LEN); 

+    

+    assert(pParaLine != NULL);

+    pDest = pStrDestMalloc;

+    length = strlen(pParaLine);

+    if ((length == 0) || (length >= ZAT_MAX_LEN))

+    {

+        free(pStrDestMalloc);

+        return;

+    }

+    for (i = 0; (i < length )&& (pDest - pStrDestMalloc < ZAT_MAX_LEN); i++)

+    {

+        if ('"' == *pSource)

+        {

+            flg = (0 == flg)?1:0;                           /* Ë«ÒýºÅ ɾ³ý  */

+            if ('"' == *(pSource + 1))                      /* ÐǺźóÃæ½ô¸úÐǺţ¬²åÈë¿Õ´®Õ¼Î»·û */

+            {

+                *pDest++ = (CHAR)ZAT_NULL_FILL;

+            }

+        }

+        else if ((',' == *pSource) && (0 == flg))

+        {

+            *pDest++ = ' ';                                 /* Ë«ÒýºÅÍâÃæµÄ¶ººÅ£¬Ìæ»»³É¿Õ¸ñ */

+            if(',' == *(pSource + 1))                       /* ¶ººÅºóÃæ½ô¸ú¶ººÅ£¬»òÕßÒÔ¶ººÅ½á⣬²åÈë¿Õ´®Õ¼Î»·û */

+            {

+                *pDest++ = '9';                             //±£Áô²ÎÊýÓÃ9ÔÝʱ´úÌæ

+            }

+            else if('\0' == *(pSource + 1))                 /* ¶ººÅºóÃæ½ô¸ú¶ººÅ£¬»òÕßÒÔ¶ººÅ½á⣬²åÈë¿Õ´®Õ¼Î»·û */

+            {

+                *pDest++ = (CHAR)ZAT_NULL_FILL;

+            }

+        }

+        else

+        {

+            //*pDest++ = ((' ' == *pSource) && (1 == flg))?(CHAR)ZAT_SPACE_REPLACE:((('\t' == *pSource) && (1 == flg))?(CHAR)ZAT_TAB_REPLACE:((('\n' == *pSource) && (1 == flg))?(CHAR)ZAT_LF_REPLACE:((('\r' == *pSource) && (1 == flg))?(CHAR)ZAT_CR_REPLACE:(*pSource))));

+            if((' ' == *pSource) && (1 == flg))

+			{

+				*pDest++ = (CHAR)ZAT_SPACE_REPLACE;

+			}

+			else if(('\t' == *pSource) && (1 == flg))

+			{

+				*pDest++ = (CHAR)ZAT_TAB_REPLACE;

+			}

+			else if(('\n' == *pSource) && (1 == flg))

+			{

+				*pDest++ = (CHAR)ZAT_LF_REPLACE;

+			}

+			else if(('\r' == *pSource) && (1 == flg))

+			{

+				*pDest++ = (CHAR)ZAT_CR_REPLACE;

+			}

+			else

+			{

+				*pDest++ = *pSource;

+			}

+        }

+        pSource++;

+    }

+    memset(pParaLine, 0, paraSize);                           /* ½«Ô¤´¦ÀíºóµÄÄÚÈÝ¿½±´»Ø²ÎÊýÐÐÖÐ */

+    strncpy(pParaLine, pStrDestMalloc,paraSize-1);

+    free(pStrDestMalloc);

+}

+

+

+VOID atBase_RestoreString(CHAR *pStringPara)

+{

+    SINT32  i           = 0;

+    SINT32  length      = 0;

+    CHAR*   pstrTemp    = 0;

+    /* ²ÎÊý¼ì²é ¡¢ ³¤¶È¼ì²é*/

+    assert(pStringPara != NULL);

+	

+    length = (SINT32)strlen(pStringPara);

+	if ( 0 == length)

+    {

+        return;

+    }

+	

+    /* ¿Õ´®Õ¼Î»·û»Ö¸´ */

+    if ((1 == length) && ((CHAR) ZAT_NULL_FILL == *pStringPara))

+    {

+        *pStringPara = '\0';

+        return;

+    }

+    /* Ñ­»·»Ö¸´¿Õ¸ñÌæ»»·ûºÍÖÆ±í·ûÌæ»»·û */

+    pstrTemp = pStringPara;

+    for (i = 0; i < length; i++)

+    {

+        if ((CHAR) ZAT_SPACE_REPLACE == *pstrTemp)

+        {

+            *pstrTemp = ' ';

+        }

+        else if ((CHAR) ZAT_TAB_REPLACE == *pstrTemp)

+        {

+            *pstrTemp = '\t';

+        }

+        else if((CHAR) ZAT_LF_REPLACE == *pstrTemp)

+        {

+            *pstrTemp = '\n';

+        }

+        else if((CHAR) ZAT_CR_REPLACE == *pstrTemp)

+        {

+            *pstrTemp = '\r';

+        }

+        else

+        {

+            ;

+        }

+        pstrTemp++;

+    }

+}

+//USSD

+T_zAt_CBSCodeType atBase_CheckDataCodeType(SINT16 bDcs)

+{

+    UINT16 value76 = (bDcs & 0xC0) >> 6;

+    UINT16 value74 = (bDcs & 0xF0) >> 4;

+    UINT16 value30 = (bDcs & 0x0F);

+    UINT16 value32 = (bDcs & 0x0C) >> 2;

+    UINT16 value2  = (bDcs & 0x04) >> 2;

+

+    if((value74 == 0) || (value74 == 2) || (value74 == 3) || (value74 == 8) ||

+        (value74 == 10) || (value74 == 11) || (value74 == 12))

+    {

+        return ZAT_GSM7BIT;

+    }

+    else if((value74 == 1) && (value30 == 1))

+    {

+        return ZAT_UCS2;

+    }

+    else if((value74 == 1) && (value30 != 1))

+    {

+        return ZAT_GSM7BIT;

+    }

+    else if((value76 == 1) && ((value32 == 0) || (value32 == 3)))

+    {

+        return ZAT_GSM7BIT;

+    }

+    else if((value76 == 1) && (value32 == 1))

+    {

+        return ZAT_8BIT;

+    }

+    else if((value76 == 1) && (value32 == 2))

+    {

+        return ZAT_UCS2;

+    }

+    else if((value74 == 9) && ((value32 == 0) || (value32 == 3)))

+    {

+        return ZAT_GSM7BIT;

+    }

+    else if((value74 == 9) && (value32 == 1))

+    {

+        return ZAT_8BIT;

+    }

+    else if((value74 == 9) && (value32 == 2))

+    {

+        return ZAT_UCS2;

+    }

+    else if((value74 == 15) && (value2 == 0))

+    {

+        return ZAT_GSM7BIT;

+    }

+    else if((value74 == 15) && (value2 == 1))

+    {

+        return ZAT_8BIT;

+    }

+    return ZAT_INVALID;

+}

+

+VOID atBase_ConvertAsciiToUCS2(const CHAR *dataStr,CHAR *convertDataStr,UINT16 dataLen)

+{

+    UINT16 iDataLen = 0;

+    

+    if((dataStr == NULL) || (convertDataStr == NULL) || (dataLen <= 0))

+    {

+        return;

+    }

+    for(iDataLen = 0;iDataLen < dataLen;iDataLen++)

+    {

+        snprintf(convertDataStr+strlen(convertDataStr),AT_USSD_DATA_TO_WEB_LEN,"%04x",dataStr[iDataLen]);

+    }

+    printf("%s\n",convertDataStr);

+}

+

+VOID atBase_Convert8BitToUCS2(const CHAR *dataStr,CHAR *convertDataStr,UINT16 dataLen)

+{

+    UINT16 iDataLen = 0;

+    

+    if((dataStr == NULL) || (convertDataStr == NULL) || (dataLen <= 0))

+    {

+        return;

+    }

+    for(iDataLen = 0;iDataLen < dataLen;iDataLen++)

+    {

+        if(iDataLen%2 == 0)

+	 {

+	      snprintf(convertDataStr+strlen(convertDataStr),AT_USSD_DATA_TO_WEB_LEN,"00%c",dataStr[iDataLen]);

+	 }

+	 else

+	 {

+	      snprintf(convertDataStr+strlen(convertDataStr),AT_USSD_DATA_TO_WEB_LEN,"%c",dataStr[iDataLen]);

+	 }

+     }

+     printf("%s\n",convertDataStr);

+}

+

+

+BOOL atBase_ConvertUCS2SetNV(T_zAt_CBSCodeType cbsCodeType,const CHAR *cusdDataStr,CHAR *convertDataStr,UINT16 dataLen)

+{

+    if((cbsCodeType == ZAT_INVALID) || (cusdDataStr == NULL) || (convertDataStr == NULL) || (dataLen <= 0))

+    {

+        return FALSE;

+    }

+    if(cbsCodeType == ZAT_GSM7BIT)

+    {

+        atBase_ConvertAsciiToUCS2(cusdDataStr,convertDataStr,dataLen);

+        cfg_set("ussd_content",convertDataStr);

+        return TRUE;

+    }

+    else if(cbsCodeType == ZAT_8BIT)

+    {

+        atBase_Convert8BitToUCS2(cusdDataStr,convertDataStr,dataLen);

+        cfg_set("ussd_content",convertDataStr);

+        return TRUE;

+    }

+    else if(cbsCodeType == ZAT_UCS2)

+    {

+        cfg_set("ussd_content",cusdDataStr);

+        return TRUE;

+    }

+    else

+    {

+        printf("DCS Reported can't be processed!!!!\n");

+        return FALSE;

+    }

+}

+

+static int get_param_count_for_ussd(const char *str){//corem0418

+    int fmt_param_count = 0;

+    

+    for(; *str != '\0'; str++){

+        if(*str == ','){

+            fmt_param_count++;

+        }

+    }

+    return fmt_param_count;

+}

+

+int cusd_auto_act(char *at_paras ,int is_query_report)

+{

+    T_zAt_CusdRes                    cusdParam = {0};

+    T_zAt_CBSCodeType            cbsCodeType = ZAT_INVALID;

+    CHAR convertDataStr[AT_USSD_DATA_TO_WEB_LEN] = {0};

+    //static int flag = 0;

+

+	at_print(AT_ERR,"!!!!cusd_auto_act start.\n");

+    if(at_paras == NULL)

+    {

+        return AT_END;

+    }

+	

+

+    at_print(AT_ERR,"!!!!cusd_auto_act Gets %s.\n", at_paras);

+

+//    void *p[3] = {&cusdParam.replyMsg,  cusdParam.cusdDataStr, &cusdParam.bDcs};

+

+//    parse_param("%d %s %d", at_paras, p);

+	

+//    at_print(AT_DEBUG,"cusd_auto_act  replyMsg=%d, cusdDataStr=%s, bDcs=%d!\n",  cusdParam.replyMsg, cusdParam.cusdDataStr, cusdParam.bDcs);  	

+    

+    if(get_param_count_for_ussd(at_paras) > 0){//corem0418           

+           atBase_PreProcRes(at_paras, strlen(at_paras));

+	    at_print(AT_ERR,"!!!!cusd_auto_act Gets 3 para:%s\n", at_paras);

+	    sscanf(at_paras, "%hd %320s %hd",&cusdParam.replyMsg,cusdParam.cusdDataStr,&cusdParam.bDcs);

+	    

+    }else{

+           at_print(AT_ERR,"!!!!cusd_auto_act Gets 1 para:%s\n", at_paras);         

+	   sscanf(at_paras, "%hd",&cusdParam.replyMsg);

+    }

+

+    at_print(AT_ERR,"cusd_auto_act before restore MSG  replyMsg=%d, cusdDataStr=%s, bDcs=%d!\n",  cusdParam.replyMsg, cusdParam.cusdDataStr, cusdParam.bDcs);  

+

+    atBase_RestoreString(cusdParam.cusdDataStr);

+	

+    at_print(AT_ERR,"cusd_auto_act after restore MSG replyMsg=%d, cusdDataStr=%s, bDcs=%d!\n",  cusdParam.replyMsg, cusdParam.cusdDataStr, cusdParam.bDcs);

+	

+    //printf("atBase_RecvCusdRsp :%d,%s,%d",cusdParam.replyMsg,cusdParam.cusdDataStr,cusdParam.bDcs);

+    if((cusdParam.replyMsg == 0) || (cusdParam.replyMsg == 1))

+    {

+        cbsCodeType = atBase_CheckDataCodeType((SINT16)cusdParam.bDcs);

+        at_print(AT_ERR,"Code Type:%d\n",cbsCodeType);

+        if(atBase_ConvertUCS2SetNV(cbsCodeType,cusdParam.cusdDataStr,convertDataStr,(UINT16)strlen(cusdParam.cusdDataStr)))

+        {

+            cfg_set("ussd_write_flag","16");

+            cfg_set("ussd_dcs","72");

+            if(cusdParam.replyMsg == 0)

+            {

+                cfg_set("ussd_mode","0");

+                cfg_set("ussd_cancel_flag","no");

+            }

+            else

+            {

+                cfg_set("ussd_mode","1");

+                cfg_set("ussd_cancel_flag","yes");

+            }

+			//½«Êý¾Ý´æ´¢µ½Êý¾Ý¿â

+			//store_ussd_data_to_db(convertDataStr);//corem0625

+        }

+        else

+        {

+            cfg_set("ussd_write_flag","99");

+            cfg_set("ussd_cancel_flag","no");

+			return AT_END;

+        }

+    }

+    else if(cusdParam.replyMsg == 2)

+    {

+        cfg_set("ussd_write_flag","13");

+        cfg_set("ussd_cancel_flag","no");

+    }

+    else if(cusdParam.replyMsg == 3)

+    {

+        cfg_set("ussd_write_flag","4");

+        cfg_set("ussd_cancel_flag","no");

+    }

+    else if(cusdParam.replyMsg == 4)

+    {

+        cfg_set("ussd_write_flag","99");

+        cfg_set("ussd_cancel_flag","no");

+    }

+    else if(cusdParam.replyMsg == 5)

+    {

+        cfg_set("ussd_write_flag","4");

+        cfg_set("ussd_cancel_flag","no");

+    }

+    else

+    {

+        cfg_set("ussd_write_flag","99");

+        cfg_set("ussd_cancel_flag","no");

+    }

+	return AT_END;

+}

+

+//add corem0620 end

+

+int cnum_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+    return AT_END;

+}

+//const char *at_paras

+int cnum_auto_act( char *at_paras ,int is_query_report)

+{

+    T_zAt_CnumRes   tAtRes  = {0};

+    CHAR tcnum[256] = {0};

+    CHAR *mslsdm = NULL;

+    UINT32 len=0;

+	

+    void *p[3] = {tAtRes.alpha, tAtRes.number, &tAtRes.type};

+    at_print(AT_DEBUG,"cnum_auto_act at_paras=%s!\n",at_paras);

+    parse_param2("%s,%s,%d", at_paras, p);

+    at_print(AT_DEBUG,"cnum_auto_act alpha=%s,number=%s,type=%d!\n",

+    tAtRes.alpha, tAtRes.number, tAtRes.type); 

+	

+	if(strlen(tAtRes.number) == 0){//corem20201209

+		return AT_END;

+	}

+

+    cfg_get_item(NV_SIM_ICCID,tcnum,sizeof(tcnum));

+    if(0 == strcmp("", tcnum))

+    {

+        cfg_set(NV_SIM_ICCID, tAtRes.number);

+		cfg_set(NV_MSISDN, tAtRes.number);

+    }

+    else

+    {

+	    char *pos = strstr(tcnum, tAtRes.number);//corem20201209

+		if(pos != NULL && (*(pos + strlen(tAtRes.number)) == '\0' || *(pos + strlen(tAtRes.number)) == ',')){

+		    return AT_END;

+		}

+		

+        len = strlen(tcnum)+strlen(tAtRes.number)+strlen(", ")+1;

+        mslsdm = malloc(len);

+	    if(mslsdm == NULL)

+	    {

+	        return AT_END;

+	    }

+        memset(mslsdm, 0, len); 

+        snprintf(mslsdm, len,"%s, %s", tcnum, tAtRes.number);

+        cfg_set(NV_SIM_ICCID, mslsdm);

+		cfg_set(NV_MSISDN, mslsdm);

+        free(mslsdm);

+	    mslsdm = NULL;

+    }

+    return AT_END;

+}

+

+char* start_query_cnum(void *msg,struct at_context *context)

+{

+    at_print(AT_DEBUG,"start_query_cnum\n");

+    return normal_CnumRead();

+}

+

+/* ЭÒéÕ»¹Ì¶¨ÐÅÏ¢»ñȡʼþÁ´ZICCID CIMI CNUM  */

+char *start_getmodeminfo(void *msg,struct at_context *context)

+{

+	return normal_getziccid();

+}

+

+

+char* start_pdpact_cmd(void *msg,struct at_context *context)

+{

+	char creg_stat[20] = {0};

+	MSG_BUF *p_msg = (MSG_BUF *)msg;

+    struct pdp_act_req *pdpsetinfo = NULL;

+	char *pstr = NULL;

+

+	cfg_get_item("creg_stat", creg_stat, sizeof(creg_stat));

+	at_print(AT_DEBUG,"@@@@@@@@@@@@@start_pdpact_cmd creg stat=%s!\n",creg_stat);

+

+	/*¶ÔÓÚÍø¹ØÀàÓ¦Óã¬ÀýÈçwebui¡¢Ö÷¿Ø¡¢TR069£¬Æä½ö¿ØÖÆÆÕͨÉÏÍøÒµÎñµÄmodemÁªÍøÓë¶Ï¿ª£¬

+	ÔÚpdp¼¤»îÐÅÏ¢Öв»Ð¯´øÈκβÎÊý£¬pdp¼¤»î¾ßÌåʹÓõÄapn¡¢ip type¡¢Óû§Ãû¡¢ÃÜÂëµÈÐÅÏ¢

+	ÐèÒªÓÉat_ctl×Ô¼ºÈ·¶¨*/

+	if(p_msg->usDataLen == 0)

+	{	

+		//zhangfen for PDP		

+		cfg_set("auto_reconnect", "1");		

+		

+	 	pdpsetinfo=malloc(sizeof(struct pdp_act_req));

+        if(pdpsetinfo == NULL){

+			softap_assert("");

+			return NULL;

+		}

+        memset(pdpsetinfo,0,sizeof(struct pdp_act_req));

+		//at_ctl¸ù¾Ý±£´æµÄĬÈÏpdp¼¤»îÐÅÏ¢£¬×é×°pdp¼¤»îÏûÏ¢ÄÚÈÝ£¬²¢Ìî³äµ½ÏûÏ¢ÖÐ

+        normal_getcurparam(pdpsetinfo);

+		

+		set_default_apn(pdpsetinfo->comm_info.apn);

+		pdpsetinfo->default_flag = 1;//¿ÉÒÔʹÓÃĬÈϳÐÔØ

+		memcpy(p_msg->aucDataBuf, pdpsetinfo, sizeof(struct pdp_act_req));

+		p_msg->usDataLen = sizeof(struct pdp_act_req);

+		pstr = pdp_act_func(p_msg,context); 

+		free(pdpsetinfo);

+	#if 0

+		if(1 == atoi(creg_stat) || 5 == atoi(creg_stat))

+	    {      

+	    	//set_pppstatus(PPP_CONNECTING);

+	       

+	        memcpy(p_msg->aucDataBuf, pdpsetinfo, sizeof(struct pdp_act_req));

+			p_msg->usDataLen = sizeof(struct pdp_act_req);

+			pstr = pdp_act_func(p_msg,context); 	       

+	    }

+		else

+		{		  	

+			/*Ϊ¼õÉÙ²»±ØÒªµÄ²¦ºÅatÃüÁîÁ÷³Ì£¬Èç¹ûµ±Ç°²»Âú×㲦ºÅÌõ¼þ£¬ÔòÖ±½Ó±¨´í¸øÍø¹ØÓ¦Óã¬

+			֪ͨÆäµ±Ç°ÎÞ·¨²¦ºÅ*/

+			send_rsp_msg(context->source,context->msg_id,MSG_CMD_PDP_ACT_RSP,0,0);

+		}

+#endif

+		

+	}

+	else

+	{

+		/*·ÇÍø¹ÜÀàÓ¦ÓõÄpdp¼¤»î£¬Óë±¾ÉíÒµÎñÓйأ¬²»ÊÜÍø¹Ø¿ØÖÆ£¬Í¬Ê±»áÖ¸¶¨apn¡¢ip typeµÈÐÅÏ¢£¬Òò´Ë

+		ÔÚpdp¼¤»îʱÐèÒª½«pdp¼¤»îÐÅϢЯ´ø¹ýÀ´£¬ÓÉat_ctlÖ±½Ó·¢Æðpdp¼¤»î*/

+		pstr = pdp_act_func(msg,context);	

+	}		

+	return pstr;   

+}

+

+extern struct defcid_mng_t g_defcid_mng;

+

+char* start_pdpdeact_cmd(void *msg,struct at_context *context)

+{

+    char pppStatus[50] = {0};

+	MSG_BUF *p_msg = (MSG_BUF *)msg;

+	AT_PDP_DEACT_REQ_INFO req = {0};

+	char *pstr = NULL;

+	

+	/*¶ÔÓÚÍø¹ØÀàÓ¦Óã¬ÀýÈçwebui¡¢Ö÷¿Ø¡¢TR069£¬Æä¿ØÖÆÆÕͨÉÏÍøÒµÎñµÄmodemÁªÍøÓë¶Ï¿ª£¬

+	ÔÚpdpÈ¥¼¤»îʱ£¬½öָʾat_ctl¶Ï¿ªmodemÁªÍø£¬¾ßÌå¶Ï¿ªµÄcid£¬ÓÉat_ctl±£´æµÄĬÈÏcid¾ö¶¨*/

+	if(p_msg->usDataLen == 0)

+	{

+		cfg_get_item("ppp_status", pppStatus, sizeof(pppStatus));

+	    if((strcmp("ppp_disconnecting", pppStatus)== 0) || (strcmp("ppp_disconnected", pppStatus) == 0))

+	    {

+	    	AT_PDP_DEACT_RSP_INFO rsp = {0};

+			rsp.result = AT_RSP_OK;

+			send_rsp_msg(context->source,context->msg_id,MSG_CMD_PDP_DEACT_RSP,sizeof(AT_PDP_DEACT_RSP_INFO),&rsp);

+	        return NULL;		

+	    }

+	    if(strcmp("ppp_connecting", pppStatus)== 0)

+	    {

+			at_print(AT_ERR,"start_pdpdeact_cmd is acting ,start timer to wait\n");

+			add_one_delayed_msg(msg);

+	        return NULL;		

+	    }

+		

+		set_pppstatus(PPP_DISCONNECTING);

+	

+		req.c_id = g_defcid_mng.cid;

+		memcpy(p_msg->aucDataBuf, &req, sizeof(AT_PDP_DEACT_REQ_INFO));

+		p_msg->usDataLen = sizeof(AT_PDP_DEACT_REQ_INFO);

+		pstr = pdp_deact_func(p_msg, context);

+	}

+	else

+	{

+		pstr = pdp_deact_func(msg, context);

+	}

+	return pstr;	

+}

+

+//ÒÔÏÂÊÇоƬÈÏÖ¤´úÂë

+char* start_zeact_cmd(void *msg,struct at_context *context)

+{

+	char *at_next=NULL;

+	

+	at_next=malloc(20);

+	if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,20);

+	snprintf(at_next,20,"AT+ZEACT=%s\r\n",((MSG_BUF*)msg)->aucDataBuf); 

+	return at_next;

+	

+}

+

+char* start_zmmi_cmd(void *msg,struct at_context *context)

+{

+	char *at_next=NULL;

+	

+	at_next=malloc(20);

+	if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,20);

+	snprintf(at_next,20,"AT+ZMMI=%s\r\n",((MSG_BUF*)msg)->aucDataBuf); 

+	return at_next;

+	

+}

+

+char* start_zimsamrw_cmd(void *msg,struct at_context *context)

+{

+	char *at_next=NULL;

+	

+	at_next=malloc(20);

+	if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,20);

+	snprintf(at_next,20,"AT+ZIMSAMRW=%s\r\n",((MSG_BUF*)msg)->aucDataBuf); 

+	return at_next;

+	

+}

+

+int  cmd_ok_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+	*next_req=malloc(10);

+	if(*next_req){

+    *next_len=10;

+    strcpy(*next_req,"1");

+	}

+    return AT_END;

+}

+

+int  cmd_err_act(char *at_str,struct at_context *context,void **next_req,int *next_len)

+{

+	*next_req=malloc(10);

+	if(*next_req){

+    *next_len=10;

+    strcpy(*next_req,"0");

+	}

+    return AT_END;

+}

+

+/**

+ * @brief Æô¶¯×ÔÄܶÌÐŽø³Ì

+ * @param 

+ * @return 

+ * @note   

+ * @warning 

+ */

+void at_ctl_startisms(void)

+{

+	at_print(AT_NORMAL,"[TEST]at_ctl_startisms\n");

+#if (APP_OS_TYPE == APP_OS_LINUX)

+/*

+	if(fork() == 0)

+	{

+		if(execv("/bin/zte_isms", NULL) < 0)

+		{

+			at_print(AT_ERR,"[TEST]execv error(%d)\n", errno);

+			exit(0);

+		}

+	}

+*/

+	if(system("/bin/zte_isms &") != 0)

+	{

+		at_print(AT_ERR,"[TEST]execv error(%d)\n", errno);

+	}

+#endif	

+}

+

+int atd_req_rcv_act( char *at_paras,int at_fd,struct at_context *context)

+{

+	if(is_ppp_dial_atd(at_paras, at_fd) == 0)

+		return AT_END;

+	else

+		return AT_CONTINUE;//ÆÕͨµÄATDÃüÁֱ½Óת·¢

+}

+

+char* start_cvmod_cmd(void *msg,struct at_context *context)

+{

+	char *at_next=NULL;

+    at_next=malloc(20);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,20);

+	sprintf(at_next,"AT+CVMOD=0\r\n");

+    

+	return at_next;

+}

+

+char* start_zchnelset_cmd(void *msg,struct at_context *context)

+{

+	char *at_next=NULL;

+    at_next=malloc(40);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,40);

+	sprintf(at_next,"AT+ZCHNELSET=0,37,38,39,40,41\r\n");

+    

+	return at_next;

+}

+

+char *start_querycgdcont_cmd(void *msg,struct at_context *context)

+{

+	char *at_next=NULL;

+    at_next=malloc(20);

+    if(at_next == NULL){

+		softap_assert("");

+		return NULL;

+	}

+    memset(at_next,0,20);

+	sprintf(at_next,"AT+CGDCONT?\r\n");

+	return at_next;

+}

+

+//bsim

+static int bs_aes_init_key(unsigned char *aes_key, int k_len)

+{

+	int efuse_fd = -1;

+	T_ZDrvEfuse_Secure efuse = {0};

+	

+	memset(&efuse, 0, sizeof(efuse));

+	efuse_fd = open("/dev/efuse", O_RDWR);

+	if (efuse_fd < 0) {

+		printf("wifi_aes_init_key efuse open errno=%d\n", errno);

+		return 0;

+	}

+	if(ioctl(efuse_fd , EFUSE_GET_DATA, &efuse) != 0) {

+		printf("wifi_aes_init_key efuse ioctl errno=%d\n", errno);

+		close(efuse_fd);

+		return 0;

+	}

+	close(efuse_fd);

+	memcpy(aes_key, efuse.pubKeyHash, k_len);

+	

+	return 1;

+}

+

+static int bs_aes_encrypt(char* in, int len, char* out, unsigned char* key, int key_len)

+{

+    if (!in || !out || !key || len <=0 || (len%AES_BLOCK_SIZE)!=0 || (key_len!=16 && key_len!=24 && key_len!=32)) {

+		printf("bs_aes_encrypt err in=%p out=%p key=%p len=%d key_len=%d\n",in,key,out,len,key_len);

+        return 0;

+    }

+ 

+    AES_KEY aes = {0}; //cov h

+    if (AES_set_encrypt_key(key, key_len*8, &aes) < 0) {

+		printf("bs_aes_encrypt AES_set_encrypt_key err\n");

+        return 0;

+    }

+ 

+    int en_len = 0;

+    while (en_len < len) {

+        AES_encrypt((unsigned char*)in, (unsigned char*)out, &aes);

+        in	+= AES_BLOCK_SIZE;

+        out += AES_BLOCK_SIZE;

+        en_len += AES_BLOCK_SIZE;

+    }

+ 

+    return 1;

+}

+

+static int bs_aes_decrypt(char* in, int len, char* out, char* key, int key_len)

+{

+    if (!in || !out || !key || len <=0 || (len%AES_BLOCK_SIZE)!=0 || (key_len!=16 && key_len!=24 && key_len!=32)) {

+		printf("bs_aes_decrypt err in=%p out=%p key=%p len=%d key_len=%d\n",in,key,out,len,key_len);

+        return 0;

+    }

+ 

+    AES_KEY aes = {0}; //cov h

+    if (AES_set_decrypt_key((unsigned char*)key, key_len*8, &aes) < 0) {

+		printf("bs_aes_decrypt AES_set_decrypt_key err\n");

+        return 0;

+    }

+ 

+    int en_len = 0;

+    while (en_len < len) {

+        AES_decrypt((unsigned char*)in, (unsigned char*)out, &aes);

+        in	+= AES_BLOCK_SIZE;

+        out += AES_BLOCK_SIZE;

+        en_len += AES_BLOCK_SIZE;

+    }

+ 

+    return 1;

+}

+

+static int apn_encrypt_code(void)

+{

+	char w_code[PROFILE_APN_LEN] = {0};

+	char b_aes[PROFILE_APN_LEN] = {0};

+	char s_aes[PROFILE_APN_AES_LEN] = {0};

+

+	cfg_get_item("ppp_passtmp", w_code, sizeof(w_code));

+	bs_aes_encrypt(w_code, PROFILE_APN_LEN - 1, b_aes, atctl_aes_key, sizeof(atctl_aes_key));

+	bytes2string(b_aes, s_aes, PROFILE_APN_LEN - 1); //libatutils

+	cfg_set("ppp_passwd", s_aes);

+	printf("apn_encrypt_code w_code=%s, s_aes=%s\n", w_code, s_aes);

+

+	return 1;

+}

+

+static int ipv6apn_encrypt_code(void)

+{

+	char w_code[PROFILE_APN_LEN] = {0};

+	char b_aes[PROFILE_APN_LEN] = {0};

+	char s_aes[PROFILE_APN_AES_LEN] = {0};

+

+	cfg_get_item("ipv6_ppp_passtmp", w_code, sizeof(w_code));

+	bs_aes_encrypt(w_code, PROFILE_APN_LEN - 1, b_aes, atctl_aes_key, sizeof(atctl_aes_key));

+	bytes2string(b_aes, s_aes, PROFILE_APN_LEN - 1);

+	cfg_set("ipv6_ppp_passwd", s_aes);

+	printf("ipv6apn_encrypt_code w_code=%s, s_aes=%s\n", w_code, s_aes);

+

+	return 1;

+}

+

+//2±íʾfota´ÓÀϰ汾ÍùÉÏÉý¼¶£¬ppp_password´æµÄÊÇÃ÷ÎÄÃÜÂ룬а汾ÊÇÃÜÎÄ

+static int apn_decrypt_code(void)

+{

+	char w_code[PROFILE_APN_LEN]= {0};

+	char b_aes[PROFILE_APN_LEN] = {0};

+	char s_aes[PROFILE_APN_AES_LEN] = {0};

+	int flag = 0;

+

+	cfg_get_item("ppp_passwd", s_aes, sizeof(s_aes));

+	if (strlen(s_aes) == (PROFILE_APN_AES_LEN - 1)) {

+		string2bytes(s_aes, b_aes, PROFILE_APN_AES_LEN - 1);

+		bs_aes_decrypt(b_aes, PROFILE_APN_LEN - 1, w_code, atctl_aes_key, sizeof(atctl_aes_key));

+		cfg_set("ppp_passtmp", w_code);

+//		printf("apn_decrypt_code w_code=%s, s_aes=%s\n", w_code, s_aes);

+	} else if (strlen(s_aes) > 0){

+		cfg_set("ppp_passtmp", s_aes);

+		return 2;

+	}

+

+	return 1;

+}

+

+static int ipv6apn_decrypt_code(void)

+{

+	char w_code[PROFILE_APN_LEN]= {0};

+	char b_aes[PROFILE_APN_LEN] = {0};

+	char s_aes[PROFILE_APN_AES_LEN] = {0};

+	int flag = 0;

+

+	cfg_get_item("ipv6_ppp_passwd", s_aes, sizeof(s_aes));

+	if (strlen(s_aes) == (PROFILE_APN_AES_LEN - 1)) {

+		string2bytes(s_aes, b_aes, PROFILE_APN_AES_LEN - 1);

+		bs_aes_decrypt(b_aes, PROFILE_APN_LEN - 1, w_code, atctl_aes_key, sizeof(atctl_aes_key));

+		cfg_set("ipv6_ppp_passtmp", w_code);

+//		printf("apn_decrypt_code w_code=%s, s_aes=%s\n", w_code, s_aes);

+	} else if (strlen(s_aes) > 0){

+		cfg_set("ipv6_ppp_passtmp", s_aes);

+		return 2;

+	}

+

+	return 1;

+}

+

+int atctl_aes_init(void)

+{

+	bs_aes_init_key(atctl_aes_key, sizeof(atctl_aes_key));

+	

+	if (2 == apn_decrypt_code())

+		apn_encrypt_code();

+	if (2 == ipv6apn_decrypt_code())

+		ipv6apn_encrypt_code();

+

+	return 1;

+}

+

+

diff --git a/lynq/S300/ap/app/zte_comm/schedule_restart/Makefile b/lynq/S300/ap/app/zte_comm/schedule_restart/Makefile
new file mode 100755
index 0000000..096ce19
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/schedule_restart/Makefile
@@ -0,0 +1,41 @@
+#*******************************************************************************
+# include ZTE application makefile
+#*******************************************************************************
+include $(COMMON_MK)
+
+##############USER COMIZE BEGIN################
+EXEC = schedule_restart
+OBJS = schedule_restart.o 
+
+CFLAGS += -I$(zte_app_path)/include
+CFLAGS += -I$(zte_lib_path)/libnvram
+CFLAGS += -I$(zte_lib_path)/libsqlite
+CFLAGS += -I$(zte_lib_path)/libsoftap
+CFLAGS += -g
+CFLAGS += -g -Werror=implicit-function-declaration
+
+ifeq ($(CUSTOM_MODEL), MF29S2)
+CFLAGS	+= -DCUSTOM_VERSION_MF29S2_ZTE
+endif 
+
+LDLIBS = -lpthread -lm
+LDLIBS += -lnvram -L$(zte_lib_path)/libnvram
+LDLIBS += -lsoftap -L$(zte_lib_path)/libsoftap
+LDLIBS  += -lsoft_timer -L$(zte_lib_path)/libsoft_timer
+
+##############USER COMIZE END##################
+
+#*******************************************************************************
+# targets
+#*******************************************************************************
+all: $(EXEC)
+
+$(EXEC): $(OBJS)
+	$(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) -Wl,--end-group
+	@cp $@ $@.elf
+
+romfs:
+	$(ROMFSINST) $(EXEC) /bin/$(EXEC)
+
+clean:
+	-rm -f $(EXEC) *.elf *.gdb *.o
diff --git a/lynq/S300/ap/app/zte_comm/schedule_restart/schedule_restart.c b/lynq/S300/ap/app/zte_comm/schedule_restart/schedule_restart.c
new file mode 100755
index 0000000..b1e5843
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/schedule_restart/schedule_restart.c
@@ -0,0 +1,142 @@
+#include "schedule_restart.h"

+

+void cfg_get_sntp_time(sntp_time * s_time)

+{

+    char sntp_nv_value[20] = {0};

+    if(!s_time)

+    {

+        return;

+    }

+

+    cfg_get_item("sntp_process_result", s_time->result, sizeof(s_time->result));

+

+    if(0 == strcmp("success", s_time->result))

+    {

+        cfg_get_item("sntp_day", sntp_nv_value, sizeof(sntp_nv_value));

+        s_time->day = atoi(sntp_nv_value);

+

+        cfg_get_item("sntp_hour", sntp_nv_value, sizeof(sntp_nv_value));

+        s_time->hour = atoi(sntp_nv_value);

+

+        cfg_get_item("sntp_minute", sntp_nv_value, sizeof(sntp_nv_value));

+        s_time->minute = atoi(sntp_nv_value);

+

+        cfg_get_item("sntp_weekday", s_time->weekday, sizeof(s_time->weekday));

+    }

+    

+    return;

+}

+

+void cfg_get_schedule_restart_config(schedule_restart_config * config)

+{

+    char schedule_restart_nv_value[20] = {0};

+    if(!config)

+    {

+        return;

+    }

+

+    cfg_get_item("schedule_restart_enable", schedule_restart_nv_value, sizeof(schedule_restart_nv_value));

+    config->enable = atoi(schedule_restart_nv_value);

+

+    if(config->enable)

+    {

+        cfg_get_item("schedule_restart_option", schedule_restart_nv_value, sizeof(schedule_restart_nv_value));

+        if(0 == strcmp("everyweek", schedule_restart_nv_value))

+        {

+            config->option = EVERY_WEEK;

+        }

+        else if(0 == strcmp("everymonth", schedule_restart_nv_value))

+        {

+            config->option = EVERY_MONTH;

+        }

+        else if(0 == strcmp("everyday", schedule_restart_nv_value))

+        {

+            config->option = EVERY_DAY;

+        }

+

+        cfg_get_item("schedule_restart_day", schedule_restart_nv_value, sizeof(schedule_restart_nv_value));

+        config->day = atoi(schedule_restart_nv_value);

+

+        cfg_get_item("schedule_restart_hour", schedule_restart_nv_value, sizeof(schedule_restart_nv_value));

+        config->hour = atoi(schedule_restart_nv_value);

+

+        cfg_get_item("schedule_restart_minute", schedule_restart_nv_value, sizeof(schedule_restart_nv_value));

+        config->minute = atoi(schedule_restart_nv_value);

+

+        cfg_get_item("schedule_restart_weekday", config->weekday, sizeof(config->weekday));

+    }

+    

+    return;

+}

+

+void get_sntp_and_schedule_info(sntp_time * s_time, schedule_restart_config * config)

+{

+    if(!s_time || !config)

+    {

+        return;

+    }

+

+    cfg_get_sntp_time(s_time);

+    cfg_get_schedule_restart_config(config);

+

+    return;

+}

+

+void send_restart_request()

+{

+    ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_MAIN_CTRL, MSG_CMD_RESTART_REQUEST, 0, NULL,0);

+

+    return;

+}

+

+void check_and_restart(const sntp_time *sntp_time, const schedule_restart_config *config)

+{

+    if(!config->enable || (0 != strcmp("success", sntp_time->result)))

+    {

+        return;

+    }

+

+    if(sntp_time->hour == config->hour && sntp_time->minute == config->minute)

+    {

+        switch(config->option) 

+        {

+            case EVERY_DAY:

+                send_restart_request();

+                break;

+            case EVERY_WEEK:

+                if(0 == strcmp(sntp_time->weekday, config->weekday)) 

+                {

+                    send_restart_request();

+                }

+                break;

+            case EVERY_MONTH:

+                if(sntp_time->day == config->day)

+                {

+                    send_restart_request();

+                }

+                break;

+        }

+    }

+

+    return;

+}

+

+void schedule_restart_proc()

+{

+    sntp_time s_time;

+    schedule_restart_config config;

+

+    while(1)

+    {

+        get_sntp_and_schedule_info(&s_time, &config);

+        check_and_restart(&s_time, &config);

+        sleep(60);

+    }

+}

+

+int schedule_restart_main(int argc, char * argv[])

+{

+    schedule_restart_proc();

+

+    return 0;

+}
\ No newline at end of file
diff --git a/lynq/S300/ap/app/zte_comm/schedule_restart/schedule_restart.h b/lynq/S300/ap/app/zte_comm/schedule_restart/schedule_restart.h
new file mode 100755
index 0000000..c4d662f
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/schedule_restart/schedule_restart.h
@@ -0,0 +1,31 @@
+#ifndef __SCHEDULE_RESTART__

+#define __SCHEDULE_RESTART__

+

+#include "softap_api.h"

+#include "cfg_api.h"

+#include "message.h"

+

+typedef struct {

+    int day;

+    int hour;

+    int minute;

+    char weekday[4];

+    char result[20];

+} sntp_time;

+

+typedef enum {

+    EVERY_DAY,

+    EVERY_WEEK,

+    EVERY_MONTH

+} restart_option;

+

+typedef struct {

+    int enable;

+    restart_option option;

+    int day;

+    int hour;

+    int minute;

+    char weekday[4];

+} schedule_restart_config;

+

+#endif
\ No newline at end of file
diff --git a/lynq/S300/ap/app/zte_comm/wlan/src/wlan-station.c b/lynq/S300/ap/app/zte_comm/wlan/src/wlan-station.c
new file mode 100755
index 0000000..8984fcf
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/wlan/src/wlan-station.c
@@ -0,0 +1,2918 @@
+/*

+ *  wlan-station.c -- wifi station mode Deal module

+ *

+ *  Copyright (c) ZTE Corporation All Rights Reserved.

+ *

+ *  $Id: wlan-station.c, v 0.1 2015-03-09 $

+ *   Authors :  XUJIAN - xu.jian5@zte.com.cn>

+ */

+#include "wifi_util.h"

+#include "wlan-station.h"

+#include "Vector.h"

+#include "wifi_sta_ctrl.h"

+#include "soft_timer.h"

+#include "rtk_arch.h"

+#include <semaphore.h>

+#define  SUCCESS  "1"

+#define  FAILED   "0"

+#define REPLY_BUF_SIZE 4096 // wpa_supplicant's maximum size.

+

+#define UEVENT_BUFFER_SIZE   1024*2

+

+#define WIFI_STATION_CMD_LEN    256

+

+//¶¨Ê±Æ÷Ïà¹Ø

+#define WIFI_STATION_TIMER_CONNECT                     109

+#define WIFI_STATION_TIMER_GET_STATUS               110

+#define WIFI_STATION_TIMER_SCAN                            111

+//add sim card init status query timer

+#define WIFI_STATION_TIMER_SIM_CARD_STATUS                 112

+#define WIFI_STATION_TIMER_GET_SCAN_RESULTS                113

+

+#define WIFI_STATION_TIMER_CONNECT_INTERVAL  1000

+#define WIFI_STATION_TIMER_GET_STATUS_INTERVAL  2000

+#define WIFI_STATION_TIMER_SCAN_INTERVAL  60000  /// 10 ----> 15s nxl

+

+#define WIFI_STATION_TIMER_GET_SCAN_RESULTS_INTERVAL  8000  /// 10 ----> 15s nxl

+

+

+#define WIFI_STATION_TIMER_SIM_CARD_STATUS_INTERVAL  2000

+

+#define WIFI_STATION_TIMER_WAIT_CONNECT_COUNT         20

+#define WIFI_STATION_TIMER_CONNECT_TIME_OUT  116

+

+//ɨÃèÏà¹Ø

+#define WIFI_STATION_SCAN_DURATION                8

+#define WIFI_STATION_SCRIPT_RSP_LINE_LEN     1024

+#define WIFI_STATION_SCAN_RESULT_STR_LEN    1024

+#define WIFI_STATION_SCAN_ONE_RESULT_STR_LEN    256

+#define WIFI_STATION_SCAN_RESULT_LIST_NUM    60//Ò»°ãʵ¼Ê¹Ì¼þÄÜɨ³öÀ´30¼¸¸ö£¬ÏµÍ³ÄÜ´æ´¢µÄɨÃè½á¹û×î¶à²»³¬¹ý2048¸ö×Ö½Ú

+

+

+

+

+

+#define WIFI_STATION_SIGNAL_LEVEL1  -80

+#define WIFI_STATION_SIGNAL_LEVEL2  -78

+#define WIFI_STATION_SIGNAL_LEVEL3  -75

+#define WIFI_STATION_SIGNAL_LEVEL4  -72

+

+#define WIFI_STATION_CHANNEL1  2412

+#define WIFI_STATION_CHANNEL2  2417

+#define WIFI_STATION_CHANNEL3  2422

+#define WIFI_STATION_CHANNEL4  2427

+#define WIFI_STATION_CHANNEL5  2432

+#define WIFI_STATION_CHANNEL6  2437

+#define WIFI_STATION_CHANNEL7  2442

+#define WIFI_STATION_CHANNEL8  2447

+#define WIFI_STATION_CHANNEL9  2452

+#define WIFI_STATION_CHANNEL10  2457

+#define WIFI_STATION_CHANNEL11  2462

+#define WIFI_STATION_CHANNEL12  2467

+#define WIFI_STATION_CHANNEL13  2472

+#define WIFI_STATION_FREQ_LEN 16

+

+#define WIFI_STATION_MSG_SOURCE_STR_LEN  15

+#define WIFI_STATION_IP_STATUS_LEN 16

+#define WIFI_CONNECTION_LEN 4

+#define WIFI_ZPBIC_STATUS_LEN 16

+#define WIFI_STATION_WPA_SUPPLICANT_STATUS_LEN 16

+

+#define WIFI_STATION_SCAN_RESULT_PARSE_IGNORE  "bssid / frequency /"

+

+#define WIFI_STATION_AUTH_WPA_PSK  "WPA-PSK"

+#define WIFI_STATION_AUTH_WPA2_PSK  "WPA2-PSK"

+#define WIFI_STATION_AUTH_WPA_EAP  "WPA-EAP"

+#define WIFI_STATION_AUTH_WPA2_EAP "WPA2-EAP"

+#define WIFI_STATION_AUTH_SHARED  "SHARED"

+#define WIFI_STATION_AUTH_WPA3  "SAE"

+

+#define WIFI_STATION_ENCRYPT_CCMP  "CCMP"

+#define WIFI_STATION_ENCRYPT_TKIP  "TKIP"

+#define WIFI_STATION_ENCRYPT_WEP  "WEP"

+

+#define WIFI_STATION_PROFILE_AUTH_WPA_PSK  "WPAPSK"

+#define WIFI_STATION_PROFILE_AUTH_WPA2_PSK  "WPA2PSK"

+//#define WIFI_STATION_PROFILE_AUTH_WPA_EAP  "WPAEAP"

+//#define WIFI_STATION_PROFILE_AUTH_WPA2_EAP  "WPA2EAP"

+#define WIFI_STATION_PROFILE_AUTH_WPA_EAP "EAP-SIM/AKA"

+#define WIFI_STATION_PROFILE_AUTH_SHARED  "SHARED"

+#define WIFI_STATION_PROFILE_AUTH_WPA3 "WPA3Personal"

+#define WIFI_STATION_PROFILE_AUTH_WPA2_WPA3  "WPA2WPA3"

+

+#define WIFI_STATION_PROFILE_ENCRYPT_WEP  "WEP"

+#define WIFI_STATION_PROFILE_ENCRYPT_CCMP  "CCMP"

+#define WIFI_STATION_PROFILE_ENCRYPT_TKIP  "TKIP"

+

+

+

+#define WIFI_STATION_STATUS_RESULT_PARSE_BSSID  "bssid"

+#define WIFI_STATION_STATUS_RESULT_PARSE_SSID  "ssid"

+#define WIFI_STATION_STATUS_RESULT_PARSE_WPA_STATUS  "wpa_state"

+#define WIFI_STATION_STATUS_RESULT_PARSE_SUPPLICANT_PAE_STATUS  "Supplicant PAE state"

+#define WIFI_STATION_STATUS_RESULT_PARSE_SUPPPORT_STATUS  "suppPortStatus"

+#define WIFI_STATION_STATUS_RESULT_PARSE_EAP_STATUS  "EAP state"

+

+

+

+

+#define WIFI_STATION_STATUS_RESULT_WPA_STATUS_OK  "COMPLETED"

+

+#define WIFI_STATION_STATUS_RESULT_WPA_STATUS_INACTIVE  "INACTIVE"

+#define WIFI_STATION_STATUS_RESULT_WPA_STATUS_SCANNING  "SCANNING"

+#define WIFI_STATION_TIMER_SCANNING_STATE_COUNT         10

+

+#define WIFI_STATION_STATUS_RESULT_WPA_STATUS_AUTHENTICATING  "AUTHENTICATING"

+#define WIFI_STATION_STATUS_RESULT_WPA_STATUS_ASSOCIATING  "ASSOCIATING"

+#define WIFI_STATION_STATUS_RESULT_WPA_STATUS_ASSOCIATED   "ASSOCIATED"

+#define WIFI_STATION_STATUS_RESULT_WPA_STATUS_4WAY_HANDSHAKE   "4WAY_HANDSHAKE"

+#define WIFI_STATION_STATUS_RESULT_WPA_STATUS_4WAY_GROUP_HANDSHAKE   "GROUP_HANDSHAKE"

+#define WIFI_STATION_STATUS_RESULT_WPA_STATUS_4WAY_GROUP_UNKNOWN   "UNKNOWN"

+#define WIFI_STATION_STATUS_RESULT_WPA_STATUS_4WAY_GROUP_DISCONNECTED   "DISCONNECTED"

+#define WIFI_STATION_STATUS_RESULT_WPA_STATUS_4WAY_GROUP_INTERFACE_DISABLED   "INTERFACE_DISABLED"

+

+

+#define WIFI_STATION_STATUS_RESULT_EAP_STATUS_FAIL  "FAILURE"

+#define WIFI_STATION_STATUS_RESULT_EAP_STATUS_SUCCESS  "SUCCESS"

+

+

+

+#define WIFI_STATION_IP_STATUS_CONNECT  "connect"

+#define WIFI_STATION_IP_STATUS_DISCONNECT  "disconnect"

+#define WIFI_STATION_IP_STATUS_CONNECTING  "connecting"

+#define WIFI_STATION_IP_STATUS_DHCPING  "dhcping"

+

+#define INVALID_NETWORK_ID  -1

+

+#define safe_free(x) do { if(x) {free(x); x=NULL;} } while(0)

+

+#define WPA_CLI "wpa_cli -p"ROOT_DIR"/wifi/wpa_supplicant -iwlan0-vxd"

+

+#define WIFI_CARD_MODE_LEN 3

+

+#define WIFI_PIN_STATUS_LEN 3

+

+#define SIMCARD_INIT_SUCCESS "success"

+#define SIMCARD_INIT_UNDEFINED "undefined"

+#define SIMCARD_INIT_NO_CARD "no_card"

+//#define SIMCARD_INIT_LOCKED "locked"

+//#define SIMCARD_INIT_FAIL "fail"

+//#define SIMCARD_INIT_PARTIAL_SUCCESS "partial_success"

+

+

+extern struct  wlan_sta_manager  *sta_manager;

+extern int need_channel_follow;

+

+//static int g_timer_sim_init_undefined_status_count = 0;

+//add by zhouti ÔÚeap ÈÏÖ¤¹ý³Ìǰ·¢Ë͵ÄÒì²½ÏûÏ¢Ôڵȴýʱºò£¬Èç¹ûÓû§disconnect£¬ÄÇôÐèÒªÅжϻØÀ´µÄrespÏûÏ¢ÊÇ·ñΪÕâ´ÎµÄ»ØÓ¦£¬Èç¹ûÊǾÍÐèÒª¶ªÆú²»´¦Àí

+static int g_send_count = 0;

+static int g_pre_send_count = 0;

+

+//gebin: Õ⼸¸öµÄÄ¿µÄ¾ÍÊÇΪÁËÔÚÏ̼߳䴫µÝ²ÎÊý°É???  Èç¹ûÕâÑù¾Í²»ÒªÓÃÈ«¾Ö±äÁ¿ÁË£¬ipc¿ÉÒÔ´«²ÎÊý

+char g_linked_ap_mac[WIFI_STATION_MAC_LEN] = {0};

+int g_linked_network_id = -1;

+int g_linked_network_id_last = -1;

+/*±£´æµ±Ç°ÀúÊ·ÁбíAPÄÚÈÝ*/

+static spot_t *g_spot_list_p[WIFI_STATION_SPOT_LIST_NUM] = {NULL};//ÈȵãÁбíÖ¸ÕëÊý×é

+

+static scan_result_t *g_scan_result_list_p[WIFI_STATION_SCAN_RESULT_LIST_NUM] = {NULL};//ɨÃèÈȵãÁбíÖ¸ÕëÊý×é

+static int g_cardmode = 0; //È«¾Ö¼Ç¼sim¿¨ÀàÐÍ

+

+static int g_blc_send_close_apsta = 0; // È«¾Ö¼Ç¼BLC·¢Ë͹رÕÏûÏ¢Ôò²»ÔÙÖ÷¶¯Á¬½Ówifi,Ö±µ½BLC·¢ËÍ´ò¿ª

+int g_wpa_supplicant;

+extern sem_t g_wpa_supplicant_id;

+

+int has_exec_disconnect = 0;     //ÊÇ·ñÖ´Ðйý¶Ï¿ª²Ù×÷

+int has_exec_select_network = 0; //ÊÇ·ñÖ´ÐйýÑ¡ÔñÁ¬½Óijһ¸öÈȵã

+int webui_select_network = 0;    //¼Ç¼webuiÏ·¢µÄÑ¡Ôñij¸öÈȵãÁ¬½ÓÃüÁî

+int g_disable_other_network = 0; //ÊÇ·ñ½ûÓÃÆäËûµÄÈȵã

+

+int g_connecting_time_out_timer = 0;//È«¾Ö¼Ç¼ÊÇ·ñÒÑ´´½¨Á¬½Ó³¬Ê±¶¨Ê±Æ÷

+static int wifi_station_connect (int from_where);

+static void wifi_station_scan (void);

+static void *wifi_station_query_sim_card_status(void *arg);

+static void sta_connect (int network_id);

+extern void basic_deal_all (int cmd);

+static int  find_linked_ap_index(void);

+static void delete_quote (char * str);

+static void wlan_station_deinit(void);

+static void process_tmp_disabled (char *buf);

+

+extern int check_alive(struct wlan_socket *skt);

+

+

+inline char * sta_docmd(const char *cmd)

+{

+	return docmd (&sta_manager->sock, cmd);

+}

+

+

+/*

+	0 : not exist

+	1: alive

+*/

+int 	check_supplicant_alive()

+{

+	return check_alive(&sta_manager->sock);

+

+}

+

+

+void *send_message_to_handle_connect_timeout(void *arg)

+{

+	ipc_send_message (MODULE_ID_WLAN_SERVER, MODULE_ID_WIFI, MSG_CMD_WIFI_STATION_CONNECT_TIMEOUT, 0, NULL, 0);

+	return NULL;

+}

+void Create_connect_timeout_timer()

+{

+	wf_log ("[111]g_connecting_time_out_timer=%d", g_connecting_time_out_timer);

+	if (g_connecting_time_out_timer) {

+		wf_log ("[xxx]station connecting timeout softtimer already exists");

+		return;

+	}

+	wf_log ("[222]create station connecting timeout softtimer");

+	CreateSoftTimer (WIFI_STATION_TIMER_CONNECT_TIME_OUT, TIMER_FLAG_ONCE, 60 * 1000, send_message_to_handle_connect_timeout, NULL);

+	g_connecting_time_out_timer = 1;

+	wf_log ("[333]g_connecting_time_out_timer=%d", g_connecting_time_out_timer);

+	return;

+}

+void Delete_connect_timeout_timer (void)

+{

+	wf_log ("[555]g_connecting_time_out_timer=%d", g_connecting_time_out_timer);

+	if (g_connecting_time_out_timer == 0) {

+		wf_log ("[xxx]station connecting timeout softtimer was already deleted");

+		return;

+	}

+	wf_log ("[666]delete station connecting timeout softtimer");

+	DeleteSoftTimer (WIFI_STATION_TIMER_CONNECT_TIME_OUT);

+	g_connecting_time_out_timer = 0;

+	wf_log ("[777]g_connecting_time_out_timer=%d", g_connecting_time_out_timer);

+	return;

+}

+

+//Ö´ÐÐÒ»¸öshellÃüÁÊä³ö½á¹ûÖðÐд洢ÔÚresvecÖУ¬²¢·µ»ØÐÐÊý

+static int32_t  convert2vector (const char *str, vector_t* resvec)

+{

+	char *tmp = NULL; //ÉèÖÃÒ»¸öºÏÊʵij¤¶È£¬ÒԴ洢ÿһÐÐÊä³ö

+	char *ret = NULL;

+	FILE  *fp = NULL;

+	int tmp_len = 0;

+

+	if (str == NULL || resvec == NULL) {

+		return -1;

+	}

+

+	fp = fopen ("/tmp/scan_results", "w+"); //½¨Á¢¹ÜµÀ

+	if (!fp) {

+		wf_log ("fopen errno: %d\n", errno); 

+		return -1;

+	}

+	fprintf (fp, "%s", str);

+	fseek (fp, 0, SEEK_SET);

+	tmp = safe_malloc (WIFI_STATION_SCRIPT_RSP_LINE_LEN, TRUE);

+

+again:

+	errno = 0;

+	while ((ret=fgets (tmp, WIFI_STATION_SCRIPT_RSP_LINE_LEN, fp)) != NULL) {

+		tmp_len = strlen (tmp);

+		if (tmp_len > 0) {

+			if (tmp[tmp_len - 1] == '\n') {

+				tmp[tmp_len - 1] = '\0'; //È¥³ý»»Ðзû

+			}

+			vector_push_back (resvec, var_string (tmp));

+		}

+	}

+

+	if (EINTR ==errno) { //kw 3

+		wf_log("fgets recv EINTR!");

+		goto again;

+	}

+

+	fflush(fp);

+	fclose (fp); 

+	safe_free (tmp);

+

+	return vector_size (resvec);

+}

+

+

+//TODO ÍøÂç×éÍø¿ÚDOWN UP·â×°

+static void network_down_up (BOOL is_up)

+{

+	if (is_up == TRUE) {

+		cfg_set ("WAN_MODE", "WIFI"); //usb,ppp,wifi

+		/*printf("[wlan-station]calling zte_ipv4.sh linkup\n");

+		system("zte_ipv4.sh \"linkup\"");

+		printf("[wlan-station]calling internet.sh\n");

+		system("internet.sh");

+		printf("[wlan-station]calling nat.sh\n");

+		system("nat.sh");*/

+		netdev_connect_internet (WIFI_WAN_DEV, MODULE_ID_WIFI);

+

+		wf_log ("[wlan-station]netdev_connect_internet");

+	} else {

+		netdev_disconnect_internet (WIFI_WAN_DEV, MODULE_ID_WIFI);

+		wf_log ("[wlan-station]netdev_disconnect_internet");

+		//system("zte_ipv4.sh \"linkdown\"");

+		cfg_set ("WAN_MODE", "PPP"); //usb,ppp,wifi

+	}

+}

+

+

+static void update_EX_APLIST_connect_status (BOOL is_connected)

+{

+	char *scan_result_str = NULL;

+	char *scan_result_str_tmp = NULL;

+	int i = 0;

+	int found_ap_index = -1;

+	char *splited_string = NULL;

+	char *splited_string1 = NULL;

+	char *save = NULL;

+	char *save1 = NULL;

+	char *delimiter = ";";

+	int found_str_index = 0;

+	BOOL is_found = FALSE;

+	BOOL is_find_EX_APLIST1 = FALSE;

+

+	int  index = 0;

+// ²»¹ÜÊÇÁ´½Ó³É¹¦»¹ÊǶϿª£¬¶¼¿ÉÒÔÕÒµ½¶ÔÓ¦µÄÈȵ㣬²»»áΪÎÞЧֵ

+	index =  find_linked_ap_index();

+

+	for (i = 0; i < WIFI_STATION_SCAN_RESULT_LIST_NUM; i++) {

+		if (g_scan_result_list_p[i] != NULL &&  index != -1) {

+			if (strcmp (g_scan_result_list_p[i]->mac, g_spot_list_p[index]->mac) == 0) {

+				found_ap_index = i;

+

+				if (is_connected == TRUE) {

+					g_scan_result_list_p[i]->connect_status = 1;

+				} else {

+					g_scan_result_list_p[i]->connect_status = 0;

+				}

+

+				break;

+			}

+		}

+

+	}

+

+	//ûÕÒµ½APÔòÖ±½ÓÍ˳ö

+	if (found_ap_index == -1) {

+		return;

+	}

+

+	scan_result_str = safe_malloc (WIFI_STATION_SCAN_RESULT_STR_LEN, FALSE);

+	scan_result_str_tmp = safe_malloc (WIFI_STATION_SCAN_RESULT_STR_LEN, FALSE);

+	if (scan_result_str == NULL || scan_result_str_tmp == NULL) {

+		safe_free (scan_result_str);

+		safe_free (scan_result_str_tmp);

+		return;

+	}

+

+	//²éÕÒEX_APLIST

+	cfg_get_item ("EX_APLIST", scan_result_str, WIFI_STATION_SCAN_RESULT_STR_LEN);

+

+	safe_strcpy (scan_result_str_tmp, scan_result_str, WIFI_STATION_SCAN_RESULT_STR_LEN);

+	//ÒԷֺŷָî×Ö·û´®

+	i = 0;

+	splited_string = strtok_r (scan_result_str_tmp, delimiter, &save);

+	while (splited_string) {

+		if (i == found_ap_index) {

+			//ÕÒµ½connect_statusÔÚ×Ö·û´®ÖеÄË÷Òý

+			found_str_index += 2;

+

+			is_found = TRUE;

+			break;

+		}

+		found_str_index += strlen (splited_string) + 1; //ÒªÔÙ¼ÓÉϷֺŵÄ1¸ö×Ö·û³¤¶È

+

+		i++;

+		splited_string = strtok_r (NULL, delimiter, &save);

+	}

+

+	//²éÕÒEX_APLIST1

+	if (is_found == FALSE) {

+		is_find_EX_APLIST1 = TRUE;

+		found_str_index = 0;

+		memset (scan_result_str, 0, WIFI_STATION_SCAN_RESULT_STR_LEN);

+		memset (scan_result_str_tmp, 0, WIFI_STATION_SCAN_RESULT_STR_LEN);

+		cfg_get_item ("EX_APLIST1", scan_result_str, WIFI_STATION_SCAN_RESULT_STR_LEN);

+

+		safe_strcpy (scan_result_str_tmp, scan_result_str, WIFI_STATION_SCAN_RESULT_STR_LEN);

+

+		splited_string1 = strtok_r (scan_result_str_tmp, delimiter, &save1);

+		while (splited_string1) {

+			if (i == found_ap_index) {

+				//ÕÒµ½connect_statusÔÚ×Ö·û´®ÖеÄË÷Òý

+				found_str_index += 2;

+

+				is_found = TRUE;

+				break;

+			}

+			found_str_index += strlen (splited_string1) + 1; //ÒªÔÙ¼ÓÉϷֺŵÄ1¸ö×Ö·û³¤¶È

+

+			i++;

+			splited_string1 = strtok_r (NULL, delimiter, &save1);

+		}

+	}

+

+	if (is_found == TRUE

+	    && found_str_index > 0 && found_str_index < strlen (scan_result_str)) {

+		if (is_connected == TRUE) {

+			scan_result_str[found_str_index] = '1';

+		} else {

+			scan_result_str[found_str_index] = '0';

+		}

+

+		if (is_find_EX_APLIST1 == TRUE) {

+			cfg_set ("EX_APLIST1", scan_result_str);

+		} else {

+			cfg_set ("EX_APLIST", scan_result_str);

+		}

+	}

+

+	safe_free (scan_result_str);

+	safe_free (scan_result_str_tmp);

+}

+

+static spot_t* parse_spot_string (char *spot_string)

+{

+	spot_t *spot = NULL;

+	char *splited_string = NULL;

+	char *save = NULL;

+	const char *delimiter = ",";

+	wifi_profile_content_t wifi_profile_content = WIFI_STATION_CONTENT_UNDEFINED;

+	char spot_string_tmp[WIFI_STATION_SPOT_LEN] = {0};

+

+	if (spot_string == NULL) {

+		return NULL;

+	}

+	//klocwork

+	strncpy(spot_string_tmp, spot_string, sizeof(spot_string_tmp)-1);

+

+	spot = safe_malloc (sizeof (spot_t), FALSE);

+	if (spot == NULL) {

+		return NULL;

+	}

+

+	spot->is_tried_connect = FALSE;

+

+	//·Ö¸î×Ö·û´®£¬´æ´¢µ½½á¹¹Ìå

+	splited_string = strtok_r (spot_string_tmp, delimiter, &save);

+	while (splited_string) {

+		wifi_profile_content++;

+		switch (wifi_profile_content) {

+		case WIFI_STATION_PROFILE_NAME:

+			//safe_strcpy (spot->profile_name, splited_string, WIFI_STATION_SPOT_PROFILE_NAME_LEN);

+			strncpy (spot->profile_name, splited_string, sizeof(spot->profile_name)-1);

+			break;

+		case WIFI_STATION_FROM_PROVIDER:

+			spot->from_provider = atoi (splited_string);

+			break;

+		case WIFI_STATION_CONNECT_STATUS:

+			spot->connect_status = atoi (splited_string);

+			break;

+		case WIFI_STATION_SIGNAL:

+			spot->signal = atoi (splited_string);

+			break;

+		case WIFI_STATION_SSID:

+			//safe_strcpy (spot->ssid, splited_string, WIFI_STATION_SSID_LEN);

+			strncpy (spot->ssid, splited_string, sizeof(spot->ssid)-1);

+			break;

+		case WIFI_STATION_AUTH_MODE:

+			//safe_strcpy (spot->auth_mode, splited_string, WIFI_STATION_AUTH_MODE_LEN);

+			strncpy (spot->auth_mode, splited_string, sizeof(spot->auth_mode)-1);

+			break;

+		case WIFI_STATION_ENCRYPT_TYPE:

+			//safe_strcpy (spot->encrypt_type, splited_string, WIFI_STATION_ENCRYPT_TYPE_LEN);

+			strncpy (spot->encrypt_type, splited_string, sizeof(spot->encrypt_type)-1);

+			break;

+		case WIFI_STATION_PASSWORD:

+			//safe_strcpy (spot->password, splited_string, WIFI_STATION_SPOT_PASSWORD_LEN);

+			strncpy (spot->password, splited_string, sizeof(spot->password)-1);

+			break;

+		case WIFI_STATION_KEY_ID:

+			spot->keyID = atoi (splited_string);

+			break;

+		case WIFI_STATION_AP_MAC:

+			//safe_strcpy (spot->mac, splited_string, WIFI_STATION_MAC_LEN);

+			strncpy (spot->mac, splited_string, sizeof(spot->mac)-1);

+			break;

+		default:

+			break;

+		}

+

+		splited_string = strtok_r (NULL, delimiter, &save);

+	}

+

+	spot->network_id = -1; // from nv profile , there is no network id property, so ,default set it -1

+

+	if (wifi_profile_content != WIFI_STATION_AP_MAC) {

+		safe_free (spot);

+		return NULL;

+	}

+

+

+	return spot;

+

+}

+

+

+static void  save_config (spot_t *spot)

+{

+

+	char cmd[WIFI_STATION_CMD_LEN] = {0};

+	char *ptr = NULL;

+	char *ptr2 = NULL;

+	char *ptr3 = NULL;

+	char *ptr_w3 = NULL;

+	char *ptr_w23 = NULL;

+	char *ptr5 = NULL;

+	char *ptr6 = NULL;

+	int  key_len = 0;

+	int id;

+

+	if (spot == NULL)    {

+		return;

+	}

+

+	if (spot->network_id   == -1) {

+		

+		//id = atoi (sta_docmd ("ADD_NETWORK"));

+		//klocwork

+		char *reply = NULL;

+		reply = sta_docmd("ADD_NETWORK");

+		if (reply == NULL) {

+			return;

+		}

+		id = atoi(reply);

+	

+		spot->network_id = id;

+		wf_log ("[sav_config] new spot  get new networkid=%d", id);

+

+	} else {

+		id = spot->network_id ;

+		wf_log ("[sav_config] old spot  have networkid=%d", id);

+

+	}

+

+

+	sprintf (cmd,  "SET_NETWORK %d ssid \"%s\"", id , spot->ssid);

+	sta_docmd (cmd);

+

+	memset (cmd, 0, WIFI_STATION_CMD_LEN);

+	ptr = strstr (spot->auth_mode, WIFI_STATION_PROFILE_AUTH_WPA_PSK);

+	ptr2 = strstr (spot->auth_mode, WIFI_STATION_PROFILE_AUTH_WPA2_PSK);

+	ptr3 = strstr (spot->auth_mode, WIFI_STATION_PROFILE_AUTH_WPA_EAP);

+	ptr_w3 = strstr(spot->auth_mode, WIFI_STATION_PROFILE_AUTH_WPA3);

+	ptr_w23 = strstr(spot->auth_mode, WIFI_STATION_PROFILE_AUTH_WPA2_WPA3);

+

+	ptr5 = strstr (spot->encrypt_type, WIFI_STATION_PROFILE_ENCRYPT_CCMP);

+	ptr6 = strstr (spot->encrypt_type, WIFI_STATION_PROFILE_ENCRYPT_TKIP);

+

+	sprintf (cmd, "SET_NETWORK %d priority 1", id);

+	sta_docmd (cmd);

+

+

+	if (ptr || ptr2) {

+		sprintf (cmd, "SET_NETWORK %d key_mgmt WPA-PSK", id);

+		sta_docmd (cmd);

+

+		if (ptr && !ptr2) {

+			sprintf (cmd, "SET_NETWORK %d proto WPA", id);

+			sta_docmd (cmd);

+		} else if (!ptr && ptr2) {

+			sprintf (cmd, "SET_NETWORK %d proto WPA2", id);

+			sta_docmd (cmd);

+		} else{

+			sprintf (cmd, "SET_NETWORK %d proto WPA RSN", id);

+			sta_docmd (cmd);

+		}

+

+		if (ptr5 && !ptr6) {

+			sprintf (cmd, "SET_NETWORK %d pairwise CCMP", id);

+			sta_docmd (cmd);

+		} else if (!ptr5 && ptr6) {

+			sprintf (cmd, "SET_NETWORK %d pairwise TKIP", id);

+			sta_docmd (cmd);

+		} else {

+			wf_log ("[save_config]can support both of CCMP TKIP", ptr5, ptr6);

+			sprintf (cmd, "SET_NETWORK %d pairwise CCMP TKIP", id);

+			sta_docmd (cmd);		

+		}

+

+		sprintf (cmd, "SET_NETWORK %d psk \"%s\" ", id , spot->password);

+		sta_docmd (cmd);

+	} else if (ptr3) { //|| ptr4)

+		sprintf (cmd, "SET_NETWORK %d key_mgmt WPA-EAP", id);

+		sta_docmd (cmd);

+

+		if (g_cardmode == CARD_MODE_USIM) {

+			sprintf (cmd, "SET_NETWORK %d eap AKA", id);

+			sta_docmd (cmd);

+		} else {

+			sprintf (cmd, "SET_NETWORK %d eap SIM", id);

+			sta_docmd (cmd);

+		}

+		sprintf (cmd, "SET_NETWORK %d pcsc '\" \"'", id);

+		sta_docmd (cmd);

+

+//ÖØÐ¸²¸ÇÉèÖÃÓÅÏȼ¶Îª×î¸ß

+		sprintf (cmd, "SET_NETWORK %d priority 4", id);

+		sta_docmd (cmd);

+

+	} else if (ptr_w3) {

+		sprintf (cmd, "SET_NETWORK %d key_mgmt SAE", id);

+		sta_docmd (cmd);

+

+		//if set ,other need ieee80211w 0?

+		//sprintf (cmd, "SET_NETWORK %d proto RSN", id);

+		//sta_docmd (cmd);

+

+		//sprintf (cmd, "SET_NETWORK %d pairwise CCMP", id);

+		//sta_docmd (cmd);

+

+		//sprintf (cmd, "SET_NETWORK %d ieee80211w 2", id);

+		//sta_docmd (cmd);

+

+

+		sprintf (cmd, "SET_NETWORK %d psk \"%s\"", id , spot->password);

+		sta_docmd (cmd);

+	} else if (ptr_w23) {

+		sprintf (cmd, "SET_NETWORK %d key_mgmt SAE WPA-PSK", id);

+		sta_docmd (cmd);

+

+		//sprintf (cmd, "SET_NETWORK %d proto RSN", id);

+		//sta_docmd (cmd);

+

+		//sprintf (cmd, "SET_NETWORK %d pairwise CCMP", id);

+		//sta_docmd (cmd);

+

+		//sprintf (cmd, "SET_NETWORK %d ieee80211w 1", id);

+		//sta_docmd (cmd);

+

+

+		sprintf (cmd, "SET_NETWORK %d psk \"%s\"", id , spot->password);

+		sta_docmd (cmd);

+	} else {

+		sprintf (cmd, "SET_NETWORK %d key_mgmt NONE", id);

+		sta_docmd (cmd);

+	}

+

+	ptr = NULL;

+	ptr = strstr (spot->encrypt_type, WIFI_STATION_PROFILE_ENCRYPT_WEP);

+	if (ptr) {

+		sprintf (cmd, "SET_NETWORK %d wep_tx_keyidx %d", id , spot->keyID);

+		sta_docmd (cmd);

+

+		key_len = strlen (spot->password);

+		wf_log ("key_len=%d,password_wep=%s",  key_len, spot->password);

+		memset (cmd, 0, WIFI_STATION_CMD_LEN);

+		if (key_len == 5 || key_len == 13) { //ascii

+			sprintf (cmd, "SET_NETWORK %d wep_key%d \"%s\"", id , spot->keyID, spot->password);

+		} else if (key_len == 10 || key_len == 26) { //hex

+			sprintf (cmd, "SET_NETWORK %d wep_key%d %s", id,  spot->keyID, spot->password);

+		} else {

+			sprintf (cmd, "SET_NETWORK %d wep_key%d \"%s\"", id, spot->keyID, spot->password);

+		}

+		sta_docmd (cmd);

+	}

+

+	ptr = NULL;

+	ptr = strstr (spot->auth_mode, WIFI_STATION_PROFILE_AUTH_SHARED);

+	if (ptr) {

+		sprintf (cmd, "SET_NETWORK %d auth_alg SHARED", id);

+		sta_docmd (cmd);

+	}

+

+	sprintf (cmd, "SET_NETWORK %d scan_ssid 1", id);

+	sta_docmd (cmd);

+

+

+	sta_docmd ("SAVE_CONFIG");

+	sta_docmd ("LIST_NETWORKS");

+}

+

+

+

+static void dump_spot(void)

+{

+	int i = 0;

+	int spot_num = 0;

+	char wifi_profile_num[WIFI_STATION_PROFILE_NV_NAME_LEN] = {0};

+	cfg_get_item ("wifi_profile_num", wifi_profile_num, sizeof (wifi_profile_num));

+	spot_num = atoi (wifi_profile_num);

+	if (spot_num > WIFI_STATION_SPOT_LIST_NUM || spot_num < 0)

+		return;

+

+//´ËʱµÄ¸öÊýÒѾ­ÊǼõ¹ýµÄÁË£¬ËùÒÔ¸öÊýÒª¼Ó1

+	for (i = 0; i < spot_num; i++) {

+		if (NULL != g_spot_list_p[i]) {

+			wf_log ("spot[%d]%s,%d,%d,%d,%s,%s,%s,%s,%d,%s,%d", i , g_spot_list_p[i]->profile_name,

+			        g_spot_list_p[i]->from_provider, g_spot_list_p[i]->connect_status, g_spot_list_p[i]->signal,

+			        g_spot_list_p[i]->ssid, g_spot_list_p[i]->auth_mode, g_spot_list_p[i]->encrypt_type,

+			        g_spot_list_p[i]->password, g_spot_list_p[i]->keyID, g_spot_list_p[i]->mac, g_spot_list_p[i]->network_id);

+		} else {

+			wf_log ("ERROR, g_spot_list_p[%d] should not be NULL spot_num = %d\n ", i, spot_num);

+		}

+	}

+}

+

+static void del_spot (int id)

+{

+	int i = 0;

+	int spot_num = 0;

+	char wifi_profile_num[WIFI_STATION_PROFILE_NV_NAME_LEN] = {0};

+	cfg_get_item ("wifi_profile_num", wifi_profile_num, sizeof (wifi_profile_num));

+	spot_num = atoi (wifi_profile_num);

+	if (spot_num >= WIFI_STATION_SPOT_LIST_NUM || spot_num < 0)//klocwork

+		return;

+

+	safe_free (g_spot_list_p[id]);

+

+//´ËʱµÄ¸öÊýÒѾ­ÊǼõ¹ýµÄÁË£¬ËùÒÔ¸öÊýÒª¼Ó1

+	for (i = id + 1; i <= spot_num; i++) {

+

+		if (g_spot_list_p[i] != NULL) {

+			g_spot_list_p[i - 1] = g_spot_list_p[i];

+			g_spot_list_p[i] = NULL;

+		}

+	}

+

+

+	//dump_spot();

+}

+

+/*webui ÒѾ­½«ÐÂÔöµÄÈÈµã´æÈënv

+   ´Ëº¯ÊýÐèÒª½«nvÖÐÐÂÈȵ㠸üе½ÎÒÃÇÓ¦ÓõÄÈ«¾Ö±äÁ¿ÖÐ

+   ²¢½«ÐÂÈÈµã´æÈëÅäÖÃÎļþ£¬²¢½«»ñÈ¡µÄnetworkid ´æÈëÈ«¾Ö±äÁ¿

+

+*/

+static void  webui_update_spot_list (updateinfo_t *info)

+{

+	int i = 0;

+	spot_t *spot = NULL;

+	int spot_num = 0;

+	char wifi_profile_num[WIFI_STATION_PROFILE_NV_NAME_LEN] = {0};

+	char sta_ip_status[WIFI_STATION_IP_STATUS_LEN] = {0};

+	int flag = 0;

+

+	cfg_get_item ("wifi_profile_num", wifi_profile_num, sizeof (wifi_profile_num));

+	spot_num = atoi (wifi_profile_num);

+

+	wf_log ("action=%s  profile=%s", info->action, info->spot);

+

+//Ìí¼ÓµÄÈȵ㲻¿ÉÄÜÊÇÔËÓªÉÌÈȵ㣬²»¿ÉÄÜÊÇÕýÁ´½ÓµÄÈȵ㣬ËùÒÔ¶¼ÊÇÆÕͨÈȵ㣬ֱ½Ó°´Ë³Ðò¼ÓÔÚºóÃæ

+	if (strcmp (info->action, "add") == 0) {

+

+		wf_log ("%s  processing", info->action);

+		if (spot_num < 1 || spot_num > WIFI_STATION_SPOT_LIST_NUM) {//klocwork

+			return;

+		}

+

+		spot = parse_spot_string (info->spot);

+		if (spot == NULL) {//klocwork

+			return;

+		}

+		spot->network_id = -1;

+		save_config (spot);

+		g_spot_list_p[spot_num - 1] = spot;

+

+//Èç¹ûÊǶϿª×´Ì¬£¬Ö±½ÓÁ¬½Ó£¬Èç¹ûÊÇÁ¬½Ó״̬£¬Ö»ÐèÒªenable¾Í¿ÉÒÔÁË

+		cfg_get_item ("sta_ip_status", sta_ip_status, sizeof (sta_ip_status));

+

+		if (strcmp (sta_ip_status, "disconnect") == 0) {

+			sta_connect (spot->network_id);

+		}

+

+	} else  if (strcmp (info->action, "modify") == 0) {

+		wf_log ("%s  processing", info->action);

+		spot = parse_spot_string (info->spot);

+		if (spot == NULL) {//klocwork

+			return;

+		}

+		for (i = 0; i < WIFI_STATION_SPOT_LIST_NUM; i++) {

+			if (g_spot_list_p[i] != NULL &&  !strcmp (g_spot_list_p[i]->profile_name, spot->profile_name)) {

+				spot->network_id = g_spot_list_p[i]->network_id;

+				safe_free (g_spot_list_p[i]);

+				g_spot_list_p[i] = spot;

+				save_config (spot);

+				flag = 1;

+				break;

+			}

+		}

+		cfg_get_item ("sta_ip_status", sta_ip_status, sizeof (sta_ip_status));

+

+		if (strcmp (sta_ip_status, "disconnect") == 0) {

+			sta_connect (spot->network_id);

+		}

+		if (flag == 0) {//for klocwork,¼Ç¼ȫ¾ÖµÄ²»ÄÜɾ

+			safe_free (spot);

+		}

+	} else if (strcmp (info->action, "delete") == 0) {

+		int  network_id = -1;;

+		int  del_id = -1;

+		char cmd[WIFI_STATION_CMD_LEN] = {0};

+		wf_log ("%s  processing", info->action);

+

+		dump_spot();

+		for (i = 0; i < WIFI_STATION_SPOT_LIST_NUM; i++) {

+			if (g_spot_list_p[i] != NULL &&  !strncmp (g_spot_list_p[i]->profile_name, info->spot,  strlen(g_spot_list_p[i]->profile_name))) {

+				network_id = g_spot_list_p[i]->network_id;

+				del_id = i;

+				break;

+			}

+		}

+

+		if (network_id != -1) {

+			sprintf (cmd, "REMOVE_NETWORK %d", network_id);

+			sta_docmd (cmd);

+			sta_docmd ("SAVE_CONFIG");

+

+			if (del_id != -1)

+				del_spot (del_id);

+		} else {

+			wf_log ("spot:%s not found", info->spot);

+		}

+

+	}

+	dump_spot();

+}

+

+

+

+/*

+	ÔÚɾ³ýÈȵã¹ý³ÌÖÐͻȻ¶Ïµç£¬ÎÞ·¨±£´æµ½conf Îļþ£¬ÐèÒªÖØÐÂͬ²½Ò»ÏÂ

+

+*/

+

+static int  get_spot_info_from_conf (spot_ssid_id_t  *info, int num)

+{

+

+	int i = 0;

+	char cmd[WIFI_STATION_CMD_LEN] = {0};

+	char * reply = NULL;

+

+	for (i = 0; i < WIFI_STATION_SPOT_LIST_NUM; i++) {

+

+		info->id = -1;

+		memset (info->ssid, 0 , sizeof (info->ssid));

+

+		sprintf (cmd, "GET_NETWORK %d ssid", i);

+		reply = sta_docmd (cmd);

+		if (reply != NULL) {

+			wf_log ("[update networkid from conf]reply SSID=%s", reply);

+			strncpy (info->ssid, reply, sizeof (info->ssid)-1);

+		} else {

+			wf_log ("[update networkid from conf]conf read over!");

+			break;

+		}

+

+		if (strlen (info->ssid) > 0) {

+			wf_log ("[update networkid from conf] delete quote");

+

+			delete_quote (info->ssid);

+		}

+

+		info->id = i;

+		wf_log ("[update networkid from conf]SSID=%s, network_id=%d", info->ssid, i);

+		info += 1;

+	}

+

+	return i;

+}

+

+

+/**/

+static void  delete_quote (char * str)

+{

+	int len = 0;

+	printf("str=%s\n", str);

+	if (*str == '\"') {

+		//strcpy (str, str + 1); //cov m

+		len = strlen(str + 1);

+		memmove(str, str + 1, len + 1); 

+		*(str + len) = '\0';

+	}

+	printf("str=%s\n", str);

+

+	if (*(str + strlen(str) - 1) == '\"')

+		*(str + strlen(str) - 1) = '\0';

+

+	printf("str=%s\n", str);

+}

+

+

+//1.  ¿ªÆô¹Ø±Õapsta

+/*

+

+     ¿ªÆô: conf fileÖØÐ±»wpa_supplicant¶ÁÈ¡£¬ÖØÆô·ÖÅänetwork id£¬ÐèÒªÖØÐÂͬ²½µ½spot list

+

+

+     ¹Ø±Õ: ²»Çå¿Õconf file£¬ ΪÁ˺͹ػú±£³ÖÒ»Ö£¬Ò²ÐèÒª½«spot ÄÚÈÝÇå¿Õ

+*/

+

+

+//2.  ¿ª»ú¹Ø»ú

+/*

+

+       ¹Ø»ú: Õý³£¹Ø»úºÍÒì³£¶Ïµç£¬¶¼²»»áÓÐÈκβÙ×÷Á÷³Ì£¬confÎļþ²»»áÐÞ¸Ä

+       ¿ª»ú: Ö±½ÓÖØÐ·ÖÅäspot Äڴ棬´Ónvͬ²½spotÊý¾Ý£¬È»ºó´ÓconfÎļþÖÐͬ²½networkid£¬Èç¹ûûÓжÔÓ¦µÄnetworid

+

+       ÔòÐèÒªÖØÐÂÌí¼Ó¸ÃÈȵ㵽confÎļþÖУ¬±ÈÈçÊÇÖ±½ÓÔ¤ÖõÄÔËÓªÉÌÈȵã

+

+*/

+void  sync_nv_spot_list_conf_file()

+{

+	spot_ssid_id_t   g_spot_ssid_id_p[WIFI_STATION_SPOT_LIST_NUM] = {{0}};

+

+	int i = 0, j = 0;

+	int spot_num = 0;

+	int  conf_spot_num = 0;

+

+	char wifi_profile_num[WIFI_STATION_PROFILE_NV_NAME_LEN] = {0};

+	cfg_get_item ("wifi_profile_num", wifi_profile_num, sizeof (wifi_profile_num));

+	spot_num = atoi (wifi_profile_num);

+	if (spot_num > WIFI_STATION_SPOT_LIST_NUM || spot_num < 0)

+		return;

+

+	memset (g_spot_ssid_id_p, 0,  WIFI_STATION_SPOT_LIST_NUM * sizeof (struct  spot_ssid_id));

+	conf_spot_num = get_spot_info_from_conf (g_spot_ssid_id_p, spot_num);

+	wf_log ("spot_num=%d,conf_spot_num=%d", spot_num, conf_spot_num);

+

+	for (i = 0; i < spot_num; i++) {

+		wf_log ("[sync spot before]SSID:%s, networkid=%d", g_spot_list_p[i]->ssid,  g_spot_list_p[i]->network_id);

+		for (j = 0; j < WIFI_STATION_SPOT_LIST_NUM; j ++) {

+//[sync before]spot SSID:CPE_E3DE4E, conf ssid="CPE_E3DE4E",   dubble quote !!!!!!

+			wf_log ("[compare to conf]spot SSID:%s, conf ssid=%s", g_spot_list_p[i]->ssid,  g_spot_ssid_id_p[j].ssid);

+			if (strcmp (g_spot_ssid_id_p[j].ssid,  g_spot_list_p[i]->ssid)  == 0) {

+				g_spot_list_p[i]->network_id = g_spot_ssid_id_p[j].id;

+				break;

+			}

+		}

+

+		if (-1 == g_spot_list_p[i]->network_id) {

+			save_config (g_spot_list_p[i]); //Èç¹ûconfÖÐûÓУ¬ÔòÐèÒª¼ÓÈ룬update spot  networkid

+		}

+		wf_log ("[sync spot after]SSID:%s, networkid=%d", g_spot_list_p[i]->ssid,  g_spot_list_p[i]->network_id);

+	}

+

+/*ÌÞ³ý confÎļþÖÐûÓÐÕý³£É¾³ýµÄspot*/

+	for (i = 0; i < conf_spot_num; i++) {

+		int  conf_spot_in_nv = 0;

+

+		wf_log ("[sync conf  before]SSID:%s, networkid=%d", g_spot_ssid_id_p[i].ssid, g_spot_ssid_id_p[i].id);

+		if (strlen (g_spot_ssid_id_p[i].ssid) > 0) {

+			for (j = 0; j < spot_num; j ++) {

+				wf_log ("[compare to spot]g_spot_list_p[j]->ssid=%s", g_spot_list_p[j]->ssid);

+				if (strcmp (g_spot_ssid_id_p[i].ssid,  g_spot_list_p[j]->ssid) == 0) {

+					conf_spot_in_nv = 1;

+					break;

+				}

+			}

+

+			//   Èç¹û²»´æÔÚnvÖУ¬ÐèҪɾ³ý

+			if (0  == conf_spot_in_nv) {

+				char cmd[WIFI_STATION_CMD_LEN] = {0};

+				sprintf (cmd, "REMOVE_NETWORK %d", g_spot_ssid_id_p[i].id);

+				sta_docmd (cmd);

+			}

+		}

+

+		wf_log ("[sync conf after]SSID:%s, networkid=%d", g_spot_ssid_id_p[i].ssid, g_spot_ssid_id_p[i].id);

+	}

+

+

+

+}

+

+//»ñÈ¡ÈȵãÁÐ±í£¬·µ»ØÒ»¸öÖ¸ÕëÊý×飬·ÅÈëÈ«¾Ö

+static void get_spot_list (void)

+{

+	int i = 0;

+	int j = 0;

+	char spot_string[WIFI_STATION_SPOT_LEN] = {0};

+	char wifi_profile_nv_name[WIFI_STATION_PROFILE_NV_NAME_LEN] = {0};

+	spot_t *spot = NULL;

+	int spot_num = 0;

+	char wifi_profile_num[WIFI_STATION_PROFILE_NV_NAME_LEN] = {0};

+	cfg_get_item ("wifi_profile_num", wifi_profile_num, sizeof (wifi_profile_num));

+	spot_num = atoi (wifi_profile_num);

+

+	wf_log ("free [g_spot_list_p] all spot");

+

+	//ÏÈÊÍ·Å֮ǰ´æ´¢µÄÈȵãÁбíÄÚ´æ

+	for (i = 0; i < WIFI_STATION_SPOT_LIST_NUM; i++) {

+		safe_free (g_spot_list_p[i]);

+		//g_spot_list_p[i] = NULL;

+	}

+

+	if (spot_num > 0 && spot_num <= WIFI_STATION_SPOT_LIST_NUM) {

+		for (i = 0; i < spot_num; i++) {

+			if (i == 0) {

+				cfg_get_item ("wifi_profile", spot_string, WIFI_STATION_SPOT_LEN);

+			} else {

+				memset (wifi_profile_nv_name, 0, WIFI_STATION_PROFILE_NV_NAME_LEN);

+				snprintf (wifi_profile_nv_name, WIFI_STATION_PROFILE_NV_NAME_LEN, "wifi_profile%d", i);

+				cfg_get_item (wifi_profile_nv_name, spot_string, WIFI_STATION_SPOT_LEN);

+			}

+

+			wf_log ("get_spot_list spot_string[%d]= %s", i, spot_string);

+			spot = parse_spot_string (spot_string);

+			if (spot != NULL) {

+				g_spot_list_p[j] = spot;

+				j++;

+			}

+		}

+	}

+

+}

+

+static void save_spot_list (void)

+{

+	int i = 0;

+	char spot_string[WIFI_STATION_SPOT_LEN] = {0};

+	char wifi_profile_nv_name[WIFI_STATION_PROFILE_NV_NAME_LEN] = {0};

+

+	for (i = 0; i < WIFI_STATION_SPOT_LIST_NUM; i++) {

+		if (g_spot_list_p[i] != NULL) {

+			snprintf (spot_string, WIFI_STATION_SPOT_LEN, "%s,%d,%d,%d,%s,%s,%s,%s,%d,%s", g_spot_list_p[i]->profile_name,

+			          g_spot_list_p[i]->from_provider, g_spot_list_p[i]->connect_status, g_spot_list_p[i]->signal,

+			          g_spot_list_p[i]->ssid, g_spot_list_p[i]->auth_mode, g_spot_list_p[i]->encrypt_type,

+			          g_spot_list_p[i]->password, g_spot_list_p[i]->keyID, g_spot_list_p[i]->mac);

+

+			wf_log (" g_spot_list_p[%d]=%s, [%d]", i, spot_string, g_spot_list_p[i]->network_id);

+

+			if (i == 0) {

+				cfg_set ("wifi_profile", spot_string);

+			} else {

+				snprintf (wifi_profile_nv_name, WIFI_STATION_PROFILE_NV_NAME_LEN, "wifi_profile%d", i);

+				cfg_set (wifi_profile_nv_name, spot_string);

+			}

+		}

+	}

+}

+

+

+/*

+½«Á´½Ó³É¹¦µÄÈȵ㣬Åŵ½µÚһλ

+*/

+static void resort_spot_list (void)

+{

+

+	int i = 0, j = 0;

+	int index = 0;

+	spot_t *  spot = NULL;

+	//  char      profile[WIFI_STATION_SPOT_PROFILE_NAME_LEN] = {0};

+

+//    cfg_get_item("EX_wifi_profile", profile, WIFI_STATION_SPOT_PROFILE_NAME_LEN);

+

+

+	for (i = 0; i < WIFI_STATION_SPOT_LIST_NUM; i++) {

+		if (g_spot_list_p[i] != NULL) {

+			if (g_spot_list_p[i]->connect_status == 1) {

+				index = i;

+				spot = g_spot_list_p[i];

+				break;

+			}

+		}

+

+	}

+

+	if (index == 0) return;

+

+	for (i = 0; i < WIFI_STATION_SPOT_LIST_NUM; i++) {

+		if (1 == g_spot_list_p[i]->from_provider) {

+			continue;

+		} else {

+			//move other spot

+			for (j = index; j > i; j--) { // ¼Ù¶¨×îºóÒ»¸ö¿Ï¶¨Êǿյ쬲»¿ÉÄÜ10¸öÂúÁË£¬»¹ÔÚÌí¼ÓÈȵ㣬֮ǰÒѾ­ÅжϴíÎó·µ»ØÁË

+				if (g_spot_list_p[j] == NULL) continue;

+				else {

+					g_spot_list_p[j] = g_spot_list_p[j - 1]; //j must greater than 0

+				}

+			}

+			if (i != index) {

+				g_spot_list_p[i] = spot;

+				wf_log ("[%s]SSID=[%s] from %d move to %d", __FILE__, spot->ssid, index, i);

+			} else {

+				wf_log ("[%s]SSID=[%s] do not move", __FILE__, spot->ssid);

+			}

+			break;

+		}

+	}

+

+	//¸ü¸Ä˳Ðòºó£¬ÐèÒªÖØÐ±¸·Ý signal

+	//reback_up_signal();

+

+	save_spot_list();

+

+}

+

+

+static void update_spot_list_signal_connect_status (short signal, short connect_status)

+{

+	int i = 0;

+

+	for (i = 0; i < WIFI_STATION_SPOT_LIST_NUM; i++) {

+		if (g_spot_list_p[i] != NULL) {

+			if (signal >= 0) {

+				g_spot_list_p[i]->signal = signal;

+			}

+

+			if (connect_status >= 0) {

+				g_spot_list_p[i]->connect_status = connect_status;

+			}

+		}

+	}

+

+}

+

+static void update_spot_connect_status_by_status_result (BOOL is_connected)

+{

+	int i = 0;

+	char spot_string[WIFI_STATION_SPOT_LEN] = {0};

+	char wifi_profile_nv_name[WIFI_STATION_PROFILE_NV_NAME_LEN] = {0};

+

+	wf_log ("is_connected=%d, g_linked_network_id= %d", is_connected, g_linked_network_id);

+

+	for (i = 0; i < WIFI_STATION_SPOT_LIST_NUM; i++) {

+		if (g_spot_list_p[i] != NULL &&  g_spot_list_p[i] ->network_id == g_linked_network_id) {

+			if (is_connected == TRUE) {

+				g_spot_list_p[i]->connect_status = 1;

+			} else {

+				g_spot_list_p[i]->connect_status = 0;

+			}

+

+			if (strcmp (g_spot_list_p[i]->mac, "0F:00:00:00:00:00") == 0) {

+				strcpy (g_spot_list_p[i]->mac, g_linked_ap_mac);

+			}

+			wf_log ("g_spot_list_p[%d]->mac=%s", i, g_spot_list_p[i]->mac);

+			wf_log ("profile[%d]=%d", i, g_spot_list_p[i]->connect_status);

+

+			snprintf (spot_string, WIFI_STATION_SPOT_LEN, "%s,%d,%d,%d,%s,%s,%s,%s,%d,%s", g_spot_list_p[i]->profile_name,

+			          g_spot_list_p[i]->from_provider, g_spot_list_p[i]->connect_status, g_spot_list_p[i]->signal,

+			          g_spot_list_p[i]->ssid, g_spot_list_p[i]->auth_mode, g_spot_list_p[i]->encrypt_type,

+			          g_spot_list_p[i]->password, g_spot_list_p[i]->keyID, g_spot_list_p[i]->mac);

+

+			if (i == 0) {

+				cfg_set ("wifi_profile", spot_string);

+			} else {

+				snprintf (wifi_profile_nv_name, WIFI_STATION_PROFILE_NV_NAME_LEN, "wifi_profile%d", i);

+				cfg_set (wifi_profile_nv_name, spot_string);

+			}

+

+			break;

+		}

+	}

+}

+

+static void update_spot_signal_by_scan_result (scan_result_t *scan_result)

+{

+	int i = 0;

+

+	if (scan_result == NULL) {

+		return;

+	}

+

+	for (i = 0; i < WIFI_STATION_SPOT_LIST_NUM; i++) {

+		if (g_spot_list_p[i] != NULL) {

+			if (strcmp (g_spot_list_p[i]->mac, scan_result->mac) == 0  &&

+

+			    strcmp (g_spot_list_p[i]->ssid, scan_result->ssid) == 0

+			    //     && (strcmp(g_spot_list_p[i]->auth_mode, scan_result->auth_mode) == 0 ||

+			    //          (strcmp(g_spot_list_p[i]->auth_mode,WIFI_STATION_PROFILE_AUTH_WPA_EAP)==0 && strcmp(scan_result->auth_mode,"802.1X")==0))

+			    /*&& strstr(g_spot_list_p[i]->encrypt_type, scan_result->encrypt_type) != NULL*/)

+// Õë¶ÔÒþ²ØÈȵ㣬ÊÖ¶¯Ìí¼ÓµÄcipherΪauto£¬µ¼ÖÂÎÞ·¨Ê¶±ð¸üÐÂÈȵãÐźÅ

+//±¾À´ÐèҪʹÓÃmac½øÐÐÆ¥Å䣬Î÷°²²»ÅäºÏ£¬Ö»ÓÐÈ¡ÕâÑùµÄ·±Ëö°ì·¨

+//webui×Ô¶¯Ê¶±ðtkip aesΪauto£¬±£´æÔÚnv profileÀïÃæÎªTKIPCCMP,µ¼Ö´˴¦ÎÞ·¨Æ¥Å䣬ÎÞ·¨¸üÐÂÈȵãÐźÅ

+//EAP-SIM/AKA, ÓëÔ­±¾Ð´µÄ802.1xÒ²²»Æ¥Å䣬µ¼ÖÂÎÞ·¨¸üÐÂÈȵãÐźÅ

+//ÐÞ¸ÄΪɨÃèÈȵãµÄ¼ÓÃÜÀàÐÍΪTKIP CCMP,Ö»ÒªÄÜÔÚ±£´æÈȵãÖÐÕÒµ½´Ë×Ö·û£¬ÔòÈÏΪÊÇͬһ¸öÈȵ㣬µ«ÊÇÎÞ·¨½â¾öÕæµÄÓÐÁ½¸öÏàͬµÄÈȵ㣬Õâ¸öÎÞ·¨Ê¶±ð

+			{

+				g_spot_list_p[i]->signal = scan_result->signal;

+				break;

+			}

+		}

+	}

+}

+

+

+static void sort_scan_result_by_signal (scan_result_t **scan_result, int size)

+{

+	int i, j = 0;

+	scan_result_t *insertnode = NULL;

+

+	if (scan_result == NULL) {

+		return;

+	}

+

+	for (i = 0; i < size; i++) {

+		if (scan_result[i] == NULL) {

+			return;

+		}

+	}

+

+	//Ö±½Ó²åÈëÅÅÐòËã·¨

+	for (i = 1; i < size; i++) { //ÒÀ´Î²åÈëÊýÖµ

+		insertnode = scan_result[i];  //ÉèÖÃÓû²åÈëµÄÊýÖµ,ÉÚ±ø

+		j = i - 1;                                             //Óû²åÈëÊý×éµÄ¿ªÊ¼Î»ÖÃ

+		while (j >= 0 && insertnode->signal > scan_result[j]->signal) { //ÕÒÊʵ±µÄ²åÈëλÖÃ

+			scan_result[j + 1] = scan_result[j];

+			j--;

+		}

+		scan_result[j + 1] = insertnode;

+	}

+

+}

+

+/*

+    inputStr: if there is a  \, then

+    outputStr: add \\ before, to be \\\

+

+

+*/

+

+static char* process_backlash (char* inputStr, char* outputStr)

+{

+	int len = 0;

+	int i, j = 0;

+	if ( (NULL == inputStr) || (NULL == outputStr)) {

+		return NULL;

+	}

+

+	len = strlen (inputStr);

+	for (i = 0; i < len; i++) { //linux תÒå

+		if ( (inputStr[i] == 0x5c && inputStr[i + 1] == 'x')) {

+			outputStr[j++]  = 0x5c;

+		}

+		outputStr[j++] = inputStr[i];

+	}

+	outputStr[j] = '\0';

+	//printf("[process_backlash]inputStr=%s,outputStr=%s",inputStr,outputStr);

+

+	return outputStr;

+}

+

+static void save_scan_result (scan_result_t*  scan_result, char *scan_result_str, char *scan_result_str1)

+{

+	char *scan_result_str_temp = NULL;

+	char one_scan_result_str[WIFI_STATION_SCAN_ONE_RESULT_STR_LEN] = {0};

+	int one_scan_result_str_len = 0;

+

+	char ssid[128] = {0};

+	if (scan_result == NULL

+	    || scan_result_str == NULL

+	    || scan_result_str1 == NULL) {

+		return;

+	}

+

+	if (strlen (scan_result->ssid) <= 0) {

+		return;

+	}

+

+	scan_result_str_temp = safe_malloc (WIFI_STATION_SCAN_RESULT_STR_LEN, TRUE);

+

+

+	process_backlash (scan_result->ssid, ssid);

+

+	snprintf (one_scan_result_str, WIFI_STATION_SCAN_ONE_RESULT_STR_LEN, "%d,%d,%s,%d,%d,%s,%s,%s", scan_result->from_provider, scan_result->connect_status, ssid,

+	          scan_result->signal, scan_result->channel, scan_result->auth_mode, scan_result->encrypt_type, scan_result->mac);

+

+	one_scan_result_str_len = strlen (one_scan_result_str);

+

+	//cfg½Ó¿ÚÊÇÒÔ"nv name=nv value\0"·½Ê½À´´æ´¢£¬ÇÒÒ»´Î×Ϊ1024£¬Òò´ËÕâ±ßÊÇ+2

+	if (one_scan_result_str_len + strlen (scan_result_str) + strlen ("EX_APLIST") + 2 > WIFI_STATION_SCAN_RESULT_STR_LEN) {

+		if (one_scan_result_str_len + strlen (scan_result_str1) + strlen ("EX_APLIST1") + 2 > WIFI_STATION_SCAN_RESULT_STR_LEN) {

+			//³¬³ö2048×Ö½ÚÁË£¬Í˳ö

+			safe_free (scan_result_str_temp);

+			return;

+		} else {

+			safe_strcpy (scan_result_str_temp, scan_result_str1, strlen(scan_result_str1) + 1);

+

+			strncat (scan_result_str_temp, one_scan_result_str, one_scan_result_str_len);

+			strncat (scan_result_str_temp, ";", 1);

+

+			//¸³Öµ½á¹û

+			safe_strcpy (scan_result_str1, scan_result_str_temp, WIFI_STATION_SCAN_RESULT_STR_LEN);

+		}

+	} else {

+		safe_strcpy (scan_result_str_temp, scan_result_str, strlen(scan_result_str) + 1);//wlocwork

+

+		strncat (scan_result_str_temp, one_scan_result_str, one_scan_result_str_len);

+		strncat (scan_result_str_temp, ";", 1);

+

+		//¸³Öµ½á¹û

+		safe_strcpy (scan_result_str, scan_result_str_temp, WIFI_STATION_SCAN_RESULT_STR_LEN);

+	}

+

+	safe_free (scan_result_str_temp);

+

+}

+

+

+static scan_result_t* parse_scan_result (Var *var)

+{

+	char *ptr = NULL;

+	char *ptr1 = NULL;

+	char *ptr2 = NULL;

+	char *ptr3 = NULL;

+	char *ptr4 = NULL;

+	char *ptr5 = NULL;

+	scan_result_t *scan_result = NULL;

+	int frequency = 0;

+	int signal = 0;

+	char flags[WIFI_STATION_FLAGS_LEN] = {0};

+	char sta_ip_status[WIFI_STATION_IP_STATUS_LEN] = {0};

+

+	char operater_ap[32] = {0};

+

+	if (var == NULL) {

+		return NULL;

+	}

+

+	//²éÕÒÊÇ·ñÊǿɺöÂÔµÄÒ»ÐÐ

+	ptr = strstr (var->val.str.sval, WIFI_STATION_SCAN_RESULT_PARSE_IGNORE);

+	if (ptr) {

+		return NULL;

+	} else {

+		//·ÖÅäɨÃè½á¹ûÄÚ´æ

+		scan_result = safe_malloc (sizeof (scan_result_t), FALSE);

+		if (scan_result == NULL) {

+			return NULL;

+		}

+

+		//Æ¥ÅäɨÃè½á¹ûÐÅÏ¢

+		sscanf (var->val.str.sval, "%19[0-9,a-f,A-F,:]       %d    %d     %127s    %127[^\n]", scan_result->mac, &frequency, &signal, flags, scan_result->ssid);

+

+		if (strncmp (scan_result->ssid, "\\x00", 4) == 0) {

+			wf_log ("scan_result->mac=[%s] scan_result->ssid=[%s]is a hidden AP",

+			        scan_result->mac, scan_result->ssid);

+			safe_free (scan_result);

+			return NULL;

+		}

+

+

+		cfg_get_item ("operater_ap", operater_ap, sizeof (operater_ap));

+		if (strcmp (scan_result->ssid, operater_ap) == 0) {

+			scan_result->from_provider = 1;//fromProvider ÊÇ·ñÀ´×ÔÔËÓªÉÌ

+		} else {

+			scan_result->from_provider = 0;//fromProvider ÊÇ·ñÀ´×ÔÔËÓªÉÌ

+		}

+

+		cfg_get_item ("sta_ip_status", sta_ip_status, sizeof (sta_ip_status));

+		//connectStatus Á¬½Ó״̬

+		if (g_linked_network_id != -1 &&  strcmp (sta_ip_status, "connect") == 0) {

+			int i = 0;

+			i = find_linked_ap_index();

+			if (i !=  -1) {

+				wf_log ("g_spot_list_p[i]->ssid=[%s],scan_result->ssid=[%s]",

+				        g_spot_list_p[i]->ssid, scan_result->ssid);

+

+				if (strcmp (g_spot_list_p[i]->mac, scan_result->mac) == 0

+				    && strcmp (g_spot_list_p[i]->ssid, scan_result->ssid) == 0) {

+					scan_result->connect_status = 1;

+				} else {

+					scan_result->connect_status = 0;

+

+				}

+				wf_log ("connect_status = [%d]",  scan_result->connect_status);

+			} else {

+				scan_result->connect_status = 0;

+			}

+

+		} else {

+			scan_result->connect_status = 0;

+		}

+

+		//signalÐźÅÇ¿¶È

+		if (signal > WIFI_STATION_SIGNAL_LEVEL4) {

+			scan_result->signal = 4;

+		} else if (signal > WIFI_STATION_SIGNAL_LEVEL3) {//kw 3

+			scan_result->signal = 3;

+		} else if (signal > WIFI_STATION_SIGNAL_LEVEL2) {

+			scan_result->signal = 2;

+		} else if (signal > WIFI_STATION_SIGNAL_LEVEL1) {

+			scan_result->signal = 1;

+		} else {

+			scan_result->signal = 0;

+		}

+

+		//channel

+		switch (frequency) {

+		case WIFI_STATION_CHANNEL1:

+			scan_result->channel = 1;

+			break;

+		case WIFI_STATION_CHANNEL2:

+			scan_result->channel = 2;

+			break;

+		case WIFI_STATION_CHANNEL3:

+			scan_result->channel = 3;

+			break;

+		case WIFI_STATION_CHANNEL4:

+			scan_result->channel = 4;

+			break;

+		case WIFI_STATION_CHANNEL5:

+			scan_result->channel = 5;

+			break;

+		case WIFI_STATION_CHANNEL6:

+			scan_result->channel = 6;

+			break;

+		case WIFI_STATION_CHANNEL7:

+			scan_result->channel = 7;

+			break;

+		case WIFI_STATION_CHANNEL8:

+			scan_result->channel = 8;

+			break;

+		case WIFI_STATION_CHANNEL9:

+			scan_result->channel = 9;

+			break;

+		case WIFI_STATION_CHANNEL10:

+			scan_result->channel = 10;

+			break;

+		case WIFI_STATION_CHANNEL11:

+			scan_result->channel = 11;

+			break;

+		case WIFI_STATION_CHANNEL12:

+			scan_result->channel = 12;

+			break;

+		case WIFI_STATION_CHANNEL13:

+			scan_result->channel = 13;

+			break;

+		default:

+			scan_result->channel = 0;

+			break;

+		}

+

+		//authMode¼øÈ¨Ä£Ê½

+		ptr = NULL;

+		ptr2 = NULL;

+		ptr3 = NULL;

+		ptr = strstr (flags, WIFI_STATION_AUTH_WPA_PSK);

+		ptr1 = strstr (flags, WIFI_STATION_AUTH_WPA3); //wpa2/wpa3: [WPA2-PSK+SAE-CCMP] wpa3: [WPA2-SAE-CCMP][ESS]

+		ptr2 = strstr (flags, WIFI_STATION_AUTH_WPA2_PSK);

+		ptr3 = strstr (flags, WIFI_STATION_AUTH_SHARED);

+		ptr4 = strstr (flags, WIFI_STATION_AUTH_WPA_EAP);

+		ptr5 = strstr (flags, WIFI_STATION_AUTH_WPA2_EAP);

+		if (ptr && ptr2) {

+			snprintf (scan_result->auth_mode, WIFI_STATION_AUTH_MODE_LEN, "WPAPSKWPA2PSK");

+		} else if (ptr1 && ptr2) {

+			snprintf (scan_result->auth_mode, WIFI_STATION_AUTH_MODE_LEN, "WPA2WPA3");

+		} else if (ptr) {

+			snprintf (scan_result->auth_mode, WIFI_STATION_AUTH_MODE_LEN, "WPAPSK");

+		} else if (ptr2) {

+			snprintf (scan_result->auth_mode, WIFI_STATION_AUTH_MODE_LEN, "WPA2PSK");

+		} else if (ptr1) {

+			snprintf (scan_result->auth_mode, WIFI_STATION_AUTH_MODE_LEN, "WPA3Personal");

+		} else if (ptr3) {

+			snprintf (scan_result->auth_mode, WIFI_STATION_AUTH_MODE_LEN, "SHARED");

+		} else if (ptr4 && ptr5) {

+

+			snprintf (scan_result->auth_mode, WIFI_STATION_AUTH_MODE_LEN, "802.1X");

+			//TODO  scan_result->from_provider = 1;//fromProvider ÊÇ·ñÀ´×ÔÔËÓªÉÌ

+		} else if (ptr4) {

+			snprintf (scan_result->auth_mode, WIFI_STATION_AUTH_MODE_LEN, "802.1X");

+

+			//TODO scan_result->from_provider = 1;//fromProvider ÊÇ·ñÀ´×ÔÔËÓªÉÌ

+		} else if (ptr5) {

+			snprintf (scan_result->auth_mode, WIFI_STATION_AUTH_MODE_LEN, "802.1X");

+

+			//TODO scan_result->from_provider = 1;//fromProvider ÊÇ·ñÀ´×ÔÔËÓªÉÌ

+		} else {

+			snprintf (scan_result->auth_mode, WIFI_STATION_AUTH_MODE_LEN, "OPEN");

+		}

+

+		//encryptType¼ÓÃÜÀàÐÍ

+		ptr = NULL;

+		ptr2 = NULL;

+		ptr3 = NULL;

+		ptr = strstr (flags, WIFI_STATION_ENCRYPT_CCMP);

+		ptr2 = strstr (flags, WIFI_STATION_ENCRYPT_TKIP);

+		ptr3 = strstr (flags, WIFI_STATION_ENCRYPT_WEP);

+		if (ptr && ptr2) {

+			snprintf (scan_result->encrypt_type, WIFI_STATION_ENCRYPT_TYPE_LEN, "TKIPCCMP");

+		} else if (ptr) {

+			snprintf (scan_result->encrypt_type, WIFI_STATION_ENCRYPT_TYPE_LEN, "CCMP");

+		} else if (ptr2) {

+			snprintf (scan_result->encrypt_type, WIFI_STATION_ENCRYPT_TYPE_LEN, "TKIP");

+		} else if (ptr3) {

+			snprintf (scan_result->encrypt_type, WIFI_STATION_ENCRYPT_TYPE_LEN, "WEP");

+		} else {

+			snprintf (scan_result->encrypt_type, WIFI_STATION_ENCRYPT_TYPE_LEN, "NONE");

+		}

+	}

+

+	return scan_result;

+

+}

+

+

+static void handle_scan_result (vector_t* v)

+{

+	int i = 0;

+	int j = 0;

+	Var *var = NULL;

+	char *scan_result_str = NULL;

+	char *scan_result_str1 = NULL;

+	int scan_result_str_len = 0;

+	int scan_result_str_len1 = 0;

+	scan_result_t *scan_result = NULL;

+

+	if (v == NULL) {

+		return;

+	}

+

+	scan_result_str = safe_malloc (WIFI_STATION_SCAN_RESULT_STR_LEN, FALSE);

+	scan_result_str1 = safe_malloc (WIFI_STATION_SCAN_RESULT_STR_LEN, FALSE);

+

+	if (scan_result_str == NULL || scan_result_str1 == NULL) {

+		safe_free (scan_result_str);

+		safe_free (scan_result_str1);

+		return;

+	}

+

+	//ÏÈÊÍ·Å֮ǰ´æ´¢µÄɨÃèÈȵãÁбíÄÚ´æ

+	for (i = 0; i < WIFI_STATION_SCAN_RESULT_LIST_NUM; i++) {

+		safe_free (g_scan_result_list_p[i]);

+		//g_scan_result_list_p[i] = NULL;

+		//printf("xujian safe_free g_scan_result_list_p[%d] = %d \n", i, g_scan_result_list_p[i]);

+	}

+

+// Ö»ÄÜÊÇÔÚwebui¸üÐÂÁбí²Å»áÈ¥»ñÈ¡ÁÐ±í£¬ÆäËûÇé¿ö²»ÐèÒª

+//    get_spot_list();

+	//Ïȳõʼ»¯ÈȵãÁбíµÄÐźÅΪ0

+	update_spot_list_signal_connect_status (0, -1);

+

+	for (i = 0; i < vector_size (v); i++) {

+		if (j >= WIFI_STATION_SCAN_RESULT_LIST_NUM) {

+			break;

+		}

+

+		var = vector_get (v, i);

+		if (var->type == IS_STRING) {

+			scan_result = parse_scan_result (var); // ÀïÃæÓÐ ¸üРɨÃèÁбíµÄ ÈȵãÁ¬½ÓÇé¿ö£¬¸ù¾ÝmacµØÖ·½øÐÐÆ¥Åä

+			if (scan_result != NULL) {

+				g_scan_result_list_p[j] = scan_result;

+

+				//²éÕÒ¸üжÔÓ¦ÈȵãµÄÐźÅÇ¿¶È

+				update_spot_signal_by_scan_result (g_scan_result_list_p[j]);

+

+				j++;

+			}

+		}

+	}

+

+	save_spot_list();

+

+	sort_scan_result_by_signal (g_scan_result_list_p, j);

+

+	for (i = 0; i < j; i++) {

+		save_scan_result (g_scan_result_list_p[i], scan_result_str, scan_result_str1);

+	}

+

+	scan_result_str_len = strlen (scan_result_str);

+	scan_result_str_len1 = strlen (scan_result_str1);

+

+	wf_log ("scan_result_str_len = %d scan_result_str_len1 = %d j = %d", scan_result_str_len, scan_result_str_len1, j);

+

+	//ÏÈÇå¿ÕɨÃèÁбíNV£¬ÔÙд

+	cfg_set ("EX_APLIST", "");

+	cfg_set ("EX_APLIST1", "");

+

+	if (scan_result_str_len > 0 && scan_result_str_len < WIFI_STATION_SCAN_RESULT_STR_LEN) {

+		scan_result_str[scan_result_str_len - 1] = '\0'; //È¥µô×îºóÒ»¸ö·ÖºÅ

+		cfg_set ("EX_APLIST", scan_result_str);

+	}//klocwork

+	if (scan_result_str_len1 > 0 && scan_result_str_len1 < WIFI_STATION_SCAN_RESULT_STR_LEN) {

+		scan_result_str1[scan_result_str_len1 - 1] = '\0'; //È¥µô×îºóÒ»¸ö·ÖºÅ

+		cfg_set ("EX_APLIST1", scan_result_str1);

+	}

+

+	safe_free (scan_result_str);

+	safe_free (scan_result_str1);

+}

+

+

+static  void  ipfail_disconnect_ap()

+{

+	char cmd[WIFI_STATION_CMD_LEN] = {0};

+	int spot_num = 0;

+	int i = 0;

+

+	char wifi_profile_num[WIFI_STATION_PROFILE_NV_NAME_LEN] = {0};

+	cfg_get_item ("wifi_profile_num", wifi_profile_num, sizeof (wifi_profile_num));

+	spot_num = atoi (wifi_profile_num);

+

+	for (i = 0; i < spot_num; i++) {

+		if (g_spot_list_p[i]->network_id ==  g_linked_network_id) {

+			wf_log ("[SSID= %s] ip dhcp failed ,will be disabled, and set priority 0", g_spot_list_p[i]->ssid);

+			sprintf (cmd, "DISABLE_NETWORK %d", g_linked_network_id);

+			sta_docmd (cmd);

+

+			sprintf (cmd, "SET_NETWORK %d  priority 0", g_linked_network_id);

+			sta_docmd (cmd);

+			break;

+		}

+	}

+	wifi_station_connect (MODULE_ID_WIFI);

+// disable cmd will disconnect the ap , and  sta_disconnected will deal the process

+	// i guess wpa_supplicant will  connect other enabled  spot

+

+}

+

+

+static void handle_sim_init_status_timer()

+{

+	char sim_zpbic_status[WIFI_ZPBIC_STATUS_LEN] = {0};

+

+	if (g_send_count != g_pre_send_count) {

+		wf_log ("g_send_count is %d -----g_pre_send_count is %d", g_send_count, g_pre_send_count);

+		return;

+	}

+	cfg_get_item ("sim_zpbic_status", sim_zpbic_status, sizeof (sim_zpbic_status));

+	if (strcmp (sim_zpbic_status,  SIMCARD_INIT_NO_CARD) == 0) {

+		//ɾ³ýsim init ״̬¶¨Ê±Æ÷

+		wf_log ("sim_zpbic_status is fail");

+		// g_timer_sim_init_undefined_status_count = 0;

+		//DeleteSoftTimer(WIFI_STATION_TIMER_SIM_CARD_STATUS);

+		wifi_station_connect (MODULE_ID_WIFI);

+

+		return;

+	} else if (strcmp (sim_zpbic_status,  SIMCARD_INIT_UNDEFINED) == 0) {

+//      printf(" handle_sim_init_status_timer in g_timer_sim_init_undefined_status_count is %d", //g_timer_sim_init_undefined_status_count);

+#if 0

+		if (g_timer_sim_init_undefined_status_count >= 4) {

+			//ɾ³ýsim init ״̬¶¨Ê±Æ÷

+			//printf(" handle_sim_init_status_timer g_timer_sim_init_undefined_status_count is %d", //g_timer_sim_init_undefined_status_count);

+			//g_timer_sim_init_undefined_status_count = 0;

+			DeleteSoftTimer (WIFI_STATION_TIMER_SIM_CARD_STATUS);

+			wlan_station_msg_handle_ex();

+			return;

+		}

+		//g_timer_sim_init_undefined_status_count++;

+#endif

+		CreateSoftTimer (WIFI_STATION_TIMER_SIM_CARD_STATUS,

+		                 TIMER_FLAG_ONCE, WIFI_STATION_TIMER_SIM_CARD_STATUS_INTERVAL,

+		                 wifi_station_query_sim_card_status, NULL);

+	} else if (strcmp (sim_zpbic_status,  SIMCARD_INIT_SUCCESS) == 0) {

+		wf_log (" success");

+

+		//wlan_station_msg_handle_connect();

+		wifi_station_connect (MODULE_ID_WIFI);

+	} else {

+		wf_log ("unknow");

+

+		wifi_station_connect (MODULE_ID_WIFI);

+

+	}

+}

+

+

+static void wpa_supplicant_scan (void)

+{

+	sta_docmd ("SCAN");

+}

+

+static void wpa_supplicant_get_scan_result (vector_t* v)

+{

+	char *reply = NULL;

+

+	if (v == NULL) {

+		return;

+	}

+

+	//»ñȡɨÃè½á¹û

+	wf_log ("wlan-station get_scan_result");

+//    exec_script(WPA_CLI" scan_results", v);

+	reply = sta_docmd ("SCAN_RESULTS");

+

+//   wf_log("[scan] scan results:\n %s" , reply);

+	convert2vector (reply, v);

+}

+

+

+static void *wifi_station_query_sim_card_status(void* arg)

+{

+	//wlan_station_send_message(MODULE_ID_WIFI, MSG_CMD_WIFI_STATION_SIM_INIT_TIMER_PROCESS, 0, NULL);

+	ipc_send_message (MODULE_ID_WIFI, MODULE_ID_WIFI, MSG_CMD_WIFI_STATION_SIM_INIT_TIMER_PROCESS, 0, NULL, 0);

+	return NULL;

+}

+

+static void wifi_station_scan (void)

+{

+	char wifi_sta_connection[WIFI_CONNECTION_LEN] = {0};

+	char sta_ip_status[WIFI_STATION_IP_STATUS_LEN] = {0};

+

+	cfg_get_item ("wifi_sta_connection", wifi_sta_connection, sizeof (wifi_sta_connection));

+

+

+	wf_log ("wifi_station_scan");

+	//¹¦ÄܹرÕÔòÖ±½ÓÍ˳ö

+	if (strcmp (wifi_sta_connection, "1") != 0) {

+		return;

+	}

+

+	//ÕýÔÚÁ¬½Ó״̬ÔòÍ˳ö

+	cfg_get_item ("sta_ip_status", sta_ip_status, sizeof (sta_ip_status));

+	if (strcmp (sta_ip_status, WIFI_STATION_IP_STATUS_CONNECTING) == 0 ||

+		strcmp (sta_ip_status, WIFI_STATION_IP_STATUS_DHCPING) == 0) {

+		wf_log ("sta_ip_status=connecting,set scan_finish=2========");

+		cfg_set ("scan_finish", "2"); //Ä¿µÄÊǸæËßwebui£¬´Ëʱµ×²ãÔÚconnecting

+		return;

+	}

+

+	//wpa_supplicant½ø³ÌûÆô¶¯ÔòÆô¶¯£¬ÊôÓÚÒì³£±£»¤

+	if (check_supplicant_alive() ==0) {

+		wf_log ("wpa supplicant is not running!xx");

+		cfg_set ("scan_finish", "2"); //Ä¿µÄÊǸæËßwebui£¬´Ëʱµ×²ã³öÎÊÌâÁË

+

+		return;

+	}

+//   cfg_set("scan_finish", "0");

+

+	//ɨÃè

+	wpa_supplicant_scan();

+

+}

+

+static void wifi_station_get_scan_results (void)

+{

+	vector_t *v = NULL;

+	char wifi_sta_connection[WIFI_CONNECTION_LEN] = {0};

+	char sta_ip_status[WIFI_STATION_IP_STATUS_LEN] = {0};

+	cfg_get_item ("wifi_sta_connection", wifi_sta_connection, sizeof (wifi_sta_connection));

+

+	wf_log ("wifi_station_get_scan_results");

+

+	//¹¦ÄܹرÕÔòÖ±½ÓÍ˳ö

+	if (strcmp (wifi_sta_connection, "1") != 0) {

+		wf_log ("wifi_sta_connection isn't 1,abormal!!!========");

+		return;

+	}

+

+	//ÕýÔÚÁ¬½Ó״̬ÔòÍ˳ö

+	cfg_get_item ("sta_ip_status", sta_ip_status, sizeof (sta_ip_status));

+	if (strcmp (sta_ip_status, WIFI_STATION_IP_STATUS_CONNECTING) == 0 ||

+		strcmp (sta_ip_status, WIFI_STATION_IP_STATUS_DHCPING) == 0) {

+		wf_log ("sta_ip_status=connecting,set scan_finish=2========");

+		cfg_set ("scan_finish", "2"); //Ä¿µÄÊǸæËßwebui£¬´Ëʱµ×²ãÔÚconnecting

+		return;

+	}

+

+	//wpa_supplicant½ø³ÌûÆô¶¯ÔòÆô¶¯£¬ÊôÓÚÒì³£±£»¤

+	if (check_supplicant_alive() ==0) {

+		wf_log ("detect wpa_supplicant isnot running========");

+		cfg_set ("scan_finish", "2"); //Ä¿µÄÊǸæËßwebui£¬´Ëʱµ×²ã³öÎÊÌâÁË

+		return;

+	}

+

+	v = vector_init();

+	wf_log ("starting scan result");

+

+	//»ñȡɨÃè½á¹û

+	wpa_supplicant_get_scan_result (v);

+

+	//´¦ÀíɨÃè½á¹û

+	handle_scan_result (v);

+

+	cfg_set ("scan_finish", "1");

+

+	wf_log ("set scan finish 1");

+

+	vector_free (v);

+}

+

+static void wifi_station_open_apsta(void)

+{

+	wf_log ("restart apsta");

+	basic_deal_all (WIFI_CFG_RESTART_APSTATION); //ÐèÒª½«µ¥¶ÀAPģʽÇл»Îªapsta ģʽ

+}

+

+static void sta_enable_all_networks (void)

+{

+	wf_log (" webui_select_network= %d, g_disable_other_network=%d ",

+	        webui_select_network, g_disable_other_network);

+

+#if 0

+	//  µ¥¶À´¦Àíwebui ÔÚÁ´½Ó״̬£¬Ñ¡ÔñÆäËûÈÈµã½øÐÐÁ´½ÓÇé¿ö

+	if (webui_select_network == 1) {

+		webui_select_network = 0;   // ½ö½öΪÁ˱ÜÃâselectÃüÁîÒýÆðµÄÉϸöÈȵãµÄ¶Ï¿ªÊ¼þ

+		return;

+	}

+#endif

+

+	if (g_disable_other_network == 1) {

+		cfg_set ("sta_ip_status", WIFI_STATION_IP_STATUS_CONNECTING);

+		sta_docmd ("ENABLE_NETWORK all");

+		// reconnect ,  willl connect last one ???

+		sta_docmd ("RECONNECT");

+		//has_exec_select_network =0;

+		g_disable_other_network = 0;  // select  will disable others networks, so enable all , then reset it

+	}

+}

+

+static void sta_disconnected (void)

+{

+	char sta_ip_status[WIFI_STATION_IP_STATUS_LEN] = {0};

+

+	cfg_get_item ("sta_ip_status", sta_ip_status, sizeof (sta_ip_status));

+

+	if (strcmp (sta_ip_status, "disconnect") != 0) { // ÓпÉÄÜÊǹرÕapsta£¬ÒѾ­×öÁËdeinit£¬ËùÒÔÏÂÃæÁ÷³Ì¾Í²»ÐèÒªÁË

+		write_status (STASTATUS, "F");     //F ±íʾ ¶Ï¿ª×´Ì¬£¬0~4 ±íʾÐźÅÇ¿¶È 5¸ö¼¶±ð

+		//¸üÐÂEX_APLISTÖеÄÁ¬½Ó״̬Ϊ0

+		update_EX_APLIST_connect_status (FALSE);

+		//¸üÐÂÈȵãÁбíÖжÔÓ¦ÈȵãµÄÁ¬½Ó״̬Ϊfalse

+		update_spot_connect_status_by_status_result (FALSE);

+

+		network_down_up (FALSE);

+

+		g_linked_network_id_last = g_linked_network_id;

+

+		if (0 ==webui_select_network) {

+			cfg_set ("sta_ip_status", WIFI_STATION_IP_STATUS_DISCONNECT);

+		}else if(1 == webui_select_network){	

+			cfg_set ("sta_ip_status", WIFI_STATION_IP_STATUS_CONNECTING);

+			webui_select_network =0;

+		}

+

+	}

+}

+

+static void sta_disconnect (void)

+{

+	int i = 0;

+	int network_id = -1;

+	char cmd[WIFI_STATION_CMD_LEN] = {0};

+	int spot_num = 0;

+	char wifi_profile_num[WIFI_STATION_PROFILE_NV_NAME_LEN] = {0};

+

+	cfg_get_item ("wifi_profile_num", wifi_profile_num, sizeof (wifi_profile_num));

+	spot_num = atoi (wifi_profile_num);

+

+	dump_spot();

+	for (i = 0; i < spot_num; i++) {

+		if (NULL != g_spot_list_p[i] && g_spot_list_p[i]->connect_status == 1) {

+			network_id = g_spot_list_p[i]->network_id;

+			break;

+		}

+	}

+

+	if (network_id != -1) {

+		sprintf (cmd, "DISCONNECT");

+		sta_docmd (cmd);

+		has_exec_disconnect = 1;

+		//	sprintf(cmd, "DISABLE_NETWORK %d", network_id);

+		//	sta_docmd(cmd);

+	} else {

+		wf_log ("All SSID AP already  disconnect, do not disconnect again");

+	}

+}

+

+static void sta_connect (int network_id)

+{

+	int i = 0;

+//	int network_id = -1;

+	char cmd[WIFI_STATION_CMD_LEN] = {0};

+	int spot_num = 0;

+	char wifi_profile_num[WIFI_STATION_PROFILE_NV_NAME_LEN] = {0};

+	char ssid[WIFI_STATION_SSID_LEN] = {0};

+	char sta_ip_status[WIFI_STATION_IP_STATUS_LEN] = {0};

+	char manual_d_wifi[8]    = {0};

+	char blc_wan_mode[32]    = {0};

+

+	cfg_get_item ("wifi_profile_num", wifi_profile_num, sizeof (wifi_profile_num));

+	spot_num = atoi (wifi_profile_num);

+

+	cfg_get_item ("sta_ip_status", sta_ip_status, sizeof (sta_ip_status));

+	cfg_get_item ("manual_d_wifi", manual_d_wifi, sizeof (manual_d_wifi));

+	cfg_get_item ("blc_wan_mode", blc_wan_mode, sizeof (blc_wan_mode));

+

+	if ((strcmp (manual_d_wifi, "1") == 0) || (strcmp ("PPPOE", blc_wan_mode) == 0)) {

+		wf_log ("connect failed manual_d_wifi=%s,blc_wan_mode=%s",

+		        manual_d_wifi, blc_wan_mode);

+		return;

+	}

+

+	if (network_id == INVALID_NETWORK_ID) {

+		// set  sta_ip_status, for webui

+		cfg_get_item ("EX_SSID1", ssid, WIFI_STATION_SSID_LEN);

+		// cfg_get_item("EX_mac", mac, WIFI_STATION_MAC_LEN);

+

+		for (i = 0; i < spot_num; i++) {

+			wf_log ("g_spot_list_p[%d] = 0x%p", i , g_spot_list_p[i]);//cov m

+			if (g_spot_list_p[i] != NULL && !strcmp (g_spot_list_p[i]->ssid, ssid)) {

+

+//protect not to connect twice

+				if(1 == g_spot_list_p[i]->connect_status ){

+					wf_log ("[%s] is connect ,do not need connect again,[sta_ip_status=%s]", ssid, sta_ip_status);

+					return;

+				}

+				network_id = g_spot_list_p[i]->network_id;

+//select¶¯×÷»áÒýÆðÁ¬×ŵÄÈȵã¶Ï¿ª£¬¶Ï¿ªÊ±ºòÒª¼Ç¼´Ë¶¯×÷£¬²»ÐèÒªÔÙÈ¥enable all

+				if (strcmp (sta_ip_status, WIFI_STATION_IP_STATUS_CONNECT) == 0 )

+					webui_select_network = 1;

+				break;

+			}

+		}

+	}

+

+	if (network_id == -1) {

+		wf_log ("got the wrong network id");

+		cfg_set ("sta_ip_status", WIFI_STATION_IP_STATUS_DISCONNECT);

+		return;

+	} else {

+//		if(strcmp(sta_ip_status, WIFI_STATION_IP_STATUS_DISCONNECT) != 0)

+		{

+			sprintf (cmd, "SELECT_NETWORK %d", network_id);

+			sta_docmd (cmd);

+			g_disable_other_network = 1;

+		}

+		sprintf (cmd, "ENABLE_NETWORK %d", network_id);

+		sta_docmd (cmd);

+

+		sta_docmd ("SAVE_CONFIG");

+

+#if 0

+		if (has_exec_disconnect == 1) {

+			sta_docmd ("RECONNECT");

+			has_exec_disconnect = 0; //  reconnect will  reset  has_exec_disconnect

+		}

+#endif

+	}

+

+//	Create_connect_timeout_timer(); //´´½¨Á¬½Ó³¬Ê±¶¨Ê±Æ÷

+}

+

+static void do_dhcp (void)

+{

+	//Á¬½Ó³É¹¦£¬µ÷ÍøÂç×é½Ó¿Ú½øÐÐDHCPÁ÷³Ì·ÖÅäIPµØÖ·

+	network_down_up (TRUE);

+}

+

+/*

+

+µ±¶Ï¿ªÊ±ºò£¬¸üÐÂÈȵãÁ´½Ó״̬£¬g_linked_network_id »¹ÊǼǼµÄÁ´½ÓµÄÈȵã

+

+sta_ip_status ¼Ç¼µÄ״̬»¹ÊÇconnect ״̬

+*/

+static int  find_linked_ap_index(void)

+{

+	int spot_num = 0;

+	int i = 0;

+

+	char sta_ip_status[WIFI_STATION_IP_STATUS_LEN] = {0};

+

+	char wifi_profile_num[WIFI_STATION_PROFILE_NV_NAME_LEN] = {0};

+	cfg_get_item ("wifi_profile_num", wifi_profile_num, sizeof (wifi_profile_num));

+	cfg_get_item ("sta_ip_status", sta_ip_status, sizeof (sta_ip_status));

+

+	spot_num = atoi (wifi_profile_num);

+

+	if (-1 == g_linked_network_id)  return -1;

+

+	for (i = 0; i < spot_num; i++) {

+		if (g_spot_list_p[i]->network_id == g_linked_network_id) {

+			wf_log ("find_linked_ap_index = %d", i); //  Ò»°ã ¶¼ÊÇ0£¬µ±ÓÐÔËÓªÉÌÈȵãʱºò¿ÉÄܲ»ÊÇ0

+			return i;

+		}

+	}

+

+	return  -1;

+

+}

+

+static void disable_network (char * ssid)

+{

+	char cmd[WIFI_STATION_CMD_LEN] = {0};

+	int spot_num = 0;

+	int i = 0;

+

+	char wifi_profile_num[WIFI_STATION_PROFILE_NV_NAME_LEN] = {0};

+	cfg_get_item ("wifi_profile_num", wifi_profile_num, sizeof (wifi_profile_num));

+

+	spot_num = atoi (wifi_profile_num);

+

+	for (i = 0; i < spot_num; i++) {

+		if (strcmp (g_spot_list_p[i]->ssid, ssid) == 0) {

+			if (-1 != g_spot_list_p[i]->network_id) {

+				sprintf (cmd, "DISABLE_NETWORK %d", g_spot_list_p[i]->network_id);

+				sta_docmd (cmd);

+				sta_docmd ("SAVE_CONFIG");

+				break;

+			} else {

+				wf_log ("Error !! ssid =%s, networkid = %d\n ", g_spot_list_p[i]->ssid, g_spot_list_p[i]->network_id);

+			}

+		}

+	}

+}

+

+static void  update_current_EX (char * ssid, char * mac)

+{

+	char buf[WIFI_STATION_SPOT_KEY_ID_LEN] = {0};

+	int spot_num = 0;

+	int i = 0;

+

+	char wifi_profile_num[WIFI_STATION_PROFILE_NV_NAME_LEN] = {0};

+	cfg_get_item ("wifi_profile_num", wifi_profile_num, sizeof (wifi_profile_num));

+

+	spot_num = atoi (wifi_profile_num);

+

+	for (i = 0; i < spot_num; i++) {

+		if (strcmp (g_spot_list_p[i]->ssid, ssid) == 0) {

+			cfg_set ("EX_wifi_profile", g_spot_list_p[i]->profile_name);

+			cfg_set ("EX_SSID1", ssid);

+			cfg_set ("EX_AuthMode", g_spot_list_p[i]->auth_mode);

+			cfg_set ("EX_EncrypType", g_spot_list_p[i]->encrypt_type);

+

+			sprintf (buf, "%d", g_spot_list_p[i]->keyID);

+			cfg_set ("EX_DefaultKeyID", buf);

+

+			cfg_set ("EX_WPAPSK1", g_spot_list_p[i]->password);

+			cfg_set ("EX_WEPKEY", g_spot_list_p[i]->password);

+			cfg_set ("EX_mac", mac);

+			break;

+		}

+	}

+}

+

+static void disable_other_network (int  network_id)

+{

+

+	char cmd[WIFI_STATION_CMD_LEN] = {0};

+	int spot_num = 0;

+	int i = 0;

+

+	char wifi_profile_num[WIFI_STATION_PROFILE_NV_NAME_LEN] = {0};

+	cfg_get_item ("wifi_profile_num", wifi_profile_num, sizeof (wifi_profile_num));

+

+	spot_num = atoi (wifi_profile_num);

+	if (spot_num > WIFI_STATION_SPOT_LIST_NUM || spot_num < 0)

+		return;

+

+	for (i = 0; i < spot_num; i++) {

+		if (g_spot_list_p[i]->network_id == network_id) {

+			continue;

+		}

+

+		sprintf (cmd, "DISABLE_NETWORK %d", g_spot_list_p[i]->network_id);

+		sta_docmd (cmd);

+	}

+

+	g_disable_other_network =  1;

+

+}

+

+static void sta_connected()

+{

+	char cmd[WIFI_STATION_CMD_LEN] = {0};

+

+	write_status (STASTATUS, "4"); //F ±íʾ ¶Ï¿ª×´Ì¬£¬0~4 ±íʾÐźÅÇ¿¶È 5¸ö¼¶±ð ÔÝʱÐźÅдÂú¸ñ

+

+	//¸üÐÂÈȵãÁбíÖжÔÓ¦ÈȵãµÄÁ¬½Ó״̬Ϊtrue

+	update_spot_connect_status_by_status_result (TRUE);

+

+	//¸üÐÂËùÓÐÈȵãÁбíÖеÄis_tried_connectΪfalse

+	//update_spot_list_is_tried_connect(FALSE);

+

+	resort_spot_list();

+

+	//¸üÐÂEX_APLISTÖеÄÁ¬½Ó״̬Ϊ1

+	update_EX_APLIST_connect_status (TRUE);

+

+	// set the success AP to EX_SSID1

+	// update_current_EX();

+

+	cfg_set ("sta_ip_status", WIFI_STATION_IP_STATUS_CONNECT);

+//	Delete_connect_timeout_timer();

+

+	wf_log ("g_linked_network_id_last = %d, g_linked_network_id= %d", g_linked_network_id_last, g_linked_network_id);

+

+// ²»ÊÇÎÞЧid£¬ÇÒÉÏÒ»¸öÁ´½ÓµÄºÍÕâ´ÎÁ´½ÓµÄ²»ÊÇͬһ¸öÈȵã

+	if (g_linked_network_id_last  !=  -1   &&  g_linked_network_id_last  != g_linked_network_id) { // thr first time,  there's no the last id

+		sprintf (cmd, "SET_NETWORK %d priority 2", g_linked_network_id_last);

+		sta_docmd (cmd);

+	}

+	sprintf (cmd, "SET_NETWORK %d priority 3", g_linked_network_id);

+	sta_docmd (cmd);

+

+	wf_log ("g_disable_other_network= %d", g_disable_other_network);

+

+//Èç¹û²»ÊÇselect ÃüÁîÖ®ºóÍê³ÉµÄÁ´½Ó£¬¾Í²»»ádisableÆäËûÈȵ㣬Ӧ¸ÃÊÇwpa_supplicant ÔÚenable allºó×ÔÐÐÑ¡ÔñÈÈµã½øÐÐÁ´½Ó

+	if (g_disable_other_network == 0) {

+		disable_other_network (g_linked_network_id);

+		//	g_disable_other_network =1;

+	}

+

+	sta_docmd ("SAVE_CONFIG");

+

+}

+

+static void update_eapsim_spot(void)

+{

+	int i = 0;

+	int spot_num = 0;

+	char wifi_profile_num[WIFI_STATION_PROFILE_NV_NAME_LEN] = {0};

+	char cmd[WIFI_STATION_CMD_LEN] = {0};

+

+	cfg_get_item ("wifi_profile_num", wifi_profile_num, sizeof (wifi_profile_num));

+	spot_num = atoi (wifi_profile_num);

+	if (spot_num > WIFI_STATION_SPOT_LIST_NUM || spot_num < 0)

+		return;

+

+	for (i = 0; i < spot_num; i++) {

+		if (strstr (g_spot_list_p[i]->auth_mode, WIFI_STATION_PROFILE_AUTH_WPA_EAP)) { //|| strstr(auth_mode, WIFI_STATION_PROFILE_AUTH_WPA2_EAP))

+			if (g_cardmode == CARD_MODE_USIM) {

+				sprintf (cmd, "SET_NETWORK %d eap AKA", g_spot_list_p[i]->network_id);

+				sta_docmd (cmd);

+			} else {

+				sprintf (cmd, " SET_NETWORK %d eap SIM", g_spot_list_p[i]->network_id);

+				sta_docmd (cmd);

+			}

+		}

+	}

+}

+

+/*

+  * just enable all networks let supplicant to connect automaticly

+  */

+static int wifi_station_connect (int from_where)

+{

+	char wifi_profile_num[8] = {0};

+	char manual_d_wifi[8]    = {0};

+	char wifi_cur_state[8]   = {0};

+	char blc_wan_mode[16]    = {0};

+

+	wf_log ("enter from %d blc_close_apsta= %d", from_where, g_blc_send_close_apsta);

+

+	if (g_blc_send_close_apsta == 1) {

+		wf_log ("blc send close wifi,so only blc can open wifi again.");

+		return -1;

+	}

+

+	//Èç¹ûûÓпÉÒÔÓõÄÈȵ㣬ֱ½Ó·µ»ØÊ§°Ü

+	cfg_get_item ("wifi_profile_num", wifi_profile_num, sizeof (wifi_profile_num));

+	cfg_get_item ("manual_d_wifi", manual_d_wifi, sizeof (manual_d_wifi));

+	cfg_get_item ("blc_wan_mode", blc_wan_mode, sizeof (blc_wan_mode));

+	cfg_get_item ("wifi_cur_state", wifi_cur_state, sizeof (wifi_cur_state));

+

+	//ÊÖ¶¯¶Ï¿ªwifi£¬¼´Ê¹Ö÷¿ØÔÙÈÃÁ¬½Ó£¬Ò²²»»áÔÙÁ¬½ÓÁË

+	if ( (strcmp (wifi_cur_state, WIFI_CLOSED) == 0) || (strcmp (wifi_profile_num, "0") == 0)

+	     || (strcmp (manual_d_wifi, "1") == 0) || (strcmp ("PPPOE", blc_wan_mode) == 0)) {

+		wf_log ("connect failed wifi_cur_state=%s, wifi_profile_num=%s,manual_d_wifi=%s,blc_wan_mode=%s",

+		        wifi_cur_state, wifi_profile_num, manual_d_wifi, blc_wan_mode);

+		return -1;

+	}

+

+	sta_enable_all_networks();

+//	Create_connect_timeout_timer(); //´´½¨Á¬½Ó³¬Ê±¶¨Ê±Æ÷

+	return 0;

+}

+

+static void wifi_station_nv_init (void)

+{

+	cfg_set ("sta_ip_status", WIFI_STATION_IP_STATUS_DISCONNECT);

+	cfg_set ("scan_finish", "0");

+	//cfg_set("EX_APLIST", "");

+	//cfg_set("EX_APLIST1", "");

+	cfg_set ("manual_d_wifi", "0");

+

+	memset (g_linked_ap_mac, 0, WIFI_STATION_MAC_LEN);

+	g_linked_network_id = -1;

+	g_linked_network_id_last = -1;

+

+	has_exec_disconnect = 0;

+	webui_select_network = 0;

+	g_disable_other_network = 1;

+

+	get_spot_list();

+	sync_nv_spot_list_conf_file();

+	update_spot_list_signal_connect_status (0, 0);

+	save_spot_list();

+}

+

+static int exist_eap_simaka_spot()

+{

+	int i = 0;

+	int spot_num = 0;

+	char wifi_profile_num[WIFI_STATION_PROFILE_NV_NAME_LEN] = {0};

+

+	cfg_get_item ("wifi_profile_num", wifi_profile_num, sizeof (wifi_profile_num));

+	spot_num = atoi (wifi_profile_num);

+

+	for (i = 0; i < spot_num; i++) {

+		if (strstr (g_spot_list_p[i]->auth_mode, WIFI_STATION_PROFILE_AUTH_WPA_EAP)) //|| strstr(auth_mode, WIFI_STATION_PROFILE_AUTH_WPA2_EAP))

+			return  g_spot_list_p[i]->network_id;

+	}

+	return -1;

+}

+

+

+void wlan_station_init (void)

+{

+	if(1 == g_wpa_supplicant)return ;

+

+	wf_log ("time=%d", time(NULL));

+	if (sta_manager->start_supplicant(sta_manager) == 0) {

+		wf_log ("time=%d", time(NULL));

+		wf_log (" wpa_supplicant run success");

+		

+		if (0 == wifi_connect_to_supplicant(&sta_manager->sock)) {

+			wf_log (" socket connect success");

+			sem_post (&g_wpa_supplicant_id);

+			g_wpa_supplicant = 1;	

+		} else {

+			wlan_station_deinit();

+			return;

+		}

+	}else {

+		wf_log ("wpa_supplicant start failed");

+		wlan_station_deinit();

+		return;

+	}

+

+	

+	wifi_station_nv_init();

+	sta_docmd ("SCAN_INTERVAL 15");

+

+	//Èç¹ûÓÐEAP-SIMÈȵ㣬ÔòÐèÒªÏÈ×߸òéѯSIM¿¨ÐÅÏ¢Á÷³Ì

+

+	if (-1 != exist_eap_simaka_spot()) { // ²»ÊÇ-1£¬ Ôò´æÔÚsimaka spot

+		//eap send msg for card type

+		/*if((0 == strcmp(ssid, "CMCC-SIM-test1")) || (0 == strcmp(ssid, "CMCC-SIM-test2")))

+			{

+			strcpy(auth_mode, WIFI_STATION_PROFILE_AUTH_WPA_EAP);

+			}*/

+

+		//if(0 == wlan_station_send_message(ZUFI_MODULE_ID_AT_MAIN, MODULE_ID_CARD_MODE_REQ, 0, NULL))

+		if (0 == ipc_send_message (MODULE_ID_WIFI, MODULE_ID_AT_CTL, MSG_CMD_CARD_MODE_REQ, 0, NULL, 0)) {

+			//·¢ËÍ ²éѯ¿¨Ä£Ê½ÏûÏ¢£¬µÈ´ýÒì²½·µ»Ø

+			g_pre_send_count = g_send_count;

+			return;

+		} else {

+			wifi_station_connect (MODULE_ID_WIFI);

+		}

+	} else {

+		wifi_station_connect (MODULE_ID_WIFI);

+	}

+}

+

+static void clear_conf_file(void)

+{

+	sta_docmd ("REMOVE_NETWORK all");

+	sta_docmd ("SAVE_CONFIG");

+}

+

+static void clear_spot_list(void)

+{

+	int i = 0;

+	wf_log ("[clear_spot_list]");

+

+	for (i = 0; i < WIFI_STATION_SPOT_LIST_NUM; i++) {

+		if (g_spot_list_p[i] != NULL) {

+			safe_free (g_spot_list_p[i]);

+		}

+

+	}

+

+}

+static void wlan_station_deinit(void)

+{

+	int count = 50;

+

+	wf_log ("enter");

+

+	sta_docmd ("DISABLE_NETWORK all");

+	sta_docmd ("SAVE_CONFIG");

+#if !defined(__REALTEK_8192_CHIP__)	

+	sta_docmd ("TERMINATE");

+	usleep (150000);

+

+	while (count-- > 0) {

+		if (check_alive(&sta_manager->sock) == 0) {

+			wf_log ("TERMINATE over\n");

+			break;

+		}

+		usleep (100000);

+	}

+#endif

+

+	g_disable_other_network  = 1;

+	sta_manager->close_connection(sta_manager);

+

+	g_wpa_supplicant = 0;

+

+	clear_spot_list();

+	memset (g_linked_ap_mac, 0, WIFI_STATION_MAC_LEN);

+	g_linked_network_id = -1;

+	g_linked_network_id_last = -1;

+	has_exec_disconnect = 0;

+	webui_select_network = 0;

+	cfg_set ("scan_finish", "0");

+	cfg_set ("EX_APLIST", "");

+	cfg_set ("EX_APLIST1", "");

+

+	cfg_set ("sta_ip_status", WIFI_STATION_IP_STATUS_DISCONNECT);

+

+}

+

+

+void wifi_station_close()

+{

+	sta_disconnected();

+	wlan_station_deinit();

+}

+

+

+BOOL wlan_station_is_station_msg (unsigned short msg)

+{

+	if (msg >= MSG_CMD_WIFI_STATION_OPEN &&  msg <= MSG_CMD_WIFI_STATION_END) {

+		return TRUE;

+	} else if(msg == MSG_CMD_NET_WAN_DIAL_FAIL ||

+				msg == MSG_CMD_CARD_MODE_RSP ||

+				msg == MSG_CMD_PIN_STATUS_RSP){

+		return TRUE;

+	}

+	else{

+		return FALSE;

+	}

+}

+

+static void wlan_station_msg_handle_card_mode_for_eap (MSG_BUF *pMsg)

+{

+#if 0

+	spot_t *p = NULL;

+	char      profile_name[WIFI_STATION_SPOT_PROFILE_NAME_LEN] = {0};

+	char      *ssid = NULL;

+	char      auth_mode[WIFI_STATION_AUTH_MODE_LEN] = {0};

+	char      encrypt_type[WIFI_STATION_ENCRYPT_TYPE_LEN] = {0};

+	char      *password_wpa = NULL;

+	char      *password_wep = NULL;

+#endif

+	char       cardmodestr[WIFI_CARD_MODE_LEN] = {0};

+	int        cardmode = 0;

+

+	if (g_send_count != g_pre_send_count) {

+		wf_log ("------------wlan_station_msg_handle_card_mode-----g_send_count is %d -----g_pre_send_count is %d", g_send_count, g_pre_send_count);

+		return;

+	}

+	wf_log ("------------wlan_station_msg_handle_card_mode------------++++++++++++++++++++++++++++++");

+	if (pMsg != NULL) {

+		//kw 3

+		memcpy (cardmodestr, pMsg->aucDataBuf, WIFI_CARD_MODE_LEN);

+

+		wf_log ("------------wlan_station_msg_handle_card_mode--------333----++++++++++++++++++++++++++++++");

+		cardmode = atoi (cardmodestr);

+		wf_log ("------------wlan_station_msg_handle_card_mode--------cardmode is %d----++++++++++++++++++++++++++++++", cardmode);

+		if (cardmode < 0 || cardmode > INT_MAX-1) //kw 3, cardmode 0-2

+			cardmode = 0;

+	}

+

+	g_cardmode = cardmode;

+

+	if (cardmode != CARD_MODE_USIM && cardmode != CARD_MODE_SIM) {

+		wifi_station_connect (MODULE_ID_WIFI);

+	} else {

+		//eap send msg for pin status

+		if (0 == ipc_send_message (MODULE_ID_WIFI, MODULE_ID_AT_CTL, MSG_CMD_PIN_STATUS_REQ, 0, NULL, 0)) {

+			wf_log ("------------ipc_send_message-------MSG_CMD_PIN_STATUSREQ-----++++++++++++++++++++++++++++++");

+			g_pre_send_count = g_send_count;

+			return;

+		} else {

+			wf_log ("------------ipc_send_message-------MODULE_ID_PIN_STATUS_REQ--ex---++++++++++++++++++++++++++++++");

+			wifi_station_connect (MODULE_ID_WIFI);

+

+		}

+

+		//wlan_station_msg_handle_connect();

+	}

+}

+

+static void wlan_station_msg_handle_pin_status_for_eap (MSG_BUF *pMsg)

+{

+	char pinstatusstr[WIFI_PIN_STATUS_LEN] = {0};

+	int pinstatus = 0;

+	char sim_zpbic_status[WIFI_ZPBIC_STATUS_LEN] = {0};

+

+	if (g_send_count != g_pre_send_count) {

+		wf_log ("------------wlan_station_msg_handle_pin_status_for_eap-----g_send_count is %d -----g_pre_send_count is %d", g_send_count, g_pre_send_count);

+		return;

+	}

+	wf_log ("------------wlan_station_msg_handle_pin_status_for_eap------------++++++++++++++++++++++++++++++");

+	if (pMsg != NULL) {

+		//kw 3

+		memcpy (pinstatusstr, pMsg->aucDataBuf, WIFI_PIN_STATUS_LEN);

+

+		pinstatus = atoi (pinstatusstr);

+

+		if (PIN_STATUS_NO_PIN != pinstatus) {

+			wifi_station_connect (MODULE_ID_WIFI);

+

+		} else {

+			//Ôö¼Ó¶Ô¿¨³õʼ»¯ÊÇ·ñÍê³ÉµÄÅжÏ

+			cfg_get_item ("sim_zpbic_status", sim_zpbic_status, sizeof (sim_zpbic_status));

+			if (0 == strcmp (sim_zpbic_status, SIMCARD_INIT_SUCCESS)) {

+				wf_log ("--------------------sim_zpbic_status-----SIMCARD_INIT_SUCCESS ++++++++++++++-------------");

+				update_eapsim_spot();

+				//   wlan_station_msg_handle_connect();

+				wifi_station_connect (MODULE_ID_WIFI);

+			} else if (0 == strcmp (sim_zpbic_status, SIMCARD_INIT_UNDEFINED)) {

+				wf_log ("--------------------sim_zpbic_status-----SIMCARD_INIT_UNDEFINED ++++++++++++++-------------");

+				//g_timer_sim_init_undefined_status_count = 0;

+				g_pre_send_count = g_send_count;

+				//δÍê³É¿¨ÎļþµÄ³õʼ»¯ÎÞ·¨½øÐÐeapÈÏÖ¤£¬ÐèÒª´´½¨¶¨Ê±Æ÷ÂÖѯsim¿¨³õʼ»¯×´Ì¬

+				CreateSoftTimer (WIFI_STATION_TIMER_SIM_CARD_STATUS,

+				                 TIMER_FLAG_ONCE, WIFI_STATION_TIMER_SIM_CARD_STATUS_INTERVAL,

+				                 wifi_station_query_sim_card_status, NULL);

+			} else {

+				wf_log ("--------------------sim_zpbic_status-----wlan_station_msg_handle_ex ++++++++++++++-------------");

+				wifi_station_connect (MODULE_ID_WIFI);

+			}

+		}

+	}

+}

+

+//wifi station´¦Àíº¯Êý

+int  wlan_sta_parse_msg (MSG_BUF *pMsg)

+{

+	

+	int ret =  0;

+	switch (pMsg->usMsgCmd) {

+	case MSG_CMD_WIFI_STATION_OPEN: {

+#if defined(__REALTEK_8192_CHIP__) || defined(__AIC_8800DW_CHIP__)

+		wifi_station_open_apsta();

+		//wifi_station_connect(MODULE_ID_WEB_CGI);//´ò¿ªµÄʱºòÒѾ­Á¬ÁËÒ»´Î£¬Ã»ÓбØÒªÔÙ´ÎÁ¬½Ó

+#else

+		wf_log("-MSG_CMD_WIFI_STATION_OPEN-");

+		wlan_station_init();

+#endif

+		break;

+	}

+	case MSG_CMD_WIFI_STATION_CLOSE: {

+		sta_disconnected();

+		wlan_station_deinit();

+#if defined(__REALTEK_8192_CHIP__)|| defined(__AIC_8800DW_CHIP__)

+		basic_deal_all (WIFI_CFG_RESTART_AP);

+#endif

+		break;

+	}

+	case MSG_CMD_WIFI_STATION_CLOSE_OPEN_MSSID: {

+		sta_disconnected();

+		wlan_station_deinit();

+		basic_deal_all (WIFI_CFG_CLOSESTA_OPENMSSID);

+		break;

+	}

+	case MSG_CMD_WIFI_STATION_SPOT_UPDATE: {

+		webui_update_spot_list ( (updateinfo_t*) (pMsg->aucDataBuf));

+

+		//ÿ´ÎÓû§¸üÐÂÈȵãºó£¬²»ÐèÒª¸üб£´æsignalµÄÈ«¾Ö±äÁ¿£¬¶øÊÇÔÚɨÃèµÄʱºò£¬À´¼ì²âÊÇ·ñÓб仯

+		//ËùÒÔÔÚÈȵã±ä»¯ºó£¬ÐèҪͨ¹ýscanÀ´¾¡¿ì¸üÐÂÈȵã״̬

+		break;

+	}

+	case MSG_CMD_WIFI_STATION_SCAN: {

+		wifi_station_scan();

+		break;

+	}

+	case MSG_CMD_WIFI_STATION_CONNECT: {

+		sta_connect (INVALID_NETWORK_ID);

+		break;

+	}

+	case MSG_CMD_WIFI_STATION_DISCONNECT: {

+		sta_disconnect();

+		break;

+	}

+	case MSG_CMD_WIFI_STATION_GET_SCAN_RESULTS: {

+		wifi_station_get_scan_results();

+		break;

+	}

+	case MSG_CMD_WIFI_STATION_SIM_INIT_TIMER_PROCESS: {

+		handle_sim_init_status_timer();

+		break;

+	}

+	case MSG_CMD_WIFI_STATION_EVENT_CONNECTED: {

+		wf_log ("[wifi event connected , goto dhcp]");

+		cfg_set ("sta_ip_status", "dhcping");

+		do_dhcp();

+		break;

+	}

+	case MSG_CMD_WIFI_STATION_EVENT_DISCONNECTED: {

+		char  sta_ip_status[WIFI_STATION_IP_STATUS_LEN] = {0};

+		cfg_get_item ("sta_ip_status", sta_ip_status, sizeof (sta_ip_status));

+

+		if (strcmp (sta_ip_status, "connect") == 0 || strcmp (sta_ip_status, "dhcping") == 0) {

+			sta_disconnected();

+		}

+		else{

+			wf_log ("The Spot connect failed, just set sta_ip_status  disconnect");

+			cfg_set ("sta_ip_status", "disconnect");

+		}

+		break;

+	}

+	case MSG_CMD_WIFI_STATION_EVENT_CONNECTING: {

+		cfg_set("sta_ip_status", WIFI_STATION_IP_STATUS_CONNECTING);

+		break;

+	}

+

+	case MSG_CMD_BLC_OPEN_WIFISTATION_ACCESS: { //  you can connect

+		char sta_ip_status[WIFI_STATION_IP_STATUS_LEN] = {0};

+

+		g_blc_send_close_apsta = 0;

+		cfg_get_item ("sta_ip_status", sta_ip_status, sizeof (sta_ip_status));

+

+		wf_log ("sta_ip_status=%s", sta_ip_status);

+

+		if (strcmp (sta_ip_status, WIFI_STATION_IP_STATUS_DISCONNECT) == 0) {

+			wifi_station_connect (MODULE_ID_MAIN_CTRL);

+		} else {

+			wf_log ("do not deal connect cmd, sta_ip_status=%s", sta_ip_status);

+		}

+		break;

+	}

+	case MSG_CMD_BLC_CLOSE_WIFISTATION_ACCESS: {

+		char sta_ip_status[WIFI_STATION_IP_STATUS_LEN] = {0};

+

+		g_blc_send_close_apsta = 1;

+		cfg_get_item ("sta_ip_status", sta_ip_status, sizeof (sta_ip_status));

+		if (strcmp (sta_ip_status, WIFI_STATION_IP_STATUS_DISCONNECT) != 0) {

+			sta_disconnect();//  if wifi not connect ok , then if there is disconnect event??

+		} else {

+			wf_log ("do not deal disconnect cmd, sta_ip_status=%s", sta_ip_status);

+

+		}

+		break;

+	}

+

+	case MSG_CMD_WIFI_STATION_BLC_CONNECTED: {

+		char sta_ip_status[WIFI_STATION_IP_STATUS_LEN] = {0};

+

+		cfg_get_item ("sta_ip_status", sta_ip_status, sizeof (sta_ip_status));

+		if (strcmp (sta_ip_status, WIFI_STATION_IP_STATUS_DHCPING) == 0) {

+			wf_log ("[wlan-station] wlan0-vxd get ip success");

+			sta_connected();

+		}

+		else{

+			wf_log (" DO not deal , sta_ip_status=%s", sta_ip_status);

+		}

+		break;

+	}

+

+	case MSG_CMD_NET_WAN_DIAL_FAIL: {

+		wf_log ("wlan0-vxd dhcp ip failed");

+		ipfail_disconnect_ap();

+		break;

+	}

+	case MSG_CMD_CARD_MODE_RSP: {

+		wlan_station_msg_handle_card_mode_for_eap (pMsg);

+		break;

+	}

+	case MSG_CMD_PIN_STATUS_RSP: {

+		wlan_station_msg_handle_pin_status_for_eap (pMsg);

+		break;

+	}

+	case MSG_CMD_WIFI_STATION_CONNECT_TIMEOUT: {

+		char sta_ip_status[WIFI_STATION_IP_STATUS_LEN] = {0};

+		cfg_get_item ("sta_ip_status", sta_ip_status, sizeof (sta_ip_status));

+		wf_log ("handle connect timeout msg,sta_ip_status=%s", sta_ip_status);

+		if (strcmp (sta_ip_status, WIFI_STATION_IP_STATUS_CONNECTING) == 0) {

+			sta_disconnect();

+			cfg_set ("sta_ip_status", WIFI_STATION_IP_STATUS_DISCONNECT);

+			g_connecting_time_out_timer = 0;

+		}

+		break;

+	}

+

+	case MSG_CMD_WIFI_STATION_NO_AVAILABLE_AP:{

+		char sta_ip_status[WIFI_STATION_IP_STATUS_LEN] = {0};

+		cfg_get_item ("sta_ip_status", sta_ip_status, sizeof (sta_ip_status));

+		wf_log ("handle no available ap, sta_ip_status=%s", sta_ip_status);

+		if (strcmp (sta_ip_status, WIFI_STATION_IP_STATUS_CONNECTING) == 0) {

+			cfg_set ("sta_ip_status", "disconnect");

+			if(1 == g_disable_other_network){

+				sta_docmd ("ENABLE_NETWORK all");//  the connecting status  will be set by assocating  event, if no assoc , just be disconnect

+				g_disable_other_network = 0;

+			}

+		}

+		break;

+	}

+	case MSG_CMD_WIFI_STATION_TEMP_DISABLED: {

+		if (g_wpa_supplicant == 1) {

+			//wf_log ("MSG_CMD_WIFI_STATION_TEMP_DISABLED=%s", (char *)(pMsg->aucDataBuf));

+			

+			cfg_set ("sta_ip_status", WIFI_STATION_IP_STATUS_DISCONNECT);

+			process_tmp_disabled((char *)(pMsg->aucDataBuf));

+		}

+		break;

+	}

+	case MSG_CMD_WIFI_STATION_FAILED_SET: {

+		char sta_ip_status[WIFI_STATION_IP_STATUS_LEN] = {0};

+		cfg_get_item ("sta_ip_status", sta_ip_status, sizeof (sta_ip_status));

+		wf_log ("handle Failed to set, sta_ip_status=%s", sta_ip_status);

+		if (strcmp (sta_ip_status, WIFI_STATION_IP_STATUS_CONNECTING) == 0) {

+			cfg_set ("sta_ip_status", "disconnect");

+			//if(1 == g_disable_other_network){

+			//	sta_docmd ("ENABLE_NETWORK all");//  the connecting status  will be set by assocating  event, if no assoc , just be disconnect

+			//	g_disable_other_network = 0;

+			//}

+		}

+		break;

+	}

+

+	default: {

+		ret = -1;

+		break;

+	}

+	}

+

+	return ret;

+}

+

+

+int  get_int_from_event (char * buf,  char * tag)

+{

+	int  ret = -1;

+	char * pstr = NULL;

+

+	if(NULL == buf || NULL == tag)

+		return -1;

+

+	pstr = strstr (buf, tag);

+	if (pstr != NULL)  {

+		pstr += strlen (tag);

+		ret = atoi (pstr);

+	}

+

+	return  ret;

+}

+

+/*

+ÃÀÀö¶³È˵ÄÁù³¯¹Å¶¼ÄÏhh, ÖÐÎÄssid»á±È½Ï³¤

+\xe7\xbe\x8e\xe4\xb8\xbd\xe5\x86\xbb\xe4\xba\xba\xe7\x9a\x84\xe5\x85\xad\xe6\x9c\x9d\xe5\x8f\xa4\xe9\x83\xbd\xe5\x8d\x97hh

+*/

+void process_trying_to_assoc (char * buf)

+{

+	char * start = NULL;

+	char * end = NULL;

+	char  ssid[WIFI_STATION_SSID_LEN] = {0};

+	char  mac[WIFI_STATION_MAC_LEN] = {0};

+	unsigned int len = 0;//klocwork

+

+	start = strstr (buf, "SSID=\'") + strlen("SSID=\'");

+	if (start != NULL) {

+		end = strstr (start, "\' ");//klocwork

+	}

+

+	strncpy (mac, buf + strlen ("Trying to associate with "), 17);

+	wf_log ("Trying to associate with  mac=%s", mac);

+	if (end != NULL && start != NULL) {

+		len = end - start;

+		len = MIN(len, WIFI_STATION_SSID_LEN-1);

+		//strncpy (ssid, start, len);

+		//ssid[WIFI_STATION_SSID_LEN-1] = '\0';//klocwork

+		snprintf(ssid,len+1,"%s",start);

+		wf_log ("Trying to associate with ssid= %s", ssid);

+	}

+

+	update_current_EX (ssid,  mac);

+

+}

+

+//Trying to associate with ca:c2:f1:74:2f:f4 (SSID='D_mi_D' freq=2412 MHz)

+//SME: Trying to authenticate with 90:1d:27:78:2c:1e (SSID='Ufi_782111' freq=2412 MHz)

+static void channel_follow(char * buf)

+{

+	char * start = NULL;

+	char * end = NULL;

+	char  freq[WIFI_STATION_FREQ_LEN] = {0};

+	unsigned int len = 0;//klocwork

+	int frequency = 0;

+

+	start = strstr(buf, "freq=") + strlen("freq=");

+	if (start != NULL) {

+		end = strstr (start, " MHz");//klocwork

+	}

+

+	if (end != NULL && start != NULL) {

+		len = end - start;

+		len = MIN(len, WIFI_STATION_FREQ_LEN-1);

+		snprintf(freq, len+1, "%s", start);

+		frequency = atoi(freq);

+		wf_log("Trying to associate with freq= %s[%d]", freq, frequency);

+

+		switch (frequency) {

+		case WIFI_STATION_CHANNEL1:

+			cfg_set("flower_channel", "1");

+			break;

+		case WIFI_STATION_CHANNEL2:

+			cfg_set("flower_channel", "2");

+			break;

+		case WIFI_STATION_CHANNEL3:

+			cfg_set("flower_channel", "3");

+			break;

+		case WIFI_STATION_CHANNEL4:

+			cfg_set("flower_channel", "4");

+			break;

+		case WIFI_STATION_CHANNEL5:

+			cfg_set("flower_channel", "5");

+			break;

+		case WIFI_STATION_CHANNEL6:

+			cfg_set("flower_channel", "6");

+			break;

+		case WIFI_STATION_CHANNEL7:

+			cfg_set("flower_channel", "7");

+			break;

+		case WIFI_STATION_CHANNEL8:

+			cfg_set("flower_channel", "8");

+			break;

+		case WIFI_STATION_CHANNEL9:

+			cfg_set("flower_channel", "9");

+			break;

+		case WIFI_STATION_CHANNEL10:

+			cfg_set("flower_channel", "10");

+			break;

+		case WIFI_STATION_CHANNEL11:

+			cfg_set("flower_channel", "11");

+			break;

+		case WIFI_STATION_CHANNEL12:

+			cfg_set("flower_channel", "12");

+			break;

+		case WIFI_STATION_CHANNEL13:

+			cfg_set("flower_channel", "13");

+			break;

+		default:

+			cfg_set("flower_channel", "0");

+			wf_log("channel_follow with unknow freq = [%d]", frequency);

+			break;

+		}

+	}

+	

+	ipc_send_message (MODULE_ID_WIFI, MODULE_ID_WIFI, MSG_CMD_WIFI_CHANNEL_FOLLOW, 0, NULL, 0);

+

+}

+

+/*

+STA: CTRL-EVENT-SSID-TEMP-DISABLED id=7 ssid="ydh" auth_failures=5 duration=60 reason=CONN_FAILED

+

+*/

+

+static void process_tmp_disabled (char *buf)

+{

+	char *p_WRONG_KEY   = NULL;

+//	char *p_AUTH_FAILED = NULL;

+//	char *p_CONN_FAILED = NULL;

+	char  wifi_profile_num[8] = {0};

+	char cmd[WIFI_STATION_CMD_LEN] = {0};

+	int network_id = -1;

+	int auth_failures = 0;

+

+	cfg_get_item ("wifi_profile_num", wifi_profile_num, sizeof (wifi_profile_num));

+	p_WRONG_KEY =  strstr (buf, "WRONG_KEY");

+//			p_AUTH_FAILED =  strstr(buf, "AUTH_FAILED");

+//			p_CONN_FAILED =  strstr(buf, "CONN_FAILED");

+

+	/*

+	¿ÉÒÔÓиüÓÅ»¯µÄËã·¨£¬Ìá¸ßÁ´½ÓЧÂÊ

+	*/

+	auth_failures = get_int_from_event (buf, "auth_failures=");

+

+	if (atoi (wifi_profile_num) > 1 && (p_WRONG_KEY || auth_failures > 1)) {

+		network_id = get_int_from_event (buf, "id=");

+

+		wf_log ("network_id = %d  wrong key  or tmp_disabled_times = %d",  network_id, auth_failures);

+

+		sprintf (cmd, "SET_NETWORK %d priority 0", network_id);

+		sta_docmd (cmd);

+		sta_docmd ("SAVE_CONFIG");

+

+		wifi_station_connect (MODULE_ID_WIFI);

+

+		if (p_WRONG_KEY) {

+			wf_log ("network_id = %d wrong key to disable it", network_id);

+			sprintf (cmd , "DISABLE_NETWORK %d", network_id);

+			sta_docmd (cmd);

+			sta_docmd ("SAVE_CONFIG");

+		}

+	}

+}

+

+

+void *station_loop (void *param)

+{

+	char buf[UEVENT_BUFFER_SIZE];

+	char name[32] = {0};

+	static  int  scan_times = 0;

+	int  loop_run = 0;

+

+	strncpy (name, (char*) param, sizeof(name)-1);

+	prctl (PR_SET_NAME, name, 0, 0, 0);

+

+	while (1) {    //¼àÌýcharging״̬µÄ²å°Î

+		//if wpa_supplicant is stop ,then wait

+		//if recv the sem,  g_wpa_supplicant ==1

+		//   wf_log("station_loop: g_wpa_supplicant= %d", g_wpa_supplicant);

+		if (g_wpa_supplicant == 0 || 0 == loop_run) {

+			sem_wait (&g_wpa_supplicant_id);

+		}

+		loop_run =1;

+		// ʼþ²Î¿¼wpa_supplantÖÐwpa_ctrl.hÖж¨Òå

+		int nread = wifi_wait_for_event (&sta_manager->sock, buf, sizeof (buf));

+

+		//wake_sta_lock();

+		if (nread > 0) {

+			wf_log ("STA: %s", buf);

+

+			if (strstr (buf, "CTRL-EVENT-SCAN-RESULTS")) {

+				char  sta_ip_status[16] = {0};

+				cfg_get_item ("sta_ip_status", sta_ip_status, sizeof (sta_ip_status));

+

+				if (strcmp (sta_ip_status, "connecting") != 0) {//disconnect connect dhcping

+					wf_log ("snd msg to get scan results");

+					scan_times = 0; // IF status change to not connecting, then set 0

+					ipc_send_message (MODULE_ID_WIFI, MODULE_ID_WIFI, MSG_CMD_WIFI_STATION_GET_SCAN_RESULTS, 0, NULL, 0);

+				} else {

+					// 17S  ccan interval,  17*12 =204S about, to disconnect,  just set the nv value, the wpa_supplicant still scan to connect

+					// the final status ,is enable all network, and scan to connect ,but sta_ip_status is disconnect

+					scan_times ++;

+					if (4 == scan_times) {//12-->4 , decrease the waiting time

+						wf_log ("can not find available spot, just set sta_ip_status disconnect", buf);

+						ipc_send_message (MODULE_ID_WIFI, MODULE_ID_WIFI, MSG_CMD_WIFI_STATION_NO_AVAILABLE_AP, 0, NULL, 0);

+						scan_times = 0;

+					}

+				}

+			}

+			//STA: CTRL-EVENT-CONNECTED - Connection to a6:44:d1:86:c5:d9 completed [id=0 id_str=]

+

+			else if (strstr (buf, "CTRL-EVENT-CONNECTED")) {			

+				ipc_send_message (MODULE_ID_WIFI, MODULE_ID_WIFI, MSG_CMD_WIFI_STATION_CONNECTED_ENABLE_AP_CMD, 0, NULL, 0);

+			

+				char *p = strstr (buf, "Connection to ");

+

+				scan_times = 0; // IF status change to not connecting, then set 0

+

+				if (p != NULL) {// 

+					p += strlen ("Connection to ");

+					strncpy (g_linked_ap_mac, p, 17);

+				}

+				g_linked_network_id = get_int_from_event (buf, "[id=");

+				wf_log ("g_linked_network_id_last = %d, g_linked_network_id= %d",  g_linked_network_id_last, g_linked_network_id);

+				//wf_send_message( MODULE_ID_WIFI, MODULE_ID_WIFI,  MSG_CMD_WIFI_STATION_EVENT_CONNECTED, 0, NULL);

+				ipc_send_message (MODULE_ID_WIFI, MODULE_ID_WIFI, MSG_CMD_WIFI_STATION_EVENT_CONNECTED, 0, NULL, 0);

+			} else if (strstr (buf, "CTRL-EVENT-DISCONNECTED")) {

+				ipc_send_message (MODULE_ID_WIFI, MODULE_ID_WIFI, MSG_CMD_WIFI_STATION_EVENT_DISCONNECTED, 0, NULL, 0);

+			}

+

+			//STA: CTRL-EVENT-SSID-REENABLED id=0 ssid="ZONG MBB-MF920W+-000012"

+			else if (strstr (buf, "CTRL-EVENT-SSID-REENABLED")) {

+				scan_times = 0; // when reenable , it indicate there is available AP, so set it  0

+				ipc_send_message (MODULE_ID_WIFI, MODULE_ID_WIFI, MSG_CMD_WIFI_STATION_EVENT_CONNECTING, 0, NULL, 0);

+			}

+			//STA: Trying to associate with 00:90:49:58:00:73 (SSID='Wo4G-0073' freq=2412 MHz)

+			else if (strstr (buf, "Trying to associate with")) {

+#if defined(__AIC_8800DW_CHIP__)

+				channel_follow(buf);

+#endif

+				scan_times = 0; // when begin to assoc , it indicate there is available AP, so set it  0

+				//  CTRL-EVENT-SSID-REENABLED   maybe lost

+				ipc_send_message (MODULE_ID_WIFI, MODULE_ID_WIFI, MSG_CMD_WIFI_STATION_EVENT_CONNECTING, 0, NULL, 0);

+				process_trying_to_assoc (buf);

+			}

+			//SME: Trying to authenticate with 90:1d:27:78:2c:1e (SSID='Ufi_782111' freq=2412 MHz)

+			else if (strstr (buf, "Trying to authenticate with")) {

+#if defined(__SSV_6X5X_CHIP__)

+				channel_follow(buf);

+#endif

+			}

+			else if (strstr (buf , "CTRL-EVENT-SIGNAL-CHANGE")) {

+				wf_log ("snd msg to update signal level");

+			}

+			// CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="CPE_E3DE4E" auth_failures=2 duration=20 reason=WRONG_KEY ¡¢AUTH_FAILED¡¢CONN_FAILED

+			else if (strstr (buf, "CTRL-EVENT-SSID-TEMP-DISABLED")) {	

+				//time sequence cfg_set sta_ip_status, process in another thread with other event

+				ipc_send_message (MODULE_ID_WIFI, MODULE_ID_WIFI, MSG_CMD_WIFI_STATION_TEMP_DISABLED, nread, buf, 0);

+			}

+			//WPA: Failed to select authenticated key management type --- 1

+			//WPA: Failed to set WPA key management and encryption suites --- 2

+			else if (strstr (buf, "WPA: Failed to set")) {	

+				//sta auth failed

+				ipc_send_message (MODULE_ID_WIFI, MODULE_ID_WIFI, MSG_CMD_WIFI_STATION_FAILED_SET, 0, NULL, 0);

+			}

+			else if (strstr (buf, "CTRL-EVENT-TERMINATING")) {

+

+				loop_run = 0;

+			}

+		} else {

+			wf_log ("Could not read pending message.");

+		}

+	}

+

+	return NULL;

+}

+

+

+void  wlan_station_open()

+{

+

+}

+

+void  wlan_statemachine_init()

+{

+

+}

+

+

diff --git a/lynq/S300/ap/app/zte_comm/wlan/src/wlan_config_ssid.c b/lynq/S300/ap/app/zte_comm/wlan/src/wlan_config_ssid.c
new file mode 100755
index 0000000..c943a80
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/wlan/src/wlan_config_ssid.c
@@ -0,0 +1,701 @@
+#include "wlan_config_ssid.h"
+#include "wifi_hal.h"
+#include "wifi_util.h"
+#include "rtk_arch.h"
+#include "softap_api.h"
+
+
+const CHAR base[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
+static VOID setWifiKeyForImei (CHAR* outkey, CHAR* imeistr, UINT32 num);
+
+
+static void wlan_set_change_ssid_key_status()
+{
+	//Zssid_SendMsgFromQueue(MODULE_ID_MMI, MSG_CMD_MODIFY_SSID_KEY, 0, NULL);
+	ipc_send_message (MODULE_ID_ZSSID, MODULE_ID_MMI, MSG_CMD_MODIFY_SSID_KEY, 0, NULL, 0);
+}
+
+/**********************************************************************************
+��������:ƴ��SSID , c Ϊ���ӷ���numΪ���Ƶ�mac��λ
+***********************************************************************************/
+static INT make_user_mac (CHAR * s_mac)
+{
+	CHAR last_mac[20] = {0};
+	CHAR ssid[40] = {0};
+	CHAR m_ssid[40] = {0};
+    CHAR ssid_cmd[128] = {0};
+	CHAR sLastbyte[3] = {0};
+	INT num = 0;
+	INT i = 0;
+	int ret = 0;
+	cfg_get_item ("wifi_ssid_gen_with_mac_lastbyte", sLastbyte, 3);
+	for (i = 0; i < strlen (sLastbyte); i++) {
+		num = (sLastbyte[i] - '0') + num * 10;
+	}
+	wf_log ("make_user_mac  num = %d", num);
+	if ( (NULL == s_mac) || (num <= 0) || (num > 12)) {
+		wf_log ("make_user_mac  error..");
+		return -1;
+	}
+	/*��ȡSSID1 ����mac��ַ����λ*/
+	cfg_get_item ("SSIDbak", ssid, sizeof (ssid));
+
+	wf_log ("old ssid = %s", ssid);
+
+	strcpy (&last_mac[0], &s_mac[WLAN_MAC_ADDR_LEN - num]);
+	strcat (ssid, last_mac);
+
+	if (strlen (ssid) > 32) {
+		wf_log ("mac_len error");
+		return -1;
+	}
+
+	sprintf (m_ssid, "%s_2", ssid);
+
+	cfg_set ("SSID1", ssid);
+	cfg_set ("m_SSID", m_ssid);
+
+	cfg_set ("ssid_write_flag", "1"); //��nv�еı�־λ��1����ʾSSID��д�롣
+	//cfg_save();
+	//softap_log(LOG_INFO,WIFI_PRINT,">-------------- ssid = %s", ssid);
+	wf_log (">-------------- ssid = %s", ssid);
+	wlan_set_change_ssid_key_status();
+
+	//ipc_send_message (MODULE_ID_ZSSID, MODULE_ID_AT_CTL, MSG_CMD_SSID_SET_REQ, 0, NULL, 0); //������Ϣ��at server  �ϱ�SSID
+    sprintf(ssid_cmd, "AT+SSID=%s\r", ssid);
+    ret = get_modem_info(ssid_cmd, NULL, NULL);
+	if (ret != 0) {
+		wf_log ("AT+SSID error");
+		return -1;
+	}
+
+	return 0;
+}
+
+
+static unsigned char proc_readable_ch (unsigned char in)
+{
+	if (0x30 > in) {
+		return (in % 10) + 0x30;
+	} else if (0x39 < in && 0x41 > in) {
+		return in - 7;
+	} else if (0x5A < in && 0x61 > in) {
+		return in - 6;
+	} else if (0x7A < in) {
+		return proc_readable_ch (in - 0x7A);
+	}
+	return in;
+}
+
+VOID zte_filter_charactor (char *ch)
+{
+	if ('i' == *ch) {
+		*ch = 'A';
+	} else if ('I' == *ch) {
+		*ch = 'B';
+	} else if ('l' == *ch) {
+		*ch = 'C';
+	} else if ('o' == *ch) {
+		*ch = 'D';
+	} else if ('O' == *ch) {
+		*ch = 'E';
+	} else if ('q' == *ch) {
+		*ch = 'F';
+	} else if ('0' == *ch) {
+		*ch = 'G';
+	} else if ('1' == *ch) {
+		*ch = 'H';
+	} else if ('9' == *ch) {
+		*ch = 'J';
+	}
+}
+
+static void alpha_to_digital (CHAR* key, UINT32 key_len)
+{
+	int i = 0;
+	if (NULL == key) {
+		return;
+	}
+	wf_log ("before key=%s key_len = %d", key, key_len);
+	for (i = 0; i < key_len; i++) {
+		if (key[i] < '0' || key[i] > '9') {
+			key[i] = key[i] % 10 + 0x30;
+		}
+	}
+	wf_log ("after key=%s ", key);
+}
+#ifndef WEBS_SECURITY
+static void make_password_strong(CHAR* key, UINT32 key_len)
+{
+    UINT32 rnum = 0;
+	int i = 0;
+	char punct[] = {'~', '!', '@', '#', '%', '-', '+', '_', '=', '?', '.'};
+	char tmpchar = 0;
+
+    for (i = 0; i < key_len; i++) {
+		rnum = (key[i] - '0') + rnum * 10;
+	}
+
+    rnum = rnum % 26;
+	*(key + key_len) = 'A' + rnum;
+
+	rnum = 0;
+	for (i = 0; i < key_len; i++) {
+		rnum = (key[key_len - 1 - i] - '0') + rnum * 10;
+	}
+
+	rnum = rnum % 26;
+	*(key + key_len + 1) = 'a' + rnum;
+
+	rnum = 0;
+	for (i = 0; i < key_len / 2; i++) {
+		rnum = (key[i] - '0') + rnum * 10;
+	}
+
+	rnum = rnum % (sizeof(punct)/sizeof(punct[0]));
+	*(key + key_len + 2) = punct[rnum];
+
+	printf("make_password_strong:%s\n", key);
+
+	tmpchar = *(key);
+	*(key) = *(key + key_len);
+	*(key + key_len) = tmpchar;
+
+	tmpchar = *(key + 1);
+	*(key + 1) = *(key + key_len + 1);
+	*(key + key_len + 1) = tmpchar;
+
+}
+#endif
+static VOID generate_ascii_password (CHAR *macdr, CHAR *outkey, INT outkeylen)
+{
+	SHORT i = 0;
+	SHORT j = 0;
+	UCHAR t = 0;
+	SHORT ret = -1;
+	CHAR imei[16] = {0};
+	CHAR only_digit_key[2] = {0};
+	CHAR key_gen_type[10] = {0};
+	CHAR sLastbyte[3] = {0};
+	CHAR sKeylen[3] = {0};
+	SHORT iKeylen = 0;
+	SHORT iLastbyte = 0;
+	SHORT iLimit = 0;
+	CHAR wifi_key_fixed[4] = {0};
+
+	if (NULL == macdr || NULL == outkey || strlen (macdr) == 0) {
+		return;
+	}
+	ret = cfg_get_item ("wifi_key_len", sKeylen, 3);
+	for (i = 0; i < strlen (sKeylen); i++) {
+		iKeylen = (sKeylen[i] - '0') + iKeylen * 10;
+	}
+	ret = cfg_get_item ("wifi_key_gen_type", key_gen_type, 10);
+	if (ret != -1) {
+		wf_log ("wifi_key_gen_type=%s", key_gen_type);
+		if (!strncmp (key_gen_type, "DEFAULT", 7)) {
+			cfg_get_item (WLAN_NV_WPAPSK1_NAME, outkey, outkeylen);
+			wf_log ("outkey=%s", outkey);
+		} else if (!strncmp (key_gen_type, "MAC", 3)) {
+			// gen by mac
+			ret = cfg_get_item ("wifi_key_gen_with_mac_lastbyte", sLastbyte, 3);
+
+			if (ret != -1) {
+				wf_log ("wifi_key_gen_with_mac_lastbyte=%s", sLastbyte);
+				for (i = 0; i < strlen (sLastbyte); i++) {
+					iLastbyte = (sLastbyte[i] - '0') + iLastbyte * 10;
+				}
+				iLimit = (WLAN_MAC_ADDR_LEN - iLastbyte) < 0 ? 0 : (WLAN_MAC_ADDR_LEN - iLastbyte);
+				for (i = iLimit; i < WLAN_MAC_ADDR_LEN; i++) {
+					outkey[j] = macdr[i];
+					j++;
+				}
+				for (i = 0; i < iLastbyte; i++) {
+					if (outkey[i] > 96 && outkey[i] < 123) {
+						outkey[i] = outkey[i] - 32;
+					}
+				}
+				outkey[iLastbyte] = '\0';
+			} else {
+
+				for (j = 0; j < iKeylen; j++) {
+					for (i = 0; i < WLAN_MAC_ADDR_LEN; i++) {
+						t ^= macdr[j] & (macdr[i] << (i % 2) ? 1 : 3);
+					}
+					outkey[j] = proc_readable_ch (t ^ (~macdr[11 - j]));
+					zte_filter_charactor (outkey + j);
+				}
+			}
+		} else if (!strncmp (key_gen_type, "IMEI", 4)) {
+			// gen by imei
+			cfg_get_item ("imei", imei, sizeof(imei));
+			while(strlen(imei) < 15) {
+				wf_log ("atctl did not get imei now.");
+				wf_ms_sleep (1000);
+				cfg_get_item ("imei", imei, sizeof(imei));
+			}
+			setWifiKeyForImei (outkey, imei, 8);
+		}
+	}
+
+	ret = cfg_get_item ("wifi_key_only_digit", only_digit_key, 2);
+	if (0 == strncmp (only_digit_key, "y", 2)) {
+		alpha_to_digital (outkey, iKeylen);
+	}
+
+	cfg_get_item ("wifi_key_fixed", wifi_key_fixed, sizeof(wifi_key_fixed));
+	if(0 == strcmp(wifi_key_fixed, "1"))
+	{
+		return;
+	}
+
+#ifndef WEBS_SECURITY
+	make_password_strong(outkey, iKeylen);//for security
+#else			
+	outkey[0] = 'Z';
+	outkey[1] = 'z';
+#endif
+	return;
+}
+
+static void generate_random_string(char *str) 
+{
+	int i = 0;
+	int random_index = 0;
+    const char charset[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+    const int charsetSize = sizeof(charset) - 1; 
+
+    if (str == NULL || strlen(str) < 8) 
+	{
+        wf_log("Provided string does not have enough space to store the result.\n");
+        return;
+    }
+
+    srand((unsigned int)time(NULL));
+
+    for (i = 0; i < 8; i++) 
+	{
+        random_index = rand() % charsetSize;
+        str[i] = charset[random_index];
+    }
+
+    str[8] = '\0';
+
+	return;
+}
+
+static void remove_chars(char *str) 
+{
+	int i = 0;
+    int len = strlen(str);
+    if (len < 6) 
+	{
+        return;
+    }
+
+    for (i = 3; i < len - 3; ++i) 
+	{
+        str[i] = str[i + 3];
+    }
+
+    str[len - 3] = '\0';
+
+	return;
+}
+
+static int make_wifikey (CHAR * key, CHAR * m_key)
+{
+	char *encode = NULL;
+
+	char * m_encode = NULL;
+    char psk_cmd[128]={0};
+	int ret = 0;
+
+	if (NULL == key || NULL == m_key) {
+		return -1;
+	}
+
+	wf_log ("make_wifikey   key=%s,  m_key=%s", key, m_key);
+
+	if (strlen (key) > 0) {
+		encode = wlan_base64_encode(key, strlen (key));
+		cfg_set ("WPAPSK1", key);
+		cfg_set ("WPAPSK1_encode", encode);
+	}
+
+	if (strlen (m_key) > 0) { // protect  multissid  , m_key maybe 0
+		m_encode =  wlan_base64_encode(m_key, strlen (m_key));
+		cfg_set ("m_WPAPSK1", m_key);
+		cfg_set ("m_WPAPSK1_encode", m_encode);
+	}
+#ifdef __AP_FUNC__
+#ifdef __USE_AES__
+	wifi_encrypt_code();
+#endif
+#endif
+
+	//cfg_save();
+	wlan_set_change_ssid_key_status();
+
+
+	if (encode != NULL) {
+		free (encode);
+	}
+	if (m_encode != NULL) {
+		free (m_encode);
+	}
+
+    snprintf(psk_cmd, sizeof(psk_cmd), "AT+WIFIKEY=%s\r", key);
+
+	//ipc_send_message (MODULE_ID_WIFI, MODULE_ID_AT_CTL, MSG_CMD_WIFIKEY_SET_REQ, 0, NULL, 0); //������Ϣ��at server
+	ret = get_modem_info(psk_cmd, NULL, NULL);
+	if (ret != 0) {
+		wf_log ("AT+WIFIKEY error");
+		return -1;
+	}
+	return 0;
+}
+
+static int set_mac_conf(char *mac, char *mac2)
+{
+#if defined(__XR_819_CHIP__)
+	//xr819 set mac before insmod??
+	wf_log ("set_mac_conf:%s", mac);
+	wlan_write_file("/etc_rw/wifi/xr_wifi.conf", mac);
+#elif defined(__SSV_6X5X_CHIP__)
+	//sv6158 set mac before insmod
+	char mac_cmd[128]={0};
+	snprintf(mac_cmd, sizeof(mac_cmd), "%s\n%s", mac, mac2);
+	wf_log ("set_mac_conf:[%s]", mac_cmd);
+	wlan_write_file("/etc_rw/wifimac", mac_cmd);
+#elif defined(__AIC_8800DW_CHIP__)
+	//aic_8800dw set mac before insmod
+	char mac_cmd[128]={0};
+	snprintf(mac_cmd, sizeof(mac_cmd), "MAC_A1=%s  MAC_A2=%s  MAC_A3=%s\n", mac, mac2, mac2);
+	//snprintf(mac_cmd, sizeof(mac_cmd), "MAC_A1=%s\n", mac);
+	wf_log ("set_mac_conf:[%s]", mac_cmd);
+	wlan_write_file("/etc_rw/aic_macconfig.txt", mac_cmd);
+#elif defined(__ESP_8089_CHIP__)
+	char mac_cmd[128]={0};
+	int ret = 0;
+
+	snprintf(mac_cmd, sizeof(mac_cmd), "AT+MAC=%s\r", s_mac);//no :
+	wf_log ("write mac:[%s]", s_mac);
+
+	ret = get_modem_info(mac_cmd, NULL, NULL);
+	if (ret != 0) {
+		wf_log ("AT+MAC error");
+		return -1;
+	}
+#endif	
+	return 0;
+}
+
+static VOID setWifiKeyForImei (CHAR* outkey, CHAR* imeistr, UINT32 num)
+{
+	CHAR old_key[WLAN_NV_WPAPSK1_LENGTH] = {0};
+	if (outkey == NULL) {
+		wf_log ("outkey is null");
+		return ;
+	}
+	if (imeistr == NULL) {
+		wf_log ("imeistr is null");
+		return ;
+	}
+	if (15 != strlen (imeistr)) {
+		wf_log ("imeistr is error");
+		return ;
+	}
+
+	strcpy (&outkey[0], &imeistr[15 - num]);
+
+	cfg_get_item (WLAN_NV_WPAPSK1_NAME, old_key, WLAN_NV_WPAPSK1_LENGTH);
+	if (strcmp (outkey, old_key)) {
+		cfg_set (WLAN_NV_WPAPSK1_NAME, outkey);
+	}
+}
+
+/*
+
+*/
+unsigned  char * a2xx (const unsigned char* addr, unsigned char *mac)
+{
+	int i = 0;
+	unsigned char *p = addr;
+	unsigned char str[3] = {0};
+
+	for (i = 0; i < 6; i++) {
+		strncpy (str, p, 2);
+		mac[i] = s2x (str);
+		p += 2;
+	}
+
+	return mac;
+}
+
+/**
+ * is_zero_ether_addr - Determine if give Ethernet address is all zeros.
+ * @addr: Pointer to a six-byte array containing the Ethernet address
+ *
+ * Return true if the address is all zeroes.
+ *
+ * Please note: addr must be aligned to u16.
+ */
+static  int  is_zero_ether_addr (const unsigned char * a)
+{
+	return ! (a[0] | a[1] | a[2] | a[3] | a[4] | a[5]);
+}
+
+/**
+ * is_multicast_ether_addr - Determine if the Ethernet address is a multicast.
+ * @addr: Pointer to a six-byte array containing the Ethernet address
+ *
+ * Return true if the address is a multicast address.
+ * By definition the broadcast address is also a multicast address.
+ */
+static  int  is_multicast_ether_addr (const unsigned char *addr)
+{
+	return 0x01 & addr[0];
+}
+
+/**
+ * is_valid_ether_addr - Determine if the given Ethernet address is valid
+ * @addr: Pointer to a six-byte array containing the Ethernet address
+ *
+ * Check that the Ethernet address (MAC) is not 00:00:00:00:00:00, is not
+ * a multicast address, and is not FF:FF:FF:FF:FF:FF.
+ *
+ * Return true if the address is valid.
+ *
+ * Please note: addr must be aligned to u16.
+ */
+static  int  is_valid_ether_addr (const unsigned char *addr)
+{
+	/* FF:FF:FF:FF:FF:FF is a multicast address so we don't need to
+	 * explicitly check for it here. */
+	return !is_multicast_ether_addr (addr) && !is_zero_ether_addr (addr);
+}
+
+/*
+
+*/
+static int  is_valid_mac (const char *mac)
+{
+	unsigned char a[6] = {0};
+
+	a2xx (mac, a);
+
+	wf_log ("addr=%02x%02x%02x%02x%02x%02x", a[0], a[1], a[2], a[3], a[4], a[5]);
+	return is_valid_ether_addr ( (const unsigned char *) a);
+
+}
+
+/**********************************************************************************
+��������:����MAC ��ַ
+
+�ó�mac��ַ
+
+����ssid ��wifikey
+
+дssid ��wifikey nvֵ
+
+��ͨоƬ��Ҫд�뵽 /mnt/jffs2/firmware/nvram_bcmdhd.txt �ļ���
+***********************************************************************************/
+static VOID wlan_setWifiNV (CHAR *macaddress)
+{
+	CHAR mac[32]   = {0};
+	CHAR m_mac[32] = {0};
+
+	CHAR *p = NULL;
+	CHAR read_mac[32] = {0};
+	CHAR outpassword[32] = {0};
+	CHAR wifi_mac_num_str[3] = {0}; // indicate the number of mac needed
+	CHAR m_read_mac[32] = {0};
+	CHAR m_outpassword[32] = {0};
+	CHAR wifi_key_fixed[10] = {0};
+
+	int  wifi_mac_num = 0;
+	int  ret = -1;
+
+	INT  i = 0;
+	INT  valid_mac = 0;
+	INT  len = 0, len1 = 0;
+
+	ret = cfg_get_item ("wifi_mac_num", wifi_mac_num_str, sizeof (wifi_mac_num_str));
+	if (ret == 0) {
+		wifi_mac_num = atoi (wifi_mac_num_str);
+	} else {
+		wifi_mac_num = 1;
+	}
+
+	len = strlen ("+MAC:");
+	len1 = strlen ("+MAC:XXXXXXXXXXXX;"); // 18
+
+	wf_log ("wlan_setWifiNV macaddress=%s", macaddress);
+
+	strncpy (read_mac, macaddress + len, 12);
+	if (2 == wifi_mac_num)
+		strncpy (m_read_mac, macaddress + len1, 12);
+
+	wf_log ("read mac = %s, m_read_mac=%s", read_mac, m_read_mac);
+
+	char ssid[32] = {0};
+	char ssidbak[32] = {0};
+	cfg_get_item ("SSID1", ssid, sizeof (ssid));
+	cfg_get_item ("SSIDbak", ssidbak, sizeof (ssidbak));
+	if (strcmp (ssidbak, "") == 0)
+		cfg_set ("SSIDbak", ssid);
+	if (0 == is_valid_mac (read_mac) || (2 == wifi_mac_num && 0 == is_valid_mac (m_read_mac))) {
+		wf_log ("invalid Mac Address read_mac=%s,m_read_mac=%s", read_mac, m_read_mac);
+		cfg_set ("ssid_write_flag", "0"); //���mac���Ϸ�����Ϊû��д��ɹ�
+		cfg_set ("SSID1", "Please set Valid MAC firstly");
+		cfg_set ("m_SSID", "Please set Valid MAC firstly");
+		cfg_set ("wifi_mac", "");
+		cfg_set ("m_wifi_mac", "");
+		wlan_set_change_ssid_key_status();
+		return ;
+	}
+
+	//+MAC:XXXXXXXXXXXX;XXXXXXXXXXXX
+	sprintf (mac, "%c%c:%c%c:%c%c:%c%c:%c%c:%c%c",
+	         read_mac[0], read_mac[1], read_mac[2], read_mac[3], read_mac[4], read_mac[5],
+	         read_mac[6], read_mac[7], read_mac[8], read_mac[9], read_mac[10], read_mac[11]);
+
+	if (2 == wifi_mac_num) {
+		sprintf (m_mac, "%c%c:%c%c:%c%c:%c%c:%c%c:%c%c",
+		         m_read_mac[0], m_read_mac[1], m_read_mac[2], m_read_mac[3], m_read_mac[4], m_read_mac[5],
+		         m_read_mac[6], m_read_mac[7], m_read_mac[8], m_read_mac[9], m_read_mac[10], m_read_mac[11]);
+
+	}
+	wf_log ("mac = %s  m_mac= %s", mac, m_mac);
+
+	cfg_set ("wifi_mac", mac);
+	if (2 == wifi_mac_num)
+		cfg_set ("m_wifi_mac", m_mac);
+
+//    setWifiWpsDefPin();
+
+	generate_ascii_password (read_mac, outpassword, sizeof (outpassword));
+	generate_ascii_password (m_read_mac, m_outpassword, sizeof (m_outpassword));
+	// generate_random_string(outpassword);
+	// generate_random_string(m_outpassword);
+
+	cfg_get_item ("wifi_key_fixed", wifi_key_fixed, sizeof (wifi_key_fixed));
+	if(0 != strcmp(wifi_key_fixed, "1"))
+	{
+		remove_chars(outpassword);
+		remove_chars(m_outpassword);
+	}
+
+	make_wifikey (outpassword, m_outpassword);
+	make_user_mac (read_mac);
+
+	set_mac_conf(mac, m_mac);
+}
+
+
+char *wlan_base64_encode(const char* data, int data_len)
+{
+	//int data_len = strlen(data);
+	int prepare = 0;
+	int ret_len;
+	int temp = 0;
+	char *ret = NULL;
+	char *f = NULL;
+	int tmp = 0;
+	char changed[4];
+	int i = 0;
+	ret_len = data_len / 3;
+	temp = data_len % 3;
+	if (temp > 0) {
+		ret_len += 1;
+	}
+	ret_len = ret_len * 4 + 1;
+	ret = (char *) malloc (ret_len);
+
+	if (ret == NULL) {
+		wf_log ("No enough memory.");
+		exit (0);
+	}
+	memset (ret, 0, ret_len);
+	f = ret;
+	while (tmp < data_len) {
+		temp = 0;
+		prepare = 0;
+		memset (changed, '\0', 4);
+		while (temp < 3) {
+			//printf("tmp = %d", tmp);
+			if (tmp >= data_len) {
+				break;
+			}
+			prepare = ( (prepare << 8) | (data[tmp] & 0xFF));
+			tmp++;
+			temp++;
+		}
+		prepare = (prepare << ( (3 - temp) * 8));
+		//printf("before for : temp = %d, prepare = %d", temp, prepare);
+		for (i = 0; i < 4 ; i++) {
+			if (temp < i) {
+				changed[i] = 0x40;
+			} else {
+				changed[i] = (prepare >> ( (3 - i) * 6)) & 0x3F;
+			}
+			*f = base[ (UCHAR) changed[i]];
+			//printf("%.2X", changed[i]);
+			f++;
+		}
+	}
+	*f = '\0';
+
+	return ret;
+
+}
+
+
+void  send_get_mac_req()
+{
+	int send_ret = -1;
+
+	char ssid_write_flag[8] = {0};
+	cfg_get_item ("ssid_write_flag", ssid_write_flag, sizeof (ssid_write_flag));
+	wf_log ("wifi_ssid_init: ssid_write_flag = %s", ssid_write_flag);
+
+	if (!strcmp (ssid_write_flag, "0")) {
+
+		send_ret = ipc_send_message(MODULE_ID_WIFI, MODULE_ID_AT_CTL, MSG_CMD_GET_MAC_REQ, 0, NULL, 0);
+		while (send_ret != 0) {
+			wf_log ("send message MSG_CMD_GET_MAC to at_ctl to get mac failed");
+			wf_ms_sleep (200);
+			send_ret = ipc_send_message(MODULE_ID_WIFI, MODULE_ID_AT_CTL, MSG_CMD_GET_MAC_REQ, 0, NULL, 0);
+		}
+		wf_log ("send message MSG_CMD_GET_MAC to at_ctl to get mac successfully");
+
+	}
+}
+
+void  get_mac_config_ssid_key_nv()
+{
+	char ssid_write_flag[8] = {0};
+	char at_wifi_mac[64]    = {0};
+
+
+	cfg_get_item ("ssid_write_flag", ssid_write_flag, sizeof (ssid_write_flag));
+	wf_log ("wifi_ssid_init: ssid_write_flag = %s", ssid_write_flag);
+
+	/*��NV���Ƿ���д��SSID �ı�־λ�Ƚϣ����Ϊ1��ʾ��д�룬������д��0��ʾ��δд��*/
+	if (!strcmp (ssid_write_flag, "0")) {
+
+		cfg_get_item ("at_wifi_mac", at_wifi_mac, sizeof (at_wifi_mac));
+		if (strncmp (at_wifi_mac, "0", 2) == 0) {
+			wf_log ("at_wifi_mac is null ");
+			do {
+				wf_log ("ATMain did not get MAC from CP.");
+				wf_ms_sleep (1000);
+				cfg_get_item ("at_wifi_mac", at_wifi_mac, sizeof (at_wifi_mac));
+			} while (strncmp (at_wifi_mac, "0", 2) == 0);
+		}
+
+		wf_log ("wifi_ssid_init:at_wifi_mac = %s", at_wifi_mac);
+		wlan_setWifiNV (&at_wifi_mac);
+	}
+}
diff --git a/lynq/S300/ap/app/zte_comm/wlan/src/wlan_main.c b/lynq/S300/ap/app/zte_comm/wlan/src/wlan_main.c
new file mode 100755
index 0000000..548638a
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/wlan/src/wlan_main.c
@@ -0,0 +1,1417 @@
+/*

+ *  wlan-server.c -- Wlan Deal module

+ *

+ *  Copyright (c) ZTE Corporation All Rights Reserved.

+ *

+ *  $Id: wlan-server.c,v 0.1 2010-12-15 $

+ *  Authors :   ZHAOYONG - zhao.yong3@zte.com.cn>

+ */

+/****************Í·Îļþ*/

+#include <signal.h>

+#include <time.h>

+#include "wlan_main.h"

+#include "wifi_util.h"

+#include <soft_timer.h>

+

+#include "wlan_config_ssid.h"

+#include "rtk_arch.h"

+#include <semaphore.h>

+

+#include "wifi_sta_ctrl.h"

+#include "wlan_sta_manager.h"

+

+

+#include "wlan_rtc_sleep.h"

+#ifdef __AP_FUNC__

+#include "wifi_ap_ctrl.h"

+#endif

+#include "hotplug.h"

+

+/**************************ºê¶¨Òå*************************/

+

+//#define UEVENT_BUFFER_SIZE   1024*2

+#define  CHARGER     "/sys/class/power_supply/charger/status"

+#define  WIFI_DIR				"/etc_rw/wifi"

+

+

+

+/*************************±äÁ¿ÉùÃ÷**************************************/

+static int g_pre_is_charging = 0;

+

+struct   wlan_ap_server  * ap_server = NULL;

+struct   wlan_sta_manager  *sta_manager= NULL;

+

+#ifdef __STA_FUNC__

+sem_t  g_wpa_supplicant_id;

+extern struct  wlan_sta_manager   esp8089_sta;

+extern struct  wlan_sta_manager   rda5995_sta;

+#ifdef __REALTEK_8192_CHIP__

+extern struct  wlan_sta_manager   realtek_sta;

+#endif

+extern struct  wlan_sta_manager   ssv6x5x_sta;

+extern struct  wlan_sta_manager   aic8800dw_sta;

+

+#endif

+

+extern void *netlink_loop (void *param);

+extern int wifi_app_msg_parse(const char *msg, int msglen, struct hotplug_event *event);

+void check_wifi_mac();

+

+#ifdef __AP_FUNC__

+extern struct wlan_ap_server  esp8089_ap;

+extern struct wlan_ap_server  rda5995_ap;

+extern struct wlan_ap_server  xr819_ap;

+extern struct wlan_ap_server  ssv6x5x_ap;

+extern struct wlan_ap_server  aic8800dw_ap;

+

+

+#ifdef __REALTEK_8192_CHIP__

+extern struct wlan_ap_server  realtek_8192_ap;

+extern int wps_rtc_timer_open ;

+extern void wlan_get_wps_access_sta();

+extern void handle_wps_result (MSG_BUF *pstMsg);

+extern void handle_wps_mac (MSG_BUF *pstMsg);

+#endif

+

+extern int g_rtc_wake_timer_open;

+extern int g_sleep_rtc_timer;

+

+extern int g_tsw_sleep_flag ;//ÓÐÎÞ´´½¨¶¨Ê±Ë¯ÃßµÄrtc timer

+extern int g_tsw_wake_flag ;//ÓÐÎÞ´´½¨¶¨Ê±»½ÐѵÄrtc timer

+extern sem_t g_hostap_id;

+

+

+static char tem_cfg[512] = {0};

+#define CFG2WEB_UNCONDITIONAL(SrcCfg,DesCfg)\

+                    do{     \

+                        memset(tem_cfg,0,sizeof(tem_cfg));                   \

+                        cfg_get_item(SrcCfg,tem_cfg,sizeof(tem_cfg));       \

+                        cfg_set(DesCfg,tem_cfg);                             \

+                    }while(0)

+extern void wifi_station_close (void);

+

+/*************************¾²Ì¬º¯ÊýÉùÃ÷***********************************/

+static int chargingcheckstates();

+static void sleep_wifi();

+void basic_deal_all (int cmd);

+extern  void zte_get_wifi_sta_list(RT_802_11_MAC_TABLE *staList);

+

+

+//¶¨Ê±»½ÐÑ: ÒòΪÔÚTswWakeLoop ÊÕµ½elapseÏûÏ¢ºó¾ÍÁ¢¼´ÖØÉètimerÁË£¬´Ë´¦

+//²»ÔÙÖØÐÂÉèÖã¬Ö»ÊÇÖ´Ðл½ÐѲÙ×÷

+static void handle_wifi_tsw_open()

+{

+	char wifi_cur_state[8] = {0};

+	char m_ssid_enable[8] = {0};

+	cfg_get_item ("wifi_cur_state", wifi_cur_state, sizeof (wifi_cur_state));

+	cfg_get_item ("m_ssid_enable", m_ssid_enable, sizeof (m_ssid_enable));

+

+	wf_log ("handle_wifi_tsw_open");

+

+	if (strcmp (wifi_cur_state, WIFI_OPENED) == 0) {

+		wf_log ("wifi is already open\n ");

+		return;

+	}

+

+	if (1 == atoi (m_ssid_enable)) {

+		basic_deal_all (WIFI_CFG_OPEN_VA0_VA1);

+	} else {

+		basic_deal_all (WIFI_CFG_OPEN);

+	}

+}

+

+int is_charging()

+{

+	int status = 0;

+	char wan_mode[16] = {0};

+

+	cfg_get_item ("WAN_MODE", wan_mode, sizeof (wan_mode));

+

+	if (chargingcheckstates() == 1 // is charging , no need to sleep

+	    || !strcmp (wan_mode, "USB")) { //  if usb is linked , no need to sleep , no concern charging ro not

+

+		wf_log ("******IS CHARING*******");

+

+		status = 1;

+

+	} else {

+

+		status = 0;

+	}

+

+	return status;

+}

+

+

+

+static void qrcode_make()

+{

+	if(0 == ap_server->ap0_state)

+		return;

+

+#ifdef __QRCODE_WIFI__

+	write_status (QRSTATUS, "0");

+	system (QRCODE_SCRIPT_DIR"/zte_qrcode_create.sh wifi_create");

+#ifndef __SINGLE_AP__

+	system (QRCODE_SCRIPT_DIR"/zte_qrcode_create.sh multi_wifi_create");

+#endif

+	write_status (QRSTATUS, "1");

+	wf_log ("zte_qrcode_create.sh wifi_create");

+#endif

+}

+

+

+

+

+

+

+

+void basic_deal_all (int cmd)

+{

+	//remove_all_acl_timer();

+	cancel_all_timer();

+

+	ap_server->basic_deal (ap_server, cmd);

+	qrcode_make();

+

+	wlan_prepare_sleep();

+}

+

+//ÉèÖúڰ×Ãûµ¥: 0£¨²»Æô¶¯£©1£¨°×Ãûµ¥£©2£¨ºÚÃûµ¥£©

+void acl_mode_set()

+{

+	char ACL_mode[8] = {0};

+

+	cfg_get_item ("ACL_mode", ACL_mode, sizeof (ACL_mode));

+	CFG2WEB_UNCONDITIONAL ("ACL_mode", "AccessPolicy0");

+

+	if (!strcmp (ACL_mode, "1")) {       // white-list

+		CFG2WEB_UNCONDITIONAL ("wifi_mac_white_list", "AccessControlList0");

+	} else if (!strcmp (ACL_mode, "2")) { // black-list

+		CFG2WEB_UNCONDITIONAL ("wifi_mac_black_list", "AccessControlList0");

+	} else {

+		cfg_set ("AccessPolicy0", "0");

+	}

+

+	

+}

+

+static void set_mac_access()

+{

+	wf_log ("nxl  set_mac_access  ");

+	acl_mode_set();

+

+	if (ap_server->ap0_state == 1) {

+		wf_log ("wifi is on");

+		acl_set_process();   

+	} else {

+		wf_log ("wifi is off");

+	}

+}

+

+

+

+static int chargingcheckstates()

+{

+	char buf_status[16] = {0};

+	int ret = 0;

+	int  errno_1 = 0;//errno value for the status file of prefer supply

+

+	FILE *p_status = NULL;

+	int len = 0;

+

+	p_status = fopen (CHARGER, "r");

+	if (p_status == NULL) {

+		wf_log ("errno_1 = %d, charger is not exist", errno_1);

+		return 1;

+	}

+	

+	len = fread(buf_status, 1, sizeof(buf_status), p_status);//cov m

+	if (len > 0) {

+		if ( (strncmp (buf_status, "Charging", 8) == 0) || (strncmp (buf_status, "Full", 4) == 0) || (strncmp (buf_status, "Not charging", 12) == 0)) { //bufÖÐ×îºóһλ´òÓ¡³öÀ´ÊÇ»»ÐÐÓÃstrcmp±È½ÏÓÀÔ¶²»³É¹¦£¬ËùÒÔ¸ÄÓÃstrncmp

+			ret = 1;

+		} else {

+			ret = 0;

+		}

+	}

+	

+	if (fclose(p_status)) { //kw

+		wf_log("fclose error");

+	}

+	return ret;

+}

+

+//ÿ´Î¿ª»ú¶¼»áµ÷Óô˺¯Êý£¬Í¨¹ý˯Ãßʱ¼ä³¤¶ÈÅжϣ¬À´ÉèÖÃÊÇ·ñ»á½øÈë˯Ãߣ¬´´½¨rtcÀ´µ¹¼ÆÊ±

+

+static void sleep_wifi()

+{

+	cfg_set ("wifiSleep", "1");

+	cancel_all_timer();

+	ap_server->basic_deal (ap_server, WIFI_CFG_SLEEP); //sleep no real action meaning,just readable

+	

+	wf_msg_to_zcore(MSG_CMD_WIFI_SET_OFF_RSP, 2, WIFI_CLOSED);	//wifi¹Ø±Õºó֪ͨ¹Ì¶¨Ì¨ÏÔʾwifi״̬

+}

+

+// if  wifi is off ,  charging  in wps, no need to sleep

+// only sta_count ==0 ,can sleep

+static void handle_sleep_wifi()

+{

+

+	if (ap_server->ap0_state == 0  || g_pre_is_charging == 1  || ap_server->ap0_wps_state  == 1)

+		return;

+

+	if (captureWlanStaInfo() == 0) {

+		sleep_wifi();

+	}

+}

+

+//¶¨Ê±Ë¯Ãß´¦Àíº¯Êý:²»¹ÜÓÐûÓÐ sta Á¬½ÓÉ豸»òÕßÓÐûÓпªÆôwps¶¼Òª¹Ø±Õ wifi

+static void handle_wifi_tsw_close()

+{

+	if (ap_server->ap0_state == 0)

+		return;

+	sleep_wifi();

+}

+

+

+

+void process_rtc_elapsed (MSG_BUF *pstMsg)

+{

+	UINT32  module_id = 0;

+	RTC_DATA_BUF *data_buf = pstMsg->aucDataBuf;

+	module_id = data_buf->module;

+

+	switch (module_id) {

+	case WIFI_INTERVAL_SLEEP: {

+		g_sleep_rtc_timer = 0; // no need to delete RTCTimer

+		handle_sleep_wifi();

+		break;

+	}

+	case WIFI_TSW_SLEEP: {

+		g_tsw_sleep_flag = 0;

+		//´Ë´¦Ôö¼Óº¯ÊýÖØÐÂÉèÖÃ˯Ãßʱ³¤Îª24Сʱ

+		create_rtc_tsw_close_timer (24 * 60 * 60);

+		handle_wifi_tsw_close();

+		break;

+	}

+	case WIFI_TSW_WAKEUP: {

+		g_tsw_wake_flag = 0;

+		//´Ë´¦Ôö¼Óº¯ÊýÖØÐÂÉèÖÃ˯Ãßʱ³¤Îª24Сʱ

+		create_rtc_tsw_open_timer (24 * 60 * 60);

+		handle_wifi_tsw_open();

+		break;

+	}

+	case WIFI_WAKE_UP_SYSTEM: {

+		g_rtc_wake_timer_open = 0;

+#ifdef __REALTEK_8192_CHIP__

+		captureWlanStaInfo();

+#endif

+		wlan_prepare_sleep();

+		break;

+	}

+

+#ifdef __REALTEK_8192_CHIP__	

+	case WIFI_WPS_RESULT_CHECK: {

+		wps_rtc_timer_open = 0;// timer close automaticly when alarm elapsed

+		wlan_get_wps_access_sta();

+		break;

+	}

+	case WIFI_ACL_SERVICE: {

+		break;

+	}

+#endif

+	default:

+		break;

+	}

+}

+

+void usb_charging_changed()

+{

+	int charging_status = 0;

+	charging_status = chargingcheckstates();

+	char fake_poweroff[8]={0};

+	char wifiSleep[8]={0};

+

+	cfg_get_item ("mmi_fake_poweroff_state", fake_poweroff, sizeof (fake_poweroff));

+	cfg_get_item ("wifiSleep", wifiSleep, sizeof (wifiSleep));

+	if (charging_status != g_pre_is_charging) { // Óë֮ǰµÄÒ»´Î´¦Àíusb״̬²»Í¬

+		g_pre_is_charging = charging_status;

+		wf_log ("charging_status =%d,ap_server->ap0_state=%d,going into handle_usb_msg", g_pre_is_charging, ap_server->ap0_state);

+		if (ap_server->ap0_state == 1) {

+			//wifi is open

+			wlan_prepare_sleep();

+		}

+		// wifi ˯Ãߺ󣬲åÈëusb¼´¿É»½ÐÑ, µ«ÊǼٹػú²»»½ÐÑ

+		else if (ap_server->ap0_state == 0 && g_pre_is_charging == 1 

+				&& strcmp (fake_poweroff, "1") != 0 // ÇÒ²»ÊǼٹػú

+				&& strcmp (wifiSleep, "1") == 0) {// ÇÒÊÇ˯ÃßÃüÁîÒýÆðµÄwifi¹Ø±Õ²Å¿ÉÒÔ»½ÐÑ

+			char m_ssid_enable[8] = {0};

+			cfg_get_item ("m_ssid_enable", m_ssid_enable, sizeof (m_ssid_enable));

+			if (1 == atoi (m_ssid_enable)) {

+				basic_deal_all (WIFI_CFG_OPEN_VA0_VA1);

+			} else {

+				basic_deal_all (WIFI_CFG_OPEN);

+			}

+		}

+	}

+}

+

+

+void fwp_charging_changed(int charging_status)

+{

+	char wifiSleep[8]={0};

+	cfg_get_item ("wifiSleep", wifiSleep, sizeof (wifiSleep));

+

+	g_pre_is_charging = charging_status;

+	wf_log ("charging_status =%d,ap_server->ap0_state=%d", charging_status, ap_server->ap0_state);

+	if (ap_server->ap0_state == 1) {

+		wlan_prepare_sleep();

+	}

+	else if (ap_server->ap0_state == 0 && charging_status == 1 

+		&& strcmp (wifiSleep, "1") == 0) {// ÇÒÊÇ˯ÃßÃüÁîÒýÆðµÄwifi¹Ø±Õ²Å¿ÉÒÔ»½ÐÑ

+		basic_deal_all (WIFI_CFG_OPEN);

+		// for R1680 notify cp mmi wifi is on

+		wf_msg_to_zcore(MSG_CMD_WIFI_SET_ON_RSP, 2, WIFI_OPENED);	//wifi¹Ø±Õºó֪ͨ¹Ì¶¨Ì¨ÏÔʾwifi״̬

+	}

+	else{

+		//do nothing

+	}

+}

+

+

+void wifi_wps_set (MSG_BUF *pstMsg)

+{

+	char encrypType[12]    = {0};

+	char wifi_wps_index[8] = {0};

+	char hidessid[20] = {0};

+	char authmode[20] = {0};

+	char wifi_cur_state[8] = {0};

+

+	cfg_get_item ("wifi_cur_state", wifi_cur_state, sizeof (wifi_cur_state));

+	if (pstMsg->src_id == MODULE_ID_MMI) {

+		strcpy (wifi_wps_index, "1");

+		cfg_set ("wifi_wps_index", "1");

+	} else {

+		cfg_get_item ("wifi_wps_index", wifi_wps_index, sizeof (wifi_wps_index));

+	}

+

+	if (strcmp (wifi_wps_index, "1") == 0) {

+		cfg_get_item ("AuthMode", authmode, sizeof (authmode));

+		cfg_get_item ("HideSSID", hidessid, sizeof (hidessid));

+		cfg_get_item ("EncrypType", encrypType, sizeof (encrypType));

+	} else if (strcmp (wifi_wps_index, "2") == 0) {

+		cfg_get_item ("m_AuthMode", authmode, sizeof (authmode));

+		cfg_get_item ("m_HideSSID", hidessid, sizeof (hidessid));

+		cfg_get_item ("m_EncrypType", encrypType, sizeof (encrypType));

+	}

+

+	//if((!strncmp(RadioOff, "1", 2)) && (!strncmp(hidessid, "0", 2)))

+

+	if (!strncmp (wifi_cur_state, WIFI_OPENED, 2) && !strncmp (hidessid, "0", 1)

+	    && strcmp (encrypType, "TKIP") && strcmp (authmode, "WPAPSK") && strcmp (authmode, "WAPIPSK")

+	    && (strcmp (authmode, "SHARED") && strcmp (authmode, "WEPAUTO"))

+	    && ! (!strcmp (authmode, "OPEN") && !strcmp (encrypType, "WEP"))) {

+		wps_deal (pstMsg);

+	} else {

+		cfg_set ("WscModeOption", "0");

+		wf_log ("Invalid WPS para!");

+	}

+}

+

+void wifi_advanced_set (MSG_BUF *pstMsg)

+{

+	UCHAR flags[8] = {0};

+	if (pstMsg->usDataLen > 0) {

+		wf_log ("aucDataBuf=%s, usDataLen=%d", pstMsg->aucDataBuf, pstMsg->usDataLen);

+		memcpy (flags, pstMsg->aucDataBuf, pstMsg->usDataLen);

+		wf_log ("flags=%s", flags);

+		switch (atoi (flags)) {

+		case WIFI_ADVANCED_CLOSE:

+			//RadioOff should be set to 0 in webserver, to be fix

+		{

+			if(ap_server->ap0_state)basic_deal_all (WIFI_CFG_CLOSE);

+			//handle_tsw_close();//²»ÐèҪɾ³ý¶¨Ê±Ë¯Ãß»½ÐѶ¨Ê±Æ÷

+			break;

+		}

+		case WIFI_ADVANCED_OPEN: {

+			wf_log ("ap_server->ap0_state=%d,ap_server->ap1_state=%d", ap_server->ap0_state, ap_server->ap1_state);

+			if (ap_server->ap0_state && ap_server->ap1_state) {

+				wf_log ("va1 is on,so close va1");

+				basic_deal_all (WIFI_CFG_CLOSE_MSSID);

+			} else {

+				if (!ap_server->ap0_state)basic_deal_all (WIFI_CFG_OPEN);

+			}

+			break;

+		}

+		//  RadioOff=0  wifiEnabled =0  to close wifi

+		//  wifiEnabled=1  to open wifi

+		// no para data to reset wifipara , need restart wifi

+		case WIFI_ADVANCED_CLOSE_MSSID: {

+			basic_deal_all (WIFI_CFG_CLOSE_MSSID);

+			break;

+		}

+		case WIFI_ADVANCED_OPEN_VA01: {

+			cfg_set ("wifi_sta_connection", "0"); //»¥³â±£»¤

+			basic_deal_all (WIFI_CFG_OPEN_VA0_VA1);

+			break;

+		}

+		case WIFI_ADVANCED_OPEN_VA1: {

+			cfg_set ("wifi_sta_connection", "0"); //»¥³â±£»¤

+			basic_deal_all (WIFI_CFG_OPEN_MSSID);

+			break;

+		}

+		case WIFI_ADVANCED_RF: {

+			basic_deal_all (WIFI_CFG_RF); // RF nv value already set OK,just restart

+			break;

+		}

+		case WIFI_ADVANCED_RESTART: { //from tr069,  set ssid password, channel,  wifi_coverage etc..

+			basic_deal_all (WIFI_CFG_FORCE_RESTART); // just  forcerestart

+			break;

+		}

+

+		}

+		//free(pData);

+	}

+}

+

+void deal_msg_data(MSG_BUF *pMsg)

+{

+	switch (pMsg->usMsgCmd) {

+		case MSG_CMD_WIFI_CFG_AP:

+		case MSG_CMD_WIFI_CFG_SSID_REQ:

+		case MSG_CMD_WIFI_CFG_PWD_REQ:

+		case MSG_CMD_WIFI_SET_SECURITY_REQ:

+			if(pMsg->usDataLen != 0){

+				wlan_basic_info *info = (wlan_basic_info*)(pMsg->aucDataBuf);

+

+				wf_log("ssid=%s ,pwd=%s, auth=%s, encrypt=%s \n",info->ssid, info->pwd, info->authmode,info->encrypt);

+

+				if(strlen(info->ssid)>0)

+					cfg_set("SSID1",info->ssid);

+				if(strlen(info->pwd)>0) {

+					char *encode = NULL;

+					cfg_set("WPAPSK1",info->pwd);

+					encode = wlan_base64_encode(info->pwd, strlen (info->pwd));

+					//kw 3

+					cfg_set ("WPAPSK1_encode", encode);

+					free(encode);

+				}

+				if(strlen(info->authmode)>0)

+					cfg_set("AuthMode",info->authmode);

+				if(strlen(info->encrypt)>0)

+					cfg_set("EncrypType",info->encrypt);

+				if(strlen(info->max_access_num)>0)

+					cfg_set("MAX_Access_num",info->max_access_num);

+				if(strlen(info->hidessid)>0)

+					cfg_set("HideSSID",info->hidessid);				

+			}

+			break;

+		case MSG_CMD_WIFI_CFG_AP2:

+			if(pMsg->usDataLen != 0){

+				wlan_basic_info *info = (wlan_basic_info*)(pMsg->aucDataBuf);

+				if(strlen(info->ssid)>0)

+					cfg_set("m_SSID",info->ssid);

+				if(strlen(info->pwd)>0)

+					cfg_set("m_WPAPSK1",info->pwd);

+				if(strlen(info->authmode)>0)

+					cfg_set("m_AuthMode",info->authmode);

+				if(strlen(info->encrypt)>0)

+					cfg_set("m_EncrypType",info->encrypt);

+				if(strlen(info->max_access_num)>0)

+					cfg_set("m_MAX_Access_num",info->max_access_num);

+				if(strlen(info->hidessid)>0)

+					cfg_set("m_HideSSID",info->hidessid);				

+			}

+			break;

+		default:

+			break;

+	}

+}

+

+void  wlan_switch_reply(MSG_BUF *pMsg)

+{

+	int expect_status =  atoi(pMsg->aucDataBuf);

+

+	if((WLAN_OFF == expect_status  && WLAN_OFF  == ap_server->ap0_state) ||

+	   (WLAN_ON == expect_status  && WLAN_ON  == ap_server->ap0_state)){

+		ipc_send_message(MODULE_ID_WIFI, pMsg->src_id, MSG_CMD_WIFI_SWITCH_RSP, 2, "0", 0);

+	}else{

+		ipc_send_message(MODULE_ID_WIFI, pMsg->src_id, MSG_CMD_WIFI_SWITCH_RSP, 2, "1", 0);

+	}

+

+}

+wlan_mac_info_list mac_list ;

+void dump_mac_list()

+{

+	int i=0;

+	char station_mac_tmp[MAX_NUMBER_OF_MAC*20] = {0};

+

+

+	for(i=0;i<mac_list.access_count;i++){

+		if(i!=0)strcat(station_mac_tmp,";");

+		strcat(station_mac_tmp, mac_list.mac_info[i].mac);

+		wf_log("mac[%d]= %s",i, mac_list.mac_info[i].mac);

+	}

+

+	cfg_set("station_mac", station_mac_tmp);

+	wf_log("station_mac= %s",station_mac_tmp);

+}

+

+void update_sta_count(int num)

+{

+

+	char sta_count[12] = {0}; //klocwork

+	sprintf(sta_count, "%d", num);

+	cfg_set ("sta_count", sta_count);

+	ap_server->g_sta_num = num;

+

+}

+void add_sta_mac(unsigned char *mac)

+{

+	if (mac_list.access_count >= MAX_NUMBER_OF_MAC-1) {

+		wf_log("mac_list over limit = %d!!!",mac_list.access_count);

+		return;

+	}

+	strncpy(mac_list.mac_info[mac_list.access_count++].mac, mac, sizeof(mac_list.mac_info[0].mac)-1);//klocwork ×¢ÒâÓÐ++

+	

+	dump_mac_list();

+	update_sta_count(mac_list.access_count);

+}

+

+

+void remove_sta_mac(unsigned char *mac)

+{

+	

+	int i=0,j=0;

+	wf_log("mac_list.access_count = %d",mac_list.access_count);

+

+	for(i=0;i<mac_list.access_count;i++){

+		if(strcmp(mac_list.mac_info[i].mac, mac)==0){

+			for(j=i+1;j<mac_list.access_count;j++ ){

+				strcpy(mac_list.mac_info[j-1].mac, mac_list.mac_info[j].mac);

+			}

+			break;

+		}

+	}

+

+	mac_list.access_count--;

+	dump_mac_list();

+	update_sta_count(mac_list.access_count);

+}

+

+

+#if  (PRODUCT_TYPE == PRODUCT_PHONE)	

+/*R1682¹Ì¶¨Ì¨Ìí¼ÓwifiÊÊÅä´úÂë*/

+void process_get_wifi_info()

+{

+	char wifi_ssid[WIFI_SSID_LEN] = {0};

+	char wifi_pwd[WLAN_PSK_LEN] = {0};

+	char wifi_authmode[WLAN_SECURITY_LEN] = {0};

+	wlan_basic_info basic_info = {0}; //cov

+	

+	wf_log ("++++++++++++process_get_wifi_info++++++++++++");

+

+	cfg_get_item ("SSID1", wifi_ssid, sizeof (wifi_ssid));

+	cfg_get_item ("WPAPSK1", wifi_pwd, sizeof (wifi_pwd));

+	cfg_get_item("AuthMode", wifi_authmode, sizeof(wifi_authmode));

+	wf_log("+++++++++++++R1682 get wifi_ssid:%s\n",wifi_ssid);

+	wf_log("+++++++++++++R1682 get wifi_pwd:%s\n",wifi_pwd);

+	

+

+

+	strcpy(basic_info.ssid, wifi_ssid);

+	strcpy(basic_info.pwd, wifi_pwd);

+	strcpy(basic_info.authmode, wifi_authmode); 

+	wf_msg_to_zcore(MSG_CMD_WIFI_GET_INFO_RSP, sizeof(wlan_basic_info), &basic_info);	

+	

+}

+#endif

+

+#ifndef __REALTEK_8192_CHIP__

+static DHCPOFFERADDR_LIST_t *find_match_sta(struct list_head *dhcp_info_list,  char* p_mac)

+{

+	DHCPOFFERADDR_LIST_t * p_dhcp_info = NULL;

+	wf_log("p_mac = %p", p_mac);

+

+	list_for_each_entry(p_dhcp_info, dhcp_info_list, list) {

+		//if (memcmp((void *)(p_dhcp_info->dhcp_info.mac), (void *)p_mac, 6)==0)

+

+		if((p_dhcp_info->dhcp_info.mac[0] == p_mac[0]) && (p_dhcp_info->dhcp_info.mac[1] == p_mac[1]) &&

+		    (p_dhcp_info->dhcp_info.mac[2] == p_mac[2]) && (p_dhcp_info->dhcp_info.mac[3] == p_mac[3]) &&

+		    (p_dhcp_info->dhcp_info.mac[4] == p_mac[4]) && (p_dhcp_info->dhcp_info.mac[5] == p_mac[5]))

+		{

+			return p_dhcp_info;

+		}

+	}

+	return  NULL;

+}

+

+/**

+**´¦Àí¹Ì¶¨Ì¨·¢À´µÄÓÃÓÚ»ñÈ¡Á¬½Óµ½APÈȵãµÄÇëÇó

+*/

+void process_get_user_list_req()

+{

+	

+    int i,result=0;

+	

+	struct list_head dhcp_info_list;

+	DHCPOFFERADDR_LIST_t * p_dhcp_info   = NULL;

+	INIT_LIST_HEAD(&dhcp_info_list);

+	char *mac_tmp=safe_malloc (6, 0);

+	if (mac_tmp == NULL) { //kw 1

+		wf_log("process_get_user_list_req malloc fail");

+		goto out;

+	}

+

+	result = zte_get_mac_list_from_lease(&dhcp_info_list);

+	

+	if(result < 0 || mac_list.access_count == 0)

+	{

+		wf_msg_to_zcore(MSG_CMD_WIFI_GET_USER_LIST_RSP, 0, NULL);	

+		goto out;

+	}	

+

+	for (i = 0; i < mac_list.access_count; i++) {

+		

+		wf_log("mac %d,is[%s]",i,mac_list.mac_info[i].mac);

+		sscanf(mac_list.mac_info[i].mac, "%2x:%2x:%2x:%2x:%2x:%2x",(unsigned int *)&mac_tmp[0],(unsigned int *)&mac_tmp[1],(unsigned int *)&mac_tmp[2],(unsigned int *)&mac_tmp[3],(unsigned int *)&mac_tmp[4],(unsigned int *)&mac_tmp[5]);//kw

+

+		wf_log("mac_tmp[%2x:%2x:%2x:%2x:%2x:%2x]",mac_tmp[0],mac_tmp[1],mac_tmp[2],mac_tmp[3],mac_tmp[4],mac_tmp[5]);

+		wf_log("mac_tmp = %p", mac_tmp);

+		if((p_dhcp_info = find_match_sta(&dhcp_info_list,  mac_tmp)) != NULL)

+		{

+			strncpy(mac_list.mac_info[i].hostname,p_dhcp_info->dhcp_info.host_name,sizeof(p_dhcp_info->dhcp_info.host_name));

+			wf_log("hostname %s",mac_list.mac_info[i].hostname);

+		}

+

+	}

+	wf_msg_to_zcore(MSG_CMD_WIFI_GET_USER_LIST_RSP, sizeof(wlan_mac_info_list), &mac_list);

+

+

+out:

+	free_dhcp_list(&dhcp_info_list);

+	safe_free(mac_tmp);

+

+}

+

+#else

+

+static DHCPOFFERADDR_LIST_t *find_match_sta(struct list_head *dhcp_info_list,  RT_802_11_MAC_ENTRY * pEntry)

+{

+	DHCPOFFERADDR_LIST_t * p_dhcp_info = NULL;

+

+	list_for_each_entry(p_dhcp_info, dhcp_info_list, list) {

+		//  printf("[%s] p_dhcp_info:%d\n", __FUNCTION__, p_dhcp_info);

+

+

+		if ((p_dhcp_info->dhcp_info.mac[0] == pEntry->Addr[0]) && (p_dhcp_info->dhcp_info.mac[1] == pEntry->Addr[1]) &&

+		    (p_dhcp_info->dhcp_info.mac[2] == pEntry->Addr[2]) && (p_dhcp_info->dhcp_info.mac[3] == pEntry->Addr[3]) &&

+		    (p_dhcp_info->dhcp_info.mac[4] == pEntry->Addr[4]) && (p_dhcp_info->dhcp_info.mac[5] == pEntry->Addr[5])) {

+

+			return p_dhcp_info;

+

+		}

+	}

+

+

+	return  NULL;

+

+}

+

+/**

+**´¦Àí¹Ì¶¨Ì¨·¢À´µÄÓÃÓÚ»ñÈ¡Á¬½Óµ½APÈȵãµÄÇëÇó

+*/

+void process_get_user_list_req()

+{

+	wlan_mac_info_list mac_list ;

+	

+    int i,result=0;

+	RT_802_11_MAC_TABLE staList             = {0};

+	struct list_head dhcp_info_list;

+	DHCPOFFERADDR_LIST_t * p_dhcp_info   = NULL;

+	INIT_LIST_HEAD(&dhcp_info_list);

+

+	result = zte_get_mac_list_from_lease(&dhcp_info_list);

+	zte_get_wifi_sta_list(&staList);

+	

+	wf_log("staList.Num:%d", staList.Num);

+	if(staList.Num == 0)

+	{

+			wf_msg_to_zcore(MSG_CMD_WIFI_GET_USER_LIST_RSP, 0, NULL);	

+			goto out;

+	}	

+	memset(&mac_list,0,sizeof(wlan_mac_info_list));

+	mac_list.access_count = staList.Num;

+	for (i = 0; i < staList.Num; i++) {

+			sprintf(mac_list.mac_info[i].mac, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X;",\

+				staList.Entry[i].Addr[0], staList.Entry[i].Addr[1],

+				staList.Entry[i].Addr[2], staList.Entry[i].Addr[3],

+				staList.Entry[i].Addr[4], staList.Entry[i].Addr[5]);

+		

+		wf_log("mac %d,is:%s",i,mac_list.mac_info[i].mac);

+		if((p_dhcp_info = find_match_sta(&dhcp_info_list,  &staList.Entry[i])) != NULL)

+		{

+			strncpy(mac_list.mac_info[i].hostname,p_dhcp_info->dhcp_info.host_name,sizeof(p_dhcp_info->dhcp_info.host_name));

+			wf_log("hostname %s",mac_list.mac_info[i].hostname);

+		}					

+

+	}

+	wf_msg_to_zcore(MSG_CMD_WIFI_GET_USER_LIST_RSP, sizeof(wlan_mac_info_list), &mac_list);

+

+

+out:

+	free_dhcp_list(&dhcp_info_list);

+

+}

+#endif

+

+

+

+void wlan_prepare_sleep()

+{

+	int wifi_status = ap_server->ap0_state;

+	int charging_status = g_pre_is_charging;

+	int sta_num = ap_server->g_sta_num;

+	int wps_status = ap_server->ap0_wps_state;

+

+	wf_log ("wifi_status=%d, charging_status=%d, sta_num=%d, wps_status=%d", wifi_status, charging_status, sta_num, wps_status);

+	check_to_presleep (wifi_status, charging_status, sta_num, wps_status);

+}

+

+static void set_globle_charging_status()

+{

+

+	g_pre_is_charging = chargingcheckstates();

+

+	wf_log ("usb charging is %s", g_pre_is_charging ? "YES" : "NO");

+}

+

+void wlan_ap_msg_handle (MSG_BUF *pMsg)

+{

+	char wifi_cur_state[8] = {0};

+

+	cfg_get_item ("wifi_cur_state", wifi_cur_state, sizeof (wifi_cur_state));

+

+	deal_msg_data(pMsg);

+

+	switch (pMsg->usMsgCmd) {

+	case MSG_CMD_WIFI_CFG_AP:

+		basic_deal_all (WIFI_CFG_AP);           //Ö÷SSID ²ÎÊýÉèÖã¬ÖØÆôwlan0

+		break;

+		

+	case MSG_CMD_WIFI_CFG_AP2:

+		basic_deal_all (WIFI_CFG_MSSID);        // m_SSID ²ÎÊýÉèÖÃ

+		break;

+		

+	case MSG_CMD_WIFI_CLOSE:

+	case  MSG_CMD_WIFI_SET_OFF_REQ:// fwp use

+		if ( ap_server->ap0_state) {

+			basic_deal_all (WIFI_CFG_CLOSE);

+		}

+		wf_msg_to_zcore(MSG_CMD_WIFI_SET_OFF_RSP, 0, NULL);

+		break;

+

+	case MSG_CMD_WIFI_OPEN:

+    	case MSG_CMD_WIFI_SET_ON_REQ:  //fwp use

+		wf_log("open wifi");

+		if (! ap_server->ap0_state) {

+			char m_ssid_enable[8] = {0};

+			cfg_get_item ("m_ssid_enable", m_ssid_enable, sizeof (m_ssid_enable));

+			if (1 == atoi (m_ssid_enable)) {

+				basic_deal_all (WIFI_CFG_OPEN_VA0_VA1);

+			} else {

+				basic_deal_all (WIFI_CFG_OPEN);

+			}

+		}

+		wf_msg_to_zcore(MSG_CMD_WIFI_SET_ON_RSP, 0, NULL);

+		break;

+

+// for open cpu start

+	case MSG_CMD_WIFI_CFG_SSID_REQ:

+		basic_deal_all (WIFI_CFG_AP);           //Ö÷SSID ²ÎÊýÉèÖã¬ÖØÆôwlan0

+		ipc_send_message(MODULE_ID_WIFI, pMsg->src_id, MSG_CMD_WIFI_CFG_SSID_RSP, 2, ap_server->ap0_state?"0":"1", 0);

+		

+		break;	

+	case MSG_CMD_WIFI_CFG_PWD_REQ:

+		basic_deal_all (WIFI_CFG_AP);           //Ö÷SSID ²ÎÊýÉèÖã¬ÖØÆôwlan0

+		ipc_send_message(MODULE_ID_WIFI, pMsg->src_id, MSG_CMD_WIFI_CFG_PWD_RSP, 2, ap_server->ap0_state?"0":"1", 0);

+		

+		break;		

+

+	case MSG_CMD_WIFI_SWITCH_REQ:// open cpu  , at ctrl  use

+		wifi_advanced_set (pMsg);

+		wlan_switch_reply(pMsg);

+		break;

+// for open cpu end

+

+		

+	case MSG_CMD_WIFI_ADVANCED:

+		wifi_advanced_set (pMsg);

+		break;

+	case MSG_CMD_WIFI_FORCE_RESTART:// broadcom ,realtek need, form netlink msg

+		//ÔÚ wifi firmware crashºóµÄÖØÆôÁ÷³Ì£¬²»ÔÊÐíwebui·¢ËÍÏûÏ¢ÏÂÀ´£¬ËùÒÔ½«RadioOffÖÃ0

+		//cfg_set("wifi_cur_state", WIFI_CLOSED);

+		//cfg_set("RadioOffException", "0");// ·¢ÏûÏ¢µÄÔ´Í··¢ÉúÁË Òì³£¹Ø±ÕwifiÇé¿ö

+		basic_deal_all (WIFI_CFG_FORCE_RESTART);

+		break;

+	case MSG_CMD_WIFI_SLEEP:

+		cancel_all_timer();

+		wlan_prepare_sleep();

+		break;

+	case MSG_CMD_WIFI_COVERAGE:

+		basic_deal_all (WIFI_CFG_RF);

+		break;

+	case MSG_CMD_WIFI_MAC:

+		//remove_all_acl_timer();

+		set_mac_access();

+		break;

+	case MSG_CMD_WIFI_CHANNEL_FOLLOW:

+		basic_deal_all (WIFI_CFG_CHANNEL_FOLLOW);

+		break;

+#if  (PRODUCT_TYPE == PRODUCT_PHONE)			

+    /*¹Ì¶¨Ì¨ÏûÏ¢´¦Àí¿ªÊ¼*/

+	case MSG_CMD_WIFI_GET_STATE_REQ:

+		wf_msg_to_zcore(MSG_CMD_WIFI_GET_STATE_RSP, sizeof(wifi_cur_state), wifi_cur_state);

+		break;

+	case MSG_CMD_WIFI_GET_INFO_REQ:

+		process_get_wifi_info();

+		break;

+	case MSG_CMD_WIFI_GET_USER_LIST_REQ:

+        	process_get_user_list_req();

+	    	break;

+	case MSG_CMD_WIFI_SET_SECURITY_REQ:

+		basic_deal_all (WIFI_CFG_AP);           //Ö÷SSID ²ÎÊýÉèÖã¬ÖØÆôwlan0

+		break;

+#endif		

+	case MSG_CMD_AP_STA_CONNECTED:

+		add_sta_mac(pMsg->aucDataBuf);

+		break;

+	case MSG_CMD_AP_STA_DISCONNECTED:

+		remove_sta_mac(pMsg->aucDataBuf);

+		//wlan_prepare_sleep();

+		break;

+

+	/*¹Ì¶¨Ì¨ÏûÏ¢´¦Àí½áÊø*/

+	case MSG_CMD_WIFI_WPS:

+		wifi_wps_set (pMsg);

+		break;

+	case MSG_CMD_WIFI_WPS_DOWN:

+#ifdef __REALTEK_8192_CHIP__

+		handle_wps_mac (pMsg);

+		handle_wps_result (pMsg);

+#endif

+		wps_down (pMsg);

+		wlan_prepare_sleep();

+		break;

+	case MSG_CMD_WIFI_WPS_UP:

+		wps_up();

+		wlan_prepare_sleep();

+		break;

+	case MSG_CMD_WIFI_TSW_SET:

+		handle_tsw_setting();       //·Ö±ð¼ÆËã˯Ãß»½ÐÑʱ¼ä£¬ÉèÖö¨Ê±Ë¯Ãß»½ÐÑÏà¹Ø¶¨Ê±Æ÷

+		break;

+	case MSG_CMD_WIFI_TSW_CLOSE:

+		handle_tsw_close();         //ɾ³ý¶¨Ê±Ë¯Ãß»½ÐѶ¨Ê±Æ÷

+		break;

+	case MSG_CMD_RTC_TIME_UPDATE:

+		handle_tsw_setting();       //rtc ʱ¼ä¸üкó£¬ÐèÒªÖØÐÂÉ趨ʱ¼ä

+		break;

+	case MSG_CMD_WIFI_RESET_TIMER:

+		wlan_reset_sleep_timer();

+		break;

+	case MSG_CMD_USB_CHARGING_CHANGED:

+		usb_charging_changed();

+		break;

+	case MSG_CMD_WIFI_NOTIFY_CHARGER_STATUS:

+		fwp_charging_changed(*(UINT32*)pMsg->aucDataBuf);

+		break;	

+	case MSG_CMD_STA_COUNT_CHANGE:

+#ifdef __REALTEK_8192_CHIP__

+		captureWlanStaInfo();

+#endif

+		wf_msg_to_mmi(MSG_CMD_STA_COUNT_CHANGE, 0, NULL);

+		wlan_prepare_sleep();

+		break;

+	case RTC_MSG_ALARM_ELAPSED:

+		process_rtc_elapsed (pMsg);

+		break;

+	case MSG_CMD_WIFI_STATION_CONNECTED_ENABLE_AP_CMD:

+		basic_deal_all (WIFI_CFG_APSTA_OPEN_AP);

+		break;

+	default:

+		break;

+	}

+}

+

+

+#endif

+/*R1682 wifiÊÊÅä´úÂë end*/

+

+//¼ì²éwifiÍø¿ÚÊÇ·ñ´æÔÚ£¬´æÔÚʱ״̬ÊÇ·ñΪLink

+int check_wlan (void)

+{

+	int find_wlan = -1;

+	int i = 0, sum = 0;

+

+	while (-1 == find_wlan) {

+		wf_log ("finding wlan  i=%d, %d s...", i , sum);

+		find_wlan = wfsystem ("ifconfig wlan0");

+		if (-1==find_wlan) {

+			if (sum >= 60)

+				return  -1;

+			sum += 2 * i;

+			sleep (2 * i++);

+		}

+	}

+	return 0;

+}

+static const char* cmdid_to_string (int status)

+{

+	switch (status) {

+		CASE_RETURN_STR (MSG_CMD_WIFI_CFG_AP); //ÉèÖÃÖ÷ssidµÄ»ù±¾²ÎÊýµÄÏûÏ¢

+		CASE_RETURN_STR (MSG_CMD_WIFI_CFG_AP2);                  //ÉèÖø±ssidµÄ»ù±¾²ÎÊýµÄÏûÏ¢

+		CASE_RETURN_STR (MSG_CMD_WIFI_CLOSE);                   //¹Ø±ÕwifiµÄÏûÏ¢

+		CASE_RETURN_STR (MSG_CMD_WIFI_OPEN);                    //¿ªÆôwifiµÄÏûÏ¢

+		CASE_RETURN_STR (MSG_CMD_WIFI_FORCE_RESTART);                 //ÖØÆôwifiµÄÏûÏ¢

+		CASE_RETURN_STR (MSG_CMD_WIFI_ADVANCED);                //wifiµÄ¸ß¼¶²ÎÊýÉèÖÃÏûÏ¢

+		CASE_RETURN_STR (MSG_CMD_WIFI_WPS);                     //¿ªÆôWPS¹¦ÄÜ£¬2·ÖÖÓ×Ô¶¯¹Ø£¬¹Ê²»ÐèÒª¹Ø±ÕÏûÏ¢

+		CASE_RETURN_STR (MSG_CMD_WIFI_WPS_UP);                  //WPSÄ£¿é·¢À´µÄWPSÆô¶¯µÄÏûÏ¢

+		CASE_RETURN_STR (MSG_CMD_WIFI_WPS_DOWN);                //WPSÄ£¿é·¢À´µÄWPS ¹Ø±ÕµÄÏûÏ¢

+		CASE_RETURN_STR (MSG_CMD_WIFI_SLEEP);                   //WEBUIÉèÖÃ˯Ãßʱ³¤µÄÏûÏ¢

+		CASE_RETURN_STR (MSG_CMD_CAPTURE_STATION);              //²éѯstaµÄÁ¬½ÓÇé¿ö

+		CASE_RETURN_STR (MSG_CMD_WIFI_COVERAGE);                //ÉèÖÃwifiµÄ¸²¸Ç·¶Î§

+		CASE_RETURN_STR (MSG_CMD_WIFI_MAC);                     //ÉèÖÃmac¹ýÂ˹¦ÄÜ

+		CASE_RETURN_STR (MSG_CMD_WIFI_CHANNEL_FOLLOW);          //ÉèÖÃwifi APÐŵÀ¸úËæSTA

+		CASE_RETURN_STR (MSG_CMD_USB_CHARGING_CHANGED);         //Çý¶¯¼ì²âµ½usb³äµç״̬±ä»¯Éϱ¨ÏûÏ¢

+		//for apstation

+		CASE_RETURN_STR (MSG_CMD_WIFI_STATION_OPEN);            //´ò¿ªapsta¹¦ÄÜ

+		CASE_RETURN_STR (MSG_CMD_WIFI_STATION_CLOSE);           //¹Ø±Õapsta¹¦ÄÜ

+		CASE_RETURN_STR (MSG_CMD_WIFI_STATION_CLOSE_OPEN_MSSID); //´ò¿ªapsta£¬¹Ø±Õ¶àssid

+		CASE_RETURN_STR (MSG_CMD_WIFI_STATION_SCAN);            //ɨÃèÈȵã

+		CASE_RETURN_STR (MSG_CMD_WIFI_STATION_CONNECT);         //Á¬½ÓÈȵã

+		CASE_RETURN_STR (MSG_CMD_WIFI_STATION_CONNECT_TIMEOUT); //Á¬½Ó³¬Ê±µÄ´¦ÀíÏûÏ¢

+

+		CASE_RETURN_STR (MSG_CMD_WIFI_STATION_SIM_INIT_TIMER_PROCESS);        //eap-sim/aka¹¦ÄÜ£¬²éѯsim¿¨ÓÐÎÞÆôÓõĶ¨Ê±Æ÷ÏûÏ¢

+		CASE_RETURN_STR (MSG_CMD_WIFI_STATION_GET_SCAN_RESULTS); // wpa_supplicantÖ÷¶¯É¨Ãè8sÒ»´Î

+		CASE_RETURN_STR (MSG_CMD_WIFI_STATION_DISCONNECT);                    //Ö÷¶¯¶Ï¿ªÕýÔÚÁ¬½ÓµÄÈȵã

+		CASE_RETURN_STR (MSG_CMD_WIFI_STATION_SPOT_UPDATE);                   //¸üÐÂÈȵãÁбí

+		CASE_RETURN_STR (MSG_CMD_WIFI_STATION_EVENT_CONNECTING);            //wpa_supplicantÕýÔÚ³¢ÊÔÁ¬½ÓʼþÏûÏ¢

+		CASE_RETURN_STR (MSG_CMD_WIFI_STATION_EVENT_CONNECTED);               //apstaÓëÈȵãÁ¬½Ó³É¹¦Í¨ÖªÏûÏ¢

+		CASE_RETURN_STR (MSG_CMD_WIFI_STATION_EVENT_DISCONNECTED);            //apstaÓëÈȵã¶Ï¿ªÁ¬½Ó֪ͨÏûÏ¢

+		CASE_RETURN_STR (MSG_CMD_WIFI_STATION_BLC_CONNECTED);               //blc·¢Ë͵ÄÁ¬½Ó³É¹¦£¬stationµÄipÒÑ·ÖÅäµ½

+		CASE_RETURN_STR (MSG_CMD_BLC_OPEN_WIFISTATION_ACCESS);                //blc·¢À´ÏûÏ¢´ò¿ªapstaÁ¬½Ó

+		CASE_RETURN_STR (MSG_CMD_BLC_CLOSE_WIFISTATION_ACCESS);               //blc·¢À´ÏûÏ¢¶Ï¿ªapstaÁ¬½Ó

+		CASE_RETURN_STR (MSG_CMD_WIFI_STATION_NO_AVAILABLE_AP);

+//	CASE_RETURN_STR(MSG_CMD_WIFI_STATION_PROCESS_TRYING_ASSOC);

+		CASE_RETURN_STR(MSG_CMD_WIFI_STATION_TEMP_DISABLED);

+		CASE_RETURN_STR(MSG_CMD_WIFI_STATION_FAILED_SET);

+

+		CASE_RETURN_STR (MSG_CMD_WIFI_STATION_END);                           //apstationµÄÏûÏ¢·¶Î§end

+		//timing of sleep wake up

+		CASE_RETURN_STR (MSG_CMD_WIFI_TSW_SET);        //ÉèÖö¨Ê±Ë¯Ãß»½ÐѵÄÏûÏ¢

+		CASE_RETURN_STR (MSG_CMD_WIFI_TSW_CLOSE);      //¹Ø±Õ¶¨Ê±Ë¯Ãß»½Ðѹ¦ÄܵÄÏûÏ¢

+		CASE_RETURN_STR (MSG_CMD_RTC_TIME_UPDATE);     //rtcʱ¼ä ¸üÐÂÐèÖØÐÂÉèÖö¨Ê±Ë¯Ãß»½ÐÑ

+		CASE_RETURN_STR (MSG_CMD_WIFI_RESET_TIMER);    //mmi°´¼üÖØÐÂÉèÖÃ˯Ãßtimer

+		CASE_RETURN_STR (RTC_MSG_ALARM_ELAPSED);    //mmi°´¼üÖØÐÂÉèÖÃ˯Ãßtimer

+		CASE_RETURN_STR (MSG_CMD_STA_COUNT_CHANGE);

+		CASE_RETURN_STR (MSG_CMD_CSIM_AUTH_RSP);

+		CASE_RETURN_STR (MSG_CMD_CARD_MODE_RSP);

+		CASE_RETURN_STR (MSG_CMD_PIN_STATUS_RSP);

+		CASE_RETURN_STR (MSG_CMD_PIN_VERIFY_RSP);

+		CASE_RETURN_STR (MSG_CMD_PIN_NUM_RSP);

+		CASE_RETURN_STR (MSG_CMD_CRSM_RSP);

+		CASE_RETURN_STR (MSG_CMD_CIMI_RSP);

+		CASE_RETURN_STR (MSG_CMD_WIFIKEY_SET_RSP);

+		CASE_RETURN_STR (MSG_CMD_NET_WAN_DIAL_FAIL);

+		CASE_RETURN_STR (MSG_CMD_WIFI_SWITCH_REQ);

+		CASE_RETURN_STR (MSG_CMD_WIFI_SWITCH_RSP);

+		CASE_RETURN_STR (MSG_CMD_WIFI_CFG_SSID_REQ);

+		CASE_RETURN_STR (MSG_CMD_WIFI_CFG_SSID_RSP);

+		CASE_RETURN_STR (MSG_CMD_WIFI_CFG_PWD_REQ);

+		CASE_RETURN_STR (MSG_CMD_WIFI_CFG_PWD_RSP);

+		CASE_RETURN_STR (MSG_CMD_WIFI_SET_ON_REQ);				//´ò¿ªWiFiÇåÇó

+		CASE_RETURN_STR (MSG_CMD_WIFI_SET_ON_RSP);				//´ò¿ªWiFi»ØÓ¦

+		CASE_RETURN_STR (MSG_CMD_WIFI_SET_OFF_REQ);				//¹Ø±ÕWiFiÇåÇó

+		CASE_RETURN_STR (MSG_CMD_WIFI_SET_OFF_RSP);				//¹Ø±ÕWiFi»ØÓ¦

+		CASE_RETURN_STR (MSG_CMD_WIFI_SET_SECURITY_REQ);			//ÉèÖÃWiFi°²È«Ä£Ê½¡¢SSID¡¢ÃÜÂëÇëÇó

+		CASE_RETURN_STR (MSG_CMD_WIFI_SET_SECURITY_RSP);			//ÉèÖÃWiFi°²È«Ä£Ê½¡¢SSID¡¢ÃÜÂë»ØÓ¦

+

+		CASE_RETURN_STR (MSG_CMD_WIFI_GET_STATE_REQ); 			//»ñÈ¡WiFi״̬(¿ª¹Ø)ÇëÇó

+		CASE_RETURN_STR (MSG_CMD_WIFI_GET_STATE_RSP); 			//»ñÈ¡WiFi״̬(¿ª¹Ø)»ØÓ¦

+		CASE_RETURN_STR (MSG_CMD_WIFI_GET_INFO_REQ);				//»ñÈ¡WiFiÐÅÏ¢(SSID¡¢ÃÜÂë¡¢°²È«Ä£Ê½)ÇëÇó

+		CASE_RETURN_STR (MSG_CMD_WIFI_GET_INFO_RSP);				//»ñÈ¡WiFiÐÅÏ¢(SSID¡¢ÃÜÂë¡¢°²È«Ä£Ê½)»ØÓ¦

+		CASE_RETURN_STR (MSG_CMD_WIFI_GET_USER_LIST_REQ); 		//»ñÈ¡WiFiÓû§ÁбíÇëÇó

+		CASE_RETURN_STR (MSG_CMD_WIFI_GET_USER_LIST_RSP); 		//»ñÈ¡WiFiÓû§ÁÐ±í»ØÓ¦

+		CASE_RETURN_STR (MSG_CMD_WIFI_NOTIFY_CHARGER_STATUS);

+		CASE_RETURN_STR (MSG_CMD_WIFI_STATION_SUPPLICANT_EVT);		

+		CASE_RETURN_STR (MSG_CMD_WIFI_STATION_INDICATE_SCAN_RESULTS);

+		CASE_RETURN_STR (MSG_CMD_WIFI_STATION_FORGET);

+		CASE_RETURN_STR (MSG_CMD_WIFI_STATION_DEBUG_DUMP);

+		CASE_RETURN_STR (MSG_CMD_WIFI_STATION_WPA_CMD);

+		CASE_RETURN_STR (MSG_CMD_AP_STA_CONNECTED);

+		CASE_RETURN_STR (MSG_CMD_AP_STA_DISCONNECTED);

+		CASE_RETURN_STR (MSG_CMD_WIFI_STATION_CONNECTED_ENABLE_AP_CMD);

+

+

+	};

+	return "UNKNOWN  CMD ID";

+}

+

+static const char* modid_to_string (int status)

+{

+	switch (status) {

+		CASE_RETURN_STR (MODULE_ID_WEB_CGI);           /* 0x1001  WEB CGIÄ£¿éµÄÏûÏ¢¶ÓÁÐID*/

+		CASE_RETURN_STR (MODULE_ID_WIFI);              /*0x 1003 wifi control*/

+		CASE_RETURN_STR (MODULE_ID_WLAN_SERVER);       /* 0x1004 wifi×Ô¼º¸ø×Ô¼º·¢ÏûÏ¢¶¨ÒåµÄmsg id*/

+		CASE_RETURN_STR (MODULE_ID_MMI);               //0x 1005 add by wuhong for ufi MMI

+		CASE_RETURN_STR (MODULE_ID_RTC_SERVICE);  //0x1007

+		CASE_RETURN_STR (MODULE_ID_AT_CTL);    			/*0x1021 at ctlÄ£¿éID*/

+		CASE_RETURN_STR (MODULE_ID_MAIN_CTRL);         /*0x1028 Ö÷¿ØÄ£¿éID*/

+		CASE_RETURN_STR (MODULE_ID_ZSSID);             /*0x1029 zte_ssid added by zhangnan00123908 20131121*/

+		CASE_RETURN_STR (MODULE_ID_WPA_SUPPLICANT);  //0x102D

+		CASE_RETURN_STR (MODULE_ID_ZCORE);  //0x2003

+		CASE_RETURN_STR (MODULE_ID_MMI_SVR);  //0x2003

+	}

+	return "UNKNOWN  Module ID";

+}

+

+/**************************************************************************

+* description of function:  wlan deal queue

+* input parameter: pstMsg:message content

+* return value: 0:success -1:error

+* zhaoyong set up this function

+**************************************************************************/

+int wifi_parse_msg (MSG_BUF *pMsg)

+{

+	int ret = -1;

+	wf_log ("src_mod=[0x%x]%s, cmd=[0x%x]%s", pMsg->src_id, modid_to_string (pMsg->src_id),

+	        pMsg->usMsgCmd, cmdid_to_string (pMsg->usMsgCmd));

+

+	if (pMsg->ulMagic != MSG_MAGIC_WORD) {

+		wf_log ("pstMsg magic error");

+		return -1;

+	} else if (pMsg->dst_id != MODULE_ID_WIFI) {

+		wf_log ("target is not wlan pstMsg->dst_id is %x", pMsg->dst_id);

+		return -1;

+	}

+

+#if (PRODUCT_TYPE == PRODUCT_PHONE)//kw3 

+	if(pMsg->usMsgCmd != MSG_CMD_WIFI_RESET_TIMER &&

+	   pMsg->usMsgCmd != MSG_CMD_USB_CHARGING_CHANGED &&

+	   pMsg->usMsgCmd != MSG_CMD_WIFI_NOTIFY_CHARGER_STATUS )

+		check_wifi_mac();

+#else

+	if(pMsg->usMsgCmd != MSG_CMD_WIFI_RESET_TIMER &&

+	   pMsg->usMsgCmd != MSG_CMD_USB_CHARGING_CHANGED)

+		check_wifi_mac();

+

+#endif

+

+#ifdef __STA_FUNC__

+	ret = wlan_sta_parse_msg(pMsg);

+#endif

+

+#ifdef __AP_FUNC__

+#ifdef __STA_FUNC__ //kw 3

+	if(-1 == ret)// sta not deal the msg

+#endif

+		wlan_ap_msg_handle (pMsg);

+#endif

+

+	if(pMsg->usMsgCmd != MSG_CMD_WIFI_RESET_TIMER && 

+		pMsg->usMsgCmd != MSG_CMD_USB_CHARGING_CHANGED &&

+		pMsg->usMsgCmd != MSG_CMD_AP_STA_CONNECTED &&

+		pMsg->usMsgCmd != MSG_CMD_STA_COUNT_CHANGE &&

+		pMsg->usMsgCmd != MSG_CMD_AP_STA_DISCONNECTED &&

+		pMsg->usMsgCmd != MSG_CMD_WIFI_WPS_DOWN &&

+		pMsg->usMsgCmd != MSG_CMD_WIFI_STATION_GET_SCAN_RESULTS &&

+		pMsg->usMsgCmd != MSG_CMD_WIFI_STATION_NO_AVAILABLE_AP &&

+		pMsg->usMsgCmd != MSG_CMD_WIFI_STATION_CONNECTED_ENABLE_AP_CMD &&

+		pMsg->usMsgCmd != MSG_CMD_WIFI_STATION_EVENT_CONNECTED &&

+		pMsg->usMsgCmd != MSG_CMD_WIFI_STATION_EVENT_DISCONNECTED &&

+		pMsg->usMsgCmd != MSG_CMD_WIFI_STATION_EVENT_CONNECTING &&

+		pMsg->usMsgCmd != MSG_CMD_WIFI_STATION_TEMP_DISABLED &&

+		pMsg->usMsgCmd != MSG_CMD_WIFI_STATION_FAILED_SET &&

+		pMsg->usMsgCmd != MSG_CMD_WIFI_STATION_CONNECT_TIMEOUT &&

+		pMsg->usMsgCmd != MSG_CMD_WIFI_STATION_BLC_CONNECTED &&

+		pMsg->usMsgCmd != MSG_CMD_BLC_CLOSE_WIFISTATION_ACCESS &&

+		pMsg->usMsgCmd != MSG_CMD_BLC_OPEN_WIFISTATION_ACCESS)

+		cfg_save();

+	return 0;

+}

+

+

+

+/*sig handler*/

+static void sig_handler(int sig)

+{

+	wf_log("receive signal %d\n", sig);

+

+    if((sig == SIGINT) || (sig == SIGTERM)) {

+        wf_log("receive signal %d\n", sig);

+        exit(0);

+    }

+	else if(sig == SIGUSR1)

+	{

+/**

+@@@@	deal the wifi sleep problem

+1. not sleep

+2. delay the sleep

+3. sleep adhead of time

+**/

+		wf_log("receive signal SIGUSR1 %d\n", sig);

+

+	}

+}

+

+

+static void sig_init(void)

+{

+    pthread_t tid = pthread_self();

+    wf_log("tid:%lu", tid);

+    struct sigaction sigact;

+    int ret;

+    sigset_t signal_mask;

+    sigemptyset(&signal_mask);

+    sigaddset(&signal_mask, SIGPIPE);

+    ret = pthread_sigmask(SIG_BLOCK, &signal_mask, NULL);

+    if(ret != 0) {

+        wf_log("block SIGPIPE error\n");

+    }

+

+    sigact.sa_handler = sig_handler;

+    sigact.sa_flags = 0;

+    sigemptyset(&sigact.sa_mask);

+    sigaction(SIGINT, &sigact, NULL);

+    sigaction(SIGTERM, &sigact, NULL);

+    sigaction(SIGUSR1, &sigact, NULL);

+

+    /*ignore SIGPIPE*/

+    sigact.sa_handler = SIG_IGN;

+    sigaction(SIGPIPE, &sigact, NULL);

+

+}

+

+

+void check_wifi_mac()

+{

+	char  wifi_mac[20] = {0};

+	int   i = 0;

+	

+	cfg_get_item("wifi_mac", wifi_mac, sizeof(wifi_mac));

+

+	if(strlen(wifi_mac)==0){

+		for(i=0; i < 50; i++){

+			wf_log ("############################################################");

+			wf_log ("####  Please set a globally unique Valid MAC by UeTester                 ");

+			wf_log ("####   watch:   at+mac=xxxxxxxxxxxx,                                                ");

+			wf_log ("####   mifi:   at+mac=xxxxxxxxxxxx,    at+mac2=xxxxxxxxxxxx            ");

+			wf_log ("####   MAC address length  is 12 bytes, can not be all of 0 or  F         ");

+			wf_log ("####   MAC address can not be a broadcast address                           ");

+			wf_log ("############################################################\n");

+			sleep (6);

+		}

+		softap_assert("Please set a globally unique Valid MAC by UeTester,  at+mac=xxxxxxxxxxxx!!!");

+	}

+}

+

+

+void init_config()

+{

+	cfg_set ("WscModeOption", "0");

+	cfg_set ("wifiSleep", "0");

+	cfg_set ("wifi_root_dir", "/etc_rw");

+	cfg_set ("sta_count", "0");

+	cfg_set ("m_sta_count", "0");

+	cfg_set ("sleep_debug", "0");

+	//cfg_set("sta_ip_status", "disconnect");

+	//cfg_set("scan_finish", "0");

+	//cfg_set("EX_APLIST", "");

+	//cfg_set("EX_APLIST1", "");

+	//cfg_set("manual_d_wifi", "0");

+	//cfg_set("EX_SSID1", "");

+	//cfg_set("EX_AuthMode", "");

+	//cfg_set("EX_EncrypType", "");

+	//cfg_set("EX_DefaultKeyID", "");

+	//cfg_set("EX_WEPKEY", "");

+	//cfg_set("EX_WPAPSK1", "");

+	//cfg_set("EX_wifi_profile", "");

+	//cfg_set("EX_mac", "");

+

+	cfg_set ("wpa_supplicant", "stop");

+	cfg_set ("wifi_cur_state", WIFI_CLOSED);

+#if (PRODUCT_TYPE == PRODUCT_MIFI_CPE)

+	cfg_set ("wifiEnabled", "1");

+#elif (PRODUCT_TYPE == PRODUCT_PHONE)

+	cfg_set ("wifiEnabled", "0");//yaoyuan special need:everytime system wakes up, wifi is off

+#else

+	cfg_set ("wifiEnabled", "0");

+#endif

+

+	ensure_config_dir_exist(WIFI_DIR);

+}

+

+

+int wlan_main (int argc, char *argv[])

+{

+	int wlan_msg_queue_id = 0;

+	int iRet = -1;

+	MSG_BUF wlanMsg={0};

+	int threadid = 0;

+	char wifiEnabled[8] = {0};

+	prctl(PR_SET_NAME, "wlan", 0, 0, 0);

+//the first step,  log  and envirenment init

+	loglevel_init();

+	wf_log ("wlan-server start, build time:[%s %s]", __DATE__,__TIME__);

+	sig_init();

+#ifdef __AP_FUNC__

+#ifdef __USE_AES__

+	wifi_aes_init_key();

+	if (2 == wifi_decrypt_code())

+		wifi_encrypt_code();

+#else

+	wifi_decode_b2s();

+#endif	

+#endif

+

+#if !(defined(__ESP_8089_CHIP__))

+	send_get_mac_req();

+#endif

+	

+//second step, nv init, ssid and wifi_mac init

+	//create main thread msg queue id

+	wlan_msg_queue_id = wf_create_msg_qid (MODULE_ID_WIFI);

+#ifdef __STA_FUNC__	

+	sem_init (&g_wpa_supplicant_id, 0 , 0);

+#endif

+#ifdef __AP_FUNC__

+	#ifndef __REALTEK_8192_CHIP__

+	sem_init (&g_hostap_id, 0 , 0);

+	#endif

+#endif

+

+

+	init_config();

+#if !(defined(__ESP_8089_CHIP__))

+	get_mac_config_ssid_key_nv();

+#endif

+

+#ifdef __AP_FUNC__	

+#if  defined( __RDA_5995_CHIP__)

+	ap_server = 	&rda5995_ap;

+#elif defined(__ESP_8089_CHIP__)

+	ap_server = 	&esp8089_ap;

+#elif defined(__REALTEK_8192_CHIP__)

+	ap_server = 	&realtek_8192_ap;

+#elif defined(__XR_819_CHIP__)

+	ap_server = 	&xr819_ap;

+#elif defined(__SSV_6X5X_CHIP__)

+	ap_server = 	&ssv6x5x_ap;

+#elif defined(__AIC_8800DW_CHIP__)

+	ap_server = 	&aic8800dw_ap;

+#endif

+	/*insmod, and , start hostapd*/

+	ap_server->init(ap_server);

+#endif

+

+#ifdef __STA_FUNC__

+#if  defined( __RDA_5995_CHIP__)

+	sta_manager = 	&rda5995_sta;

+#elif defined(__ESP_8089_CHIP__)

+	sta_manager = 	&esp8089_sta;

+#elif defined(__REALTEK_8192_CHIP__)

+	sta_manager = 	&realtek_sta;

+#elif defined(__SSV_6X5X_CHIP__)

+	sta_manager = 	&ssv6x5x_sta;

+#elif defined(__AIC_8800DW_CHIP__)

+	sta_manager = 	&aic8800dw_sta;

+#endif

+	sta_manager->init(sta_manager);

+#endif

+

+	if (check_wlan() == -1) {

+		wf_log (" wlan0 interface is not exist ,please contact wlan driver engineer");

+		cfg_set("wifi_chip", "0");

+		cfg_save();

+		return -1;

+	}

+

+#if defined(__ESP_8089_CHIP__)

+	wifi_fw_mac_config_ssid(ap_server);

+#endif

+

+	wf_log ("wifichip exist, set  nv to tell mmi");

+	cfg_set("wifi_chip", "1");

+	

+

+

+	#ifdef  __STA_FUNC__

+	wlan_statemachine_init();

+	#endif

+

+

+//thrid step,  according wifiEnabled, to open wifi

+

+	cfg_get_item ("wifiEnabled", wifiEnabled, sizeof (wifiEnabled));

+	if (!strcmp (wifiEnabled, "1")) {

+#ifdef __AP_FUNC__

+		wlan_ap_open();

+#endif

+

+#ifdef __STA_FUNC__

+		wlan_station_open();

+#endif

+	}

+	else{

+		wf_log ("rda5995 to rmmod");

+#if  defined( __RDA_5995_CHIP__)

+		sta_manager->drv_proxy.drv_deinit(&sta_manager->drv_proxy);

+#endif		

+	}

+

+#ifdef __AP_FUNC__		

+	qrcode_make();	

+	set_globle_charging_status();

+	wlan_prepare_sleep();

+	handle_tsw_setting();				//ÉèÖö¨Ê±Ë¯Ãß»½ÐÑ

+#endif

+

+

+#if  defined  ( __RDA5995_WIFI_CHIP__) && (PRODUCT_TYPE == PRODUCT_PHONE)	

+	wf_msg_to_zcore(MSG_CMD_WIFI_IS_READY, 0, NULL);  //wifiÆô¶¯ºó֪ͨ¹Ì¶¨Ì¨ÏÔʾwifi״̬

+#endif

+

+	//wf_create_thread ("netlink", netlink_loop);

+	hotplug_parse_register(DEVICE_TYPE_APP_WIFI, wifi_app_msg_parse);

+

+#ifdef  __STA_FUNC__

+	wf_create_thread ("wlan-station", station_loop);

+#endif

+

+#ifdef __AP_FUNC__	

+#ifndef __REALTEK_8192_CHIP__

+	wf_create_thread ("hostap", hostap_loop);

+#if defined(__MULTI_AP__)

+	wf_log ("hostap_multi thread create");

+	wf_create_thread ("hostap_multi", hostap_loop_multi);

+#endif

+

+#endif

+#endif

+

+	wf_log (" main thread getpid=%d", getpid());

+

+	//prctl(PR_SET_NAME, "wlan-main", 0, 0, 0);

+	while (1) {

+		memset (&wlanMsg, 0, sizeof (MSG_BUF));

+		iRet = msgrcv (wlan_msg_queue_id, &wlanMsg, sizeof (MSG_BUF) - sizeof (LONG), 0, 0);

+		if (iRet == -1) {

+			continue;

+		}

+

+		wifi_parse_msg (&wlanMsg);

+	}

+	return 0;

+}

+

+

diff --git a/lynq/S300/ap/app/zte_comm/zte_hotplug/netdev_plug.c b/lynq/S300/ap/app/zte_comm/zte_hotplug/netdev_plug.c
new file mode 100644
index 0000000..170b93c
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/zte_hotplug/netdev_plug.c
@@ -0,0 +1,765 @@
+#include "hotplug.h"
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <net/if_arp.h>
+#include "libcpnv.h"
+#include "RONvParam_AMT.h"
+
+
+/*
+ĿǰRJ45ÈȰβåÏûÏ¢¸ñʽ
+
+[sw0 wan]
+gmackobj: /gmac/gmacconfig
+action:KOBJ_ADD
+envp_ext:GMACEVENT = gmac_sw0_wan
+
+
+add@/gmac/gmacconfig
+ACTION=add
+DEVPATH=/gmac/gmacconfig
+SUBSYSTEM=gmac
+GMACEVENT = gmac_sw0_wan
+
+
+
+gmackobj: /gmac/gmacconfig
+action:KOBJ_REMOVE
+envp_ext:GMACEVENT = gmac_sw0_wan
+
+remove@/gmac/gmacconfig
+ACTION=remove
+DEVPATH=/gmac/gmacconfig
+SUBSYSTEM=gmac
+GMACEVENT = gmac_sw0_wan
+
+
+[sw0 lan]
+gmackobj: /gmac/gmacconfig
+action:KOBJ_ADD
+envp_ext:GMACEVENT = gmac_sw0_lan
+
+add@/gmac/gmacconfig
+ACTION=add
+DEVPATH=/gmac/gmacconfig
+SUBSYSTEM=gmac
+GMACEVENT = gmac_sw0_lan
+
+
+
+gmackobj: /gmac/gmacconfig
+action:KOBJ_REMOVE
+envp_ext:GMACEVENT = gmac_sw0_lan
+
+remove@/gmac/gmacconfig
+ACTION=remove
+DEVPATH=/gmac/gmacconfig
+SUBSYSTEM=gmac
+GMACEVENT = gmac_sw0_lan
+
+
+[ eth0 ]
+gmackobj: /gmac/gmacconfig
+action:KOBJ_ADD
+envp_ext:GMACEVENT = gmac_eth0
+
+add@/gmac/gmacconfig
+ACTION=add
+DEVPATH=/gmac/gmacconfig
+SUBSYSTEM=gmac
+GMACEVENT = gmac_eth0
+
+
+gmackobj: /gmac/gmacconfig
+action:KOBJ_REMOVE
+envp_ext:GMACEVENT = gmac_eth0
+
+remove@/gmac/gmacconfig
+ACTION=remove
+DEVPATH=/gmac/gmacconfig
+SUBSYSTEM=gmac
+GMACEVENT = gmac_eth0
+
+*/
+
+
+
+/*USB [rj45]*/
+#define RJ45_ONLINE_MESSAGE       "online@/devices/platform/zx297520_usb.0/usb1/1-1"
+#define RJ45_OFFLINE_MESSAGE      "offline@/devices/platform/zx297520_usb.0/usb1/1-1"
+//#define RJ45_PLUG_STATE_PATH      "/sys/kernel/eth_debug/eth_state"     /*ͨ¹ýnv  rj45_plugstate_path´æ´¢*/
+
+/*USB¿Ú״̬Îļþ£¬Í¨¹ýnv´æ´¢*/
+/*ÓÃusb_name_path´úÌæ£¬ÀïÃæ´æ´¢²åÈëµÄusb¿ÚÃû³Æ£¬¸ñʽÈç: usblan0;usblan1;usblan2*/
+//#define RNDIS_NAME_FILE_PATH      "/sys/dwc_usb/usbconfig/netname"
+
+/*usbÍø¿Ú״̬ÎļþËùÔÚ·¾¶*/
+//#define USB_PLUG_STATE_PATH       "/sys/dwc_usb/usbconfig/"
+
+
+/*ÍâÍø¿Ú²åÈë״̬*/
+#define WAN_PLUG_OUT   0
+#define WAN_PLUG_IN    1
+
+
+typedef enum {
+	RJ45_WAN_LAN_OFF = 0,		/*rj45 ÄÚÍâÍø¾ù°Î³ö*/
+	RJ45_WAN_ON_LAN_OFF,        /*rj45ÍâÍø¿Ú²åÈ룬ÄÚÍø¿Ú°Î³ö*/
+	RJ45_WAN_OFF_LAN_ON,        /*RJ45ÄÚÍø¿Ú²åÈ룬ÍâÍø¿Ú°Î³ö*/
+	RJ45_WAN_LAN_ON,            /*rj45ÄÚÍâÍø¿Ú¾ù²åÈë*/
+	RJ45_LAN_OFF,               /*rj45ÄÚÍø¿Ú°Î³ö£¬Ä¿Ç°Î´Ê¹ÓÃ*/
+	RJ45_LAN_ON,                /*rj45ÄÚÍø¿Ú²åÈ룬ĿǰδʹÓÃ*/
+	RJ45_INVALID,               /*ÎÞЧ״̬*/
+	RJ45_STATE_MAX,
+};
+
+/*rj45״̬ÎļþÖÐ´æ´¢Íø¿Ú״̬×Ö·û´®*/
+static const char *rj45_state_str[] = {
+	[RJ45_WAN_LAN_OFF]    = "wan_lan_off",
+	[RJ45_WAN_ON_LAN_OFF] = "wan_on_lan_off",
+	[RJ45_WAN_OFF_LAN_ON] = "wan_off_lan_on",
+	[RJ45_WAN_LAN_ON]     = "wan_lan_on",
+	[RJ45_LAN_OFF]        = "lan_off",
+	[RJ45_LAN_ON]         = "lan_on",
+	[RJ45_INVALID]   = "invalid",
+};
+
+
+char usbdev_name[1024] = {0};
+
+/*±ê¼ÇÍø¿ÚÀàÐÍ£¬1:eth0¿Ú£¬0:sw¿Ú*/
+int  rj45_eth0 = 0;
+
+static inline int read_file(char *path, char *buf, int len)
+{
+	FILE *fp = NULL;
+	int msglen = 0;
+
+	if ((fp = fopen(path, "r")) != NULL) {
+		msglen = fread(buf, 1, len, fp);
+		fclose(fp);
+		return msglen;
+	}
+
+	return -1;
+}
+
+static int parse_string(char *str, char split, char out_str[][20], int max_num)
+{
+	char *curr = NULL;
+	char *prev = NULL;
+	char *tail = NULL;
+	int count = 0;
+
+	prev = str;
+	tail = str + strlen(str);
+
+	if (max_num <= 0)
+		return 0;
+
+
+	while ((curr = strchr(prev, split)) != 0) {
+		strncpy(out_str[count], prev, curr - prev);
+		prev = curr + 1;
+		count++;
+		if (count >= max_num)
+			return count;
+	}
+
+	if (prev < tail) {
+		strncpy(out_str[count], prev, tail - prev);
+		count++;
+	}
+
+	return count;
+}
+
+static char* neutralize(char *path)
+{
+	if(path == NULL)
+	{
+		return NULL;
+	}
+	/* Ïà¶Ô·¾¶·À»¤ */
+	if (strstr(path, "../"))
+	{
+		return NULL;
+	}
+	
+	/* ϵͳ·¾¶·À»¤ */
+	if (strncmp(path, "/etc", 4) == 0)
+	{
+		return NULL;
+	}
+	
+	/* null ·ûºÅ·À»¤*/
+	if (strstr(path, "%00"))
+	{
+		return NULL;
+	}
+
+	return path;
+}
+
+
+/*¼ì²âUSBÉϵç״̬£¬²¢½øÐÐÏàÓ¦µÄplugin/plugout²Ù×÷*/
+static void usb_hotplug_init()
+{
+	char usb_name[64] = {0};
+	char path[160] = {0};//klocwork
+	char state_str[8] = {0};
+	char netif_name[4][20] = {0};
+	char rndis_path[128] = {0};
+	char state_path[128] = {0};
+	int netif_num = 0;
+	int msglen = 0;
+	int state = 0;
+	int i = 0;
+
+	cfg_get_item("usb_name_path", rndis_path, sizeof(rndis_path));
+	cfg_get_item("usb_plugstate_path", state_path, sizeof(state_path));
+
+	msglen = read_file(rndis_path, usb_name, sizeof(usb_name)-1);
+	if (msglen <= 0)
+		return;
+	usb_name[63]=0;
+	slog(NET_PRINT, SLOG_DEBUG, "[%s][%d]read state = %s\n", __func__, __LINE__, usb_name);
+
+	netif_num = parse_string(usb_name, ';', netif_name, 4);
+	if (netif_num > 0) {
+		for (i = 0; i < netif_num; i++) {
+			char *path_t = NULL;
+			memset(state_str, 0, sizeof(state_str));
+			memset(path, 0, sizeof(path));
+			snprintf(path, sizeof(path), "%s/%s", state_path, netif_name[i]);
+			path[159]=0;
+			path_t = neutralize(path); //klocwork
+			if (path_t == NULL) 
+				continue;
+			path_t[159]=0;
+			msglen = read_file(path_t, state_str, sizeof(state_str)-1);
+			if (msglen > 0) {
+				slog(NET_PRINT, SLOG_DEBUG, "[%s][%d]netif_name = %s, state = %s\n", __func__, __LINE__, netif_name[i], state_str);
+
+				state = atoi(state_str);
+				if (1 == state) {
+					netdev_plugin_proc_byname(netif_name[i], MODULE_ID_HOTPLUG);
+				}
+			}
+		}
+	}
+}
+
+
+/*»ñÈ¡rj45¿ÚÉϵç״̬*/
+int rj45_state_get(char *state, int len)
+{
+	int ret = -1;
+	int count = 0;
+
+	if (len && (state[len - 1] == '\n' || state[len - 1] == '\0'))
+		len--;
+
+	if (!len)
+		return -1;
+
+	/*µ¥phy eth0¿Ú״̬*/
+	if (0 == strncmp(state, "0", 1)) { /*°Î³ö*/
+		rj45_eth0 = 1;
+		return RJ45_WAN_LAN_OFF;
+	} else if (0 == strncmp(state, "1", 1)) { /*²åÈë*/
+		rj45_eth0 = 1;
+		return RJ45_WAN_ON_LAN_OFF;
+	} else {
+		/*swÍø¿Ú״̬*/
+		for (count = 0; count < RJ45_STATE_MAX; count++) {
+			if (0 == strncmp(rj45_state_str[count], state, len)) {
+				return count;
+			}
+		}
+	}
+
+	return -1;
+}
+
+/*»ñÈ¡switch rj45¿ÚÉϵç״̬*/
+int rj45_switch_state_get(char *wan_state, int wan_len, char *lan_state, int lan_len)
+{
+	int ret = -1;
+	int count = 0;
+
+	if (wan_len && (wan_state[wan_len - 1] == '\n' || wan_state[wan_len - 1] == '\0'))
+		wan_len--;
+	if (!wan_len)
+		return -1;
+
+	if (lan_len && (lan_state[lan_len - 1] == '\n' || lan_state[lan_len - 1] == '\0'))
+		lan_len--;
+	if (!lan_len)
+		return -1;
+
+	if(0 == strncmp(wan_state, "0", 1) && 0 == strncmp(lan_state, "0", 1))
+	{
+		count = RJ45_WAN_LAN_OFF;
+	}
+	else if(0 == strncmp(wan_state, "1", 1) && 0 == strncmp(lan_state, "0", 1))
+	{
+		count = RJ45_WAN_ON_LAN_OFF;
+	}
+	else if(0 == strncmp(wan_state, "0", 1) && 0 == strncmp(lan_state, "1", 1))
+	{
+		count = RJ45_WAN_OFF_LAN_ON;
+	}
+	else if(0 == strncmp(wan_state, "1", 1) && 0 == strncmp(lan_state, "1", 1))
+	{
+		count = RJ45_WAN_LAN_ON;
+	}
+	else
+	{
+		return -1;
+	}
+
+	return count;
+}
+
+
+
+static inline void rj45_wan_mode_set(char *mode)
+{
+	char wan_mode[32] = {0};
+
+	cfg_get_item("blc_wan_mode", wan_mode, sizeof(wan_mode));
+
+	if (0 == strcmp(wan_mode, "AUTO")) {
+		cfg_set("blc_wan_auto_mode", mode);
+	}
+}
+
+
+/*»ñÈ¡ÍâÍø¿Údevid*/
+int rj45_wan_devid_get(int plug_type)
+{
+	char wan_mode[20] = {0};
+	char wan_auto_mode[20] = {0};
+	int dev_id = -1;
+
+	cfg_get_item("blc_wan_mode", wan_mode, sizeof(wan_mode));
+	cfg_get_item("blc_wan_auto_mode", wan_auto_mode, sizeof(wan_auto_mode));
+
+	/*²åÈë*/
+	if (WAN_PLUG_IN == plug_type) {
+		if (0 == strcmp(wan_mode, "AUTO")) {
+			cfg_set("blc_wan_auto_mode", "AUTO_PPPOE");
+			if (1 == rj45_eth0)
+				dev_id = RJ45_WAN_DEV;
+			else
+				dev_id = SW_WAN_DEV;
+		} else if (0 == strcmp(wan_mode, "PPPOE")) {
+			if (1 == rj45_eth0)
+				dev_id = RJ45_WAN_DEV;
+			else
+				dev_id = SW_WAN_DEV;
+		} else if (0 == strcmp(wan_mode, "PPP")) {
+			/*Èç¹ûΪPSÁªÍø£¬Ôòeth0¼¤»îΪÄÚÍø¿Ú£¬sw0.200²»¼¤»î*/
+			if (1 == rj45_eth0)
+				dev_id = RJ45_LAN_DEV;
+		}
+	} else { /*°Î³ö*/
+		if (0 == strcmp(wan_mode, "PPP")) {
+			if (1 == rj45_eth0)
+				dev_id = RJ45_LAN_DEV;
+		} else {
+			if (0 == strcmp(wan_mode, "AUTO"))
+				cfg_set("blc_wan_auto_mode", "AUTO_PPP");
+
+			if (1 == rj45_eth0)
+				dev_id = RJ45_WAN_DEV;
+			else
+				dev_id = SW_WAN_DEV;
+		}
+	}
+
+	return dev_id;
+}
+
+
+
+/*¼ì²âRJ45Éϵç״̬£¬²¢½øÐÐÏàÓ¦²Ù×÷*/
+void rj45_hotplug_init()
+{
+	char state_str[32] = {0};
+	char wan_state_str[32] = {0};
+	char lan_state_str[32] = {0};
+	char state_path[128] = {0};
+	char wan_state_path[128] = {0};
+	char lan_state_path[128] = {0};
+	char cpe_type[32] = {0};
+	int state_len = 0;
+	int wan_state_len = 0;
+	int lan_state_len = 0;
+	int state;
+	int dev_id = 0;
+
+	cfg_get_item("cpe_type", cpe_type, sizeof(cpe_type));
+	
+	//ÔÝʱֻ¿¼Âǵ¥phyºÍswitch£¬Ã»Óп¼Âǵ¥phy+switchÐÎ̬
+	if(strcmp(cpe_type, "switch") == 0) //switch
+	{		
+		cfg_get_item("rj45_wan_plugstate_path", wan_state_path, sizeof(wan_state_path));
+		if (0 == strcmp(wan_state_path, ""))
+			return;
+		wan_state_len = read_file(wan_state_path, wan_state_str, sizeof(wan_state_str));
+		if (wan_state_len <= 0) {
+			return;
+		}
+			
+		cfg_get_item("rj45_lan_plugstate_path", lan_state_path, sizeof(lan_state_path));
+		if (0 == strcmp(lan_state_path, ""))
+			return;
+		lan_state_len = read_file(lan_state_path, lan_state_str, sizeof(lan_state_str));
+		if (lan_state_len <= 0) {
+			return;
+		}		
+		
+		state = rj45_switch_state_get(wan_state_str, wan_state_len, lan_state_str, lan_state_len);
+		slog(NET_PRINT, SLOG_DEBUG, "[%s][%d]read pht wan_state = %s,lan_state = %s\n", __func__, __LINE__, wan_state_str, lan_state_str);
+	}
+	else //µ¥phy
+	{	
+		cfg_get_item("rj45_plugstate_path", state_path, sizeof(state_path));
+		if (0 == strcmp(state_path, ""))
+			return;
+		state_len = read_file(state_path, state_str, sizeof(state_str));
+		if (state_len <= 0) {
+			return;
+		}
+		state = rj45_state_get(state_str, state_len);
+		
+		slog(NET_PRINT, SLOG_DEBUG, "[%s][%d]read pht state = %s\n", __func__, __LINE__, state_str);
+	}
+	
+
+	if (state < 0 || state == RJ45_INVALID) {
+		return;
+	}
+
+	slog(NET_PRINT, SLOG_DEBUG, "[%s][%d]init state = %d\n", __func__, __LINE__, state);
+
+	switch (state) {
+	case RJ45_WAN_LAN_OFF:
+		rj45_wan_mode_set("AUTO_PPP");
+		break;
+	case RJ45_WAN_ON_LAN_OFF:
+		rj45_wan_mode_set("AUTO_PPPOE");
+		dev_id = rj45_wan_devid_get(WAN_PLUG_IN);
+		if (dev_id >= 0) {
+			slog(NET_PRINT, SLOG_DEBUG, "[%s][%d]dev_id = %d\n", __func__, __LINE__, dev_id);
+			netdev_plugin_proc(dev_id, MODULE_ID_HOTPLUG);
+		}
+		break;
+	case RJ45_WAN_OFF_LAN_ON:
+		rj45_wan_mode_set("AUTO_PPP");
+		netdev_plugin_proc(SW_LAN_DEV, MODULE_ID_HOTPLUG);
+		break;
+	case RJ45_WAN_LAN_ON:
+		rj45_wan_mode_set("AUTO_PPPOE");
+		dev_id = rj45_wan_devid_get(WAN_PLUG_IN);
+		if (dev_id >= 0) {
+			slog(NET_PRINT, SLOG_DEBUG, "[%s][%d]dev_id = %d\n", __func__, __LINE__, dev_id);
+			netdev_plugin_proc(dev_id, MODULE_ID_HOTPLUG);
+		}
+		netdev_plugin_proc(SW_LAN_DEV, MODULE_ID_HOTPLUG);
+		break;
+	default:
+		break;
+	}
+
+	return;
+}
+
+/*½âÎörj45ÈȰβåÏûÏ¢*/
+int rj45_msg_parse(const char *msg, int msglen, struct hotplug_event *event)
+{
+	char buff[UEVENT_BUFFER_SIZE] = {0};
+	int dev_id = 0;
+
+	memcpy(buff, msg, msglen);
+	char_replace(buff, msglen, '\0', '\n');
+
+	switch (event->action) {
+	case KOBJ_ADD:
+	case KOBJ_REMOVE:
+		if (strstr(buff, "gmac/gmacconfig")) {
+			if (strstr(buff, "gmac_eth_sw_wan") || strstr(buff, "gmac_eth_phy")) {
+				if (KOBJ_ADD == event->action) {
+					dev_id = rj45_wan_devid_get(WAN_PLUG_IN);
+				} else {
+					dev_id = rj45_wan_devid_get(WAN_PLUG_OUT);
+				}
+				if (dev_id < 0)
+					goto err_out;
+
+				slog(NET_PRINT, SLOG_DEBUG, "[%s][%d]rj45 dev id = %d\n", __func__, __LINE__, dev_id);
+
+				event->type = DEVICE_TYPE_RJ45;
+				event->u.netdev.dev_id = dev_id;
+				return 0;
+			} else if (strstr(buff, "gmac_eth_sw_lan")) {
+				slog(NET_PRINT, SLOG_DEBUG, "[%s][%d]rj45 dev id = %d\n", __func__, __LINE__, SW_LAN_DEV);
+				event->type = DEVICE_TYPE_RJ45;
+				event->u.netdev.dev_id = SW_LAN_DEV;
+				return 0;
+			}
+		}
+		break;
+
+	case KOBJ_ONLINE:
+		if (strncmp(RJ45_ONLINE_MESSAGE, buff, strlen(RJ45_ONLINE_MESSAGE)) == 0) {
+			dev_id = rj45_wan_devid_get(WAN_PLUG_IN);
+			if (dev_id < 0)
+				goto err_out;
+
+			slog(NET_PRINT, SLOG_DEBUG, "[%s][%d]rj45 dev id = %d\n", __func__, __LINE__, dev_id);
+
+			event->type = DEVICE_TYPE_RJ45;
+			event->u.netdev.dev_id = dev_id;
+			return 0;
+		}
+		break;
+
+	case KOBJ_OFFLINE:
+		if (strncmp(RJ45_OFFLINE_MESSAGE, buff, strlen(RJ45_OFFLINE_MESSAGE)) == 0) {
+			dev_id = rj45_wan_devid_get(WAN_PLUG_OUT);
+			if (dev_id < 0)
+				goto err_out;
+
+			slog(NET_PRINT, SLOG_DEBUG, "[%s][%d]rj45 dev id = %d\n", __func__, __LINE__, dev_id);
+
+			event->u.netdev.dev_id = dev_id;
+			event->type = DEVICE_TYPE_RJ45;
+			return 0;
+		}
+		break;
+	default:
+		break;
+	}
+
+err_out:
+	slog(NET_PRINT, SLOG_ERR, "[%s][%d]not rj45 hotplug msg\n", __func__, __LINE__);
+	return -1;
+}
+
+
+/*½âÎöusbÍø¿ÚÈȰβåÏûÏ¢*/
+static int usb_msg_parse(const char *msg, int msglen, struct hotplug_event *event)
+{
+	char *dev_ptr = NULL;
+	int dev_id = 0;
+
+	dev_ptr = strrchr(msg, '/');
+	if (NULL == dev_ptr) {
+		slog(NET_PRINT, SLOG_ERR, "[%s][%d]can not find devname\n", __func__, __LINE__);
+		return -1;
+	}
+
+	dev_ptr++;
+
+	if (strlen(dev_ptr)) {
+		slog(NET_PRINT, SLOG_ERR, "[%s][%d]dev_name1 = %s\n", __func__, __LINE__, dev_ptr);
+		if (strstr(usbdev_name, dev_ptr)) {
+			slog(NET_PRINT, SLOG_ERR, "[%s][%d]dev_name = %s\n", __func__, __LINE__, dev_ptr);
+			dev_id = getDevId_byname(dev_ptr);
+			slog(NET_PRINT, SLOG_ERR, "[%s][%d]dev_id = %d\n", __func__, __LINE__, dev_id);
+			if (dev_id < 0)
+				return -1;
+
+			event->type = DEVICE_TYPE_USB;
+			strncpy(event->u.netdev.dev_name, dev_ptr, sizeof(event->u.netdev.dev_name)-1);
+			event->u.netdev.dev_id = dev_id;
+			return 0;
+		}
+		if (KOBJ_ADD == event->action && strstr(dev_ptr, "v4-wan")) {
+			char cmd[60] = {0};
+			
+			snprintf(cmd, sizeof(cmd), "ip route add default dev %s", dev_ptr);
+			slog(NET_PRINT, SLOG_ERR, "[%s][%d]system=%s\n", __func__, __LINE__, cmd);
+			soft_system(cmd);
+			return 0;
+		}
+	}
+
+	return -1;
+}
+
+
+/*Ŀǰrj45Éϱ¨µÄÏûÏ¢±È½Ï¶¨ÖÆ£¬ÎÞ·¨½âÎö³ödev_name*/
+void netdev_name_init()
+{
+	char usblan_name[NETIF_NAME_LEN] = {0};
+	char psext1_name[NETIF_NAME_LEN] = {0};
+	char psext2_name[NETIF_NAME_LEN] = {0};
+	char psext3_name[NETIF_NAME_LEN] = {0};
+	char psext4_name[NETIF_NAME_LEN] = {0};
+	char psext5_name[NETIF_NAME_LEN] = {0};
+	char psext6_name[NETIF_NAME_LEN] = {0};
+	char psext7_name[NETIF_NAME_LEN] = {0};
+	char psext8_name[NETIF_NAME_LEN] = {0};
+
+	cfg_get_item("usblan", usblan_name, sizeof(usblan_name));
+	cfg_get_item("ps_ext1", psext1_name, sizeof(psext1_name));
+	cfg_get_item("ps_ext2", psext2_name, sizeof(psext2_name));
+	cfg_get_item("ps_ext3", psext3_name, sizeof(psext3_name));
+	cfg_get_item("ps_ext4", psext4_name, sizeof(psext4_name));
+	cfg_get_item("ps_ext5", psext5_name, sizeof(psext1_name));
+	cfg_get_item("ps_ext6", psext6_name, sizeof(psext2_name));
+	cfg_get_item("ps_ext7", psext7_name, sizeof(psext3_name));
+	cfg_get_item("ps_ext8", psext8_name, sizeof(psext4_name));
+	//cfg_get_item("ethwan", ethwan_name, sizeof(ethwan_name));
+	//cfg_get_item("ethlan", ethlan_name, sizeof(ethlan_name));
+
+	if (0 != strlen(usblan_name))
+		strcpy(usbdev_name, usblan_name);
+	if (0 != strlen(psext1_name))
+		strcat(usbdev_name, psext1_name);
+	if (0 != strlen(psext2_name))
+		strcat(usbdev_name, psext2_name);
+	if (0 != strlen(psext3_name))
+		strcat(usbdev_name, psext3_name);
+	if (0 != strlen(psext4_name))
+		strcat(usbdev_name, psext4_name);
+	if (0 != strlen(psext5_name))
+		strcat(usbdev_name, psext1_name);
+	if (0 != strlen(psext6_name))
+		strcat(usbdev_name, psext2_name);
+	if (0 != strlen(psext7_name))
+		strcat(usbdev_name, psext3_name);
+	if (0 != strlen(psext8_name))
+		strcat(usbdev_name, psext4_name);
+}
+
+
+/*ÍøÂçÉ豸ÈȰβ崦Àí*/
+int netdev_hotplug_proc(struct hotplug_event *event)
+{
+	slog(NET_PRINT, SLOG_NORMAL, "[%s][%d]act type = %d, dev_id = %d\n", __func__, __LINE__, event->action, event->u.netdev.dev_id);
+
+	switch (event->action) {
+	case KOBJ_ADD:
+	case KOBJ_ONLINE:
+		netdev_plugin_proc(event->u.netdev.dev_id, MODULE_ID_HOTPLUG);
+		break;
+
+	case KOBJ_REMOVE:
+	case KOBJ_OFFLINE:
+		netdev_plugout_proc(event->u.netdev.dev_id, MODULE_ID_HOTPLUG);
+		break;
+    case KOBJ_CHANGE:
+        //´ýÌí¼ÓÍø¿¨¸´Î»Âß¼­
+        break ;
+	default:
+		break;
+	}
+
+	return 0;
+}
+
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: gmacif_hwaddr_init
+* ¹¦ÄÜÃèÊö: ³õʼ»¯gmacÍø¿Ú¶ÔÓ¦macµØÖ·
+* ²ÎÊý˵Ã÷: (IN)
+*                         (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷: NVÖÐMACµØÖ·ÎªBCDÂ룬ÐèҪת³ÉASCIIÂë
+**************************************************************************/
+static int gmacif_hwaddr_init()
+{
+    unsigned long   retCode = CPNV_ERROR;
+    char            TmpMacAddr[OS_FLASH_AMT_COMM_RO_GMAC_SIZE] = {0};//imei³¤¶È×î´óÖµ
+	char			ethwan[16] = {0};
+	char			ethwan_name[16] = {0};
+	char 			*ptr = NULL;
+	char			set_gmac[16] = {0};
+	int 			fd, rt;
+	struct ifreq 	ifr;
+	int				i = 0;
+	int				sum_and = 0xFF;
+	int				sum_or = 0x0;
+	
+	cfg_get_item("set_gmac", set_gmac, sizeof(set_gmac));
+	if(strcmp(set_gmac, "1") != 0)
+	{
+		return -1;
+	}
+    retCode = cpnv_NvItemRead(OS_FLASH_AMT_COMM_RO_GMAC_ADDRESS, (UINT8 *)TmpMacAddr, OS_FLASH_AMT_COMM_RO_GMAC_SIZE);    
+    if (CPNV_ERROR == retCode)
+    {   
+    	printf("gmacif_hwaddr_init() cpnv_NvItemRead() read fail \n");
+        return CPNV_ERROR;
+    }
+
+	//¼ì²é´Ónvro¶ÁÈ¡³ömacÖµÊÇ·ñÈ«0x0»òÈ«0xFF£¬ÈôÊÇÔò˵Ã÷»¹Î´Í¨¹ýAT+GMACÃüÁîдÈëgmacµÄmacµØÖ·
+	for(i = 0; i < 6; i++)
+	{
+		sum_and &= TmpMacAddr[i];
+		sum_or	|= TmpMacAddr[i]; 	
+	}
+	if(sum_and == 0xFF || sum_or == 0x0)
+	{
+		return -1;
+	}
+	
+	cfg_get_item("ethwan", ethwan_name, sizeof(ethwan_name));
+	if((ptr = strchr(ethwan_name, '.')) != NULL)	//cpe switchÐÎ̬ÏÂnvÏîethwanֵΪeth0.200
+	{
+		int len = ptr - ethwan_name;
+		memcpy((void*)ethwan, (void*)ethwan_name, len);
+	}
+	else
+	{
+		memcpy((void*)ethwan, (void*)ethwan_name, strlen(ethwan_name));
+	}
+	
+	fd = socket(AF_INET, SOCK_DGRAM, 0);
+	if(fd < 0)
+	{
+		printf("gmacif_hwaddr_init() create socket fail \n");
+		return -1;
+	}
+
+	ifr.ifr_addr.sa_family = ARPHRD_ETHER;
+	strncpy(ifr.ifr_name, (const char*)ethwan, IFNAMSIZ - 1);
+	memcpy((unsigned char*)ifr.ifr_hwaddr.sa_data, TmpMacAddr, 6);
+
+	if((rt = ioctl(fd, SIOCSIFHWADDR, &ifr)) != 0)
+	{
+		printf("gmacif_hwaddr_init() ioctl fail\n");
+	}
+	close(fd);
+	   
+    return rt;
+}
+
+
+/*Éϵç³õʼ»¯*/
+void netdev_hotplug_init()
+{
+	/*ÍøÂçÉ豸Ãû³õʼ»¯*/
+	netdev_name_init();
+	gmacif_hwaddr_init();
+
+	/*ÈȰβåÏûÏ¢½âÎö³õʼ»¯*/
+	hotplug_parse_register(DEVICE_TYPE_RJ45, (hotplug_parse_func)rj45_msg_parse);
+	hotplug_parse_register(DEVICE_TYPE_USB, (hotplug_parse_func)usb_msg_parse);
+
+	/*ÍøÂçÉ豸ÈȰβ崦Àí×¢²á*/
+	hotplug_proc_register(DEVICE_TYPE_RJ45, (hotplug_proc_func)netdev_hotplug_proc);
+	hotplug_proc_register(DEVICE_TYPE_USB, (hotplug_proc_func)netdev_hotplug_proc);
+
+	/*ÍøÂçÉ豸³õʼ״̬´¦Àí*/
+	rj45_hotplug_init();
+	usb_hotplug_init();
+}
+
+
diff --git a/lynq/S300/ap/app/zte_comm/zte_mainctrl/net_other.c b/lynq/S300/ap/app/zte_comm/zte_mainctrl/net_other.c
new file mode 100644
index 0000000..2110999
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/zte_mainctrl/net_other.c
@@ -0,0 +1,1377 @@
+#include    <stdio.h>
+#include    <stdlib.h>
+#include    <sys/ioctl.h>
+#include    <arpa/inet.h>
+#include    <net/if.h>
+#include    <net/route.h>
+#include    <string.h>
+#include    <dirent.h>
+
+#include "zte_mainctrl.h"
+
+extern void str_vary_dit(char * str, char *result);
+#if 0
+/*
+ * substitution of getNthValue which dosen't destroy the original value
+ */
+static int static_getNthValueSafe(int index, char *value, char delimit, char *result, int len)
+{
+	int i = 0, result_len = 0;
+	char *begin, *end;
+
+	if (!value || !result || !len)
+		return -1;
+
+	begin = value;
+	end = strchr(begin, delimit);
+
+	while (i < index && end) {
+		begin = end + 1;
+		end = strchr(begin, delimit);
+		i++;
+	}
+
+	//no delimit
+	if (!end) {
+		if (i == index) {
+			end = begin + strlen(begin);
+			result_len = (len - 1) < (end - begin) ? (len - 1) : (end - begin);
+		} else
+			return -1;
+	} else
+		result_len = (len - 1) < (end - begin) ? (len - 1) : (end - begin);
+
+	memcpy(result, begin, result_len);
+	*(result + result_len) = '\0';
+
+	return 0;
+}
+
+/*change the value of the Nth macip list */
+/*the macip list format is:
+  [mac1]+[ip1];[mac2]+[ip2];....*/
+/*add by lyf 2012/5/21*/
+static int changeNthValue(int index, char *value, char delimit, char *result, char *web_list)
+{
+	int i = 0;
+	int front_len = 0;
+	int end_len = 0;
+	int edit_len = 0;
+	int total_len = 0;
+
+	char *begin, *end;
+	char tempchar[NV_MACIP_LIST_MAX_LEN] = {0};
+
+	if (!value || !result || !web_list)
+		return -1;
+
+	begin = value;
+	end = strchr(begin, delimit);
+
+	while (i < index && end) {
+		begin = end + 1;
+		end = strchr(begin, delimit);
+		i++;
+	}
+
+	//no delimit
+	if (!end) {
+		if (i == index) {
+			end = begin + strlen(begin) - 1;
+			front_len = begin - value;
+			strncpy(tempchar, value, front_len);
+			strncpy(tempchar + front_len, web_list, (strlen(web_list)));
+			total_len = front_len + strlen(web_list);
+		} else {
+			return -1;
+		}
+	} else {
+		front_len = begin - value;
+		edit_len = end - begin;
+		end_len = strlen(value) - front_len - edit_len;
+		strncpy(tempchar, value, front_len);
+		strncpy(tempchar + front_len, web_list, strlen(web_list));
+		strncpy(tempchar + front_len + strlen(web_list), value + front_len + edit_len, end_len);
+		total_len = front_len + strlen(web_list) + end_len;
+
+
+	}
+
+	memcpy(result, tempchar, total_len);
+	*(result + total_len) = '\0';
+
+	return 0;
+}
+
+/*delete the value of the Nth macip list*/
+/*the macip list format is:
+  [mac1]+[ip1];[mac2]+[ip2];....*/
+/*add by lyf 2012/5/21*/
+static int deleteNthValue(int index,  char *value, char delimit)
+{
+	char *begin, *end;
+	int i = 0, j = 0;
+	int need_check_flag = 0;
+	char *buf = NULL;
+	int default_len = 0;
+
+	if (!value)
+		return -1;
+	buf = strdup(value);
+	begin = buf;
+	end = strchr(begin, delimit);
+	while (end) {
+		if (i == index) {
+			memset(begin, 0, end - begin);
+			if (index == 0)
+				need_check_flag = 1;
+			break;
+		}
+		begin = end;
+		end = strchr(begin + 1, delimit);
+		i++;
+	}
+
+	if (!end && index == i)
+		memset(begin, 0, strlen(begin));
+
+	if (need_check_flag) {
+		for (i = 0; i < strlen(value); i++) {
+			if (buf[i] == '\0')
+				continue;
+			if (buf[i] == ';')
+				buf[i] = '\0';
+			break;
+		}
+	}
+	default_len = strlen(value);
+	for (i = 0, j = 0; i < strlen(value); i++) {
+		if (buf[i] != '\0') {
+			value[j++] = buf[i];
+		}
+	}
+	for (i = j; i < default_len; i++)
+		value[i] = '\0';
+
+	free(buf);
+	return 0;
+}
+//·ÅÈëzte_router½ø³ÌʵÏÖ,opms_wan_modeÓ¦¸Ã¸ù¾Ýµ±Ç°µÄȱʡÍâÍø¿Ú£¬Ê¶±ð³öethwan_mode¡¢pswan_mode¡¢wifiwan_modeÆäÖеÄÒ»ÖÖ
+void zte_qos_list_run(void)
+{
+	char Qos_enable[CONFIG_DEFAULT_LENGTH] = {0};
+	char Qos_auto_control[CONFIG_DEFAULT_LENGTH] = {0};
+	char list[NV_QOS_LIST_MAX_LEN] = {0};
+	char rec[NV_QOS_LIST_MAX_LEN] = {0};
+	char opms_wan_mode[CONFIG_DEFAULT_LENGTH] = {0};
+	char wan_if[CONFIG_DEFAULT_LENGTH] = {0};
+	char lan_if_cable[CONFIG_DEFAULT_LENGTH] = {0};
+	char lan_if_wifi[CONFIG_DEFAULT_LENGTH] = {0};
+	char uplimit_total[CONFIG_DEFAULT_LENGTH] = {0};
+	char downlimit_total[CONFIG_DEFAULT_LENGTH] = {0};
+	int i = 0;
+	char ip_list[32] = {0};
+	char maxdownload[32] = {0};
+	char maxupload[32] = {0};
+	char tempchar[32] = {0};
+	cfg_get_item("Qos_enable", Qos_enable, sizeof(Qos_enable));
+	cfg_get_item("Qos_auto_control", Qos_auto_control, sizeof(Qos_auto_control));
+	cfg_get_item("opms_wan_mode", opms_wan_mode, sizeof(opms_wan_mode));
+	cfg_get_item("Qos_control_list", list, sizeof(list));
+	cfg_get_item("UpLimit_Total", uplimit_total, sizeof(uplimit_total));
+	cfg_get_item("DownLimit_Total", downlimit_total, sizeof(downlimit_total));
+
+	if (0 == strlen(opms_wan_mode)) {
+		return;
+	}
+
+	if (!strcmp(opms_wan_mode, "PPPOE")) {
+		strcpy(wan_if, "ppp0");
+		strcpy(lan_if_cable, "eth1");
+		strcpy(lan_if_wifi, "ath0");
+
+	}
+	if (!strcmp(opms_wan_mode, "PPP")) {
+		strcpy(wan_if, "usb0");
+		strcpy(lan_if_cable, "eth0");
+		strcpy(lan_if_wifi, "ath0");
+
+	}
+	if (!strcmp(opms_wan_mode, "DHCP") || !strcmp(opms_wan_mode, "STATIC")) {
+		strcpy(wan_if, "eth0");
+		strcpy(lan_if_cable, "eth1");
+		strcpy(lan_if_wifi, "ath0");
+
+	}
+	if (!strcmp(opms_wan_mode, "BRIDGE")) {
+		return;
+	}
+	/*clear the qdisc first before func return,important!(the qos state from enabled to disabled)*/
+	/*clear upload*/
+	ZTE_LOG(LOG_INFO, "delete the qdisc ################"); /*lint !e26*/
+	doSystem("tc qdisc del dev %s root", wan_if);
+	/*clear download*/
+	doSystem("tc qdisc del dev %s root", lan_if_cable);
+	doSystem("tc qdisc del dev %s root", lan_if_wifi);
+	/*flush the mangle table*/
+	doSystem("iptables -t mangle -F");
+	ZTE_LOG(LOG_INFO, "delete over qdisc::"); /*lint !e26*/
+
+	if (!strlen(Qos_enable)) {
+		return;
+	}
+	if (!atoi(Qos_enable)) {
+		return;
+	}
+	if (atoi(Qos_auto_control)) {
+		return;
+	}
+
+	if (0 == strlen(list)) {
+		return;
+	}
+	ZTE_LOG(LOG_INFO, "list= %s", list); /*lint !e26*/
+
+	/*mark data first for the upload limit(because of SNAT )*/
+	doSystem("iptables -t mangle -A PREROUTING  -p tcp -m length --length :64 -j MARK --set-mark 256 ");
+	doSystem("iptables -t mangle -A PREROUTING  -p tcp -m length --length :64 -j RETURN  ");
+
+	while ((static_getNthValueSafe(i++, list, ';', rec, sizeof(rec)) != -1)) {
+		// get ip
+		if ((static_getNthValueSafe(0, rec, '+', ip_list, sizeof(ip_list)) == -1)) {
+			continue;
+		}
+		if (strlen(ip_list)) {
+			ZTE_LOG(LOG_INFO, "ip_list= %s", ip_list); /*lint !e26*/
+			sprintf(tempchar, "%d", i);
+			doSystem("iptables -t mangle -A PREROUTING -s %s -j MARK --set-mark %s ", ip_list, tempchar);
+			doSystem("iptables -t mangle -A PREROUTING -s %s -j RETURN ", ip_list);
+			memset(tempchar, 0, sizeof(tempchar));
+		}
+		memset(ip_list, 0, sizeof(ip_list));
+		memset(rec, 0, sizeof(rec));
+	}
+	/*upload&&download*/
+	doSystem("tc qdisc add dev %s root handle 1: htb", wan_if);
+	doSystem("tc qdisc add dev %s root handle 1: htb default 256", lan_if_cable);
+	doSystem("tc qdisc add dev %s root handle 1: htb default 256", lan_if_wifi);
+
+	doSystem("tc class add dev %s parent 1: classid 1:256 htb rate %skbit ceil %skbit prio 0 ", wan_if, uplimit_total, uplimit_total);
+	doSystem("tc class add dev %s parent 1: classid 1:256 htb rate %skbit ceil %skbit prio 0 ", lan_if_cable, downlimit_total, downlimit_total);
+	doSystem("tc class add dev %s parent 1: classid 1:256 htb rate %skbit ceil %skbit prio 0 ", lan_if_wifi, downlimit_total, downlimit_total);
+
+
+	doSystem("tc qdisc add dev %s parent 1:256 handle 256: sfq perturb 5 ", wan_if);
+	doSystem("tc qdisc add dev %s parent 1:256 handle 256: sfq perturb 5 ", lan_if_cable);
+	doSystem("tc qdisc add dev %s parent 1:256 handle 256: sfq perturb 5 ", lan_if_wifi);
+
+	doSystem("tc filter add dev %s parent 1:0 protocol ip prio 0 handle 256 fw classid 1:256", wan_if);
+
+	i = 0;
+	while ((static_getNthValueSafe(i++, list, ';', rec, sizeof(rec)) != -1)) {
+		// get ip
+		if ((static_getNthValueSafe(0, rec, '+', ip_list, sizeof(ip_list)) == -1)) {
+			continue;
+		}
+		// get maxdownload
+		if ((static_getNthValueSafe(1, rec, '+', maxdownload, sizeof(maxdownload)) == -1)) {
+			continue;
+		}
+		// get maxupload
+		if ((static_getNthValueSafe(2, rec, '+', maxupload, sizeof(maxupload)) == -1)) {
+			continue;
+		}
+		/*the max download and upload can be 0*/
+		if (strlen(ip_list)) {
+
+			sprintf(tempchar, "%d", i);
+			doSystem("tc class add dev %s parent 1: classid 1:%s htb rate %skbit ceil %skbit prio 1", wan_if, tempchar, maxupload, maxupload);
+			doSystem("tc class add dev %s parent 1: classid 1:%s htb rate %skbit ceil %skbit prio 1", lan_if_cable, tempchar, maxdownload, maxdownload);
+			doSystem("tc class add dev %s parent 1: classid 1:%s htb rate %skbit ceil %skbit prio 1", lan_if_wifi, tempchar, maxdownload, maxdownload);
+			doSystem("tc qdisc add dev %s parent 1:%s handle 1%s: sfq perturb 15", wan_if, tempchar, tempchar);
+			doSystem("tc qdisc add dev %s parent 1:%s handle 1%s: sfq perturb 15", lan_if_cable, tempchar, tempchar);
+			doSystem("tc qdisc add dev %s parent 1:%s handle 1%s: sfq perturb 15", lan_if_wifi, tempchar, tempchar);
+			doSystem("tc filter add dev %s protocol ip parent 1:0 handle %s fw classid 1:%s", wan_if, tempchar, tempchar);
+			doSystem("tc filter add dev %s parent 1:0 protocol ip u32 match ip dst %s flowid 1:%s", lan_if_cable, ip_list, tempchar);
+			doSystem("tc filter add dev %s parent 1:0 protocol ip u32 match ip dst %s flowid 1:%s", lan_if_wifi, ip_list, tempchar);
+			memset(tempchar, 0, sizeof(tempchar));
+		}
+		memset(rec, 0, sizeof(rec));
+		memset(ip_list, 0, sizeof(ip_list));
+		memset(maxdownload, 0, sizeof(maxdownload));
+		memset(maxupload, 0, sizeof(maxupload));
+
+	}
+	cfg_save();
+}
+
+
+/*add a Qos list to the Qos control list */
+/*the Qos list format is:
+  [ip]+[maxdownload]+[maxupload]+[comment];[ip]+[maxdownload]+[maxupload]+[comment];....*/
+/*add by lyf 2012/6/11*/
+void zte_goform_qoslist_add_process(char_t *web_ip, char_t *max_download, char_t *max_upload, char_t *web_comment)
+{
+
+
+	/* value of make qos list */
+	char qos_list[NV_QOS_LIST_MAX_LEN] = {0};
+	char list[NV_QOS_LIST_MAX_LEN] = {0};
+
+	if (!max_download || !web_ip || !max_upload)
+		return;
+	cfg_get_item("Qos_control_list", qos_list, sizeof(qos_list));
+	if (0 != strlen(qos_list)) {
+		snprintf(list, sizeof(list), "%s;%s+%s+%s+%s", qos_list, web_ip, max_download, max_upload, web_comment);
+	} else {
+		snprintf(list, sizeof(list), "%s+%s+%s+%s", web_ip, max_download, max_upload, web_comment);
+	}
+
+	cfg_set("Qos_control_list", list);
+
+	zte_qos_list_run();
+	cfg_save();
+
+}
+
+
+/*delete a Qos list from the  list */
+/*the Qos list format is:
+  [ip]+[maxdownload]+[maxupload]+[comment];[ip]+[maxdownload]+[maxupload]+[comment];....*/
+/*add by lyf 2012/6/11*/
+void zte_goform_qoslist_del_process(char_t *index)/*lint !e129*/
+{
+	char qos_list[NV_QOS_LIST_MAX_LEN] = {0};
+	//int list_count=0;
+	int deleIndex = 0;
+
+	if (!index)
+		return;
+	/*the web index begin from 1,but the fun index begin from 0*/
+	deleIndex = atoi(index) - 1;
+	cfg_get_item("Qos_control_list", qos_list, sizeof(qos_list));
+	if (0 == strlen(qos_list)) {
+		return;
+	}
+
+	deleteNthValue(deleIndex, qos_list, ';');
+	cfg_set("Qos_control_list", qos_list);
+	zte_qos_list_run();
+	cfg_save();
+
+
+
+}
+
+
+
+/*edit a qos list of the list */
+/*the Qos list format is:
+  [ip]+[maxdownload]+[maxupload]+[comment];[ip]+[maxdownload]+[maxupload]+[comment];....*/
+/*add by lyf 2012/6/11*/
+void zte_goform_qoslist_edit_process(char_t *web_ip, char_t *maxdownload, char_t *maxupload, char_t *web_comment, char_t *index) /*lint !e129*/
+{
+	char qos_address[64] = {0};
+	char qos_list[NV_QOS_LIST_MAX_LEN] = {0};
+	char rec[NV_QOS_LIST_MAX_LEN] = {0};
+	int editIndex = 0;
+
+	if (!web_ip || !maxdownload || !maxupload || !index)
+		return;
+	/*the web index begin from 1,but the fun index begin from 0*/
+	editIndex = atoi(index) - 1;
+	cfg_get_item("Qos_control_list", qos_list, sizeof(qos_list));
+	if (0 == strlen(qos_list)) {
+		return;
+	}
+
+	sprintf(qos_address, "%s+%s+%s+%s", web_ip, maxdownload, maxupload, web_comment);
+	changeNthValue(editIndex, qos_list, ';', rec, qos_address);
+	cfg_set("Qos_control_list", rec);
+	zte_qos_list_run();
+	cfg_save();
+
+}
+
+
+/*QoS£¬ÔÝδʵÏÖÐèÇó£¬opms_wan_modeÓ¦¸Ã¸ù¾Ýµ±Ç°µÄȱʡÍâÍø¿Ú£¬Ê¶±ð³öethwan_mode¡¢pswan_mode¡¢wifiwan_modeÆäÖеÄÒ»ÖÖ*/
+void zte_goform_Qos(void)/*lint !e18*/
+{
+	char Qos_enable[CONFIG_DEFAULT_LENGTH] = {0};
+	char Qos_auto_control[CONFIG_DEFAULT_LENGTH] = {0};
+	char opms_wan_mode[CONFIG_DEFAULT_LENGTH] = {0};
+	char ack_enable[CONFIG_DEFAULT_LENGTH] = {0};
+
+	cfg_get_item("Qos_enable", Qos_enable, sizeof(Qos_enable));
+	cfg_get_item("Qos_auto_control", Qos_auto_control, sizeof(Qos_auto_control));
+	cfg_get_item("opms_wan_mode", opms_wan_mode, sizeof(opms_wan_mode));
+	cfg_get_item("Qos_control_list", ack_enable, sizeof(ack_enable));
+
+	if (!atoi(Qos_enable)) {
+		/*if the wanmode is ppp0,then to call the ack first shall scrip*/
+		if (atoi(ack_enable)) {
+			if (!strcmp(opms_wan_mode, "PPP")) {
+				ZTE_LOG(LOG_INFO, "ack first is running////////////"); /*lint !e26*/
+				doSystem("ack_first.sh");
+			}
+			cfg_save();
+			return ;/*lint !e533 !e110 */
+		}
+
+
+
+		doSystem("speed_limit_ini.sh");
+		cfg_save();
+		return ;/*lint !e533 !e110 */
+	}
+
+	if (!atoi(Qos_auto_control)) {
+		zte_qos_list_run();
+	} else {
+		ZTE_LOG(LOG_INFO, "QoS auto traffic control is starting!");/*lint !e26*/
+
+		doSystem("qos.sh");
+
+	}
+	cfg_save();
+}
+
+/******************************************************
+* Function: zte_static_route_list_ini_run()
+* Description:  run the static route list after the device reboot
+  the static route list format is:
+   [name]+[private]+[active]+[des ip]+[ip subnet mask]+[GateWay]+[metric];.....
+* Input:
+* Output:
+* Return:
+* Others:
+* 2012/5/21  created by Liu Yifei
+*******************************************************/
+void zte_static_route_list_ini_run(void)
+{
+	//char name[CONFIG_DEFAULT_LENGTH] = {0};
+	char des_ip[32] = {0};
+	char subnet_mask[32] = {0};
+	char gateway[32] = {0};
+	char static_routelist[NV_STATIC_ROUTE_LIST_MAX_LEN] = {0};
+	char rec[NV_STATIC_ROUTE_LIST_MAX_LEN] = {0};
+	char pirvate[3] = {0}; /*private button*/
+	char active[3] = {0}; /*active button*/
+	char metric[3] = {0};
+	int list_index = 0;
+	int active_flag = 0;
+
+	cfg_get_item("static_route_list", static_routelist, sizeof(static_routelist));
+	if (0 == strlen(static_routelist)) {
+		return;
+	}
+	while ((getNthValueSafe(list_index++, static_routelist, ';', rec, sizeof(rec)) != -1)) {
+		/*get private info*/
+		if ((getNthValueSafe(1, rec, '+', pirvate, sizeof(pirvate)) == -1)) {
+			continue;
+		}
+		/*get active info*/
+		if ((getNthValueSafe(2, rec, '+', active, sizeof(active)) == -1)) {
+			continue;
+		}
+		/*get des ip address*/
+		if ((getNthValueSafe(3, rec, '+', des_ip, sizeof(des_ip)) == -1)) {
+			continue;
+		}
+		/*get subnet mask*/
+		if ((getNthValueSafe(4, rec, '+', subnet_mask, sizeof(subnet_mask)) == -1)) {
+			continue;
+		}
+		/*get gateway*/
+		if ((getNthValueSafe(5, rec, '+', gateway, sizeof(gateway)) == -1)) {
+			continue;
+		}
+		/*get metric*/
+		if ((getNthValueSafe(6, rec, '+', metric, sizeof(metric)) == -1)) {
+			continue;
+		}
+		if ((0 != strlen(active)) && (0 != strlen(des_ip))
+		    && (0 != strlen(subnet_mask)) && (0 != strlen(gateway))) {
+			if (active_flag = atoi(active)) {
+				if (!strcmp(subnet_mask, "255.255.255.255")) {
+					doSystem("route add -host %s gw %s metric %s", des_ip, gateway, metric);
+				} else {
+					doSystem("route add -net %s netmask %s gw %s metric %s", des_ip, subnet_mask, gateway, metric);
+				}
+			}
+		}
+
+
+	}
+
+	cfg_save();
+
+
+}
+
+/******************************************************
+* Function: zte_static_route_list_add()
+* Description:  add a list to the static route list
+  the static route list format is:
+   [name]+[private]+[active]+[des ip]+[ip subnet mask]+[GateWay]+[metric];.....
+* Input:  static route info from the web
+* Output:
+* Return:
+* Others:
+* 2012/5/21  created by Liu Yifei
+*******************************************************/
+void zte_static_route_list_add(char *name, char *private, char *active, char *des_ip, char *subnet_mask, char *gateway, char *metric)
+{
+	char static_routelist[NV_STATIC_ROUTE_LIST_MAX_LEN] = {0};
+	char list[NV_STATIC_ROUTE_LIST_MAX_LEN] = {0};
+	int active_flag = 0;
+
+	if (!name || !des_ip || !subnet_mask || !gateway) { /*private,active,metric may equal to 0*/
+		return;
+	}
+	cfg_get_item("static_route_list", static_routelist, sizeof(static_routelist));
+
+	if (0 != strlen(static_routelist)) {
+		snprintf(list, sizeof(list), "%s;%s+%s+%s+%s+%s+%s+%s", static_routelist, name, private, active, des_ip, subnet_mask, gateway, metric);
+	} else {
+		snprintf(list, sizeof(list), "%s+%s+%s+%s+%s+%s+%s", name, private, active, des_ip, subnet_mask, gateway, metric);
+	}
+
+	cfg_set("static_route_list", list);
+	if (active_flag = atoi(active)) {
+		if (!strcmp(subnet_mask, "255.255.255.255")) {
+			doSystem("route add -host %s gw %s metric %s", des_ip, gateway, metric);
+		} else {
+			doSystem("route add -net %s netmask %s gw %s metric %s", des_ip, subnet_mask, gateway, metric);
+		}
+	}
+
+	cfg_save();
+}
+/******************************************************
+* Function: zte_static_route_list_run_one()
+* Description:  run one list from the static route list
+  the static route list format is:
+   [name]+[private]+[active]+[des ip]+[ip subnet mask]+[GateWay]+[metric]
+* Input:
+  list--the list to run
+  delimit -- delimitor
+* Output:
+* Return:
+* Others:
+* 2012/5/21  created by Liu Yifei
+*******************************************************/
+void zte_static_route_list_run_one(char *list, char delimit)
+{
+	char des_ip[32] = {0};
+	char subnet_mask[32] = {0};
+	char gateway[32] = {0};
+	char pirvate[3] = {0};
+	char active[3] = {0};
+	char metric[3] = {0};
+	int active_flag = 0;
+
+	if (!list) {
+		return;
+	}
+
+	/*get private info*/
+	if ((getNthValueSafe(1, list, delimit, pirvate, sizeof(pirvate)) == -1)) { /*the index begin from 1,ingore the name(index 0)*/
+		return;
+	}
+	/*get active info*/
+	if ((getNthValueSafe(2, list, delimit, active, sizeof(active)) == -1)) {
+		return;
+	}
+	/*get des ip address*/
+	if ((getNthValueSafe(3, list, delimit, des_ip, sizeof(des_ip)) == -1)) {
+		return;
+	}
+	/*get subnet mask*/
+	if ((getNthValueSafe(4, list, delimit, subnet_mask, sizeof(subnet_mask)) == -1)) {
+		return;
+	}
+	/*get gateway*/
+	if ((getNthValueSafe(5, list, delimit, gateway, sizeof(gateway)) == -1)) {
+		return;
+	}
+	/*get metric*/
+	if ((getNthValueSafe(6, list, delimit, metric, sizeof(metric)) == -1)) {
+		return;
+	}
+	if ((0 != strlen(active)) && (0 != strlen(des_ip))
+	    && (0 != strlen(subnet_mask)) && (0 != strlen(gateway))) {
+		if (active_flag = atoi(active)) {
+			if (!strcmp(subnet_mask, "255.255.255.255")) {
+				doSystem("route add -host %s gw %s metric %s", des_ip, gateway, metric);
+			} else {
+				doSystem("route add -net %s netmask %s gw %s metric %s", des_ip, subnet_mask, gateway, metric);
+			}
+		}
+	}
+
+}
+/******************************************************
+* Function: zte_static_route_list_del_one()
+* Description:  delete one list from the static route list
+  the static route list format is:
+   [name]+[private]+[active]+[des ip]+[ip subnet mask]+[GateWay]+[metric]
+* Input:
+  list--the list to delete
+  delimit -- delimitor
+* Output:
+* Return:
+* Others:
+* 2012/5/21  created by Liu Yifei
+*******************************************************/
+void zte_static_route_list_del_one(char *list, char delimit)
+{
+	char des_ip[32] = {0};
+	char subnet_mask[32] = {0};
+	char gateway[32] = {0};
+	char pirvate[3] = {0};
+	char active[3] = {0};
+	char metric[3] = {0};
+	int active_flag = 0;
+
+	if (!list) {
+		return;
+	}
+
+	/*get private info*/
+	if ((getNthValueSafe(1, list, delimit, pirvate, sizeof(pirvate)) == -1)) { /*the index begin from 1,ingore the name(index 0)*/
+		return;
+	}
+	/*get active info*/
+	if ((getNthValueSafe(2, list, delimit, active, sizeof(active)) == -1)) {
+		return;
+	}
+	/*get des ip address*/
+	if ((getNthValueSafe(3, list, delimit, des_ip, sizeof(des_ip)) == -1)) {
+		return;
+	}
+	/*get subnet mask*/
+	if ((getNthValueSafe(4, list, delimit, subnet_mask, sizeof(subnet_mask)) == -1)) {
+		return;
+	}
+	/*get gateway*/
+	if ((getNthValueSafe(5, list, delimit, gateway, sizeof(gateway)) == -1)) {
+		return;
+	}
+	/*get metric*/
+	if ((getNthValueSafe(6, list, delimit, metric, sizeof(metric)) == -1)) {
+		return;
+	}
+	if ((0 != strlen(active)) && (0 != strlen(des_ip))
+	    && (0 != strlen(subnet_mask)) && (0 != strlen(gateway))) {
+		if (active_flag = atoi(active)) {
+			if (!strcmp(subnet_mask, "255.255.255.255")) {
+				doSystem("route del -host %s gw %s metric %s", des_ip, gateway, metric);
+			} else {
+				doSystem("route del -net %s netmask %s gw %s metric %s", des_ip, subnet_mask, gateway, metric);
+			}
+		}
+	}
+
+}
+/******************************************************
+* Function: zte_static_route_list_del()
+* Description:  delete a list from the static route list according to the delete index
+  the static route list format is:
+   [name]+[private]+[active]+[des ip]+[ip subnet mask]+[GateWay]+[metric];.....
+* Input:
+  index--the index  of deleted items
+  delimit -- delimitor
+* Output:
+* Return:
+* Others:
+* 2012/5/21  created by Liu Yifei
+*******************************************************/
+void zte_static_route_list_del(int index, char delimit)
+{
+	char static_routelist[NV_STATIC_ROUTE_LIST_MAX_LEN] = {0};
+	char list[NV_STATIC_ROUTE_LIST_MAX_LEN] = {0};/*temp list*/
+	//int active_flag=0;
+	char *begin = NULL;
+	char *end = NULL;
+	char *buf = NULL;
+	int i = 0;
+	int j = 0;
+	int need_check_flag = 0;
+	int default_len = 0;
+
+	cfg_get_item("static_route_list", static_routelist, sizeof(static_routelist));
+	if (!strlen(static_routelist)) {
+		return;
+	}
+
+	buf = strdup(static_routelist);
+	begin = buf;
+	end = strchr(begin, delimit);
+	while (end) {
+		if (i == index) {
+			strncpy(list, begin, end - begin);
+			zte_static_route_list_del_one(list, '+');
+			memset(begin, 0, end - begin);
+			memset(list, 0, strlen(list));
+			if (index == 0)
+				need_check_flag = 1;
+			break;
+		}
+		begin = end;
+
+		end = strchr(begin + 1, delimit);
+		i++;
+	}
+	if (!end && index == i) {
+		strncpy(list, begin, strlen(begin));
+		zte_static_route_list_del_one(list, '+');
+		memset(list, 0, strlen(list)); /*set the temp list to 0*/
+		memset(begin, 0, strlen(begin));
+
+	}
+
+
+	if (need_check_flag) {
+		for (i = 0; i < strlen(static_routelist); i++) {
+			if (buf[i] == '\0') {
+				continue;
+			}
+			if (buf[i] == ';') {
+				buf[i] = '\0';
+			}
+			break;
+		}
+	}
+	default_len = strlen(static_routelist);
+	for (i = 0, j = 0; i < strlen(static_routelist); i++) {
+		if (buf[i] != '\0') {
+			static_routelist[j++] = buf[i];
+		}
+	}
+	for (i = j; i < default_len; i++)
+		static_routelist[i] = '\0';
+
+	cfg_set("static_route_list", static_routelist);
+	cfg_save();
+	free(buf);
+
+
+}
+/******************************************************
+* Function: zte_static_route_list_edit_one()
+* Description:  edit a list from the static route list
+  the static route list format is:
+   [name]+[private]+[active]+[des ip]+[ip subnet mask]+[GateWay]+[metric];.....
+* Input:
+  index--the index of deleted item
+  value--the static route list
+  delimit--delimitor
+  web_list--static route info from the web
+* Output:
+  result-- the edited static route list
+* Return:
+* Others:
+* 2012/5/21  created by Liu Yifei
+*******************************************************/
+int zte_static_route_list_edit_one(int index, char *value, char delimit, char *result, char *web_list)
+{
+	int i = 0;
+	int front_len = 0;
+	int end_len = 0;
+	int edit_len = 0;
+	int total_len = 0;
+	char *begin = NULL;
+	char *end = NULL;
+	char tempchar[NV_STATIC_ROUTE_LIST_MAX_LEN] = {0};
+	char dosys_list[NV_STATIC_ROUTE_LIST_MAX_LEN] = {0};
+
+	if (!value || !result || !web_list)
+		return -1;
+
+	begin = value;
+	end = strchr(begin, delimit);
+	while (i < index && end) {
+		begin = end + 1;
+		end = strchr(begin, delimit);
+		i++;
+	}
+
+	//no delimit
+	if (!end) {
+		if (i == index) {
+			end = begin + strlen(begin) - 1;
+			strncpy(dosys_list, begin, end - begin + 1);
+			printf(dosys_list);
+			zte_static_route_list_del_one(dosys_list, '+');
+			memset(dosys_list, 0, strlen(dosys_list));
+			front_len = begin - value;
+			strncpy(tempchar, value, front_len);
+			strncpy(tempchar + front_len, web_list, (strlen(web_list)));
+			zte_static_route_list_run_one(web_list, '+');
+			total_len = front_len + strlen(web_list);
+		} else {
+			return -1;
+		}
+	} else {
+		front_len = begin - value;
+		edit_len = end - begin;
+		end_len = strlen(value) - front_len - edit_len;
+		strncpy(dosys_list, begin, end - begin);
+		printf(dosys_list);
+		zte_static_route_list_del_one(dosys_list, '+');
+		memset(dosys_list, 0, strlen(dosys_list));
+		strncpy(tempchar, value, front_len);
+		strncpy(tempchar + front_len, web_list, strlen(web_list));
+		strncpy(tempchar + front_len + strlen(web_list), value + front_len + edit_len, end_len);
+		zte_static_route_list_run_one(web_list, '+');
+		total_len = front_len + strlen(web_list) + end_len;
+	}
+	memcpy(result, tempchar, total_len);
+	*(result + total_len) = '\0';
+
+	return 0;
+
+}
+/******************************************************
+* Function: zte_static_route_list_edit()
+* Description:  edit a list from the static route list
+  call zte_static_route_list_edit_one() to process
+  the static route list format is:
+   [name]+[private]+[active]+[des ip]+[ip subnet mask]+[GateWay]+[metric];.....
+* Input:
+  index--the index of deleted item
+  list info from the web
+* Output:
+* Return:
+* Others:
+* 2012/5/21  created by Liu Yifei
+*******************************************************/
+void zte_static_route_list_edit(char *index, char *web_name, char *web_private, char *web_active, char *web_des_ip, char *web_subnet_mask, char *web_gateway, char *web_metric)
+{
+	char staticroute_one_list[NV_STATIC_ROUTE_LIST_MAX_LEN] = {0};
+	char static_route_list[NV_STATIC_ROUTE_LIST_MAX_LEN] = {0};
+	char rec[NV_STATIC_ROUTE_LIST_MAX_LEN] = {0};
+	int editIndex = 0;
+	if (!web_name || !web_des_ip || !web_subnet_mask || !web_gateway) { /*private,active,metric may equal to 0*/
+		return;
+	}
+	editIndex = atoi(index) - 1;
+	cfg_get_item("static_route_list", static_route_list, sizeof(static_route_list));
+	if (!strlen(static_route_list)) {
+		return;
+	}
+	sprintf(staticroute_one_list, "%s+%s+%s+%s+%s+%s+%s", web_name, web_private, web_active, web_des_ip, web_subnet_mask, web_gateway, web_metric);
+	zte_static_route_list_edit_one(editIndex, static_route_list, ';', rec, staticroute_one_list);
+	cfg_set("static_route_list", rec);
+	cfg_save();
+}
+#endif
+
+//add by gongxuanhui 03/13/2014
+static void zte_router_make_MTU_Rule(char *buf, int len, char *wan_name, char *mtu_value)
+{
+	snprintf(buf, len, "ifconfig %s mtu %s ", wan_name,  mtu_value);
+}
+
+//add by gongxuanhui 03/13/2014
+void zte_router_MTU_set(void)
+{
+
+	char cmd[1024] = {0};
+	char mtu[128] = {0};
+	int mtu_int;
+
+	memset(cmd, 0, sizeof(cmd));
+
+	//zte_router_nvconfig_read("mtu");
+	//strcpy(mtu , g_router_nvconfig_buf);
+
+	cfg_get_item("mtu", mtu, sizeof(mtu));
+
+	if (0 == strcmp(mtu, "")) {
+		slog(NET_PRINT, SLOG_ERR, "Warning: mtu  valu is null \n");
+		return;
+	}
+
+	if ((mtu_int = atoi(mtu)) < 1280 || mtu_int > 1500) {
+		slog(NET_PRINT, SLOG_ERR, "Warning: mtu value is illgality\n");
+		return;
+	}
+
+	zte_router_make_MTU_Rule(cmd, sizeof(cmd), defwan_rel, mtu);
+
+	system_cmd_ex(cmd);
+	//system_cmd_ex("firewall_init.sh");
+	return;
+}
+
+//1217
+void zte_unpn_set(void)
+{
+	char upnpEnabled[8] = {0};
+	
+	cfg_get_item("upnpEnabled", upnpEnabled, sizeof(upnpEnabled));
+	slog(NET_PRINT, SLOG_NORMAL, "router : start to set upnp %s\n", upnpEnabled);
+	//if(atoi(upnpEnabled))
+		system_cmd_ex("upnp.sh");
+}
+void zte_router_dhcp_set_process(void)
+{
+	slog(NET_PRINT, SLOG_NORMAL, "router : start to set dhcp \n");
+	system_cmd_ex("lan.sh");
+	//doSystem("killall fullshare");
+	//doSystem("killall smbd");
+	//doSystem("killall nmbd");
+	//doSystem("fullshare &");
+	//doSystem("smbd -D");
+	//doSystem("nmbd -D");
+	//doSystem("sh /mnt/jffs2/scripts/upnp.sh");
+}
+
+//add by gongxuanhui 03/13/2014
+void zte_router_mtu_set_process(void)
+{
+	//zte_router_MTU_set();
+	zte_router_init();
+}
+
+
+//set  mac_ip_list when get msg from web_firewall 08/09/2015
+void zte_macip_list_run(void)
+{
+	char dhcp_enable[ROUTER_DEFAULT_LEN] = {0};
+	char list[NV_MACIP_LIST_MAX_LEN] = {0};
+	char mac_address[32] = {0};   /*mac address */
+	char ip_address[32]  = {0};  /*ip address */
+
+	int dhcp_server_enable = 0;
+	int i = 0;
+	char rec[NV_MACIP_LIST_MAX_LEN] = {0};
+	char cmd[1024] = {0};
+
+	cfg_get_item("dhcpEnabled", dhcp_enable, sizeof(dhcp_enable));
+	if (0 == strlen(dhcp_enable)) {
+		slog(NET_PRINT, SLOG_ERR, "Error: can't find \"dhcpEnabled\" in flash.\n"); /*lint !e26*/
+		return;
+	}
+	dhcp_server_enable = atoi(dhcp_enable);
+	/* if dhcp is disable, then return directly: 0 mean disable, 1 means enable */
+	if (0 == dhcp_server_enable) {
+		return;
+	}
+
+	cfg_get_item("mac_ip_list", list, sizeof(list));
+
+	/*kill udhcpd*/
+	system_cmd_ex("config-udhcpd.sh \"lan\" -k");
+	/*clear the static_lease list in udhcpd.conf file*/
+	system_cmd_ex("config-udhcpd.sh \"lan\" -S");
+	while ((getNthValueSafe(i++, list, ';', rec, sizeof(rec)) != -1)) {
+		// get mac
+		if ((getNthValueSafe(1, rec, '+', mac_address, sizeof(mac_address)) == -1)) {
+			continue;
+		}
+		// get ip
+		if ((getNthValueSafe(2, rec, '+', ip_address, sizeof(ip_address)) == -1)) {
+			continue;
+		}
+		if ((0 != strlen(mac_address))
+		    && (0 != strlen(ip_address))) {
+			memset(cmd, 0, sizeof(cmd));
+			sprintf(cmd, "config-udhcpd.sh \"lan\" -S %s %s", mac_address, ip_address);
+			system_cmd_ex(cmd);
+			//system_cmd_ex("config-udhcpd.sh -S %s %s",mac_address,ip_address);
+		}
+
+
+	}
+
+	/*restart udhcpd*/
+	system_cmd_ex("config-udhcpd.sh \"lan\" -r");
+
+}
+
+void zte_bind_macip_list(void)
+{
+	char dhcp_enable[ROUTER_DEFAULT_LEN] = {0};
+	char static_dhcp_enable[ROUTER_DEFAULT_LEN] = {0};
+
+	cfg_get_item("dhcpEnabled", dhcp_enable, sizeof(dhcp_enable));
+	if (0 == strlen(dhcp_enable)) {
+		slog(NET_PRINT, SLOG_ERR, "Error: can't find \"dhcpEnabled\" in flash.\n"); /*lint !e26*/
+		return;
+	}
+	/* if dhcp is disable, then return directly: 0 mean disable, 1 means enable */
+	if (0 == atoi(dhcp_enable)) {
+		return;
+	}
+
+	/*kill udhcpd*/
+	system_cmd_ex("config-udhcpd.sh \"lan\" -k");
+
+	cfg_get_item("static_dhcp_enable", static_dhcp_enable, sizeof(static_dhcp_enable));
+
+	//static_dhcp_enable=0,¹Ø±ÕMAC-IP°ó¶¨¹¦ÄÜ£¬Çå¿Õudhcpd.confÎļþÖа󶨵ÄMAC-IP
+	//static_dhcp_enable=1,¿ªÆôMAC-IP°ó¶¨¹¦ÄÜ£¬½«Ö®Ç°µÄMAC-IP°ó¶¨¹ØÏµÖØÐÂдÈëudhcpd.conf
+	if (0 == atoi(static_dhcp_enable)) {
+		/*clear the static_lease list in udhcpd.conf file*/
+		system_cmd_ex("config-udhcpd.sh \"lan\" -S");
+	} else
+		system_cmd_ex("config-udhcpd.sh \"lan\" -E");
+
+	system_cmd_ex("config-udhcpd.sh \"lan\" -r");
+
+}
+
+void zte_bind_macip_list_add(struct static_macip_info *static_macip)
+{
+	char dhcp_enable[ROUTER_DEFAULT_LEN] = {0};
+	char static_dhcp_enable[ROUTER_DEFAULT_LEN] = {0};
+	char* mac_address = NULL;   /*mac address  to add*/
+	char* ip_address = NULL;  /*ip address to add */
+	char cmd[200] = {0};
+
+	cfg_get_item("dhcpEnabled", dhcp_enable, sizeof(dhcp_enable));
+	if (0 == strlen(dhcp_enable)) {
+		slog(NET_PRINT, SLOG_ERR, "Error: can't find \"dhcpEnabled\" in flash.\n"); /*lint !e26*/
+		return;
+	}
+	/* if dhcp is disable, then return directly: 0 mean disable, 1 means enable */
+	if (0 == atoi(dhcp_enable)) {
+		return;
+	}
+
+	mac_address = static_macip->mac;
+	ip_address = static_macip->ip;
+
+	/*kill udhcpd*/
+	system_cmd_ex("config-udhcpd.sh \"lan\" -k");
+
+	cfg_get_item("static_dhcp_enable", static_dhcp_enable, sizeof(static_dhcp_enable));
+
+	//static_dhcp_enable=0,¹Ø±ÕMAC-IP°ó¶¨¹¦ÄÜ£¬Çå¿Õ°ó¶¨µÄMAC-IP
+	if (1 == atoi(static_dhcp_enable)) {
+		//Ôö¼ÓMAC-IP°ó¶¨¹æÔò
+		if ((0 != strlen(mac_address)) && (0 != strlen(ip_address))) {
+			sprintf(cmd, "config-udhcpd.sh \"lan\" -S %s %s", mac_address, ip_address);
+			system_cmd_ex(cmd);
+		}
+	}
+
+	system_cmd_ex("config-udhcpd.sh \"lan\" -r");
+
+}
+
+void zte_bind_macip_list_del(char* mac)
+{
+	char dhcp_enable[ROUTER_DEFAULT_LEN] = {0};
+	char static_dhcp_enable[ROUTER_DEFAULT_LEN] = {0};
+	char cmd[200] = {0};
+
+	cfg_get_item("dhcpEnabled", dhcp_enable, sizeof(dhcp_enable));
+	if (0 == strlen(dhcp_enable)) {
+		slog(NET_PRINT, SLOG_ERR, "Error: can't find \"dhcpEnabled\" in flash.\n"); /*lint !e26*/
+		return;
+	}
+	/* if dhcp is disable, then return directly: 0 mean disable, 1 means enable */
+	if (0 == atoi(dhcp_enable)) {
+		return;
+	}
+
+	/*kill udhcpd*/
+	system_cmd_ex("config-udhcpd.sh \"lan\" -k");
+
+	cfg_get_item("static_dhcp_enable", static_dhcp_enable, sizeof(static_dhcp_enable));
+
+	//static_dhcp_enable=0,¹Ø±ÕMAC-IP°ó¶¨¹¦ÄÜ£¬Çå¿Õ°ó¶¨µÄMAC-IP
+	if (1 == atoi(static_dhcp_enable)) {
+		//ɾ³ýMAC-IP°ó¶¨¹æÔò
+		if (0 != strlen(mac)) {
+			sprintf(cmd, "config-udhcpd.sh \"lan\" -D %s", mac);
+			system_cmd_ex(cmd);
+		}
+	}
+
+	system_cmd_ex("config-udhcpd.sh \"lan\" -r");
+
+}
+
+
+void get_mac_hostname_pro(struct mac_hostname_info *mac_hostname_)
+{
+	char *mac = NULL;
+	char *hostname = NULL;
+	char cmd[200] = {0};
+	mac = mac_hostname_->mac;
+	hostname = mac_hostname_->hostname;
+	sprintf(cmd, "config-hostname.sh \"%s\" \"%s\"", mac, hostname);
+	system_cmd_ex(cmd);
+
+}
+
+void children_device_add(struct mac_hostname_info *mac_hostname)
+{
+	char *mac = NULL;
+	char *hostname = NULL;
+	char cmd[200] = {0};
+	mac = mac_hostname->mac;
+	hostname = mac_hostname->hostname;
+	slog(NET_PRINT, SLOG_NORMAL, "children_device_add:mac= %s, hostname = %s\n", mac, hostname);
+	if ((0 != strlen(mac)) && (0 != strlen(hostname))) {
+		sprintf(cmd, "config-parents.sh device \"%s\" \"%s\"", mac, hostname);
+		system_cmd_ex(cmd);
+	}
+}
+
+void children_device_del(char * mac)
+{
+	char cmd[100] = {0};
+	if (0 != strlen(mac)) {
+		sprintf(cmd, "config-parents.sh device \"%s\"", mac);
+		system_cmd_ex(cmd);
+	}
+}
+
+
+void white_site_add(struct white_site_info * white_site)
+{
+	char *name = NULL;
+	char *site = NULL;
+	char cmd[600] = {0};
+	name = white_site->name;
+	site = white_site->site;
+	slog(NET_PRINT, SLOG_NORMAL, "white_site_add:site= %s, name = %s\n", site, name);
+	if (0 != strlen(site)) {
+		sprintf(cmd, "config-parents.sh white_site -A \"%s\" \"%s\"", site, name);
+		system_cmd_ex(cmd);
+	}
+
+}
+
+
+void white_site_remove(char * ids)
+{
+	char cmd[100] = {0};
+	if (0 != strlen(ids)) {
+		sprintf(cmd, "config-parents.sh white_site -D \"%s\"", ids);
+		system_cmd_ex(cmd);
+	}
+}
+
+
+void zte_children_start_nonet(void)
+{
+	char sys_cmd_bufer[500] = {0};
+
+	FILE *chilren_device_file = NULL;
+	char line[200] = {0};
+	char mac[18] = {0};
+	char path_conf[50] = {0};
+	char path_file[100] = {0};
+	cfg_get_item("path_conf", path_conf, sizeof(path_conf));
+	sprintf(path_file, "%s/children_device_file", path_conf);
+
+	/*flush filter chain*/
+	sprintf(sys_cmd_bufer, "iptables -F %s %s", CLILDREN_MAC_CHAIN, FMT_ECHO_IPTABLES_CMD);
+	system_cmd_ex(sys_cmd_bufer);
+	memset(sys_cmd_bufer, 0, sizeof(sys_cmd_bufer));
+	sprintf(sys_cmd_bufer, "iptables -F %s %s", CLILDREN_WEB_CHAIN, FMT_ECHO_IPTABLES_CMD);
+	system_cmd_ex(sys_cmd_bufer);
+	memset(sys_cmd_bufer, 0, sizeof(sys_cmd_bufer));
+	sprintf(sys_cmd_bufer, "iptables -F %s %s", CLILDREN_WEB_PHONE_CHAIN, FMT_ECHO_IPTABLES_CMD);
+	system_cmd_ex(sys_cmd_bufer);
+
+
+	chilren_device_file = fopen(path_file, "r");
+	if (chilren_device_file == NULL) {
+		fprintf(stderr, "can not open file children_device_file.");
+		return;
+	}
+
+	while (fgets(line, 200, chilren_device_file) != NULL) {
+		memset(sys_cmd_bufer, 0, sizeof(sys_cmd_bufer));
+
+		strncpy(mac, line, 17);
+
+		if (strcmp(mac, "") != 0) {
+			sprintf(sys_cmd_bufer, "iptables -A %s -m mac --mac-source %s -j DROP", CLILDREN_MAC_CHAIN, mac);
+			slog(NET_PRINT, SLOG_NORMAL, "%s \n", sys_cmd_bufer);
+			system_cmd_ex(sys_cmd_bufer);
+		}
+
+		memset(line, 0, sizeof(line));
+		memset(mac, 0, sizeof(mac));
+	}
+	fclose(chilren_device_file);
+}
+
+static void make_children_white_site_rule(char mac[])
+{
+	slog(NET_PRINT, SLOG_NORMAL, "make_children_white_site_rule start! \n");
+	char sys_cmd_bufer[600] = {0};
+	FILE *white_site_file = NULL;
+	char url_hexstring[ZTE_ROUTER_URL_FILTER_LEN] = {0};
+	char line[600] = {0};
+	char site[600] = {0};//klocwork
+	char temp_site[600] = {0};
+
+	unsigned int len = 0;
+
+	char path_conf[50] = {0};
+	char path_file[100] = {0};
+	cfg_get_item("path_conf", path_conf, sizeof(path_conf));
+	sprintf(path_file, "%s/white_site_file", path_conf);
+
+	white_site_file = fopen(path_file, "r");
+	if (white_site_file == NULL) {
+		fprintf(stderr, "can not open file white_site_file.");
+
+		//PCÖÕ¶Ë:ĬÈϽ«macµØÖ·µÄ53¶Ë¿ÚµÄ°ü¶ªµô
+		memset(sys_cmd_bufer, 0, sizeof(sys_cmd_bufer));
+		sprintf(sys_cmd_bufer, "iptables -A %s -m mac --mac-source %s -p udp --dport 53 -j DROP", CLILDREN_WEB_CHAIN, mac);
+		system_cmd_ex(sys_cmd_bufer);
+
+		//ÊÖ»úÖÕ¶Ë:ĬÈϽ«macµØÖ·µÄ53¶Ë¿ÚµÄ°ü¶ªµô
+		memset(sys_cmd_bufer, 0, sizeof(sys_cmd_bufer));
+		sprintf(sys_cmd_bufer, "iptables -A %s -m mac --mac-source %s -p udp --dport 53 -j DROP", CLILDREN_WEB_PHONE_CHAIN, mac);
+		system_cmd_ex(sys_cmd_bufer);
+
+		return;
+	}
+
+	while (fgets(line, 600, white_site_file) != NULL) {
+		memset(sys_cmd_bufer, 0, sizeof(sys_cmd_bufer));
+		memset(url_hexstring, 0, sizeof(url_hexstring));
+
+		int i = 0;
+		for (i = 0; i < 600; i++) {
+			if (line[i] == ',') {
+				len = i;
+				break;
+			}
+		}
+		strncpy(site, line, len);
+
+		if (strcmp(site, "") != 0) {
+			//È¥³ý꿅Ⴁ̾µÄhttpÍ·²¿
+			if (!strncasecmp(site, "http://", strlen("http://"))) {
+				strncpy(site, site + strlen("http://"), sizeof(site)-1);
+			}
+			if (!strncasecmp(site, "https://", strlen("https://"))) {
+				strncpy(site, site + strlen("https://"), sizeof(site)-1);
+			}
+			//È¥³ýÍøÖ·ºóÃæ.com/ºóµÄβ²¿
+			int seq = 0;
+			int len_site = 0;
+			memset(temp_site, 0, sizeof(temp_site));
+			strcpy(temp_site, site);
+			for (seq = 0; seq < strlen(temp_site); seq++) {
+				if (temp_site[seq] == '/') {
+					len_site = seq;
+					memset(site, 0, sizeof(site));
+					strncpy(site, temp_site, len_site);
+					break;
+				}
+			}
+
+
+
+			str_vary_dit(site, url_hexstring);
+			slog(NET_PRINT, SLOG_NORMAL, "site=%s url_hexstring=%s\n", site, url_hexstring);
+			snprintf(sys_cmd_bufer, sizeof(sys_cmd_bufer), "iptables -A %s -m mac --mac-source %s -m string --hex-string  \"|%s|\" --algo kmp -j ACCEPT", \
+			        CLILDREN_WEB_CHAIN, mac, url_hexstring);//klocwork
+			system_cmd_ex(sys_cmd_bufer);
+
+			memset(sys_cmd_bufer, 0, sizeof(sys_cmd_bufer));
+			snprintf(sys_cmd_bufer, sizeof(sys_cmd_bufer), "iptables -A %s -m mac --mac-source %s -m string --hex-string  \"|%s|\" --algo kmp -j ACCEPT", \
+			        CLILDREN_WEB_PHONE_CHAIN, mac, url_hexstring);
+			system_cmd_ex(sys_cmd_bufer);
+
+		}
+
+		memset(line, 0, sizeof(line));
+		memset(site, 0, sizeof(site));
+		len = 0;
+	}
+
+	fclose(white_site_file);
+
+	//ĬÈϽ«macµØÖ·µÄ53¶Ë¿ÚµÄ°ü¶ªµô
+	memset(sys_cmd_bufer, 0, sizeof(sys_cmd_bufer));
+	sprintf(sys_cmd_bufer, "iptables -A %s -m mac --mac-source %s -p udp --dport 53 -j DROP", CLILDREN_WEB_CHAIN, mac);
+	system_cmd_ex(sys_cmd_bufer);
+
+	memset(sys_cmd_bufer, 0, sizeof(sys_cmd_bufer));
+	sprintf(sys_cmd_bufer, "iptables -A %s -m mac --mac-source %s -p udp --dport 53 -j DROP", CLILDREN_WEB_PHONE_CHAIN, mac);
+	system_cmd_ex(sys_cmd_bufer);
+
+
+}
+
+void zte_children_stop_nonet(void)
+{
+	char sys_cmd_bufer[500] = {0};
+	FILE *chilren_device_file = NULL;
+	char line[200] = {0};
+	char mac[18] = {0};
+
+	char path_conf[50] = {0};
+	char path_file[100] = {0};
+	cfg_get_item("path_conf", path_conf, sizeof(path_conf));
+	sprintf(path_file, "%s/children_device_file", path_conf);
+
+	system_cmd_ex("iptables -t filter -D INPUT -p udp --dport 53  -j ACCEPT");
+	system_cmd_ex("iptables -t filter -D FORWARD -p udp --dport 53  -j ACCEPT");
+
+
+
+	/*flush filter chain*/
+	sprintf(sys_cmd_bufer, "iptables -F %s %s", CLILDREN_MAC_CHAIN, FMT_ECHO_IPTABLES_CMD);
+	system_cmd_ex(sys_cmd_bufer);
+	memset(sys_cmd_bufer, 0, sizeof(sys_cmd_bufer));
+	sprintf(sys_cmd_bufer, "iptables -F %s %s", CLILDREN_WEB_CHAIN, FMT_ECHO_IPTABLES_CMD);
+	system_cmd_ex(sys_cmd_bufer);
+	memset(sys_cmd_bufer, 0, sizeof(sys_cmd_bufer));
+	sprintf(sys_cmd_bufer, "iptables -F %s %s", CLILDREN_WEB_PHONE_CHAIN, FMT_ECHO_IPTABLES_CMD);
+	system_cmd_ex(sys_cmd_bufer);
+
+	chilren_device_file = fopen(path_file, "r");
+	if (chilren_device_file == NULL) {
+		fprintf(stderr, "can not open file children_device_file.");
+		return;
+	}
+
+	while (fgets(line, 200, chilren_device_file) != NULL) {
+		memset(sys_cmd_bufer, 0, sizeof(sys_cmd_bufer));
+
+		strncpy(mac, line, 17);
+
+		if (strcmp(mac, "") != 0) {
+			make_children_white_site_rule(mac);
+		}
+
+		memset(line, 0, sizeof(line));
+		memset(mac, 0, sizeof(mac));
+	}
+	fclose(chilren_device_file);
+}
+
+/* DHCP_SETTING_REQ */
+void zte_router_dhcp_setting_req_process(dhcp_setting_req *pdhcp_setting_req)
+{
+	(void)cfg_set("lan_ipaddr", pdhcp_setting_req->lan_ip);
+	(void)cfg_set("lan_netmask", pdhcp_setting_req->lan_netmask);
+	if (!pdhcp_setting_req->dhcp_enabled) {
+		(void)cfg_set("dhcpEnabled", "0");
+	} else {
+		(void)cfg_set("dhcpEnabled", "1");
+		(void)cfg_set("dhcpStart", pdhcp_setting_req->dhcp_start);
+		(void)cfg_set("dhcpEnd", pdhcp_setting_req->dhcp_end);
+		(void)cfg_set("dhcpDns", pdhcp_setting_req->dhcp_dns);
+		(void)cfg_set("dhcpLease_hour", pdhcp_setting_req->dhcp_lease);
+	}
+
+	system_cmd_ex("user-config-udhcpd.sh");
+}
+
diff --git a/lynq/S300/ap/app/zte_comm/zte_mmi/makefile b/lynq/S300/ap/app/zte_comm/zte_mmi/makefile
new file mode 100755
index 0000000..70551c0
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/zte_mmi/makefile
@@ -0,0 +1,104 @@
+# /*****************************************************************************

+#* 版权所有 (C)2015, 中兴通讯股份有限公司。

+#* 

+#* 文件名称:     Makefile

+#* 文件标识:     Makefile

+#* 内容摘要:     Makefile of ZTE applications

+#* 使用方法:     void

+#* 

+#* 修改日期        版本号      修改标记        修改人          修改内容

+#* -----------------------------------------------------------------------------

+#* 2015/02/10      V1.0        Create          张楠          创建

+#* 

+# ******************************************************************************/

+

+#*******************************************************************************

+# include ZTE application makefile

+#*******************************************************************************

+#include $(zte_app_mak)

+#include $(zte_app_path)/net_team.mk

+include $(COMMON_MK)

+WORKPATH = $(zte_lib_path)

+SOFT_TIMER_PATH = $(WORKPATH)/libsoft_timer

+

+#*******************************************************************************

+# execute

+#*******************************************************************************

+EXEC    = zte_mmi

+

+#*******************************************************************************

+# objects

+#*******************************************************************************

+OBJS    = mmi_adapter.o mmi.o mmi_battery.o mmi_net.o mmi_wifi.o mmi_tip.o mmi_sms.o mmi_lcd_page.o mmi_lcd.o mmi_lcd_init.o mmi_ctrl.o \

+		  mmi_keystrokes.o mmi_lcd_timer.o mmi_led.o mmi_led_init.o mmi_led_adapter.o mmi_poweroff_charger.o mmi_traffic.o mmi_fota.o mmi_msg.o \

+		  mmi_cfg.o mmi_poweroff.o mmi_battery_adapter.o mmi_mo.o mmi_mo_en.o mmi_mo_zh.o mmi_voip.o mmi_plat_adapter.o mmi_rj45.o

+

+#*******************************************************************************

+# include path

+#*******************************************************************************                

+INCLUE_PATH = -I. -I./../../include

+CFLAGS += -Wextra -Wall $(INCLUE_PATH) $(CUSTOM_MACRO)

+CFLAGS  += -I$(SOFT_TIMER_PATH)

+

+ifneq ($(CONFIG_MMI_LCD),no)

+CFLAGS  += -I$(WORKPATH)/libzcore/min/zcore_zcore/src/zCore/src/gui/adapter/Linux/inc \

+           -I$(WORKPATH)/libzcore/min/zcore_zcore/src/zCore/inc/os \

+           -I$(WORKPATH)/libzcore/min/zcore_zcore/inc/zCore/gui \

+           -I$(WORKPATH)/libzcore/min/zcore_zcore/inc/zCore/os \

+           -I$(WORKPATH)/libzcore/min/zcore_zcore/inc/zCore/kernel \

+           -I$(WORKPATH)/libzcore/min/zcore_zcore/inc/zCore/gui/ctrl \

+           -I$(WORKPATH)/libzcore/min/zcore_zcore/inc/zCore/mmi \

+           -I$(WORKPATH)/libzcore/min/ 

+endif

+

+CFLAGS  += -I$(SOFT_TIMER_PATH) \

+		   -L$(SOFT_TIMER_PATH)

+CFLAGS += -g

+CFLAGS += -I$(WORKPATH)/libnvram

+CFLAGS += -I$(zte_app_path)/zte_comm/zte_hotplug

+

+ifeq ($(LINUX_TYPE),uClinux)

+CFLAGS += -g -O0

+endif

+

+#*******************************************************************************

+# macro definition

+#*******************************************************************************

+

+

+#*******************************************************************************

+# library

+#*******************************************************************************

+LDLIBS += -lpthread -lm -lrt 

+CFLAGS += -I$(SOFT_TIMER_PATH)

+

+LDLIBS += -lnvram -lpthread -lsoft_timer -lsoftap

+#LDFLAGS += -L../soft_timer -lsofttimer 

+

+ifneq ($(CONFIG_MMI_LCD),no)

+LDLIBS += -lzcore

+endif

+

+#*******************************************************************************

+# library path

+#*******************************************************************************

+LDLIBS  += -L$(WORKPATH)/libnvram

+LDLIBS  += -L$(WORKPATH)/libsoft_timer

+

+ifneq ($(CONFIG_MMI_LCD),no)

+LDLIBS  += -L$(WORKPATH)/libzcore/min

+endif

+

+LDLIBS  += -L$(zte_lib_path)/libsoftap

+

+#*******************************************************************************

+# targets

+#*******************************************************************************

+lib: $(OBJS)

+	@echo Compiling zte_mmi libraries.

+	

+clean:

+	-rm -f $(OBJS)

+	

+

+	

diff --git a/lynq/S300/ap/app/zte_comm/zte_mmi/mmi.c b/lynq/S300/ap/app/zte_comm/zte_mmi/mmi.c
new file mode 100755
index 0000000..d39f8dc
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/zte_mmi/mmi.c
@@ -0,0 +1,871 @@
+/*****************************************************************************
+*  °æ±¾ËùÓÐ (C)ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾
+*  Ä£¿éÃû    £ºMMI
+*  ÎļþÃû    £ºmmi.c
+*  Îļþ±êʶ  £º
+*  Ïà¹ØÎļþ  £º
+*  ʵÏÖ¹¦ÄÜ  £º
+*  ×÷Õß      £º
+*  °æ±¾      £ºV1.0
+*  Íê³ÉÈÕÆÚ  £º2014-6-20
+*  ÆäËü˵Ã÷  £º
+*
+******************************************************************************/
+
+/*****************************************************************************
+ Í·Îļþ
+******************************************************************************/
+#include "mmi_common.h"
+#include "mmi_lcd.h"
+
+//ÏÂÃæ¶¼ÊÇdebug¶¨Î»ÎÊÌâʱÓõ½µÄÈ«¾Ö±äÁ¿
+#define MMI_DEBUG_MAINCONTROL
+#ifdef MMI_DEBUG_MAINCONTROL
+SINT32 g_mmi_MainContrlIndex = -1;
+SINT32 g_mmi_MainContrlProcess = -1;//0, get content;1 gelceinfo; 2 show
+SINT32 g_mmi_MainContrl = -1;
+
+
+int g_debug[20] = {0};
+int g_debug_index = 0;
+#endif
+/********************************************************************************
+  È«¾Ö±äÁ¿ÒýÓÃ
+**********************************************************************************/
+extern E_zMmiShowMode g_showMode;
+
+/********************************************************************************
+  È«¾Ö±äÁ¿¶¨Òå
+**********************************************************************************/
+int g_mmi_msgQue_Id = 0;
+pthread_mutex_t g_mmi_lcdmode_mutex ;
+pthread_mutex_t g_mmi_ledmode_mutex ;
+pthread_mutex_t g_mmi_update_flag_mutex;
+pthread_mutex_t g_mmi_refresh_lcd_mutex;
+pthread_mutex_t g_mmi_poweron_mutex;
+
+sem_t g_mmi_update_sem_id;
+sem_t g_mmi_init_sem_id;
+sem_t g_mmi_traffic_warn_sem_id;
+sem_t g_mmi_poweroff_sem_id ;
+sem_t g_mmi_gui_init_sem_id;
+
+
+UINT32 	g_mmi_poweroff_turnon_flag = FALSE ;
+UINT32  g_mmi_led_status_flag = 0;
+T_zMMITaskInfoItem g_zMMITaskInfoTab[MMI_TASK_MAX] = {0};
+
+UINT32 g_smstask_enable = 0;
+UINT32 g_voicetask_enable = 0;
+UINT32 g_temp_protect = 0;
+UINT32 g_discharge_protect = 0;
+UINT32 g_charge_protect = 0;
+
+UINT32 g_fast_poweron = 0;
+UINT32 g_led_standby_mode = 0;
+UINT32 g_led_sleep_mode = 0;
+UINT32 g_use_wifi_usernum = 0;
+
+UINT32 g_show_pagefirst = 0;
+UINT32 g_show_pagesecond = 0;
+UINT32 g_show_pagethird = 0;
+/*
+SINT32 g_mmi_hightempvol = 0;
+SINT32 g_mmi_superhightempvol = 0;
+SINT32 g_mmi_lowtempvol = 0;
+SINT32 g_mmi_superlowtempvol = 0;
+*/
+SINT32 g_mmi_batvoltageline[21] = {0};
+
+SINT32 g_mmi_power_mode = 0;//0:charge;1:poweron
+
+//int g_customer_type = CUSTOMER_SDK;  // Õë¶Ô²»Í¬¿Í»§µÄ¶¨ÖÆÐèÇó
+extern int g_customer_type;
+
+extern VOID  mmi_BatLedOffOpt();
+extern VOID mmi_BatLedGreenOn();
+
+//ÉèÖô¥·¢¸üбêÖ¾
+VOID mmi_set_update_flag(E_zMmi_Task task)
+{
+	mmi_getMutex(&g_mmi_update_flag_mutex);
+	g_zMMITaskInfoTab[task].is_update = 1;
+	mmi_putMutex(&g_mmi_update_flag_mutex);
+
+	mmi_PutSemaphore(&g_mmi_update_sem_id);
+}
+
+VOID mmi_clean_update_flag(E_zMmi_Task task)
+{
+	mmi_getMutex(&g_mmi_update_flag_mutex);
+	g_zMMITaskInfoTab[task].is_update = 0;
+	mmi_putMutex(&g_mmi_update_flag_mutex);
+}
+SINT32 mmi_get_update_flag(E_zMmi_Task task)
+{
+	SINT32 ret = 0;
+	if (task >= MMI_TASK_MAX)//cov kw 3
+		return ret;
+	mmi_getMutex(&g_mmi_update_flag_mutex);
+	ret = g_zMMITaskInfoTab[task].is_update;
+	g_zMMITaskInfoTab[task].is_update = 0;
+	mmi_putMutex(&g_mmi_update_flag_mutex);
+	return ret;
+}
+
+//ÏÔʾledµÆ
+static VOID mmi_show_led_item(T_zMMITaskInfoItem* taskInfoItem)
+{
+	if (taskInfoItem->get_taskinfo_fun == NULL || taskInfoItem->taskinfo == NULL ||
+	    taskInfoItem->get_ledinfo_fun == NULL || taskInfoItem->ledinfo == NULL) {
+		//slog(MMI_PRINT,SLOG_DEBUG,"ZTE_MMI mmi_show_led parameter null!!!\n");
+		return;
+	}
+	if (taskInfoItem->get_taskinfo_fun((UINT32)taskInfoItem->taskinfo) == MMI_SUCCESS) { //e64
+		if (taskInfoItem->get_ledinfo_fun((UINT32)taskInfoItem->taskinfo, (UINT32)taskInfoItem->ledinfo) == MMI_SUCCESS) {
+			mmi_showLed((UINT32)taskInfoItem->ledinfo);
+		}
+	}
+}
+//ÏÔʾlcdµÆ
+static VOID mmi_show_lcd_item(T_zMMITaskInfoItem* taskInfoItem)
+{
+	if (taskInfoItem->get_taskinfo_fun == NULL || taskInfoItem->taskinfo == NULL ||
+	    taskInfoItem->get_lcdinfo_fun == NULL) {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_show_lcd parameter null!!!");
+		return;
+	}
+#ifdef MMI_DEBUG_MAINCONTROL
+	g_mmi_MainContrlProcess = 0;//0, get content;1 gelceinfo; 2 show
+#endif
+	if (taskInfoItem->get_taskinfo_fun((UINT32)taskInfoItem->taskinfo) == MMI_SUCCESS) {
+#ifdef MMI_DEBUG_MAINCONTROL
+		g_mmi_MainContrlProcess = 1;//0, get content;1 gelceinfo; 2 show
+#endif
+		if (taskInfoItem->get_lcdinfo_fun((UINT32)taskInfoItem->taskinfo) == MMI_SUCCESS) {
+#ifdef MMI_DEBUG_MAINCONTROL
+			g_mmi_MainContrlProcess = 2;//0, get content;1 gelceinfo; 2 show
+#endif
+			//mmi_showLcd(appInfoItem->lcdinfo);
+			mmi_invalidateLcd(taskInfoItem->taskinfo);
+		}
+	}
+}
+//MMIÖ÷¿Ø
+static VOID *mmi_mainControllerEntry(VOID *arg)
+{
+	UINT32 i = 0;
+	int ret = 0;
+
+#ifdef MMI_DEBUG_MAINCONTROL
+	g_mmi_MainContrl = 1;
+#endif
+
+#ifndef DISABLE_LCD
+	if (g_showMode == MMI_MODE_LCD || g_showMode == MMI_MODE_ALL) {
+		while ((ret = mmi_GetSemaphore(&g_mmi_init_sem_id, MMI_WAIT_FOREVER)) != MMI_SUCCESS) {
+			slog(MMI_PRINT, SLOG_DEBUG, "zte_mmi g_mmi_update_sem_id get failed ret = %d,errno=%d\n", ret, errno);
+			continue;
+		}
+		mmi_DeleteSemaphore(&g_mmi_init_sem_id);
+	}
+#endif
+
+	while (1) {
+		if ((ret = mmi_GetSemaphore(&g_mmi_update_sem_id, MMI_WAIT_FOREVER)) != MMI_SUCCESS) {//kw 3
+			slog(MMI_PRINT, SLOG_DEBUG, "zte_mmi mmi_mainControllerEntry failed ret = %d,errno=%d\n", ret, errno);
+			continue;
+		}
+		for (i = 0; i < sizeof(g_zMMITaskInfoTab) / sizeof(T_zMMITaskInfoItem); ++ i) { //warning539
+#ifdef MMI_DEBUG_MAINCONTROL
+			g_mmi_MainContrlIndex = i;
+#endif
+			if (mmi_get_update_flag(g_zMMITaskInfoTab[i].task)  == 1) { //ÓиüÐÂ
+				if (g_showMode == MMI_MODE_LED || g_showMode == MMI_MODE_ALL) { //led
+					mmi_show_led_item(&(g_zMMITaskInfoTab[i]));
+				}
+#ifndef DISABLE_LCD
+				if (g_showMode == MMI_MODE_LCD || g_showMode == MMI_MODE_ALL) { //lcd
+					mmi_show_lcd_item(&(g_zMMITaskInfoTab[i]));
+				}
+#endif
+			}
+		}
+#ifdef MMI_DEBUG_MAINCONTROL
+		g_mmi_MainContrlIndex = -1;
+		g_mmi_MainContrlProcess = -1;//0, get content;1 gelceinfo; 2 show
+#endif
+	}
+}
+
+
+//×¢²áMMIÒµÎñÐÅÏ¢
+VOID mmi_register_taskinfo_item(T_zMMITaskInfoItem* taskInfoItem)
+{
+	if (taskInfoItem != NULL) {
+		E_zMmi_Task task = taskInfoItem->task;//ÒµÎñ
+		g_zMMITaskInfoTab[task].task = taskInfoItem->task;
+		mmi_getMutex(&g_mmi_update_flag_mutex); //cov m
+		g_zMMITaskInfoTab[task].is_update = taskInfoItem->is_update;
+		mmi_putMutex(&g_mmi_update_flag_mutex);
+		//g_zMMIFrameInfoTab[appInfoItem->flag].show_mode= appInfoItem->show_mode;
+		g_zMMITaskInfoTab[task].taskinfo = taskInfoItem->taskinfo;
+		g_zMMITaskInfoTab[task].ledinfo = taskInfoItem->ledinfo;
+		g_zMMITaskInfoTab[task].get_taskinfo_fun = taskInfoItem->get_taskinfo_fun;
+		g_zMMITaskInfoTab[task].get_ledinfo_fun = taskInfoItem->get_ledinfo_fun;
+		g_zMMITaskInfoTab[task].get_lcdinfo_fun = taskInfoItem->get_lcdinfo_fun;
+	}
+}
+
+/********************************************************************************
+  MMI LOG´æÈëÎļþ
+**********************************************************************************/
+static char * mmi_get_time(void)
+{
+	time_t timep;
+	struct tm *p;
+	static char buf[22];
+	memset(buf, 0, 22);
+	time(&timep);
+	p = (struct tm *)localtime(&timep);
+	if (NULL == p) {
+		return NULL;
+	}
+	snprintf(buf, 21, "%4d/%02d/%02d %02d:%02d:%02d ", 1900 + p->tm_year, 1 + p->tm_mon, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec);
+	return buf;
+}
+
+void mmi_log_save(const char *fmt, ...)
+{
+	time_t timep;
+	struct tm p = {0};
+	va_list ap;
+	FILE *fp = NULL;
+	struct stat statbuff;
+
+	time(&timep);
+	localtime_r(&timep, &p);
+#if MMI_SERIAL_DEBUG
+	//printf("%4d/%02d/%02d %02d:%02d:%02d ",1900 + p.tm_year,1 + p.tm_mon,p.tm_mday,p.tm_hour,p.tm_min,p.tm_sec);
+	va_start(ap, fmt);
+	vprintf(fmt, ap);
+	va_end(ap);
+#endif
+
+#if MMI_FILE_DEBUG
+	fp = fopen(MMI_LOG_FILE_PATH, "a+");
+
+	if (fp) {
+		fprintf(fp, "%4d/%02d/%02d %02d:%02d:%02d ", 1900 + p.tm_year, 1 + p.tm_mon, p.tm_mday, p.tm_hour, p.tm_min, p.tm_sec);
+		va_start(ap, fmt);
+		vfprintf(fp, fmt, ap);
+		va_end(ap);
+		fclose(fp);
+		if (stat(MMI_LOG_FILE_PATH, &statbuff) == 0) {
+			if (statbuff.st_size >= MMI_MAX_LOG_LENGTH) {
+				remove(MMI_LOG_OLD_FILE_PATH);
+				rename(MMI_LOG_FILE_PATH, MMI_LOG_OLD_FILE_PATH);
+			}
+		}
+	}
+#endif
+}
+
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:´¦Àí·¢¸øMMI½ø³ÌµÄÏûÏ¢
+***********************************************************************************/
+//zdm ½«mmiÄܹ»´¦ÀíµÄËùÓÐÏûÏ¢¾ù½øÐд¦Àí£¬º¯ÊýÄÚ²¿Í¨¹ýnvÀ´¾ö¶¨ÊÇ·ñÕæÕý½øÐд¦Àí
+//Èç¹ûµ±Ç°»·¾³ÎÞ·¨´¦Àí¸ÃÏûÏ¢£¬Ö±½Ó·µ»Ø¼´¿É
+static int mmi_ProcMsg(MSG_BUF *pstMsg)
+{
+	int i = 0;
+	if (NULL == pstMsg) {
+		return -1;
+	}
+	//kw 3, kw bug???
+	//if ((pstMsg->usMsgCmd != MSG_CMD_MMICHECK_TIP_INFO) && (pstMsg->usMsgCmd != MSG_CMD_MMIGET_WIFI_DATA)) {
+		slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI Mmi_ProcMsg msg:src_id = 0x%04x,lMsgType = %d,usMsgCmd = 0x%08x,usDataLen = %d,data = %s\n", pstMsg->src_id, pstMsg->lMsgType, pstMsg->usMsgCmd, pstMsg->usDataLen, pstMsg->aucDataBuf);
+	//}
+	switch (pstMsg->usMsgCmd) {
+	case MSG_CMD_CHANNEL_NETWORK_MODE:
+		zMMI_Handle_Msg_Network_Mode((VOID *)pstMsg->aucDataBuf);
+		break;
+	case MSG_CMD_MULTI_CONNECT_STATUS:
+		zMMI_Handle_Msg_MultiConnect_Status((VOID *)pstMsg->aucDataBuf, pstMsg->src_id);
+		break;
+	case MSG_CMD_CHANNEL_CONNECT_STATUS:
+		zMMI_Handle_Msg_Connect_Status((VOID *)pstMsg->aucDataBuf);
+		break;
+	case MSG_CMD_OUT_REG_GET_SIGNAL_NUM:
+		zMMI_Handle_Msg_Signal_Num((VOID *)pstMsg->aucDataBuf);
+		break;
+	case MSG_CMD_SMS_STATUS_INFO_IND:
+		zMMI_Handle_Msg_SmsBox_Sattus((VOID *)pstMsg->aucDataBuf);
+		break;
+	case MSG_CMD_VOIP_STATUS_INFO:
+		zMMI_Handle_Msg_Voip_Status((VOID *)pstMsg->aucDataBuf);
+		break; //cov m
+	case MSG_CMD_RJ11_STATUS_INFO:
+		zMMI_Handle_Msg_Rj11_Status((VOID *)pstMsg->aucDataBuf);
+		break;
+	case MSG_CMD_RJ45_STATUS_INFO:
+		zMMI_Handle_Msg_Rj45_Status((VOID *)pstMsg->aucDataBuf);
+		break;
+	case MSG_CMD_MODIFY_SSID_KEY:
+		zMMI_Handle_Msg_Get_SSID_Key((VOID *)pstMsg->aucDataBuf);
+		break;
+	case MSG_CMD_MMIGET_WIFI_STANUM:
+	case MSG_CMD_STA_COUNT_CHANGE:
+		zMMI_Handle_Msg_Get_Wifi_StaNum((VOID *)pstMsg->aucDataBuf);
+		break;
+	case MSG_CMD_MMISTART_BACKLIGHTOFF_TIMER:
+		zMMI_Handle_Msg_BacklightOff((VOID *)pstMsg->aucDataBuf);
+		break;
+	case MSG_CMD_RESET_NOTIFY:
+		zMMI_Handle_Msg_Factory_Reset((VOID *)pstMsg->aucDataBuf);
+		break;
+	case MSG_CMD_POWEROFF_NOTIFY:
+		zMMI_Handle_Msg_Poweroff((VOID *)pstMsg->aucDataBuf);
+		break;
+	case MSG_CMD_RESTART_NOTIFY:
+		zMMI_Handle_Msg_Restart((VOID *)pstMsg->aucDataBuf);
+		break;
+	case MSG_CMD_GET_NET_PROVIDER:
+		zMMI_Handle_Msg_Get_Provider((VOID *)pstMsg->aucDataBuf);
+		break;
+	case MSG_CMD_GET_TRAFFIC_INFO_START:
+		zMMI_Handle_Msg_Get_TafficInfo_Start((VOID *)pstMsg->aucDataBuf);
+		break;
+	case MSG_CMD_GET_TRAFFIC_INFO_END:
+		zMMI_Handle_Msg_Get_TafficInfo_End((VOID *)pstMsg->aucDataBuf);
+		break;
+	case MSG_CMD_TRAFFIC_INFO_RESET:
+		zMMI_Handle_Msg_TafficInfo_Reset((VOID *)pstMsg->aucDataBuf);
+		break;
+	case MSG_CMD_MMICHECK_TIP_INFO:
+		zMMI_Handle_Msg_Check_Tip_Info((VOID *)pstMsg->aucDataBuf);
+		break;
+	case MSG_CMD_MMISHOW_SSID_INFO:
+		zMMI_Handle_Msg_SSID_Show_Info((VOID *)pstMsg->aucDataBuf);
+		break;
+	case MSG_CMD_MMIGET_WIFI_DATA:
+		zMMI_Handle_Msg_Get_Wifi_Data((VOID *)pstMsg->aucDataBuf);
+		break;
+	case MSG_CMD_POWEROFF_RSP:
+		zMMI_Handle_Msg_Plugout((VOID *)pstMsg->aucDataBuf);
+		break;
+	case MSG_CMD_SIM_ABNORMAL_IND:
+		zMMI_Handle_Msg_Simcard_Info((VOID *)pstMsg->aucDataBuf);
+		break;
+	case MSG_CMD_SOCKET_STATE_CHANGE:
+		zMMI_Handle_Msg_Socket_Status((VOID *)pstMsg->aucDataBuf, pstMsg->src_id);
+		break;
+	case MSG_CMD_MCUSOCKET_STATE_CHANGE:
+		zMMI_Handle_Msg_MCUSocket_Status((VOID *)pstMsg->aucDataBuf);
+		break;
+#if 0
+	case MSG_CMD_AUTOTEST_KEY_REQ:
+		if (g_mmi_power_mode == 1)
+			zMMI_Handle_Msg_Atest_Key((VOID *)pstMsg->aucDataBuf);
+		else
+			zMMI_Handle_Msg_Atest_Chg((VOID *)pstMsg->aucDataBuf);
+		break;
+#endif
+	}
+	return 0;
+#if 0
+	for (i = 0; i < (SINT32)(sizeof(scmp_info) / sizeof(scmp_info[0])); i++) {
+		if (pstMsg->usMsgCmd == scmp_info[i].id) {
+			if (scmp_info[i].func_ptr != NULL) {
+				scmp_info[i].func_ptr((VOID *)pstMsg->aucDataBuf);
+			}
+			return 0;
+		}
+	}
+#endif
+
+	return 0;
+}
+
+
+static void *mmi_handleMsgEntry(void *arg)
+{
+	long MsgType = 0;
+	MSG_BUF MmiMsg;
+	prctl(PR_SET_NAME, "mmihandlemsg", 0, 0, 0);
+	while (1) {
+		memset((VOID *)(&MmiMsg), 0, sizeof(MSG_BUF));//warning516
+		if (-1 != mmi_RecvMsgFromQueue(g_mmi_msgQue_Id, &MmiMsg, MsgType)) {
+			mmi_ProcMsg(&MmiMsg);
+		}
+	}
+}
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:¿ª»úʱÆÁ»òµÆµÄ¶¯×÷
+		 LCD ÏÔʾ¿ª»ú¶¯»­
+		 LED Á÷Á¿µÆÏÈÈ«²¿Ï¨Ãð ÆäÓàËĸöµÆÍ¬Ê±ÉÁһϠÔÙ¸ù¾Ýʵ¼Ê״̬ÁÁÆð
+***********************************************************************************/
+static VOID mmi_set_poweron_show(VOID)
+{
+	mmi_set_led_mode(MMI_POWERON_MODE);
+	mmi_set_update_flag(MMI_TASK_CTRL);//¿ª»úģʽ ÏÔʾ¿ª»ú¶¯»­
+}
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:mmi ÒµÎñ×¢²á
+***********************************************************************************/
+
+//zdm ʹÓÃnv¿ØÖÆÒµÎñµÄ×¢²áºÍ³õʼ»¯£¬ÔÝʱµÄʵÏÖÊǶÔÓÚ¿ª»úÉϵçµÄÿ¸öÒµÎñ£¬¾ùÌṩһ¸önv¿ØÖÆ
+//ºóÆÚÒª¸ù¾ÝÐèÇó£¬ÌáÈ¡³ö±ØÐëʹÓõÄnv¿ØÖÆÏ¶ÔÓÚÈκÎÇé¿öÏ£¬¾ùÐèÒªµÄÒµÎñ£¬Ö±½Ó×¢²á¾Í¿ÉÒÔ
+//²»ÔÙʹÓÃnv¿ØÖÆ£¬±ÈÈçMMI_TASK_CTRL£¬°´ÕÕÀí½âÓ¦¸ÃËùÓеij¡¾°Ï¾ùÐèҪע²áºÍ³õʼ»¯
+
+
+static int mmi_task_register()
+{
+	UINT32 i = 0;
+	char *nv_task_tab[NV_CONTENT_LEN] = {0};
+
+	//zdm ÔÚ×¢²áºÍ³õʼ»¯ÒµÎñ֮ǰ£¬ÏȽ«ÒµÎñĿ¼ÖеÄÿ¸öÒµÎñÏîÖÃΪÎÞЧ
+	for (i = 0; i < sizeof(g_zMMITaskInfoTab) / sizeof(T_zMMITaskInfoItem); ++ i) {
+		g_zMMITaskInfoTab[i].task = MMI_TASK_INVALID;
+	}
+
+	//Èç¹ûÓÐÓëled/lcd¾ùÐèҪʹÓõÄÒµÎñ£¬ÔÚÕâÀïÍê³É×¢²á£¬×¢²áºÍ³õʼ»¯º¯ÊýÄÚ²¿½øÐÐÇø·ÖlcdºÍled
+
+	cfg_get_item("mmi_task_tab", nv_task_tab, sizeof(nv_task_tab));
+
+	if (strstr(nv_task_tab, "net_task")) {
+		mmi_RegisterNetTaskInfoItem();
+	}
+
+	//Ó²¼þÏÞÖÆ£¬Á½¸öÒµÎñ¸´ÓÃͬһ¸öÓ²¼þµÆ,Òò´ËnvʹÓÃsmsºÍvoice½øÐÐÇø·Ö
+
+	if (strstr(nv_task_tab, "sms_task") && strstr(nv_task_tab, "voice_task")) {
+		assert(0);
+	}
+
+	if (strstr(nv_task_tab, "sms_task")) {
+		mmi_RegisterSmsTaskInfoItem();
+		g_smstask_enable = 1;
+	} else if (strstr(nv_task_tab, "voice_task")) {
+		mmi_RegisterVoipTaskInfoItem();
+		g_voicetask_enable = 1;
+	}
+
+	//ÊÇ·ñÓÐµç³ØÌõ¼þ¿ØÖÆ
+	if (strstr(nv_task_tab, "battery_task")) {
+		mmi_RegisterBatteryTaskInfoItem();
+
+	}
+
+	if (strstr(nv_task_tab, "ctrl_task")) {
+		mmi_RegisterCtrlTaskInfoItem();
+	}
+
+
+	if (strstr(nv_task_tab, "wifi_task")) {
+		mmi_RegisterWifiTaskInfoItem();
+	}
+
+
+	if (strstr(nv_task_tab, "traffic_task")) {
+		mmi_RegisterTrafficTaskInfoItem();
+	}
+
+	if (strstr(nv_task_tab, "rj45_task")) {
+		mmi_RegisterRj45TaskInfoItem();
+	}
+
+	if (g_showMode == MMI_MODE_LED || g_showMode == MMI_MODE_ALL) {
+		//×¢²áÓëledÏà¹ØµÄÒµÎñ £¬ÇëÎâºìʵÏÖ
+		if (strstr(nv_task_tab, "netsignal_task")) {
+			mmi_RegisterNetSigTaskInfoItem();
+		}
+		if (strstr(nv_task_tab, "ledwps_task")) {
+			mmi_RegisterWpsTaskInfoItem();
+		}
+		if (strstr(nv_task_tab, "rj11_task")) {
+			mmi_RegisterRj11TaskInfoItem();
+		}
+	}
+
+#ifndef DISABLE_LCD
+	if (g_showMode == MMI_MODE_LCD || g_showMode == MMI_MODE_ALL) {
+		//×¢²áÓëlcdÏà¹ØµÄÒµÎñ£¬ÇëÎâºìʵÏÖ
+		if (strstr(nv_task_tab, "tip_task")) {
+			mmi_RegisterTipTaskInfoItem();
+		}
+		//Ó²¼þÓеçÁ¿¼ÆµÄÌõ¼þÏ£¬²ÅÄÜ´ò¿ª
+
+		if (strstr(nv_task_tab, "power_task")) {
+			mmi_RegisterPowerTaskInfoItem();
+		}
+		//Ö§³ÖwifiµÄÇé¿öϲÅÄÜÖ§³Ö
+		if (strstr(nv_task_tab, "ssid_task")) {
+			mmi_RegisterSSIDInfoTaskInfoItem();
+		}
+		if (strstr(nv_task_tab, "wificode_task")) {
+			mmi_RegisterWifiCodeTaskInfoItem();
+		}
+		if (strstr(nv_task_tab, "tipnetconnect_task")) {
+			mmi_RegisterTipNetConnectTaskInfoItem();
+		}
+
+		if (strstr(nv_task_tab, "tipwps_task")) {
+			mmi_RegisterTipWpsTaskInfoItem();
+		}
+		if (strstr(nv_task_tab, "tipfota_task")) {
+			mmi_RegisterTipFotaTaskInfoItem();
+
+		}
+		if (strstr(nv_task_tab, "tipwifistation_task")) {
+			mmi_RegisterTipWifiStationConnectTaskInfoItem();
+		}
+	}
+#endif
+	return 0;
+}
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:mmi ÒµÎñ³õʼ»¯
+***********************************************************************************/
+
+//¶ÔÓÚÓÐÐèÇó¿ØÖƵÄijЩҵÎñ£¬ÌáÈ¡³Énv¿ØÖÆ£¬¸ù¾ÝÐèÇó½øÐдò¿ªºÍ¹Ø±ÕÅäÖÃ
+static int mmi_task_init()
+{
+	char *nv_task_tab[NV_CONTENT_LEN] = {0};
+
+
+	//Èç¹ûÓÐÓëled/lcd¾ùÐèҪʹÓõÄÒµÎñ£¬ÔÚÕâÀïÍê³É³õʼ»¯
+
+	cfg_get_item("mmi_task_tab", nv_task_tab, sizeof(nv_task_tab));
+
+
+	if (strstr(nv_task_tab, "net_task")) {
+		mmi_net_init();
+	}
+
+	//Ó²¼þÏÞÖÆ£¬Á½¸öÒµÎñ¸´ÓÃͬһ¸öÓ²¼þµÆ,Òò´ËnvʹÓÃsmsºÍvoice½øÐÐÇø·Ö
+	if (strstr(nv_task_tab, "sms_task")) {
+		mmi_sms_init();
+
+	} else if (strstr(nv_task_tab, "voice_task")) {
+		mmi_voip_init();
+
+	}
+
+	//ÊÇ·ñÓÐµç³ØÌõ¼þ¿ØÖÆ
+	if (strstr(nv_task_tab, "battery_task")) {
+		mmi_battery_init();
+
+	}
+
+	if (strstr(nv_task_tab, "ctrl_task")) {
+		mmi_init_idle_control();
+	}
+
+	if (strstr(nv_task_tab, "wifi_task")) {
+		mmi_wifi_init();
+	}
+
+	if (strstr(nv_task_tab, "traffic_task")) {
+		mmi_traffic_init();
+	}
+
+	if (strstr(nv_task_tab, "key_task")) {
+		mmi_keyStrokes_init();
+	}
+
+	if (strstr(nv_task_tab, "rj45_task")) {
+		mmi_rj45_init();
+	}
+	//³õʼ»¯½öÓëledÏà¹ØµÄÒµÎñ £¬ÇëÎâºìʵÏÖ
+	if (g_showMode == MMI_MODE_LED || g_showMode == MMI_MODE_ALL) {
+	}
+
+#ifndef DISABLE_LCD
+	//³õʼ»¯½öÓëlcdÏà¹ØµÄÒµÎñ£¬ÇëÎâºìʵÏÖ
+	if (g_showMode == MMI_MODE_LCD || g_showMode == MMI_MODE_ALL) {
+		if (strstr(nv_task_tab, "tip_task")) {
+			mmi_init_lcd_tip();
+		}
+	}
+#endif
+	return 0;
+}
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:mmi ÏÔʾģʽ³õʼ»¯
+***********************************************************************************/
+static int mmi_showmode_init()
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_showmode_init \n");
+	if (g_showMode == MMI_MODE_LED || g_showMode == MMI_MODE_ALL) {
+		mmi_initLed();
+	}
+
+#ifndef DISABLE_LCD
+	if (g_showMode == MMI_MODE_LCD || g_showMode == MMI_MODE_ALL) {
+		mmi_set_lcd_page_index(MMI_SHOW_PAGE_FIRST);
+		mmi_initLcd(FALSE);
+	}
+#endif
+	return 0;
+}
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:MMIÈë¿Úº¯Êý  ´´½¨ÏûÏ¢¶ÓÁÐ ¸÷¸öµÆ³õʼ»¯ ½ÓÊÕÏûÏ¢
+***********************************************************************************/
+VOID mmi_powerOnLcdEntry()
+{
+	pthread_t mmi_handlemsg_thread;
+	//´´½¨MMIÏûÏ¢¶ÓÁÐ
+	if ((g_mmi_msgQue_Id = mmi_create_msg_queue()) == -1) {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI create g_mmi_msgQue_Id failed!!!\n");
+		MMI_ASSERT(0);
+	}
+	pthread_mutex_init(&g_mmi_lcdmode_mutex, NULL);
+	pthread_mutex_init(&g_mmi_ledmode_mutex, NULL);
+	pthread_mutex_init(&g_mmi_update_flag_mutex, NULL);
+	pthread_mutex_init(&g_mmi_refresh_lcd_mutex, NULL);
+	sem_init(&g_mmi_update_sem_id, 0, 0);
+	sem_init(&g_mmi_init_sem_id, 0, 0);
+	sem_init(&g_mmi_traffic_warn_sem_id, 0, 0);
+	sem_init(&g_mmi_poweroff_sem_id, 0, 0); //ÓÃÓڹػúʱ±£Ö¤LCDÆÁ²¥Íê¹Ø»ú¶¯»­ºóÃðÆ½»òLEDµÆ¶¼ÁÁÖ®ºóÔÙÃðµÆ
+
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI start set_mmi_active\n");
+	set_wake_lock(MMI_MAIN_LOCK_ID);
+
+	//´´½¨MMI ´¦ÀíÏûÏ¢Ïß³Ì
+	if (pthread_create(&mmi_handlemsg_thread, NULL, &mmi_handleMsgEntry, NULL) == -1) {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI pthread_create handle msg error\n");
+		return ;
+	}
+	mmi_showmode_init();
+
+	mmi_task_register();
+	mmi_task_init();
+
+	mmi_set_poweron_show();
+	slog(MMI_PRINT, SLOG_NORMAL, "ZTE_MMI main Register finish!!\n");
+
+	//´´½¨MMIÖ÷¿ØÏß³Ì
+	mmi_mainControllerEntry(NULL);
+}
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:¹Ø»ú³äµç
+***********************************************************************************/
+VOID mmi_poweroffcharger_init()
+{
+
+	UINT32 i = 0;
+	pthread_t mmi_handlemsg_thread;
+	//´´½¨MMIÏûÏ¢¶ÓÁÐ
+	if ((g_mmi_msgQue_Id = mmi_create_msg_queue()) == -1) {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI create g_mmi_msgQue_Id failed!!!\n");
+		MMI_ASSERT(0);
+	}
+
+	pthread_t mmi_offchg_mainctrl_thread;
+	pthread_mutex_init(&g_mmi_update_flag_mutex, NULL);
+	pthread_mutex_init(&g_mmi_poweron_mutex, NULL);
+	sem_init(&g_mmi_update_sem_id, 0, 0);
+	sem_init(&g_mmi_init_sem_id, 0, 0);
+
+#ifndef DISABLE_LCD
+	if (g_showMode == MMI_MODE_LCD || g_showMode == MMI_MODE_ALL) {
+		sem_init(&g_mmi_gui_init_sem_id, 0, 0);
+	}
+#endif
+
+	//´´½¨MMI ´¦ÀíÏûÏ¢Ïß³Ì
+	if (pthread_create(&mmi_handlemsg_thread, NULL, &mmi_handleMsgEntry, NULL) == -1) {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI pthread_create handle msg error\n");
+		return ;
+	}
+
+	for (i = 0; i < sizeof(g_zMMITaskInfoTab) / sizeof(T_zMMITaskInfoItem); ++ i) {
+		g_zMMITaskInfoTab[i].task = MMI_TASK_INVALID;
+	}
+
+	offchg_RegisterPocTaskInfoItem();
+	if (g_showMode == MMI_MODE_LED || g_showMode == MMI_MODE_ALL) {
+		mmi_initLed();
+	}
+#ifndef DISABLE_LCD
+	if (g_showMode == MMI_MODE_LCD || g_showMode == MMI_MODE_ALL) {
+		mmi_initLcd(TRUE);
+	}
+#endif
+
+	int res = pthread_create(&mmi_offchg_mainctrl_thread, NULL, &mmi_mainControllerEntry, NULL);
+	if (res != 0) {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI pthread_create main control error\n");
+		assert(0);
+	}
+}
+
+static int get_nv()
+{
+	char mmi_nv_value[NV_CONTENT_LEN] = {0};
+	SINT32 ret_fd = -1;
+	int state = 0;
+
+	//ÉèÖÃmmiÏÔʾģʽȫ¾Ö±äÁ¿
+	cfg_get_item("mmi_showmode", mmi_nv_value, sizeof(mmi_nv_value));
+	if (0 == strcmp(mmi_nv_value, "led")) {
+		g_showMode = MMI_MODE_LED;
+		ret_fd = open(LCD_PATH, O_RDWR);
+		if (ret_fd == -1) 
+		{
+			slog(MMI_PRINT, SLOG_ERR,"ZTE_MMI mmi_file_operate open file fail: %s!\n", LCD_PATH);
+		}
+		else
+		{
+			if(ioctl(ret_fd, LEADT15DS26_SET_BACKLIGHT, &state) < 0)
+			{
+				slog(MMI_PRINT, SLOG_ERR,"get_nv ioctl fail!\n");
+			}
+		}
+	} else if (0 == strcmp(mmi_nv_value, "lcd")) {
+		g_showMode = MMI_MODE_LCD;
+	} else if (0 == strcmp(mmi_nv_value, "all")) {
+		g_showMode = MMI_MODE_ALL;
+	} else {
+		assert(0);
+	}
+
+	cfg_get_item("customer_type",mmi_nv_value,sizeof(mmi_nv_value));
+	if(0 == strcmp(mmi_nv_value, "sdk_min"))
+	{
+		g_customer_type = CUSTOMER_SDK_MIN;
+	}
+	else if(0 == strcmp(mmi_nv_value, "guodian"))
+	{
+		g_customer_type = CUSTOMER_GUODIAN;
+	}
+	else if(0 == strcmp(mmi_nv_value, "nandian"))
+	{
+		g_customer_type = CUSTOMER_NANDIAN;
+	}
+
+	cfg_get_item("mmi_use_protect", mmi_nv_value, sizeof(mmi_nv_value));
+
+	if (strstr(mmi_nv_value, "discharge_protect")) {
+		g_discharge_protect = 1;
+	}
+
+	if (strstr(mmi_nv_value, "temp_protect")) {
+		g_temp_protect = 1;
+
+		if (strstr(mmi_nv_value, "charge_protect")) {
+			g_charge_protect = 1;
+		}
+	}
+
+	cfg_get_item("mmi_fast_poweron", mmi_nv_value, sizeof(mmi_nv_value));
+
+	if (0 == strcmp(mmi_nv_value, "1")) {
+		g_fast_poweron = 1;
+
+	}
+
+	cfg_get_item("mmi_led_mode", mmi_nv_value, sizeof(mmi_nv_value));
+
+	if (strstr(mmi_nv_value, "standby_mode")) {
+		g_led_standby_mode = 1;
+
+	}
+
+	if (strstr(mmi_nv_value, "sleep_mode")) {
+		g_led_sleep_mode = 1;
+	}
+
+
+	cfg_get_item("mmi_use_wifi_usernum", mmi_nv_value, sizeof(mmi_nv_value));
+
+	if (0 == strcmp(mmi_nv_value, "1")) {
+		g_use_wifi_usernum = 1;
+	}
+
+	cfg_get_item("mmi_show_pagetab", mmi_nv_value, sizeof(mmi_nv_value));
+
+	if (strstr(mmi_nv_value, "page1")) {
+		g_show_pagefirst = 1;
+	}
+	if (strstr(mmi_nv_value, "page2")) {
+		g_show_pagesecond = 1;
+	}
+	if (strstr(mmi_nv_value, "page3")) {
+		g_show_pagethird = 1;
+	}
+	/*
+	cfg_get_item("mmi_temp_voltage_line", mmi_nv_value, sizeof(mmi_nv_value));
+	{
+		char *tmp = NULL;
+		char *substr = strtok_r(mmi_nv_value, "+",&tmp);
+		int temp[4] = {0};
+		int i = 0;
+		while (substr != NULL) {
+			temp[i] = atoi(substr);
+			i++;
+			substr = strtok_r(NULL, "+",&tmp);
+		}
+		g_mmi_superhightempvol = temp[0];
+		g_mmi_hightempvol = temp[1];
+		g_mmi_lowtempvol = temp[2];
+		g_mmi_superlowtempvol = temp[3];
+	}
+	*/
+	cfg_get_item("mmi_battery_voltage_line", mmi_nv_value, sizeof(mmi_nv_value));
+	{
+		char *tmp = NULL;
+		char *substr = strtok_r(mmi_nv_value, "+",&tmp);
+		int i = 0;
+		while (substr != NULL) {
+			g_mmi_batvoltageline[i] = atoi(substr);
+			slog(MMI_PRINT, SLOG_DEBUG, "g_mmi_batvoltageline[%d] = %d\n", i, g_mmi_batvoltageline[i]);
+			i++;
+			substr = strtok_r(NULL, "+",&tmp);
+		}
+	}
+	if(ret_fd >= 0)
+	close(ret_fd);
+	return 0;
+}
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:MMIÈë¿Úº¯Êý  ´´½¨ÏûÏ¢¶ÓÁÐ ¸÷¸öµÆ³õʼ»¯ ½ÓÊÕÏûÏ¢
+***********************************************************************************/
+int zte_mmi_main(int argc, char * argv[])
+{
+	prctl(PR_SET_NAME, "mmi", 0, 0, 0);
+	//¸ù¾ÝNV³õʼ»¯´òÓ¡¼¶±ð£¬²¢×¢²á¶¯Ì¬µ÷Õû´òÓ¡¼¶±ðÐźÅÁ¿
+	loglevel_init();
+
+	//zdm½«nvÉèÖÃת»»³ÉÈ«¾Ö±äÁ¿½øÐй¦ÄÜ¿ØÖÆ
+	get_nv();
+	mmi_BatLedOffOpt();//¹ØbootµãµÄµÆ
+	mmi_BatLedGreenOn();// R306 ÐèÇó :µçÔ´µÆÎªÂÌµÆ 
+#ifdef DISABLE_LCD
+	if (g_showMode != MMI_MODE_LED) {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI MIN only support LED \n");
+		return -1;
+	}
+#endif
+
+	if (argc >= 2) {
+		slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI ###POWER OFF CHARGER START####\n");
+		g_mmi_power_mode = 0;
+		zMmi_PowerOffChargerEntry();
+	} else {
+		slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI ######START######\n");
+		g_mmi_power_mode = 1;
+		mmi_powerOnLcdEntry();
+	}
+	return 0;
+}
+
diff --git a/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_battery.c b/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_battery.c
new file mode 100755
index 0000000..330b954
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_battery.c
@@ -0,0 +1,568 @@
+/*****************************************************************************
+*  °æ±¾ËùÓÐ (C)ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾
+*  Ä£¿éÃû    £ºMMI
+*  ÎļþÃû    £ºmmi_batterry.c
+*  Îļþ±êʶ  £º
+*  Ïà¹ØÎļþ  £º
+*  ʵÏÖ¹¦ÄÜ  £ºMMI»ñÈ¡³äµçºÍµç³ØÐÅÏ¢
+*  ×÷Õß      £º
+*  °æ±¾      £ºV1.0
+*  Íê³ÉÈÕÆÚ  £º2014-6-20
+*  ÆäËü˵Ã÷  £º
+*
+******************************************************************************/
+
+
+/************************************************************************************
+                           Í·Îļþ
+***********************************************************************************/
+#include "mmi_lcd.h"
+#include <linux/netlink.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <mmi_common.h>
+#include "hotplug.h"
+
+
+/************************************************************************************
+                            È«¾Ö±äÁ¿¶¨Òå
+***********************************************************************************/
+
+static UINT32 s_mmi_poweroff_voltage_num = 0;//¶Áµ½µÍµç¹Ø»úµçѹµÄ´ÎÊý£¬Á¬ÐøÈý´Î×Ô¶¯¹Ø»ú
+static SINT32 g_mmi_voltageEx = 0;//ÿ20s²éѯµçѹʱ£¬±£´æÉÏÒ»´ÎµÄµçѹ
+static E_zMmi_Charge_State s_mmi_charge_state = STATE_CHARGE_MAX; //ÿ´ÎÊÕµ½Çý¶¯Éϱ¨Ê±£¬±£´æµ±Ç°µÄ³äµç״̬
+static E_zMmi_Charge_State s_mmi_charge_stateEx = STATE_CHARGE_MAX;//ÿ´ÎÊÕµ½Çý¶¯Éϱ¨Ê±£¬±£´æÉÏÒ»´ÎµÄ³äµç״̬
+static E_zMmi_Voltage_level s_mmi_voltage_level = VOLT_MAX;//²éѯµçѹʱ£¬¸ù¾Ýµçѹֵ±£´æµ±Ç°µçÁ¿·¶Î§
+
+static BOOL g_mmi_chg_switch_off = FALSE;//¼Ç¼³äµç¹Ø±Õ¿ª¹Ø£¬Ä¬ÈÏÔÊÐí³äµç
+static BOOL s_mmi_usb_insert_status = FALSE;//0:USB²åÈë״̬ 1:USB δ²åÈë״̬
+static SINT32 s_mmi_battery_pers = 0;//µçÁ¿°Ù·Ö±ÈÇø¼ä
+
+static MMI_TEMP_DETECT last_temp = MMI_TEMP_DETECT_MAX;//µç³ØÉÏÒ»´ÎζÈ״̬
+static SINT32 s_mmi_temp_count = 0;//ζÈÒ쳣ʱ¼ÆÊýÆ÷£¬Á¬Ðø3´Îºó½øÐÐÏàÓ¦´¦Àí
+
+
+extern E_zMmiShowMode g_showMode;
+extern UINT32 g_temp_protect;
+extern UINT32 g_discharge_protect;
+extern UINT32 g_charge_protect;
+extern UINT32 g_fast_poweron;
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡µç³ØÐÅÏ¢
+***********************************************************************************/
+SINT32 mmi_get_batteryinfo(UINT32 batteryinfo)
+{
+	if (batteryinfo != 0) {
+		T_zMMIBatteryInfo * pBatInfo = (T_zMMIBatteryInfo *)batteryinfo;
+		pBatInfo->chg_state = s_mmi_charge_state;
+		pBatInfo->bat_level = s_mmi_voltage_level;
+		pBatInfo->bat_pers = s_mmi_battery_pers;
+		pBatInfo->bat_grid = pBatInfo->bat_pers <= 5 ? 0 : (pBatInfo->bat_pers <= 25 ? 1 : (pBatInfo->bat_pers <= 50 ? 2 : (pBatInfo->bat_pers < 100 ? 3 : 4))); /*ÐèÇóÒªÇó<=5ÏÔʾºì¿ò0¸ñ,<=25ÏÔʾ1¸ñ*/
+	}
+	return MMI_SUCCESS;
+}
+
+SINT32 mmi_RegisterBatteryTaskInfoItem()
+{
+	T_zMMITaskInfoItem batteryTaskInfoItem = {0};
+
+	batteryTaskInfoItem.task = MMI_TASK_BATTERY;
+	batteryTaskInfoItem.taskinfo = (VOID *)malloc(sizeof(T_zMMIBatteryInfo));
+	batteryTaskInfoItem.get_taskinfo_fun = mmi_get_batteryinfo;
+	batteryTaskInfoItem.get_ledinfo_fun = mmi_getLedBatteryInfo;
+#ifndef DISABLE_LCD
+	batteryTaskInfoItem.get_lcdinfo_fun = mmi_getLcdBatteryInfo;
+#endif
+	batteryTaskInfoItem.ledinfo = (VOID *)malloc(sizeof(T_zMmi_Led_Info));
+	//batteryAppInfoItem.show_mode = 2;
+	mmi_register_taskinfo_item(&batteryTaskInfoItem);
+	return MMI_SUCCESS;
+}
+SINT32 mmi_RegisterPowerTaskInfoItem()
+{
+	T_zMMITaskInfoItem batteryTaskInfoItem = {0};
+	batteryTaskInfoItem.task = MMI_TASK_POWER;
+	batteryTaskInfoItem.taskinfo = (VOID *)malloc(sizeof(T_zMMIBatteryInfo));
+	batteryTaskInfoItem.get_taskinfo_fun = mmi_get_batteryinfo;
+	batteryTaskInfoItem.get_ledinfo_fun = mmi_getLedBatteryInfo;
+#ifndef DISABLE_LCD
+	batteryTaskInfoItem.get_lcdinfo_fun = mmi_getLcdPowerInfo;
+#endif
+	batteryTaskInfoItem.ledinfo = (VOID *)malloc(sizeof(T_zMmi_Led_Info));
+	//batteryAppInfoItem.show_mode = 2;
+	mmi_register_taskinfo_item(&batteryTaskInfoItem);
+	return MMI_SUCCESS;
+}
+
+static VOID mmi_set_battery_update(VOID)
+{
+	if (g_showMode == MMI_MODE_LCD || g_showMode == MMI_MODE_ALL) {
+		mmi_set_update_flag(MMI_TASK_BATTERY);
+	}
+	if (g_showMode == MMI_MODE_LED || g_showMode == MMI_MODE_ALL) {
+		E_zMmi_Work_Mode mode = mmi_get_led_mode();
+		if (mode != MMI_IDLE_LEDOFF_MODE && mode != MMI_FAKE_POWEROFF_MODE && mode != MMI_IDLE_STANDBY_LEDOFF_MODE) {
+			mmi_set_update_flag(MMI_TASK_BATTERY);
+		}
+	}
+}
+VOID mmi_set_discharge_low_current(BOOL discharge_low_current_flag)
+{
+	if (discharge_low_current_flag) {
+		system(MMI_DISCHG_LOW_CURRENT);
+	} else {
+		system(MMI_DISCHG_HIGH_CURRENT);
+	}
+}
+
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:¸æÖªcharger½øÈë¼Ù¹Ø»úģʽ
+***********************************************************************************/
+VOID mmi_set_fake_poweroff_charger(int fake_poweroff_flag)
+{
+	if (fake_poweroff_flag == 1) {
+		system(MMI_SET_FAKEPOWEROFF_CHARGER);
+	} else {
+		system(MMI_CAN_FAKEPOWEROFF_CHARGER);
+	}
+}
+
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:µÍµç¹Ø»ú´¦Àí
+***********************************************************************************/
+static void mmi_lowbattery_shutdown(UINT32 voltagepower)
+{
+	if (voltagepower < POWEROFFLEVEL) {
+		s_mmi_poweroff_voltage_num ++ ;
+		if (s_mmi_poweroff_voltage_num == 3) {
+			s_mmi_poweroff_voltage_num = 0;
+			mmi_set_abnormal_poweroff_flag();
+
+			slog(MMI_PRINT, SLOG_NORMAL, "ZTE_MMI poweroff,lowerbattery!!!\n");
+			mmi_set_poweroff();
+		}
+	} else {
+		s_mmi_poweroff_voltage_num = 0;
+	}
+}
+
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:¸ù¾Ýµç³ØµçѹÉèÖÃµç³Ø°Ù·Ö±È¡¢webUI¶ÔÓ¦µç³Ø¸ñ
+Êý¡¢µç³Ø×´Ì¬(5%,10%,20%,25%,normal)
+***********************************************************************************/
+static VOID mmi_battery_capacity_compare(SINT32 voltagepower)
+{
+	int cur_power = 0;
+	int bat_level = 0;
+	if (g_mmi_voltageEx != 0) {
+		cur_power = voltagepower < g_mmi_voltageEx ? voltagepower : g_mmi_voltageEx;
+	} else {
+		cur_power = voltagepower;
+	}
+
+	if (g_discharge_protect) {
+		mmi_lowbattery_discharge_protect(voltagepower);
+	}
+	mmi_lowbattery_shutdown(voltagepower);
+	g_mmi_voltageEx = cur_power;
+	bat_level = get_voltage_level_from_table(cur_power);
+	mmi_set_webUI_batterypers(bat_level);
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_battery_capacity_compare voltagepower = %d !! cur_power = %d  !! bat_level = %d\n ", voltagepower, cur_power, bat_level);
+	s_mmi_battery_pers = bat_level;
+	s_mmi_voltage_level = mmi_set_battery_state(bat_level);
+
+}
+VOID mmi_set_mode_fast_poweron(BOOL chgflag)
+{
+
+	if (!g_fast_poweron)
+		return;
+	if (g_showMode == MMI_MODE_LED || g_showMode == MMI_MODE_ALL) {
+		if (chgflag) {
+			if (mmi_get_led_mode() == MMI_FAKE_POWEROFF_MODE || mmi_get_led_mode() == MMI_FAKE_POWEROFF_CHARGE_MODE) {
+				slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_set_battery_info  startcharging MMI_FAKE_POWEROFF_CHARGE_MODE \n\n");
+				mmi_set_led_mode(MMI_FAKE_POWEROFF_CHARGE_MODE);
+				mmi_set_update_flag(MMI_TASK_CTRL);
+			}
+		} else {
+			if (mmi_get_led_mode() == MMI_FAKE_POWEROFF_CHARGE_MODE) {
+				slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_set_battery_info  discharging MMI_FAKE_POWEROFF_MODE \n\n");
+				mmi_set_led_mode(MMI_FAKE_POWEROFF_MODE);
+				mmi_set_update_flag(MMI_TASK_CTRL);
+			}
+		}
+	}
+#ifndef DISABLE_LCD
+	if (g_showMode == MMI_MODE_LCD || g_showMode == MMI_MODE_ALL) {
+		if (chgflag) {
+			if (mmi_get_lcd_mode() == MMI_FAKE_POWEROFF_MODE || mmi_get_lcd_mode() == MMI_FAKE_POWEROFF_CHARGE_MODE) {
+				slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_set_battery_info  startcharging MMI_FAKE_POWEROFF_CHARGE_MODE \n\n");
+				mmi_set_lcd_mode(MMI_FAKE_POWEROFF_CHARGE_MODE);
+				mmi_set_update_flag(MMI_TASK_CTRL);
+			}
+		} else {
+			if (mmi_get_lcd_mode() == MMI_FAKE_POWEROFF_CHARGE_MODE) {
+				slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_set_battery_info  discharging MMI_FAKE_POWEROFF_MODE \n\n");
+				mmi_set_lcd_mode(MMI_FAKE_POWEROFF_MODE);
+				mmi_set_update_flag(MMI_TASK_CTRL);
+			}
+		}
+	}
+#endif
+}
+
+/**********************************************************************************
+*º¯Êý˵Ã÷£º»ñÈ¡³äµç״̬
+ ***********************************************************************************/
+static VOID mmi_set_battery_info(VOID)
+{
+	E_zMmi_Charge_State chg_sta = STATE_CHARGE_MAX;
+	int power = 0;
+	chg_sta = mmi_get_charge_status();
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_set_battery_info chg_sta = %d!!\n", chg_sta);
+	s_mmi_charge_stateEx = s_mmi_charge_state;
+	/*if (chg_sta == STATE_CHARGING || chg_sta == STATE_FULL) {
+		// when the battery missed, the chg_sta may be CHARGING or FULL, 
+		// so we need read voltage to determine if the battery is in place.
+		power = mmi_voltage_state_read();
+		if (power < 0) {
+			// power<0 indicates that the battery is not in place, we modify the state to DISCHARGE.
+			s_mmi_charge_state = STATE_DISCHARGE;
+			mmi_set_webUI_batterycharge(WEBUIUNCHARGING, FALSE);
+			mmi_set_mode_fast_poweron(FALSE);
+			return;
+		}
+	}*/
+	if (chg_sta == STATE_CHARGING) {
+		s_mmi_charge_state = STATE_CHARGING;
+		mmi_set_webUI_batterycharge(WEBUICHARGING, FALSE);
+		g_mmi_voltageEx = 0;
+		mmi_set_mode_fast_poweron(TRUE);
+	} else if (chg_sta == STATE_FULL) {
+		s_mmi_charge_state = STATE_FULL;
+		g_mmi_voltageEx = 0;
+		mmi_set_webUI_batterycharge(WEBUIUNCHARGING, TRUE);
+		mmi_set_mode_fast_poweron(TRUE);
+		if (g_charge_protect == 1) {
+			system(MMI_TURN_OFF_CHG_FULL);
+			slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_set_battery_info off charge full!!\n");
+		}
+	} else if (chg_sta == STATE_DISCHARGE) {
+		s_mmi_charge_state = STATE_DISCHARGE;
+		mmi_set_webUI_batterycharge(WEBUIUNCHARGING, FALSE);
+		
+		power = mmi_voltage_state_read();
+		if (power > 0 && power < INT_MAX) {//kw 3
+			mmi_battery_capacity_compare(power);
+		}
+		
+		mmi_set_mode_fast_poweron(FALSE);
+	} else if (chg_sta == STATE_CHARGERROR) {
+		s_mmi_charge_state = STATE_DISCHARGE;
+		mmi_set_webUI_batterycharge(WEBUIUNCHARGING, FALSE);
+
+		power = mmi_voltage_state_read();
+		if (power > 0 && power < INT_MAX) {//kw 3
+			mmi_battery_capacity_compare(power);
+		}
+		
+		mmi_set_mode_fast_poweron(FALSE);
+	} else {
+		power = mmi_voltage_state_read();
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_set_battery_info invalid charge state!! power=%d\n");
+	}
+
+}
+
+
+/**********************************************************************************
+*º¯Êý˵Ã÷£º»ñÈ¡USB״̬
+ ***********************************************************************************/
+BOOL mmi_get_usb_insert_state()
+{
+	return s_mmi_usb_insert_status;
+}
+
+E_zMmi_Voltage_level mmi_get_voltage_level()
+{
+	return s_mmi_voltage_level;
+}
+
+E_zMmi_Charge_State mmi_get_charge_state()
+{
+	return s_mmi_charge_state;
+}
+
+
+
+
+/**********************************************************************************
+*º¯Êý˵Ã÷£º´ò¿ªcharging_netlinkÌ×½Ó×Ö
+ ·µ»ØÖµ£º ´ò¿ªµÄnetlinkÌ×½Ó×ÖÃèÊö·û£¬´ò¿ª³É¹¦·µ»Ø·Ç0Öµ
+***********************************************************************************/
+int open_charging_netlink()
+{
+	struct sockaddr_nl addr;
+	int s = -1;
+	memset(&addr, 0, sizeof(addr));
+	addr.nl_family = AF_NETLINK;
+	addr.nl_pid = getpid();
+	addr.nl_groups = 0xffffffff;
+	s = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);
+	if (s < 0) {		
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI charging socketfail %d\n",errno);
+		return -1;
+	}
+//  setsockopt(s, SOL_SOCKET, SO_RCVBUFFORCE, &sz, sizeof(sz));
+	if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI charging bindfail %d\n",errno);
+		close(s);
+		return -1;
+	}
+	return s;
+}
+
+/**********************************************************************************
+*º¯Êý˵Ã÷£ºnetlinkÊý¾Ý¼ìË÷º¯Êý
+Êä   È룺const char *key£ºÖ¸Ïò¹Ø¼ü×ÖµÄÖ¸Õë
+         const char *buf£ºÖ¸Ïò×Ö·û´®µÄÖ¸Õë
+         size_t len£º×Ö·û´®³¤¶È
+
+Êä   ³ö£º
+·µ»ØÖµ£º ·µ»Ø×Ö·û´®ÖжÔÓ¦¹Ø¼ü×ֵįðʼµØÖ·£¬Èô¼ìË÷²»µ½¹Ø¼ü×Ö£¬·µ»ØNULL
+Æä   Ëû£º
+***********************************************************************************/
+static const char *search_netlink(const char *key, const char *buf, size_t len)
+{
+	size_t curlen = 0;
+	size_t keylen = strlen((char *)key);
+	char *cur = (char *)buf;
+
+	while (cur < buf + len - keylen) {
+		curlen = strlen(cur);
+		if (curlen == 0)
+			break;
+		if (!strncmp(key, cur, keylen) && cur[keylen] == '=') {
+			return cur + keylen + 1;
+		}
+		cur += (curlen + 1);
+	}
+	return NULL;
+}
+
+/**********************************************************************************
+*º¯Êý˵Ã÷£º´Ónetlink¼àÌýµ½µÄÏûÏ¢×Ö·û´®´¦Àí³äµçÏûÏ¢
+ ***********************************************************************************/
+void process_netlink_event(int netlink_fd)
+{
+	char buf[1024] = {0};
+	int byte_counts = -1;
+	const char *keys = NULL, *subsys = NULL, *action = NULL;
+	const char *power_supply_name = NULL;
+
+
+	byte_counts = recv(netlink_fd, buf, sizeof(buf)-1, 0);
+	buf[sizeof(buf)-1] = '\0';//cov
+
+	if (byte_counts <= 0) {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI receive from netlonk ret %d err %d \n", byte_counts, errno);
+		return;
+	}
+
+	keys = (char *)(buf + strlen((char *)buf) + 1);
+	byte_counts -= (strlen((char*)buf) + 1);
+
+	subsys = search_netlink("SUBSYSTEM", keys, byte_counts);
+	action = search_netlink("ACTION", keys, byte_counts);
+	power_supply_name = search_netlink("POWER_SUPPLY_NAME", keys, byte_counts);
+	slog(MMI_PRINT, SLOG_NORMAL, "ZTE_MMI process_netlink_event subsys=%s, action=%s, power_supply_name=%s\n", subsys, action, power_supply_name);
+
+	if ((subsys != NULL) && (action != NULL) && (power_supply_name != NULL)) {//klocwork
+		if ((!strcmp(subsys, "power_supply")) && (!(strcmp(action, "change")))) {
+			if (!strcmp(power_supply_name, "charger")) {
+				set_wake_lock(MMI_MAIN_LOCK_ID);
+				mmi_reset_idle_timer();
+				mmi_set_battery_info();
+				slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI BATTERY process_netlink_event s_mmi_charge_state = %d s_mmi_charge_stateEx=%d\n", s_mmi_charge_state, s_mmi_charge_stateEx);
+				mmi_set_mode_active();
+				if (s_mmi_charge_state != s_mmi_charge_stateEx) {
+					mmi_set_battery_update();
+				}
+			} else if (!strcmp(power_supply_name, "boost")) {
+				if (g_discharge_protect) {
+					set_wake_lock(MMI_MAIN_LOCK_ID);
+					mmi_set_discharge_info();
+					set_wake_unlock(MMI_MAIN_LOCK_ID);
+				}
+			} else {
+				return;
+			}
+		}
+	}
+}
+
+int battery_app_msg_parse(const char *msg, int msglen, struct hotplug_event *event)
+{
+	int byte_counts = msglen;
+	const char *keys = NULL, *subsys = NULL, *action = NULL;
+	const char *power_supply_name = NULL;
+	
+	keys = (char *)(msg + strlen((char *)msg) + 1);
+	byte_counts -= (strlen((char*)msg) + 1);
+
+	subsys = search_netlink("SUBSYSTEM", keys, byte_counts);
+	action = search_netlink("ACTION", keys, byte_counts);
+	power_supply_name = search_netlink("POWER_SUPPLY_NAME", keys, byte_counts);
+	slog(MMI_PRINT, SLOG_NORMAL, "ZTE_MMI process_netlink_event subsys=%s, action=%s, power_supply_name=%s\n", subsys, action, power_supply_name);
+
+	if ((subsys != NULL) && (action != NULL) && (power_supply_name != NULL)) {
+		if ((!strcmp(subsys, "power_supply")) && (!(strcmp(action, "change")))) {
+			if (!strcmp(power_supply_name, "charger")) {
+				mmi_set_battery_info();
+				slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI BATTERY process_netlink_event s_mmi_charge_state = %d s_mmi_charge_stateEx=%d\n", s_mmi_charge_state, s_mmi_charge_stateEx);
+				if (s_mmi_charge_state != s_mmi_charge_stateEx 
+					&& (s_mmi_charge_state == STATE_DISCHARGE || s_mmi_charge_stateEx == STATE_DISCHARGE)) {
+					set_wake_lock(MMI_MAIN_LOCK_ID);
+					mmi_reset_idle_timer();
+					mmi_set_mode_active();
+				}
+				if (s_mmi_charge_state != s_mmi_charge_stateEx) {
+					mmi_set_battery_update();
+				}
+			} else if (!strcmp(power_supply_name, "boost")) {
+				if (g_discharge_protect) {
+					set_wake_lock(MMI_MAIN_LOCK_ID);
+					mmi_set_discharge_info();
+					set_wake_unlock(MMI_MAIN_LOCK_ID);
+				}
+			} else {
+				return -1;
+			}
+		}
+	}
+	return -1;
+}
+
+/**********************************************************************************
+*º¯Êý˵Ã÷£ºµçѹÂÖѯ¶¨Ê±Æ÷»Øµ÷º¯Êýÿ20Ãë¶ÁÒ»´Îµçѹ
+ ***********************************************************************************/
+static VOID *mmi_batterypower_process_thread(VOID *arg)
+{
+	UINT32 voltagepower = 0;
+
+	prctl(PR_SET_NAME, "mmigetbatvol", 0, 0, 0);
+
+	while (1) {
+		set_wake_lock(MMI_GET_POWER_LOCK_ID);
+		
+		if (g_discharge_protect) {
+			voltagepower = mmi_voltage_state_read_ex();
+			if (voltagepower > 0 && voltagepower < INT_MAX) {//kw 3
+				mmi_battery_capacity_compare(voltagepower);
+				mmi_set_battery_update();
+			}
+		} else {
+			if (mmi_get_charge_state() == STATE_DISCHARGE) {
+				voltagepower = mmi_voltage_state_read();
+				if (voltagepower > 0 && voltagepower < INT_MAX) {//kw 3
+					mmi_battery_capacity_compare(voltagepower);
+					mmi_set_battery_update();
+				}
+			} else {
+				/*³äµçµÈÆäËûÇé¿öϵĵ͵籣»¤*/
+				if (g_temp_protect) {
+					voltagepower = mmi_voltage_state_read_ex();
+					if (voltagepower > 0 && voltagepower < INT_MAX) {//kw 3
+						mmi_lowbattery_shutdown(voltagepower);
+					}
+				}
+			}
+		}
+		set_wake_unlock(MMI_GET_POWER_LOCK_ID);
+		mmi_sleep(CHECK_POWER_TIME_INTERVAL);
+	}
+}
+
+/**********************************************************************************
+*º¯Êý˵Ã÷£º´´½¨µçѹ²éѯÏß³Ì
+ ***********************************************************************************/
+static VOID mmi_create_get_voltage_thread(VOID)
+{
+	pthread_t mmi_battryvol_thread;
+	if (pthread_create(&mmi_battryvol_thread, NULL, &mmi_batterypower_process_thread, NULL) == -1) {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI pthread_create BatteryPower_thread error\n");
+		return;
+	}
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_create_get_voltage_timer success!!\n");
+}
+/**********************************************************************************
+*º¯Êý˵Ã÷£º´´½¨³äµç¼àÌýÏß³Ì
+ ***********************************************************************************/
+void *mmi_chargingcheck_process_thread(void *arg)
+{
+	int charging_netlink = -1;
+	int fd_counts = -1;
+	fd_set readfds;
+	prctl(PR_SET_NAME, "mmichgcheck", 0, 0, 0);
+	if ((charging_netlink = open_charging_netlink()) < 0) {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI charging_netlink wrong \n");
+		return NULL;
+	}
+	while (1) {
+/*		FD_ZERO(&readfds);
+		FD_SET(charging_netlink, &readfds);
+
+		fd_counts = select(charging_netlink + 1, &readfds, NULL, NULL, NULL);
+
+		if (fd_counts < 0) {
+			slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI select usb_netlink error! \n");
+			continue;
+		} else if (fd_counts == 0) {
+			slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI select usb_netlink timeout\n");
+			continue;
+		} else {
+			if (charging_netlink > 0 && FD_ISSET(charging_netlink, &readfds)) {*/
+				process_netlink_event(charging_netlink);
+			//}
+		//}
+	}
+}
+
+/**********************************************************************************
+*º¯Êý˵Ã÷£º´´½¨³äµç״̬¼à¿ØÏß³Ì
+ ***********************************************************************************/
+static VOID mmi_create_chargestate_check_thread(VOID)
+{
+	pthread_t mmi_chgstate_thread;
+	if (pthread_create(&mmi_chgstate_thread, NULL, &mmi_chargingcheck_process_thread, NULL) == -1) {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_create_chargestate_check_thread error\n");
+		return;
+	}
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_create_chargestate_check_thread success!!!\n");
+
+}
+
+/**************************************************************************************
+*º¯Êý˵Ã÷:³õʼ»¯³äµç״̬ ÉèÖÃµç³ØµÆ
+***************************************************************************************/
+static VOID mmi_charge_state_init(VOID)
+{
+	mmi_set_battery_info();
+	mmi_set_battery_update();
+}
+
+/**************************************************************************************
+*º¯Êý˵Ã÷:³õʼ»¯µç³ØµÆ×´Ì¬
+***************************************************************************************/
+VOID mmi_battery_init(VOID)
+{
+
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI BATTERY mmi_battery_Led_Init begin!!\n");
+	mmi_charge_state_init();
+	if (g_discharge_protect) {
+		mmi_load_state_init();
+	}
+	//mmi_create_chargestate_check_thread();
+	hotplug_parse_register(DEVICE_TYPE_APP_MMI_BATTERY, battery_app_msg_parse);
+	mmi_create_get_voltage_thread();
+}
diff --git a/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_battery_adapter.c b/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_battery_adapter.c
new file mode 100755
index 0000000..d55e6a9
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_battery_adapter.c
@@ -0,0 +1,237 @@
+/*****************************************************************************
+*  °æ±¾ËùÓÐ (C)ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾
+*  Ä£¿éÃû    £ºMMI
+*  ÎļþÃû    £ºmmi_batterry_adapter.c
+*  Îļþ±êʶ  £º
+*  Ïà¹ØÎļþ  £º
+*  ʵÏÖ¹¦ÄÜ  £ºMMI»ñÈ¡³äµçºÍµç³ØÐÅÏ¢ÊÊÅä
+*  ×÷Õß      £º
+*  °æ±¾      £ºV1.0
+*  Íê³ÉÈÕÆÚ  £º2014-6-20
+*  ÆäËü˵Ã÷  £º
+*
+******************************************************************************/
+
+
+/************************************************************************************
+                           Í·Îļþ
+***********************************************************************************/
+#include <linux/netlink.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include "mmi_common.h"
+#include "mmi_lcd.h"
+/*
+extern SINT32 g_mmi_hightempvol;
+extern SINT32 g_mmi_superhightempvol;
+extern SINT32 g_mmi_lowtempvol;
+extern SINT32 g_mmi_superlowtempvol;
+*/
+extern SINT32 g_mmi_batvoltageline[MMI_BAT_VOLTAGE_LEN];
+
+//µçѹ-µçÁ¿ÅäÖÃ±í£¬mmi´ÓÇý¶¯¶Áµ½µÄµçѹ»á¸úÕâ¸ö±íµÄµçѹ½øÐбȶԣ¬´Ó¶øÕÒµ½µçÁ¿·¶Î§
+static int bat_volage[] = {
+	3090, 3300, 3450, 3490, 3510, 3540, 3550, 3570, 3580, 3600, 3620,
+	3650, 3670, 3710, 3740, 3780, 3850, 3900, 3950, 4000, 4060,
+
+};
+
+
+static T_zMmiChgStateStringItem g_chgStateStringTab[] = {
+	{CHARGE_STATUS_FULL,     	STATE_FULL},
+	{CHARGE_STATUS_CHARGING, 	STATE_CHARGING},
+	{CHARGE_STATUS_DISCHARGING,	STATE_DISCHARGE},
+	{CHARGE_STATUS_NOTCHARGING,	STATE_CHARGERROR}
+};
+
+E_zMmi_Charge_State mmi_get_charge_status(VOID);
+
+/**********************************************************************************
+*º¯Êý˵Ã÷£º ¶ÁÈ¡µçѹֵ
+***********************************************************************************/
+SINT32 mmi_voltage_state_read(VOID)
+{
+	char buf_volt[CHARGE_VOLTAGE_LENGTH] = {0};
+	FILE* fd_voltage = NULL;
+	int len = 0;
+	int voltagepower = 0;
+
+	fd_voltage = fopen(CHARGE_VOLTAGE_PATH, "r");
+	if (fd_voltage == NULL) {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI open voltage file fail!\n");
+		//MMI_ASSERT(0);
+		cfg_set(WEBUIBATTERYLEVEL, WEBUINOBATTERY);
+		return -1;
+	}
+	len = fread(buf_volt, 1, CHARGE_VOLTAGE_LENGTH, fd_voltage);
+	if (len > 0) { //kw 3
+		voltagepower = atoi(buf_volt);
+		fclose(fd_voltage);
+		slog(MMI_PRINT, SLOG_NORMAL, "ZTE_MMI voltagepower=%d\n",voltagepower);
+		if(voltagepower < 0)
+			cfg_set(WEBUIBATTERYLEVEL, WEBUINOBATTERY);
+		return voltagepower;
+	} else {
+		perror("read voltage file failed");
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI read voltage file fail len = %d !\n", len);
+		fclose(fd_voltage);
+		cfg_set(WEBUIBATTERYLEVEL, WEBUINOBATTERY);
+		return -1;
+	}
+}
+
+/**********************************************************************************
+*º¯Êý˵Ã÷£º ¶ÁÈ¡µçѹֵ֮ǰÏÈÅжϳäµç״̬£¬Èç¹ûÊÇCHARGING£¬ÔòÏȹرճäµç£¬¶ÁÈ¡µçѹֵ֮ºóÔÙ¿ªÆô³äµç¡£
+***********************************************************************************/
+SINT32 mmi_voltage_state_read_ex(VOID)
+{
+	E_zMmi_Charge_State chg_sta = mmi_get_charge_status();
+	if (STATE_CHARGING == chg_sta)
+	{
+		system(MMI_TURN_OFF_CHG);
+	}
+	SINT32 ret = mmi_voltage_state_read();
+	if (STATE_CHARGING == chg_sta)
+	{
+		system(MMI_TURN_ON_CHG);
+	}
+	return ret;
+}
+
+/*****************************************************************************************
+*º¯Êý˵Ã÷£º ¸ù¾Ýµç³Ø°Ù·Ö±ÈÉèÖÃµç³Ø×´Ì¬ 10%/25%/normal
+*******************************************************************************************/
+E_zMmi_Voltage_level mmi_set_battery_state(UINT32 bat_level)
+{
+	E_zMmi_Voltage_level volt_lev = VOLT_MAX;
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_set_battery_state bat_level = %d\n", bat_level);
+	if (bat_level <= 5) {
+		volt_lev = VOLT_5PERCENTLEVEL;
+	} else if (bat_level <= 10) { //kw 3
+		volt_lev = VOLT_10PERCENTLEVEL;
+	} else if (bat_level <= 20) {
+		volt_lev = VOLT_20PERCENTLEVEL;
+	} else if (bat_level <= 25) {
+		volt_lev = VOLT_25PERCENTLEVEL;
+	} else {
+		volt_lev = VOLT_NORMALLEVEL;
+	}
+	return volt_lev;
+}
+/*****************************************************************************************
+*º¯Êý˵Ã÷£º ÉèÖÃWEBUIµç³Ø¸ñÊý
+*******************************************************************************************/
+VOID mmi_set_webUI_batterypers(UINT32 bat_level)
+{
+	if (bat_level <= 5) {
+		cfg_set(WEBUIBATTERYLEVEL, WEBUINOLEVEL);
+	} else if (bat_level <= 25) { //kw 3
+		cfg_set(WEBUIBATTERYLEVEL, WEBUIONELEVEL);
+	} else if (bat_level <= 50) {
+		cfg_set(WEBUIBATTERYLEVEL, WEBUITWOLEVEL);
+	} else if (bat_level < 100) {
+		cfg_set(WEBUIBATTERYLEVEL, WEBUITHRLEVEL);
+	} else {
+		cfg_set(WEBUIBATTERYLEVEL, WEBUIFOURLEVEL);
+	}
+}
+
+/*****************************************************************************************
+*º¯Êý˵Ã÷£º ÉèÖÃWEBUIµç³Ø×´Ì¬
+*******************************************************************************************/
+VOID mmi_set_webUI_batterycharge(char* chg_sta, BOOL isFull)
+{
+	cfg_set(WEBUICHARGESTATTUS, chg_sta);
+	if (isFull) {
+		cfg_set(BATTERYPERS_NV, WEBUIFULLLEVEL);
+		cfg_set(WEBUIBATTERYLEVEL, WEBUIFOURLEVEL);
+	}
+}
+/*****************************************************************************************
+*º¯Êý˵Ã÷£º ¸ù¾Ýµçѹ»ñÈ¡µç³ØµçÁ¿°Ù·Ö±È
+*******************************************************************************************/
+SINT32 get_voltage_level_from_table(SINT32 voltagepower)
+{
+	UINT32 bat_lev = 0;
+	SINT32 i;
+
+	if (voltagepower < g_mmi_batvoltageline[0]) {
+		bat_lev = 0;
+	} else if (voltagepower >= g_mmi_batvoltageline[MMI_BAT_VOLTAGE_LEN - 1]) {
+		bat_lev = 100;
+	} else {
+		for (i = 0; i < MMI_BAT_VOLTAGE_LEN - 1; i++) {
+			if (voltagepower >= g_mmi_batvoltageline[i] && voltagepower < g_mmi_batvoltageline[i + 1]) {
+				bat_lev = i * 5;
+				break;
+			}
+		}
+	}
+	return bat_lev;
+}
+
+/**********************************************************************************
+*º¯Êý˵Ã÷£º»ñÈ¡³äµç״̬
+ ***********************************************************************************/
+E_zMmi_Charge_State mmi_get_charge_status(VOID)
+{
+	char chg_state_buf[CHARGE_STATUS_LENGTH] = {0};
+	int len = 0;
+	UINT32 i = 0;
+	FILE* fd_charger = NULL;
+
+	fd_charger = fopen(CHARGE_STATUS_PATH, "r");
+	if (fd_charger == NULL) {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_get_charge_status open charging file fail!\n");
+		//MMI_ASSERT(0);
+		return STATE_CHARGE_MAX;
+	}
+	len = fread(chg_state_buf, 1, CHARGE_STATUS_LENGTH, fd_charger);
+	if (len > 0) { //kw 3
+		fclose(fd_charger);
+		slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_get_charge_status chg_state_buf=%s !\n", chg_state_buf);
+		for (i = 0; i < sizeof(g_chgStateStringTab) / sizeof(T_zMmiChgStateStringItem); ++ i) {
+			if (strncmp(chg_state_buf, g_chgStateStringTab[i].devString, strlen(g_chgStateStringTab[i].devString)) == 0) {
+				return g_chgStateStringTab[i].chg_sta;
+			}
+		}
+	} else {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_get_charge_status read voltage file fail len = %d !\n", len);
+		fclose(fd_charger);
+		return STATE_CHARGE_MAX;
+	}
+	return STATE_CHARGE_MAX;
+}
+/**********************************************************************************
+*º¯Êý˵Ã÷£º»ñÈ¡USB²å°Î״̬
+ ***********************************************************************************/
+BOOL mmi_read_usb_insert_status(VOID)
+{
+	char usb_state_buf[2] = {0};
+	int len = 0;
+	FILE* fd_charger = NULL;
+
+	fd_charger = fopen(USB_INSERT_STATUS_PATH, "r");
+	if (fd_charger == NULL) {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_read_usb_insert_status open usb file fail!\n");
+		//MMI_ASSERT(0);
+		return FALSE;
+	}
+	len = fread(usb_state_buf, 1, 2, fd_charger);
+	if (len > 0) { //kw 3
+		fclose(fd_charger);
+		slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_read_usb_insert_status usb_state_buf=%s !\n", usb_state_buf);
+		if (!strncmp(usb_state_buf, USB_STATUS_IN, strlen(USB_STATUS_IN))) {
+			return TRUE;
+		}
+		if (!strncmp(usb_state_buf, USB_STATUS_OUT, strlen(USB_STATUS_OUT))) {
+			return FALSE;
+		}
+	} else {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_read_usb_insert_status read usb file fail len = %d !\n", len);
+		fclose(fd_charger);
+		return FALSE;
+	}
+	return FALSE;
+}
+
diff --git a/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_cfg.c b/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_cfg.c
new file mode 100755
index 0000000..8b5cd96
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_cfg.c
@@ -0,0 +1,209 @@
+/*****************************************************************************
+*  °æ±¾ËùÓÐ (C)ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾
+*  Ä£¿éÃû    £ºMMI
+*  ÎļþÃû    £ºmmi_lcd.c
+*  Îļþ±êʶ  £º
+*  Ïà¹ØÎļþ  £º
+*  ʵÏÖ¹¦ÄÜ  £º
+*  ×÷Õß      £º
+*  °æ±¾      £ºV1.0
+*  Íê³ÉÈÕÆÚ  £º2014-6-20
+*  ÆäËü˵Ã÷  £º
+*
+*******************************************************************************/
+#include "mmi_common.h"
+
+/***********************************LCDͳһÅäÖÃ********************************/
+
+/*ÆÁĻģʽÅäÖÃ*/
+E_zMmiShowMode g_showMode = 0;//led,1;lcd,2;lcd+lcd,3
+
+
+/***********************************LEDͳһÅäÖÃ********************************/
+
+T_zMmiSmsLedConfig g_mmi_smsled_config_tab[] = {
+	{{0, SMS_RECVBOX_STATUS_FULL}, {LED_SMS, LED_STATE_BLINK, LED_STATE_SMS_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{{0, SMS_RECVBOX_STATUS_NEW}, {LED_SMS, LED_STATE_BLINK, LED_STATE_SMS_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{{0, SMS_RECVBOX_STATUS_UNREAD}, {LED_SMS, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{{0, SMS_RECVBOX_STATUS_NOR}, {LED_SMS, LED_STATE_OFF, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+
+};
+
+T_zMmiVoipLedConfig g_mmi_voipled_config_tab[] = {
+	{{VOIP_STATUS_IN_CALL}, {LED_VOIP, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{{VOIP_STATUS_IN_CONNECTION}, {LED_VOIP, LED_STATE_BLINK, LED_STATE_VOIP_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{{VOIP_STATUS_HANG_UP}, {LED_VOIP, LED_STATE_OFF, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{{VOIP_STATUS_NOR}, {LED_VOIP, LED_STATE_OFF, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+
+};
+
+T_zMmiBatteryLedConfig g_mmi_batled_config_tab[] = {
+	{{STATE_CHARGING, 0, 0, 0}, {LED_BATTERY, LED_STATE_ON, LED_STATE_BAT_BLINK, {0}, LED_COLOR_RED, TRAFFIC_LED_MAX}},
+	{{STATE_FULL, 0, 0, 0}, {LED_BATTERY, LED_STATE_ON, LED_STATE_BAT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{{STATE_DISCHARGE, VOLT_5PERCENTLEVEL, 0, 0}, {LED_BATTERY, LED_STATE_BLINK, LED_STATE_BAT_BLINK, {0}, LED_COLOR_RED, TRAFFIC_LED_MAX}},
+	{{STATE_DISCHARGE, VOLT_10PERCENTLEVEL, 0, 0}, {LED_BATTERY, LED_STATE_BLINK, LED_STATE_BAT_BLINK, {0}, LED_COLOR_RED, TRAFFIC_LED_MAX}},
+	{{STATE_DISCHARGE, VOLT_20PERCENTLEVEL, 0, 0}, {LED_BATTERY, LED_STATE_BLINK, LED_STATE_BAT_BLINK, {0}, LED_COLOR_RED, TRAFFIC_LED_MAX}},
+	{{STATE_DISCHARGE, VOLT_25PERCENTLEVEL, 0, 0}, {LED_BATTERY, LED_STATE_ON, LED_STATE_BAT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{{STATE_DISCHARGE, VOLT_50PERCENTLEVEL, 0, 0}, {LED_BATTERY, LED_STATE_ON, LED_STATE_BAT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{{STATE_DISCHARGE, VOLT_75PERCENTLEVEL, 0, 0}, {LED_BATTERY, LED_STATE_ON, LED_STATE_BAT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{{STATE_DISCHARGE, VOLT_NORMALLEVEL, 0, 0}, {LED_BATTERY, LED_STATE_ON, LED_STATE_BAT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+};
+
+T_zMmiNetLedConfig g_mmi_netled_config_tab[] = {
+	{CUSTOMER_SDK, {NET_MODE_2G, 1, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_BLINK, LED_STATE_WAN_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK, {NET_MODE_2G, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK, {NET_MODE_3G, 1, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_BLINK, LED_STATE_WAN_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK, {NET_MODE_3G, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK, {NET_MODE_4G, 1, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_BLINK, LED_STATE_WAN_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK, {NET_MODE_4G, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK, {NET_MODE_NOSERVICE, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_RED, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK, {NET_MODE_LIMITSERVICE, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_RED, TRAFFIC_LED_MAX}},
+	//16M flash
+	{CUSTOMER_SDK_MIN, {NET_MODE_2G, 1, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_BLINK, LED_STATE_WAN_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK_MIN, {NET_MODE_2G, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK_MIN, {NET_MODE_3G, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_RED, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK_MIN, {NET_MODE_3G, 0, 0, 1, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK_MIN, {NET_MODE_3G, 0, 0, 2, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK_MIN, {NET_MODE_4G, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_RED, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK_MIN, {NET_MODE_4G, 0, 0, 1, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK_MIN, {NET_MODE_4G, 0, 0, 2, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK_MIN, {NET_MODE_NOSERVICE, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_OFF, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_RED, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK_MIN, {NET_MODE_LIMITSERVICE, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_OFF, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_RED, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK_MIN, {NET_MODE_NOTREADY, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_BLINK, LED_STATE_WAN_BLINK, {0}, LED_COLOR_RED, TRAFFIC_LED_MAX}},
+	//16M flash, yaoyuan cpe
+	{CUSTOMER_YAOYUAN, {NET_MODE_2G, 1, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_BLINK, LED_STATE_WAN_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_YAOYUAN, {NET_MODE_2G, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_YAOYUAN, {NET_MODE_3G, 1, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_BLINK, LED_STATE_WAN_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_YAOYUAN, {NET_MODE_3G, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_YAOYUAN, {NET_MODE_4G, 1, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_BLINK, LED_STATE_WAN_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_YAOYUAN, {NET_MODE_4G, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_YAOYUAN, {NET_MODE_NOSERVICE, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_RED, TRAFFIC_LED_MAX}},
+	{CUSTOMER_YAOYUAN, {NET_MODE_LIMITSERVICE, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_RED, TRAFFIC_LED_MAX}},
+	{CUSTOMER_YAOYUAN, {NET_MODE_NOTREADY, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_RED, TRAFFIC_LED_MAX}},
+	//{CUSTOMER_YAOYUAN, {NET_MODE_NOSERVICE, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_BLINK, LED_STATE_WAN_CPE_FAST_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	//{CUSTOMER_YAOYUAN, {NET_MODE_LIMITSERVICE, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_BLINK, LED_STATE_WAN_CPE_FAST_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	//{CUSTOMER_YAOYUAN, {NET_MODE_NOTREADY, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_BLINK, LED_STATE_WAN_CPE_SLOW_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	//GUODIAN led config
+	{CUSTOMER_GUODIAN, {NET_MODE_2G, 1, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_BLINK, LED_STATE_WAN_FAST_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_GUODIAN, {NET_MODE_3G, 1, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_BLINK, LED_STATE_WAN_FAST_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_GUODIAN, {NET_MODE_4G, 1, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_BLINK, LED_STATE_WAN_FAST_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_GUODIAN, {NET_MODE_2G, 1, 0, 0, 0, NET_SOCKET_ACTIVE}, {LED_WAN, LED_STATE_BLINK, LED_STATE_WAN_SLOW_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_GUODIAN, {NET_MODE_3G, 1, 0, 0, 0, NET_SOCKET_ACTIVE}, {LED_WAN, LED_STATE_BLINK, LED_STATE_WAN_SLOW_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_GUODIAN, {NET_MODE_4G, 1, 0, 0, 0, NET_SOCKET_ACTIVE}, {LED_WAN, LED_STATE_BLINK, LED_STATE_WAN_SLOW_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_GUODIAN, {NET_MODE_2G, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_GUODIAN, {NET_MODE_3G, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_GUODIAN, {NET_MODE_4G, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_GUODIAN, {NET_MODE_NOSERVICE, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_OFF, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_GUODIAN, {NET_MODE_LIMITSERVICE, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_OFF, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	//NANDIAN led config
+	{CUSTOMER_NANDIAN, {NET_MODE_2G, 1, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_BLINK, LED_STATE_WAN_FAST_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_NANDIAN, {NET_MODE_3G, 1, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_BLINK, LED_STATE_WAN_FAST_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_NANDIAN, {NET_MODE_4G, 1, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_BLINK, LED_STATE_WAN_FAST_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_NANDIAN, {NET_MODE_2G, 1, 0, 0, 0, NET_SOCKET_ACTIVE}, {LED_WAN, LED_STATE_BLINK, LED_STATE_WAN_SLOW_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_NANDIAN, {NET_MODE_3G, 1, 0, 0, 0, NET_SOCKET_ACTIVE}, {LED_WAN, LED_STATE_BLINK, LED_STATE_WAN_SLOW_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_NANDIAN, {NET_MODE_4G, 1, 0, 0, 0, NET_SOCKET_ACTIVE}, {LED_WAN, LED_STATE_BLINK, LED_STATE_WAN_SLOW_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_NANDIAN, {NET_MODE_2G, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_NANDIAN, {NET_MODE_3G, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_NANDIAN, {NET_MODE_4G, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_NANDIAN, {NET_MODE_NOSERVICE, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_OFF, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_NANDIAN, {NET_MODE_LIMITSERVICE, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_WAN, LED_STATE_OFF, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+};
+
+
+#if 0
+T_zMmiWifiLedConfig g_mmi_wifiled_config_tab[] = {
+	{{TRUE, 0, 0, WPS_ACTIVING}, {LED_LAN, LED_STATE_BLINK, LED_STATE_LAN_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{{TRUE, 0, 0, WPS_ACTIVED}, {LED_LAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{{TRUE, 0, 0, WPS_DEACTIVED}, {LED_LAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{{TRUE, 0, 0, WPS_DEACTIVING}, {LED_LAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{{TRUE, 0, 0, WPS_ACTIVE_MAX}, {LED_LAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{{FALSE, 0, 0, WPS_ACTIVE_MAX}, {LED_LAN, LED_STATE_OFF, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+};
+#endif
+
+T_zMmiWifiLedConfig g_mmi_wifiled_config_tab[] = {
+	{CUSTOMER_SDK, {TRUE, TRUE, 0, 0, WPS_ACTIVING}, {LED_LAN, LED_STATE_BLINK, LED_STATE_LAN_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK, {TRUE, FALSE, 0, 0, WPS_ACTIVED}, {LED_LAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK, {FALSE, TRUE, 0, 0, WPS_DEACTIVED}, {LED_LAN, LED_STATE_OFF, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK, {FALSE, FALSE, 0, 0, WPS_DEACTIVING}, {LED_LAN, LED_STATE_OFF, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+
+	//16M flash
+	{CUSTOMER_SDK_MIN, {TRUE, TRUE, 0, 0, WPS_ACTIVING}, {LED_LAN, LED_STATE_ON, LED_STATE_LAN_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK_MIN, {TRUE, FALSE, 0, 0, WPS_ACTIVED}, {LED_LAN, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK_MIN, {FALSE, TRUE, 0, 0, WPS_DEACTIVED}, {LED_LAN, LED_STATE_OFF, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK_MIN, {FALSE, FALSE, 0, 0, WPS_DEACTIVING}, {LED_LAN, LED_STATE_OFF, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+};
+
+//wpsµÆ Ò¢Ô¶cpe
+T_zMmiWifiLedConfig g_mmi_wpsled_config_tab[] = {
+	{CUSTOMER_SDK, {TRUE, TRUE, 0, 0, WPS_ACTIVING}, {LED_WPS, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK, {TRUE, FALSE, 0, 0, WPS_ACTIVED}, {LED_WPS, LED_STATE_OFF, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK, {FALSE, TRUE, 0, 0, WPS_DEACTIVED}, {LED_WPS, LED_STATE_OFF, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK, {FALSE, FALSE, 0, 0, WPS_DEACTIVING}, {LED_WPS, LED_STATE_OFF, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK, {FALSE, FALSE, 0, 0, WPS_FAIL}, {LED_WPS, LED_STATE_OFF, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_SDK, {FALSE, FALSE, 0, 0, WPS_ACTIVE_MAX}, {LED_WPS, LED_STATE_OFF, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+};
+
+//5¿ÅµÆ ¸´ÓÃTRAFFIC_LED  Ò¢Ô¶cpe
+T_zMmiNetLedConfig g_mmi_signalled_config_tab[] = {
+	//16M flash, yaoyuan cpe
+	{CUSTOMER_YAOYUAN, {NET_MODE_2G, 0, 1, 0, 0, NET_SOCKET_INACTIVE}, {LED_SIGNAL, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_1}},
+	{CUSTOMER_YAOYUAN, {NET_MODE_2G, 0, 2, 0, 0, NET_SOCKET_INACTIVE}, {LED_SIGNAL, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_2}},
+	{CUSTOMER_YAOYUAN, {NET_MODE_2G, 0, 3, 0, 0, NET_SOCKET_INACTIVE}, {LED_SIGNAL, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_3}},
+	{CUSTOMER_YAOYUAN, {NET_MODE_2G, 0, 4, 0, 0, NET_SOCKET_INACTIVE}, {LED_SIGNAL, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_4}},
+	{CUSTOMER_YAOYUAN, {NET_MODE_2G, 0, 5, 0, 0, NET_SOCKET_INACTIVE}, {LED_SIGNAL, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_5}},
+
+	{CUSTOMER_YAOYUAN, {NET_MODE_3G, 0, 1, 0, 0, NET_SOCKET_INACTIVE}, {LED_SIGNAL, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_1}},
+	{CUSTOMER_YAOYUAN, {NET_MODE_3G, 0, 2, 0, 0, NET_SOCKET_INACTIVE}, {LED_SIGNAL, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_2}},
+	{CUSTOMER_YAOYUAN, {NET_MODE_3G, 0, 3, 0, 0, NET_SOCKET_INACTIVE}, {LED_SIGNAL, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_3}},
+	{CUSTOMER_YAOYUAN, {NET_MODE_3G, 0, 4, 0, 0, NET_SOCKET_INACTIVE}, {LED_SIGNAL, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_4}},
+	{CUSTOMER_YAOYUAN, {NET_MODE_3G, 0, 5, 0, 0, NET_SOCKET_INACTIVE}, {LED_SIGNAL, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_5}},
+
+	{CUSTOMER_YAOYUAN, {NET_MODE_4G, 0, 1, 0, 0, NET_SOCKET_INACTIVE}, {LED_SIGNAL, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_1}},
+	{CUSTOMER_YAOYUAN, {NET_MODE_4G, 0, 2, 0, 0, NET_SOCKET_INACTIVE}, {LED_SIGNAL, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_2}},
+	{CUSTOMER_YAOYUAN, {NET_MODE_4G, 0, 3, 0, 0, NET_SOCKET_INACTIVE}, {LED_SIGNAL, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_3}},
+	{CUSTOMER_YAOYUAN, {NET_MODE_4G, 0, 4, 0, 0, NET_SOCKET_INACTIVE}, {LED_SIGNAL, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_4}},
+	{CUSTOMER_YAOYUAN, {NET_MODE_4G, 0, 5, 0, 0, NET_SOCKET_INACTIVE}, {LED_SIGNAL, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_5}},
+
+	{CUSTOMER_YAOYUAN, {NET_MODE_NOSERVICE, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_SIGNAL, LED_STATE_BLINK, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_YAOYUAN, {NET_MODE_LIMITSERVICE, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_SIGNAL, LED_STATE_BLINK, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{CUSTOMER_YAOYUAN, {NET_MODE_NOTREADY, 0, 0, 0, 0, NET_SOCKET_INACTIVE}, {LED_SIGNAL, LED_STATE_BLINK, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+};
+
+//rj11µÆ Ò¢Ô¶cpe
+T_zMmiRj11LedConfig g_mmi_rj11led_config_tab[] = {
+	{{RJ11_STATUS_IN}, {LED_RJ11, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{{RJ11_STATUS_OUT}, {LED_RJ11, LED_STATE_OFF, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+	{{RJ11_STATUS_NOR}, {LED_RJ11, LED_STATE_OFF, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_BLUE, TRAFFIC_LED_MAX}},
+};
+
+//rj45µÆ
+T_zMmiRj45LedConfig g_mmi_rj45led_config_tab[] = {
+	{{RJ45_STATUS_IN}, {LED_RJ45, LED_STATE_ON, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{{RJ45_STATUS_OUT}, {LED_RJ45, LED_STATE_OFF, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+	{{RJ45_STATUS_NOR}, {LED_RJ45, LED_STATE_OFF, LED_STATE_DEFAULT_BLINK, {0}, LED_COLOR_GREEN, TRAFFIC_LED_MAX}},
+};
+
+unsigned int mmi_get_config_tab_size(MMI_LED_NAME led)
+{
+	if (led == LED_BATTERY) {
+		return sizeof(g_mmi_batled_config_tab);
+	} else if (led == LED_LAN) {
+		return sizeof(g_mmi_wifiled_config_tab);
+	} else if (led == LED_WAN) {
+		return sizeof(g_mmi_netled_config_tab);
+	} else if (led == LED_SMS) {
+		return sizeof(g_mmi_smsled_config_tab);
+	} else if (led == LED_VOIP) {
+		return sizeof(g_mmi_voipled_config_tab);
+	} else if (led == LED_SIGNAL) {
+		return sizeof(g_mmi_signalled_config_tab);
+	} else if (led == LED_WPS) {
+		return sizeof(g_mmi_wpsled_config_tab);
+	} else if (led == LED_RJ11) {
+		return sizeof(g_mmi_rj11led_config_tab);
+	} else if (led == LED_RJ45) {
+		return sizeof(g_mmi_rj45led_config_tab);
+	}
+	return 0;
+}
diff --git a/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_cfg.h b/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_cfg.h
new file mode 100755
index 0000000..1bb23bb
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_cfg.h
@@ -0,0 +1,253 @@
+/*****************************************************************************
+*  °æ±¾ËùÓÐ (C)ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾
+*  Ä£¿éÃû    £ºMMI
+*  ÎļþÃû    £ºmmi_lcd.c
+*  Îļþ±êʶ  £º
+*  Ïà¹ØÎļþ  £º
+*  ʵÏÖ¹¦ÄÜ  £º
+*  ×÷Õß      £º
+*  °æ±¾      £ºV1.0
+*  Íê³ÉÈÕÆÚ  £º2014-6-20
+*  ÆäËü˵Ã÷  £º
+*
+*******************************************************************************/
+
+/***********************************LCDͳһÅäÖÃ********************************/
+
+
+
+/*****************************************************************************
+ÆÁÄ»×ÖÌå´óС¶¨Òå
+******************************************************************************/
+#define MMI_LCD_SHOW_STRING_LEN 			68
+#define MMI_LCD_CHAR8_MAX_LEN    			18	//ÿÆÁÏÔʾµÄ×î´ó³¤¶È£¬´óÓÚ´ËÖµ½«¹ö¶¯ÏÔʾ£¬Èç×ÖÌå±ä»¯ÐèÐÞ¸Ä
+#define MMI_LCD_CHAR9_MAX_LEN    			18	//ÿÆÁÏÔʾµÄ×î´ó³¤¶È£¬´óÓÚ´ËÖµ½«¹ö¶¯ÏÔʾ£¬Èç×ÖÌå±ä»¯ÐèÐÞ¸Ä
+
+/*****************************************************************************
+Îļþ×ÊԴ·¾¶¶¨Òå
+******************************************************************************/
+#define MMI_RESOURCE_PATH  					"/etc_ro/mmi/"
+
+/*****************************************************************************
+ LEDµÆÉÁ˸ƵÂÊÅäÖÃ
+******************************************************************************/
+
+#define LED_BLINK_TIME_INTERVAL			1000
+
+//LEDµÆ¿ìÉÁ/ÂýÉÁʱ¼ä    µ¥Î»:ms
+#define LED_FAST_BLINK_ON_TIME          100//1000
+#define LED_FAST_BLINK_OFF_TIME         100//1000
+#define LED_SLOW_BLINK_ON_TIME          250//2000
+#define LED_SLOW_BLINK_OFF_TIME         250//5000
+
+#define LED_BAT_BLINK_ON_TIME			800
+#define LED_BAT_BLINK_OFF_TIME			1200
+#define LED_LAN_BLINK_ON_TIME			400
+#define LED_LAN_BLINK_OFF_TIME			1600
+#define LED_SMS_BLINK_ON_TIME			800
+#define LED_SMS_BLINK_OFF_TIME			1200
+#define LED_WAN_BLINK_ON_TIME			200
+#define LED_WAN_BLINK_OFF_TIME			1400
+#define LED_VOIP_BLINK_ON_TIME			400
+#define LED_VOIP_BLINK_OFF_TIME			1600
+
+#define LED_BREATH_BLINK_ON_TIME		300
+#define LED_BREATH_BLINK_OFF_TIME		5000
+//¹úµçÁªÇ¿:PDP¼¤»îSOCKETδÁ¬½Ó1.8sÃð0.2sÁÁ£¬SOCKETÒÑÁ¬½Ó·´Ö®
+#define LED_WAN_FAST_BLINK_ON_TIME		200
+#define LED_WAN_FAST_BLINK_OFF_TIME		1800
+#define LED_WAN_SLOW_BLINK_ON_TIME		1800
+#define LED_WAN_SLOW_BLINK_OFF_TIME		200
+//yaoyuan cpe
+#define LED_WAN_CPE_FAST_BLINK_ON_TIME		500
+#define LED_WAN_CPE_FAST_BLINK_OFF_TIME		500
+#define LED_WAN_CPE_SLOW_BLINK_ON_TIME		500
+#define LED_WAN_CPE_SLOW_BLINK_OFF_TIME		1000
+
+
+
+/*******************************************************************************
+  LEDµÆ¹«¹²¶¨Òå//ÏÂÃæ¼¸¸öÊǶ¨ÒåÁ˺ôÎüµÆÊ±Óõ½µÄ·¾¶
+*******************************************************************************/
+#define ALL_LED_PATH					"/sys/class/leds/battery_led/brightness"
+#define BATTERY_LED_PATH				"/sys/class/leds/battery_led/ledSwitch"
+#define WAN_LED_PATH					"/sys/class/leds/net_led/ledSwitch"
+#define LAN_LED_PATH					"/sys/class/leds/wifi_led/ledSwitch"
+#define SMS_LED_PATH					"/sys/class/leds/sms_led/ledSwitch"
+#define TRAFFIC_LED_PATH				"/sys/class/leds/traffic_led/ledSwitch"
+
+/*
+/×Ö·û´®º¬Òå:µÚһλ: ÑÕÉ« 1-RED 2-GREEN 3-YELLOW 4-BLUE;
+			µÚ¶þλ: ״̬ 0-OFF 1-ON 2-BLINK;
+			µÚÈýËÄλ: Á÷Á¿µÆÁÁµÄ¸öÊý£¬00-09·Ö±ðΪÁÁ1¸öµ½10¸öÁ÷Á¿µÆ£¬10ΪÎÞЧֵ*/
+#define LED_STATE_GREEN_OFF				"2010"
+#define LED_STATE_YELLOW_OFF			"3010"
+#define LED_STATE_BLUE_OFF				"4010"
+#define LED_TRAFFIC_ALL_OFF				"2009"
+
+#define LED_ALL_POWER_ON				"1"
+#define LED_ALL_POWER_OFF				"2"
+
+#define LED_STATE_RED_ON				"1110"
+#define LED_STATE_RED_BLINK				"1210"
+#define LED_STATE_GREEN_ON				"2110"
+#define LED_STATE_GREEN_BLINK			"2210"
+#define LED_STATE_YELLOW_ON				"3110"
+#define LED_STATE_YELLOW_BLINK			"3210"
+#define LED_STATE_BLUE_ON				"4110"
+#define LED_STATE_BLUE_BLINK			"4210"
+
+#define TRAFIIC_LED_1_ON				"2100"
+#define TRAFIIC_LED_1_BLINK				"2200"
+#define TRAFIIC_LED_2_ON				"2101"
+#define TRAFIIC_LED_2_BLINK				"2201"
+#define TRAFIIC_LED_3_ON				"2102"
+#define TRAFIIC_LED_3_BLINK				"2202"
+#define TRAFIIC_LED_4_ON				"2103"
+#define TRAFIIC_LED_4_BLINK				"2203"
+#define TRAFIIC_LED_5_ON				"2104"
+#define TRAFIIC_LED_5_BLINK				"2204"
+#define TRAFIIC_LED_6_ON				"2105"
+#define TRAFIIC_LED_6_BLINK				"2205"
+#define TRAFIIC_LED_7_ON				"2106"
+#define TRAFIIC_LED_7_BLINK				"2206"
+#define TRAFIIC_LED_8_ON				"2107"
+#define TRAFIIC_LED_8_BLINK				"2207"
+#define TRAFIIC_LED_9_ON				"2108"
+#define TRAFIIC_LED_9_BLINK				"2208"
+#define TRAFIIC_LED_10_ON				"2109"
+#define TRAFIIC_LED_10_BLINK			"2209"
+
+
+#define LED_WAN_RED_BRIGHTNESS			"/sys/class/leds/modem_r_led/brightness"
+#define LED_WAN_RED_BLINKSWITCH			"/sys/class/leds/modem_r_led/trigger"
+#define LED_WAN_RED_BLINKTIMEON			"/sys/class/leds/modem_r_led/delay_on"
+#define LED_WAN_RED_BLINKTIMEOFF		"/sys/class/leds/modem_r_led/delay_off"
+
+#define LED_WAN_GREEN_BRIGHTNESS        "/sys/class/leds/modem_g_led/brightness"
+#define LED_WAN_GREEN_BLINKSWITCH		"/sys/class/leds/modem_g_led/trigger"
+#define LED_WAN_GREEN_BLINKTIMEON		"/sys/class/leds/modem_g_led/delay_on"
+#define LED_WAN_GREEN_BLINKTIMEOFF		"/sys/class/leds/modem_g_led/delay_off"
+
+
+#define LED_WAN_BLUE_BRIGHTNESS			"/sys/class/leds/modem_b_led/brightness"
+#define LED_WAN_BLUE_BLINKSWITCH		"/sys/class/leds/modem_b_led/trigger"
+#define LED_WAN_BLUE_BLINKTIMEON		"/sys/class/leds/modem_b_led/delay_on"
+#define LED_WAN_BLUE_BLINKTIMEOFF		"/sys/class/leds/modem_b_led/delay_off"
+
+#define LED_BATTERY_GREEN_BRIGHTNESS	"/sys/class/leds/battery_g_led/brightness"
+#define LED_BATTERY_GREEN_BLINKSWITCH	"/sys/class/leds/battery_g_led/trigger"
+#define LED_BATTERY_GREEN_BLINKTIMEON	"/sys/class/leds/battery_g_led/delay_on"
+#define LED_BATTERY_GREEN_BLINKTIMEOFF	"/sys/class/leds/battery_g_led/delay_off"
+
+#define LED_BATTERY_RED_BRIGHTNESS		"/sys/class/leds/battery_r_led/brightness"
+#define LED_BATTERY_RED_BLINKSWITCH		"/sys/class/leds/battery_r_led/trigger"
+#define LED_BATTERY_RED_BLINKTIMEON		"/sys/class/leds/battery_r_led/delay_on"
+#define LED_BATTERY_RED_BLINKTIMEOFF 	"/sys/class/leds/battery_r_led/delay_off"
+
+#define LED_SMS_GREEN_BRIGHTNESS		"/sys/class/leds/sms_led/brightness"
+#define LED_SMS_GREEN_BLINKSWITCH		"/sys/class/leds/sms_led/trigger"
+#define LED_SMS_GREEN_BLINKTIMEON		"/sys/class/leds/sms_led/delay_on"
+#define LED_SMS_GREEN_BLINKTIMEOFF		"/sys/class/leds/sms_led/delay_off"
+
+#define LED_SMS_BLUE_BRIGHTNESS		    "/sys/class/leds/sms_led/brightness"
+#define LED_SMS_BLUE_BLINKSWITCH		"/sys/class/leds/sms_led/trigger"
+#define LED_SMS_BLUE_BLINKTIMEON		"/sys/class/leds/sms_led/delay_on"
+#define LED_SMS_BLUE_BLINKTIMEOFF		"/sys/class/leds/sms_led/delay_off"
+
+#define LED_LAN_GREEN_BRIGHTNESS		"/sys/class/leds/wifi_led/brightness"
+#define LED_LAN_GREEN_BLINKSWITCH		"/sys/class/leds/wifi_led/trigger"
+#define LED_LAN_GREEN_BLINKTIMEON		"/sys/class/leds/wifi_led/delay_on"
+#define LED_LAN_GREEN_BLINKTIMEOFF		"/sys/class/leds/wifi_led/delay_off"
+
+#define LED_LAN_BLUE_BRIGHTNESS		    "/sys/class/leds/wifi_led/brightness"
+#define LED_LAN_BLUE_BLINKSWITCH		"/sys/class/leds/wifi_led/trigger"
+#define LED_LAN_BLUE_BLINKTIMEON		"/sys/class/leds/wifi_led/delay_on"
+#define LED_LAN_BLUE_BLINKTIMEOFF		"/sys/class/leds/wifi_led/delay_off"
+
+#define LED_VOIP_BLUE_BRIGHTNESS		"/sys/class/leds/sms_led/brightness"
+#define LED_VOIP_BLUE_BLINKSWITCH		"/sys/class/leds/sms_led/trigger"
+#define LED_VOIP_BLUE_BLINKTIMEON		"/sys/class/leds/sms_led/delay_on"
+#define LED_VOIP_BLUE_BLINKTIMEOFF		"/sys/class/leds/sms_led/delay_off"
+
+#define LED_SIGNAL1_BLUE_BRIGHTNESS		"/sys/class/leds/4g_1_led/brightness"
+#define LED_SIGNAL1_BLUE_BLINKSWITCH	"/sys/class/leds/4g_1_led/trigger"
+#define LED_SIGNAL1_BLUE_BLINKTIMEON	"/sys/class/leds/4g_1_led/delay_on"
+#define LED_SIGNAL1_BLUE_BLINKTIMEOFF	"/sys/class/leds/4g_1_led/delay_off"
+
+#define LED_SIGNAL2_BLUE_BRIGHTNESS		"/sys/class/leds/4g_2_led/brightness"
+#define LED_SIGNAL2_BLUE_BLINKSWITCH	"/sys/class/leds/4g_2_led/trigger"
+#define LED_SIGNAL2_BLUE_BLINKTIMEON	"/sys/class/leds/4g_2_led/delay_on"
+#define LED_SIGNAL2_BLUE_BLINKTIMEOFF	"/sys/class/leds/4g_2_led/delay_off"
+
+#define LED_SIGNAL3_BLUE_BRIGHTNESS		"/sys/class/leds/4g_3_led/brightness"
+#define LED_SIGNAL3_BLUE_BLINKSWITCH	"/sys/class/leds/4g_3_led/trigger"
+#define LED_SIGNAL3_BLUE_BLINKTIMEON	"/sys/class/leds/4g_3_led/delay_on"
+#define LED_SIGNAL3_BLUE_BLINKTIMEOFF	"/sys/class/leds/4g_3_led/delay_off"
+
+#define LED_SIGNAL4_BLUE_BRIGHTNESS		"/sys/class/leds/4g_4_led/brightness"
+#define LED_SIGNAL4_BLUE_BLINKSWITCH	"/sys/class/leds/4g_4_led/trigger"
+#define LED_SIGNAL4_BLUE_BLINKTIMEON	"/sys/class/leds/4g_4_led/delay_on"
+#define LED_SIGNAL4_BLUE_BLINKTIMEOFF	"/sys/class/leds/4g_4_led/delay_off"
+
+#define LED_SIGNAL5_BLUE_BRIGHTNESS		"/sys/class/leds/4g_5_led/brightness"
+#define LED_SIGNAL5_BLUE_BLINKSWITCH	"/sys/class/leds/4g_5_led/trigger"
+#define LED_SIGNAL5_BLUE_BLINKTIMEON	"/sys/class/leds/4g_5_led/delay_on"
+#define LED_SIGNAL5_BLUE_BLINKTIMEOFF	"/sys/class/leds/4g_5_led/delay_off"
+
+#define LED_WPS_BLUE_BRIGHTNESS		"/sys/class/leds/wps_led/brightness"
+#define LED_WPS_BLUE_BLINKSWITCH	"/sys/class/leds/wps_led/trigger"
+#define LED_WPS_BLUE_BLINKTIMEON	"/sys/class/leds/wps_led/delay_on"
+#define LED_WPS_BLUE_BLINKTIMEOFF	"/sys/class/leds/wps_led/delay_off"
+
+#define LED_RJ11_BLUE_BRIGHTNESS	"/sys/class/leds/rj11_led/brightness"
+#define LED_RJ11_BLUE_BLINKSWITCH	"/sys/class/leds/rj11_led/trigger"
+#define LED_RJ11_BLUE_BLINKTIMEON	"/sys/class/leds/rj11_led/delay_on"
+#define LED_RJ11_BLUE_BLINKTIMEOFF	"/sys/class/leds/rj11_led/delay_off"
+
+#define LED_RJ45_GREEN_BRIGHTNESS	"/sys/class/leds/eth_led/brightness"
+#define LED_RJ45_GREEN_BLINKSWITCH	"/sys/class/leds/eth_led/trigger"
+#define LED_RJ45_GREEN_BLINKTIMEON	"/sys/class/leds/eth_led/delay_on"
+#define LED_RJ45_GREEN_BLINKTIMEOFF	"/sys/class/leds/eth_led/delay_off"
+
+
+#define LED_BLINKON_STATE               "timer"
+#define LED_BLINKOFF_STATE              "none"
+
+
+//¸ºÔØÂ·¾¶ÅäÖÃ
+#define BOOST_LOAD_STATUS_PATH			"/sys/class/power_supply/boost/online"
+
+//µçѹÁÙ½çÖµ
+
+//zdm ¶ÔÓÚÏÂÃæ¼¸¸öºêÖµ£¬Ôݲ»½øÐÐÆ½Ì¨»¯£¬ºóÆÚÒ»µ©ÓÐÐèÇó½øÐÐÐ޸ģ¬ÔòÖ±½ÓÌá³Énv½øÐпØÖÆ
+#define POWEROFFLEVEL           		3300        //µÍÓڴ˵çѹֵ×Ô¶¯¹Ø»ú
+#define POWERONLEVEL           			3400       //µÍÓڴ˵çѹֵ²»ÄÜ¿ª»ú
+#define DISCHARGELEVEL					3600		//µÍÓڴ˵çѹֵ·ÅµçµçÁ÷ÉèΪ0.5A
+#define CHARGINGLEVEL					3800		//¸ßÓڴ˵çѹֵ·ÅµçµçÁ÷ÉèΪ1.5A
+
+#define CHECK_POWER_TIME_INTERVAL      	60000
+#define GET_TEMP_INTERVAL_TIME		    20000//ms
+
+//WIFIÐÅÏ¢¶¨Òå
+#define WIFI_STATE_PATH				"/etc_rw/wifiStatus"
+#define WPS_STATE_PATH				"/etc_rw/wpsStatus"
+#define WPS_STATEEX_PATH			"/etc_rw/wpsdisplayStatus"
+#define QRCODE_STATE_PATH			"/etc_rw/qrStatus"
+#define WIFI_STATION_PATH			"/etc_rw/staStatus"
+#define WIFI_DATA_VA0		        "wlan0-va0"
+#define WIFI_DATA_VA1		        "wlan0-va1"
+#define WIFI_TXBYTE		            0//·¢ËÍÊý¾Ý
+#define WIFI_RXBYTE		            2//½ÓÊÕÊý¾Ý
+#define WIFICODE_MAIN_PATH          "/etc_rw/wifi/ssid_wifikey.bmp"
+#define WIFICODE_GUST1_PATH         "/etc_rw/wifi/multi_ssid_wifikey.bmp"
+
+
+
+/*******************************************************************************
+ÓïÒôÌáʾָʾµÆ×´Ì¬¶¨Òå
+*******************************************************************************/
+#define VOIP_IN_CALL                "ledon"
+#define VOIP_IN_CONNECTION          "ledblink"
+#define VOIP_HANG_UP                "ledoff"
+
diff --git a/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_common.h b/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_common.h
new file mode 100755
index 0000000..27d7e75
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_common.h
@@ -0,0 +1,1296 @@
+/*****************************************************************************
+*  °æ±¾ËùÓÐ (C)ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾
+*  Ä£¿éÃû    £ºMMI
+*  ÎļþÃû    £ºmmi_led.h
+*  Îļþ±êʶ  £º
+*  Ïà¹ØÎļþ  £º
+*  ʵÏÖ¹¦ÄÜ  £ºMMIÍ·Îļþ
+*  ×÷Õß      £º
+*  °æ±¾      £ºV1.0
+*  Íê³ÉÈÕÆÚ  £º2014-6-20
+*  ÆäËü˵Ã÷  £º
+*
+*******************************************************************************/
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+#include <pthread.h>
+#include <semaphore.h>
+#include <time.h>
+#include <sys/prctl.h>
+#include "softap_api.h"
+#include "soft_timer.h"
+#include "mmi_cfg.h"
+
+#ifndef DISABLE_LCD
+#include "os_type.h"
+#include "gui_common.h"
+#endif
+
+#include "cfg_api.h"
+#include "cfg_nv_def.h"
+
+#ifndef __MMI_COMMON_H
+#define __MMI_COMMON_H
+#define MMI_SOFTTIMER_DEBUG     1
+/*******************************************************************************
+  ¸÷Ä£¿é¶¨ÒåµÄNV ͳһ»ã×Ü
+*******************************************************************************/
+#define MMI_BAT_VOLTAGE_LEN				21
+
+/*******************************************************************************
+  MMI ¹«¹²×Ö·û´®Í³Ò»¶¨Òå
+*******************************************************************************/
+#define INVALID_STR ""
+
+/*******************************************************************************
+  MMI ·µ»ØÖµ¶¨Òå
+*******************************************************************************/
+#define MMI_SUCCESS						0x0
+#define MMI_ERROR						-1
+
+#define MMI_WAIT_FOREVER 				0XFFFFFFFF
+#define MMI_THREAD_INVALID_ID  			0XFFFFFFFF
+#define MMI_SEMA_INVALID_ID  			0xFFFFFFFF
+#define MMI_MUTEX_INVALID_ID            0xFFFFFFFF
+
+
+/*******************************************************************************
+  MMI LOG¿ª¹Ø¡¢´æ´¢Â·¾¶¡¢³¤¶È
+*******************************************************************************/
+#define MMI_FILE_DEBUG 				0
+#define MMI_SERIAL_DEBUG 			1
+#define MMI_DEBUG 					1
+
+#define MMI_LOG_FILE_PATH         "/etc_rw/config/mmi.log"
+#define MMI_LOG_OLD_FILE_PATH     "/etc_rw/config/oldmmi.log"
+
+#define MMI_MAX_PRINT_LEN	      256
+#define MMI_MAX_LOG_LENGTH 	      524288
+
+/*******************************************************************************
+  MMI ʹÓÃÉ豸Ãû³Æ
+*******************************************************************************/
+
+#define  KPD_DEV    					"kpd"
+#define  RTC_DEV    					"rtc"
+#define  LED_DEV    			  		"led"
+#define  CHG_DEV                        "charger"
+
+#define LCD_PATH 						"/dev/fb0"
+#define LCD_MAGIC 						 'L'
+#define LEADT15DS26_SET_BACKLIGHT		_IOW(LCD_MAGIC, 2, unsigned int)
+
+
+/*******************************************************************************
+ MMI ¶¨Ê±Æ÷¶¨Òå
+*******************************************************************************/
+#define SET_BACKLIGHT_HALFBRIGHT_TIMER	80
+#define SET_TIME_CHECK_TIMER			81
+#define SET_WIFI_STANUM_CHECK_TIMER		82
+#define SET_WPS_TIP_CHECK_TIMER         83
+#define SET_TIP_CHECK_TIMER				84
+#define SET_MMI_IDLE_TIMER				85
+#define SET_SSID_SHOW_TIMER				86
+#define SET_SMS_TIP_TIMER				87
+#define SET_TRAFFIC_INFO_WAIT_TIMER     88
+#define SET_MMI_FAST_POWERON_IDLE_TIMER	89
+#define SET_WIFI_DATA_CHECK_TIMER	    90
+#define SET_RJ45_INFO_WAIT_TIMER        91
+
+
+#define SET_TIME_CHECK_TIME         	1000
+#define SET_WIFI_STANUM_CHECK_TIME      3000
+#define SET_WPS_TIP_CHECK_TIME         	2000
+#define SET_TIP_CHECK_TIME         		1000
+#define SET_MMI_IDLE_TIME				20000
+#define SET_BACKLIGHT_HALFBRIGHT_TIME	5000
+#define SET_SSID_SHOW_TIME				20000
+#define SET_SMS_TIP_TIME				10000
+#define SET_TRAFFIC_INFO_WAIT_TIME      10000
+#define SET_MMI_FAST_POWERON_IDLE_TIME	4000
+#define SET_WIFI_DATA_CHECK_TIME	    3000
+#define SET_RJ45_INFO_WAIT_TIME         2000
+
+/*******************************************************************************
+MMI ³äµçÒµÎñÅäÖÃ
+*******************************************************************************/
+#define CHARGE_STATUS_PATH			  	"/sys/class/power_supply/charger/status"
+#define CHARGING_TYPE_PATH				"/sys/class/power_supply/charger/pc1_ac2"
+#define USB_INSERT_STATUS_PATH			"/sys/class/power_supply/charger/online"
+#define CHARGE_VOLTAGE_PATH				"/sys/class/power_supply/battery/voltage_now"
+#define CHARGE_BAT_TEMP_PATH 			"/sys/class/power_supply/battery/temp"
+#define CHARGE_BAT_HEALTH_PATH 			"/sys/class/power_supply/battery/health"
+
+#define MMI_SET_FAKEPOWEROFF_CHARGER    "echo 1 > /sys/class/power_supply/charger/quick_power_on"
+#define MMI_CAN_FAKEPOWEROFF_CHARGER    "echo 0 > /sys/class/power_supply/charger/quick_power_on"
+
+#define MMI_TURN_OFF_CHG_FULL  		    "echo 2 > /sys/class/power_supply/charger/charge_enabled"
+#define MMI_TURN_OFF_CHG  		        "echo 0 > /sys/class/power_supply/charger/charge_enabled"
+#define MMI_TURN_ON_CHG	  		        "echo 1 > /sys/class/power_supply/charger/charge_enabled"
+
+#define MMI_TURN_OFF_DISCHG  	        "echo 0 > /sys/class/power_supply/boost/boost_enabled"
+#define MMI_TURN_ON_DISCHG	  	        "echo 1 > /sys/class/power_supply/boost/boost_enabled"
+
+#define MMI_DISCHG_LOW_CURRENT  	    "echo 5 > /sys/class/power_supply/boost/current_now"
+#define MMI_DISCHG_HIGH_CURRENT	        "echo 15 > /sys/class/power_supply/boost/current_now"
+
+#define CHARGE_STATUS_CHARGING		 	"Charging"
+#define CHARGE_STATUS_FULL		 	 	"Full"
+#define CHARGE_STATUS_NOTCHARGING		"Not charging"
+#define CHARGE_STATUS_DISCHARGING		"Discharging"
+
+#define CHARGING_TYPE_PC				"USB"
+#define CHARGING_TYPE_ADAPTER			"Mains"
+#define CHARGING_TYPE_UNKNOWN			"Unknown"
+
+#define TEMP_STATUS_GOOD				"Good"
+#define TEMP_STATUS_OVERHEAT			"Overheat"
+#define TEMP_STATUS_DEAD				"Dead"
+#define TEMP_STATUS_OVER_VOLTAGE		"Over voltage"
+#define TEMP_STATUS_FAIL				"Unspecified failure"
+#define TEMP_STATUS_COLD				"Cold"
+#define TEMP_STATUS_WARM				"Warm"
+#define TEMP_STATUS_COOL				"Cool"
+#define TEMP_STATUS_UNKNOWN			    "Unknown"
+
+#define USB_STATUS_IN					"1"
+#define USB_STATUS_OUT					"0"
+
+#define CHARGE_STATUS_LENGTH				16
+#define CHARGING_TYPE_LENGTH				8
+#define CHARGE_VOLTAGE_LENGTH				8
+
+#define CHARGE_STATUS_CHARGING_LENGTH		8
+#define CHARGE_STATUS_FULL_LENGTH		 	4
+#define CHARGE_STATUS_NOTCHARGING_LENGTH	12
+#define CHARGE_STATUS_DISCHARGING_LENGTH	11
+
+/*******************************************************************************
+ MMI ÈÎÎñ¶¨Òå
+*******************************************************************************/
+
+
+typedef enum {
+	MMI_TASK_CTRL = 0,//¿ª»ú±ØÐëʱµÚһλ£¬È·±£¿ª»ú¶¯»­ÏÈ»æÖÆ
+	MMI_TASK_BATTERY,
+	MMI_TASK_NET,
+	MMI_TASK_WIFI,
+	MMI_TASK_SMS,
+	MMI_TASK_VOIP,
+	MMI_TASK_TRAFFIC,
+	MMI_TASK_POWEROFF_CHARGER,
+	MMI_TASK_TIP_NET_CONNECT,
+	MMI_TASK_TIP_WIFISTATION,
+	MMI_TASK_TIP_WPS,
+	MMI_TASK_TIP,
+	MMI_TASK_SSID,
+	MMI_TASK_TIP_FOTA,
+	MMI_TASK_POWER,
+	MMI_TASK_WIFICODE,
+	MMI_TASK_NETSIGNAL, //yaoyuan cpe
+	MMI_TASK_LED_WPS, //yaoyuan cpe MMI_TASK_TIP_WPS
+	MMI_TASK_RJ11, //yaoyuan cpe
+	MMI_TASK_TIME,
+	MMI_TASK_KEY,
+	MMI_TASK_USB_MODE,
+	MMI_TASK_RJ45,
+	MMI_TASK_MAX
+} E_zMmi_Task;
+
+#define MMI_TASK_INVALID  -1
+//¶¨Ò庯ÊýÖ¸ÕëÀàÐÍ
+typedef SINT32(*MMI_TASK_REGISTER_FUNC)(void);
+typedef void (*MMI_TASK_INIT_FUNC)(void);
+
+/*******************************************************************************
+ MMI ÏÔʾģʽ¶¨Òå
+*******************************************************************************/
+typedef enum {
+	MMI_MODE_LED = 1,
+	MMI_MODE_LCD,
+	MMI_MODE_ALL
+} E_zMmiShowMode;
+
+
+/*******************************************************************************
+ MMI ÏûÏ¢¶¨Òå
+*******************************************************************************/
+
+#define NV_CONTENT_LEN 						1024
+
+
+/*******************************************************************************
+  LEDµÆÊ¡µçÏà¹Ø¶¨Òå
+*******************************************************************************/
+typedef enum {
+	//public
+	MMI_ACTIVE_MODE = 0,
+	MMI_IDLE_LEDOFF_MODE,
+	MMI_IDLE_CHG_LEDOFF_MODE,
+	MMI_IDLE_STANDBY_LEDOFF_MODE,
+	MMI_FAKE_POWEROFF_MODE,
+	MMI_FAKE_POWEROFF_CHARGE_MODE,
+
+	//LED
+	MMI_ALL_LED_ON_MODE,
+	MMI_ALL_LED_OFF_MODE,
+	MMI_POWEROFF_ON_MODE,
+	MMI_POWEROFF_OFF_MODE,
+
+
+	//LCD
+	MMI_BACKLIGHT_OFF_MODE,
+	MMI_BACKLIGHT_HALFBRIGHT_MODE,
+	MMI_POWERON_MODE,
+	MMI_POWEROFF_MODE,
+	MMI_RESET_MODE,
+	MMI_RESTART_MODE,
+	MMI_FAST_POWERON_MODE,
+} E_zMmi_Work_Mode;
+
+/*
+¿ØÖÆÐÅÏ¢½á¹¹
+*/
+typedef struct {
+	E_zMmi_Work_Mode lcdmode;
+	E_zMmi_Work_Mode ledmode;
+} T_zMMICtrlInfo;
+
+#define MMI_MAIN_LOCK_ID				"mmi_main_lock"
+#define MMI_POWEROFF_LOCK_ID			"mmi_powerdown_lock"//¹Ø»ú¡¢»Ö¸´³ö³§ÉèÖá¢ÖØÆô¡¢¹Ø»ú³äµç¿ª»ú
+#define MMI_GET_POWER_LOCK_ID			"mmi_get_power_lock"//20Sζȼì²â/µÍµç¼ì²â
+#define MMI_POWEROFF_LOCK_LCD_ID		"mmi_poweroff_charger_lock"//³õʼ»¯¡¢°´¼ü--  --ÃðÆÁ
+
+
+/*******************************************************************************
+  LCDÌáʾ¶¨Òå ÍøÂçÁ¬½Ó¡¢SIM¿¨×´Ì¬µÈ
+*******************************************************************************/
+typedef enum {
+	INSERT_SIM = 0,
+	PIN_LOCK,
+	PUK_LOCK,
+	SIM_BUSY,
+	INVALID_SIM,
+	SIM_LOCK,
+	SIM_READY,
+
+	SIM_MAX
+}
+E_zMmi_Sim_Tip;
+
+typedef enum {
+	NET_DISCONNECTED = 0,
+	NET_CONNECTED,
+	NET_CONNECTING,
+	NET_DISCONNECTING,
+	NET_NOSERVICE,
+	NET_LIMITSERVICE,
+	NET_SEARCHING,
+	NET_MAX
+} E_zMmi_NetCon_Tip;
+
+typedef enum {
+	WPS_ACTIVING = 0,
+	WPS_ACTIVED,
+	WPS_DEACTIVING,
+	WPS_DEACTIVED,
+	WPS_FAIL,
+	WPS_ACTIVE_MAX
+} E_zMmi_WpsAct_Tip;
+
+
+typedef struct {
+	E_zMmi_Sim_Tip sim_tip;
+	E_zMmi_NetCon_Tip net_tip;
+	CHAR* net_pro;
+	//CHAR* update_result;//zk add for fota update result
+	//SINT32 update_tip;
+} T_zMMITipInfo;
+
+typedef enum {
+	FOTA_DOWNLOADING = 0,
+	FOTA_DOWNLOAD_FAILED,
+	FOTA_DOWNLOAD_OK,
+	FOTA_DOWNLOAD_LOWBATTERY,
+	FOTA_UPDATE_SUCCESS,
+	FOTA_UPDATE_FAILED,
+	FOTA_SHOW_FINISH,
+	FOTA_MAX
+} E_zMMI_Fota_Tip;
+
+typedef enum {
+	FOTA_UPDATE = 0,
+	FOTA_CANCEL
+} E_zMmi_Fota_Oper;
+
+typedef struct {
+	SINT32 fota_update;
+	E_zMMI_Fota_Tip fota_tip;
+	E_zMmi_Fota_Oper fota_oper;
+} T_zMMIFotaInfo;
+
+typedef struct {
+	CHAR *ssid;
+	CHAR *wifi_key;
+	CHAR *ssid2;
+	CHAR *wifi_key2;
+} T_zMMISSIDInfo;
+
+typedef struct {
+	CHAR *msisdn;
+	CHAR *pci;
+	CHAR *rapr_dBm;
+	CHAR *sinr_dB;
+} T_zMMINetSignalInfo;
+
+/*
+ʱ¼äÐÅÏ¢½á¹¹
+*/
+typedef struct {
+	BOOL mode;//ʱ¼äÖÆÊ½ true--24Ð¡Ê±ÖÆ false--12Ð¡Ê±ÖÆ
+	CHAR* hour;
+	CHAR* minute;
+	//CHAR* quota;
+} T_zMMITimeInfo;
+
+/*******************************************************************************
+µç³ØÐÅÏ¢¶¨Òå
+*******************************************************************************/
+//webui³äµç״̬NV
+#define WEBUICHARGESTATTUS      		"battery_charging"        					///1:³äµç״̬ 0:·Ç³äµç״̬
+#define WEBUICHARGING           		"1"
+#define WEBUIUNCHARGING        			"0"
+
+//webuiµÄµç³Ø¸ñÊýNV
+#define WEBUIBATTERYLEVEL       		"battery_pers"
+#define WEBUINOLEVEL            		"0"
+#define WEBUIONELEVEL           		"1"
+#define WEBUITWOLEVEL           		"2"
+#define WEBUITHRLEVEL           		"3"
+#define WEBUIFOURLEVEL         	 		"4"
+#define WEBUIFULLLEVEL         	 		"100"
+#define WEBUINOBATTERY         	 		"-1"
+
+//wifi Monitorµç³Ø°Ù·Ö±È
+#define BATTERYPERS_NV					"battery_vol_percent"
+
+typedef enum {
+	STATE_FULL = 0,
+	STATE_CHARGING,
+	STATE_DISCHARGE,
+	STATE_CHARGERROR,
+	STATE_CHARGE_MAX
+} E_zMmi_Charge_State;
+
+typedef enum {
+	CHARGING_PC = 0,
+	CHARGING_ADAPTER,
+	CHARGING_TYPE_MAX,
+} E_zMmi_Charge_Type;
+
+typedef enum {
+	VOLT_5PERCENTLEVEL = 0,
+	VOLT_10PERCENTLEVEL,
+	VOLT_20PERCENTLEVEL,
+	VOLT_25PERCENTLEVEL,
+	VOLT_50PERCENTLEVEL,
+	VOLT_75PERCENTLEVEL,
+	VOLT_NORMALLEVEL,
+	VOLT_MAX,
+} E_zMmi_Voltage_level;
+
+typedef struct {
+	CHAR* devString;
+	E_zMmi_Charge_State chg_sta;
+} T_zMmiChgStateStringItem;
+
+
+typedef enum {
+	MODE_STANDBY = 0,
+	MODE_CHARGING,
+	MODE_LOWBATTERY_20,
+	MODE_LOWBATTERY_10,
+	MODE_OFF
+} E_zMMI_BatLed_Mode;
+
+/*µç³ØÐÅÏ¢½á¹¹*/
+typedef struct {
+	E_zMmi_Charge_State chg_state;
+	E_zMmi_Voltage_level bat_level;
+	SINT32 bat_pers;
+	SINT32 bat_grid;
+} T_zMMIBatteryInfo;
+
+
+//ζȼì²â
+typedef enum {
+	MMI_TEMP_DETECT_ERROR = 0,
+	MMI_TEMP_DETECT_ABNORMAL,
+	MMI_TEMP_DETECT_NORMAL,
+	MMI_TEMP_DETECT_MAX
+} MMI_TEMP_DETECT;
+
+//¹Ø»ú³äµç
+typedef enum {
+	POC_STATE_CHARGING = 0,
+	POC_STATE_FULL,
+	POC_STATE_LOWBATTERY,
+	POC_STATE_NOBATTERY,
+	POC_STATE_TEMP_ERROR,
+	POC_STATE_MAX
+} E_zMmi_Poc_State;
+
+typedef enum {
+	POC_CHARGING_PC = 0,
+	POC_CHARGING_ADAPTER,
+	POC_CHARGING_TYPE_MAX
+} E_zMmi_Poc_Type;
+
+typedef struct {
+	SINT32 backlight_sta;
+	E_zMmi_Poc_State poc_sta;
+	BOOL overvoltage_mode;
+} T_zMmi_Poc_Info;
+
+/*******************************************************************************
+  ÍøÂçÐÅÏ¢¶¨Òå
+*******************************************************************************/
+typedef enum {
+	NET_MODE_DEFAULT = 0,
+	NET_MODE_2G,
+	NET_MODE_3G,
+	NET_MODE_4G,
+	NET_MODE_NOSERVICE,
+	NET_MODE_LIMITSERVICE,
+	NET_MODE_NOTREADY //yaoyuan
+} E_zMmi_Net_Mode;
+
+typedef enum {
+	NET_STATE_DISCONNECTED = 0,
+	NET_STATE_CONNECTED,
+	NET_STATE_CONNECTING,
+	NET_STATE_DISCONNECTING,
+	NET_STATE_NOSERVICE,
+	NET_STATE_LIMITSERVICE,
+	NET_STATE_SEARCHING,
+	NET_STATE_MAX
+} E_zMmi_Net_State;
+
+typedef enum {
+	NET_SIGNAL_DEFAULT = 0,
+	NET_SIGNAL_NORMAL,
+	NET_SIGNAL_WEAK
+} E_zMmi_Net_Signal;
+
+typedef enum {
+	NET_SOCKET_INACTIVE = 0,
+	NET_SOCKET_ACTIVE
+} E_zMmi_Net_Socket;
+
+
+/*ÍøÂçÐÅÏ¢½á¹¹*/
+
+typedef struct {
+	E_zMmi_Net_Mode net_mode;
+	E_zMmi_Net_State connect_status;
+	SINT32 signal_num;
+	SINT32 signal_weak;
+	SINT32 roam_mode;
+	E_zMmi_Net_Socket socket_state;
+} T_zMMINetInfo;
+
+
+#define WD_NUM 						    5    //wifi ¼à¿ØÎļþ¸öÊý
+#define WIFI_TURN_ON 					"1"  //wifi operate type
+#define WIFI_TURN_OFF 					"0"  //wifi operate type
+#define WIFI_TURN_OFF_FAKE_POWEROFF		"2"  //wifi operate type
+
+
+struct st_files {
+	char *filename;
+	int wd;
+};
+
+typedef struct {
+	BOOL wifiState;
+	BOOL wpsState;
+	BOOL mIsConnectUser;
+} T_zMmi_LanLed_Info;
+
+typedef enum {
+	WIFI_OFF = 0,
+	WIFI_ON
+} E_zMmi_Wifi_State;
+
+typedef enum {
+	WPS_OFF = 0,
+	WPS_ON
+} E_zMmi_Wps_State;
+
+typedef enum {
+	NO_USER_CONNECTED = 0,
+	USER_CONNECTED
+} E_zMmi_Wifi_ConState;
+typedef enum {
+	WIFISTATION_OFF = 0,
+	WIFISTATION_ON
+} E_zMmi_WifiStation_State;
+typedef enum {
+	WIFICODE_MAIN = 0,
+	WIFICODE_GUST1
+} E_zMmi_WifiCode_State;
+
+
+/*
+wifiÐÅÏ¢½á¹¹
+*/
+typedef struct {
+	BOOL wifi_state;
+	BOOL wifidata_state;
+	SINT32 Isconnected_user;
+	SINT32 connected_userNum;
+	E_zMmi_WpsAct_Tip wps_state;
+} T_zMMIWifiInfo;
+/*
+wifistationÐÅÏ¢½á¹¹
+*/
+typedef struct {
+	BOOL wifistation_connect_state;
+	SINT32 signal_num;
+	CHAR *wifista_ssid;
+} T_zMMIWifiStationInfo;
+/*
+wificodeÐÅÏ¢½á¹¹
+*/
+typedef struct {
+	BOOL multi_ssid_switch;
+	BOOL is_wificode_exist;
+} T_zMMIWifiCodeInfo;
+
+/*******************************************************************************
+ Á÷Á¿ÐÅÏ¢¶¨Òå
+*******************************************************************************/
+typedef enum {
+	TRAFFIC_UNIT_DATA = 0,
+	TRAFFIC_UNIT_TIME,
+
+	TRAFFIC_UNIT_MAX
+} MMI_TRAFFIC_UNIT;
+
+typedef enum {
+	TRAFFIC_LIMIT_SWITCH_OFF = 0,
+	TRAFFIC_LIMIT_SWITCH_ON,
+} MMI_TRAFFIC_SWITCH;
+
+typedef enum {
+	TRAFFIC_DATA_UNIT_MAX = 0,
+	TRAFFIC_DATA_UNIT_MB,
+	TRAFFIC_DATA_UNIT_GB,
+	TRAFFIC_DATA_UNIT_TB
+} E_ZMmi_Traffic_Data_Unit;
+
+typedef enum {
+	TRAFFIC_LED_1 = 0,
+	TRAFFIC_LED_2,
+	TRAFFIC_LED_3,
+	TRAFFIC_LED_4,
+	TRAFFIC_LED_5,
+	TRAFFIC_LED_6,
+	TRAFFIC_LED_7,
+	TRAFFIC_LED_8,
+	TRAFFIC_LED_9,
+	TRAFFIC_LED_10,
+	TRAFFIC_LED_MAX
+} MMI_TRAFFIC_LED;
+
+/*
+trafficÐÅÏ¢½á¹¹
+*/
+typedef struct {
+	MMI_TRAFFIC_SWITCH traffic_switch;
+	MMI_TRAFFIC_UNIT traffic_unit;
+	E_ZMmi_Traffic_Data_Unit data_unit;
+	E_ZMmi_Traffic_Data_Unit useddata_unit;
+	MMI_TRAFFIC_LED led_status;
+	SINT32 warning_tip_flag ;
+	UINT32 warning_tip_level;
+	float total_traffic;
+	float uesd_traffic;
+} T_zMMITrafficInfo;
+/*
+ÒÆ¶¯ÔËÓªÉÌtrafficÐÅÏ¢½á¹¹
+*/
+typedef struct {
+	BOOL main_used_valid;//˵Ã÷main usedÊý¾ÝÊÇ·ñÓÐЧ
+	SINT32 main_left_traffic;
+	SINT32 main_total_traffic;
+	//BOOL bonus_used_valid;//˵Ã÷bonus usedÊý¾ÝÊÇ·ñÓÐЧ
+	//FLOAT bonus_uesd_traffic;
+	//FLOAT bonus_total_traffic;
+} T_zMMIQuotaTrafficInfo;
+
+
+/*******************************************************************************
+ ¶ÌÐÅÐÅÏ¢Ïà¹Ø¶¨Òå
+*******************************************************************************/
+typedef enum {
+	SMS_RECVBOX_STATUS_UNREAD = 0,
+	SMS_RECVBOX_STATUS_NEW,
+	SMS_RECVBOX_STATUS_FULL,
+	SMS_RECVBOX_STATUS_NOR
+} E_zMmi_Sms_Recvbox_Status;
+
+typedef struct {
+	SINT32 mSmsNum;
+	E_zMmi_Sms_Recvbox_Status recvBox_sta;
+} T_zMmi_Sms_Info;
+
+/*******************************************************************************
+ ÓïÒôÌáʾÐÅÏ¢Ïà¹Ø¶¨Òå
+*******************************************************************************/
+typedef enum {
+	VOIP_STATUS_IN_CALL = 0,
+	VOIP_STATUS_IN_CONNECTION,
+	VOIP_STATUS_HANG_UP,
+	VOIP_STATUS_NOR
+} E_zMmi_Voip_Status;
+
+typedef struct {
+	E_zMmi_Voip_Status voip_sta;
+} T_zMmi_Voip_Info;
+
+/*******************************************************************************
+ rj11²å°ÎÐÅÏ¢Ïà¹Ø¶¨Òå
+*******************************************************************************/
+typedef enum {
+	RJ11_STATUS_OUT = 0,
+	RJ11_STATUS_IN,
+	RJ11_STATUS_NOR
+} E_zMmi_Rj11_Status;
+
+typedef struct {
+	E_zMmi_Rj11_Status rj11_sta;
+} T_zMmi_Rj11_Info;
+
+/*******************************************************************************
+ rj45²å°ÎÐÅÏ¢Ïà¹Ø¶¨Òå
+*******************************************************************************/
+typedef enum {
+	RJ45_STATUS_OUT = 0,
+	RJ45_STATUS_IN,
+	RJ45_STATUS_NOR
+} E_zMmi_Rj45_Status;
+
+typedef struct {
+	E_zMmi_Rj45_Status rj45_sta;
+} T_zMmi_Rj45_Info;
+
+/*******************************************************************************
+  LEDµÆ¹«¹²¶¨Òå
+*******************************************************************************/
+
+typedef enum {
+	LED_STATE_ON = 0,
+	LED_STATE_OFF,
+	LED_STATE_BLINK,
+	LED_STATE_MAX
+} MMI_LED_STATE;
+
+typedef enum {
+	LED_STATE_DEFAULT_BLINK,
+	LED_STATE_FAST_BLINK,
+	LED_STATE_SLOW_BLINK,
+	LED_STATE_BAT_BLINK,
+	LED_STATE_SMS_BLINK,
+	LED_STATE_VOIP_BLINK,
+	LED_STATE_LAN_BLINK,
+	LED_STATE_WAN_BLINK,
+	LED_STATE_WAN_FAST_BLINK,
+	LED_STATE_WAN_SLOW_BLINK,
+	LED_STATE_WAN_CPE_FAST_BLINK,
+	LED_STATE_WAN_CPE_SLOW_BLINK
+} MMI_LED_BLINK_SPEED;
+
+
+typedef enum {
+	LED_WAN = 0,
+	LED_LAN,
+	LED_BATTERY,
+	LED_SMS,
+	LED_VOIP,
+	LED_TRAFFIC,
+	LED_SIGNAL,
+	LED_WPS,
+	LED_RJ11,
+	LED_RJ45,
+	LED_ALL
+} MMI_LED_NAME;
+
+typedef enum {
+	LED_COLOR_RED = 0,
+	LED_COLOR_GREEN,
+	LED_COLOR_YELLOW,
+	LED_COLOR_BLUE,
+
+	MAX_LED_COLOR //kw 3
+} MMI_LED_COLOR;
+
+typedef struct {
+	UINT32 uBlinkOnTime;
+	UINT32 uBlinkOffTime;
+} T_zMmi_Led_Blink_Time;
+
+typedef struct {
+	MMI_LED_NAME led_name;
+	MMI_LED_STATE led_state;
+	MMI_LED_BLINK_SPEED ledBlink_speed;
+	T_zMmi_Led_Blink_Time ledBlink_time;
+	MMI_LED_COLOR led_color;
+	MMI_TRAFFIC_LED traffic;
+} T_zMmi_Led_Info;
+
+typedef struct {
+	char *fileblinkSwitch;
+	char *fileblinktimeon;
+	char *fileblinktimeoff;
+	char *timeon;
+	char *timoff;
+} T_zMmi_LedBlink_Info;
+
+typedef enum {
+	LED_RED_ON,
+	LED_RED_BLINK,
+
+	LED_GREEN_ON,
+	LED_GREEN_BLINK,
+
+	LED_YELLOW_ON,
+	LED_YELLOW_BLINK,
+
+	LED_BLUE_ON,
+	LED_BLUE_BLINK,
+
+	LED_BLUE1_ON,
+	LED_BLUE2_ON,
+	LED_BLUE3_ON,
+	LED_BLUE4_ON,
+	LED_BLUE5_ON,
+
+	LED_ALL_OFF,
+} MMI_LED_LASTSTATE;
+
+/**************************LED ÅäÖñí½á¹¹Ìå*****************************************************/
+
+typedef struct {
+	T_zMmi_Sms_Info sms_info;
+	T_zMmi_Led_Info led_info;
+} T_zMmiSmsLedConfig;
+
+typedef struct {
+	T_zMmi_Voip_Info voip_info;
+	T_zMmi_Led_Info led_info;
+} T_zMmiVoipLedConfig;
+
+typedef struct {
+	T_zMmi_Rj11_Info rj11_info;
+	T_zMmi_Led_Info led_info;
+} T_zMmiRj11LedConfig;
+
+typedef struct {
+	T_zMmi_Rj45_Info rj45_info;
+	T_zMmi_Led_Info led_info;
+} T_zMmiRj45LedConfig;
+
+typedef struct {
+	int custom_type;
+	T_zMMINetInfo net_info;
+	T_zMmi_Led_Info led_info;
+} T_zMmiNetLedConfig;
+
+typedef struct {
+	T_zMMIBatteryInfo bat_info;
+	T_zMmi_Led_Info led_info;
+} T_zMmiBatteryLedConfig;
+
+typedef struct {
+	int custom_type;
+	T_zMMIWifiInfo wifi_info;
+	T_zMmi_Led_Info led_info;
+} T_zMmiWifiLedConfig;
+
+
+/*******************************************************************************
+ °´¼üÏà¹Ø¶¨Òå
+*******************************************************************************/
+#define KPD_PATH 						"/dev/event0"
+#define KEY_POWER_CODE              116
+#define KEY_WPS_CODE                117
+#define KEY_RESET_CODE              118
+#define KEY_WIFI_CODE               119 //ҢԶcpe
+
+
+
+typedef enum {
+	KEY_STATUS_MAX = 0,				/*ÎÞЧ״̬*/
+	KEY_STATUS_UP,                  /*°´¼üËÉ¿ª*/
+	KEY_STATUS_DOWN,                /*°´¼ü°´ÏÂ*/
+	KEY_STATUS_LONGPRESS,            /*°´¼ü³¤°´*/
+} KEY_STATUS;
+
+typedef enum {
+	KEY_TYPE_POWER = 0,					/*power ¼ü*/
+	KEY_TYPE_RESET, 					/*reset ¼ü*/
+	KEY_TYPE_WPS,				        /*wps ¼ü*/
+	KEY_TYPE_WIFI,				        /*wifi ¼ü, ¿ª¹Ø Ò¢Ô¶cpe*/
+} KEY_TYPE;
+
+typedef struct {
+	KEY_TYPE    type;               /*°´¼üÀàÐÍ*/
+	KEY_STATUS  status;             /*°´¼ü״̬*/
+} MMI_KP_INFO;
+
+
+/*******************************************************************************
+ ¿ò¼ÜÏà¹Ø¶¨Òå
+*******************************************************************************/
+
+
+/*»ñȡҵÎñÐÅÏ¢º¯ÊýÖ¸Õë
+appInfo:³ö²Î£¬ÒµÎñÐÅÏ¢£¬Èç¹ûÊÇÊý¾Ý½á¹¹Ôò¸ÃÖµÖ¸ÏòÊý¾Ý½á¹¹µØÖ·
+·µ»ØÕýÈ·»ò´íÎó
+*/
+typedef SINT32(*MMI_GET_TASKINFO_FUNC)(UINT32 taskInfo);
+
+/*»ñÈ¡ledÏÔʾÐÅÏ¢º¯ÊýÖ¸Õë
+appInfo:Èë²Î£¬ÒµÎñÐÅÏ¢£¬Èç¹ûÊÇÊý¾Ý½á¹¹Ôò¸ÃÖµÖ¸ÏòÊý¾Ý½á¹¹µØÖ·
+outLedInfo:³ö²Î£¬ledÏÔʾÐÅÏ¢
+·µ»ØÕýÈ·»ò´íÎó
+*/
+typedef SINT32(*MMI_GET_LEDINFO_FUNC)(UINT32 taskInfo, UINT32 outLedInfo);
+
+/*»ñÈ¡lcdÏÔʾÐÅÏ¢º¯ÊýÖ¸Õë
+appInfo:Èë²Î£¬ÒµÎñÐÅÏ¢£¬Èç¹ûÊÇÊý¾Ý½á¹¹Ôò¸ÃÖµÖ¸ÏòÊý¾Ý½á¹¹µØÖ·
+outLcdInfo:³ö²Î£¬lcdÏÔʾÐÅÏ¢
+·µ»ØÕýÈ·»ò´íÎó
+*/
+typedef SINT32(*MMI_GET_LCDINFO_FUNC)(UINT32 taskInfo);
+/*ÏÔʾLED
+ledInfo:Èë²Î£¬ÒµÎñÐÅÏ¢£¬Èç¹ûÊÇÊý¾Ý½á¹¹Ôò¸ÃÖµÖ¸ÏòÊý¾Ý½á¹¹µØÖ·
+·µ»ØÕýÈ·»ò´íÎó
+*/
+typedef SINT32(*MMI_SHOW_LED_FUNC)(UINT32 ledInfo);
+/*ÏÔʾLCD
+lcdInfo:Èë²Î£¬ÒµÎñÐÅÏ¢£¬Èç¹ûÊÇÊý¾Ý½á¹¹Ôò¸ÃÖµÖ¸ÏòÊý¾Ý½á¹¹µØÖ·
+·µ»ØÕýÈ·»ò´íÎó
+*/
+typedef SINT32(*MMI_SHOW_LCD_FUNC)(UINT32 lcdInfo);
+
+/*¸Ã½á¹¹ÌåÓÃÓÚ±£´æÃ¿¸öÒµÎñµÄÊÊÅä²ãÌṩº¯ÊýÐÅÏ¢*/
+typedef struct {
+	E_zMmi_Task task;//ÒµÎñ
+	SINT32 is_update;//ÊÇ·ñÓиüÐÂ
+	//SINT32 show_mode;//led,1;lcd,2;lcd+lcd,3
+	VOID* taskinfo;
+	VOID* ledinfo;
+	MMI_GET_TASKINFO_FUNC   get_taskinfo_fun;
+	MMI_GET_LEDINFO_FUNC get_ledinfo_fun;
+	MMI_GET_LCDINFO_FUNC get_lcdinfo_fun;
+} T_zMMITaskInfoItem;
+
+//lcd ÏÔʾҳ
+typedef enum {
+	MMI_SHOW_PAGE_FIRST = 0,//traffic
+	MMI_SHOW_PAGE_SECOND, //SSID WIFI KEY; IMEI MSISDN
+	MMI_SHOW_PAGE_THIRD,//CODE
+	MMI_SHOW_PAGE_FOUR,//SSID2 WIFI KEY
+	MMI_SHOW_PAGE_FIVE,//CODE2
+	MMI_SHOW_PAGE_MAX
+} E_zMMI_Lcd_Page_Index;
+
+
+/**********************************************************************************
+º¯ÊýÉùÃ÷
+***********************************************************************************/
+/*¿ª¹Ø»ú»Øµ÷£¬ÓÃÓÚlcdÏÔʾÓÃ*/
+typedef VOID (*POWER_ON_OFF_CALLBACK_FUN)();
+VOID mmi_registerLcdPowerOnOff(POWER_ON_OFF_CALLBACK_FUN fun);
+//ÉèÖô¥·¢¸üбêÖ¾
+VOID mmi_set_update_flag(E_zMmi_Task task);
+//Çå³ý¸üбêÖ¾
+VOID mmi_clean_update_flag(E_zMmi_Task task);
+//»ñÈ¡¸üбêÖ¾
+SINT32 mmi_get_update_flag(E_zMmi_Task task);
+
+/**
+ * <mmi_register_appinfo_item>
+ * ×¢²á¸÷¸öÒµÎñÐÅÏ¢
+ **/
+VOID mmi_register_taskInfo_item(T_zMMITaskInfoItem* taskInfoItem);
+SINT32 mmi_showLed(UINT32 ledInfo);
+
+#define MMI_ASSERT(a)		assert(a);
+#define itoa(i,a,b) (((b) == 16) ? sprintf((a), "%x", (i)) : sprintf((a), "%d", (i)));
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:¿ª¹Ø»úÐÅÏ¢
+***********************************************************************************/
+SINT32 mmi_getLcdCtrlInfo(UINT32 taskInfo);
+SINT32 mmi_getLedCtrlInfo(UINT32 taskInfo, UINT32 outLedInfo);
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡¶ÌÐŵÆÐÅÏ¢
+***********************************************************************************/
+SINT32 mmi_getLedSmsInfo(UINT32 taskInfo, UINT32 outLedInfo);
+SINT32 mmi_getLcdSmsInfo(UINT32 taskInfo);
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡ÓïÒôÌáʾµÆÐÅÏ¢
+***********************************************************************************/
+SINT32 mmi_getLedVoipInfo(UINT32 taskInfo, UINT32 outLedInfo);
+
+SINT32 mmi_getLedRj11Info(UINT32 taskInfo, UINT32 outLedInfo);
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡ÒÔÌ«ÍøÌáʾµÆÐÅÏ¢
+***********************************************************************************/
+SINT32 mmi_getLedRj45Info(UINT32 taskInfo, UINT32 outLedInfo);
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡¶ÌÐŵÆÐÅÏ¢±íË÷Òý
+***********************************************************************************/
+SINT32 mmi_get_batteryinfo(UINT32 batteryinfo);
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡ÍøÂçµÆÐÅÏ¢
+***********************************************************************************/
+SINT32 mmi_getLedNetInfo(UINT32 taskInfo, UINT32 outLedInfo);
+SINT32 mmi_getLcdNetInfo(UINT32 taskInfo);
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡ÍøÂçÐźŸñÐÅÏ¢£¨Ò¢Ô¶cpe£©
+***********************************************************************************/
+SINT32 mmi_getLedNetSigInfo(UINT32 taskInfo, UINT32 outLedInfo);
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡WIFIµÆÐÅÏ¢
+***********************************************************************************/
+SINT32 mmi_getLedWifiInfo(UINT32 taskInfo, UINT32 outLedInfo);
+SINT32 mmi_getLcdWifiInfo(UINT32 taskInfo);
+SINT32 mmi_getLedWpsInfo(UINT32 taskInfo, UINT32 outLedInfo);
+
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡Á÷Á¿µÆÐÅÏ¢
+***********************************************************************************/
+SINT32 mmi_getLedTrafficInfo(UINT32 taskInfo, UINT32 outLedInfo);
+SINT32 mmi_getLcdTrafficInfo(UINT32 taskInfo);
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡ÒÆ¶¯ÔËÓªÉÌÁ÷Á¿ÐÅÏ¢
+***********************************************************************************/
+SINT32 mmi_getLcdQuotaTrafficInfo(UINT32 taskInfo);
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡µ±Ç°¹¤×÷ģʽ
+***********************************************************************************/
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡µç³ØµÆÐÅÏ¢
+***********************************************************************************/
+SINT32 mmi_getLedBatteryInfo(UINT32 taskInfo, UINT32 outLedInfo);
+SINT32 mmi_getLcdBatteryInfo(UINT32 taskInfo);
+SINT32 mmi_getLcdPowerInfo(UINT32 taskInfo);
+SINT32 mmi_getLcdTipInfo(UINT32 taskInfo);
+SINT32 mmi_getLcdPowerOffChagerInfo(UINT32 taskInfo);
+SINT32 mmi_getLedPowerOffChagerInfo(UINT32 taskInfo, UINT32 outLedInfo);
+
+
+SINT32 mmi_getFotaUpdateStateInfo(VOID);//»ñÈ¡FOTAÉý¼¶×´Ì¬ÐÅÏ¢
+SINT32 mmi_getLcdTipFotaInfo(UINT32 taskInfo);//FOTA
+SINT32 mmi_getLcdWifiStationInfo(UINT32 taskInfo);//wifistation
+SINT32 mmi_getLcdTipWpsInfo(UINT32 taskInfo);//wps
+SINT32 mmi_getLcdTipNetConnInfo(UINT32 taskInfo);//net connect
+
+SINT32 mmi_getLcdWifiCodeInfo(UINT32 taskInfo);//wifi¶þάÂë
+
+SINT32 mmi_getLcdSSIDKeyInfo(UINT32 taskInfo);
+SINT32 mmi_getLcdBasicDevInfo(UINT32 taskInfo);//SSID/WIFIKEY/IMSI/MSISDN
+SINT32 mmi_getLcdCurConInfo(UINT32 taskInfo);//±¾´ÎÁ¬½Óʱ¼ä£¬±¾´ÎÁ÷Á¿
+SINT32 mmi_getLcdTimeInfo(UINT32 taskInfo);//time
+
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡¿ª»ú20s¶¨Ê±Æ÷ÐÅÏ¢
+***********************************************************************************/
+BOOL mmi_getSSIDFirstShowInfo(VOID);
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡¿ª»ú¶¯»­ÊÇ·ñ½áÊøÐÅÏ¢
+***********************************************************************************/
+BOOL mmi_getShowingPowerOnInfo(VOID);
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡fotaÉý¼¶½á¹ûÏÔʾÊÇ·ñ½áÊøÐÅÏ¢
+***********************************************************************************/
+BOOL mmi_getShowingFotaResultInfo(VOID);
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡fotaа汾ÐÅÏ¢
+***********************************************************************************/
+BOOL mmi_getFotaNewVersionInfo(VOID);
+
+E_zMmi_Work_Mode mmi_get_lcd_mode(VOID);
+E_zMmi_Work_Mode mmi_get_led_mode(VOID);
+
+/**
+ * <mmi_sms_Led_Init>
+ * ¶ÌÐŵƳõʼ»¯
+ **/
+VOID mmi_sms_led_init(VOID);
+
+
+/**
+ * <mmi_wifi_Led_Init>
+ * Wifi µÆ³õʼ»¯
+ **/
+VOID mmi_wifi_led_init(VOID);
+
+
+/**
+ * <mmi_net_Led_Init>
+ * ÍøÂçµÆ³õʼ»¯
+ **/
+VOID mmi_net_led_init(VOID);
+
+
+/**
+ * <mmi_battery_Led_Init>
+ * µç³ØµÆ³õʼ»¯
+ **/
+VOID mmi_battery_led_init(VOID);
+
+
+
+/**
+ * <mmi_traffic_Led_Init>
+ * Á÷Á¿µÆ³õʼ»¯
+ **/
+VOID mmi_traffic_led_init(VOID);
+
+
+
+/**
+ * <mmi_keyStrokes_Init>
+ * °´¼ü³õʼ»¯
+ **/
+VOID mmi_keyStrokes_init(VOID);
+
+/**
+ * <mmi_recover_allleds>
+ *»½ÐÑ˯Ãß״̬ʱµãÁÁËùÓеÆ
+ **/
+VOID mmi_set_allleds_on(VOID);
+
+/**
+ * <mmi_init_idle_control>
+ *MMIÊ¡µç¿ØÖƳõʼ»¯
+ **/
+
+VOID mmi_init_idle_control(VOID);
+
+
+/**
+ * <mmi_reset_idle_timer>
+ *Ê¡µçÏà¹Ø¶¨Ê±Æ÷ÖØÖÃ
+ **/
+
+VOID mmi_reset_idle_timer(VOID);
+
+/**
+ * <mmi_reset_idle_timer>
+ *¿ìËÙ¿ª¹Ø»úʱʡµçÏà¹Ø¶¨Ê±Æ÷ÖØÖÃ
+ **/
+
+VOID mmi_reset_fast_poweron_idle_timer(VOID);
+
+/**
+ * <mmi_close_chg_handle>
+ * ¹Ø±Õ³äµçÉ豸¾ä±ú
+ **/
+VOID mmi_close_chg_handle(VOID);
+
+/**
+ * <mmi_close_chg_handle>
+ * ¹Ø±Õ°´¼üÉ豸¾ä±ú
+ **/
+VOID mmi_close_kpd_handle(VOID);
+
+/**
+ * <mmi_close_chg_handle>
+ * ¹Ø±ÕLED É豸¾ä±ú
+ **/
+VOID mmi_close_led_handle(VOID);
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:³õʼ»¯LEDÉ豸
+***********************************************************************************/
+VOID mmi_led_dev_init(VOID);
+
+/**
+ * <zMMI_Handle_Msg_Idle_ledon>
+ * ´¦ÀíÊ¡µç¿ªµÆÏûÏ¢
+ **/
+
+VOID zMMI_Handle_Msg_Idle_ledon(VOID);
+
+
+/**
+ * <mmi_set_allleds_blink>
+ * ¿ª»ú»ò¹Ø»úʱËùÓеÆÏÈ¿ªºó¹Ø
+ **/
+
+VOID mmi_set_allleds_blink(VOID);
+
+VOID mmi_traffictip_timer_stop(VOID);
+
+/**
+ * <mmi_kill_idle_timer>
+ *killÊ¡µçÏà¹Ø¶¨Ê±Æ÷
+ **/
+VOID mmi_kill_idle_timer(VOID);
+
+/**
+ * <mmi_kill_tip_timer>
+ *kill sim¿¨Ñ­»·¼ì²â¶¨Ê±Æ÷
+ **/
+VOID mmi_kill_tip_timer(VOID);
+
+/**
+ * <mmi_kill_traffic_timer>
+ *kill Á÷Á¿Ñ­»·¼ì²â¶¨Ê±Æ÷
+ **/
+VOID mmi_kill_traffic_timer(VOID);
+
+/**
+ * <mmi_kill_wifi_data_timer>
+ *kill wifiÊý¾Ý´«ÊäÑ­»·¼ì²â¶¨Ê±Æ÷
+ **/
+VOID mmi_kill_wifi_data_timer(VOID);
+
+/**
+ * <mmi_kill_get_voltage_timer>
+ *kill¶ÁÈ¡µçѹ¶¨Ê±Æ÷
+ **/
+
+VOID mmi_kill_get_voltage_timer(VOID);
+
+
+
+/**
+ * <mmi_create_get_batlev_thread>
+ * ´´½¨»ñÈ¡µç³ØµçÁ¿°Ù·Ö±ÈµÄÏß³Ì
+ **/
+VOID mmi_create_get_batlev_thread(VOID);
+/**
+ * <get_voltage_level_from_table>
+ * ´Óµç³Ø°Ù·Ö±È±íÖлñÈ¡µç³ØµçÁ¿°Ù·Ö±È
+ **/
+SINT32 get_voltage_level_from_table(SINT32 voltagepower);
+/**
+ * <mmi_voltage_state_read>
+ * ¶ÁÈ¡µçѹ
+ **/
+SINT32 mmi_voltage_state_read(VOID);
+SINT32 mmi_voltage_state_read_ex(VOID);
+SINT32 zMMI_Handle_Msg_Network_Mode(VOID *data);
+SINT32 zMMI_Handle_Msg_Connect_Status(VOID *data);
+SINT32 zMMI_Handle_Msg_MultiConnect_Status(VOID *data, int src_id);
+SINT32 zMMI_Handle_Msg_Signal_Num(VOID *data);
+SINT32 zMMI_Handle_Msg_Simcard_Info(VOID *data);
+SINT32 zMMI_Handle_Msg_Get_Wifi_StaNum(VOID *data);
+SINT32 zMMI_Handle_Msg_SmsBox_Sattus(VOID *data);
+SINT32 zMMI_Handle_Msg_Voip_Status(VOID *data);
+SINT32 zMMI_Handle_Msg_Rj11_Status(VOID * data);
+SINT32 zMMI_Handle_Msg_Rj45_Status(VOID * data);
+SINT32 zMMI_Handle_Msg_Get_SSID_Key(VOID *data);
+SINT32 zMMI_Handle_Msg_BacklightOff(VOID *data);
+SINT32 zMMI_Handle_Msg_Factory_Reset(VOID *data);
+SINT32 zMMI_Handle_Msg_Restart(VOID *data);
+SINT32 zMMI_Handle_Msg_Poweroff(VOID *data);
+SINT32 zMMI_Handle_Msg_Get_Provider(VOID *data);
+SINT32 zMMI_Handle_Msg_Get_TafficInfo_Start(VOID* data);
+SINT32 zMMI_Handle_Msg_Get_TafficInfo_End(VOID* data);
+SINT32 zMMI_Handle_Msg_TafficInfo_Reset(VOID* data);
+SINT32 zMMI_Handle_Msg_Check_Tip_Info(VOID *data);
+SINT32 zMMI_Handle_Msg_SSID_Show_Info(VOID *data);
+SINT32 zMMI_Handle_Msg_Get_Wifi_Data(VOID *data);
+SINT32 zMMI_Handle_Msg_Socket_Status(VOID *data, int src_id);
+SINT32 zMMI_Handle_Msg_MCUSocket_Status(VOID *data);
+
+SINT32	mmi_RegisterNetTaskInfoItem();
+SINT32	mmi_RegisterSmsTaskInfoItem();
+SINT32  mmi_RegisterVoipTaskInfoItem();
+SINT32 mmi_RegisterRj11TaskInfoItem();
+SINT32 mmi_RegisterRj45TaskInfoItem();
+
+SINT32 	mmi_RegisterBatteryTaskInfoItem();
+SINT32 	mmi_RegisterPowerTaskInfoItem();
+SINT32	mmi_RegisterCtrlTaskInfoItem();
+SINT32 	mmi_RegisterTimeTaskInfoItem();
+SINT32 	mmi_RegisterSSIDInfoTaskInfoItem();
+SINT32 	mmi_RegisterWifiTaskInfoItem();
+SINT32 mmi_RegisterWpsTaskInfoItem();
+
+SINT32 	mmi_RegisterWifiCodeTaskInfoItem();
+SINT32 	mmi_RegisterTrafficTaskInfoItem();
+SINT32 	mmi_RegisterQuotaTrafficInfoItem();
+SINT32 	mmi_RegisterTipTaskInfoItem();
+SINT32 	mmi_RegisterTipWifiStationConnectTaskInfoItem();
+SINT32 	mmi_RegisterTipWpsTaskInfoItem();
+SINT32 mmi_RegisterNetSigTaskInfoItem();
+SINT32 	mmi_RegisterTipFotaTaskInfoItem();
+SINT32  mmi_RegisterTipNetConnectTaskInfoItem();
+SINT32 	mmi_RegisterTipWifiStationConnectTaskInfoItem();
+void	mmi_net_init();
+void	mmi_sms_init();
+void    mmi_voip_init();
+void	mmi_init_idle_control();
+void	mmi_battery_init();
+void	mmi_init_lcd_tip();
+void	mmi_init_time();
+void	mmi_wifi_init();
+void	mmi_traffic_init();
+void	mmi_rj45_init();
+void	mmi_init_quota_traffic();
+VOID    mmi_play_poweroff_cartoon(E_zMmi_Work_Mode mode);
+VOID    mmi_set_fake_poweroff_charger(int fake_poweroff_flag);
+VOID    mmi_lowbattery_discharge_protect(UINT32 voltagepower);
+VOID    mmi_set_discharge_low_current(BOOL discharge_low_current_flag);
+VOID    mmi_handle_fast_poweroff(VOID);
+VOID    mmi_wifi_operate(char* mode);
+BOOL    mmi_get_usb_insert_state();
+E_zMmi_Charge_State     mmi_get_charge_state();
+VOID   mmi_handle_fast_poweron(VOID);
+VOID   mmi_set_discharge_switch(BOOL discharge_protect_flag);
+void mmi_log_save(const char *fmt, ...);
+VOID mmi_sleep(UINT32 time_in_ms);
+void mmi_add_list(struct list_head *head, int src_id);
+void mmi_del_list(struct list_head *head, int src_id);
+
+VOID mmi_clean_net_state();
+VOID mmi_set_wificode_show_flag(BOOL flag);
+E_zMMI_Lcd_Page_Index mmi_get_lcd_page_index(VOID);
+E_zMmi_Sim_Tip mmi_getSIMStateInfo(VOID);
+E_zMmi_NetCon_Tip mmi_getNetConInfo(VOID);
+E_zMmi_WpsAct_Tip mmi_get_wps_state();
+VOID mmi_set_poweroff_charge_show(BOOL show);
+#ifndef DISABLE_LCD
+SINT32 mmi_showLcd(HDC hdc);
+#endif
+VOID mmi_initLcdShowInfoTab();
+VOID mmi_handle_lcd_key_switch_page();
+VOID mmi_idle_timer_stop(VOID);
+VOID mmi_wps_operate(VOID);
+VOID mmi_changePowerOnOffFrame(VOID);
+VOID mmi_startLedTrafficWarnTimer(SINT32 time, SINT32 flag);
+VOID mmi_stopLedTrafficWarnTimer();
+VOID mmi_poweroffcharger_init();
+UINT32 mmi_get_net_state(VOID);
+/**º¯Êý×÷ÓÃ:×Ô¶¯»¯²âÊÔÄ£Äâ°´¼ü**/
+SINT32 zMMI_Handle_Msg_Atest_Key(VOID *data);
+SINT32 zMMI_Handle_Msg_Atest_Chg(VOID *data);
+
+
+
+
+
+#endif //__MMI_COMMON_H
diff --git a/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_keystrokes.c b/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_keystrokes.c
new file mode 100755
index 0000000..1bb015c
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_keystrokes.c
@@ -0,0 +1,460 @@
+/*****************************************************************************
+*  °æ±¾ËùÓÐ (C)ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾
+*  Ä£¿éÃû    £ºMMI
+*  ÎļþÃû    £ºmmi_keystokes.c
+*  Îļþ±êʶ  £º
+*  Ïà¹ØÎļþ  £º
+*  ʵÏÖ¹¦ÄÜ  £ºMMI°´¼ü²Ù×÷
+*  ×÷            Õß  £º
+*  °æ            ±¾  £ºV1.0
+*  Íê³ÉÈÕÆÚ  £º2014-6-20
+*  ÆäËü˵Ã÷  £º
+*
+*******************************************************************************/
+/*****************************************************************************
+                         Í·Îļþ
+******************************************************************************/
+#include <fcntl.h>
+#include <sys/syscall.h>
+#include <linux/reboot.h>
+#include <linux/input.h>
+#include "mmi_common.h"
+#include "mmi_lcd.h"
+
+extern int g_customer_type;
+
+/************************************************************************************
+                            È«¾Ö±äÁ¿¶¨Òå
+***********************************************************************************/
+static int g_mmi_kpd_handle = -1;//»ñÈ¡¼üÅÌÉ豸¾ä±ú
+static BOOL g_longPressFlag = FALSE;//±ê¼ÇÊÇ·ñ³¤°´
+static BOOL g_key_wakeup_flag = FALSE;//±êʾMMIÐÝÃßʱ°´¼ü Ö»»½ÐÑµÆ £¬ÆäËû¹¦Äܲ»ÏìÓ¦
+static long s_mmi_keypress_begin = 0;//°´¼ü°´Ïºó¿ªÊ¼¼ÆÊ±
+BOOL g_mmi_key_longpress_flag = FALSE;//±ê¼ÇÊÇ·ñΪmmi³¤°´power¼ü·¢ÆðµÄ¹Ø»ú
+extern E_zMmiShowMode g_showMode;
+extern UINT32 g_fast_poweron;
+static int g_mmi_kpd_longpress_time = 3;//³¤°´¼üÅжÏʱ¼äS
+static int g_mmi_wifi_longpress_time = 5;//³¤°´wifi¼üÅжÏʱ¼äS, Ò¢Ô¶cpe
+
+BOOL mmi_get_wakeup_flag(VOID);
+/**********************************************************************************
+º¯Êý×÷ÓÃ:»ñÈ¡°´¼üʱ¼ä
+***********************************************************************************/
+static long mmi_get_keypress_time()
+{
+	struct timeval tv;
+	long second;
+	gettimeofday(&tv, NULL);
+	second = tv.tv_sec;
+	return second;
+}
+
+
+/************************************************************************************
+ º¯Êý×÷ÓÃ:¶ÁÈ¡°´¼üÐÅÏ¢
+***********************************************************************************/
+static VOID mmi_get_keystrokes_data(MMI_KP_INFO *kp_info)
+{
+
+	int retR = -1;
+	struct input_event kp_event = {0};
+
+	retR = read(g_mmi_kpd_handle, (CHAR *)(&kp_event), sizeof(kp_event));
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI  Key's type:%d, value:%d, code:%d\n", kp_event.type, kp_event.value, kp_event.code);
+	if (retR < 0) {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI get_keystrokes_data read falied k-err:%d!",errno);
+		return;
+	}
+
+	if (kp_event.type == 1) {
+		if (kp_event.value == 1) {
+			set_wake_lock(MMI_MAIN_LOCK_ID);
+			kp_info->status = KEY_STATUS_DOWN;
+			s_mmi_keypress_begin = mmi_get_keypress_time();
+			if (kp_event.code == KEY_WIFI_CODE) {
+				if (mmi_get_wifi_state()) {
+					g_mmi_wifi_longpress_time = 5;
+				} else {
+					g_mmi_wifi_longpress_time = 1;
+				}
+			}
+		} else if (kp_event.value == 0) {
+			kp_info->status = KEY_STATUS_UP;
+			s_mmi_keypress_begin = 0;
+		} else if (kp_event.value == 2) {
+			long sec_end = mmi_get_keypress_time();
+			int sec_lingpress = (int)(sec_end - s_mmi_keypress_begin);
+			if (kp_event.code == KEY_WIFI_CODE) {
+				if (sec_lingpress >= g_mmi_wifi_longpress_time) {
+					kp_info->status = KEY_STATUS_LONGPRESS;
+				}
+			}
+			else {
+				if (sec_lingpress >= g_mmi_kpd_longpress_time) {
+					kp_info->status = KEY_STATUS_LONGPRESS;
+				}
+			}
+		}
+		if (kp_event.code == KEY_POWER_CODE) {
+			kp_info->type = KEY_TYPE_POWER;
+		} else if (kp_event.code == KEY_RESET_CODE) {
+			kp_info->type = KEY_TYPE_RESET;
+		} else if (kp_event.code == KEY_WPS_CODE) {
+			kp_info->type = KEY_TYPE_WPS;
+		} else if (kp_event.code == KEY_WIFI_CODE) {
+			kp_info->type = KEY_TYPE_WIFI;
+		}
+	} else {
+		kp_info->status = (KEY_STATUS)0;
+		return;
+	}
+
+}
+
+/***********************************************************************************
+   º¯Êý×÷ÓÃ:°´¼ü»½ÐÑwifi
+***********************************************************************************/
+static VOID mmi_wakeup_wifi(int key_type)
+{
+	if (key_type == KEY_TYPE_WPS || key_type == KEY_TYPE_RESET) {
+		if (!mmi_get_wifi_state()) {
+			if (g_fast_poweron) {
+				if (mmi_get_lcd_mode() != MMI_FAKE_POWEROFF_MODE && mmi_get_lcd_mode() != MMI_FAKE_POWEROFF_CHARGE_MODE
+				    && mmi_get_led_mode() != MMI_FAKE_POWEROFF_MODE && mmi_get_led_mode() != MMI_FAKE_POWEROFF_CHARGE_MODE) {
+					mmi_wifi_operate(WIFI_TURN_ON);
+				}
+			} else
+				mmi_wifi_operate(WIFI_TURN_ON);
+		}
+	}
+	if (key_type == KEY_TYPE_POWER) { //LCDģʽÏÂ×¢ÒâÃðÆÁºÍ»½ÐÑ£¬LEDģʽÏÂûÓÐÃðµÆ²Ù×÷
+		if (g_showMode == MMI_MODE_LCD || g_showMode == MMI_MODE_ALL) {
+			if ((mmi_get_lcd_mode() == MMI_ACTIVE_MODE || mmi_get_led_mode() == MMI_ACTIVE_MODE) && mmi_get_wakeup_flag()) {
+				mmi_wifi_operate(WIFI_TURN_ON);
+			}
+		} else {
+			if ((mmi_get_lcd_mode() == MMI_ACTIVE_MODE || mmi_get_led_mode() == MMI_ACTIVE_MODE) && !mmi_get_wifi_state()) {
+				mmi_wifi_operate(WIFI_TURN_ON);
+			}
+		}
+	}
+}
+/***********************************************************************************
+   º¯Êý×÷ÓÃ:ÉèÖð´¼ü»½Ðѱêʶ
+***********************************************************************************/
+VOID mmi_set_wakeup_flag(BOOL flag)
+{
+	if(g_customer_type == CUSTOMER_NANDIAN){//¹úµçûÓÐlcd led£¬°´¼ü²»ÐèÒª»½Ðѹ¦ÄÜ
+		g_key_wakeup_flag = FALSE;
+	}else{
+		g_key_wakeup_flag = flag;
+	}
+}
+
+/***********************************************************************************
+   º¯Êý×÷ÓÃ:·µ»Ø°´¼ü»½Ðѱêʶ
+***********************************************************************************/
+BOOL mmi_get_wakeup_flag(VOID)
+{
+	return g_key_wakeup_flag;
+}
+
+/***********************************************************************************
+   º¯Êý×÷ÓÃ:ÉèÖð´¼ü³¤°´±êʶ
+***********************************************************************************/
+VOID mmi_set_longpress_flag(BOOL flag)
+{
+	g_longPressFlag = flag;
+}
+
+/***********************************************************************************
+   º¯Êý×÷ÓÃ:·µ»Ø°´¼ü³¤°´±êʶ
+***********************************************************************************/
+BOOL mmi_get_longpress_flag(VOID)
+{
+	return g_longPressFlag;
+}
+
+/***********************************************************************************
+   º¯Êý×÷ÓÃ:°´¼ü»½ÐÑLED/LCD ²¢ÉèÖû½Ðѱê־λ
+***********************************************************************************/
+static VOID mmi_set_active_mode_key()
+{
+	if (g_showMode == MMI_MODE_LCD || g_showMode == MMI_MODE_ALL) {
+		E_zMmi_Work_Mode lcd_mode = mmi_get_lcd_mode();
+		if (lcd_mode == MMI_BACKLIGHT_OFF_MODE || lcd_mode == MMI_BACKLIGHT_HALFBRIGHT_MODE) {
+			mmi_set_wakeup_flag(TRUE);
+		} else {
+			if (g_fast_poweron) {
+				if (lcd_mode == MMI_FAKE_POWEROFF_MODE && (mmi_get_charge_state() == STATE_CHARGING || mmi_get_charge_state() == STATE_FULL)) {
+					mmi_set_lcd_mode(MMI_FAKE_POWEROFF_CHARGE_MODE);
+					mmi_set_update_flag(MMI_TASK_CTRL);
+					mmi_set_wakeup_flag(TRUE);
+				}
+			}
+		}
+	}
+
+	if (g_showMode == MMI_MODE_LED || g_showMode == MMI_MODE_ALL) {
+		E_zMmi_Work_Mode led_mode = mmi_get_led_mode();
+		if (led_mode == MMI_IDLE_LEDOFF_MODE || led_mode == MMI_IDLE_STANDBY_LEDOFF_MODE || led_mode == MMI_IDLE_CHG_LEDOFF_MODE) {
+			mmi_set_wakeup_flag(TRUE);
+		}
+	}
+	mmi_set_mode_active();
+}
+
+
+/***********************************************************************************
+   º¯Êý×÷ÓÃ:down°´¼üÏûÏ¢´¦Àí
+***********************************************************************************/
+static VOID mmi_handle_keystroke_down()
+{
+	BOOL long_press = mmi_get_longpress_flag();
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI  KEYDOWN  long_press=%d!!!\n ", long_press);
+	if (FALSE == long_press) {
+		// ÖØÖö¨Ê±Æ÷
+		if (g_fast_poweron && (mmi_get_charge_state() == STATE_DISCHARGE) && ((mmi_get_lcd_mode() == MMI_FAKE_POWEROFF_MODE) || (mmi_get_led_mode() == MMI_FAKE_POWEROFF_MODE))) {
+			mmi_reset_fast_poweron_idle_timer();
+		} else {
+			mmi_reset_idle_timer();
+		}
+
+		mmi_set_active_mode_key();
+		
+		if (mmi_get_wifi_state()) {
+			//mmi_send_message(MODULE_ID_WIFI, (USHORT)MSG_CMD_WIFI_RESET_TIMER, 0, NULL);
+
+			ipc_send_message(MODULE_ID_MMI, MODULE_ID_WIFI, MSG_CMD_WIFI_RESET_TIMER, 0, NULL, 0);
+		}
+	}
+}
+
+/***********************************************************************************
+   º¯Êý×÷ÓÃ:up°´¼üÏûÏ¢´¦Àí
+***********************************************************************************/
+static VOID mmi_handle_keystroke_up(int key_type)
+{
+	BOOL longPress = mmi_get_longpress_flag();
+	BOOL key_wakeup = mmi_get_wakeup_flag();
+
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI  KEYUP KEYUP !!! longPress=%d key_wakeup=%d\n", longPress, key_wakeup);
+	mmi_wakeup_wifi(key_type);
+#ifndef DISABLE_LCD
+	if (FALSE == longPress && (g_showMode == MMI_MODE_LCD || g_showMode == MMI_MODE_ALL)) {
+		if (key_type == KEY_TYPE_WPS) {
+			if (mmi_get_lcd_mode() == MMI_ACTIVE_MODE && key_wakeup == FALSE && mmi_getSSIDFirstShowInfo() == FALSE) {
+				mmi_handle_lcd_key_switch_page();
+			}
+		} else if (key_type == KEY_TYPE_POWER && mmi_getShowingPowerOnInfo() == FALSE) {
+			if (mmi_get_lcd_mode() == MMI_ACTIVE_MODE && key_wakeup == FALSE) {
+				slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI  mmi_handle_keystroke_up ssssss");
+				mmi_idle_timer_stop();
+				mmi_set_lcd_mode(MMI_BACKLIGHT_OFF_MODE);
+				mmi_set_update_flag(MMI_TASK_CTRL);
+
+			}
+		}
+	}
+#endif
+	if (TRUE == longPress) {
+		mmi_set_longpress_flag(FALSE); //±ê¼Ç³¤°´½áÊø
+	}
+	if (TRUE == key_wakeup) {
+		mmi_set_wakeup_flag(FALSE);
+	}
+}
+
+/***********************************************************************************
+   º¯Êý×÷Óó¤°´¼üÏûÏ¢´¦Àí
+***********************************************************************************/
+static VOID mmi_handle_keystroke_longpress(int key_type)
+{
+	BOOL longPress = mmi_get_longpress_flag();
+	BOOL key_wakeup = mmi_get_wakeup_flag();
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI  mmi_handle_keystroke_longpress  longPress=%d key_wakeup=%d\n", longPress, key_wakeup);
+	if ((FALSE == longPress) && (FALSE == key_wakeup)) {
+		slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI KEYLONGPRESS!KEYLONGPRESS!\n");
+		mmi_set_longpress_flag(TRUE);
+		if (key_type == KEY_TYPE_POWER) {
+			slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI handleKey ######KEY_POWER LONGPRESS######\n\n");
+
+			if (g_fast_poweron) {
+				if (mmi_get_lcd_mode() == MMI_FAKE_POWEROFF_MODE || mmi_get_lcd_mode() == MMI_FAKE_POWEROFF_CHARGE_MODE
+				    || mmi_get_led_mode() == MMI_FAKE_POWEROFF_MODE || mmi_get_led_mode() == MMI_FAKE_POWEROFF_CHARGE_MODE) {
+					g_mmi_key_longpress_flag = FALSE;
+					mmi_handle_fast_poweron();
+				} else {
+					g_mmi_key_longpress_flag = TRUE;
+
+					slog(MMI_PRINT, SLOG_NORMAL, "ZTE_MMI poweroff,longpress!!!\n");
+					mmi_set_poweroff();
+				}
+			} else {
+				slog(MMI_PRINT, SLOG_NORMAL, "ZTE_MMI poweroff,longpress!!!\n");
+				mmi_set_poweroff();
+			}
+		} else if (key_type == KEY_TYPE_RESET) {
+			slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI handleKey ######KEY_RESET LONGPRESS######\n\n");
+			if (mmi_get_lcd_mode() == MMI_FAKE_POWEROFF_CHARGE_MODE || mmi_get_lcd_mode() == MMI_FAKE_POWEROFF_MODE
+			    || mmi_get_led_mode() == MMI_FAKE_POWEROFF_CHARGE_MODE || mmi_get_led_mode() == MMI_FAKE_POWEROFF_MODE) {
+				return;//break;
+			}
+			mmi_set_factory_reset();
+		} else if ((key_type == KEY_TYPE_WPS)) {
+			slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI handleKey ######KEY_WPS LONGPRESS######\n");
+			if (mmi_get_wifi_state()) {
+				mmi_wps_operate();
+			}
+		} else if ((key_type == KEY_TYPE_WIFI)) {
+			slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI handleKey ######KEY_WIFI LONGPRESS######\n");
+			if (mmi_get_wifi_state()) {
+				mmi_wifi_operate(WIFI_TURN_OFF);
+			} else {
+				mmi_wifi_operate(WIFI_TURN_ON);
+			}
+		} else {
+			slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI invalid operation!!\n");
+		}
+	}
+}
+
+void mmi_handle_keystroke(MMI_KP_INFO* keyData,BOOL* key_pressed)
+{
+	const char *buttonStr = NULL;  
+
+    if (keyData->type == KEY_TYPE_WPS)
+	{
+		buttonStr = "+BUTTON: WPS\r\n";
+	} 
+	else if (keyData->type == KEY_TYPE_RESET)
+	{
+		buttonStr = "+BUTTON: RESET\r\n";
+	}
+	else
+		return;
+
+
+	if (keyData->status == KEY_STATUS_DOWN)
+	{
+		key_pressed = TRUE;
+	}
+	else if (keyData->status == KEY_STATUS_UP && key_pressed)
+	{
+		send_rsp_str_to_farps(MODULE_ID_MMI, buttonStr, strlen(buttonStr));
+		key_pressed = FALSE;
+	}
+	else
+		return;
+}
+
+/***********************************************************************************
+   º¯Êý×÷ÓÃ:´¦Àí°´¼ü
+***********************************************************************************/
+VOID *mmi_handle_keystrokes_thread(VOID *arg)
+{
+	MMI_KP_INFO keyData = {0};
+	BOOL key_pressed = FALSE;
+
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI handleKey handle_keystrokes_thread begin !!\n ");
+	prctl(PR_SET_NAME, "mmihandlekey", 0, 0, 0);
+	while (1) {
+		mmi_get_keystrokes_data(&keyData);
+		mmi_handle_keystroke(&keyData, &key_pressed);
+		switch (keyData.status) {
+		case KEY_STATUS_DOWN: {
+			mmi_handle_keystroke_down();
+			break;
+		}
+
+		case KEY_STATUS_UP: {
+			mmi_handle_keystroke_up(keyData.type);
+			break;
+		}
+		case KEY_STATUS_LONGPRESS: {
+			mmi_handle_keystroke_longpress(keyData.type);
+			break;
+		}
+		default: {
+			break;
+		}
+		}
+	}
+
+}
+#if 0
+/***********************************************************************************
+   º¯Êý×÷ÓÃ:×Ô¶¯»¯²âÊÔÄ£Äâ°´¼ü£¬Õý³£¿ª»ú
+***********************************************************************************/
+SINT32 zMMI_Handle_Msg_Atest_Key(VOID *data)
+{
+	//value:°´¼üʼþ code:°´¼ü¼üÖµ
+	autotest_key_rspmsg *kp_event = (autotest_key_rspmsg *)data;
+	MMI_KP_INFO keyData = {0};
+
+	if (kp_event->value == 1) {
+		set_wake_lock(MMI_MAIN_LOCK_ID);
+		keyData.status = KEY_STATUS_DOWN;
+		s_mmi_keypress_begin = mmi_get_keypress_time();
+	} else if (kp_event->value == 0) {
+		keyData.status = KEY_STATUS_UP;
+		s_mmi_keypress_begin = 0;
+	} else if (kp_event->value == 2) {
+		long sec_end = mmi_get_keypress_time();
+		int sec_lingpress = (int)(sec_end - s_mmi_keypress_begin);
+		if (sec_lingpress >= g_mmi_kpd_longpress_time) {
+			keyData.status = KEY_STATUS_LONGPRESS;
+		}
+	}
+	
+	if (kp_event->code == KEY_POWER_CODE) {
+		keyData.type = KEY_TYPE_POWER;
+	} else if (kp_event->code == KEY_RESET_CODE) {
+		keyData.type = KEY_TYPE_RESET;
+	} else if (kp_event->code == KEY_WPS_CODE) {
+		keyData.type = KEY_TYPE_WPS;
+	}
+
+	switch (keyData.status) {
+		case KEY_STATUS_DOWN: {
+			mmi_handle_keystroke_down();
+			break;
+		}
+		case KEY_STATUS_UP: {
+			mmi_handle_keystroke_up(keyData.type);
+			break;
+		}
+		case KEY_STATUS_LONGPRESS: {
+			mmi_handle_keystroke_longpress(keyData.type);
+			break;
+		}
+		default: {
+			break;
+		}
+	}
+	return 0;
+}
+#endif
+
+/************************************************************************************
+ º¯Êý×÷ÓÃ:°´¼ü³õʼ»¯
+***********************************************************************************/
+VOID mmi_keyStrokes_init(VOID)
+{
+	pthread_t  mmi_handlekey_thread;
+	/*´´½¨µÆ¿ØÖÆflagÐźÅÁ¿*/
+	g_mmi_kpd_handle = open(KPD_PATH, O_RDONLY);
+	if (g_mmi_kpd_handle == -1) {
+		slog(MMI_PRINT, SLOG_ERR, "handleKey Couldn't open kp /dev/event0\n");
+		return;//MMI_ASSERT(0);
+	}
+	if(g_customer_type == CUSTOMER_GUODIAN || g_customer_type == CUSTOMER_NANDIAN){
+		g_mmi_kpd_longpress_time = 1;//1s
+	}
+	if (pthread_create(&mmi_handlekey_thread, NULL, &mmi_handle_keystrokes_thread, NULL) == -1) {
+		slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI create handle_keystrokes_thread error\n");
+		return ;
+	}
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_keyStrokes_Init finish!!\n");
+}
+
diff --git a/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_led.c b/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_led.c
new file mode 100755
index 0000000..7b7e99b
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_led.c
@@ -0,0 +1,882 @@
+/*****************************************************************************
+*  °æ±¾ËùÓÐ (C)ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾
+*  Ä£¿éÃû    £ºMMI
+*  ÎļþÃû    £ºmmi_led.c
+*  Îļþ±êʶ  £º
+*  Ïà¹ØÎļþ  £º
+*  ʵÏÖ¹¦ÄÜ  £º
+*  ×÷Õß      £º
+*  °æ±¾      £ºV1.0
+*  Íê³ÉÈÕÆÚ  £º2014-6-20
+*  ÆäËü˵Ã÷  £º
+*
+*******************************************************************************/
+#include "mmi_common.h"
+
+/********************************************************************************
+  È«¾Ö±äÁ¿ÒýÓÃ
+**********************************************************************************/
+extern UINT32 g_smstask_enable;
+extern UINT32 g_voicetask_enable;
+extern UINT32 g_led_sleep_mode;
+
+/*****************************************************************************
+ È«¾Ö±äÁ¿¶¨Òå
+******************************************************************************/
+MMI_LED_STATE s_mmi_batled_laststate = LED_STATE_MAX;//±ê¼Çµç³ØµÆµÄÉÏÒ»´Î״̬
+MMI_LED_STATE s_mmi_wanled_laststate = LED_STATE_MAX;//±ê¼ÇÍøÂçµÆµÄÉÏÒ»´Î״̬
+MMI_LED_STATE s_mmi_lanled_laststate = LED_STATE_MAX;//±ê¼ÇwifiµÆµÄÉÏÒ»´Î״̬
+MMI_LED_STATE s_mmi_smsled_laststate = LED_STATE_MAX;//±ê¼Ç¶ÌÐŵƵÄÉÏÒ»´Î״̬
+MMI_LED_STATE s_mmi_traled_laststate = LED_STATE_MAX;//±ê¼ÇÁ÷Á¿µÆµÄÉÏÒ»´Î״̬
+MMI_LED_STATE s_mmi_voiled_laststate = LED_STATE_MAX;//±ê¼ÇÓïÒôµÆµÄÉÏÒ»´Î״̬
+
+extern POWER_ON_OFF_CALLBACK_FUN g_PowerOnOffFun;
+extern T_zMmiSmsLedConfig g_mmi_smsled_config_tab[];
+extern T_zMmiWifiLedConfig g_mmi_wifiled_config_tab[];
+extern T_zMmiNetLedConfig g_mmi_netled_config_tab[];
+extern T_zMmiBatteryLedConfig g_mmi_batled_config_tab[];
+extern T_zMmiVoipLedConfig g_mmi_voipled_config_tab[];
+extern T_zMmiNetLedConfig g_mmi_signalled_config_tab[];
+extern T_zMmiWifiLedConfig g_mmi_wpsled_config_tab[];
+extern T_zMmiRj11LedConfig g_mmi_rj11led_config_tab[];
+extern T_zMmiRj45LedConfig g_mmi_rj45led_config_tab[];
+
+
+extern sem_t g_mmi_traffic_warn_sem_id;
+BOOL s_mmi_trafficled_warn_flag = FALSE;//±ê¼ÇÁ÷Á¿¸æ¾¯µÆÊÇ·ñÕýÔÚË«ÉÁÖÐ
+extern int g_customer_type;
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:LEDµÆ²Ù×÷
+***********************************************************************************/
+static VOID mmi_led_operate_blink_off(T_zMmi_Led_Info*  userInfo)
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_led_operate name= %d\n", userInfo->led_name);
+	T_zMmi_Led_Info tmpInfo = {0};
+	memcpy((VOID *)(&tmpInfo), (const VOID *)userInfo, sizeof(T_zMmi_Led_Info));
+	tmpInfo.led_state = LED_STATE_OFF;
+	tmpInfo.led_color = userInfo->led_color;
+	mmi_led_operate(&tmpInfo);
+
+}
+
+static VOID mmi_led_operate_set_blinktime(T_zMmi_Led_Blink_Time *blink_time, MMI_LED_BLINK_SPEED speed)
+{
+	switch (speed) {
+	case LED_STATE_FAST_BLINK: {
+		blink_time->uBlinkOnTime = LED_FAST_BLINK_ON_TIME;
+		blink_time->uBlinkOffTime = LED_FAST_BLINK_OFF_TIME;
+		break;
+	}
+	case LED_STATE_SLOW_BLINK: {
+		blink_time->uBlinkOnTime = LED_SLOW_BLINK_ON_TIME;
+		blink_time->uBlinkOffTime = LED_SLOW_BLINK_OFF_TIME;
+		break;
+	}
+	case LED_STATE_BAT_BLINK: {
+		blink_time->uBlinkOnTime = LED_BAT_BLINK_ON_TIME;
+		blink_time->uBlinkOffTime = LED_BAT_BLINK_OFF_TIME;
+		break;
+	}
+	case LED_STATE_LAN_BLINK: {
+		blink_time->uBlinkOnTime = LED_LAN_BLINK_ON_TIME;
+		blink_time->uBlinkOffTime = LED_LAN_BLINK_OFF_TIME;
+		break;
+	}
+	case LED_STATE_SMS_BLINK: {
+		blink_time->uBlinkOnTime = LED_SMS_BLINK_ON_TIME;
+		blink_time->uBlinkOffTime = LED_SMS_BLINK_OFF_TIME;
+		break;
+	}
+	case LED_STATE_WAN_BLINK: {
+		blink_time->uBlinkOnTime = LED_WAN_BLINK_ON_TIME;
+		blink_time->uBlinkOffTime = LED_WAN_BLINK_OFF_TIME;
+		break;
+	}
+	case LED_STATE_VOIP_BLINK: {
+		blink_time->uBlinkOnTime = LED_VOIP_BLINK_ON_TIME;
+		blink_time->uBlinkOffTime = LED_VOIP_BLINK_OFF_TIME;
+		break;
+	}
+	case LED_STATE_WAN_FAST_BLINK: {
+		blink_time->uBlinkOnTime = LED_WAN_FAST_BLINK_ON_TIME;
+		blink_time->uBlinkOffTime = LED_WAN_FAST_BLINK_OFF_TIME;
+		break;
+	}
+	case LED_STATE_WAN_SLOW_BLINK: {
+		blink_time->uBlinkOnTime = LED_WAN_SLOW_BLINK_ON_TIME;
+		blink_time->uBlinkOffTime = LED_WAN_SLOW_BLINK_OFF_TIME;
+		break;
+	}
+	//yaoyuan cpe
+	case LED_STATE_WAN_CPE_FAST_BLINK: {
+		blink_time->uBlinkOnTime = LED_WAN_CPE_FAST_BLINK_ON_TIME;
+		blink_time->uBlinkOffTime = LED_WAN_CPE_FAST_BLINK_OFF_TIME;
+		break;
+	}
+	case LED_STATE_WAN_CPE_SLOW_BLINK: {
+		blink_time->uBlinkOnTime = LED_WAN_CPE_SLOW_BLINK_ON_TIME;
+		blink_time->uBlinkOffTime = LED_WAN_CPE_SLOW_BLINK_OFF_TIME;
+		break;
+	}
+	default: {
+		break;
+	}
+	}
+}
+
+static VOID mmi_set_led_laststate(T_zMmi_Led_Info*  userInfo)
+{
+	switch (userInfo->led_name) {
+	case LED_BATTERY: {
+		if (userInfo->led_state == LED_STATE_BLINK) {
+			s_mmi_batled_laststate = LED_STATE_BLINK;
+		} else if (userInfo->led_state == LED_STATE_ON && s_mmi_batled_laststate == LED_STATE_BLINK) {
+			mmi_led_operate_blink_off(userInfo);
+			s_mmi_batled_laststate = LED_STATE_MAX;
+		} else {
+			s_mmi_batled_laststate = LED_STATE_MAX;
+		}
+		break;
+	}
+	case LED_WAN: {
+		if (userInfo->led_state == LED_STATE_BLINK) {
+			s_mmi_wanled_laststate = LED_STATE_BLINK;
+		} else if (userInfo->led_state == LED_STATE_ON && s_mmi_wanled_laststate == LED_STATE_BLINK) {
+			mmi_led_operate_blink_off(userInfo);
+			s_mmi_wanled_laststate = LED_STATE_MAX;
+		} else {
+			s_mmi_wanled_laststate = LED_STATE_MAX;
+		}
+		break;
+	}
+	case LED_LAN: {
+		if (userInfo->led_state == LED_STATE_BLINK) {
+			s_mmi_lanled_laststate = LED_STATE_BLINK;
+		} else if (userInfo->led_state == LED_STATE_ON && s_mmi_lanled_laststate == LED_STATE_BLINK) {
+			mmi_led_operate_blink_off(userInfo);
+			s_mmi_lanled_laststate = LED_STATE_MAX;
+		} else {
+			s_mmi_lanled_laststate = LED_STATE_MAX;
+		}
+		break;
+	}
+	case LED_SMS: {
+		if (userInfo->led_state == LED_STATE_BLINK) {
+			s_mmi_smsled_laststate = LED_STATE_BLINK;
+		} else if (userInfo->led_state == LED_STATE_ON && s_mmi_smsled_laststate == LED_STATE_BLINK) {
+			mmi_led_operate_blink_off(userInfo);
+			s_mmi_smsled_laststate = LED_STATE_MAX;
+		} else {
+			s_mmi_smsled_laststate = LED_STATE_MAX;
+		}
+		break;
+	}
+	case LED_TRAFFIC: {
+		if (userInfo->led_state == LED_STATE_BLINK) {
+			s_mmi_traled_laststate = LED_STATE_BLINK;
+		} else if (userInfo->led_state == LED_STATE_ON && s_mmi_traled_laststate == LED_STATE_BLINK) {
+			mmi_led_operate_blink_off(userInfo);
+			s_mmi_traled_laststate = LED_STATE_MAX;
+		} else {
+			s_mmi_traled_laststate = LED_STATE_MAX;
+		}
+		break;
+	}
+	case LED_VOIP: {
+		if (userInfo->led_state == LED_STATE_BLINK) {
+			s_mmi_voiled_laststate = LED_STATE_BLINK;
+		} else if (userInfo->led_state == LED_STATE_ON && s_mmi_voiled_laststate == LED_STATE_BLINK) {
+			mmi_led_operate_blink_off(userInfo);
+			s_mmi_voiled_laststate = LED_STATE_MAX;
+		} else {
+			s_mmi_voiled_laststate = LED_STATE_MAX;
+		}
+		break;
+	}
+#if 0
+	//yao yuan
+	case LED_SIGNAL: {
+		if (userInfo->led_state == LED_STATE_BLINK) {
+			s_mmi_sigled_laststate = LED_STATE_BLINK;
+		} else if (userInfo->led_state == LED_STATE_ON && s_mmi_voiled_laststate == LED_STATE_BLINK) {
+			mmi_led_operate_blink_off(userInfo);
+			s_mmi_sigled_laststate = LED_STATE_MAX;
+		} else {
+			s_mmi_sigled_laststate = LED_STATE_MAX;
+		}
+		break;
+	}
+	case LED_WPS: {
+		if (userInfo->led_state == LED_STATE_BLINK) {
+			s_mmi_wpsled_laststate = LED_STATE_BLINK;
+		} else if (userInfo->led_state == LED_STATE_ON && s_mmi_voiled_laststate == LED_STATE_BLINK) {
+			mmi_led_operate_blink_off(userInfo);
+			s_mmi_wpsled_laststate = LED_STATE_MAX;
+		} else {
+			s_mmi_wpsled_laststate = LED_STATE_MAX;
+		}
+		break;
+	}
+	case LED_RJ11: {
+		if (userInfo->led_state == LED_STATE_BLINK) {
+			s_mmi_rj11led_laststate = LED_STATE_BLINK;
+		} else if (userInfo->led_state == LED_STATE_ON && s_mmi_voiled_laststate == LED_STATE_BLINK) {
+			mmi_led_operate_blink_off(userInfo);
+			s_mmi_rj11led_laststate = LED_STATE_MAX;
+		} else {
+			s_mmi_rj11led_laststate = LED_STATE_MAX;
+		}
+		break;
+	}
+	case LED_RJ45: {
+		if (userInfo->led_state == LED_STATE_BLINK) {
+			s_mmi_rj45led_laststate = LED_STATE_BLINK;
+		} else if (userInfo->led_state == LED_STATE_ON && s_mmi_rj45led_laststate == LED_STATE_BLINK) {
+			mmi_led_operate_blink_off(userInfo);
+			s_mmi_rj45led_laststate = LED_STATE_MAX;
+		} else {
+			s_mmi_rj45led_laststate = LED_STATE_MAX;
+		}
+		break;
+	}
+#endif	
+	default: {
+		break;
+	}
+	}
+}
+
+SINT32 mmi_showLed(UINT32 ledInfo)
+{
+	T_zMmi_Led_Info *led_info = (T_zMmi_Led_Info *)ledInfo;
+	T_zMmi_Led_Blink_Time blink_time = {0};
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_showLed name= %d ,state = %d, color=%d !\n", led_info->led_name, led_info->led_state, led_info->led_color);
+
+	mmi_set_led_laststate(led_info);
+	if (led_info->led_state == LED_STATE_BLINK) {
+		mmi_led_operate_set_blinktime(&blink_time, led_info->ledBlink_speed);
+		led_info->ledBlink_time = blink_time;
+	}
+	if (led_info->led_name == LED_TRAFFIC && s_mmi_traled_laststate == LED_STATE_BLINK && led_info->led_state == LED_STATE_OFF) {
+		mmi_led_operate(led_info);//Á÷Á¿µÆÉÏÒ»¸ö״̬ʱÉÁ˸£¬ÐèÒª¹ØÁ½´Î²ÅÄܹصô
+	}
+	mmi_led_operate(led_info);
+	return 0;
+}
+
+static VOID mmi_setLedShowInfo(T_zMmi_Led_Info* outLedInfo, T_zMmi_Led_Info inLedInfo)
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_setLedShowInfo inLedInfo name:%d,state:%d,color:%d\n", inLedInfo.led_name, inLedInfo.led_state, inLedInfo.led_color);
+	outLedInfo->led_name = inLedInfo.led_name;
+	outLedInfo->led_color = inLedInfo.led_color;
+	outLedInfo->traffic = inLedInfo.traffic;
+	outLedInfo->led_state = inLedInfo.led_state;
+	outLedInfo->ledBlink_speed = inLedInfo.ledBlink_speed;
+
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_setLedShowInfo outLedInfo name:%d,state:%d,color:%d\n", outLedInfo->led_name, outLedInfo->led_state, outLedInfo->led_color);
+}
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡¶ÌÐŵÆÐÅÏ¢
+***********************************************************************************/
+SINT32 mmi_getLedSmsInfo(UINT32 taskInfo, UINT32 outLedInfo)
+{
+	T_zMmi_Led_Info* pLedInfo = (T_zMmi_Led_Info*)outLedInfo;
+	T_zMmi_Sms_Info *pSmsInfo = (T_zMmi_Sms_Info*)taskInfo;
+	UINT32 i = 0;
+	
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_getLedSmsInfo recvBox_sta=%d\n",pSmsInfo->recvBox_sta);
+
+	for (i = 0; i < (UINT32)mmi_get_config_tab_size(LED_SMS) / sizeof(T_zMmiSmsLedConfig); ++ i) {
+		if (pSmsInfo->recvBox_sta == g_mmi_smsled_config_tab[i].sms_info.recvBox_sta) {
+			mmi_setLedShowInfo(pLedInfo, g_mmi_smsled_config_tab[i].led_info);
+			return MMI_SUCCESS;
+		}
+	}
+	return MMI_ERROR;
+}
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡ÓïÒôÌáʾµÆÐÅÏ¢
+***********************************************************************************/
+SINT32 mmi_getLedVoipInfo(UINT32 taskInfo, UINT32 outLedInfo)
+{
+	T_zMmi_Led_Info* pLedInfo = (T_zMmi_Led_Info*)outLedInfo;
+	T_zMmi_Voip_Info *pVoipInfo = (T_zMmi_Voip_Info*)taskInfo;
+	UINT32 i = 0;
+	
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_getLedVoipInfo voip_sta=%d\n",pVoipInfo->voip_sta);
+
+	for (i = 0; i < (UINT32)mmi_get_config_tab_size(LED_VOIP) / sizeof(T_zMmiVoipLedConfig); ++ i) {
+		if (pVoipInfo->voip_sta == g_mmi_voipled_config_tab[i].voip_info.voip_sta) {
+			mmi_setLedShowInfo(pLedInfo, g_mmi_voipled_config_tab[i].led_info);
+			return MMI_SUCCESS;
+		}
+	}
+	return MMI_ERROR;
+}
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡rj11µÆÐÅÏ¢ Ò¢Ô¶cpe
+***********************************************************************************/
+SINT32 mmi_getLedRj11Info(UINT32 taskInfo, UINT32 outLedInfo)
+{
+	T_zMmi_Led_Info* pLedInfo = (T_zMmi_Led_Info*)outLedInfo;
+	T_zMmi_Rj11_Info *pVoipInfo = (T_zMmi_Rj11_Info*)taskInfo;
+	UINT32 i = 0;
+
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_getLedRj11Info rj11_sta=%d\n",pVoipInfo->rj11_sta);
+
+	for (i = 0; i < (UINT32)mmi_get_config_tab_size(LED_RJ11) / sizeof(T_zMmiRj11LedConfig); ++ i) {
+		if (pVoipInfo->rj11_sta == g_mmi_rj11led_config_tab[i].rj11_info.rj11_sta) {
+			mmi_setLedShowInfo(pLedInfo, g_mmi_rj11led_config_tab[i].led_info);
+			return MMI_SUCCESS;
+		}
+	}
+	return MMI_ERROR;
+}
+
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡rj45µÆÐÅÏ¢
+***********************************************************************************/
+SINT32 mmi_getLedRj45Info(UINT32 taskInfo, UINT32 outLedInfo)
+{
+	T_zMmi_Led_Info* pLedInfo = (T_zMmi_Led_Info*)outLedInfo;
+	T_zMmi_Rj45_Info *pRj45Info = (T_zMmi_Rj45_Info*)taskInfo;
+	UINT32 i = 0;
+
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_getLedRj45Info rj45_sta=%d\n",pRj45Info->rj45_sta);
+
+	for (i = 0; i < (UINT32)mmi_get_config_tab_size(LED_RJ45) / sizeof(T_zMmiRj45LedConfig); ++ i) {
+		if (pRj45Info->rj45_sta == g_mmi_rj45led_config_tab[i].rj45_info.rj45_sta) {
+			mmi_setLedShowInfo(pLedInfo, g_mmi_rj45led_config_tab[i].led_info);
+			return MMI_SUCCESS;
+		}
+	}
+	return MMI_ERROR;
+}
+
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡µç³ØµÆÐÅÏ¢
+***********************************************************************************/
+SINT32 mmi_getLedBatteryInfo(UINT32 taskInfo, UINT32 outLedInfo)
+{
+	T_zMmi_Led_Info* pLedInfo = (T_zMmi_Led_Info*)outLedInfo;
+	T_zMMIBatteryInfo *pBatteryInfo = (T_zMMIBatteryInfo *)taskInfo;
+	UINT32 i = 0;
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_getLedBatteryInfo chg_sta=%d\n", pBatteryInfo->chg_state);
+	for (i = 0; i < (UINT32)mmi_get_config_tab_size(LED_BATTERY) / sizeof(T_zMmiBatteryLedConfig); ++ i) {
+		if (pBatteryInfo->chg_state == g_mmi_batled_config_tab[i].bat_info.chg_state) {
+			if (pBatteryInfo->chg_state == STATE_DISCHARGE) {
+				if (pBatteryInfo->bat_level == g_mmi_batled_config_tab[i].bat_info.bat_level) {
+					mmi_setLedShowInfo(pLedInfo, g_mmi_batled_config_tab[i].led_info);
+					return MMI_SUCCESS;
+				}
+			} else {
+				mmi_setLedShowInfo(pLedInfo, g_mmi_batled_config_tab[i].led_info);
+				return MMI_SUCCESS;
+			}
+		}
+	}
+	return MMI_ERROR;
+}
+
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡ÍøÂçµÆÐÅÏ¢
+***********************************************************************************/
+SINT32 mmi_getLedNetInfo(UINT32 taskInfo, UINT32 outLedInfo)
+{
+	T_zMmi_Led_Info* pLedInfo = (T_zMmi_Led_Info*)outLedInfo;
+	T_zMMINetInfo *pNetInfo = (T_zMMINetInfo *)taskInfo;
+	UINT32 i = 0;
+	int customer_type = g_customer_type; 
+	E_zMmi_Net_Mode net_mode = pNetInfo->net_mode;
+	char mmi_nv_value[32] = {0};
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_getLedNetInfo net_mode=%d connect=%d signal_weak=%d customer_type=%d\n",pNetInfo->net_mode,pNetInfo->connect_status,pNetInfo->signal_weak,g_customer_type);
+
+	//cfg_get_item("mmi_led_plan", mmi_nv_value, sizeof(mmi_nv_value));
+	//if (0 == strcmp(mmi_nv_value, "yaoyuan")) {
+	//	customer_type = CUSTOMER_YAOYUAN;
+		
+		cfg_get_item(NV_MODEM_MAIN_STATE, mmi_nv_value, sizeof(mmi_nv_value));
+		if (strcmp(mmi_nv_value, NV_SIM_STATE_INIT_COMPLETE)) {
+			net_mode = NET_MODE_NOTREADY;
+		}
+	//}
+
+	for (i = 0; i < (UINT32)mmi_get_config_tab_size(LED_WAN) / sizeof(T_zMmiNetLedConfig); ++ i) {
+		if ((net_mode == g_mmi_netled_config_tab[i].net_info.net_mode) && (customer_type == g_mmi_netled_config_tab[i].custom_type)) {
+			if (net_mode == NET_MODE_NOSERVICE 
+				|| net_mode == NET_MODE_LIMITSERVICE
+				|| net_mode == NET_MODE_NOTREADY) {
+				mmi_setLedShowInfo(pLedInfo, g_mmi_netled_config_tab[i].led_info);
+				return MMI_SUCCESS;
+			} else {
+				//if ((pNetInfo->connect_status == g_mmi_netled_config_tab[i].net_info.connect_status) && (pNetInfo->socket_state == g_mmi_netled_config_tab[i].net_info.socket_state)) {
+				if ((pNetInfo->signal_weak == g_mmi_netled_config_tab[i].net_info.signal_weak)) {
+					mmi_setLedShowInfo(pLedInfo, g_mmi_netled_config_tab[i].led_info);
+					slog(MMI_PRINT, SLOG_NORMAL, "ZTE_MMI mmi_getLedNetInfo netmode = %d, signal_weak = %d,i = %d,ledsta = %d\n", net_mode, pNetInfo->signal_weak, i, g_mmi_netled_config_tab[i].led_info.led_state);
+					return MMI_SUCCESS;
+				}
+			}
+		}
+	}
+	return MMI_ERROR;
+}
+
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡ÍøÂçÐźŸñÐÅÏ¢£¨Ò¢Ô¶cpe£©
+***********************************************************************************/
+SINT32 mmi_getLedNetSigInfo(UINT32 taskInfo, UINT32 outLedInfo)
+{
+	T_zMmi_Led_Info* pLedInfo = (T_zMmi_Led_Info*)outLedInfo;
+	T_zMMINetInfo *pNetInfo = (T_zMMINetInfo *)taskInfo;
+	UINT32 i = 0;
+	int customer_type = g_customer_type; 
+	E_zMmi_Net_Mode net_mode = pNetInfo->net_mode;
+	char mmi_nv_value[32] = {0};
+
+	cfg_get_item("mmi_led_plan", mmi_nv_value, sizeof(mmi_nv_value));
+	if (0 == strcmp(mmi_nv_value, "yaoyuan")) {
+		customer_type = CUSTOMER_YAOYUAN;
+	}
+
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_getLedNetSigInfo net_mode=%d signal_num %d customer_type=%d\n",pNetInfo->net_mode,pNetInfo->signal_num,customer_type);
+
+	for (i = 0; i < (UINT32)mmi_get_config_tab_size(LED_SIGNAL) / sizeof(T_zMmiNetLedConfig); ++ i) {
+		if ((net_mode == g_mmi_signalled_config_tab[i].net_info.net_mode) && (customer_type == g_mmi_signalled_config_tab[i].custom_type)) {
+			if (net_mode == NET_MODE_NOSERVICE 
+				|| net_mode == NET_MODE_LIMITSERVICE
+				|| net_mode == NET_MODE_NOTREADY) {
+				mmi_setLedShowInfo(pLedInfo, g_mmi_signalled_config_tab[i].led_info);
+				return MMI_SUCCESS;
+			} else {
+				if (pNetInfo->signal_num == g_mmi_signalled_config_tab[i].net_info.signal_num) {
+					mmi_setLedShowInfo(pLedInfo, g_mmi_signalled_config_tab[i].led_info);
+					slog(MMI_PRINT, SLOG_NORMAL, "ZTE_MMI mmi_getLedNetSigInfo netmode = %d, con_sta = %d,i = %d,ledsta = %d\n", net_mode, pNetInfo->connect_status, i, g_mmi_netled_config_tab[i].led_info.led_state);
+					return MMI_SUCCESS;
+				}
+			}
+		}
+	}
+	return MMI_ERROR;
+}
+
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡WIFIµÆÐÅÏ¢
+***********************************************************************************/
+SINT32 mmi_getLedWifiInfo(UINT32 taskInfo, UINT32 outLedInfo)
+{
+	T_zMmi_Led_Info* pLedInfo = (T_zMmi_Led_Info*)outLedInfo;
+	T_zMMIWifiInfo * pWifiInfo = (T_zMMIWifiInfo *)taskInfo;
+	UINT32 i = 0;
+	
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_getLedWifiInfo wifi_state=%d, wifidata_state=%d\n",pWifiInfo->wifi_state,pWifiInfo->wifidata_state);
+
+	for (i = 0; i < (UINT32)mmi_get_config_tab_size(LED_LAN) / sizeof(T_zMmiWifiLedConfig); ++ i) {
+		if (pWifiInfo->wifi_state == g_mmi_wifiled_config_tab[i].wifi_info.wifi_state
+		    && pWifiInfo->wifidata_state == g_mmi_wifiled_config_tab[i].wifi_info.wifidata_state
+		    && (g_customer_type == g_mmi_wifiled_config_tab[i].custom_type)) {
+			mmi_setLedShowInfo(pLedInfo, g_mmi_wifiled_config_tab[i].led_info);
+			return MMI_SUCCESS;
+		}
+	}
+	
+	return MMI_ERROR;
+}
+
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡wpsµÆÐÅÏ¢ Ò¢Ô¶cpe
+***********************************************************************************/
+SINT32 mmi_getLedWpsInfo(UINT32 taskInfo, UINT32 outLedInfo)
+{
+	T_zMmi_Led_Info* pLedInfo = (T_zMmi_Led_Info*)outLedInfo;
+	T_zMMIWifiInfo * pWifiInfo = (T_zMMIWifiInfo *)taskInfo;
+	UINT32 i = 0;
+
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_getLedWpsInfo wps_state=%d customer_type=%d\n",pWifiInfo->wps_state, g_customer_type);
+
+	for (i = 0; i < (UINT32)mmi_get_config_tab_size(LED_WPS) / sizeof(T_zMmiWifiLedConfig); ++ i) {
+		if (pWifiInfo->wps_state == g_mmi_wpsled_config_tab[i].wifi_info.wps_state
+		    && (g_customer_type == g_mmi_wpsled_config_tab[i].custom_type)) {
+			mmi_setLedShowInfo(pLedInfo, g_mmi_wpsled_config_tab[i].led_info);
+			return MMI_SUCCESS;
+		}
+	}
+
+	return MMI_ERROR;
+}
+
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:Á÷Á¿¸æ¾¯Ë«ÉÁµÆ
+***********************************************************************************/
+VOID mmi_set_led_double_blink()
+{
+	slog(MMI_PRINT, SLOG_NORMAL, "ZTE_MMI mmi_set_led_double_blink 1000ms off\n");
+
+	T_zMmi_Led_Info userInfo = {0};
+	userInfo.led_name = LED_WAN;
+	userInfo.led_state = LED_STATE_OFF;
+	userInfo.led_color = LED_COLOR_YELLOW;
+	mmi_led_operate(&userInfo);
+	userInfo.led_color = LED_COLOR_BLUE;
+	mmi_led_operate(&userInfo);
+	mmi_startLedTrafficWarnTimer(1000, 0);
+
+	int sem_ret1 = -1;
+	sem_ret1 = mmi_GetSemaphoreEintr(&g_mmi_traffic_warn_sem_id, MMI_WAIT_FOREVER);
+	if (sem_ret1 != MMI_SUCCESS) {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI DBget1 FAILED! errno=%d\n",errno);
+	}
+	userInfo.led_color = LED_COLOR_RED;
+	userInfo.led_state = LED_STATE_ON;
+	mmi_led_operate(&userInfo);
+	mmi_startLedTrafficWarnTimer(100, 0);
+
+	int sem_ret2 = -1;
+	sem_ret2 = mmi_GetSemaphoreEintr(&g_mmi_traffic_warn_sem_id, MMI_WAIT_FOREVER);
+	if (sem_ret2 != MMI_SUCCESS) {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI DBget2 FAILED! errno=%d\n",errno);
+	}
+
+	userInfo.led_state = LED_STATE_OFF;
+	mmi_led_operate(&userInfo);
+	mmi_startLedTrafficWarnTimer(100, 0);
+
+	int sem_ret3 = -1;
+	sem_ret3 = mmi_GetSemaphoreEintr(&g_mmi_traffic_warn_sem_id, MMI_WAIT_FOREVER);
+	if (sem_ret3 != MMI_SUCCESS) {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI DBget3 FAILED! errno=%d\n",errno);
+	}
+
+	userInfo.led_state = LED_STATE_ON;
+	mmi_led_operate(&userInfo);
+	mmi_startLedTrafficWarnTimer(100, 0);
+
+	int sem_ret4 = -1;
+	sem_ret4 = mmi_GetSemaphoreEintr(&g_mmi_traffic_warn_sem_id, MMI_WAIT_FOREVER);
+	if (sem_ret4 != MMI_SUCCESS) {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI DBget4 FAILED! errno=%d\n",errno);
+	}
+
+	userInfo.led_state = LED_STATE_OFF;
+	mmi_led_operate(&userInfo);
+	mmi_startLedTrafficWarnTimer(1000, 0);
+
+	int sem_ret5 = -1;
+	sem_ret5 = mmi_GetSemaphoreEintr(&g_mmi_traffic_warn_sem_id, MMI_WAIT_FOREVER);
+	if (sem_ret5 != MMI_SUCCESS) {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI DBget5 FAILED! errno=%d\n",errno);
+	}
+
+	mmi_set_update_flag(MMI_TASK_NET);
+	mmi_startLedTrafficWarnTimer(4000, 1);
+}
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:ÉèÖÃÁ÷Á¿¾¯¸æ±êÖ¾
+***********************************************************************************/
+VOID mmi_set_traffic_warn_flag(BOOL flag)
+{
+	s_mmi_trafficled_warn_flag = flag;
+}
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡Á÷Á¿µÆÐÅÏ¢
+***********************************************************************************/
+SINT32 mmi_getLedTrafficInfo(UINT32 taskInfo, UINT32 outLedInfo)
+{
+	T_zMMITrafficInfo * pTrafficInfo = (T_zMMITrafficInfo *)taskInfo;
+
+#if 0
+	pLedInfo->led_name = IOCTL_LED_TRAFFIC;
+	pLedInfo->userPara.uBrightness = 0;
+	pLedInfo->userPara.uColor = LED_COLOR_GREEN;
+	pLedInfo->userPara.uSleep = LED_SLEEP_MAX;
+	if (pTrafficInfo->traffic_switch == TRAFFIC_LIMIT_SWITCH_OFF) {
+		pLedInfo->userPara.uState = LED_STATE_OFF;
+		pLedInfo->speed = LED_STATE_DEFAULT_BLINK;
+		pLedInfo->userPara.uTraffic = LED_TRAFFIC_100;
+	} else {
+		if (pTrafficInfo->warning_tip_flag == 0) {
+			pLedInfo->userPara.uState = LED_STATE_ON;
+			pLedInfo->speed = LED_STATE_DEFAULT_BLINK;
+		} else {
+			pLedInfo->userPara.uState = LED_STATE_BLINK;
+			pLedInfo->speed = LED_STATE_FAST_BLINK;
+		}
+	}
+#endif
+
+	UINT32 temp = 100 * (pTrafficInfo->uesd_traffic / pTrafficInfo->total_traffic);
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_getLedTrafficInfo temp = %d, level = %d\n", temp, pTrafficInfo->warning_tip_level);
+	if ((pTrafficInfo->warning_tip_level != 0) && (temp >= pTrafficInfo->warning_tip_level) && (pTrafficInfo->traffic_switch == TRAFFIC_LIMIT_SWITCH_ON)) {
+		if (!s_mmi_trafficled_warn_flag) {
+			mmi_set_traffic_warn_flag(TRUE);
+			mmi_set_led_double_blink();
+		}
+	} else {
+		mmi_set_traffic_warn_flag(FALSE);
+		mmi_stopLedTrafficWarnTimer();
+		mmi_set_update_flag(MMI_TASK_NET);
+	}
+	return MMI_ERROR;
+
+}
+
+static VOID mmi_set_allleds_off(E_zMMI_BatLed_Mode mode)
+{
+	T_zMmi_Led_Info userInfo = {0};
+
+	slog(MMI_PRINT, SLOG_NORMAL, "ZTE_MMI mmi_set_allleds_off mode = %d\n", mode);
+	mmi_set_traffic_warn_flag(FALSE);
+	mmi_stopLedTrafficWarnTimer();
+	mmi_clean_update_flag(MMI_TASK_NET);
+	mmi_clean_update_flag(MMI_TASK_TRAFFIC);
+	mmi_clean_update_flag(MMI_TASK_WIFI);
+	
+	mmi_clean_update_flag(MMI_TASK_NETSIGNAL);
+	mmi_clean_update_flag(MMI_TASK_LED_WPS);
+	mmi_clean_update_flag(MMI_TASK_RJ11);
+	mmi_clean_update_flag(MMI_TASK_RJ45);
+
+	if (g_voicetask_enable)
+		mmi_clean_update_flag(MMI_TASK_VOIP);
+	else if (g_smstask_enable)
+		mmi_clean_update_flag(MMI_TASK_SMS);
+
+	if (mode == MODE_OFF) {
+		userInfo.led_name = LED_BATTERY;
+		userInfo.led_color = LED_COLOR_YELLOW;
+		userInfo.led_state = LED_STATE_OFF;
+
+		mmi_led_operate(&userInfo);
+	} else if (mode == MODE_CHARGING) {
+
+	} else if (mode == MODE_STANDBY) {
+		userInfo.led_name = LED_BATTERY;
+		userInfo.led_color = LED_COLOR_GREEN;
+		userInfo.led_state = LED_STATE_BLINK;
+		userInfo.ledBlink_time.uBlinkOffTime = LED_BREATH_BLINK_OFF_TIME;
+		userInfo.ledBlink_time.uBlinkOnTime = LED_BREATH_BLINK_ON_TIME;
+		mmi_led_operate(&userInfo);
+	}
+	userInfo.led_name = LED_WAN;
+	userInfo.led_state = LED_STATE_OFF;
+	userInfo.led_color = LED_COLOR_BLUE;
+	mmi_led_operate(&userInfo);
+	userInfo.led_color = LED_COLOR_BLUE;
+	mmi_led_operate(&userInfo);
+	userInfo.led_name = LED_LAN;
+	mmi_led_operate(&userInfo);
+	if (g_voicetask_enable)
+		userInfo.led_name = LED_VOIP;
+	else if (g_smstask_enable)
+		userInfo.led_name = LED_SMS;
+	mmi_led_operate(&userInfo);
+	//yaoyuan cpe
+	userInfo.led_color = LED_COLOR_BLUE;
+	userInfo.led_name = LED_WPS;
+	mmi_led_operate(&userInfo);
+	userInfo.led_name = LED_RJ11;
+	mmi_led_operate(&userInfo);
+	userInfo.led_name = LED_RJ45;
+	mmi_led_operate(&userInfo);
+	userInfo.led_name = LED_SIGNAL;
+	mmi_led_operate(&userInfo);
+}
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:¹Ø»ú»òÖØÆôʱËùÓеÆÏÈÈ«ÁÁÔÙÈ«Ãð
+***********************************************************************************/
+VOID mmi_set_allleds_blink(VOID)
+{
+
+	mmi_set_traffic_warn_flag(FALSE);
+	mmi_stopLedTrafficWarnTimer();
+	mmi_clean_update_flag(MMI_TASK_NET);
+	mmi_clean_update_flag(MMI_TASK_TRAFFIC);
+	mmi_clean_update_flag(MMI_TASK_WIFI);
+	//yao yuan
+	mmi_clean_update_flag(MMI_TASK_NETSIGNAL);
+	mmi_clean_update_flag(MMI_TASK_LED_WPS);
+	mmi_clean_update_flag(MMI_TASK_RJ11);
+	mmi_clean_update_flag(MMI_TASK_RJ45);
+
+	if (g_voicetask_enable)
+		mmi_clean_update_flag(MMI_TASK_VOIP);
+	else if (g_smstask_enable)
+		mmi_clean_update_flag(MMI_TASK_SMS);
+
+	T_zMmi_Led_Info userInfo = {0};
+
+	userInfo.led_name = LED_BATTERY;
+	userInfo.led_state = LED_STATE_ON;
+	userInfo.led_color = LED_COLOR_RED;
+	mmi_led_operate(&userInfo);
+
+	userInfo.led_name = LED_LAN;
+	userInfo.led_color = LED_COLOR_BLUE;
+	mmi_led_operate(&userInfo);
+
+	if (g_voicetask_enable)
+		userInfo.led_name = LED_VOIP;
+	else if (g_smstask_enable)
+		userInfo.led_name = LED_SMS;
+	userInfo.led_color = LED_COLOR_BLUE;
+	mmi_led_operate(&userInfo);
+
+	userInfo.led_name = LED_WAN;
+	if(g_customer_type == CUSTOMER_SDK_MIN)
+		userInfo.led_color = LED_COLOR_GREEN;
+	else
+		userInfo.led_color = LED_COLOR_BLUE;
+	mmi_led_operate(&userInfo);
+
+	//yaoyuan cpe
+	userInfo.led_color = LED_COLOR_BLUE;
+	userInfo.led_name = LED_WPS;
+	mmi_led_operate(&userInfo);
+	userInfo.led_name = LED_RJ11;
+	mmi_led_operate(&userInfo);
+	userInfo.led_name = LED_RJ45;
+	mmi_led_operate(&userInfo);
+	userInfo.led_name = LED_SIGNAL;
+	userInfo.traffic = TRAFFIC_LED_5;
+	mmi_led_operate(&userInfo);
+
+
+	mmi_sleep(LED_BLINK_TIME_INTERVAL);
+
+	userInfo.led_state = LED_STATE_OFF;
+
+	userInfo.led_name = LED_BATTERY;
+	userInfo.led_color = LED_COLOR_RED;
+	mmi_led_operate(&userInfo);
+
+	userInfo.led_name = LED_LAN;
+	userInfo.led_color = LED_COLOR_BLUE;
+	mmi_led_operate(&userInfo);
+
+	if (g_voicetask_enable)
+		userInfo.led_name = LED_VOIP;
+	else if (g_smstask_enable)
+		userInfo.led_name = LED_SMS;
+	userInfo.led_color = LED_COLOR_BLUE;
+	mmi_led_operate(&userInfo);
+
+	userInfo.led_name = LED_WAN;
+	userInfo.led_color = LED_COLOR_BLUE;
+	mmi_led_operate(&userInfo);
+	//yaoyuan cpe
+	userInfo.led_color = LED_COLOR_BLUE;
+	userInfo.led_name = LED_WPS;
+	mmi_led_operate(&userInfo);
+	userInfo.led_name = LED_RJ11;
+	mmi_led_operate(&userInfo);
+	userInfo.led_name = LED_RJ45;
+	mmi_led_operate(&userInfo);
+	userInfo.led_name = LED_SIGNAL;
+	mmi_led_operate(&userInfo);
+	
+	slog(MMI_PRINT, SLOG_DEBUG, "mmi_set_allleds_blink  off!\n");
+}
+SINT32 mmi_getLedCtrlInfo(UINT32 taskInfo, UINT32 outLedInfo)
+{
+	T_zMMICtrlInfo * pCtrlInfo = (T_zMMICtrlInfo *)taskInfo;
+	T_zMmi_Led_Info* pLedInfo = (T_zMmi_Led_Info*)outLedInfo;
+
+	pLedInfo->traffic = TRAFFIC_LED_MAX;
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_getLedCtrlInfo pCtrlInfo->ledmode = %d\n", pCtrlInfo->ledmode);
+	switch (pCtrlInfo->ledmode) {
+	case MMI_ACTIVE_MODE:
+		mmi_set_update_flag(MMI_TASK_BATTERY);
+
+		if (g_voicetask_enable)
+			mmi_set_update_flag(MMI_TASK_VOIP);
+		else if (g_smstask_enable)
+			mmi_set_update_flag(MMI_TASK_SMS);
+
+		mmi_set_update_flag(MMI_TASK_WIFI);
+		mmi_set_update_flag(MMI_TASK_NET);
+		mmi_set_update_flag(MMI_TASK_TRAFFIC);
+		mmi_set_update_flag(MMI_TASK_LED_WPS);
+		break;
+	case MMI_IDLE_LEDOFF_MODE:
+		if (g_customer_type == CUSTOMER_SDK || g_customer_type == CUSTOMER_SDK_MIN) {
+			mmi_set_allleds_off(MODE_OFF);
+		}		
+		set_wake_unlock(MMI_MAIN_LOCK_ID);
+		break;
+	case MMI_IDLE_STANDBY_LEDOFF_MODE:
+		if (g_customer_type == CUSTOMER_SDK || g_customer_type == CUSTOMER_SDK_MIN) {
+			mmi_set_allleds_off(MODE_STANDBY);
+		}		
+		set_wake_unlock(MMI_MAIN_LOCK_ID);
+		break;
+	case MMI_FAKE_POWEROFF_MODE:
+		mmi_set_allleds_off(MODE_OFF);
+		set_wake_unlock(MMI_MAIN_LOCK_ID);
+		break;
+	case MMI_IDLE_CHG_LEDOFF_MODE:
+		if (g_customer_type == CUSTOMER_SDK || g_customer_type == CUSTOMER_SDK_MIN) {
+			mmi_set_allleds_off(MODE_CHARGING);
+		}
+		break;
+	case MMI_FAKE_POWEROFF_CHARGE_MODE:
+		mmi_set_update_flag(MMI_TASK_BATTERY);
+		mmi_set_allleds_off(MODE_CHARGING);
+		break;
+	case MMI_POWEROFF_MODE:
+	case MMI_RESET_MODE:
+	case MMI_RESTART_MODE:
+		if(g_customer_type == CUSTOMER_SDK || g_customer_type == CUSTOMER_SDK_MIN){
+			mmi_set_allleds_blink();
+		}
+#ifndef DISABLE_LCD
+		if (g_PowerOnOffFun != NULL) {
+			slog(MMI_PRINT, SLOG_DEBUG, "mmi_set_allleds_blink  g_PowerOnOffFun!\n");
+			g_PowerOnOffFun();
+		}
+#endif
+		break;
+	case MMI_FAST_POWERON_MODE:
+		mmi_set_allleds_blink();
+		mmi_set_update_flag(MMI_TASK_BATTERY);
+
+		if (g_voicetask_enable)
+			mmi_set_update_flag(MMI_TASK_VOIP);
+		else if (g_smstask_enable)
+			mmi_set_update_flag(MMI_TASK_SMS);
+
+		mmi_set_update_flag(MMI_TASK_WIFI);
+		mmi_set_update_flag(MMI_TASK_NET);
+		mmi_set_update_flag(MMI_TASK_TRAFFIC);
+		mmi_set_update_flag(MMI_TASK_LED_WPS);
+		break;
+	case MMI_POWEROFF_ON_MODE:
+		break;
+	default:
+		break;
+	}
+	return MMI_ERROR;
+}
+
+SINT32 mmi_getLedPowerOffChagerInfo(UINT32 taskInfo, UINT32 outLedInfo)
+{
+	T_zMmi_Poc_Info *pPocInfo = (T_zMmi_Poc_Info *)taskInfo;
+	T_zMmi_Led_Info* pLedInfo = (T_zMmi_Led_Info*)outLedInfo;
+	pLedInfo->led_name = LED_BATTERY;
+	pLedInfo->traffic = TRAFFIC_LED_MAX;
+	pLedInfo->led_color = LED_COLOR_GREEN;
+
+	if (pPocInfo->poc_sta == POC_STATE_FULL || pPocInfo->poc_sta == POC_STATE_TEMP_ERROR) {
+		pLedInfo->led_state = LED_STATE_ON;
+	}
+	else if (pPocInfo->poc_sta == POC_STATE_LOWBATTERY) {
+		pLedInfo->led_color = LED_COLOR_RED;
+		pLedInfo->led_state = LED_STATE_ON;
+	}
+	else {
+		pLedInfo->led_state = LED_STATE_BLINK;
+		pLedInfo->ledBlink_speed = LED_STATE_BAT_BLINK;
+	}
+	return MMI_SUCCESS;
+
+}
+
diff --git a/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_led_adapter.c b/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_led_adapter.c
new file mode 100755
index 0000000..3411f31
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_led_adapter.c
@@ -0,0 +1,1535 @@
+/*****************************************************************************
+*  °æ±¾ËùÓÐ (C)ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾
+*  Ä£¿éÃû    £ºMMI
+*  ÎļþÃû    £ºmmiledadapter.c
+*  Îļþ±êʶ  £º
+*  Ïà¹ØÎļþ  £º
+*  ʵÏÖ¹¦ÄÜ  £ºLED²Ù×÷
+*  ×÷Õß      £º
+*  °æ±¾      £ºV1.0
+*  Íê³ÉÈÕÆÚ  £º2014-6-20
+*  ÆäËü˵Ã÷  £º
+*
+******************************************************************************/
+
+/*****************************************************************************
+ Í·Îļþ
+******************************************************************************/
+#include "mmi_common.h"
+
+#define itoa(i,a,b) (((b) == 16) ? sprintf((a), "%x", (i)) : sprintf((a), "%d", (i)))
+
+MMI_LED_LASTSTATE g_mmi_wanled_state = LED_ALL_OFF;//±ê¼ÇÍøÂçµÆµÄµ±Ç°×´Ì¬
+MMI_LED_BLINK_SPEED g_mmi_wanled_speed = LED_STATE_DEFAULT_BLINK;//±ê¼ÇÍøÂçµÆµÄÉÁ˸ƵÂÊ
+MMI_LED_LASTSTATE g_mmi_lanled_state = LED_ALL_OFF;//±ê¼ÇwifiµÆµÄµ±Ç°×´Ì¬
+MMI_LED_LASTSTATE g_mmi_batteryled_state = LED_ALL_OFF;//±ê¼Çµç³ØµÆµÄµ±Ç°×´Ì¬
+MMI_LED_LASTSTATE g_mmi_smsled_state = LED_ALL_OFF;//±ê¼Ç¶ÌÐŵƵĵ±Ç°×´Ì¬
+MMI_LED_LASTSTATE g_mmi_voipled_state = LED_ALL_OFF;//±ê¼ÇÓïÒôµÆµÄµ±Ç°×´Ì¬
+MMI_LED_LASTSTATE g_mmi_signalled_state = LED_ALL_OFF;//±ê¼ÇÒ¢Ô¶cpeÍøÂçÐźŵƵĵ±Ç°×´Ì¬
+MMI_LED_LASTSTATE g_mmi_wpsled_state = LED_ALL_OFF;//±ê¼ÇÒ¢Ô¶cpe wpsµÆµÄµ±Ç°×´Ì¬
+MMI_LED_LASTSTATE g_mmi_rj11led_state = LED_ALL_OFF;//±ê¼ÇÒ¢Ô¶cpe rj11µÆµÄµ±Ç°×´Ì¬
+MMI_LED_LASTSTATE g_mmi_rj45led_state = LED_ALL_OFF;//±ê¼Çrj45µÆµÄµ±Ç°×´Ì¬
+
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:дÎļþ²Ù×÷º¯Êý
+***********************************************************************************/
+SINT32 mmi_file_operate(char *filepath, char *buf)
+{
+#if 1
+	SINT32 ret_fd = 0;
+	SINT32 len = 0;
+
+	ret_fd = open(filepath, O_RDWR);
+	if (ret_fd == -1) {
+		slog(MMI_PRINT, SLOG_ERR,"ZTE_MMI mmi_file_operate open file fail: %s!\n", filepath);
+		return MMI_ERROR;
+	}
+
+	len = strlen(buf);
+	if (write(ret_fd, buf, len) != len) {
+		slog(MMI_PRINT, SLOG_ERR,"ZTE_MMI mmi_file_operate write file fail: %s!\n", filepath);
+		close((int)ret_fd);
+		return MMI_ERROR;
+	}
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_file_operate write file: %s success!!\n", filepath);
+	close((int)ret_fd);
+#endif
+	return MMI_SUCCESS;
+}
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:µãÁÁ
+***********************************************************************************/
+static SINT32 mmi_led_opt_on(char *filepath)
+{
+	return mmi_file_operate(filepath, "1");
+}
+
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:µãÃð
+***********************************************************************************/
+static SINT32 mmi_led_opt_off(char *filebrightness)
+{
+	return mmi_file_operate(filebrightness, "0");
+}
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:ÉÁ˸
+***********************************************************************************/
+static SINT32 mmi_led_opt_blinkon(T_zMmi_LedBlink_Info *info)
+{
+	char buf1[12] = {0};
+	char buf2[12] = {0};
+	SINT32 ret1, ret2, ret3 = 0;
+
+	ret1 = mmi_file_operate(info->fileblinkSwitch, LED_BLINKON_STATE);
+
+
+	itoa((int)(info->timeon), buf1, 10);
+	ret2 = mmi_file_operate(info->fileblinktimeon, buf1);
+
+	itoa((int)(info->timoff), buf2, 10);
+	ret3 = mmi_file_operate(info->fileblinktimeoff, buf2);
+	if (ret1 == MMI_ERROR || ret2 == MMI_ERROR || ret3 == MMI_ERROR) {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI led_setFastBlinkOn fail ret1 = %d ret2 = %d ret3 = %d!\n", ret1, ret2, ret3);
+		return MMI_ERROR;
+	}
+	return MMI_SUCCESS;
+
+}
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:ÉÁ˸¹Ø
+***********************************************************************************/
+static SINT32 mmi_led_opt_blinkoff(char *fileblinkSwitch)
+{
+	return mmi_file_operate(fileblinkSwitch, LED_BLINKOFF_STATE);
+}
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:ÉèÖÃ/»ñÈ¡µÆµÄÉÏ´Î״̬
+***********************************************************************************/
+static VOID mmi_setBatLedState(MMI_LED_LASTSTATE bat_state)
+{
+	g_mmi_batteryled_state = bat_state;
+}
+
+static VOID mmi_setWanLedState(MMI_LED_LASTSTATE wan_state)
+{
+	g_mmi_wanled_state = wan_state;
+}
+
+static VOID mmi_setWanLedSpeed(MMI_LED_BLINK_SPEED wan_speed)
+{
+	g_mmi_wanled_speed = wan_speed;
+}
+
+static VOID mmi_setLanLedState(MMI_LED_LASTSTATE lan_state)
+{
+	g_mmi_lanled_state = lan_state;
+}
+static VOID mmi_setSmsLedState(MMI_LED_LASTSTATE sms_state)
+{
+	g_mmi_smsled_state = sms_state;
+}
+static VOID mmi_setVoipLedState(MMI_LED_LASTSTATE voip_state)
+{
+	g_mmi_voipled_state = voip_state;
+}
+
+static MMI_LED_LASTSTATE mmi_getBatLedState(VOID)
+{
+	MMI_LED_LASTSTATE state;
+	state = g_mmi_batteryled_state;
+	return state;
+}
+
+static MMI_LED_LASTSTATE mmi_getWanLedState(VOID)
+{
+	MMI_LED_LASTSTATE state;
+	state = g_mmi_wanled_state;
+	return state;
+}
+static MMI_LED_BLINK_SPEED mmi_getWanLedSpeed(VOID)
+{
+	MMI_LED_BLINK_SPEED speed;
+	speed = g_mmi_wanled_speed;
+	return speed;
+}
+
+static MMI_LED_LASTSTATE mmi_getLanLedState(VOID)
+{
+	MMI_LED_LASTSTATE state;
+	state = g_mmi_lanled_state;
+	return state;
+}
+
+static MMI_LED_LASTSTATE mmi_getSmsLedState(VOID)
+{
+	MMI_LED_LASTSTATE state;
+	state = g_mmi_smsled_state;
+	return state;
+}
+
+static MMI_LED_LASTSTATE mmi_getVoipLedState(VOID)
+{
+	MMI_LED_LASTSTATE state;
+	state = g_mmi_voipled_state;
+	return state;
+}
+
+/********************************************************************************
+µç³ØµÆ²Ù×÷
+**********************************************************************************/
+VOID  mmi_BatLedOffOpt()
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_BatLedOffOpt !\n");
+	mmi_led_opt_blinkoff(LED_BATTERY_GREEN_BLINKSWITCH);
+	mmi_led_opt_off(LED_BATTERY_GREEN_BRIGHTNESS);
+	mmi_led_opt_blinkoff(LED_BATTERY_RED_BLINKSWITCH);
+	mmi_led_opt_off(LED_BATTERY_RED_BRIGHTNESS);
+	mmi_setBatLedState(LED_ALL_OFF);
+}
+
+static VOID mmi_BatLedRedOn()
+{
+	mmi_led_opt_on(LED_BATTERY_RED_BRIGHTNESS);
+}
+
+static VOID mmi_BatLedRedBlink(T_zMmi_Led_Blink_Time time)
+{
+	T_zMmi_LedBlink_Info info = {0};
+	info.fileblinkSwitch = LED_BATTERY_RED_BLINKSWITCH;
+	info.fileblinktimeoff = LED_BATTERY_RED_BLINKTIMEOFF;
+	info.fileblinktimeon = LED_BATTERY_RED_BLINKTIMEON;
+	info.timeon = (char *)time.uBlinkOnTime;
+	info.timoff = (char *)time.uBlinkOffTime;
+	mmi_led_opt_on(LED_BATTERY_RED_BRIGHTNESS);
+	mmi_led_opt_blinkon(&info);
+}
+
+VOID mmi_BatLedGreenOn()
+{
+	mmi_led_opt_on(LED_BATTERY_GREEN_BRIGHTNESS);
+}
+
+static VOID mmi_BatLedGreenBlink(T_zMmi_Led_Blink_Time time)
+{
+	T_zMmi_LedBlink_Info info = {0};
+	info.fileblinkSwitch = LED_BATTERY_GREEN_BLINKSWITCH;
+	info.fileblinktimeoff = LED_BATTERY_GREEN_BLINKTIMEOFF;
+	info.fileblinktimeon = LED_BATTERY_GREEN_BLINKTIMEON;
+	info.timeon = (char *)time.uBlinkOnTime;
+	info.timoff = (char *)time.uBlinkOffTime;
+	mmi_led_opt_on(LED_BATTERY_GREEN_BRIGHTNESS);
+	mmi_led_opt_blinkon(&info);
+}
+
+static VOID mmi_BatLedYellowOn()
+{
+	mmi_led_opt_on(LED_BATTERY_RED_BRIGHTNESS);
+	mmi_led_opt_on(LED_BATTERY_GREEN_BRIGHTNESS);
+}
+
+static VOID mmi_BatLedYellowBlink(T_zMmi_Led_Blink_Time time)
+{
+	T_zMmi_LedBlink_Info info = {0};
+	info.fileblinkSwitch = LED_BATTERY_RED_BLINKSWITCH;
+	info.fileblinktimeoff = LED_BATTERY_RED_BLINKTIMEOFF;
+	info.fileblinktimeon = LED_BATTERY_RED_BLINKTIMEON;
+	info.timeon = (char *)time.uBlinkOnTime;
+	info.timoff = (char *)time.uBlinkOffTime;
+	mmi_led_opt_on(LED_BATTERY_RED_BRIGHTNESS);
+	mmi_led_opt_blinkon(&info);
+
+	info.fileblinkSwitch = LED_BATTERY_GREEN_BLINKSWITCH;
+	info.fileblinktimeoff = LED_BATTERY_GREEN_BLINKTIMEOFF;
+	info.fileblinktimeon = LED_BATTERY_GREEN_BLINKTIMEON;
+	mmi_led_opt_on(LED_BATTERY_GREEN_BRIGHTNESS);
+	mmi_led_opt_blinkon(&info);
+}
+
+static VOID mmi_BatLedOnOpt(MMI_LED_COLOR color)
+{
+	MMI_LED_LASTSTATE bat_sta = mmi_getBatLedState();
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_BatLedOnOpt  color=%d, bat_sta = %d!\n", color, bat_sta);
+	if (color == LED_COLOR_RED) {
+
+		if (bat_sta == LED_RED_ON) {
+			return;
+		} else {
+			mmi_BatLedOffOpt();
+			mmi_BatLedRedOn();
+		}
+		mmi_setBatLedState(LED_RED_ON);
+	} else if (color == LED_COLOR_GREEN) {
+		if (bat_sta == LED_GREEN_ON) {
+			return;
+		} else {
+			mmi_BatLedOffOpt();
+			mmi_BatLedGreenOn();
+		}
+		mmi_setBatLedState(LED_GREEN_ON);
+	} else if (color == LED_COLOR_YELLOW) {
+		if (bat_sta == LED_YELLOW_ON) {
+			return;
+		} else if (bat_sta == LED_GREEN_ON) {
+			mmi_BatLedRedOn();
+		} else if (bat_sta == LED_RED_ON) {
+			mmi_BatLedGreenOn();
+		} else {
+			mmi_BatLedOffOpt();
+			mmi_BatLedYellowOn();
+		}
+		mmi_setBatLedState(LED_YELLOW_ON);
+	} else {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_BatLedOnOpt invalid led color!\n");
+	}
+}
+
+static VOID mmi_BatLedBlinkOpt(MMI_LED_COLOR color, T_zMmi_Led_Blink_Time time)
+{
+	MMI_LED_LASTSTATE bat_sta = mmi_getBatLedState();
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_BatLedFastBlinkOpt  color=%d bat_sta = %d!\n", color, bat_sta);
+	if (color == LED_COLOR_RED) {
+		if (bat_sta == LED_RED_BLINK) {
+			return;
+		} else {
+			mmi_BatLedOffOpt();
+			mmi_BatLedRedBlink(time);
+		}
+		mmi_setBatLedState(LED_RED_BLINK);
+	} else if (color == LED_COLOR_GREEN) {
+		if (bat_sta == LED_GREEN_BLINK) {
+			return;
+		} else {
+			mmi_BatLedOffOpt();
+			mmi_BatLedGreenBlink(time);
+		}
+		mmi_setBatLedState(LED_GREEN_BLINK);
+	} else if (color == LED_COLOR_YELLOW) {
+		if (bat_sta == LED_YELLOW_BLINK) {
+			return;
+		} else {
+			mmi_BatLedOffOpt();
+			mmi_BatLedYellowBlink(time);
+		}
+		mmi_setBatLedState(LED_YELLOW_BLINK);
+	} else {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_BatLedFastBlinkOpt invalid led color!\n");
+	}
+}
+
+static VOID mmi_processbBatteryLed(MMI_LED_STATE state, MMI_LED_COLOR color, T_zMmi_Led_Blink_Time time)
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_processbBatteryLed state = %d color = %d !\n",  state, color);
+	switch (state) {
+	case LED_STATE_ON: {
+		mmi_BatLedOnOpt(color);
+		break;
+	}
+	case LED_STATE_OFF: {
+		mmi_BatLedOffOpt();
+		break;
+	}
+	case LED_STATE_BLINK: {
+		mmi_BatLedBlinkOpt(color, time);
+		break;
+	}
+	default: {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_processbBatteryLed invalid state!\n");
+		break;
+	}
+	}
+}
+
+
+/********************************************************************************
+  ÍøÂçµÆ²Ù×÷
+**********************************************************************************/
+static VOID mmi_WanLedOffOpt()
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_WanLedOffOpt !\n");
+	mmi_led_opt_blinkoff(LED_WAN_GREEN_BLINKSWITCH);
+	mmi_led_opt_off(LED_WAN_GREEN_BRIGHTNESS);
+	mmi_led_opt_blinkoff(LED_WAN_RED_BLINKSWITCH);
+	mmi_led_opt_off(LED_WAN_RED_BRIGHTNESS);
+	mmi_led_opt_blinkoff(LED_WAN_BLUE_BLINKSWITCH);
+	mmi_led_opt_off(LED_WAN_BLUE_BRIGHTNESS);
+	mmi_setWanLedState(LED_ALL_OFF);
+}
+
+static VOID mmi_WanLedRedOn()
+{
+	mmi_led_opt_on(LED_WAN_RED_BRIGHTNESS);
+}
+
+static VOID mmi_WanLedRedBlink(T_zMmi_Led_Blink_Time time)
+{
+	T_zMmi_LedBlink_Info info = {0};
+	info.fileblinkSwitch = LED_WAN_RED_BLINKSWITCH;
+	info.fileblinktimeoff = LED_WAN_RED_BLINKTIMEOFF;
+	info.fileblinktimeon = LED_WAN_RED_BLINKTIMEON;
+	info.timeon = (char *)time.uBlinkOnTime;
+	info.timoff = (char *)time.uBlinkOffTime;
+	mmi_led_opt_on(LED_WAN_RED_BRIGHTNESS);
+	mmi_led_opt_blinkon(&info);
+}
+
+static VOID mmi_WanLedGreenOn()
+{
+	mmi_led_opt_on(LED_WAN_GREEN_BRIGHTNESS);
+}
+
+static VOID mmi_WanLedGreenBlink(T_zMmi_Led_Blink_Time time)
+{
+	T_zMmi_LedBlink_Info info = {0};
+	info.fileblinkSwitch = LED_WAN_GREEN_BLINKSWITCH;
+	info.fileblinktimeoff = LED_WAN_GREEN_BLINKTIMEOFF;
+	info.fileblinktimeon = LED_WAN_GREEN_BLINKTIMEON;
+	info.timeon = (char *)time.uBlinkOnTime;
+	info.timoff = (char *)time.uBlinkOffTime;
+	mmi_led_opt_on(LED_WAN_GREEN_BRIGHTNESS);
+	mmi_led_opt_blinkon(&info);
+}
+
+static VOID mmi_WanLedYellowOn()
+{
+	mmi_led_opt_on(LED_WAN_RED_BRIGHTNESS);
+	mmi_led_opt_on(LED_WAN_GREEN_BRIGHTNESS);
+}
+
+static VOID mmi_WanLedYellowBlink(T_zMmi_Led_Blink_Time time)
+{
+	T_zMmi_LedBlink_Info info = {0};
+	info.fileblinkSwitch = LED_WAN_RED_BLINKSWITCH;
+	info.fileblinktimeoff = LED_WAN_RED_BLINKTIMEOFF;
+	info.fileblinktimeon = LED_WAN_RED_BLINKTIMEON;
+	info.timeon = (char *)time.uBlinkOnTime;
+	info.timoff = (char *)time.uBlinkOffTime;
+	mmi_led_opt_on(LED_WAN_RED_BRIGHTNESS);
+	mmi_led_opt_blinkon(&info);
+
+	info.fileblinkSwitch = LED_WAN_GREEN_BLINKSWITCH;
+	info.fileblinktimeoff = LED_WAN_GREEN_BLINKTIMEOFF;
+	info.fileblinktimeon = LED_WAN_GREEN_BLINKTIMEON;
+	mmi_led_opt_on(LED_WAN_GREEN_BRIGHTNESS);
+	mmi_led_opt_blinkon(&info);
+}
+
+static VOID mmi_WanLedBlueOn()
+{
+	mmi_led_opt_on(LED_WAN_BLUE_BRIGHTNESS);
+}
+
+static VOID mmi_WanLedBlueBlink(T_zMmi_Led_Blink_Time time)
+{
+	T_zMmi_LedBlink_Info info = {0};
+	info.fileblinkSwitch = LED_WAN_BLUE_BLINKSWITCH;
+	info.fileblinktimeoff = LED_WAN_BLUE_BLINKTIMEOFF;
+	info.fileblinktimeon = LED_WAN_BLUE_BLINKTIMEON;
+	info.timeon = (char *)time.uBlinkOnTime;
+	info.timoff = (char *)time.uBlinkOffTime;
+	mmi_led_opt_on(LED_WAN_BLUE_BRIGHTNESS);
+	mmi_led_opt_blinkon(&info);
+}
+
+static VOID mmi_WanLedOnOpt(MMI_LED_COLOR color)
+{
+	MMI_LED_LASTSTATE wan_sta = mmi_getWanLedState();
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_WanLedOnOpt  color=%d, wan_sta = %d!\n", color, wan_sta);
+	if (color == LED_COLOR_RED) {
+		if (wan_sta == LED_RED_ON) {
+			return;
+		} else {
+			mmi_WanLedOffOpt();
+			mmi_WanLedRedOn();
+		}
+		mmi_setWanLedState(LED_RED_ON);
+	} else if (color == LED_COLOR_GREEN) {
+		if (wan_sta == LED_GREEN_ON) {
+			return;
+		} else {
+			mmi_WanLedOffOpt();
+			mmi_WanLedGreenOn();
+		}
+		mmi_setWanLedState(LED_GREEN_ON);
+	} else if (color == LED_COLOR_YELLOW) {
+		if (wan_sta == LED_YELLOW_ON) {
+			return;
+		} else if (wan_sta == LED_GREEN_ON) {
+			mmi_WanLedRedOn();
+		} else if (wan_sta == LED_RED_ON) {
+			mmi_WanLedGreenOn();
+		} else {
+			mmi_WanLedOffOpt();
+			mmi_WanLedYellowOn();
+		}
+		mmi_setWanLedState(LED_YELLOW_ON);
+	} else if (color == LED_COLOR_BLUE) {
+		if (wan_sta == LED_BLUE_ON) {
+			return;
+		} else {
+			mmi_WanLedOffOpt();
+			mmi_WanLedBlueOn();
+		}
+		mmi_setWanLedState(LED_BLUE_ON);
+	} else {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_WanLedOnOpt invalid led color!\n");
+	}
+}
+
+static VOID mmi_WanLedBlinkOpt(MMI_LED_COLOR color, T_zMmi_Led_Blink_Time time,MMI_LED_BLINK_SPEED speed)
+{
+	MMI_LED_LASTSTATE wan_sta = mmi_getWanLedState();
+	MMI_LED_BLINK_SPEED wan_speed = mmi_getWanLedSpeed();
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_WanLedBlinkOpt  color=%d, wan_sta = %d wan_speed_last=%d!\n", color, wan_sta, wan_speed);
+	if (color == LED_COLOR_RED) {
+		if (wan_sta == LED_RED_BLINK) {
+			return;
+		} else {
+			mmi_WanLedOffOpt();
+			mmi_WanLedRedBlink(time);
+		}
+		mmi_setWanLedState(LED_RED_BLINK);
+	} else if (color == LED_COLOR_GREEN) {
+		if (wan_sta == LED_GREEN_BLINK && (speed == wan_speed)) {
+			return;
+		} else {
+			mmi_WanLedOffOpt();
+			mmi_WanLedGreenBlink(time);
+		}
+		mmi_setWanLedState(LED_GREEN_BLINK);
+		mmi_setWanLedSpeed(speed);
+	} else if (color == LED_COLOR_YELLOW) {
+		if (wan_sta == LED_YELLOW_BLINK) {
+			return;
+		} else {
+			mmi_WanLedOffOpt();
+			mmi_WanLedYellowBlink(time);
+		}
+		mmi_setWanLedState(LED_YELLOW_BLINK);
+	} else if (color == LED_COLOR_BLUE) {
+		if (wan_sta == LED_BLUE_BLINK) {
+			return;
+		} else {
+			mmi_WanLedOffOpt();
+			mmi_WanLedBlueBlink(time);
+		}
+		mmi_setWanLedState(LED_BLUE_BLINK);
+	} else {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_WanLedFastBlinkOpt invalid led color!\n");
+	}
+}
+
+static VOID mmi_processWanLed(MMI_LED_STATE state, MMI_LED_COLOR color, T_zMmi_Led_Blink_Time time, MMI_LED_BLINK_SPEED speed)
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_processWanLed state = %d color=%d speed=%d!\n",  state, color, speed);
+	switch (state) {
+	case LED_STATE_ON: {
+		mmi_WanLedOnOpt(color);
+		break;
+	}
+	case LED_STATE_OFF: {
+		mmi_WanLedOffOpt();
+		break;
+	}
+	case LED_STATE_BLINK: {
+		mmi_WanLedBlinkOpt(color, time, speed);
+		break;
+	}
+	default: {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_processNetLed invalid state!\n");
+		break;
+	}
+	}
+}
+
+/********************************************************************************
+  WIFI µÆ²Ù×÷
+**********************************************************************************/
+static VOID mmi_LanLedOffOpt(MMI_LED_COLOR color)
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_LanLedOffOpt!\n");
+	if (color == LED_COLOR_GREEN) {
+		mmi_led_opt_blinkoff(LED_LAN_GREEN_BLINKSWITCH);
+		mmi_led_opt_off(LED_LAN_GREEN_BRIGHTNESS);
+	} else if (color == LED_COLOR_BLUE) {
+		mmi_led_opt_blinkoff(LED_LAN_BLUE_BLINKSWITCH);
+		mmi_led_opt_off(LED_LAN_BLUE_BRIGHTNESS);
+	}
+	mmi_setLanLedState(LED_ALL_OFF);
+}
+static VOID mmi_LanLedGreenOn()
+{
+	mmi_led_opt_on(LED_LAN_GREEN_BRIGHTNESS);
+}
+static VOID mmi_LanLedGreenBlink(T_zMmi_Led_Blink_Time time)
+{
+	T_zMmi_LedBlink_Info info = {0};
+	info.fileblinkSwitch = LED_LAN_GREEN_BLINKSWITCH;
+	info.fileblinktimeoff = LED_LAN_GREEN_BLINKTIMEOFF;
+	info.fileblinktimeon = LED_LAN_GREEN_BLINKTIMEON;
+	info.timeon = (char *)time.uBlinkOnTime;
+	info.timoff = (char *)time.uBlinkOffTime;
+	mmi_led_opt_on(LED_LAN_GREEN_BRIGHTNESS);
+	mmi_led_opt_blinkon(&info);
+}
+
+static VOID mmi_LanLedBlueOn()
+{
+	mmi_led_opt_on(LED_LAN_BLUE_BRIGHTNESS);
+}
+
+static VOID mmi_LanLedBlueBlink(T_zMmi_Led_Blink_Time time)
+{
+	T_zMmi_LedBlink_Info info = {0};
+	info.fileblinkSwitch = LED_LAN_BLUE_BLINKSWITCH;
+	info.fileblinktimeoff = LED_LAN_BLUE_BLINKTIMEOFF;
+	info.fileblinktimeon = LED_LAN_BLUE_BLINKTIMEON;
+	info.timeon = (char *)time.uBlinkOnTime;
+	info.timoff = (char *)time.uBlinkOffTime;
+	mmi_led_opt_on(LED_LAN_BLUE_BRIGHTNESS);
+	mmi_led_opt_blinkon(&info);
+}
+
+static VOID mmi_LanLedOnOpt(MMI_LED_COLOR color)
+{
+	MMI_LED_LASTSTATE lan_sta = mmi_getLanLedState();
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_LanLedOnOpt lan_sta = %d!\n", lan_sta);
+	if (color == LED_COLOR_GREEN) {
+		if (lan_sta == LED_GREEN_ON) {
+			return;
+		} else {
+			mmi_LanLedOffOpt(color);
+			mmi_LanLedGreenOn();
+		}
+		mmi_setLanLedState(LED_GREEN_ON);
+	} else if (color == LED_COLOR_BLUE) {
+		if (lan_sta == LED_BLUE_ON) {
+			return;
+		} else {
+			mmi_LanLedOffOpt(color);
+			mmi_LanLedBlueOn();
+		}
+		mmi_setLanLedState(LED_BLUE_ON);
+	} else {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_LanLedOnOpt invalid color!!\n");
+	}
+}
+
+static VOID mmi_LanLedBlinkOpt(MMI_LED_COLOR color, T_zMmi_Led_Blink_Time time)
+{
+	MMI_LED_LASTSTATE lan_sta = mmi_getLanLedState();
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_LanLedBlinkOpt lan_sta = %d!\n", lan_sta);
+	if (color == LED_COLOR_GREEN) {
+		if (lan_sta == LED_GREEN_BLINK) {
+			return;
+		} else {
+			mmi_LanLedOffOpt(color);
+			mmi_LanLedGreenBlink(time);
+		}
+		mmi_setLanLedState(LED_GREEN_BLINK);
+	} else if (color == LED_COLOR_BLUE) {
+		if (lan_sta == LED_BLUE_BLINK) {
+			return;
+		} else {
+			mmi_LanLedOffOpt(color);
+			mmi_LanLedBlueBlink(time);
+		}
+		mmi_setLanLedState(LED_BLUE_BLINK);
+	} else {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_LanLedBlinkOpt invalid color!!\n");
+	}
+}
+static VOID mmi_processLanLed(MMI_LED_STATE state, MMI_LED_COLOR color, T_zMmi_Led_Blink_Time time)
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_processLanLed state=%d!\n", state);
+	switch (state) {
+	case LED_STATE_ON: {
+		mmi_LanLedOnOpt(color);
+		break;
+	}
+	case LED_STATE_OFF: {
+		mmi_LanLedOffOpt(color);
+		break;
+	}
+	case LED_STATE_BLINK: {
+		mmi_LanLedBlinkOpt(color, time);
+		break;
+	}
+	default: {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_processLanLed invalid state!\n");
+		break;
+	}
+	}
+}
+
+
+/********************************************************************************
+  ¶ÌÐŵƲÙ×÷
+**********************************************************************************/
+static VOID mmi_SmsLedOffOpt(MMI_LED_COLOR color)
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_SmsLedOffOpt!\n");
+	if (color == LED_COLOR_GREEN) {
+		mmi_led_opt_blinkoff(LED_SMS_GREEN_BLINKSWITCH);
+		mmi_led_opt_off(LED_SMS_GREEN_BRIGHTNESS);
+	} else if (color == LED_COLOR_BLUE) {
+		mmi_led_opt_blinkoff(LED_SMS_BLUE_BLINKSWITCH);
+		mmi_led_opt_off(LED_SMS_BLUE_BRIGHTNESS);
+	}
+	mmi_setSmsLedState(LED_ALL_OFF);
+}
+static VOID mmi_SmsLedGreenOn()
+{
+	mmi_led_opt_on(LED_SMS_GREEN_BRIGHTNESS);
+}
+
+static VOID mmi_SmsLedGreenBlink(T_zMmi_Led_Blink_Time time)
+{
+	T_zMmi_LedBlink_Info info = {0};
+	info.fileblinkSwitch = LED_SMS_GREEN_BLINKSWITCH;
+	info.fileblinktimeoff = LED_SMS_GREEN_BLINKTIMEOFF;
+	info.fileblinktimeon = LED_SMS_GREEN_BLINKTIMEON;
+	info.timeon = (char *)time.uBlinkOnTime;
+	info.timoff = (char *)time.uBlinkOffTime;
+	mmi_led_opt_on(LED_SMS_GREEN_BRIGHTNESS);
+	mmi_led_opt_blinkon(&info);
+}
+
+static VOID mmi_SmsLedBlueOn()
+{
+	mmi_led_opt_on(LED_SMS_BLUE_BRIGHTNESS);
+}
+
+static VOID mmi_SmsLedBlueBlink(T_zMmi_Led_Blink_Time time)
+{
+	T_zMmi_LedBlink_Info info = {0};
+	info.fileblinkSwitch = LED_SMS_BLUE_BLINKSWITCH;
+	info.fileblinktimeoff = LED_SMS_BLUE_BLINKTIMEOFF;
+	info.fileblinktimeon = LED_SMS_BLUE_BLINKTIMEON;
+	info.timeon = (char *)time.uBlinkOnTime;
+	info.timoff = (char *)time.uBlinkOffTime;
+	mmi_led_opt_on(LED_SMS_BLUE_BRIGHTNESS);
+	mmi_led_opt_blinkon(&info);
+}
+
+static VOID mmi_SmsLedOnOpt(MMI_LED_COLOR color)
+{
+	MMI_LED_LASTSTATE sms_sta = mmi_getSmsLedState();
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_SmsLedOnOpt  sms_sta = %d!\n", sms_sta);
+	if (color == LED_COLOR_GREEN) {
+		if (sms_sta == LED_GREEN_ON) {
+			return;
+		} else {
+			mmi_SmsLedOffOpt(color);
+			mmi_SmsLedGreenOn();
+		}
+		mmi_setSmsLedState(LED_GREEN_ON);
+	} else if (color == LED_COLOR_BLUE) {
+		if (sms_sta == LED_BLUE_ON) {
+			return;
+		} else {
+			mmi_SmsLedOffOpt(color);
+			mmi_SmsLedBlueOn();
+		}
+		mmi_setSmsLedState(LED_BLUE_ON);
+	} else {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_SmsLedOnOpt invalid color!!\n");
+	}
+}
+static VOID mmi_SmsLedBlinkOpt(MMI_LED_COLOR color, T_zMmi_Led_Blink_Time time)
+{
+	MMI_LED_LASTSTATE sms_sta = mmi_getSmsLedState();
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_SmsLedBlinkOpt sms_sta = %d!\n", sms_sta);
+	if (color == LED_COLOR_GREEN) {
+		if (sms_sta == LED_GREEN_BLINK) {
+			return;
+		} else {
+			mmi_SmsLedOffOpt(color);
+			mmi_SmsLedGreenBlink(time);
+		}
+		mmi_setSmsLedState(LED_GREEN_BLINK);
+	} else if (color == LED_COLOR_BLUE) {
+		if (sms_sta == LED_BLUE_BLINK) {
+			return;
+		} else {
+			mmi_SmsLedOffOpt(color);
+			mmi_SmsLedBlueBlink(time);
+		}
+		mmi_setSmsLedState(LED_BLUE_BLINK);
+	} else {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_SmsLedBlinkOpt invalid color!!\n");
+	}
+
+}
+static VOID mmi_processSmsLed(MMI_LED_STATE state, MMI_LED_COLOR color, T_zMmi_Led_Blink_Time time)
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_processSmsLed state=%d\n", state);
+	switch (state) {
+	case LED_STATE_ON: {
+		mmi_SmsLedOnOpt(color);
+		break;
+	}
+	case LED_STATE_OFF: {
+		mmi_SmsLedOffOpt(color);
+		break;
+	}
+	case LED_STATE_BLINK: {
+		mmi_SmsLedBlinkOpt(color, time);
+		break;
+	}
+	default: {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_processSmsLed invalid state!\n");
+		break;
+	}
+	}
+}
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:Á÷Á¿µÆ²Ù×÷
+***********************************************************************************/
+static VOID mmi_TrafficLedOnOpt(MMI_TRAFFIC_LED traffic)
+{
+	switch (traffic) {
+	case TRAFFIC_LED_1:
+		mmi_file_operate(TRAFFIC_LED_PATH, TRAFIIC_LED_1_ON);
+		break;
+	case TRAFFIC_LED_2:
+		mmi_file_operate(TRAFFIC_LED_PATH, TRAFIIC_LED_2_ON);
+		break;
+	case TRAFFIC_LED_3:
+		mmi_file_operate(TRAFFIC_LED_PATH, TRAFIIC_LED_3_ON);
+		break;
+	case TRAFFIC_LED_4:
+		mmi_file_operate(TRAFFIC_LED_PATH, TRAFIIC_LED_4_ON);
+		break;
+	case TRAFFIC_LED_5:
+		mmi_file_operate(TRAFFIC_LED_PATH, TRAFIIC_LED_5_ON);
+		break;
+	case TRAFFIC_LED_6:
+		mmi_file_operate(TRAFFIC_LED_PATH, TRAFIIC_LED_6_ON);
+		break;
+	case TRAFFIC_LED_7:
+		mmi_file_operate(TRAFFIC_LED_PATH, TRAFIIC_LED_7_ON);
+		break;
+	case TRAFFIC_LED_8:
+		mmi_file_operate(TRAFFIC_LED_PATH, TRAFIIC_LED_8_ON);
+		break;
+	case TRAFFIC_LED_9:
+		mmi_file_operate(TRAFFIC_LED_PATH, TRAFIIC_LED_9_ON);
+		break;
+	case TRAFFIC_LED_10:
+		mmi_file_operate(TRAFFIC_LED_PATH, TRAFIIC_LED_10_ON);
+		break;
+	default:
+		break;
+	}
+}
+
+static VOID mmi_TrafficLedBlinkOpt(MMI_TRAFFIC_LED traffic)
+{
+	switch (traffic) {
+	case TRAFFIC_LED_1:
+		mmi_file_operate(TRAFFIC_LED_PATH, TRAFIIC_LED_1_BLINK);
+		break;
+	case TRAFFIC_LED_2:
+		mmi_file_operate(TRAFFIC_LED_PATH, TRAFIIC_LED_2_BLINK);
+		break;
+	case TRAFFIC_LED_3:
+		mmi_file_operate(TRAFFIC_LED_PATH, TRAFIIC_LED_3_BLINK);
+		break;
+	case TRAFFIC_LED_4:
+		mmi_file_operate(TRAFFIC_LED_PATH, TRAFIIC_LED_4_BLINK);
+		break;
+	case TRAFFIC_LED_5:
+		mmi_file_operate(TRAFFIC_LED_PATH, TRAFIIC_LED_5_BLINK);
+		break;
+	case TRAFFIC_LED_6:
+		mmi_file_operate(TRAFFIC_LED_PATH, TRAFIIC_LED_6_BLINK);
+		break;
+	case TRAFFIC_LED_7:
+		mmi_file_operate(TRAFFIC_LED_PATH, TRAFIIC_LED_7_BLINK);
+		break;
+	case TRAFFIC_LED_8:
+		mmi_file_operate(TRAFFIC_LED_PATH, TRAFIIC_LED_8_BLINK);
+		break;
+	case TRAFFIC_LED_9:
+		mmi_file_operate(TRAFFIC_LED_PATH, TRAFIIC_LED_9_BLINK);
+		break;
+	case TRAFFIC_LED_10:
+		mmi_file_operate(TRAFFIC_LED_PATH, TRAFIIC_LED_10_BLINK);
+		break;
+	default:
+		break;
+	}
+}
+
+static VOID mmi_TrafficLedOffOpt()
+{
+	mmi_file_operate(TRAFFIC_LED_PATH, LED_TRAFFIC_ALL_OFF);
+}
+static VOID mmi_processTrafficLed(MMI_LED_STATE state, MMI_TRAFFIC_LED traffic)
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_processTrafficLed state = %d traffic = %d\n", state, traffic);
+	switch (state) {
+	case LED_STATE_ON:
+		mmi_TrafficLedOnOpt(traffic);
+		break;
+	case LED_STATE_BLINK:
+		mmi_TrafficLedBlinkOpt(traffic);
+		break;
+	case LED_STATE_OFF:
+		mmi_TrafficLedOffOpt();
+		break;
+	default:
+		break;
+
+	}
+}
+
+/********************************************************************************
+  ÓïÒôÌáʾµÆ²Ù×÷
+**********************************************************************************/
+static VOID mmi_VoipLedOffOpt(MMI_LED_COLOR color)
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_VoipLedOffOpt!\n");
+	if (color == LED_COLOR_BLUE) {
+		mmi_led_opt_blinkoff(LED_VOIP_BLUE_BLINKSWITCH);
+		mmi_led_opt_off(LED_VOIP_BLUE_BRIGHTNESS);
+	}
+	mmi_setVoipLedState(LED_ALL_OFF);
+}
+
+static VOID mmi_VoipLedBlueOn()
+{
+	mmi_led_opt_on(LED_VOIP_BLUE_BRIGHTNESS);
+}
+
+static VOID mmi_VoipLedBlueBlink(T_zMmi_Led_Blink_Time time)
+{
+	T_zMmi_LedBlink_Info info = {0};
+	info.fileblinkSwitch = LED_VOIP_BLUE_BLINKSWITCH;
+	info.fileblinktimeoff = LED_VOIP_BLUE_BLINKTIMEOFF;
+	info.fileblinktimeon = LED_VOIP_BLUE_BLINKTIMEON;
+	info.timeon = (char *)time.uBlinkOnTime;
+	info.timoff = (char *)time.uBlinkOffTime;
+	mmi_led_opt_on(LED_VOIP_BLUE_BRIGHTNESS);
+	mmi_led_opt_blinkon(&info);
+}
+
+static VOID mmi_VoipLedOnOpt(MMI_LED_COLOR color)
+{
+	MMI_LED_LASTSTATE voip_sta = mmi_getVoipLedState();
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_VoipLedOnOpt  voip_sta = %d!\n", voip_sta);
+	if (color == LED_COLOR_BLUE) {
+		if (voip_sta == LED_BLUE_ON) {
+			return;
+		} else {
+			mmi_VoipLedOffOpt(color);
+			mmi_VoipLedBlueOn();
+		}
+		mmi_setVoipLedState(LED_BLUE_ON);
+	} else {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_VoipLedOnOpt invalid color!!\n");
+	}
+}
+static VOID mmi_VoipLedBlinkOpt(MMI_LED_COLOR color, T_zMmi_Led_Blink_Time time)
+{
+	MMI_LED_LASTSTATE voip_sta = mmi_getVoipLedState();
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_VoipLedBlinkOpt voip_sta = %d!\n", voip_sta);
+	if (color == LED_COLOR_BLUE) {
+		if (voip_sta == LED_BLUE_BLINK) {
+			return;
+		} else {
+			mmi_VoipLedOffOpt(color);
+			mmi_VoipLedBlueBlink(time);
+		}
+		mmi_setVoipLedState(LED_BLUE_BLINK);
+	} else {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_VoipLedBlinkOpt invalid color!!\n");
+	}
+
+}
+static VOID mmi_processVoipLed(MMI_LED_STATE state, MMI_LED_COLOR color, T_zMmi_Led_Blink_Time time)
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_processVoipLed state=%d\n", state);
+	switch (state) {
+	case LED_STATE_ON: {
+		mmi_VoipLedOnOpt(color);
+		break;
+	}
+	case LED_STATE_OFF: {
+		mmi_VoipLedOffOpt(color);
+		break;
+	}
+	case LED_STATE_BLINK: {
+		mmi_VoipLedBlinkOpt(color, time);
+		break;
+	}
+	default: {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_processVoipLed invalid state!\n");
+		break;
+	}
+	}
+}
+
+/********************************************************************************
+  ÐźÅÇ¿¶ÈÌáʾµÆ²Ù×÷ Ò¢Ô¶cpe
+**********************************************************************************/
+static MMI_LED_LASTSTATE mmi_getSignalLedState(VOID)
+{
+	MMI_LED_LASTSTATE state;
+	state = g_mmi_signalled_state;
+	return state;
+}
+
+static VOID mmi_setSignalLedState(MMI_LED_LASTSTATE sig_state)
+{
+	g_mmi_signalled_state = sig_state;
+}
+
+static MMI_LED_LASTSTATE mmi_transSignalLedState(MMI_TRAFFIC_LED traffic)
+{
+	MMI_LED_LASTSTATE state;
+    switch (traffic)
+    {
+    	case TRAFFIC_LED_1:
+	        state = LED_BLUE1_ON;
+	        break;
+
+    	case TRAFFIC_LED_2:
+	        state = LED_BLUE2_ON;
+	        break;
+
+		case TRAFFIC_LED_3:
+	        state = LED_BLUE3_ON;
+	        break;
+
+		case TRAFFIC_LED_4:
+	        state = LED_BLUE4_ON;
+	        break;
+
+		case TRAFFIC_LED_5:
+	        state = LED_BLUE5_ON;
+	        break;
+
+		case TRAFFIC_LED_MAX:
+			state = LED_BLUE_BLINK;
+			break;
+
+    	default:
+	        state = LED_ALL_OFF;
+	        break;
+    }
+
+	return state;
+}
+
+
+static VOID mmi_SignalLedOffOpt(MMI_LED_COLOR color)
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_SignalLedOffOpt!\n");
+	if (color == LED_COLOR_BLUE) {
+		mmi_led_opt_blinkoff(LED_SIGNAL1_BLUE_BLINKSWITCH);
+		mmi_led_opt_off(LED_SIGNAL1_BLUE_BRIGHTNESS);
+		mmi_led_opt_off(LED_SIGNAL2_BLUE_BRIGHTNESS);
+		mmi_led_opt_off(LED_SIGNAL3_BLUE_BRIGHTNESS);
+		mmi_led_opt_off(LED_SIGNAL4_BLUE_BRIGHTNESS);
+		mmi_led_opt_off(LED_SIGNAL5_BLUE_BRIGHTNESS);
+	}
+	mmi_setSignalLedState(LED_ALL_OFF);
+}
+
+static VOID mmi_SignalLedBlueOn(MMI_LED_LASTSTATE state)
+{
+	switch (state)
+    {
+    	case LED_BLUE1_ON:
+			mmi_led_opt_on(LED_SIGNAL1_BLUE_BRIGHTNESS);
+	        break;
+
+    	case LED_BLUE2_ON:
+	        mmi_led_opt_on(LED_SIGNAL1_BLUE_BRIGHTNESS);
+			mmi_led_opt_on(LED_SIGNAL2_BLUE_BRIGHTNESS);
+	        break;
+
+		case LED_BLUE3_ON:
+	        mmi_led_opt_on(LED_SIGNAL1_BLUE_BRIGHTNESS);
+			mmi_led_opt_on(LED_SIGNAL2_BLUE_BRIGHTNESS);
+			mmi_led_opt_on(LED_SIGNAL3_BLUE_BRIGHTNESS);
+	        break;
+
+		case LED_BLUE4_ON:
+	        mmi_led_opt_on(LED_SIGNAL1_BLUE_BRIGHTNESS);
+			mmi_led_opt_on(LED_SIGNAL2_BLUE_BRIGHTNESS);
+			mmi_led_opt_on(LED_SIGNAL3_BLUE_BRIGHTNESS);
+			mmi_led_opt_on(LED_SIGNAL4_BLUE_BRIGHTNESS);
+	        break;
+
+		case LED_BLUE5_ON:
+	        mmi_led_opt_on(LED_SIGNAL1_BLUE_BRIGHTNESS);
+			mmi_led_opt_on(LED_SIGNAL2_BLUE_BRIGHTNESS);
+			mmi_led_opt_on(LED_SIGNAL3_BLUE_BRIGHTNESS);
+			mmi_led_opt_on(LED_SIGNAL4_BLUE_BRIGHTNESS);
+			mmi_led_opt_on(LED_SIGNAL5_BLUE_BRIGHTNESS);
+	        break;
+
+    	default:
+	        slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_SignalLedBlueOn  state = %d!\n", state);
+	        break;
+    }
+}
+
+static VOID mmi_SignalLedBlueBlink(T_zMmi_Led_Blink_Time time)
+{
+	T_zMmi_LedBlink_Info info = {0};
+	info.fileblinkSwitch = LED_SIGNAL1_BLUE_BLINKSWITCH;
+	info.fileblinktimeoff = LED_SIGNAL1_BLUE_BLINKTIMEON;
+	info.fileblinktimeon = LED_SIGNAL1_BLUE_BLINKTIMEOFF;
+	info.timeon = (char *)time.uBlinkOnTime;
+	info.timoff = (char *)time.uBlinkOffTime;
+	mmi_led_opt_on(LED_SIGNAL1_BLUE_BRIGHTNESS);
+	mmi_led_opt_blinkon(&info);
+}
+
+static VOID mmi_SignalLedOnOpt(MMI_LED_COLOR color, MMI_TRAFFIC_LED traffic)
+{
+	MMI_LED_LASTSTATE sig_sta = mmi_getSignalLedState();
+	MMI_LED_LASTSTATE traffic_trans = mmi_transSignalLedState(traffic);
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_SignalLedOnOpt  sig_sta = %d,%d!\n", sig_sta, traffic_trans);
+	if (color == LED_COLOR_BLUE) {
+		if (sig_sta == traffic_trans) {
+			return;
+		} else {
+			mmi_SignalLedOffOpt(color);
+			mmi_SignalLedBlueOn(traffic_trans);
+		}
+		mmi_setSignalLedState(traffic_trans);
+	} else {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_SignalLedOnOpt invalid color!!\n");
+	}
+}
+static VOID mmi_SignalLedBlinkOpt(MMI_LED_COLOR color, T_zMmi_Led_Blink_Time time)
+{
+	MMI_LED_LASTSTATE sig_sta = mmi_getSignalLedState();
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_SignalLedBlinkOpt voip_sta = %d!\n", sig_sta);
+	if (color == LED_COLOR_BLUE) {
+		if (sig_sta == LED_BLUE_BLINK) {
+			return;
+		} else {
+			mmi_SignalLedOffOpt(color);
+			mmi_SignalLedBlueBlink(time);
+		}
+		mmi_setSignalLedState(LED_BLUE_BLINK);
+	} else {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_SignalLedBlinkOpt invalid color!!\n");
+	}
+}
+
+static VOID mmi_processSignalLed(MMI_LED_STATE state, MMI_LED_COLOR color, T_zMmi_Led_Blink_Time time, MMI_TRAFFIC_LED traffic)
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_processSignalLed state=%d\n", state);
+	switch (state) {
+	case LED_STATE_ON: {
+		mmi_SignalLedOnOpt(color, traffic);
+		break;
+	}
+	case LED_STATE_OFF: {
+		mmi_SignalLedOffOpt(color);
+		break;
+	}
+	case LED_STATE_BLINK: {
+		mmi_SignalLedBlinkOpt(color, time);
+		break;
+	}
+	default: {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_processSignalLed invalid state!\n");
+		break;
+	}
+	}
+}
+
+/********************************************************************************
+  WPSµÆ²Ù×÷ Ò¢Ô¶cpe
+**********************************************************************************/
+static MMI_LED_LASTSTATE mmi_getWpsLedState(VOID)
+{
+	MMI_LED_LASTSTATE state;
+	state = g_mmi_wpsled_state;
+	return state;
+}
+
+static VOID mmi_setWpsLedState(MMI_LED_LASTSTATE sig_state)
+{
+	g_mmi_wpsled_state = sig_state;
+}
+
+static VOID mmi_WpsLedOffOpt(MMI_LED_COLOR color)
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_WpsLedOffOpt!\n");
+	if (color == LED_COLOR_BLUE) {
+		mmi_led_opt_blinkoff(LED_WPS_BLUE_BLINKSWITCH);
+		mmi_led_opt_off(LED_WPS_BLUE_BRIGHTNESS);
+	}
+	mmi_setWpsLedState(LED_ALL_OFF);
+}
+
+static VOID mmi_WpsLedBlueOn()
+{
+	mmi_led_opt_on(LED_WPS_BLUE_BRIGHTNESS);
+}
+
+static VOID mmi_WpsLedBlueBlink(T_zMmi_Led_Blink_Time time)
+{
+	T_zMmi_LedBlink_Info info = {0};
+	info.fileblinkSwitch = LED_WPS_BLUE_BLINKSWITCH;
+	info.fileblinktimeoff = LED_WPS_BLUE_BLINKTIMEON;
+	info.fileblinktimeon = LED_WPS_BLUE_BLINKTIMEOFF;
+	info.timeon = (char *)time.uBlinkOnTime;
+	info.timoff = (char *)time.uBlinkOffTime;
+	mmi_led_opt_on(LED_WPS_BLUE_BRIGHTNESS);
+	mmi_led_opt_blinkon(&info);
+}
+
+static VOID mmi_WpsLedOnOpt(MMI_LED_COLOR color)
+{
+	MMI_LED_LASTSTATE sig_sta = mmi_getWpsLedState();
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_WpsLedOnOpt  sig_sta = %d!\n", sig_sta);
+
+	if (color == LED_COLOR_BLUE) {
+		if (sig_sta == LED_BLUE_ON) {
+			return;
+		} else {
+			mmi_WpsLedOffOpt(color);
+			mmi_WpsLedBlueOn();
+		}
+		mmi_setWpsLedState(LED_BLUE_ON);
+	} else {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_WpsLedOnOpt invalid color!!\n");
+	}
+}
+static VOID mmi_WpsLedBlinkOpt(MMI_LED_COLOR color, T_zMmi_Led_Blink_Time time)
+{
+	MMI_LED_LASTSTATE sig_sta = mmi_getWpsLedState();
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_SignalLedBlinkOpt voip_sta = %d!\n", sig_sta);
+	if (color == LED_COLOR_BLUE) {
+		if (sig_sta == LED_BLUE_BLINK) {
+			return;
+		} else {
+			mmi_WpsLedOffOpt(color);
+			mmi_WpsLedBlueBlink(time);
+		}
+		mmi_setWpsLedState(LED_BLUE_BLINK);
+	} else {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_SignalLedBlinkOpt invalid color!!\n");
+	}
+}
+
+static VOID mmi_processWpsLed(MMI_LED_STATE state, MMI_LED_COLOR color, T_zMmi_Led_Blink_Time time)
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_processWpsLed state=%d\n", state);
+
+	switch (state) {
+	case LED_STATE_ON: {
+		mmi_WpsLedOnOpt(color);
+		break;
+	}
+	case LED_STATE_OFF: {
+		mmi_WpsLedOffOpt(color);
+		break;
+	}
+	case LED_STATE_BLINK: {
+		mmi_WpsLedBlinkOpt(color, time);
+		break;
+	}
+	default: {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_processWpsLed invalid state!\n");
+		break;
+	}
+	}
+}
+
+/********************************************************************************
+  rj11µÆ²Ù×÷ Ò¢Ô¶cpe
+**********************************************************************************/
+static MMI_LED_LASTSTATE mmi_getRj11LedState(VOID)
+{
+	MMI_LED_LASTSTATE state;
+	state = g_mmi_rj11led_state;
+	return state;
+}
+
+static VOID mmi_setRj11LedState(MMI_LED_LASTSTATE sig_state)
+{
+	g_mmi_rj11led_state = sig_state;
+}
+
+static VOID mmi_Rj11LedOffOpt(MMI_LED_COLOR color)
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_Rj11LedOffOpt!\n");
+	if (color == LED_COLOR_BLUE) {
+		mmi_led_opt_blinkoff(LED_RJ11_BLUE_BLINKSWITCH);
+		mmi_led_opt_off(LED_RJ11_BLUE_BRIGHTNESS);
+	}
+	mmi_setRj11LedState(LED_ALL_OFF);
+}
+
+static VOID mmi_Rj11LedBlueOn()
+{
+	mmi_led_opt_on(LED_RJ11_BLUE_BRIGHTNESS);
+}
+
+static VOID mmi_Rj11LedBlueBlink(T_zMmi_Led_Blink_Time time)
+{
+	T_zMmi_LedBlink_Info info = {0};
+	info.fileblinkSwitch = LED_RJ11_BLUE_BLINKSWITCH;
+	info.fileblinktimeoff = LED_RJ11_BLUE_BLINKTIMEON;
+	info.fileblinktimeon = LED_RJ11_BLUE_BLINKTIMEOFF;
+	info.timeon = (char *)time.uBlinkOnTime;
+	info.timoff = (char *)time.uBlinkOffTime;
+	mmi_led_opt_on(LED_RJ11_BLUE_BRIGHTNESS);
+	mmi_led_opt_blinkon(&info);
+}
+
+static VOID mmi_Rj11LedOnOpt(MMI_LED_COLOR color)
+{
+	MMI_LED_LASTSTATE sig_sta = mmi_getRj11LedState();
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_Rj11LedOnOpt  sig_sta = %d!\n", sig_sta);
+
+	if (color == LED_COLOR_BLUE) {
+		if (sig_sta == LED_BLUE_ON) {
+			return;
+		} else {
+			mmi_Rj11LedOffOpt(color);
+			mmi_Rj11LedBlueOn();
+		}
+		mmi_setRj11LedState(LED_BLUE_ON);
+	} else {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_Rj11LedOnOpt invalid color!!\n");
+	}
+}
+static VOID mmi_Rj11LedBlinkOpt(MMI_LED_COLOR color, T_zMmi_Led_Blink_Time time)
+{
+	MMI_LED_LASTSTATE sig_sta = mmi_getRj11LedState();
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_Rj11LedBlinkOpt voip_sta = %d!\n", sig_sta);
+	if (color == LED_COLOR_BLUE) {
+		if (sig_sta == LED_BLUE_BLINK) {
+			return;
+		} else {
+			mmi_Rj11LedOffOpt(color);
+			mmi_Rj11LedBlueBlink(time);
+		}
+		mmi_setRj11LedState(LED_BLUE_BLINK);
+	} else {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_Rj11LedBlinkOpt invalid color!!\n");
+	}
+}
+
+static VOID mmi_processRj11Led(MMI_LED_STATE state, MMI_LED_COLOR color, T_zMmi_Led_Blink_Time time)
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_processRj11Led state=%d\n", state);
+printf("ZTE_MMI mmi_processRj11Led state=%d\n", state);
+
+	switch (state) {
+	case LED_STATE_ON: {
+		mmi_Rj11LedOnOpt(color);
+		break;
+	}
+	case LED_STATE_OFF: {
+		mmi_Rj11LedOffOpt(color);
+		break;
+	}
+	case LED_STATE_BLINK: {
+		mmi_Rj11LedBlinkOpt(color, time);
+		break;
+	}
+	default: {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_processRj11Led invalid state!\n");
+		break;
+	}
+	}
+}
+
+/********************************************************************************
+  rj45µÆ²Ù×÷
+**********************************************************************************/
+static MMI_LED_LASTSTATE mmi_getRj45LedState(VOID)
+{
+	MMI_LED_LASTSTATE state;
+	state = g_mmi_rj45led_state;
+	return state;
+}
+
+static VOID mmi_setRj45LedState(MMI_LED_LASTSTATE sig_state)
+{
+	g_mmi_rj45led_state = sig_state;
+}
+
+static VOID mmi_Rj45LedOffOpt(MMI_LED_COLOR color)
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_Rj45LedOffOpt!\n");
+	if (color == LED_COLOR_GREEN) {
+		mmi_led_opt_blinkoff(LED_RJ45_GREEN_BLINKSWITCH);
+		mmi_led_opt_off(LED_RJ45_GREEN_BRIGHTNESS);
+	}
+	mmi_setRj45LedState(LED_ALL_OFF);
+}
+
+static VOID mmi_Rj45LedGreenOn()
+{
+	mmi_led_opt_on(LED_RJ45_GREEN_BRIGHTNESS);
+}
+
+static VOID mmi_Rj45LedGreenBlink(T_zMmi_Led_Blink_Time time)
+{
+	T_zMmi_LedBlink_Info info = {0};
+	info.fileblinkSwitch = LED_RJ45_GREEN_BLINKSWITCH;
+	info.fileblinktimeoff = LED_RJ45_GREEN_BLINKTIMEON;
+	info.fileblinktimeon = LED_RJ45_GREEN_BLINKTIMEOFF;
+	info.timeon = (char *)time.uBlinkOnTime;
+	info.timoff = (char *)time.uBlinkOffTime;
+	mmi_led_opt_on(LED_RJ45_GREEN_BRIGHTNESS);
+	mmi_led_opt_blinkon(&info);
+}
+
+static VOID mmi_Rj45LedOnOpt(MMI_LED_COLOR color)
+{
+	MMI_LED_LASTSTATE sig_sta = mmi_getRj45LedState();
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_Rj45LedOnOpt  sig_sta = %d!\n", sig_sta);
+
+	if (color == LED_COLOR_GREEN) {
+		if (sig_sta == LED_GREEN_ON) {
+			return;
+		} else {
+			mmi_Rj45LedOffOpt(color);
+			mmi_Rj45LedGreenOn();
+		}
+		mmi_setRj45LedState(LED_GREEN_ON);
+	} else {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_Rj45LedOnOpt invalid color!!\n");
+	}
+}
+static VOID mmi_Rj45LedBlinkOpt(MMI_LED_COLOR color, T_zMmi_Led_Blink_Time time)
+{
+	MMI_LED_LASTSTATE sig_sta = mmi_getRj45LedState();
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_Rj45LedBlinkOpt voip_sta = %d!\n", sig_sta);
+	if (color == LED_COLOR_GREEN) {
+		if (sig_sta == LED_GREEN_BLINK) {
+			return;
+		} else {
+			mmi_Rj45LedOffOpt(color);
+			mmi_Rj45LedGreenBlink(time);
+		}
+		mmi_setRj45LedState(LED_GREEN_BLINK);
+	} else {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_Rj45LedBlinkOpt invalid color!!\n");
+	}
+}
+
+static VOID mmi_processRj45Led(MMI_LED_STATE state, MMI_LED_COLOR color, T_zMmi_Led_Blink_Time time)
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_processRj45Led state=%d\n", state);
+	printf("ZTE_MMI mmi_processRj45Led state=%d\n", state);
+
+	switch (state) {
+	case LED_STATE_ON: {
+		mmi_Rj45LedOnOpt(color);
+		break;
+	}
+	case LED_STATE_OFF: {
+		mmi_Rj45LedOffOpt(color);
+		break;
+	}
+	case LED_STATE_BLINK: {
+		mmi_Rj45LedBlinkOpt(color, time);
+		break;
+	}
+	default: {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_processRj45Led invalid state!\n");
+		break;
+	}
+	}
+}
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:¿ª¹Ø»úʱËùÓеÆÈ«ÁÁÈ«Ãð²Ù×÷
+***********************************************************************************/
+static VOID mmi_processAllLed(MMI_LED_STATE state)
+{
+	switch (state) {
+	case LED_STATE_ON: {
+		mmi_file_operate(ALL_LED_PATH, LED_ALL_POWER_ON);
+		break;
+	}
+	case LED_STATE_OFF: {
+		mmi_file_operate(ALL_LED_PATH, LED_ALL_POWER_OFF);
+		break;
+	}
+	default:
+		break;
+	}
+}
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:µãµÆ²Ù×÷º¯Êý
+***********************************************************************************/
+VOID mmi_led_operate(T_zMmi_Led_Info *ledinfo)
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_led_operate ledname = %d state = %d color=%d,traffic=%d\n", ledinfo->led_name, ledinfo->led_state, ledinfo->led_color, ledinfo->traffic);
+	switch (ledinfo->led_name) {
+	case LED_BATTERY: {
+		mmi_processbBatteryLed(ledinfo->led_state, ledinfo->led_color, ledinfo->ledBlink_time);
+		break;
+	}
+	case LED_WAN: {
+		mmi_processWanLed(ledinfo->led_state, ledinfo->led_color, ledinfo->ledBlink_time, ledinfo->ledBlink_speed);
+		break;
+	}
+	case LED_LAN: {
+		mmi_processLanLed(ledinfo->led_state, ledinfo->led_color, ledinfo->ledBlink_time);
+		break;
+	}
+	case LED_SMS: {
+		mmi_processSmsLed(ledinfo->led_state, ledinfo->led_color, ledinfo->ledBlink_time);
+		break;
+	}
+	case LED_TRAFFIC: {
+		mmi_processTrafficLed(ledinfo->led_state, ledinfo->traffic);
+		break;
+	}
+	case LED_VOIP: {
+		mmi_processVoipLed(ledinfo->led_state, ledinfo->led_color, ledinfo->ledBlink_time);
+		break;
+	}
+	//yao yuan
+	case LED_SIGNAL: {
+		mmi_processSignalLed(ledinfo->led_state, ledinfo->led_color, ledinfo->ledBlink_time, ledinfo->traffic);
+		break;
+	}
+	case LED_WPS: {
+		mmi_processWpsLed(ledinfo->led_state, ledinfo->led_color, ledinfo->ledBlink_time);
+		break;
+	}
+	case LED_RJ11: {
+		mmi_processRj11Led(ledinfo->led_state, ledinfo->led_color, ledinfo->ledBlink_time);
+		break;
+	}
+	case LED_RJ45: {
+		mmi_processRj45Led(ledinfo->led_state, ledinfo->led_color, ledinfo->ledBlink_time);
+		break;
+	}
+	case LED_ALL: {
+		mmi_processAllLed(ledinfo->led_state);
+		break;
+	}
+	default: {
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_led_operate invalid ledname!\n");
+		break;
+	}
+	}
+}
+
diff --git a/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_net.c b/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_net.c
new file mode 100755
index 0000000..a440696
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_net.c
@@ -0,0 +1,387 @@
+/*****************************************************************************
+*  °æ±¾ËùÓÐ (C)ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾
+*  Ä£¿éÃû    £ºMMI
+*  ÎļþÃû    £ºmmi_net.c
+*  Îļþ±êʶ  £º
+*  Ïà¹ØÎļþ  £º
+*  ʵÏÖ¹¦ÄÜ  £ºMMI»ñÈ¡ÍøÂçÏà¹ØÐÅÏ¢
+*  ×÷Õß      £º
+*  °æ±¾      £ºV1.0
+*  Íê³ÉÈÕÆÚ  £º2014-6-20
+*  ÆäËü˵Ã÷  £º
+*
+*******************************************************************************/
+
+/*****************************************************************************
+*                       Í·Îļþ
+*******************************************************************************/
+#include <limits.h>
+
+#include "mmi_common.h"
+#include "mmi_lcd.h"
+
+/*****************************************************************************
+*                       È«¾Ö±äÁ¿¶¨Òå
+*******************************************************************************/
+#define NETWORKMODE_2G                      3
+#define NETWORKMODE_3G_5                    5
+#define NETWORKMODE_3G_15                   15
+#define NETWORKMODE_4G                      17
+#define NETTYPE_NO_SERVICE                  "No Service"
+#define NETTYPE_LIMITED_SERVICE             "Limited Service"
+#define NETTYPE_NULL                        ""
+#define NETTYPE_E                           "E"
+#define NETTYPE_G                           "G"
+#define NETTYPE_3G                          "3G"
+#define NETTYPE_4G                          "4G"
+#define NETTYPE_4G_LTE                      "LTE"
+#define PPP_STATUS_CONNECTED                "ppp_connected"
+#define PPP_STATUS_IPV6_CONNECTED           "ipv6_connected"
+#define PPP_STATUS_IPV4_IPV6_CONNECTED      "ipv4_ipv6_connected"
+
+static UINT32 NET_Connect_State  = 0;	//ÍøÂçÁ¬½Ó״̬
+static UINT32 NET_MutilConnect_State  = 0;	//¶à·PDP¼¤»î×´Ì¬ÍøÂçÁ¬½Ó״̬
+static UINT32 NET_Signal_num = 0;       //ÍøÂçÐźŸñÊý  LCDʹÓÃ
+static UINT32 NET_Signal_Weak = 1;   	//ÍøÂçÐźűäÈõ״̬ LEDʹÓà 0-weak, 1-normal, 2-strong
+static UINT32 NET_Roam_Mode = 0;    	//ÂþÓÎģʽ
+static UINT32 NET_Socket_State = NET_SOCKET_INACTIVE;     //SOCKETÊÇ·ñ½¨Á¢Á¬½Ó״̬
+static UINT32 NET_McuSocket_State = NET_SOCKET_INACTIVE;     //SOCKETÊÇ·ñ½¨Á¢Á¬½Ó״̬
+
+struct list_head g_mmi_socket_queue;//·¢Ëͽ¨Á¢SOCKETÁ¬½ÓÏûÏ¢µÄÄ£¿éÁ´±í
+struct list_head g_mmi_multiconnect_queue;//·¢ËͶà·PDP¼¤»îÏûÏ¢µÄÄ£¿éÁ´±í
+
+static E_zMmi_Net_Mode s_mmi_net_mode = NET_MODE_DEFAULT;//ÍøÂçÖÆÊ½
+extern E_zMmiShowMode g_showMode;
+extern int g_customer_type;
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:·µ»ØÊÇ·ñÁªÍø×´Ì¬
+***********************************************************************************/
+BOOL mmi_net_connected()
+{
+	if (NET_Connect_State == 1 && s_mmi_net_mode != NET_MODE_NOSERVICE && s_mmi_net_mode != NET_MODE_LIMITSERVICE) { //e58
+		return TRUE;
+	}
+	return FALSE;
+}
+
+/**********************************************************************************
+*º¯Êý×÷ÓÃ:»ñÈ¡ÍøÂçÐÅÏ¢
+***********************************************************************************/
+SINT32 mmi_get_netinfo(UINT32 netinfo)
+{
+	if (netinfo != 0) {
+		T_zMMINetInfo * pNetInfo = (T_zMMINetInfo *)netinfo;
+		pNetInfo->net_mode = s_mmi_net_mode;
+		pNetInfo->connect_status = (E_zMmi_Net_State)NET_Connect_State;
+		pNetInfo->signal_num = NET_Signal_num;
+		pNetInfo->signal_weak = NET_Signal_Weak;
+		pNetInfo->roam_mode = NET_Roam_Mode;
+		pNetInfo->socket_state = NET_Socket_State || NET_McuSocket_State;
+	}
+	return MMI_SUCCESS;
+}
+
+SINT32 mmi_RegisterNetTaskInfoItem()
+{
+	T_zMMITaskInfoItem netTaskInfoItem = {0};
+	netTaskInfoItem.task = MMI_TASK_NET;
+	netTaskInfoItem.taskinfo = (VOID *)malloc(sizeof(T_zMMINetInfo));
+	netTaskInfoItem.get_taskinfo_fun = mmi_get_netinfo;
+	netTaskInfoItem.get_ledinfo_fun = mmi_getLedNetInfo;
+#ifndef DISABLE_LCD
+	netTaskInfoItem.get_lcdinfo_fun = mmi_getLcdNetInfo;
+#endif
+	netTaskInfoItem.ledinfo = (VOID *)malloc(sizeof(T_zMmi_Led_Info));
+	mmi_register_taskinfo_item(&netTaskInfoItem);
+	return MMI_SUCCESS;
+}
+
+SINT32 mmi_RegisterNetSigTaskInfoItem()
+{
+	T_zMMITaskInfoItem netTaskInfoItem = {0};
+	netTaskInfoItem.task = MMI_TASK_NETSIGNAL;
+	netTaskInfoItem.taskinfo = (VOID *)malloc(sizeof(T_zMMINetInfo));
+	netTaskInfoItem.get_taskinfo_fun = mmi_get_netinfo;
+	netTaskInfoItem.get_ledinfo_fun = mmi_getLedNetSigInfo;
+#ifndef DISABLE_LCD
+	//netTaskInfoItem.get_lcdinfo_fun = mmi_getLcdNetInfo;
+#endif
+	netTaskInfoItem.ledinfo = (VOID *)malloc(sizeof(T_zMmi_Led_Info));
+	mmi_register_taskinfo_item(&netTaskInfoItem);
+	return MMI_SUCCESS;
+}
+
+static VOID mmi_set_net_update()
+{
+	if (g_showMode == MMI_MODE_LCD || g_showMode == MMI_MODE_ALL) {
+		slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_set_net_update LCD!!!\n");
+		mmi_set_update_flag(MMI_TASK_NET);
+		mmi_set_update_flag(MMI_TASK_NETSIGNAL);
+	}
+	if (g_showMode == MMI_MODE_LED || g_showMode == MMI_MODE_ALL) {
+		E_zMmi_Work_Mode mode = mmi_get_led_mode();
+		slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_set_net_update LED mode=%d!!!\n",mode);
+		if(g_customer_type == CUSTOMER_GUODIAN || g_customer_type == CUSTOMER_NANDIAN){//guodian
+			mmi_set_update_flag(MMI_TASK_NET);
+		}else{
+			if (mode != MMI_RESET_MODE && mode != MMI_RESTART_MODE && mode != MMI_POWEROFF_MODE && mode != MMI_IDLE_LEDOFF_MODE && mode != MMI_IDLE_CHG_LEDOFF_MODE
+				&& mode != MMI_FAKE_POWEROFF_MODE && mode != MMI_FAKE_POWEROFF_CHARGE_MODE && mode != MMI_IDLE_STANDBY_LEDOFF_MODE) {
+				mmi_set_update_flag(MMI_TASK_NET);
+				mmi_set_update_flag(MMI_TASK_NETSIGNAL);
+			}
+		}
+	}
+}
+
+UINT32 mmi_get_net_state(VOID)
+{
+	return NET_Connect_State;
+}
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:SIM¿¨°Î³öʱ£¬Å¼ÏÖat_server²»Éϱ¨¶ÏÍø×´Ì¬£¬Ðè×ÔÐн«ÍøÂç״̬ÖÃΪ¶Ï¿ª×´Ì¬
+***********************************************************************************/
+VOID mmi_clean_net_state()
+{
+	s_mmi_net_mode = NET_MODE_NOSERVICE;
+	NET_Connect_State = 0;
+	mmi_set_net_update();
+	mmi_update_net_tip(NET_Connect_State, s_mmi_net_mode);
+}
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:¸ù¾ÝÍøÂçÁ¬½Ó״̬²Ù×÷ÍøÂçµÆ
+***********************************************************************************/
+SINT32 zMMI_Handle_Msg_Connect_Status(VOID *data)
+{
+	NET_Connect_State = *(UINT32*)data;//ÍøÂç״̬0-¶Ï¿ª£¬1-Á¬½Ó  2-Á¬½ÓÖÐ 3-¶Ï¿ªÖÐ
+	if(1 == NET_MutilConnect_State && 0 == NET_Connect_State){
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI svr_handle_msg_connect_status NET_Connect_State = %d\n", NET_Connect_State);
+		return 0;
+	}
+	slog(MMI_PRINT, SLOG_NORMAL, "ZTE_MMI svr_handle_msg_connect_status NET_Connect_State = %d\n", NET_Connect_State);
+	if (NET_Connect_State == 1 || NET_Connect_State == 0) {
+		mmi_set_net_update();
+		ipc_send_message(MODULE_ID_MMI, MODULE_ID_FLUXSTAT, MSG_CMD_CHANNEL_CONNECT_STATUS, sizeof(NET_Connect_State), (UCHAR *)&NET_Connect_State, 0);
+	}
+	mmi_update_net_tip(NET_Connect_State, s_mmi_net_mode);
+
+	return 0;
+}
+/**********************************************************************************
+º¯Êý×÷ÓÃ:¸ù¾Ý¶à·PDP¼¤»î״̬²Ù×÷ÍøÂçµÆ£¬,×¢Òâ¿ÉÄÜ»áÓжà¸ösocket_proxy½øÐжà·PDP¼¤»î
+***********************************************************************************/
+SINT32 zMMI_Handle_Msg_MultiConnect_Status(VOID *data, int src_id)
+{	
+	NET_MutilConnect_State = *(UINT32*)data;//ÍøÂç״̬0-¶Ï¿ª£¬1-Á¬½Ó  	
+	slog(MMI_PRINT, SLOG_NORMAL, "ZTE_MMI zMMI_Handle_Msg_MultiConnect_Status NET_MutilConnect_State = %d\n", NET_MutilConnect_State);
+
+	if(1 == NET_MutilConnect_State){
+		mmi_add_list(&g_mmi_multiconnect_queue, src_id);
+	}else{
+		mmi_del_list(&g_mmi_multiconnect_queue, src_id);
+	}
+	if(list_empty(&g_mmi_multiconnect_queue)) {
+		NET_MutilConnect_State = 0;
+	}else {
+		NET_MutilConnect_State = 1;
+	}
+	NET_Connect_State = NET_MutilConnect_State;
+	mmi_set_net_update();
+	ipc_send_message(MODULE_ID_MMI, MODULE_ID_FLUXSTAT, MSG_CMD_CHANNEL_CONNECT_STATUS, sizeof(NET_Connect_State), (UCHAR *)&NET_Connect_State, 0);
+
+	mmi_update_net_tip(NET_Connect_State, s_mmi_net_mode);
+
+	return 0;
+}
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:¸ù¾ÝÍøÂçÖÆÊ½²Ù×÷ÍøÂçµÆ
+***********************************************************************************/
+SINT32 zMMI_Handle_Msg_Network_Mode(VOID *data)
+{
+	SINT32 networkStatus = 0;
+	SINT32 networkMode = 0;
+	SINT32 netroamMode = 0;
+	networkMode = ((T_zAt_SysinfoRes*)data) ->sysMode;	//ÍøÂçÖÆÊ½
+	networkStatus = ((T_zAt_SysinfoRes*)data) ->srvStatus;//ÊÇ·ñÕý³£·þÎñ:0-ÎÞ·þÎñ 1-ÏÞÖÆ·þÎñ ÆäËû-Õý³£·þÎñ
+	netroamMode = ((T_zAt_SysinfoRes*)data) ->roamStatus;
+	slog(MMI_PRINT, SLOG_NORMAL, "ZTE_MMI svr_handle_msg_network_mode networkStatus = %d,networkMode=%d !!!\n", networkStatus, networkMode);
+
+	if (netroamMode == 1) {
+		NET_Roam_Mode = 1;
+	} else {
+		NET_Roam_Mode = 0;
+	}
+	if (networkStatus == 0) {
+		s_mmi_net_mode = NET_MODE_NOSERVICE;
+		mmi_update_net_tip(NET_Connect_State, s_mmi_net_mode);
+	} else if (networkStatus == 1) {
+		s_mmi_net_mode = NET_MODE_LIMITSERVICE;
+		mmi_update_net_tip(NET_Connect_State, s_mmi_net_mode);
+	} else {
+		if (NETWORKMODE_2G == networkMode) {
+			s_mmi_net_mode = NET_MODE_2G;
+		} else if ((NETWORKMODE_3G_5 == networkMode) || (NETWORKMODE_3G_15 == networkMode)) {
+			s_mmi_net_mode = NET_MODE_3G;
+		} else if (NETWORKMODE_4G == networkMode) {
+			s_mmi_net_mode = NET_MODE_4G;
+		} else {
+			s_mmi_net_mode = NET_MODE_NOSERVICE;
+		}
+		mmi_update_net_tip(NET_Connect_State, s_mmi_net_mode);
+	}
+	mmi_set_net_update();
+	return 0;
+}
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:ÍøÂçÐźűäÈõʱ´¦Àíº¯Êý
+***********************************************************************************/
+SINT32 zMMI_Handle_Msg_Signal_Num(VOID *data)
+{
+	UINT32 sig_num = 0;
+	sig_num = *(UINT32*)data;
+	slog(MMI_PRINT, SLOG_NORMAL, "ZTE_MMI svr_handle_msg_Signal_Num sig_num = %d\n", sig_num);
+	if (sig_num <= 1)
+	{
+		NET_Signal_Weak = 0;
+	}
+	else if (sig_num >= 4)
+	{
+		NET_Signal_Weak = 2;
+	}
+	else
+	{
+		NET_Signal_Weak = 1;
+	}
+	NET_Signal_num = sig_num;
+	mmi_set_net_update();
+	return 0;
+
+}
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:SIMcard °Î³ö»òδ²åÈë´¦Àíº¯Êý
+***********************************************************************************/
+SINT32 zMMI_Handle_Msg_Simcard_Info(VOID *data)
+{
+	UINT32 sig_num = 0;
+	sig_num = *(UINT32*)data;
+	slog(MMI_PRINT, SLOG_NORMAL, "ZTE_MMI zMMI_Handle_Msg_Simcard_Info sig_num = %d\n", sig_num);
+
+	if (g_showMode == MMI_MODE_LCD)
+		return 0;
+
+	mmi_clean_net_state();
+
+	return 0;
+
+}
+/**********************************************************************************
+º¯Êý×÷ÓÃ:SOCKETÁ¬½Ó״̬±ä»¯´¦Àíº¯Êý,×¢Òâ¿ÉÄÜ»áÓжà¸ösocket_proxy½¨Á¢SOCKETÁ¬½Ó
+***********************************************************************************/
+SINT32 zMMI_Handle_Msg_Socket_Status(VOID *data, int src_id)
+{
+	NET_Socket_State = *(UINT32*)data;//socket״̬0-¶Ï¿ª£¬1-Á¬½Ó 
+	slog(MMI_PRINT, SLOG_NORMAL, "ZTE_MMI zMMI_Handle_Msg_Socket_Status NET_Socket_State = %d\n", NET_Socket_State);
+	
+	if(1 == NET_Socket_State){
+		mmi_add_list(&g_mmi_socket_queue, src_id);
+	}else{
+		mmi_del_list(&g_mmi_socket_queue, src_id);
+	}
+	if(list_empty(&g_mmi_socket_queue)) {
+		NET_Socket_State = NET_SOCKET_INACTIVE;
+	}else {
+		NET_Socket_State = NET_SOCKET_ACTIVE;
+	}
+	mmi_set_net_update();
+	return 0;
+}
+/**********************************************************************************
+º¯Êý×÷ÓÃ:ÍâÖÃSOCKETÁ¬½Ó״̬±ä»¯´¦Àíº¯Êý
+***********************************************************************************/
+SINT32 zMMI_Handle_Msg_MCUSocket_Status(VOID *data)
+{
+	NET_McuSocket_State = *(UINT32*)data;//socket״̬0-¶Ï¿ª£¬1-Á¬½Ó 
+	slog(MMI_PRINT, SLOG_NORMAL, "ZTE_MMI zMMI_Handle_Msg_MCUSocket_Status NET_McuSocket_State = %d\n", NET_McuSocket_State);
+	if (NET_McuSocket_State == NET_SOCKET_INACTIVE || NET_McuSocket_State == NET_SOCKET_ACTIVE) {
+		mmi_set_net_update();		
+	}
+	return 0;
+}
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:³õʼ»¯ÍøÂçָʾµÆ
+***********************************************************************************/
+static VOID mmi_init_wan_led(VOID)
+{
+	CHAR nettype[20] = {0};
+	CHAR netstate[20] = {0};
+	CHAR signal_num[2] = {0};
+	UINT32 tmp_signal_num = 0;
+
+	cfg_get_item(NV_NETWORK_TYPE, nettype, 20);
+	cfg_get_item(NV_PPP_STATUS, netstate, 20);
+	cfg_get_item(NV_SIGNALBAR, signal_num, 2);
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_init_wan_led nettype = %s netstate = %s signal_num = %s\n", nettype, netstate, signal_num);
+	if (!strncmp(nettype, NETTYPE_LIMITED_SERVICE, strlen(NETTYPE_LIMITED_SERVICE))) {
+		s_mmi_net_mode = NET_MODE_LIMITSERVICE;
+	} else if ((!strncmp(nettype, NETTYPE_G, 1)) || (!strncmp(nettype, NETTYPE_E, 1))) {
+		s_mmi_net_mode = NET_MODE_2G;
+	} else if (!strncmp(nettype, NETTYPE_3G, 2)) {
+		s_mmi_net_mode = NET_MODE_3G;
+	} else if (!strncmp(nettype, NETTYPE_4G, 2)) {
+		s_mmi_net_mode = NET_MODE_4G;
+	} else if (!strncmp(nettype, NETTYPE_4G_LTE, 3)) {
+		s_mmi_net_mode = NET_MODE_4G;
+	} else {
+		s_mmi_net_mode = NET_MODE_NOSERVICE;
+	}
+	if ((!strncmp(netstate, PPP_STATUS_CONNECTED, strlen(PPP_STATUS_CONNECTED))) || (!strncmp(netstate, PPP_STATUS_IPV6_CONNECTED, strlen(PPP_STATUS_IPV6_CONNECTED))) || (!strncmp(netstate, PPP_STATUS_IPV4_IPV6_CONNECTED, strlen(PPP_STATUS_IPV4_IPV6_CONNECTED)))) {
+		NET_Connect_State = 1;
+	} else {
+		NET_Connect_State = 0;
+	}
+	if (strlen(signal_num) == 0)
+	{
+		NET_Signal_Weak = 1;
+	}
+	else
+	{
+		int sig_num = atoi(signal_num);
+		if (sig_num <= 1)
+		{
+			NET_Signal_Weak = 0;
+		}
+		else if (sig_num >= 4)
+		{
+			NET_Signal_Weak = 2;
+		}
+		else
+		{
+			NET_Signal_Weak = 1;
+		}
+	}
+	//kw 3
+	tmp_signal_num = (strlen(signal_num) == 0 ? 0 : atoi(signal_num));
+	if (tmp_signal_num > INT_MAX-1) {
+		tmp_signal_num = 0;
+		slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI signal_num = %s\n", signal_num);
+	}
+	NET_Signal_num = tmp_signal_num;
+	mmi_update_net_tip(NET_Connect_State, s_mmi_net_mode);
+	mmi_set_net_update();
+}
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:ÍøÂçָʾµÆ³õʼ»¯
+***********************************************************************************/
+VOID mmi_net_init(VOID)
+{
+	INIT_LIST_HEAD(&g_mmi_socket_queue);
+	INIT_LIST_HEAD(&g_mmi_multiconnect_queue);
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_net_Led_Init finish !!\n");
+}
+
diff --git a/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_rj45.c b/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_rj45.c
new file mode 100755
index 0000000..0c29251
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/zte_mmi/mmi_rj45.c
@@ -0,0 +1,99 @@
+/*****************************************************************************
+*  °æ±¾ËùÓÐ (C)ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾
+*  Ä£¿éÃû    £ºMMI
+*  ÎļþÃû    £ºmmi_rj45.c
+*  Îļþ±êʶ  £º
+*  Ïà¹ØÎļþ  £º
+*  ʵÏÖ¹¦ÄÜ  £ºMMIÒÔÌ«ÍøÌáʾµÆ²Ù×÷
+*  ×÷Õß      £º
+*  °æ±¾      £ºV1.0
+*  Íê³ÉÈÕÆÚ  £º2024-8-28
+*  ÆäËü˵Ã÷  £º
+*
+*******************************************************************************/
+#include "mmi_common.h"
+//#include "mmi_lcd.h"
+
+extern E_zMmiShowMode g_showMode;
+
+static E_zMmi_Rj45_Status s_mmi_rj45_state = RJ45_STATUS_NOR;//±£´ærj45µÄµ±Ç°×´Ì¬
+static E_zMmi_Rj45_Status s_mmi_rj45_state_bak = RJ45_STATUS_NOR;
+
+SINT32 mmi_get_rj45info(UINT32 rj45info)
+{
+	if (rj45info != 0) {
+		T_zMmi_Rj45_Info * pRj45Info = (T_zMmi_Rj45_Info *)rj45info;
+		pRj45Info->rj45_sta = s_mmi_rj45_state;
+	}
+	return MMI_SUCCESS;
+}
+
+SINT32 mmi_RegisterRj45TaskInfoItem()
+{
+	T_zMMITaskInfoItem rj45TaskInfoItem = {0};
+	rj45TaskInfoItem.task = MMI_TASK_RJ45;
+	rj45TaskInfoItem.taskinfo = (VOID *)malloc(sizeof(T_zMmi_Rj45_Info));
+	rj45TaskInfoItem.get_taskinfo_fun = mmi_get_rj45info;
+	rj45TaskInfoItem.get_ledinfo_fun = mmi_getLedRj45Info;
+	rj45TaskInfoItem.ledinfo = (VOID *)malloc(sizeof(T_zMmi_Led_Info));
+	mmi_register_taskinfo_item(&rj45TaskInfoItem);
+	return MMI_SUCCESS;
+}
+
+static VOID mmi_set_rj45_update()
+{
+	if (g_showMode == MMI_MODE_LED || g_showMode == MMI_MODE_ALL) {
+		E_zMmi_Work_Mode mode = mmi_get_led_mode();
+		if (mode != MMI_IDLE_LEDOFF_MODE && mode != MMI_IDLE_CHG_LEDOFF_MODE
+		    && mode != MMI_FAKE_POWEROFF_MODE && mode != MMI_FAKE_POWEROFF_CHARGE_MODE && mode != MMI_IDLE_STANDBY_LEDOFF_MODE) {
+			mmi_set_update_flag(MMI_TASK_RJ45);
+		}
+	}
+}
+
+VOID mmi_get_rj45_status(VOID)
+{
+	char nv_rj45_state[16] = {0};
+	cfg_get_item("rj45_pluginstate", nv_rj45_state, sizeof(nv_rj45_state));
+	int state = atoi(nv_rj45_state);
+	if (0 == state) {
+		s_mmi_rj45_state = RJ45_STATUS_OUT;
+	} else {
+		s_mmi_rj45_state = RJ45_STATUS_IN;
+	}
+	slog(MMI_PRINT, SLOG_NORMAL, "ZTE_MMI mmi_get_rj45_status nv_rj45_state = %s s_mmi_rj45_state= %d !\n", nv_rj45_state, s_mmi_rj45_state);
+}
+
+SINT32 zMMI_Handle_Msg_Rj45_Status(VOID * data)
+{
+	slog(MMI_PRINT, SLOG_NORMAL, "ZTE_MMI zMMI_Handle_Msg_Rj45_Status !\n");
+	mmi_get_rj45_status();
+	mmi_set_rj45_update();
+	return 0;
+}
+
+static VOID * mmi_get_rj45_info_timer_callback(VOID *arg)
+{
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_get_rj45_info_timer_callback!!!\n");
+	mmi_get_rj45_status();
+	if(s_mmi_rj45_state_bak != s_mmi_rj45_state)
+	{
+		s_mmi_rj45_state_bak = s_mmi_rj45_state;
+		mmi_set_rj45_update();
+	}
+	return NULL;
+}
+
+VOID mmi_rj45_init(VOID)
+{
+	int ret = -1;
+	mmi_get_rj45_status();
+	mmi_set_rj45_update();
+
+	ret = CreateSoftTimer(SET_RJ45_INFO_WAIT_TIMER, TIMER_FLAG_RESTART, SET_RJ45_INFO_WAIT_TIME, &mmi_get_rj45_info_timer_callback, NULL);
+	if (ret != 0) {
+		slog(MMI_PRINT, SLOG_ERR, " ZTE_MMI rj45 init Start Timer FAILED,cause=%d!!\n", ret);
+	}
+	slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_rj45_init finish!!!\n");
+}
+
diff --git a/lynq/S300/ap/app/zte_mifi/Makefile b/lynq/S300/ap/app/zte_mifi/Makefile
new file mode 100755
index 0000000..a9f8279
--- /dev/null
+++ b/lynq/S300/ap/app/zte_mifi/Makefile
@@ -0,0 +1,311 @@
+#*******************************************************************************

+# include ZTE application makefile

+#*******************************************************************************

+include $(zte_app_mak)

+#include ../net_team.mk

+include $(COMMON_MK)

+

+CPU_PUB_ROOT=$(TOPDIR_AP)/../pub

+##############USER COMIZE BEGIN################

+EXEC = zte_mifi 

+EXEC1 = zte-rtc-clock 

+EXEC2 = router_msg_proxy 

+OBJS = zte_mifi.o ../zte_comm/nvserver/nvserver.o  ../zte_comm/nvserver/nvupdate.o  \

+       $(patsubst %.c,%.o,$(wildcard ../zte_comm/at_ctl/src/atctrl/*.c ../zte_comm/at_ctl/src/atconfig/*.c ../zte_comm/at_ctl/src/phone/*.c ../zte_comm/at_ctl/src/phone/src/*.c)) \

+       ../zte_comm/rtc-service/rtc-service.o \

+       $(filter-out ../zte_comm/zte_mainctrl/router_msg_proxy.o,$(patsubst %.c,%.o,$(wildcard ../zte_comm/zte_mainctrl/*.c))) \

+       ../zte_comm/zte_hotplug/hotplug.o ../zte_comm/zte_hotplug/netdev_plug.o ../zte_comm/zte_hotplug/drv_plug.o \

+       $(patsubst %.c,%.o,$(wildcard ../zte_comm/zte_drv_ctrl/usb/*.c ../zte_comm/zte_drv_ctrl/serial/*.c)) \

+       ../zte_comm/fluxstat/fluxstat.o \

+       ../zte_comm/sntp/sntp.o \

+       ../zte_comm/schedule_restart/schedule_restart.o \

+       ../zte_comm/sd_hotplug/sd_hotplug.o ../zte_comm/sd_hotplug/sd_httpshare.o \

+       $(patsubst %.c,%.o,$(wildcard ../zte_comm/sms/src/*.c )) \

+       $(patsubst %.c,%.o,$(wildcard ../zte_comm/fota_dm/src/*.c )) \

+	   $(patsubst %.c,%.o,$(wildcard ../zte_comm/phonebook/src/*.c ))   ../zte_comm/zte_audio_ctrl/audio_res_ctrl.o

+

+OBJS1 = ../zte_comm/rtc-service/zte-rtc-clock.o

+OBJS2 = ../zte_comm/zte_mainctrl/router_msg_proxy.o

+

+ZTE_MMI_DEP = zte_mmi_app

+ZTE_MMI_TOBJS = mmi_adapter.o mmi.o mmi_battery.o mmi_net.o mmi_wifi.o mmi_tip.o mmi_sms.o mmi_lcd_page.o mmi_lcd.o mmi_lcd_init.o mmi_ctrl.o \

+		  mmi_keystrokes.o mmi_lcd_timer.o mmi_led.o mmi_led_init.o mmi_led_adapter.o mmi_poweroff_charger.o mmi_traffic.o mmi_fota.o mmi_msg.o \

+		  mmi_cfg.o mmi_poweroff.o mmi_battery_adapter.o mmi_mo.o mmi_mo_en.o mmi_mo_zh.o mmi_voip.o mmi_plat_adapter.o mmi_rj45.o

+ZTE_MMI_OBJS = $(addprefix ../zte_comm/zte_mmi/,$(ZTE_MMI_TOBJS))

+

+ZTE_LOCKNET_DEP = zte_locknet_app

+ZTE_LOCKNET_OBJS = $(patsubst %.c,%.o,$(wildcard ../zte_comm/zte_locknet/src/*.c ))

+

+ZTE_WATCHDOG_DEP = zte_watchdog_app

+ZTE_WATCHDOG_TOBJS = watchdog.o watchdog_adapter.o watchdog_battery.o

+ZTE_WATCHDOG_OBJS = $(addprefix ../zte_comm/zte_watchdog/,$(ZTE_WATCHDOG_TOBJS))

+

+#wifi

+ifeq ($(CONFIG_WIFI_MODULE),realtek)

+CFLAGS	 +=	-D__REALTEK_8192_CHIP__

+ifeq ($(CONFIG_WIFI_RTL_WPA2),yes)

+tools_dir += ../zte_comm/wlan/realtek_tools_wpa2/auth  ../zte_comm/wlan/realtek_tools_wpa2/mini_upnp ../zte_comm/wlan/realtek_tools_wpa2/utility

+tools_dir += ../zte_comm/wlan/realtek_tools_wpa2/wsc ../zte_comm/wlan/realtek_tools_wpa2/wireless_tools.25

+else

+tools_dir += ../zte_comm/wlan/realtek_tools/auth  ../zte_comm/wlan/realtek_tools/mini_upnp ../zte_comm/wlan/realtek_tools/utility

+tools_dir += ../zte_comm/wlan/realtek_tools/wsc ../zte_comm/wlan/realtek_tools/wireless_tools.25

+endif

+else ifeq ($(CONFIG_WIFI_MODULE),rda5995)

+CFLAGS	 += -D__RDA_5995_CHIP__

+tools_dir += ../zte_comm/wlan/rda_tools

+else ifeq ($(CONFIG_WIFI_MODULE),esp8089)

+CFLAGS	 += -D__ESP_8089_CHIP__

+tools_dir += ../zte_comm/wlan/esp_tools/eagle_test   ../zte_comm/wlan/esp_tools/fcctest

+else ifeq ($(CONFIG_WIFI_MODULE),xr819)

+CFLAGS	 += -D__XR_819_CHIP__

+#tools_dir +=

+else ifeq ($(CONFIG_WIFI_MODULE),ssv6x5x)

+CFLAGS	 += -D__SSV_6X5X_CHIP__

+#tools_dir +=

+else ifeq ($(CONFIG_WIFI_MODULE),aic8800)

+CFLAGS	 += -D__AIC_8800DW_CHIP__

+tools_dir += ../zte_comm/wlan/aic_tools/rftest

+ifeq ($(CONFIG_WIFI_SINGLEAP), no)

+CFLAGS  +=  -D__MULTI_AP__

+endif

+endif

+

+$(warning  CONFIG_WIFI_FUNCTION=$(CONFIG_WIFI_FUNCTION))

+

+ifeq ($(findstring sta,$(CONFIG_WIFI_FUNCTION)), sta)

+WLAN_STA_FUNC=yes

+endif

+

+ifeq ($(findstring ap,$(CONFIG_WIFI_FUNCTION)), ap)

+WLAN_AP_FUNC=yes

+endif

+

+CFLAGS 	 += -D__QRCODE_WIFI__

+CFLAGS 	 += -D__USE_AES__

+

+ifeq ($(WLAN_STA_FUNC),yes)

+CFLAGS += -D__STA_FUNC__

+ifneq ($(WLAN_AP_FUNC),yes)

+ifeq ($(CONFIG_WIFI_MODULE),aic8800)

+CFLAGS	 += -I$(zte_app_path)/wpa_supplicant-2.10/src/common

+LDLIBS   += -lwpa_client -L$(zte_app_path)/wpa_supplicant-2.10/wpa_supplicant

+else

+CFLAGS	 += -I$(zte_app_path)/wpa_supplicant-2.6/src/common

+LDLIBS   += -lwpa_client -L$(zte_app_path)/wpa_supplicant-2.6/wpa_supplicant

+endif

+endif

+endif

+ifeq ($(WLAN_AP_FUNC),yes)

+CFLAGS += -D__AP_FUNC__

+ifeq ($(CONFIG_WIFI_MODULE),aic8800)

+CFLAGS	 += -I$(zte_app_path)/hostapd-2.10/src/common

+LDLIBS   += -lwpa_client -L$(zte_app_path)/hostapd-2.10/hostapd

+else

+CFLAGS	 += -I$(zte_app_path)/hostapd-2.6/src/common

+LDLIBS   += -lwpa_client -L$(zte_app_path)/hostapd-2.6/hostapd

+endif

+endif

+

+OBJS +=  ../zte_comm/wlan/src/wlan_main.o ../zte_comm/wlan/src/wifi_socket.o ../zte_comm/wlan/src/wlan_rtc_sleep.o ../zte_comm/wlan/src/wifi_drv_ko.o \

+		  ../zte_comm/wlan/src/wifi_sta_ctrl.o ../zte_comm/wlan/src/wifi_util.o  ../zte_comm/wlan/src/wlan_config_ssid.o   ../zte_comm/wlan/src/wlan_netlink.o ../zte_comm/wlan/src/Vector.o

+ifeq ($(CONFIG_WIFI_MODULE),realtek)

+OBJS +=  ../zte_comm/wlan/src/wifi_hal.o

+	ifeq ($(WLAN_STA_FUNC),yes)

+		OBJS +=  ../zte_comm/wlan/src/wlan-station.o

+	endif

+LDLIBS   += -lwlan_interface

+LDLIBS   += -L$(zte_lib_path)/libwlan_interface

+else ifeq ($(CONFIG_WIFI_MODULE),rda5995)

+	ifeq ($(WLAN_STA_FUNC),yes)

+		OBJS += ../zte_comm/wlan/src/wlan_sta_manager.o  ../zte_comm/wlan/src/wlan_sm.o 

+	endif

+

+	ifeq ($(WLAN_AP_FUNC),yes)

+		OBJS += ../zte_comm/wlan/src/wifi_ap_ctrl.o

+LDLIBS   += -lwlan_interface

+LDLIBS   += -L$(zte_lib_path)/libwlan_interface

+	endif

+else ifeq ($(CONFIG_WIFI_MODULE),esp8089)

+	ifeq ($(WLAN_STA_FUNC),yes)

+		OBJS += ../zte_comm/wlan/src/wlan_sta_manager.o  ../zte_comm/wlan/src/wlan_sm.o 

+	endif

+

+	ifeq ($(WLAN_AP_FUNC),yes)

+		OBJS += ../zte_comm/wlan/src/wifi_ap_ctrl.o

+LDLIBS   += -lwlan_interface

+LDLIBS   += -L$(zte_lib_path)/libwlan_interface		

+	endif

+else ifeq ($(CONFIG_WIFI_MODULE),xr819)

+	ifeq ($(WLAN_STA_FUNC),yes)

+		OBJS += ../zte_comm/wlan/src/wlan_sta_manager.o  ../zte_comm/wlan/src/wlan_sm.o 

+	endif

+

+	ifeq ($(WLAN_AP_FUNC),yes)

+		OBJS += ../zte_comm/wlan/src/wifi_ap_ctrl.o

+LDLIBS   += -lwlan_interface

+LDLIBS   += -L$(zte_lib_path)/libwlan_interface		

+	endif

+else ifeq ($(CONFIG_WIFI_MODULE),ssv6x5x)

+	ifeq ($(WLAN_STA_FUNC),yes)

+		OBJS += ../zte_comm/wlan/src/wlan-station.o 

+	endif

+

+	ifeq ($(WLAN_AP_FUNC),yes)

+		OBJS += ../zte_comm/wlan/src/wifi_ap_ctrl.o

+LDLIBS   += -lwlan_interface

+LDLIBS   += -L$(zte_lib_path)/libwlan_interface		

+	endif

+else ifeq ($(CONFIG_WIFI_MODULE),aic8800)

+	ifeq ($(WLAN_STA_FUNC),yes)

+		OBJS += ../zte_comm/wlan/src/wlan-station.o 

+	endif

+

+	ifeq ($(WLAN_AP_FUNC),yes)

+		OBJS += ../zte_comm/wlan/src/wifi_ap_ctrl.o

+LDLIBS   += -lwlan_interface

+LDLIBS   += -L$(zte_lib_path)/libwlan_interface		

+	endif

+endif

+#aes

+CFLAGS += -I$(zte_lib_path)/libssl/install/include

+LDLIBS += -L$(zte_lib_path)/libssl/install/lib -lcrypto

+

+

+#*******************************************************************************

+# include path

+#*******************************************************************************

+CFLAGS += -I./

+CFLAGS += -I../include

+CFLAGS += -I../zte_comm/nvserver

+CFLAGS += -I$(LIB_DIR)/libnvram

+CFLAGS += -I$(APP_DIR)/include                                                   

+CFLAGS += -g -Werror=implicit-function-declaration 

+

+CFLAGS += -I../zte_comm/zte_hotplug

+CFLAGS += -I../zte_comm/at_ctl/inc

+CFLAGS += -I../zte_comm/at_ctl/src/phone/inc

+CFLAGS += -I$(zte_app_path)/include

+CFLAGS += -I$(zte_lib_path)/libatext

+CFLAGS += -I$(zte_lib_path)/libsqlite

+CFLAGS += -I$(zte_lib_path)/libnvram

+CFLAGS += -I$(LINUX_DIR)

+CFLAGS += -I$(zte_lib_path)/libzcore/std/inc/zCore/bl

+CFLAGS += -I$(zte_lib_path)/libzcore/std/inc/zCore/gui

+CFLAGS += -I$(CPU_PUB_ROOT)/project/zx297520v3/include/nv

+CFLAGS += -O -Dlinux=1 -DHIGH_SPEED=1

+

+

+CFLAGS += -I$(zte_lib_path)/libsoftap

+#CFLAGS += -I.

+

+

+CFLAGS += -I$(zte_lib_path)/libsoft_timer

+

+CFLAGS += -I../zte_comm/sms/inc

+CFLAGS += -I../zte_comm/phonebook/inc

+

+CFLAGS	 += -I../zte_comm/wlan/inc

+

+

+CFLAGS	+= -I../zte_comm/fota_dm/inc

+#CFLAGS 	+= -I../zte_comm/fota_dm/gs_lib

+CFLAGS 	+= -I../zte_comm/fota_dm/rs_lib

+CFLAGS 	+= -I$(zte_lib_path)/libzte_dmapp/inc

+

+#*******************************************************************************

+# library

+#*******************************************************************************

+LDLIBS += -lnvram -L$(zte_lib_path)/libnvram -lpthread

+ifeq ($(LINUX_TYPE),uClinux)

+LDFLAGS += -Wl,--allow-multiple-definition,-elf2flt=-s131072

+endif

+

+

+LDLIBS  += -lsoftap -L$(zte_lib_path)/libsoftap

+LDLIBS  += -lsoft_timer -L$(zte_lib_path)/libsoft_timer

+LDLIBS  += -latutils -L$(zte_lib_path)/libatutils

+LDLIBS  += -lsqlite -L$(zte_lib_path)/libsqlite

+LDLIBS  += -latext -L$(zte_lib_path)/libatext

+LDLIBS  += -lm

+#LDLIBS  += -ltinyalsa -L$(zte_lib_path)/libtinyalsa

+LDLIBS  += -lcpnv -L$(zte_lib_path)/libcpnv

+LDLIBS  += -lamt -L$(zte_lib_path)/libamt

+LDLIBS  += -lkey -L$(zte_lib_path)/libkey

+

+LDLIBS  += -lcurl -L$(zte_lib_path)/libcurl/install/lib

+

+ifneq ($(CONFIG_MMI_LCD),no)

+LDLIBS += -lzcore

+LDLIBS += -lrt

+ifeq ($(USE_TTF_FONT), yes)

+LDLIBS += -lft2

+LDLIBS += -lttf_font

+else

+LDLIBS += -lbitmap_font

+endif

+LDLIBS += -L$(zte_lib_path)/libzcore/min

+ifeq ($(USE_TTF_FONT), yes)

+LDLIBS += -L$(zte_lib_path)/libzcore/min/prebuilts/freetype

+endif

+endif

+

+LDLIBS +=  -lztedmapp  -L$(zte_lib_path)/libzte_dmapp

+#LIBSHARE_GS =  ../zte_comm/fota_dm/gs_lib/libdmgr.so.1

+#LDLIBS +=  -L../zte_comm/fota_dm/gs_lib -ldmgr

+

+LIBSHARE_GS =  ../zte_comm/fota_dm/rs_lib/librsdlsdk.so

+LDLIBS +=  -L../zte_comm/fota_dm/rs_lib -lrsdlsdk

+LDLIBS1 += -lnvram -L$(zte_lib_path)/libnvram -lpthread

+LDLIBS1  += -lsoftap -L$(zte_lib_path)/libsoftap

+LDLIBS1  += -lsoft_timer -L$(zte_lib_path)/libsoft_timer

+

+##############USER COMIZE END##################

+

+all: $(EXEC) $(EXEC1) $(EXEC2)

+ifneq ($(tools_dir), )

+	for i in $(tools_dir) ; do $(MAKE) -C $$i || exit $?; done

+endif

+	(cd ../zte_comm/fota_dm/gs_lib;rm libdmgr.so;ln -s libdmgr.so.1  libdmgr.so; cd ../../../zte_comm)

+

+$(EXEC): $(OBJS) $(ZTE_MMI_DEP) $(ZTE_LOCKNET_DEP) $(ZTE_WATCHDOG_DEP)

+	$(CC) $(LDFLAGS) -o $@ $(OBJS) $(ZTE_MMI_OBJS) $(ZTE_LOCKNET_OBJS) $(ZTE_WATCHDOG_OBJS) -Wl,--start-group $(LDLIBS) -Wl,--end-group

+	@cp $@ $@.elf

+

+$(EXEC1): $(OBJS1)

+	$(CC) $(CFLAGS) -o $@ $(OBJS1) -Wl,--start-group $(LDLIBS1) -Wl,--end-group

+	@cp $@ $@.elf

+

+$(EXEC2): $(OBJS2)

+	$(CC) $(CFLAGS) -o $@ $(OBJS2) -Wl,--start-group $(LDLIBS1) -Wl,--end-group

+	@cp $@ $@.elf

+

+romfs:

+	$(ROMFSINST)  /sbin/$(EXEC)

+	$(ROMFSINST)  /sbin/$(EXEC1)

+	$(ROMFSINST)  /sbin/$(EXEC2)

+	$(ROMFSINST) $(LIBSHARE_GS) /lib/

+ifneq ($(tools_dir), )

+	for i in $(tools_dir) ; do $(MAKE) -C $$i romfs || exit $?; done

+endif

+

+clean:

+	-rm -f $(EXEC) *.elf *.gdb *.o

+	-rm -f $(EXEC1) *.elf *.gdb *.o

+	-rm -f $(EXEC2) *.elf *.gdb *.o

+	-find ../zte_comm/ -name \*.o -exec rm -rf {} \; 

+	-find . -name \*.o -exec rm -rf {} \;

+ifneq ($(tools_dir), )

+	for i in $(tools_dir) ; do $(MAKE) -C $$i clean || exit $?; done

+endif

+ifeq ($(CONFIG_USER_SINGLE_DM), zx)

+	rm -rf $(ROOTFS_DIR)//bin/$(EXEC_GS)

+endif

+

+$(ZTE_MMI_DEP):

+	${MAKE} -C ../zte_comm/zte_mmi lib

+

+$(ZTE_LOCKNET_DEP):

+	${MAKE} -C ../zte_comm/zte_locknet lib

+

+$(ZTE_WATCHDOG_DEP):

+	${MAKE} -C ../zte_comm/zte_watchdog lib

diff --git a/lynq/S300/ap/app/zte_mifi/zte_mifi.c b/lynq/S300/ap/app/zte_mifi/zte_mifi.c
new file mode 100755
index 0000000..93cd802
--- /dev/null
+++ b/lynq/S300/ap/app/zte_mifi/zte_mifi.c
@@ -0,0 +1,282 @@
+#define _GNU_SOURCE /**/
+
+#include <string.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <time.h>
+#include <syslog.h>
+#include <unistd.h>
+#include <errno.h>
+#include <signal.h>
+#include <netdb.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/sysctl.h>
+#include <net/if.h>
+#include <poll.h>
+#include <stddef.h>
+#include <linux/if_packet.h>
+#include <netinet/ether.h>
+#include <netinet/if_ether.h>
+#include <arpa/inet.h>
+#include <pthread.h>
+#include <zte_mifi.h>
+#include "softap_api.h"
+
+void nvserver_entry(void)
+{
+	nvserver_main(0,NULL);
+	return;
+}
+
+void at_ctl_entry(char *arg)
+{
+	//printf("at_ctl_entry boot:%s\n", arg);
+	char *argv[2];
+	argv[0] = NULL;
+	argv[1] = arg;
+
+	at_ctl_main(2, argv);
+	return;
+}
+
+void rtc_service_entry(char *arg)
+{
+	rtc_service_main(0,NULL);
+	return;
+}
+
+void zte_mainctrl_entry(char *arg)
+{
+	/*if (0 == strcmp(arg, "2")) {
+		char *argv[2];
+		argv[0] = NULL;
+		argv[1] = "poweroff_charger";
+
+		zte_mainctrl_main(2, argv);
+	} else {*/
+		zte_mainctrl_main(0,NULL);
+	//}
+
+	return;
+}
+
+void zte_hotplug_entry(char *arg)
+{
+	zte_hotplug_main(0,NULL);
+	return;
+}
+/*
+void zte_audio_res_ctrl_entry(char *arg)
+{
+	zte_audio_res_ctrl_main(0,NULL);
+	return;
+}
+*/
+void zte_drv_serial_ctrl_entry(char *arg)
+{
+	zte_drv_serial_ctrl_main();
+	return;
+}
+
+void zte_drv_usb_ctrl_entry(char *arg)
+{
+	if(arg)
+		zte_drv_usb_ctrl_main(3,NULL);
+	else
+		zte_drv_usb_ctrl_main(0,NULL);
+	return;
+}
+
+void zte_mmi_entry(char *arg)
+{
+	//printf("zte_mmi_entry boot:%s\n", arg);
+/*	if (0 == strcmp(arg, "2")) {
+		char *argv[2];
+		argv[0] = NULL;
+		argv[1] = "poweroff_charger";
+
+		zte_mmi_main(2, argv);
+	} else {*/
+		zte_mmi_main(0,NULL);
+	//}
+	return;
+}
+/*
+void zte_locknet_entry(char *arg)
+{
+	zte_locknet_main(0,NULL);
+	//return; //klocwork
+}
+*/
+void zte_watchdog_entry(char *arg)
+{
+	zte_watchdog_main(0,NULL);
+	return;
+}
+
+void fluxstat_entry(char *arg)
+{
+	fluxstat_main(0,NULL);
+	return;
+}
+
+void sntp_entry(char *arg)
+{
+	sntp_main(0,NULL);
+	return;
+}
+
+void schedule_restart_entry(char *arg)
+{
+	schedule_restart_main(0,NULL);
+	return;
+}
+
+/*
+void sd_hotplug_entry(char *arg)
+{
+	sd_hotplug_main(0,NULL);
+	return;
+}
+*/
+void sms_entry(char *arg)
+{
+	sms_main(0,NULL);
+}
+
+void phonebook_entry(char *arg)
+{
+	phonebook_main(0,NULL);
+	return;
+}
+
+void wlan_entry(char *arg)
+{
+	wlan_main(0,NULL);
+	return;
+}
+/*
+void fota_dm_entry(char *arg)
+{
+	fota_dm_main(0,NULL);
+}
+*/
+
+int main(int argc, char *argv[])
+{
+	int ret = 0;
+	/* nvserver */
+    pthread_t nvserver_thread_tid;
+    pthread_create(&nvserver_thread_tid, NULL, (void *)nvserver_entry, NULL);
+
+	/* zte_hotplug */
+	pthread_t zte_hotplug_thread_tid;
+	pthread_create(&zte_hotplug_thread_tid, NULL, (void *)zte_hotplug_entry, NULL);
+
+    /* zte_drv_serial_ctrl */
+	pthread_t zte_drv_serial_ctrl_thread_tid;
+	pthread_create(&zte_drv_serial_ctrl_thread_tid, NULL, (void *)zte_drv_serial_ctrl_entry, NULL);
+	if (0 == strcmp(argv[2], "amt")) {
+		ret = cfg_set("ver_mode", "0");
+		if(ret < 0)
+			printf("zte_mifi set vermode fail\n");
+		else
+			cfg_save();
+		printf("---set ver mode to 0\n");
+	}
+	/* zte_drv_usb_ctrl */
+	pthread_t zte_drv_usb_ctrl_thread_tid;
+
+	if (0 != strcmp(argv[2], "amt")) { //³äµç»òÕý³£¿ª»úģʽ
+		char LanEnable[10] = {0};
+		/* at_ctl */
+		pthread_t at_ctl_thread_tid;
+		pthread_create(&at_ctl_thread_tid, NULL, (void *)at_ctl_entry, argv[1]);
+		/* rtc_service */
+		pthread_t rtc_service_thread_tid;
+		pthread_create(&rtc_service_thread_tid, NULL, (void *)rtc_service_entry, NULL);
+		/* zte_mainctrl */
+		pthread_t zte_mainctrl_thread_tid;
+		pthread_create(&zte_mainctrl_thread_tid, NULL, (void *)zte_mainctrl_entry, argv[1]);
+
+		/* zte_audio_res_ctrl */
+		//pthread_t zte_audio_res_ctrl_thread_tid;
+		//pthread_create(&zte_audio_res_ctrl_thread_tid, NULL, (void *)zte_audio_res_ctrl_entry, NULL);
+
+		cfg_get_item("LanEnable", LanEnable, sizeof(LanEnable));
+		if(atoi(LanEnable) == 1) { //mifiÐÎ̬
+			/* zte_mmi */
+			pthread_t zte_mmi_thread_tid;
+			pthread_create(&zte_mmi_thread_tid, NULL, (void *)zte_mmi_entry, argv[1]);
+		}	
+
+		//if(0 != strcmp(argv[1], "2")){
+			pthread_create(&zte_drv_usb_ctrl_thread_tid, NULL, (void *)zte_drv_usb_ctrl_entry, NULL);
+
+			if(atoi(LanEnable) == 1) { //mifiÐÎ̬
+					/* zte_locknet */
+				//pthread_t zte_locknet_thread_tid;
+				//pthread_create(&zte_locknet_thread_tid, NULL, (void *)zte_locknet_entry, NULL);
+				/* fluxstat */
+
+
+				pthread_t fluxstat_thread_tid;
+				pthread_create(&fluxstat_thread_tid, NULL, (void *)fluxstat_entry, NULL);
+				/* sntp */
+				pthread_t sntp_thread_tid;
+				pthread_create(&sntp_thread_tid, NULL, (void *)sntp_entry, NULL);
+				/* schedule_restart */
+				pthread_t schedule_restart_thread_tid;
+				pthread_create(&schedule_restart_thread_tid, NULL, (void *)schedule_restart_entry, NULL);
+				/* sd_hotplug */
+				//pthread_t sd_hotplug_thread_tid;
+				//pthread_create(&sd_hotplug_thread_tid, NULL, (void *)sd_hotplug_entry, NULL);
+				//sd_hotplug_init();
+				/* sms */
+				pthread_t sms_thread_tid;
+				pthread_create(&sms_thread_tid, NULL, (void *)sms_entry, NULL);
+				/* phonebook */
+				//NV_NEED_SUPPORT_PB
+				pthread_t phonebook_thread_tid;
+				pthread_create(&phonebook_thread_tid, NULL, (void *)phonebook_entry, NULL);
+
+				/* wifi_manager */
+				pthread_t wlan_thread_tid;
+				pthread_create(&wlan_thread_tid, NULL, (void *)wlan_entry, NULL);
+
+			}	
+
+			/* fota_dm */
+			// pthread_t fota_dm_thread_tid;
+			// pthread_create(&fota_dm_thread_tid, NULL, (void *)fota_dm_entry, NULL);			
+/*		}else{
+			pthread_create(&zte_drv_usb_ctrl_thread_tid, NULL, (void *)zte_drv_usb_ctrl_entry, "poweroff_charger");
+		}*/
+
+
+		/* zte_watchdog */
+		pthread_t zte_watchdog_thread_tid;
+		pthread_create(&zte_watchdog_thread_tid, NULL, (void *)zte_watchdog_entry, NULL);
+	}
+	else
+	{
+		pthread_create(&zte_drv_usb_ctrl_thread_tid, NULL, (void *)zte_drv_usb_ctrl_entry, NULL);
+	}
+
+
+	while(1)
+	{
+		sleep(20);
+		//printf("zte app test -1 \n");
+	}
+
+	return 0;
+}
+
diff --git a/lynq/S300/ap/app/zte_mifi/zte_mifi.h b/lynq/S300/ap/app/zte_mifi/zte_mifi.h
new file mode 100755
index 0000000..7ef7ff6
--- /dev/null
+++ b/lynq/S300/ap/app/zte_mifi/zte_mifi.h
@@ -0,0 +1,60 @@
+/*******************************************************************************
+* °æÈ¨ËùÓÐ (C)2016, ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+* 
+* ÎļþÃû³Æ:     zte_mifi.h
+* Îļþ±êʶ:     zte_mifi.h
+* ÄÚÈÝÕªÒª:     mifiºÏ²¢Ó¦ÓÃÍ·Îļþ
+* ʹÓ÷½·¨:     #include <zte_mifi.h>
+* 
+* 
+*******************************************************************************/
+#ifndef _ZTE_MIFI_H
+#define _ZTE_MIFI_H
+
+/*******************************************************************************
+*                                   Í·Îļþ                                     *
+*******************************************************************************/
+
+
+/*******************************************************************************
+*                                   ºê¶¨Òå                                     *
+*******************************************************************************/
+    
+	
+/*******************************************************************************
+*                                Êý¾ÝÀàÐͶ¨Òå                                  *
+*******************************************************************************/
+
+
+/*******************************************************************************
+*                                È«¾Ö±äÁ¿ÉùÃ÷                                  *
+*******************************************************************************/
+
+
+/*******************************************************************************
+*                                È«¾Öº¯ÊýÉùÃ÷                                  *
+*******************************************************************************/
+int nvserver_main(int argc, char *argv[]);
+int at_ctl_main(int argc, char * argv[]);
+int rtc_service_main(int argc, char **argv);
+int zte_mainctrl_main(int argc, char * argv[]);
+int zte_hotplug_main(int argc, char * argv[]);
+int zte_audio_res_ctrl_main(int argc, char * argv[]);
+int zte_drv_serial_ctrl_main();
+int zte_drv_usb_ctrl_main(int argc, char* argv[]);
+int zte_mmi_main(int argc, char* argv[]);
+int zte_locknet_main(int argc, char* argv[]);
+int zte_watchdog_main(int argc, char * argv[]);
+int fluxstat_main(int argc, char * argv[]);
+int sntp_main(int argc, char * argv[]);
+int schedule_restart_main(int argc, char * argv[]);
+int sd_hotplug_init(viod);
+int sd_hotplug_main(int argc, char* argv[]);
+int sms_main(int argc, char* argv[]);
+int phonebook_main(int argc, char* argv[]);
+int wlan_main (int argc, char *argv[]);
+int fota_dm_main(int argc, char**argv);
+
+
+#endif
+
diff --git a/lynq/S300/ap/app/zte_webui/css/bt_strp.css b/lynq/S300/ap/app/zte_webui/css/bt_strp.css
new file mode 100755
index 0000000..841893e
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/css/bt_strp.css
@@ -0,0 +1,6200 @@
+html {
+  font-family: sans-serif;
+  -ms-text-size-adjust: 100%;
+  -webkit-text-size-adjust: 100%;
+}
+body {
+  margin: 0;
+}
+.progress {
+  overflow: hidden;
+  height: 20px;
+  margin-bottom: 20px;
+  background-color: #f5f5f5;
+  border-radius: 4px;
+  -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
+  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
+}
+.progress-bar {
+  float: left;
+  width: 0%;
+  height: 100%;
+  font-size: 12px;
+  line-height: 20px;
+  color: #ffffff;
+  text-align: center;
+  background-color: #428bca;
+  -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
+  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
+  -webkit-transition: width 0.6s ease;
+  -o-transition: width 0.6s ease;
+  transition: width 0.6s ease;
+}
+.progress-striped .progress-bar,
+.progress-bar-striped {
+  background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+  background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+  background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+  background-size: 40px 40px;
+}
+.progress.active .progress-bar,
+.progress-bar.active {
+  -webkit-animation: progress-bar-stripes 2s linear infinite;
+  -o-animation: progress-bar-stripes 2s linear infinite;
+  animation: progress-bar-stripes 2s linear infinite;
+}
+.progress-bar[aria-valuenow="0"] {
+  color: #777777;
+  min-width: 30px;
+  background-color: transparent;
+  background-image: none;
+  box-shadow: none;
+}
+.progress-bar-success {
+  background-color: #5cb85c;
+}
+.progress-striped .progress-bar-success {
+  background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+  background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+  background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+}
+.progress-bar-info {
+  background-color: #5bc0de;
+}
+.progress-striped .progress-bar-info {
+  background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+  background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+  background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+}
+.progress-bar-warning {
+  background-color: #f0ad4e;
+}
+.progress-striped .progress-bar-warning {
+  background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+  background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+  background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+}
+.progress-bar-danger {
+  background-color: #d9534f;
+}
+.progress-striped .progress-bar-danger {
+  background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+  background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+  background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+}
+
+* {
+  -webkit-box-sizing: border-box;
+  -moz-box-sizing: border-box;
+  box-sizing: border-box;
+}
+*:before,
+*:after {
+  -webkit-box-sizing: border-box;
+  -moz-box-sizing: border-box;
+  box-sizing: border-box;
+}
+html {
+  font-size: 10px;
+  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
+}
+body {
+  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+  font-size: 14px;
+  line-height: 1.42857143;
+  color: #333333;
+  background-color: #ffffff;
+}
+input,
+button,
+select,
+textarea {
+  font-family: inherit;
+  font-size: inherit;
+  line-height: inherit;
+}
+a {
+  color: #428bca;
+  text-decoration: none;
+}
+a:hover,
+a:focus {
+  color: #2a6496;
+  text-decoration: underline;
+}
+a:focus {
+  outline: thin dotted;
+  outline: 5px auto -webkit-focus-ring-color;
+  outline-offset: -2px;
+}
+figure {
+  margin: 0;
+}
+img {
+  vertical-align: middle;
+}
+.img-responsive,
+.thumbnail > img,
+.thumbnail a > img,
+.carousel-inner > .item > img,
+.carousel-inner > .item > a > img {
+  display: block;
+  width: 100% \9;
+  max-width: 100%;
+  height: auto;
+}
+.img-rounded {
+  border-radius: 6px;
+}
+.img-thumbnail {
+  padding: 4px;
+  line-height: 1.42857143;
+  background-color: #ffffff;
+  border: 1px solid #dddddd;
+  border-radius: 4px;
+  -webkit-transition: all 0.2s ease-in-out;
+  -o-transition: all 0.2s ease-in-out;
+  transition: all 0.2s ease-in-out;
+  display: inline-block;
+  width: 100% \9;
+  max-width: 100%;
+  height: auto;
+}
+.img-circle {
+  border-radius: 50%;
+}
+hr {
+  margin-top: 20px;
+  margin-bottom: 20px;
+  border: 0;
+  border-top: 1px solid #eeeeee;
+}
+.sr-only {
+  position: absolute;
+  width: 1px;
+  height: 1px;
+  margin: -1px;
+  padding: 0;
+  overflow: hidden;
+  clip: rect(0, 0, 0, 0);
+  border: 0;
+}
+.sr-only-focusable:active,
+.sr-only-focusable:focus {
+  position: static;
+  width: auto;
+  height: auto;
+  margin: 0;
+  overflow: visible;
+  clip: auto;
+}
+h1,
+h2,
+h3,
+h4,
+h5,
+h6,
+.h1,
+.h2,
+.h3,
+.h4,
+.h5,
+.h6 {
+  font-family: inherit;
+  font-weight: 500;
+  line-height: 1.1;
+  color: inherit;
+}
+h1 small,
+h2 small,
+h3 small,
+h4 small,
+h5 small,
+h6 small,
+.h1 small,
+.h2 small,
+.h3 small,
+.h4 small,
+.h5 small,
+.h6 small,
+h1 .small,
+h2 .small,
+h3 .small,
+h4 .small,
+h5 .small,
+h6 .small,
+.h1 .small,
+.h2 .small,
+.h3 .small,
+.h4 .small,
+.h5 .small,
+.h6 .small {
+  font-weight: normal;
+  line-height: 1;
+  color: #777777;
+}
+h1,
+.h1,
+h2,
+.h2,
+h3,
+.h3 {
+  margin-top: 20px;
+  margin-bottom: 10px;
+}
+h1 small,
+.h1 small,
+h2 small,
+.h2 small,
+h3 small,
+.h3 small,
+h1 .small,
+.h1 .small,
+h2 .small,
+.h2 .small,
+h3 .small,
+.h3 .small {
+  font-size: 65%;
+}
+h4,
+.h4,
+h5,
+.h5,
+h6,
+.h6 {
+  margin-top: 10px;
+  margin-bottom: 10px;
+}
+h4 small,
+.h4 small,
+h5 small,
+.h5 small,
+h6 small,
+.h6 small,
+h4 .small,
+.h4 .small,
+h5 .small,
+.h5 .small,
+h6 .small,
+.h6 .small {
+  font-size: 75%;
+}
+h1,
+.h1 {
+  font-size: 36px;
+}
+h2,
+.h2 {
+  font-size: 30px;
+}
+h3,
+.h3 {
+  font-size: 24px;
+}
+h4,
+.h4 {
+  font-size: 18px;
+}
+h5,
+.h5 {
+  font-size: 14px;
+}
+h6,
+.h6 {
+  font-size: 12px;
+}
+p {
+  margin: 0 0 10px;
+}
+.lead {
+  margin-bottom: 20px;
+  font-size: 16px;
+  font-weight: 300;
+  line-height: 1.4;
+}
+@media (min-width: 768px) {
+  .lead {
+    font-size: 21px;
+  }
+}
+small,
+.small {
+  font-size: 85%;
+}
+mark,
+.mark {
+  background-color: #fcf8e3;
+  padding: .2em;
+}
+.text-left {
+  text-align: left;
+}
+.text-right {
+  text-align: right;
+}
+.text-center {
+  text-align: center;
+}
+.text-justify {
+  text-align: justify;
+}
+.text-nowrap {
+  white-space: nowrap;
+}
+.text-lowercase {
+  text-transform: lowercase;
+}
+.text-uppercase {
+  text-transform: uppercase;
+}
+.text-capitalize {
+  text-transform: capitalize;
+}
+.text-muted {
+  color: #777777;
+}
+.text-primary {
+  color: #428bca;
+}
+a.text-primary:hover {
+  color: #3071a9;
+}
+.text-success {
+  color: #3c763d;
+}
+a.text-success:hover {
+  color: #2b542c;
+}
+.text-info {
+  color: #31708f;
+}
+a.text-info:hover {
+  color: #245269;
+}
+.text-warning {
+  color: #8a6d3b;
+}
+a.text-warning:hover {
+  color: #66512c;
+}
+.text-danger {
+  color: #a94442;
+}
+a.text-danger:hover {
+  color: #843534;
+}
+.bg-primary {
+  color: #fff;
+  background-color: #428bca;
+}
+a.bg-primary:hover {
+  background-color: #3071a9;
+}
+.bg-success {
+  background-color: #dff0d8;
+}
+a.bg-success:hover {
+  background-color: #c1e2b3;
+}
+.bg-info {
+  background-color: #d9edf7;
+}
+a.bg-info:hover {
+  background-color: #afd9ee;
+}
+.bg-warning {
+  background-color: #fcf8e3;
+}
+a.bg-warning:hover {
+  background-color: #f7ecb5;
+}
+.bg-danger {
+  background-color: #f2dede;
+}
+a.bg-danger:hover {
+  background-color: #e4b9b9;
+}
+.page-header {
+  padding-bottom: 9px;
+  margin: 40px 0 20px;
+  border-bottom: 1px solid #eeeeee;
+}
+ul,
+ol {
+  margin-top: 0;
+  margin-bottom: 10px;
+}
+ul ul,
+ol ul,
+ul ol,
+ol ol {
+  margin-bottom: 0;
+}
+.list-unstyled {
+  padding-left: 0;
+  list-style: none;
+}
+.list-inline {
+  padding-left: 0;
+  list-style: none;
+  margin-left: -5px;
+}
+.list-inline > li {
+  display: inline-block;
+  padding-left: 5px;
+  padding-right: 5px;
+}
+dl {
+  margin-top: 0;
+  margin-bottom: 20px;
+}
+dt,
+dd {
+  line-height: 1.42857143;
+}
+dt {
+  font-weight: bold;
+}
+dd {
+  margin-left: 0;
+}
+code,
+kbd,
+pre,
+samp {
+  font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
+}
+code {
+  padding: 2px 4px;
+  font-size: 90%;
+  color: #c7254e;
+  background-color: #f9f2f4;
+  border-radius: 4px;
+}
+kbd {
+  padding: 2px 4px;
+  font-size: 90%;
+  color: #ffffff;
+  background-color: #333333;
+  border-radius: 3px;
+  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.25);
+}
+kbd kbd {
+  padding: 0;
+  font-size: 100%;
+  box-shadow: none;
+}
+pre {
+  display: block;
+  padding: 9.5px;
+  margin: 0 0 10px;
+  font-size: 13px;
+  line-height: 1.42857143;
+  word-break: break-all;
+  word-wrap: break-word;
+  color: #333333;
+  background-color: #f5f5f5;
+  border: 1px solid #cccccc;
+  border-radius: 4px;
+  word-break: keep-all;
+  word-wrap: normal;
+}
+pre code {
+  padding: 0;
+  font-size: inherit;
+  color: inherit;
+  white-space: pre-wrap;
+  background-color: transparent;
+  border-radius: 0;
+}
+.pre-scrollable {
+  max-height: 340px;
+  overflow-y: scroll;
+}
+.container {
+  margin-right: auto;
+  margin-left: auto;
+  padding-left: 15px;
+  padding-right: 15px;
+}
+
+@media (min-width: 768px) {
+  .dl-horizontal dt {
+    float: left;
+    width: 160px;
+    clear: left;
+    text-align: right;
+    overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+  }
+  .dl-horizontal dd {
+    margin-left: 180px;
+  }
+}
+abbr[title],
+abbr[data-original-title] {
+  cursor: help;
+  border-bottom: 1px dotted #777777;
+}
+.initialism {
+  font-size: 90%;
+  text-transform: uppercase;
+}
+blockquote {
+  padding: 10px 20px;
+  margin: 0 0 20px;
+  font-size: 17.5px;
+  border-left: 5px solid #eeeeee;
+}
+blockquote p:last-child,
+blockquote ul:last-child,
+blockquote ol:last-child {
+  margin-bottom: 0;
+}
+blockquote footer,
+blockquote small,
+blockquote .small {
+  display: block;
+  font-size: 80%;
+  line-height: 1.42857143;
+  color: #777777;
+}
+blockquote footer:before,
+blockquote small:before,
+blockquote .small:before {
+  content: '\2014 \00A0';
+}
+.blockquote-reverse,
+blockquote.pull-right {
+  padding-right: 15px;
+  padding-left: 0;
+  border-right: 5px solid #eeeeee;
+  border-left: 0;
+  text-align: right;
+}
+.blockquote-reverse footer:before,
+blockquote.pull-right footer:before,
+.blockquote-reverse small:before,
+blockquote.pull-right small:before,
+.blockquote-reverse .small:before,
+blockquote.pull-right .small:before {
+  content: '';
+}
+.blockquote-reverse footer:after,
+blockquote.pull-right footer:after,
+.blockquote-reverse small:after,
+blockquote.pull-right small:after,
+.blockquote-reverse .small:after,
+blockquote.pull-right .small:after {
+  content: '\00A0 \2014';
+}
+blockquote:before,
+blockquote:after {
+  content: "";
+}
+address {
+  margin-bottom: 20px;
+  font-style: normal;
+  line-height: 1.42857143;
+}
+
+@media (min-width: 768px) {
+  .container {
+    width: 750px;
+  }
+}
+@media (min-width: 992px) {
+  .container {
+    width: 970px;
+  }
+}
+@media (min-width: 1200px) {
+  .container {
+    width: 1170px;
+  }
+}
+.container-fluid {
+  margin-right: auto;
+  margin-left: auto;
+  padding-left: 15px;
+  padding-right: 15px;
+}
+.row {
+  margin-left: -15px;
+  margin-right: -15px;
+}
+.col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12 {
+  position: relative;
+  min-height: 1px;
+  padding-left: 15px;
+  padding-right: 15px;
+}
+.col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12 {
+  float: left;
+}
+.col-xs-12 {
+  width: 100%;
+}
+.col-xs-11 {
+  width: 91.66666667%;
+}
+.col-xs-10 {
+  width: 83.33333333%;
+}
+.col-xs-9 {
+  width: 75%;
+}
+.col-xs-8 {
+  width: 66.66666667%;
+}
+.col-xs-7 {
+  width: 58.33333333%;
+}
+.col-xs-6 {
+  width: 50%;
+}
+.col-xs-5 {
+  width: 41.66666667%;
+}
+.col-xs-4 {
+  width: 33.33333333%;
+}
+.col-xs-3 {
+  width: 25%;
+}
+.col-xs-2 {
+  width: 16.66666667%;
+}
+.col-xs-1 {
+  width: 8.33333333%;
+}
+.col-xs-pull-12 {
+  right: 100%;
+}
+.col-xs-pull-11 {
+  right: 91.66666667%;
+}
+.col-xs-pull-10 {
+  right: 83.33333333%;
+}
+.col-xs-pull-9 {
+  right: 75%;
+}
+.col-xs-pull-8 {
+  right: 66.66666667%;
+}
+.col-xs-pull-7 {
+  right: 58.33333333%;
+}
+.col-xs-pull-6 {
+  right: 50%;
+}
+.col-xs-pull-5 {
+  right: 41.66666667%;
+}
+.col-xs-pull-4 {
+  right: 33.33333333%;
+}
+.col-xs-pull-3 {
+  right: 25%;
+}
+.col-xs-pull-2 {
+  right: 16.66666667%;
+}
+.col-xs-pull-1 {
+  right: 8.33333333%;
+}
+.col-xs-pull-0 {
+  right: auto;
+}
+.col-xs-push-12 {
+  left: 100%;
+}
+.col-xs-push-11 {
+  left: 91.66666667%;
+}
+.col-xs-push-10 {
+  left: 83.33333333%;
+}
+.col-xs-push-9 {
+  left: 75%;
+}
+.col-xs-push-8 {
+  left: 66.66666667%;
+}
+.col-xs-push-7 {
+  left: 58.33333333%;
+}
+.col-xs-push-6 {
+  left: 50%;
+}
+.col-xs-push-5 {
+  left: 41.66666667%;
+}
+.col-xs-push-4 {
+  left: 33.33333333%;
+}
+.col-xs-push-3 {
+  left: 25%;
+}
+.col-xs-push-2 {
+  left: 16.66666667%;
+}
+.col-xs-push-1 {
+  left: 8.33333333%;
+}
+.col-xs-push-0 {
+  left: auto;
+}
+.col-xs-offset-12 {
+  margin-left: 100%;
+}
+.col-xs-offset-11 {
+  margin-left: 91.66666667%;
+}
+.col-xs-offset-10 {
+  margin-left: 83.33333333%;
+}
+.col-xs-offset-9 {
+  margin-left: 75%;
+}
+.col-xs-offset-8 {
+  margin-left: 66.66666667%;
+}
+.col-xs-offset-7 {
+  margin-left: 58.33333333%;
+}
+.col-xs-offset-6 {
+  margin-left: 50%;
+}
+.col-xs-offset-5 {
+  margin-left: 41.66666667%;
+}
+.col-xs-offset-4 {
+  margin-left: 33.33333333%;
+}
+.col-xs-offset-3 {
+  margin-left: 25%;
+}
+.col-xs-offset-2 {
+  margin-left: 16.66666667%;
+}
+.col-xs-offset-1 {
+  margin-left: 8.33333333%;
+}
+.col-xs-offset-0 {
+  margin-left: 0%;
+}
+
+@media (min-width: 1200px) {
+  .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12 {
+    float: left;
+  }
+  .col-lg-12 {
+    width: 100%;
+  }
+  .col-lg-11 {
+    width: 91.66666667%;
+  }
+  .col-lg-10 {
+    width: 83.33333333%;
+  }
+  .col-lg-9 {
+    width: 75%;
+  }
+  .col-lg-8 {
+    width: 66.66666667%;
+  }
+  .col-lg-7 {
+    width: 58.33333333%;
+  }
+  .col-lg-6 {
+    width: 50%;
+  }
+  .col-lg-5 {
+    width: 41.66666667%;
+  }
+  .col-lg-4 {
+    width: 33.33333333%;
+  }
+  .col-lg-3 {
+    width: 25%;
+  }
+  .col-lg-2 {
+    width: 16.66666667%;
+  }
+  .col-lg-1 {
+    width: 8.33333333%;
+  }
+  .col-lg-pull-12 {
+    right: 100%;
+  }
+  .col-lg-pull-11 {
+    right: 91.66666667%;
+  }
+  .col-lg-pull-10 {
+    right: 83.33333333%;
+  }
+  .col-lg-pull-9 {
+    right: 75%;
+  }
+  .col-lg-pull-8 {
+    right: 66.66666667%;
+  }
+  .col-lg-pull-7 {
+    right: 58.33333333%;
+  }
+  .col-lg-pull-6 {
+    right: 50%;
+  }
+  .col-lg-pull-5 {
+    right: 41.66666667%;
+  }
+  .col-lg-pull-4 {
+    right: 33.33333333%;
+  }
+  .col-lg-pull-3 {
+    right: 25%;
+  }
+  .col-lg-pull-2 {
+    right: 16.66666667%;
+  }
+  .col-lg-pull-1 {
+    right: 8.33333333%;
+  }
+  .col-lg-pull-0 {
+    right: auto;
+  }
+  .col-lg-push-12 {
+    left: 100%;
+  }
+  .col-lg-push-11 {
+    left: 91.66666667%;
+  }
+  .col-lg-push-10 {
+    left: 83.33333333%;
+  }
+  .col-lg-push-9 {
+    left: 75%;
+  }
+  .col-lg-push-8 {
+    left: 66.66666667%;
+  }
+  .col-lg-push-7 {
+    left: 58.33333333%;
+  }
+  .col-lg-push-6 {
+    left: 50%;
+  }
+  .col-lg-push-5 {
+    left: 41.66666667%;
+  }
+  .col-lg-push-4 {
+    left: 33.33333333%;
+  }
+  .col-lg-push-3 {
+    left: 25%;
+  }
+  .col-lg-push-2 {
+    left: 16.66666667%;
+  }
+  .col-lg-push-1 {
+    left: 8.33333333%;
+  }
+  .col-lg-push-0 {
+    left: auto;
+  }
+  .col-lg-offset-12 {
+    margin-left: 100%;
+  }
+  .col-lg-offset-11 {
+    margin-left: 91.66666667%;
+  }
+  .col-lg-offset-10 {
+    margin-left: 83.33333333%;
+  }
+  .col-lg-offset-9 {
+    margin-left: 75%;
+  }
+  .col-lg-offset-8 {
+    margin-left: 66.66666667%;
+  }
+  .col-lg-offset-7 {
+    margin-left: 58.33333333%;
+  }
+  .col-lg-offset-6 {
+    margin-left: 50%;
+  }
+  .col-lg-offset-5 {
+    margin-left: 41.66666667%;
+  }
+  .col-lg-offset-4 {
+    margin-left: 33.33333333%;
+  }
+  .col-lg-offset-3 {
+    margin-left: 25%;
+  }
+  .col-lg-offset-2 {
+    margin-left: 16.66666667%;
+  }
+  .col-lg-offset-1 {
+    margin-left: 8.33333333%;
+  }
+  .col-lg-offset-0 {
+    margin-left: 0%;
+  }
+}
+
+@media (min-width: 768px) {
+  .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12 {
+    float: left;
+  }
+  .col-sm-12 {
+    width: 100%;
+  }
+  .col-sm-11 {
+    width: 91.66666667%;
+  }
+  .col-sm-10 {
+    width: 83.33333333%;
+  }
+  .col-sm-9 {
+    width: 75%;
+  }
+  .col-sm-8 {
+    width: 66.66666667%;
+  }
+  .col-sm-7 {
+    width: 58.33333333%;
+  }
+  .col-sm-6 {
+    width: 50%;
+  }
+  .col-sm-5 {
+    width: 41.66666667%;
+  }
+  .col-sm-4 {
+    width: 33.33333333%;
+  }
+  .col-sm-3 {
+    width: 25%;
+  }
+  .col-sm-2 {
+    width: 16.66666667%;
+  }
+  .col-sm-1 {
+    width: 8.33333333%;
+  }
+  .col-sm-pull-12 {
+    right: 100%;
+  }
+  .col-sm-pull-11 {
+    right: 91.66666667%;
+  }
+  .col-sm-pull-10 {
+    right: 83.33333333%;
+  }
+  .col-sm-pull-9 {
+    right: 75%;
+  }
+  .col-sm-pull-8 {
+    right: 66.66666667%;
+  }
+  .col-sm-pull-7 {
+    right: 58.33333333%;
+  }
+  .col-sm-pull-6 {
+    right: 50%;
+  }
+  .col-sm-pull-5 {
+    right: 41.66666667%;
+  }
+  .col-sm-pull-4 {
+    right: 33.33333333%;
+  }
+  .col-sm-pull-3 {
+    right: 25%;
+  }
+  .col-sm-pull-2 {
+    right: 16.66666667%;
+  }
+  .col-sm-pull-1 {
+    right: 8.33333333%;
+  }
+  .col-sm-pull-0 {
+    right: auto;
+  }
+  .col-sm-push-12 {
+    left: 100%;
+  }
+  .col-sm-push-11 {
+    left: 91.66666667%;
+  }
+  .col-sm-push-10 {
+    left: 83.33333333%;
+  }
+  .col-sm-push-9 {
+    left: 75%;
+  }
+  .col-sm-push-8 {
+    left: 66.66666667%;
+  }
+  .col-sm-push-7 {
+    left: 58.33333333%;
+  }
+  .col-sm-push-6 {
+    left: 50%;
+  }
+  .col-sm-push-5 {
+    left: 41.66666667%;
+  }
+  .col-sm-push-4 {
+    left: 33.33333333%;
+  }
+  .col-sm-push-3 {
+    left: 25%;
+  }
+  .col-sm-push-2 {
+    left: 16.66666667%;
+  }
+  .col-sm-push-1 {
+    left: 8.33333333%;
+  }
+  .col-sm-push-0 {
+    left: auto;
+  }
+  .col-sm-offset-12 {
+    margin-left: 100%;
+  }
+  .col-sm-offset-11 {
+    margin-left: 91.66666667%;
+  }
+  .col-sm-offset-10 {
+    margin-left: 83.33333333%;
+  }
+  .col-sm-offset-9 {
+    margin-left: 75%;
+  }
+  .col-sm-offset-8 {
+    margin-left: 66.66666667%;
+  }
+  .col-sm-offset-7 {
+    margin-left: 58.33333333%;
+  }
+  .col-sm-offset-6 {
+    margin-left: 50%;
+  }
+  .col-sm-offset-5 {
+    margin-left: 41.66666667%;
+  }
+  .col-sm-offset-4 {
+    margin-left: 33.33333333%;
+  }
+  .col-sm-offset-3 {
+    margin-left: 25%;
+  }
+  .col-sm-offset-2 {
+    margin-left: 16.66666667%;
+  }
+  .col-sm-offset-1 {
+    margin-left: 8.33333333%;
+  }
+  .col-sm-offset-0 {
+    margin-left: 0%;
+  }
+}
+@media (min-width: 992px) {
+  .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12 {
+    float: left;
+  }
+  .col-md-12 {
+    width: 100%;
+  }
+  .col-md-11 {
+    width: 91.66666667%;
+  }
+  .col-md-10 {
+    width: 83.33333333%;
+  }
+  .col-md-9 {
+    width: 75%;
+  }
+  .col-md-8 {
+    width: 66.66666667%;
+  }
+  .col-md-7 {
+    width: 58.33333333%;
+  }
+  .col-md-6 {
+    width: 50%;
+  }
+  .col-md-5 {
+    width: 41.66666667%;
+  }
+  .col-md-4 {
+    width: 33.33333333%;
+  }
+  .col-md-3 {
+    width: 25%;
+  }
+  .col-md-2 {
+    width: 16.66666667%;
+  }
+  .col-md-1 {
+    width: 8.33333333%;
+  }
+  .col-md-pull-12 {
+    right: 100%;
+  }
+  .col-md-pull-11 {
+    right: 91.66666667%;
+  }
+  .col-md-pull-10 {
+    right: 83.33333333%;
+  }
+  .col-md-pull-9 {
+    right: 75%;
+  }
+  .col-md-pull-8 {
+    right: 66.66666667%;
+  }
+  .col-md-pull-7 {
+    right: 58.33333333%;
+  }
+  .col-md-pull-6 {
+    right: 50%;
+  }
+  .col-md-pull-5 {
+    right: 41.66666667%;
+  }
+  .col-md-pull-4 {
+    right: 33.33333333%;
+  }
+  .col-md-pull-3 {
+    right: 25%;
+  }
+  .col-md-pull-2 {
+    right: 16.66666667%;
+  }
+  .col-md-pull-1 {
+    right: 8.33333333%;
+  }
+  .col-md-pull-0 {
+    right: auto;
+  }
+  .col-md-push-12 {
+    left: 100%;
+  }
+  .col-md-push-11 {
+    left: 91.66666667%;
+  }
+  .col-md-push-10 {
+    left: 83.33333333%;
+  }
+  .col-md-push-9 {
+    left: 75%;
+  }
+  .col-md-push-8 {
+    left: 66.66666667%;
+  }
+  .col-md-push-7 {
+    left: 58.33333333%;
+  }
+  .col-md-push-6 {
+    left: 50%;
+  }
+  .col-md-push-5 {
+    left: 41.66666667%;
+  }
+  .col-md-push-4 {
+    left: 33.33333333%;
+  }
+  .col-md-push-3 {
+    left: 25%;
+  }
+  .col-md-push-2 {
+    left: 16.66666667%;
+  }
+  .col-md-push-1 {
+    left: 8.33333333%;
+  }
+  .col-md-push-0 {
+    left: auto;
+  }
+  .col-md-offset-12 {
+    margin-left: 100%;
+  }
+  .col-md-offset-11 {
+    margin-left: 91.66666667%;
+  }
+  .col-md-offset-10 {
+    margin-left: 83.33333333%;
+  }
+  .col-md-offset-9 {
+    margin-left: 75%;
+  }
+  .col-md-offset-8 {
+    margin-left: 66.66666667%;
+  }
+  .col-md-offset-7 {
+    margin-left: 58.33333333%;
+  }
+  .col-md-offset-6 {
+    margin-left: 50%;
+  }
+  .col-md-offset-5 {
+    margin-left: 41.66666667%;
+  }
+  .col-md-offset-4 {
+    margin-left: 33.33333333%;
+  }
+  .col-md-offset-3 {
+    margin-left: 25%;
+  }
+  .col-md-offset-2 {
+    margin-left: 16.66666667%;
+  }
+  .col-md-offset-1 {
+    margin-left: 8.33333333%;
+  }
+  .col-md-offset-0 {
+    margin-left: 0%;
+  }
+}
+
+table {
+  background-color: transparent;
+}
+th {
+  text-align: left;
+}
+.table {
+  width: 100%;
+  max-width: 100%;
+  margin-bottom: 20px;
+}
+.table > thead > tr > th,
+.table > tbody > tr > th,
+.table > tfoot > tr > th,
+.table > thead > tr > td,
+.table > tbody > tr > td,
+.table > tfoot > tr > td {
+  padding: 8px;
+  line-height: 1.42857143;
+  vertical-align: top;
+  border-top: 1px solid #dddddd;
+}
+.table > thead > tr > th {
+  vertical-align: bottom;
+  border-bottom: 2px solid #dddddd;
+}
+.table > caption + thead > tr:first-child > th,
+.table > colgroup + thead > tr:first-child > th,
+.table > thead:first-child > tr:first-child > th,
+.table > caption + thead > tr:first-child > td,
+.table > colgroup + thead > tr:first-child > td,
+.table > thead:first-child > tr:first-child > td {
+  border-top: 0;
+}
+.table > tbody + tbody {
+  border-top: 2px solid #dddddd;
+}
+.table .table {
+  background-color: #ffffff;
+}
+.table-condensed > thead > tr > th,
+.table-condensed > tbody > tr > th,
+.table-condensed > tfoot > tr > th,
+.table-condensed > thead > tr > td,
+.table-condensed > tbody > tr > td,
+.table-condensed > tfoot > tr > td {
+  padding: 5px;
+}
+.table-bordered {
+  border: 1px solid #dddddd;
+}
+.table-bordered > thead > tr > th,
+.table-bordered > tbody > tr > th,
+.table-bordered > tfoot > tr > th,
+.table-bordered > thead > tr > td,
+.table-bordered > tbody > tr > td,
+.table-bordered > tfoot > tr > td {
+  border: 1px solid #dddddd;
+}
+.table-bordered > thead > tr > th,
+.table-bordered > thead > tr > td {
+  border-bottom-width: 2px;
+}
+.table-striped > tbody > tr:nth-child(odd) {
+  background-color: #f9f9f9;
+}
+.table-hover > tbody > tr:hover {
+  background-color: #f5f5f5;
+}
+table col[class*="col-"] {
+  position: static;
+  float: none;
+  display: table-column;
+}
+table td[class*="col-"],
+table th[class*="col-"] {
+  position: static;
+  float: none;
+  display: table-cell;
+}
+.table > thead > tr > td.active,
+.table > tbody > tr > td.active,
+.table > tfoot > tr > td.active,
+.table > thead > tr > th.active,
+.table > tbody > tr > th.active,
+.table > tfoot > tr > th.active,
+.table > thead > tr.active > td,
+.table > tbody > tr.active > td,
+.table > tfoot > tr.active > td,
+.table > thead > tr.active > th,
+.table > tbody > tr.active > th,
+.table > tfoot > tr.active > th {
+  background-color: #f5f5f5;
+}
+.table-hover > tbody > tr > td.active:hover,
+.table-hover > tbody > tr > th.active:hover,
+.table-hover > tbody > tr.active:hover > td,
+.table-hover > tbody > tr:hover > .active,
+.table-hover > tbody > tr.active:hover > th {
+  background-color: #e8e8e8;
+}
+.table > thead > tr > td.success,
+.table > tbody > tr > td.success,
+.table > tfoot > tr > td.success,
+.table > thead > tr > th.success,
+.table > tbody > tr > th.success,
+.table > tfoot > tr > th.success,
+.table > thead > tr.success > td,
+.table > tbody > tr.success > td,
+.table > tfoot > tr.success > td,
+.table > thead > tr.success > th,
+.table > tbody > tr.success > th,
+.table > tfoot > tr.success > th {
+  background-color: #dff0d8;
+}
+.table-hover > tbody > tr > td.success:hover,
+.table-hover > tbody > tr > th.success:hover,
+.table-hover > tbody > tr.success:hover > td,
+.table-hover > tbody > tr:hover > .success,
+.table-hover > tbody > tr.success:hover > th {
+  background-color: #d0e9c6;
+}
+.table > thead > tr > td.info,
+.table > tbody > tr > td.info,
+.table > tfoot > tr > td.info,
+.table > thead > tr > th.info,
+.table > tbody > tr > th.info,
+.table > tfoot > tr > th.info,
+.table > thead > tr.info > td,
+.table > tbody > tr.info > td,
+.table > tfoot > tr.info > td,
+.table > thead > tr.info > th,
+.table > tbody > tr.info > th,
+.table > tfoot > tr.info > th {
+  background-color: #d9edf7;
+}
+.table-hover > tbody > tr > td.info:hover,
+.table-hover > tbody > tr > th.info:hover,
+.table-hover > tbody > tr.info:hover > td,
+.table-hover > tbody > tr:hover > .info,
+.table-hover > tbody > tr.info:hover > th {
+  background-color: #c4e3f3;
+}
+.table > thead > tr > td.warning,
+.table > tbody > tr > td.warning,
+.table > tfoot > tr > td.warning,
+.table > thead > tr > th.warning,
+.table > tbody > tr > th.warning,
+.table > tfoot > tr > th.warning,
+.table > thead > tr.warning > td,
+.table > tbody > tr.warning > td,
+.table > tfoot > tr.warning > td,
+.table > thead > tr.warning > th,
+.table > tbody > tr.warning > th,
+.table > tfoot > tr.warning > th {
+  background-color: #fcf8e3;
+}
+.table-hover > tbody > tr > td.warning:hover,
+.table-hover > tbody > tr > th.warning:hover,
+.table-hover > tbody > tr.warning:hover > td,
+.table-hover > tbody > tr:hover > .warning,
+.table-hover > tbody > tr.warning:hover > th {
+  background-color: #faf2cc;
+}
+.table > thead > tr > td.danger,
+.table > tbody > tr > td.danger,
+.table > tfoot > tr > td.danger,
+.table > thead > tr > th.danger,
+.table > tbody > tr > th.danger,
+.table > tfoot > tr > th.danger,
+.table > thead > tr.danger > td,
+.table > tbody > tr.danger > td,
+.table > tfoot > tr.danger > td,
+.table > thead > tr.danger > th,
+.table > tbody > tr.danger > th,
+.table > tfoot > tr.danger > th {
+  background-color: #f2dede;
+}
+.table-hover > tbody > tr > td.danger:hover,
+.table-hover > tbody > tr > th.danger:hover,
+.table-hover > tbody > tr.danger:hover > td,
+.table-hover > tbody > tr:hover > .danger,
+.table-hover > tbody > tr.danger:hover > th {
+  background-color: #ebcccc;
+}
+@media screen and (max-width: 767px) {
+  .table-responsive {
+    width: 100%;
+    margin-bottom: 15px;
+    overflow-y: hidden;
+    overflow-x: auto;
+    -ms-overflow-style: -ms-autohiding-scrollbar;
+    border: 1px solid #dddddd;
+    -webkit-overflow-scrolling: touch;
+  }
+  .table-responsive > .table {
+    margin-bottom: 0;
+  }
+  .table-responsive > .table > thead > tr > th,
+  .table-responsive > .table > tbody > tr > th,
+  .table-responsive > .table > tfoot > tr > th,
+  .table-responsive > .table > thead > tr > td,
+  .table-responsive > .table > tbody > tr > td,
+  .table-responsive > .table > tfoot > tr > td {
+    white-space: nowrap;
+  }
+  .table-responsive > .table-bordered {
+    border: 0;
+  }
+  .table-responsive > .table-bordered > thead > tr > th:first-child,
+  .table-responsive > .table-bordered > tbody > tr > th:first-child,
+  .table-responsive > .table-bordered > tfoot > tr > th:first-child,
+  .table-responsive > .table-bordered > thead > tr > td:first-child,
+  .table-responsive > .table-bordered > tbody > tr > td:first-child,
+  .table-responsive > .table-bordered > tfoot > tr > td:first-child {
+    border-left: 0;
+  }
+  .table-responsive > .table-bordered > thead > tr > th:last-child,
+  .table-responsive > .table-bordered > tbody > tr > th:last-child,
+  .table-responsive > .table-bordered > tfoot > tr > th:last-child,
+  .table-responsive > .table-bordered > thead > tr > td:last-child,
+  .table-responsive > .table-bordered > tbody > tr > td:last-child,
+  .table-responsive > .table-bordered > tfoot > tr > td:last-child {
+    border-right: 0;
+  }
+  .table-responsive > .table-bordered > tbody > tr:last-child > th,
+  .table-responsive > .table-bordered > tfoot > tr:last-child > th,
+  .table-responsive > .table-bordered > tbody > tr:last-child > td,
+  .table-responsive > .table-bordered > tfoot > tr:last-child > td {
+    border-bottom: 0;
+  }
+}
+fieldset {
+  padding: 0;
+  margin: 0;
+  border: 0;
+  min-width: 0;
+}
+legend {
+  display: block;
+  width: 100%;
+  padding: 0;
+  margin-bottom: 20px;
+  font-size: 21px;
+  line-height: inherit;
+  color: #333333;
+  border: 0;
+  border-bottom: 1px solid #e5e5e5;
+}
+label {
+  display: inline-block;
+  max-width: 100%;
+  margin-bottom: 5px;
+  font-weight: bold;
+}
+input[type="search"] {
+  -webkit-box-sizing: border-box;
+  -moz-box-sizing: border-box;
+  box-sizing: border-box;
+}
+input[type="radio"],
+input[type="checkbox"] {
+  margin: 4px 0 0;
+  margin-top: 1px \9;
+  line-height: normal;
+}
+input[type="file"] {
+  display: block;
+}
+input[type="range"] {
+  display: block;
+  width: 100%;
+}
+select[multiple],
+select[size] {
+  height: auto;
+}
+input[type="file"]:focus,
+input[type="radio"]:focus,
+input[type="checkbox"]:focus {
+  outline: thin dotted;
+  outline: 5px auto -webkit-focus-ring-color;
+  outline-offset: -2px;
+}
+output {
+  display: block;
+  padding-top: 7px;
+  font-size: 14px;
+  line-height: 1.42857143;
+  color: #555555;
+}
+.form-control {
+  display: block;
+  width: 100%;
+  height: 34px;
+  padding: 6px 12px;
+  font-size: 14px;
+  line-height: 1.42857143;
+  color: #555555;
+  background-color: #ffffff;
+  background-image: none;
+  border: 1px solid #cccccc;
+  border-radius: 4px;
+  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+  -webkit-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
+  -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
+  transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
+}
+.form-control:focus {
+  border-color: #66afe9;
+  outline: 0;
+  -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
+  box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
+}
+.form-control::-moz-placeholder {
+  color: #777777;
+  opacity: 1;
+}
+.form-control:-ms-input-placeholder {
+  color: #777777;
+}
+.form-control::-webkit-input-placeholder {
+  color: #777777;
+}
+.form-control[disabled],
+.form-control[readonly],
+fieldset[disabled] .form-control {
+  cursor: not-allowed;
+  background-color: #eeeeee;
+  opacity: 1;
+}
+textarea.form-control {
+  height: auto;
+}
+input[type="search"] {
+  -webkit-appearance: none;
+}
+input[type="date"],
+input[type="time"],
+input[type="datetime-local"],
+input[type="month"] {
+  line-height: 34px;
+  line-height: 1.42857143 \0;
+}
+input[type="date"].input-sm,
+input[type="time"].input-sm,
+input[type="datetime-local"].input-sm,
+input[type="month"].input-sm {
+  line-height: 30px;
+}
+input[type="date"].input-lg,
+input[type="time"].input-lg,
+input[type="datetime-local"].input-lg,
+input[type="month"].input-lg {
+  line-height: 46px;
+}
+.form-group {
+  margin-bottom: 15px;
+}
+.radio,
+.checkbox {
+  position: relative;
+  display: block;
+  margin-top: 10px;
+  margin-bottom: 10px;
+}
+.radio label,
+.checkbox label {
+  min-height: 20px;
+  padding-left: 20px;
+  margin-bottom: 0;
+  font-weight: normal;
+  cursor: pointer;
+}
+.radio input[type="radio"],
+.radio-inline input[type="radio"],
+.checkbox input[type="checkbox"],
+.checkbox-inline input[type="checkbox"] {
+  position: absolute;
+  margin-left: -20px;
+  margin-top: 4px \9;
+}
+.radio + .radio,
+.checkbox + .checkbox {
+  margin-top: -5px;
+}
+.radio-inline,
+.checkbox-inline {
+  display: inline-block;
+  padding-left: 20px;
+  margin-bottom: 0;
+  vertical-align: middle;
+  font-weight: normal;
+  cursor: pointer;
+}
+.radio-inline + .radio-inline,
+.checkbox-inline + .checkbox-inline {
+  margin-top: 0;
+  margin-left: 10px;
+}
+input[type="radio"][disabled],
+input[type="checkbox"][disabled],
+input[type="radio"].disabled,
+input[type="checkbox"].disabled,
+fieldset[disabled] input[type="radio"],
+fieldset[disabled] input[type="checkbox"] {
+  cursor: not-allowed;
+}
+.radio-inline.disabled,
+.checkbox-inline.disabled,
+fieldset[disabled] .radio-inline,
+fieldset[disabled] .checkbox-inline {
+  cursor: not-allowed;
+}
+.radio.disabled label,
+.checkbox.disabled label,
+fieldset[disabled] .radio label,
+fieldset[disabled] .checkbox label {
+  cursor: not-allowed;
+}
+.form-control-static {
+  padding-top: 7px;
+  padding-bottom: 7px;
+  margin-bottom: 0;
+}
+.form-control-static.input-lg,
+.form-control-static.input-sm {
+  padding-left: 0;
+  padding-right: 0;
+}
+.input-sm,
+.form-group-sm .form-control {
+  height: 30px;
+  padding: 5px 10px;
+  font-size: 12px;
+  line-height: 1.5;
+  border-radius: 3px;
+}
+select.input-sm,
+select.form-group-sm .form-control {
+  height: 30px;
+  line-height: 30px;
+}
+textarea.input-sm,
+textarea.form-group-sm .form-control,
+select[multiple].input-sm,
+select[multiple].form-group-sm .form-control {
+  height: auto;
+}
+.input-lg,
+.form-group-lg .form-control {
+  height: 46px;
+  padding: 10px 16px;
+  font-size: 18px;
+  line-height: 1.33;
+  border-radius: 6px;
+}
+select.input-lg,
+select.form-group-lg .form-control {
+  height: 46px;
+  line-height: 46px;
+}
+textarea.input-lg,
+textarea.form-group-lg .form-control,
+select[multiple].input-lg,
+select[multiple].form-group-lg .form-control {
+  height: auto;
+}
+.has-feedback {
+  position: relative;
+}
+.has-feedback .form-control {
+  padding-right: 42.5px;
+}
+.form-control-feedback {
+  position: absolute;
+  top: 0;
+  right: 0;
+  z-index: 2;
+  display: block;
+  width: 34px;
+  height: 34px;
+  line-height: 34px;
+  text-align: center;
+}
+.input-lg + .form-control-feedback {
+  width: 46px;
+  height: 46px;
+  line-height: 46px;
+}
+.input-sm + .form-control-feedback {
+  width: 30px;
+  height: 30px;
+  line-height: 30px;
+}
+.has-success .help-block,
+.has-success .control-label,
+.has-success .radio,
+.has-success .checkbox,
+.has-success .radio-inline,
+.has-success .checkbox-inline,
+.has-success.radio label,
+.has-success.checkbox label,
+.has-success.radio-inline label,
+.has-success.checkbox-inline label {
+  color: #3c763d;
+}
+.has-success .form-control {
+  border-color: #3c763d;
+  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+}
+.has-success .form-control:focus {
+  border-color: #2b542c;
+  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #67b168;
+  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #67b168;
+}
+.has-success .input-group-addon {
+  color: #3c763d;
+  border-color: #3c763d;
+  background-color: #dff0d8;
+}
+.has-success .form-control-feedback {
+  color: #3c763d;
+}
+.has-warning .help-block,
+.has-warning .control-label,
+.has-warning .radio,
+.has-warning .checkbox,
+.has-warning .radio-inline,
+.has-warning .checkbox-inline,
+.has-warning.radio label,
+.has-warning.checkbox label,
+.has-warning.radio-inline label,
+.has-warning.checkbox-inline label {
+  color: #8a6d3b;
+}
+.has-warning .form-control {
+  border-color: #8a6d3b;
+  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+}
+.has-warning .form-control:focus {
+  border-color: #66512c;
+  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #c0a16b;
+  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #c0a16b;
+}
+.has-warning .input-group-addon {
+  color: #8a6d3b;
+  border-color: #8a6d3b;
+  background-color: #fcf8e3;
+}
+.has-warning .form-control-feedback {
+  color: #8a6d3b;
+}
+.has-error .help-block,
+.has-error .control-label,
+.has-error .radio,
+.has-error .checkbox,
+.has-error .radio-inline,
+.has-error .checkbox-inline,
+.has-error.radio label,
+.has-error.checkbox label,
+.has-error.radio-inline label,
+.has-error.checkbox-inline label {
+  color: #a94442;
+}
+.has-error .form-control {
+  border-color: #a94442;
+  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+}
+.has-error .form-control:focus {
+  border-color: #843534;
+  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #ce8483;
+  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #ce8483;
+}
+.has-error .input-group-addon {
+  color: #a94442;
+  border-color: #a94442;
+  background-color: #f2dede;
+}
+.has-error .form-control-feedback {
+  color: #a94442;
+}
+.has-feedback label ~ .form-control-feedback {
+  top: 25px;
+}
+.has-feedback label.sr-only ~ .form-control-feedback {
+  top: 0;
+}
+.help-block {
+  display: block;
+  margin-top: 5px;
+  margin-bottom: 10px;
+  color: #737373;
+}
+@media (min-width: 768px) {
+  .form-inline .form-group {
+    display: inline-block;
+    margin-bottom: 0;
+    vertical-align: middle;
+  }
+  .form-inline .form-control {
+    display: inline-block;
+    width: auto;
+    vertical-align: middle;
+  }
+  .form-inline .input-group {
+    display: inline-table;
+    vertical-align: middle;
+  }
+  .form-inline .input-group .input-group-addon,
+  .form-inline .input-group .input-group-btn,
+  .form-inline .input-group .form-control {
+    width: auto;
+  }
+  .form-inline .input-group > .form-control {
+    width: 100%;
+  }
+  .form-inline .control-label {
+    margin-bottom: 0;
+    vertical-align: middle;
+  }
+  .form-inline .radio,
+  .form-inline .checkbox {
+    display: inline-block;
+    margin-top: 0;
+    margin-bottom: 0;
+    vertical-align: middle;
+  }
+  .form-inline .radio label,
+  .form-inline .checkbox label {
+    padding-left: 0;
+  }
+  .form-inline .radio input[type="radio"],
+  .form-inline .checkbox input[type="checkbox"] {
+    position: relative;
+    margin-left: 0;
+  }
+  .form-inline .has-feedback .form-control-feedback {
+    top: 0;
+  }
+}
+.form-horizontal .radio,
+.form-horizontal .checkbox,
+.form-horizontal .radio-inline,
+.form-horizontal .checkbox-inline {
+  margin-top: 0;
+  margin-bottom: 0;
+  padding-top: 7px;
+}
+.form-horizontal .radio,
+.form-horizontal .checkbox {
+  min-height: 27px;
+}
+.form-horizontal .form-group {
+  margin-left: -15px;
+  margin-right: -15px;
+}
+@media (min-width: 768px) {
+  .form-horizontal .control-label {
+    text-align: right;
+    margin-bottom: 0;
+    padding-top: 7px;
+  }
+}
+.form-horizontal .has-feedback .form-control-feedback {
+  right: 15px;
+}
+@media (min-width: 768px) {
+  .form-horizontal .form-group-lg .control-label {
+    padding-top: 14.3px;
+  }
+}
+@media (min-width: 768px) {
+  .form-horizontal .form-group-sm .control-label {
+    padding-top: 6px;
+  }
+}
+
+input[type="submit"].btn-block,
+input[type="reset"].btn-block,
+input[type="button"].btn-block {
+  width: 100%;
+}
+.fade {
+  opacity: 0;
+  -webkit-transition: opacity 0.15s linear;
+  -o-transition: opacity 0.15s linear;
+  transition: opacity 0.15s linear;
+}
+.fade.in {
+  opacity: 1;
+}
+.collapse {
+  display: none;
+}
+.collapse.in {
+  display: block;
+}
+tr.collapse.in {
+  display: table-row;
+}
+tbody.collapse.in {
+  display: table-row-group;
+}
+.collapsing {
+  position: relative;
+  height: 0;
+  overflow: hidden;
+  -webkit-transition: height 0.35s ease;
+  -o-transition: height 0.35s ease;
+  transition: height 0.35s ease;
+}
+.caret {
+  display: inline-block;
+  width: 0;
+  height: 0;
+  margin-left: 2px;
+  vertical-align: middle;
+  border-top: 4px solid;
+  border-right: 4px solid transparent;
+  border-left: 4px solid transparent;
+}
+.dropdown {
+  position: relative;
+}
+.dropdown-toggle:focus {
+  outline: 0;
+}
+.dropdown-menu {
+  position: absolute;
+  top: 100%;
+  left: 0;
+  z-index: 1000;
+  display: none;
+  float: left;
+  min-width: 160px;
+  padding: 5px 0;
+  margin: 2px 0 0;
+  list-style: none;
+  font-size: 14px;
+  text-align: left;
+  background-color: #ffffff;
+  border: 1px solid #cccccc;
+  border: 1px solid rgba(0, 0, 0, 0.15);
+  border-radius: 4px;
+  -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
+  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
+  background-clip: padding-box;
+}
+.dropdown-menu.pull-right {
+  right: 0;
+  left: auto;
+}
+.dropdown-menu .divider {
+  height: 1px;
+  margin: 9px 0;
+  overflow: hidden;
+  background-color: #e5e5e5;
+}
+.dropdown-menu > li > a {
+  display: block;
+  padding: 3px 20px;
+  clear: both;
+  font-weight: normal;
+  line-height: 1.42857143;
+  color: #333333;
+  white-space: nowrap;
+}
+.dropdown-menu > li > a:hover,
+.dropdown-menu > li > a:focus {
+  text-decoration: none;
+  color: #262626;
+  background-color: #f5f5f5;
+}
+.dropdown-menu > .active > a,
+.dropdown-menu > .active > a:hover,
+.dropdown-menu > .active > a:focus {
+  color: #ffffff;
+  text-decoration: none;
+  outline: 0;
+  background-color: #428bca;
+}
+.dropdown-menu > .disabled > a,
+.dropdown-menu > .disabled > a:hover,
+.dropdown-menu > .disabled > a:focus {
+  color: #777777;
+}
+.dropdown-menu > .disabled > a:hover,
+.dropdown-menu > .disabled > a:focus {
+  text-decoration: none;
+  background-color: transparent;
+  background-image: none;
+  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
+  cursor: not-allowed;
+}
+.open > .dropdown-menu {
+  display: block;
+}
+.open > a {
+  outline: 0;
+}
+.dropdown-menu-right {
+  left: auto;
+  right: 0;
+}
+.dropdown-menu-left {
+  left: 0;
+  right: auto;
+}
+.dropdown-header {
+  display: block;
+  padding: 3px 20px;
+  font-size: 12px;
+  line-height: 1.42857143;
+  color: #777777;
+  white-space: nowrap;
+}
+.dropdown-backdrop {
+  position: fixed;
+  left: 0;
+  right: 0;
+  bottom: 0;
+  top: 0;
+  z-index: 990;
+}
+.pull-right > .dropdown-menu {
+  right: 0;
+  left: auto;
+}
+.dropup .caret,
+.navbar-fixed-bottom .dropdown .caret {
+  border-top: 0;
+  border-bottom: 4px solid;
+  content: "";
+}
+.dropup .dropdown-menu,
+.navbar-fixed-bottom .dropdown .dropdown-menu {
+  top: auto;
+  bottom: 100%;
+  margin-bottom: 1px;
+}
+@media (min-width: 768px) {
+  .navbar-right .dropdown-menu {
+    left: auto;
+    right: 0;
+  }
+  .navbar-right .dropdown-menu-left {
+    left: 0;
+    right: auto;
+  }
+}
+.btn-group,
+.btn-group-vertical {
+  position: relative;
+  display: inline-block;
+  vertical-align: middle;
+}
+.btn-group > .btn,
+.btn-group-vertical > .btn {
+  position: relative;
+  float: left;
+}
+.btn-group > .btn:hover,
+.btn-group-vertical > .btn:hover,
+.btn-group > .btn:focus,
+.btn-group-vertical > .btn:focus,
+.btn-group > .btn:active,
+.btn-group-vertical > .btn:active,
+.btn-group > .btn.active,
+.btn-group-vertical > .btn.active {
+  z-index: 2;
+}
+.btn-group > .btn:focus,
+.btn-group-vertical > .btn:focus {
+  outline: 0;
+}
+.btn-group .btn + .btn,
+.btn-group .btn + .btn-group,
+.btn-group .btn-group + .btn,
+.btn-group .btn-group + .btn-group {
+  margin-left: -1px;
+}
+.btn-toolbar {
+  margin-left: -5px;
+}
+.btn-toolbar .btn-group,
+.btn-toolbar .input-group {
+  float: left;
+}
+.btn-toolbar > .btn,
+.btn-toolbar > .btn-group,
+.btn-toolbar > .input-group {
+  margin-left: 5px;
+}
+.btn-group > .btn:not(:first-child):not(:last-child):not(.dropdown-toggle) {
+  border-radius: 0;
+}
+.btn-group > .btn:first-child {
+  margin-left: 0;
+}
+.btn-group > .btn:first-child:not(:last-child):not(.dropdown-toggle) {
+  border-bottom-right-radius: 0;
+  border-top-right-radius: 0;
+}
+.btn-group > .btn:last-child:not(:first-child),
+.btn-group > .dropdown-toggle:not(:first-child) {
+  border-bottom-left-radius: 0;
+  border-top-left-radius: 0;
+}
+.btn-group > .btn-group {
+  float: left;
+}
+.btn-group > .btn-group:not(:first-child):not(:last-child) > .btn {
+  border-radius: 0;
+}
+.btn-group > .btn-group:first-child > .btn:last-child,
+.btn-group > .btn-group:first-child > .dropdown-toggle {
+  border-bottom-right-radius: 0;
+  border-top-right-radius: 0;
+}
+.btn-group > .btn-group:last-child > .btn:first-child {
+  border-bottom-left-radius: 0;
+  border-top-left-radius: 0;
+}
+.btn-group .dropdown-toggle:active,
+.btn-group.open .dropdown-toggle {
+  outline: 0;
+}
+.btn-group > .btn + .dropdown-toggle {
+  padding-left: 8px;
+  padding-right: 8px;
+}
+.btn-group > .btn-lg + .dropdown-toggle {
+  padding-left: 12px;
+  padding-right: 12px;
+}
+.btn-group.open .dropdown-toggle {
+  -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
+  box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
+}
+.btn-group.open .dropdown-toggle.btn-link {
+  -webkit-box-shadow: none;
+  box-shadow: none;
+}
+.btn .caret {
+  margin-left: 0;
+}
+.btn-lg .caret {
+  border-width: 5px 5px 0;
+  border-bottom-width: 0;
+}
+.dropup .btn-lg .caret {
+  border-width: 0 5px 5px;
+}
+.btn-group-vertical > .btn,
+.btn-group-vertical > .btn-group,
+.btn-group-vertical > .btn-group > .btn {
+  display: block;
+  float: none;
+  width: 100%;
+  max-width: 100%;
+}
+.btn-group-vertical > .btn-group > .btn {
+  float: none;
+}
+.btn-group-vertical > .btn + .btn,
+.btn-group-vertical > .btn + .btn-group,
+.btn-group-vertical > .btn-group + .btn,
+.btn-group-vertical > .btn-group + .btn-group {
+  margin-top: -1px;
+  margin-left: 0;
+}
+.btn-group-vertical > .btn:not(:first-child):not(:last-child) {
+  border-radius: 0;
+}
+.btn-group-vertical > .btn:first-child:not(:last-child) {
+  border-top-right-radius: 4px;
+  border-bottom-right-radius: 0;
+  border-bottom-left-radius: 0;
+}
+.btn-group-vertical > .btn:last-child:not(:first-child) {
+  border-bottom-left-radius: 4px;
+  border-top-right-radius: 0;
+  border-top-left-radius: 0;
+}
+.btn-group-vertical > .btn-group:not(:first-child):not(:last-child) > .btn {
+  border-radius: 0;
+}
+.btn-group-vertical > .btn-group:first-child:not(:last-child) > .btn:last-child,
+.btn-group-vertical > .btn-group:first-child:not(:last-child) > .dropdown-toggle {
+  border-bottom-right-radius: 0;
+  border-bottom-left-radius: 0;
+}
+.btn-group-vertical > .btn-group:last-child:not(:first-child) > .btn:first-child {
+  border-top-right-radius: 0;
+  border-top-left-radius: 0;
+}
+.btn-group-justified {
+  display: table;
+  width: 100%;
+  table-layout: fixed;
+  border-collapse: separate;
+}
+.btn-group-justified > .btn,
+.btn-group-justified > .btn-group {
+  float: none;
+  display: table-cell;
+  width: 1%;
+}
+.btn-group-justified > .btn-group .btn {
+  width: 100%;
+}
+.btn-group-justified > .btn-group .dropdown-menu {
+  left: auto;
+}
+[data-toggle="buttons"] > .btn > input[type="radio"],
+[data-toggle="buttons"] > .btn > input[type="checkbox"] {
+  position: absolute;
+  z-index: -1;
+  opacity: 0;
+  filter: alpha(opacity=0);
+}
+.input-group {
+  position: relative;
+  display: table;
+  border-collapse: separate;
+}
+.input-group[class*="col-"] {
+  float: none;
+  padding-left: 0;
+  padding-right: 0;
+}
+.input-group .form-control {
+  position: relative;
+  z-index: 2;
+  float: left;
+  width: 100%;
+  margin-bottom: 0;
+}
+.input-group-lg > .form-control,
+.input-group-lg > .input-group-addon,
+.input-group-lg > .input-group-btn > .btn {
+  height: 46px;
+  padding: 10px 16px;
+  font-size: 18px;
+  line-height: 1.33;
+  border-radius: 6px;
+}
+select.input-group-lg > .form-control,
+select.input-group-lg > .input-group-addon,
+select.input-group-lg > .input-group-btn > .btn {
+  height: 46px;
+  line-height: 46px;
+}
+textarea.input-group-lg > .form-control,
+textarea.input-group-lg > .input-group-addon,
+textarea.input-group-lg > .input-group-btn > .btn,
+select[multiple].input-group-lg > .form-control,
+select[multiple].input-group-lg > .input-group-addon,
+select[multiple].input-group-lg > .input-group-btn > .btn {
+  height: auto;
+}
+.input-group-sm > .form-control,
+.input-group-sm > .input-group-addon,
+.input-group-sm > .input-group-btn > .btn {
+  height: 30px;
+  padding: 5px 10px;
+  font-size: 12px;
+  line-height: 1.5;
+  border-radius: 3px;
+}
+select.input-group-sm > .form-control,
+select.input-group-sm > .input-group-addon,
+select.input-group-sm > .input-group-btn > .btn {
+  height: 30px;
+  line-height: 30px;
+}
+textarea.input-group-sm > .form-control,
+textarea.input-group-sm > .input-group-addon,
+textarea.input-group-sm > .input-group-btn > .btn,
+select[multiple].input-group-sm > .form-control,
+select[multiple].input-group-sm > .input-group-addon,
+select[multiple].input-group-sm > .input-group-btn > .btn {
+  height: auto;
+}
+.input-group-addon,
+.input-group-btn,
+.input-group .form-control {
+  display: table-cell;
+}
+.input-group-addon:not(:first-child):not(:last-child),
+.input-group-btn:not(:first-child):not(:last-child),
+.input-group .form-control:not(:first-child):not(:last-child) {
+  border-radius: 0;
+}
+.input-group-addon,
+.input-group-btn {
+  width: 1%;
+  white-space: nowrap;
+  vertical-align: middle;
+}
+.input-group-addon {
+  padding: 6px 12px;
+  font-size: 14px;
+  font-weight: normal;
+  line-height: 1;
+  color: #555555;
+  text-align: center;
+  background-color: #eeeeee;
+  border: 1px solid #cccccc;
+  border-radius: 4px;
+}
+.input-group-addon.input-sm {
+  padding: 5px 10px;
+  font-size: 12px;
+  border-radius: 3px;
+}
+.input-group-addon.input-lg {
+  padding: 10px 16px;
+  font-size: 18px;
+  border-radius: 6px;
+}
+.input-group-addon input[type="radio"],
+.input-group-addon input[type="checkbox"] {
+  margin-top: 0;
+}
+.input-group .form-control:first-child,
+.input-group-addon:first-child,
+.input-group-btn:first-child > .btn,
+.input-group-btn:first-child > .btn-group > .btn,
+.input-group-btn:first-child > .dropdown-toggle,
+.input-group-btn:last-child > .btn:not(:last-child):not(.dropdown-toggle),
+.input-group-btn:last-child > .btn-group:not(:last-child) > .btn {
+  border-bottom-right-radius: 0;
+  border-top-right-radius: 0;
+}
+.input-group-addon:first-child {
+  border-right: 0;
+}
+.input-group .form-control:last-child,
+.input-group-addon:last-child,
+.input-group-btn:last-child > .btn,
+.input-group-btn:last-child > .btn-group > .btn,
+.input-group-btn:last-child > .dropdown-toggle,
+.input-group-btn:first-child > .btn:not(:first-child),
+.input-group-btn:first-child > .btn-group:not(:first-child) > .btn {
+  border-bottom-left-radius: 0;
+  border-top-left-radius: 0;
+}
+.input-group-addon:last-child {
+  border-left: 0;
+}
+.input-group-btn {
+  position: relative;
+  font-size: 0;
+  white-space: nowrap;
+}
+.input-group-btn > .btn {
+  position: relative;
+}
+.input-group-btn > .btn + .btn {
+  margin-left: -1px;
+}
+.input-group-btn > .btn:hover,
+.input-group-btn > .btn:focus,
+.input-group-btn > .btn:active {
+  z-index: 2;
+}
+.input-group-btn:first-child > .btn,
+.input-group-btn:first-child > .btn-group {
+  margin-right: -1px;
+}
+.input-group-btn:last-child > .btn,
+.input-group-btn:last-child > .btn-group {
+  margin-left: -1px;
+}
+.nav {
+  margin-bottom: 0;
+  padding-left: 0;
+  list-style: none;
+}
+.nav > li {
+  position: relative;
+  display: block;
+}
+.nav > li > a {
+  position: relative;
+  display: block;
+  padding: 10px 15px;
+}
+.nav > li > a:hover,
+.nav > li > a:focus {
+  text-decoration: none;
+  background-color: #eeeeee;
+}
+.nav > li.disabled > a {
+  color: #777777;
+}
+.nav > li.disabled > a:hover,
+.nav > li.disabled > a:focus {
+  color: #777777;
+  text-decoration: none;
+  background-color: transparent;
+  cursor: not-allowed;
+}
+.nav .open > a,
+.nav .open > a:hover,
+.nav .open > a:focus {
+  background-color: #eeeeee;
+  border-color: #428bca;
+}
+.nav .nav-divider {
+  height: 1px;
+  margin: 9px 0;
+  overflow: hidden;
+  background-color: #e5e5e5;
+}
+.nav > li > a > img {
+  max-width: none;
+}
+.nav-tabs {
+  border-bottom: 1px solid #dddddd;
+}
+.nav-tabs > li {
+  float: left;
+  margin-bottom: -1px;
+}
+.nav-tabs > li > a {
+  margin-right: 2px;
+  line-height: 1.42857143;
+  border: 1px solid transparent;
+  border-radius: 4px 4px 0 0;
+}
+.nav-tabs > li > a:hover {
+  border-color: #eeeeee #eeeeee #dddddd;
+}
+.nav-tabs > li.active > a,
+.nav-tabs > li.active > a:hover,
+.nav-tabs > li.active > a:focus {
+  color: #555555;
+  background-color: #ffffff;
+  border: 1px solid #dddddd;
+  border-bottom-color: transparent;
+  cursor: default;
+}
+.nav-tabs.nav-justified {
+  width: 100%;
+  border-bottom: 0;
+}
+.nav-tabs.nav-justified > li {
+  float: none;
+}
+.nav-tabs.nav-justified > li > a {
+  text-align: center;
+  margin-bottom: 5px;
+}
+.nav-tabs.nav-justified > .dropdown .dropdown-menu {
+  top: auto;
+  left: auto;
+}
+@media (min-width: 768px) {
+  .nav-tabs.nav-justified > li {
+    display: table-cell;
+    width: 1%;
+  }
+  .nav-tabs.nav-justified > li > a {
+    margin-bottom: 0;
+  }
+}
+.nav-tabs.nav-justified > li > a {
+  margin-right: 0;
+  border-radius: 4px;
+}
+.nav-tabs.nav-justified > .active > a,
+.nav-tabs.nav-justified > .active > a:hover,
+.nav-tabs.nav-justified > .active > a:focus {
+  border: 1px solid #dddddd;
+}
+@media (min-width: 768px) {
+  .nav-tabs.nav-justified > li > a {
+    border-bottom: 1px solid #dddddd;
+    border-radius: 4px 4px 0 0;
+  }
+  .nav-tabs.nav-justified > .active > a,
+  .nav-tabs.nav-justified > .active > a:hover,
+  .nav-tabs.nav-justified > .active > a:focus {
+    border-bottom-color: #ffffff;
+  }
+}
+.nav-pills > li {
+  float: left;
+}
+.nav-pills > li > a {
+  border-radius: 4px;
+}
+.nav-pills > li + li {
+  margin-left: 2px;
+}
+.nav-pills > li.active > a,
+.nav-pills > li.active > a:hover,
+.nav-pills > li.active > a:focus {
+  color: #ffffff;
+  background-color: #428bca;
+}
+.nav-stacked > li {
+  float: none;
+}
+.nav-stacked > li + li {
+  margin-top: 2px;
+  margin-left: 0;
+}
+.nav-justified {
+  width: 100%;
+}
+.nav-justified > li {
+  float: none;
+}
+.nav-justified > li > a {
+  text-align: center;
+  margin-bottom: 5px;
+}
+.nav-justified > .dropdown .dropdown-menu {
+  top: auto;
+  left: auto;
+}
+@media (min-width: 768px) {
+  .nav-justified > li {
+    display: table-cell;
+    width: 1%;
+  }
+  .nav-justified > li > a {
+    margin-bottom: 0;
+  }
+}
+.nav-tabs-justified {
+  border-bottom: 0;
+}
+.nav-tabs-justified > li > a {
+  margin-right: 0;
+  border-radius: 4px;
+}
+.nav-tabs-justified > .active > a,
+.nav-tabs-justified > .active > a:hover,
+.nav-tabs-justified > .active > a:focus {
+  border: 1px solid #dddddd;
+}
+@media (min-width: 768px) {
+  .nav-tabs-justified > li > a {
+    border-bottom: 1px solid #dddddd;
+    border-radius: 4px 4px 0 0;
+  }
+  .nav-tabs-justified > .active > a,
+  .nav-tabs-justified > .active > a:hover,
+  .nav-tabs-justified > .active > a:focus {
+    border-bottom-color: #ffffff;
+  }
+}
+.tab-content > .tab-pane {
+  display: none;
+}
+.tab-content > .active {
+  display: block;
+}
+.nav-tabs .dropdown-menu {
+  margin-top: -1px;
+  border-top-right-radius: 0;
+  border-top-left-radius: 0;
+}
+.navbar {
+  position: relative;
+  min-height: 50px;
+  margin-bottom: 20px;
+  border: 1px solid transparent;
+}
+@media (min-width: 768px) {
+  .navbar {
+    border-radius: 4px;
+  }
+}
+@media (min-width: 768px) {
+  .navbar-header {
+    float: left;
+  }
+}
+.navbar-collapse {
+  overflow-x: visible;
+  padding-right: 15px;
+  padding-left: 15px;
+  border-top: 1px solid transparent;
+  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
+  -webkit-overflow-scrolling: touch;
+}
+.navbar-collapse.in {
+  overflow-y: auto;
+}
+@media (min-width: 768px) {
+  .navbar-collapse {
+    width: auto;
+    border-top: 0;
+    box-shadow: none;
+  }
+  .navbar-collapse.collapse {
+    display: block !important;
+    height: auto !important;
+    padding-bottom: 0;
+    overflow: visible !important;
+  }
+  .navbar-collapse.in {
+    overflow-y: visible;
+  }
+  .navbar-fixed-top .navbar-collapse,
+  .navbar-static-top .navbar-collapse,
+  .navbar-fixed-bottom .navbar-collapse {
+    padding-left: 0;
+    padding-right: 0;
+  }
+}
+.navbar-fixed-top .navbar-collapse,
+.navbar-fixed-bottom .navbar-collapse {
+  max-height: 340px;
+}
+@media (max-device-width: 480px) and (orientation: landscape) {
+  .navbar-fixed-top .navbar-collapse,
+  .navbar-fixed-bottom .navbar-collapse {
+    max-height: 200px;
+  }
+}
+
+
+.tooltip {
+  position: absolute;
+  z-index: 1070;
+  display: block;
+  visibility: visible;
+  font-size: 12px;
+  line-height: 1.4;
+  opacity: 0;
+  filter: alpha(opacity=0);
+}
+.tooltip.in {
+  opacity: 0.9;
+  filter: alpha(opacity=90);
+}
+.tooltip.top {
+  margin-top: -3px;
+  padding: 5px 0;
+}
+.tooltip.right {
+  margin-left: 3px;
+  padding: 0 5px;
+}
+.tooltip.bottom {
+  margin-top: 3px;
+  padding: 5px 0;
+}
+.tooltip.left {
+  margin-left: -3px;
+  padding: 0 5px;
+}
+.tooltip-inner {
+  max-width: 200px;
+  padding: 3px 8px;
+  color: #ffffff;
+  text-align: center;
+  text-decoration: none;
+  background-color: #000000;
+  border-radius: 4px;
+}
+.tooltip-arrow {
+  position: absolute;
+  width: 0;
+  height: 0;
+  border-color: transparent;
+  border-style: solid;
+}
+.tooltip.top .tooltip-arrow {
+  bottom: 0;
+  left: 50%;
+  margin-left: -5px;
+  border-width: 5px 5px 0;
+  border-top-color: #000000;
+}
+.tooltip.top-left .tooltip-arrow {
+  bottom: 0;
+  left: 5px;
+  border-width: 5px 5px 0;
+  border-top-color: #000000;
+}
+.tooltip.top-right .tooltip-arrow {
+  bottom: 0;
+  right: 5px;
+  border-width: 5px 5px 0;
+  border-top-color: #000000;
+}
+.tooltip.right .tooltip-arrow {
+  top: 50%;
+  left: 0;
+  margin-top: -5px;
+  border-width: 5px 5px 5px 0;
+  border-right-color: #000000;
+}
+.tooltip.left .tooltip-arrow {
+  top: 50%;
+  right: 0;
+  margin-top: -5px;
+  border-width: 5px 0 5px 5px;
+  border-left-color: #000000;
+}
+.tooltip.bottom .tooltip-arrow {
+  top: 0;
+  left: 50%;
+  margin-left: -5px;
+  border-width: 0 5px 5px;
+  border-bottom-color: #000000;
+}
+.tooltip.bottom-left .tooltip-arrow {
+  top: 0;
+  left: 5px;
+  border-width: 0 5px 5px;
+  border-bottom-color: #000000;
+}
+.tooltip.bottom-right .tooltip-arrow {
+  top: 0;
+  right: 5px;
+  border-width: 0 5px 5px;
+  border-bottom-color: #000000;
+}
+.popover {
+  position: absolute;
+  top: 0;
+  left: 0;
+  z-index: 1060;
+  display: none;
+  max-width: 276px;
+  padding: 1px;
+  text-align: left;
+  background-color: #ffffff;
+  background-clip: padding-box;
+  border: 1px solid #cccccc;
+  border: 1px solid rgba(0, 0, 0, 0.2);
+  border-radius: 6px;
+  -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
+  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
+  white-space: normal;
+}
+.popover.top {
+  margin-top: -10px;
+}
+.popover.right {
+  margin-left: 10px;
+}
+.popover.bottom {
+  margin-top: 10px;
+}
+.popover.left {
+  margin-left: -10px;
+}
+.popover-title {
+  margin: 0;
+  padding: 8px 14px;
+  font-size: 14px;
+  font-weight: normal;
+  line-height: 18px;
+  background-color: #f7f7f7;
+  border-bottom: 1px solid #ebebeb;
+  border-radius: 5px 5px 0 0;
+}
+.popover-content {
+  padding: 9px 14px;
+}
+.popover > .arrow,
+.popover > .arrow:after {
+  position: absolute;
+  display: block;
+  width: 0;
+  height: 0;
+  border-color: transparent;
+  border-style: solid;
+}
+.popover > .arrow {
+  border-width: 11px;
+}
+.popover > .arrow:after {
+  border-width: 10px;
+  content: "";
+}
+.popover.top > .arrow {
+  left: 50%;
+  margin-left: -11px;
+  border-bottom-width: 0;
+  border-top-color: #999999;
+  border-top-color: rgba(0, 0, 0, 0.25);
+  bottom: -11px;
+}
+.popover.top > .arrow:after {
+  content: " ";
+  bottom: 1px;
+  margin-left: -10px;
+  border-bottom-width: 0;
+  border-top-color: #ffffff;
+}
+.popover.right > .arrow {
+  top: 50%;
+  left: -11px;
+  margin-top: -11px;
+  border-left-width: 0;
+  border-right-color: #999999;
+  border-right-color: rgba(0, 0, 0, 0.25);
+}
+.popover.right > .arrow:after {
+  content: " ";
+  left: 1px;
+  bottom: -10px;
+  border-left-width: 0;
+  border-right-color: #ffffff;
+}
+.popover.bottom > .arrow {
+  left: 50%;
+  margin-left: -11px;
+  border-top-width: 0;
+  border-bottom-color: #999999;
+  border-bottom-color: rgba(0, 0, 0, 0.25);
+  top: -11px;
+}
+.popover.bottom > .arrow:after {
+  content: " ";
+  top: 1px;
+  margin-left: -10px;
+  border-top-width: 0;
+  border-bottom-color: #ffffff;
+}
+.popover.left > .arrow {
+  top: 50%;
+  right: -11px;
+  margin-top: -11px;
+  border-right-width: 0;
+  border-left-color: #999999;
+  border-left-color: rgba(0, 0, 0, 0.25);
+}
+.popover.left > .arrow:after {
+  content: " ";
+  right: 1px;
+  border-right-width: 0;
+  border-left-color: #ffffff;
+  bottom: -10px;
+}
+.carousel {
+  position: relative;
+}
+.carousel-inner {
+  position: relative;
+  overflow: hidden;
+  width: 100%;
+}
+.carousel-inner > .item {
+  display: none;
+  position: relative;
+  -webkit-transition: 0.6s ease-in-out left;
+  -o-transition: 0.6s ease-in-out left;
+  transition: 0.6s ease-in-out left;
+}
+.carousel-inner > .item > img,
+.carousel-inner > .item > a > img {
+  line-height: 1;
+}
+.carousel-inner > .active,
+.carousel-inner > .next,
+.carousel-inner > .prev {
+  display: block;
+}
+.carousel-inner > .active {
+  left: 0;
+}
+.carousel-inner > .next,
+.carousel-inner > .prev {
+  position: absolute;
+  top: 0;
+  width: 100%;
+}
+.carousel-inner > .next {
+  left: 100%;
+}
+.carousel-inner > .prev {
+  left: -100%;
+}
+.carousel-inner > .next.left,
+.carousel-inner > .prev.right {
+  left: 0;
+}
+.carousel-inner > .active.left {
+  left: -100%;
+}
+.carousel-inner > .active.right {
+  left: 100%;
+}
+.carousel-control {
+  position: absolute;
+  top: 0;
+  left: 0;
+  bottom: 0;
+  width: 15%;
+  opacity: 0.5;
+  filter: alpha(opacity=50);
+  font-size: 20px;
+  color: #ffffff;
+  text-align: center;
+  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
+}
+.carousel-control.left {
+  background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.0001) 100%);
+  background-image: -o-linear-gradient(left, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.0001) 100%);
+  background-image: linear-gradient(to right, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.0001) 100%);
+  background-repeat: repeat-x;
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#80000000', endColorstr='#00000000', GradientType=1);
+}
+.carousel-control.right {
+  left: auto;
+  right: 0;
+  background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, 0.0001) 0%, rgba(0, 0, 0, 0.5) 100%);
+  background-image: -o-linear-gradient(left, rgba(0, 0, 0, 0.0001) 0%, rgba(0, 0, 0, 0.5) 100%);
+  background-image: linear-gradient(to right, rgba(0, 0, 0, 0.0001) 0%, rgba(0, 0, 0, 0.5) 100%);
+  background-repeat: repeat-x;
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000', endColorstr='#80000000', GradientType=1);
+}
+.carousel-control:hover,
+.carousel-control:focus {
+  outline: 0;
+  color: #ffffff;
+  text-decoration: none;
+  opacity: 0.9;
+  filter: alpha(opacity=90);
+}
+.carousel-control .icon-prev,
+.carousel-control .icon-next,
+.carousel-control .glyphicon-chevron-left,
+.carousel-control .glyphicon-chevron-right {
+  position: absolute;
+  top: 50%;
+  z-index: 5;
+  display: inline-block;
+}
+.carousel-control .icon-prev,
+.carousel-control .glyphicon-chevron-left {
+  left: 50%;
+  margin-left: -10px;
+}
+.carousel-control .icon-next,
+.carousel-control .glyphicon-chevron-right {
+  right: 50%;
+  margin-right: -10px;
+}
+.carousel-control .icon-prev,
+.carousel-control .icon-next {
+  width: 20px;
+  height: 20px;
+  margin-top: -10px;
+  font-family: serif;
+}
+.carousel-control .icon-prev:before {
+  content: '\2039';
+}
+.carousel-control .icon-next:before {
+  content: '\203a';
+}
+.carousel-indicators {
+  position: absolute;
+  bottom: 10px;
+  left: 50%;
+  z-index: 15;
+  width: 60%;
+  margin-left: -30%;
+  padding-left: 0;
+  list-style: none;
+  text-align: center;
+}
+.carousel-indicators li {
+  display: inline-block;
+  width: 10px;
+  height: 10px;
+  margin: 1px;
+  text-indent: -999px;
+  border: 1px solid #ffffff;
+  border-radius: 10px;
+  cursor: pointer;
+  background-color: #000 \9;
+  background-color: rgba(0, 0, 0, 0);
+}
+.carousel-indicators .active {
+  margin: 0;
+  width: 12px;
+  height: 12px;
+  background-color: #ffffff;
+}
+.carousel-caption {
+  position: absolute;
+  left: 15%;
+  right: 15%;
+  bottom: 20px;
+  z-index: 10;
+  padding-top: 20px;
+  padding-bottom: 20px;
+  color: #ffffff;
+  text-align: center;
+  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
+}
+.carousel-caption .btn {
+  text-shadow: none;
+}
+@media screen and (min-width: 768px) {
+  .carousel-control .glyphicon-chevron-left,
+  .carousel-control .glyphicon-chevron-right,
+  .carousel-control .icon-prev,
+  .carousel-control .icon-next {
+    width: 30px;
+    height: 30px;
+    margin-top: -15px;
+    font-size: 30px;
+  }
+  .carousel-control .glyphicon-chevron-left,
+  .carousel-control .icon-prev {
+    margin-left: -15px;
+  }
+  .carousel-control .glyphicon-chevron-right,
+  .carousel-control .icon-next {
+    margin-right: -15px;
+  }
+  .carousel-caption {
+    left: 20%;
+    right: 20%;
+    padding-bottom: 30px;
+  }
+  .carousel-indicators {
+    bottom: 20px;
+  }
+}
+.clearfix:before,
+.clearfix:after,
+.dl-horizontal dd:before,
+.dl-horizontal dd:after,
+.container:before,
+.container:after,
+.container-fluid:before,
+.container-fluid:after,
+.row:before,
+.row:after,
+.form-horizontal .form-group:before,
+.form-horizontal .form-group:after,
+.btn-toolbar:before,
+.btn-toolbar:after,
+.btn-group-vertical > .btn-group:before,
+.btn-group-vertical > .btn-group:after,
+.nav:before,
+.nav:after,
+.navbar:before,
+.navbar:after,
+.navbar-header:before,
+.navbar-header:after,
+.navbar-collapse:before,
+.navbar-collapse:after,
+.pager:before,
+.pager:after,
+.panel-body:before,
+.panel-body:after,
+.modal-footer:before,
+.modal-footer:after {
+  content: " ";
+  display: table;
+}
+.clearfix:after,
+.dl-horizontal dd:after,
+.container:after,
+.container-fluid:after,
+.row:after,
+.form-horizontal .form-group:after,
+.btn-toolbar:after,
+.btn-group-vertical > .btn-group:after,
+.nav:after,
+.navbar:after,
+.navbar-header:after,
+.navbar-collapse:after,
+.pager:after,
+.panel-body:after,
+.modal-footer:after {
+  clear: both;
+}
+.center-block {
+  display: block;
+  margin-left: auto;
+  margin-right: auto;
+}
+
+.btn {
+  display: inline-block;
+  margin-bottom: 0;
+  font-weight: normal;
+  text-align: center;
+  vertical-align: middle;
+  cursor: pointer;
+  background-image: none;
+  border: 1px solid transparent;
+  white-space: nowrap;
+  padding: 6px 12px;
+  font-size: 14px;
+  line-height: 1.42857143;
+  border-radius: 4px;
+  -webkit-user-select: none;
+  -moz-user-select: none;
+  -ms-user-select: none;
+  user-select: none;
+}
+.btn:focus,
+.btn:active:focus,
+.btn.active:focus {
+  outline: thin dotted;
+  outline: 5px auto -webkit-focus-ring-color;
+  outline-offset: -2px;
+}
+.btn:hover,
+.btn:focus {
+  color: #333333;
+  text-decoration: none;
+}
+.btn:active,
+.btn.active {
+  outline: 0;
+  background-image: none;
+  -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
+  box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
+}
+.btn.disabled,
+.btn[disabled],
+fieldset[disabled] .btn {
+  cursor: not-allowed;
+  pointer-events: none;
+  opacity: 0.65;
+  filter: alpha(opacity=65);
+  -webkit-box-shadow: none;
+  box-shadow: none;
+}
+.btn-default {
+  color: #333333;
+  background-color: #ffffff;
+  border-color: #cccccc;
+}
+.btn-default:hover,
+.btn-default:focus,
+.btn-default:active,
+.btn-default.active,
+.open > .dropdown-toggle.btn-default {
+  color: #333333;
+  background-color: #e6e6e6;
+  border-color: #adadad;
+}
+.btn-default:active,
+.btn-default.active,
+.open > .dropdown-toggle.btn-default {
+  background-image: none;
+}
+.btn-default.disabled,
+.btn-default[disabled],
+fieldset[disabled] .btn-default,
+.btn-default.disabled:hover,
+.btn-default[disabled]:hover,
+fieldset[disabled] .btn-default:hover,
+.btn-default.disabled:focus,
+.btn-default[disabled]:focus,
+fieldset[disabled] .btn-default:focus,
+.btn-default.disabled:active,
+.btn-default[disabled]:active,
+fieldset[disabled] .btn-default:active,
+.btn-default.disabled.active,
+.btn-default[disabled].active,
+fieldset[disabled] .btn-default.active {
+  background-color: #ffffff;
+  border-color: #cccccc;
+}
+.btn-default .badge {
+  color: #ffffff;
+  background-color: #333333;
+}
+.btn-primary {
+  color: #ffffff;
+  background-color: #428bca;
+  border-color: #357ebd;
+}
+.btn-primary:hover,
+.btn-primary:focus,
+.btn-primary:active,
+.btn-primary.active,
+.open > .dropdown-toggle.btn-primary {
+  color: #ffffff;
+  background-color: #3071a9;
+  border-color: #285e8e;
+}
+.btn-primary:active,
+.btn-primary.active,
+.open > .dropdown-toggle.btn-primary {
+  background-image: none;
+}
+.btn-primary.disabled,
+.btn-primary[disabled],
+fieldset[disabled] .btn-primary,
+.btn-primary.disabled:hover,
+.btn-primary[disabled]:hover,
+fieldset[disabled] .btn-primary:hover,
+.btn-primary.disabled:focus,
+.btn-primary[disabled]:focus,
+fieldset[disabled] .btn-primary:focus,
+.btn-primary.disabled:active,
+.btn-primary[disabled]:active,
+fieldset[disabled] .btn-primary:active,
+.btn-primary.disabled.active,
+.btn-primary[disabled].active,
+fieldset[disabled] .btn-primary.active {
+  background-color: #428bca;
+  border-color: #357ebd;
+}
+.btn-primary .badge {
+  color: #428bca;
+  background-color: #ffffff;
+}
+.btn-success {
+  color: #ffffff;
+  background-color: #5cb85c;
+  border-color: #4cae4c;
+}
+.btn-success:hover,
+.btn-success:focus,
+.btn-success:active,
+.btn-success.active,
+.open > .dropdown-toggle.btn-success {
+  color: #ffffff;
+  background-color: #449d44;
+  border-color: #398439;
+}
+.btn-success:active,
+.btn-success.active,
+.open > .dropdown-toggle.btn-success {
+  background-image: none;
+}
+.btn-success.disabled,
+.btn-success[disabled],
+fieldset[disabled] .btn-success,
+.btn-success.disabled:hover,
+.btn-success[disabled]:hover,
+fieldset[disabled] .btn-success:hover,
+.btn-success.disabled:focus,
+.btn-success[disabled]:focus,
+fieldset[disabled] .btn-success:focus,
+.btn-success.disabled:active,
+.btn-success[disabled]:active,
+fieldset[disabled] .btn-success:active,
+.btn-success.disabled.active,
+.btn-success[disabled].active,
+fieldset[disabled] .btn-success.active {
+  background-color: #5cb85c;
+  border-color: #4cae4c;
+}
+.btn-success .badge {
+  color: #5cb85c;
+  background-color: #ffffff;
+}
+.btn-info {
+  color: #ffffff;
+  background-color: #5bc0de;
+  border-color: #46b8da;
+}
+.btn-info:hover,
+.btn-info:focus,
+.btn-info:active,
+.btn-info.active,
+.open > .dropdown-toggle.btn-info {
+  color: #ffffff;
+  background-color: #31b0d5;
+  border-color: #269abc;
+}
+.btn-info:active,
+.btn-info.active,
+.open > .dropdown-toggle.btn-info {
+  background-image: none;
+}
+.btn-info.disabled,
+.btn-info[disabled],
+fieldset[disabled] .btn-info,
+.btn-info.disabled:hover,
+.btn-info[disabled]:hover,
+fieldset[disabled] .btn-info:hover,
+.btn-info.disabled:focus,
+.btn-info[disabled]:focus,
+fieldset[disabled] .btn-info:focus,
+.btn-info.disabled:active,
+.btn-info[disabled]:active,
+fieldset[disabled] .btn-info:active,
+.btn-info.disabled.active,
+.btn-info[disabled].active,
+fieldset[disabled] .btn-info.active {
+  background-color: #5bc0de;
+  border-color: #46b8da;
+}
+.btn-info .badge {
+  color: #5bc0de;
+  background-color: #ffffff;
+}
+.btn-warning {
+  color: #ffffff;
+  background-color: #f0ad4e;
+  border-color: #eea236;
+}
+.btn-warning:hover,
+.btn-warning:focus,
+.btn-warning:active,
+.btn-warning.active,
+.open > .dropdown-toggle.btn-warning {
+  color: #ffffff;
+  background-color: #ec971f;
+  border-color: #d58512;
+}
+.btn-warning:active,
+.btn-warning.active,
+.open > .dropdown-toggle.btn-warning {
+  background-image: none;
+}
+.btn-warning.disabled,
+.btn-warning[disabled],
+fieldset[disabled] .btn-warning,
+.btn-warning.disabled:hover,
+.btn-warning[disabled]:hover,
+fieldset[disabled] .btn-warning:hover,
+.btn-warning.disabled:focus,
+.btn-warning[disabled]:focus,
+fieldset[disabled] .btn-warning:focus,
+.btn-warning.disabled:active,
+.btn-warning[disabled]:active,
+fieldset[disabled] .btn-warning:active,
+.btn-warning.disabled.active,
+.btn-warning[disabled].active,
+fieldset[disabled] .btn-warning.active {
+  background-color: #f0ad4e;
+  border-color: #eea236;
+}
+.btn-warning .badge {
+  color: #f0ad4e;
+  background-color: #ffffff;
+}
+.btn-danger {
+  color: #ffffff;
+  background-color: #d9534f;
+  border-color: #d43f3a;
+}
+.btn-danger:hover,
+.btn-danger:focus,
+.btn-danger:active,
+.btn-danger.active,
+.open > .dropdown-toggle.btn-danger {
+  color: #ffffff;
+  background-color: #c9302c;
+  border-color: #ac2925;
+}
+.btn-danger:active,
+.btn-danger.active,
+.open > .dropdown-toggle.btn-danger {
+  background-image: none;
+}
+.btn-danger.disabled,
+.btn-danger[disabled],
+fieldset[disabled] .btn-danger,
+.btn-danger.disabled:hover,
+.btn-danger[disabled]:hover,
+fieldset[disabled] .btn-danger:hover,
+.btn-danger.disabled:focus,
+.btn-danger[disabled]:focus,
+fieldset[disabled] .btn-danger:focus,
+.btn-danger.disabled:active,
+.btn-danger[disabled]:active,
+fieldset[disabled] .btn-danger:active,
+.btn-danger.disabled.active,
+.btn-danger[disabled].active,
+fieldset[disabled] .btn-danger.active {
+  background-color: #d9534f;
+  border-color: #d43f3a;
+}
+.btn-danger .badge {
+  color: #d9534f;
+  background-color: #ffffff;
+}
+.btn-link {
+  color: #428bca;
+  font-weight: normal;
+  border-radius: 0;
+}
+.btn-link,
+.btn-link:active,
+.btn-link[disabled],
+fieldset[disabled] .btn-link {
+  background-color: transparent;
+  -webkit-box-shadow: none;
+  box-shadow: none;
+}
+.btn-link,
+.btn-link:hover,
+.btn-link:focus,
+.btn-link:active {
+  border-color: transparent;
+}
+.btn-link:hover,
+.btn-link:focus {
+  color: #2a6496;
+  text-decoration: underline;
+  background-color: transparent;
+}
+.btn-link[disabled]:hover,
+fieldset[disabled] .btn-link:hover,
+.btn-link[disabled]:focus,
+fieldset[disabled] .btn-link:focus {
+  color: #777777;
+  text-decoration: none;
+}
+.btn-lg,
+.btn-group-lg > .btn {
+  padding: 10px 16px;
+  font-size: 18px;
+  line-height: 1.33;
+  border-radius: 6px;
+}
+.btn-sm,
+.btn-group-sm > .btn {
+  padding: 5px 10px;
+  font-size: 12px;
+  line-height: 1.5;
+  border-radius: 3px;
+}
+.btn-xs,
+.btn-group-xs > .btn {
+  padding: 1px 5px;
+  font-size: 12px;
+  line-height: 1.5;
+  border-radius: 3px;
+}
+.btn-block {
+  display: block;
+  width: 100%;
+}
+.btn-block + .btn-block {
+  margin-top: 5px;
+}
+
+.container > .navbar-header,
+.container-fluid > .navbar-header,
+.container > .navbar-collapse,
+.container-fluid > .navbar-collapse {
+  margin-right: -15px;
+  margin-left: -15px;
+}
+@media (min-width: 768px) {
+  .container > .navbar-header,
+  .container-fluid > .navbar-header,
+  .container > .navbar-collapse,
+  .container-fluid > .navbar-collapse {
+    margin-right: 0;
+    margin-left: 0;
+  }
+}
+.navbar-static-top {
+  z-index: 1000;
+  border-width: 0 0 1px;
+}
+@media (min-width: 768px) {
+  .navbar-static-top {
+    border-radius: 0;
+  }
+}
+.navbar-fixed-top,
+.navbar-fixed-bottom {
+  position: fixed;
+  right: 0;
+  left: 0;
+  z-index: 1030;
+  -webkit-transform: translate3d(0, 0, 0);
+  transform: translate3d(0, 0, 0);
+}
+@media (min-width: 768px) {
+  .navbar-fixed-top,
+  .navbar-fixed-bottom {
+    border-radius: 0;
+  }
+}
+.navbar-fixed-top {
+  top: 0;
+  border-width: 0 0 1px;
+}
+.navbar-fixed-bottom {
+  bottom: 0;
+  margin-bottom: 0;
+  border-width: 1px 0 0;
+}
+.navbar-brand {
+  float: left;
+  padding: 15px 15px;
+  font-size: 18px;
+  line-height: 20px;
+  height: 50px;
+}
+.navbar-brand:hover,
+.navbar-brand:focus {
+  text-decoration: none;
+}
+@media (min-width: 768px) {
+  .navbar > .container .navbar-brand,
+  .navbar > .container-fluid .navbar-brand {
+    margin-left: -15px;
+  }
+}
+.navbar-toggle {
+  position: relative;
+  float: right;
+  margin-right: 15px;
+  padding: 9px 10px;
+  margin-top: 8px;
+  margin-bottom: 8px;
+  background-color: transparent;
+  background-image: none;
+  border: 1px solid transparent;
+  border-radius: 4px;
+}
+.navbar-toggle:focus {
+  outline: 0;
+}
+.navbar-toggle .icon-bar {
+  display: block;
+  width: 22px;
+  height: 2px;
+  border-radius: 1px;
+}
+.navbar-toggle .icon-bar + .icon-bar {
+  margin-top: 4px;
+}
+@media (min-width: 768px) {
+  .navbar-toggle {
+    display: none;
+  }
+}
+.navbar-nav {
+  margin: 7.5px -15px;
+}
+.navbar-nav > li > a {
+  padding-top: 10px;
+  padding-bottom: 10px;
+  line-height: 20px;
+}
+@media (max-width: 767px) {
+  .navbar-nav .open .dropdown-menu {
+    position: static;
+    float: none;
+    width: auto;
+    margin-top: 0;
+    background-color: transparent;
+    border: 0;
+    box-shadow: none;
+  }
+  .navbar-nav .open .dropdown-menu > li > a,
+  .navbar-nav .open .dropdown-menu .dropdown-header {
+    padding: 5px 15px 5px 25px;
+  }
+  .navbar-nav .open .dropdown-menu > li > a {
+    line-height: 20px;
+  }
+  .navbar-nav .open .dropdown-menu > li > a:hover,
+  .navbar-nav .open .dropdown-menu > li > a:focus {
+    background-image: none;
+  }
+}
+@media (min-width: 768px) {
+  .navbar-nav {
+    float: left;
+    margin: 0;
+  }
+  .navbar-nav > li {
+    float: left;
+  }
+  .navbar-nav > li > a {
+    padding-top: 15px;
+    padding-bottom: 15px;
+  }
+  .navbar-nav.navbar-right:first-child {
+    margin-right: -15px;
+  }
+}
+@media (min-width: 768px) {
+  .navbar-left {
+    float: left !important;
+  }
+  .navbar-right {
+    float: right !important;
+  }
+}
+.navbar-form {
+  margin-left: -15px;
+  margin-right: -15px;
+  padding: 10px 15px;
+  border-top: 1px solid transparent;
+  border-bottom: 1px solid transparent;
+  -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1);
+  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1);
+  margin-top: 8px;
+  margin-bottom: 8px;
+}
+@media (min-width: 768px) {
+  .navbar-form .form-group {
+    display: inline-block;
+    margin-bottom: 0;
+    vertical-align: middle;
+  }
+  .navbar-form .form-control {
+    display: inline-block;
+    width: auto;
+    vertical-align: middle;
+  }
+  .navbar-form .input-group {
+    display: inline-table;
+    vertical-align: middle;
+  }
+  .navbar-form .input-group .input-group-addon,
+  .navbar-form .input-group .input-group-btn,
+  .navbar-form .input-group .form-control {
+    width: auto;
+  }
+  .navbar-form .input-group > .form-control {
+    width: 100%;
+  }
+  .navbar-form .control-label {
+    margin-bottom: 0;
+    vertical-align: middle;
+  }
+  .navbar-form .radio,
+  .navbar-form .checkbox {
+    display: inline-block;
+    margin-top: 0;
+    margin-bottom: 0;
+    vertical-align: middle;
+  }
+  .navbar-form .radio label,
+  .navbar-form .checkbox label {
+    padding-left: 0;
+  }
+  .navbar-form .radio input[type="radio"],
+  .navbar-form .checkbox input[type="checkbox"] {
+    position: relative;
+    margin-left: 0;
+  }
+  .navbar-form .has-feedback .form-control-feedback {
+    top: 0;
+  }
+}
+@media (max-width: 767px) {
+  .navbar-form .form-group {
+    margin-bottom: 5px;
+  }
+}
+@media (min-width: 768px) {
+  .navbar-form {
+    width: auto;
+    border: 0;
+    margin-left: 0;
+    margin-right: 0;
+    padding-top: 0;
+    padding-bottom: 0;
+    -webkit-box-shadow: none;
+    box-shadow: none;
+  }
+  .navbar-form.navbar-right:first-child {
+    margin-right: -15px;
+  }
+}
+.navbar-nav > li > .dropdown-menu {
+  margin-top: 0;
+  border-top-right-radius: 0;
+  border-top-left-radius: 0;
+}
+.navbar-fixed-bottom .navbar-nav > li > .dropdown-menu {
+  border-bottom-right-radius: 0;
+  border-bottom-left-radius: 0;
+}
+.navbar-btn {
+  margin-top: 8px;
+  margin-bottom: 8px;
+}
+.navbar-btn.btn-sm {
+  margin-top: 10px;
+  margin-bottom: 10px;
+}
+.navbar-btn.btn-xs {
+  margin-top: 14px;
+  margin-bottom: 14px;
+}
+.navbar-text {
+  margin-top: 15px;
+  margin-bottom: 15px;
+}
+@media (min-width: 768px) {
+  .navbar-text {
+    float: left;
+    margin-left: 15px;
+    margin-right: 15px;
+  }
+  .navbar-text.navbar-right:first-child {
+    margin-right: 0;
+  }
+}
+.navbar-default {
+  background-color: #f8f8f8;
+  border-color: #e7e7e7;
+}
+.navbar-default .navbar-brand {
+  color: #777777;
+}
+.navbar-default .navbar-brand:hover,
+.navbar-default .navbar-brand:focus {
+  color: #5e5e5e;
+  background-color: transparent;
+}
+.navbar-default .navbar-text {
+  color: #777777;
+}
+.navbar-default .navbar-nav > li > a {
+  color: #777777;
+}
+.navbar-default .navbar-nav > li > a:hover,
+.navbar-default .navbar-nav > li > a:focus {
+  color: #333333;
+  background-color: transparent;
+}
+.navbar-default .navbar-nav > .active > a,
+.navbar-default .navbar-nav > .active > a:hover,
+.navbar-default .navbar-nav > .active > a:focus {
+  color: #555555;
+  background-color: #e7e7e7;
+}
+.navbar-default .navbar-nav > .disabled > a,
+.navbar-default .navbar-nav > .disabled > a:hover,
+.navbar-default .navbar-nav > .disabled > a:focus {
+  color: #cccccc;
+  background-color: transparent;
+}
+.navbar-default .navbar-toggle {
+  border-color: #dddddd;
+}
+.navbar-default .navbar-toggle:hover,
+.navbar-default .navbar-toggle:focus {
+  background-color: #dddddd;
+}
+.navbar-default .navbar-toggle .icon-bar {
+  background-color: #888888;
+}
+.navbar-default .navbar-collapse,
+.navbar-default .navbar-form {
+  border-color: #e7e7e7;
+}
+.navbar-default .navbar-nav > .open > a,
+.navbar-default .navbar-nav > .open > a:hover,
+.navbar-default .navbar-nav > .open > a:focus {
+  background-color: #e7e7e7;
+  color: #555555;
+}
+@media (max-width: 767px) {
+  .navbar-default .navbar-nav .open .dropdown-menu > li > a {
+    color: #777777;
+  }
+  .navbar-default .navbar-nav .open .dropdown-menu > li > a:hover,
+  .navbar-default .navbar-nav .open .dropdown-menu > li > a:focus {
+    color: #333333;
+    background-color: transparent;
+  }
+  .navbar-default .navbar-nav .open .dropdown-menu > .active > a,
+  .navbar-default .navbar-nav .open .dropdown-menu > .active > a:hover,
+  .navbar-default .navbar-nav .open .dropdown-menu > .active > a:focus {
+    color: #555555;
+    background-color: #e7e7e7;
+  }
+  .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a,
+  .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:hover,
+  .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:focus {
+    color: #cccccc;
+    background-color: transparent;
+  }
+}
+.navbar-default .navbar-link {
+  color: #777777;
+}
+.navbar-default .navbar-link:hover {
+  color: #333333;
+}
+.navbar-default .btn-link {
+  color: #777777;
+}
+.navbar-default .btn-link:hover,
+.navbar-default .btn-link:focus {
+  color: #333333;
+}
+.navbar-default .btn-link[disabled]:hover,
+fieldset[disabled] .navbar-default .btn-link:hover,
+.navbar-default .btn-link[disabled]:focus,
+fieldset[disabled] .navbar-default .btn-link:focus {
+  color: #cccccc;
+}
+.navbar-inverse {
+  background-color: #222222;
+  border-color: #080808;
+}
+.navbar-inverse .navbar-brand {
+  color: #777777;
+}
+.navbar-inverse .navbar-brand:hover,
+.navbar-inverse .navbar-brand:focus {
+  color: #ffffff;
+  background-color: transparent;
+}
+.navbar-inverse .navbar-text {
+  color: #969696;
+}
+.navbar-inverse .navbar-nav > li > a {
+  color: #777777;
+}
+.navbar-inverse .navbar-nav > li > a:hover,
+.navbar-inverse .navbar-nav > li > a:focus {
+  color: #ffffff;
+  background-color: transparent;
+}
+.navbar-inverse .navbar-nav > .active > a,
+.navbar-inverse .navbar-nav > .active > a:hover,
+.navbar-inverse .navbar-nav > .active > a:focus {
+  color: #ffffff;
+  background-color: #080808;
+}
+.navbar-inverse .navbar-nav > .disabled > a,
+.navbar-inverse .navbar-nav > .disabled > a:hover,
+.navbar-inverse .navbar-nav > .disabled > a:focus {
+  color: #444444;
+  background-color: transparent;
+}
+.navbar-inverse .navbar-toggle {
+  border-color: #333333;
+}
+.navbar-inverse .navbar-toggle:hover,
+.navbar-inverse .navbar-toggle:focus {
+  background-color: #333333;
+}
+.navbar-inverse .navbar-toggle .icon-bar {
+  background-color: #ffffff;
+}
+.navbar-inverse .navbar-collapse,
+.navbar-inverse .navbar-form {
+  border-color: #101010;
+}
+.navbar-inverse .navbar-nav > .open > a,
+.navbar-inverse .navbar-nav > .open > a:hover,
+.navbar-inverse .navbar-nav > .open > a:focus {
+  background-color: #080808;
+  color: #ffffff;
+}
+@media (max-width: 767px) {
+  .navbar-inverse .navbar-nav .open .dropdown-menu > .dropdown-header {
+    border-color: #080808;
+  }
+  .navbar-inverse .navbar-nav .open .dropdown-menu .divider {
+    background-color: #080808;
+  }
+  .navbar-inverse .navbar-nav .open .dropdown-menu > li > a {
+    color: #777777;
+  }
+  .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:hover,
+  .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:focus {
+    color: #ffffff;
+    background-color: transparent;
+  }
+  .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a,
+  .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:hover,
+  .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:focus {
+    color: #ffffff;
+    background-color: #080808;
+  }
+  .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a,
+  .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a:hover,
+  .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a:focus {
+    color: #444444;
+    background-color: transparent;
+  }
+}
+.navbar-inverse .navbar-link {
+  color: #777777;
+}
+.navbar-inverse .navbar-link:hover {
+  color: #ffffff;
+}
+.navbar-inverse .btn-link {
+  color: #777777;
+}
+.navbar-inverse .btn-link:hover,
+.navbar-inverse .btn-link:focus {
+  color: #ffffff;
+}
+.navbar-inverse .btn-link[disabled]:hover,
+fieldset[disabled] .navbar-inverse .btn-link:hover,
+.navbar-inverse .btn-link[disabled]:focus,
+fieldset[disabled] .navbar-inverse .btn-link:focus {
+  color: #444444;
+}
+.breadcrumb {
+  padding: 8px 15px;
+  margin-bottom: 20px;
+  list-style: none;
+  background-color: #f5f5f5;
+  border-radius: 4px;
+}
+.breadcrumb > li {
+  display: inline-block;
+}
+.breadcrumb > li + li:before {
+  content: "/\00a0";
+  padding: 0 5px;
+  color: #cccccc;
+}
+.breadcrumb > .active {
+  color: #777777;
+}
+.pagination {
+  display: inline-block;
+  padding-left: 0;
+  margin: 20px 0;
+  border-radius: 4px;
+}
+.pagination > li {
+  display: inline;
+}
+.pagination > li > a,
+.pagination > li > span {
+  position: relative;
+  float: left;
+  padding: 6px 12px;
+  line-height: 1.42857143;
+  text-decoration: none;
+  color: #428bca;
+  background-color: #ffffff;
+  border: 1px solid #dddddd;
+  margin-left: -1px;
+}
+.pagination > li:first-child > a,
+.pagination > li:first-child > span {
+  margin-left: 0;
+  border-bottom-left-radius: 4px;
+  border-top-left-radius: 4px;
+}
+.pagination > li:last-child > a,
+.pagination > li:last-child > span {
+  border-bottom-right-radius: 4px;
+  border-top-right-radius: 4px;
+}
+.pagination > li > a:hover,
+.pagination > li > span:hover,
+.pagination > li > a:focus,
+.pagination > li > span:focus {
+  color: #2a6496;
+  background-color: #eeeeee;
+  border-color: #dddddd;
+}
+.pagination > .active > a,
+.pagination > .active > span,
+.pagination > .active > a:hover,
+.pagination > .active > span:hover,
+.pagination > .active > a:focus,
+.pagination > .active > span:focus {
+  z-index: 2;
+  color: #ffffff;
+  background-color: #428bca;
+  border-color: #428bca;
+  cursor: default;
+}
+.pagination > .disabled > span,
+.pagination > .disabled > span:hover,
+.pagination > .disabled > span:focus,
+.pagination > .disabled > a,
+.pagination > .disabled > a:hover,
+.pagination > .disabled > a:focus {
+  color: #777777;
+  background-color: #ffffff;
+  border-color: #dddddd;
+  cursor: not-allowed;
+}
+.pagination-lg > li > a,
+.pagination-lg > li > span {
+  padding: 10px 16px;
+  font-size: 18px;
+}
+.pagination-lg > li:first-child > a,
+.pagination-lg > li:first-child > span {
+  border-bottom-left-radius: 6px;
+  border-top-left-radius: 6px;
+}
+.pagination-lg > li:last-child > a,
+.pagination-lg > li:last-child > span {
+  border-bottom-right-radius: 6px;
+  border-top-right-radius: 6px;
+}
+.pagination-sm > li > a,
+.pagination-sm > li > span {
+  padding: 5px 10px;
+  font-size: 12px;
+}
+.pagination-sm > li:first-child > a,
+.pagination-sm > li:first-child > span {
+  border-bottom-left-radius: 3px;
+  border-top-left-radius: 3px;
+}
+.pagination-sm > li:last-child > a,
+.pagination-sm > li:last-child > span {
+  border-bottom-right-radius: 3px;
+  border-top-right-radius: 3px;
+}
+.pager {
+  padding-left: 0;
+  margin: 20px 0;
+  list-style: none;
+  text-align: center;
+}
+.pager li {
+  display: inline;
+}
+.pager li > a,
+.pager li > span {
+  display: inline-block;
+  padding: 5px 14px;
+  background-color: #ffffff;
+  border: 1px solid #dddddd;
+  border-radius: 15px;
+}
+.pager li > a:hover,
+.pager li > a:focus {
+  text-decoration: none;
+  background-color: #eeeeee;
+}
+.pager .next > a,
+.pager .next > span {
+  float: right;
+}
+.pager .previous > a,
+.pager .previous > span {
+  float: left;
+}
+.pager .disabled > a,
+.pager .disabled > a:hover,
+.pager .disabled > a:focus,
+.pager .disabled > span {
+  color: #777777;
+  background-color: #ffffff;
+  cursor: not-allowed;
+}
+.label {
+  display: inline;
+  padding: .2em .6em .3em;
+  font-size: 75%;
+  font-weight: bold;
+  line-height: 1;
+  color: #ffffff;
+  text-align: center;
+  white-space: nowrap;
+  vertical-align: baseline;
+  border-radius: .25em;
+}
+a.label:hover,
+a.label:focus {
+  color: #ffffff;
+  text-decoration: none;
+  cursor: pointer;
+}
+.label:empty {
+  display: none;
+}
+.btn .label {
+  position: relative;
+  top: -1px;
+}
+.label-default {
+  background-color: #777777;
+}
+.label-default[href]:hover,
+.label-default[href]:focus {
+  background-color: #5e5e5e;
+}
+.label-primary {
+  background-color: #428bca;
+}
+.label-primary[href]:hover,
+.label-primary[href]:focus {
+  background-color: #3071a9;
+}
+.label-success {
+  background-color: #5cb85c;
+}
+.label-success[href]:hover,
+.label-success[href]:focus {
+  background-color: #449d44;
+}
+.label-info {
+  background-color: #5bc0de;
+}
+.label-info[href]:hover,
+.label-info[href]:focus {
+  background-color: #31b0d5;
+}
+.label-warning {
+  background-color: #f0ad4e;
+}
+.label-warning[href]:hover,
+.label-warning[href]:focus {
+  background-color: #ec971f;
+}
+.label-danger {
+  background-color: #d9534f;
+}
+.label-danger[href]:hover,
+.label-danger[href]:focus {
+  background-color: #c9302c;
+}
+.badge {
+  display: inline-block;
+  min-width: 10px;
+  padding: 3px 7px;
+  font-size: 12px;
+  font-weight: bold;
+  color: #ffffff;
+  line-height: 1;
+  vertical-align: baseline;
+  white-space: nowrap;
+  text-align: center;
+  background-color: #777777;
+  border-radius: 10px;
+}
+.badge:empty {
+  display: none;
+}
+.btn .badge {
+  position: relative;
+  top: -1px;
+}
+.btn-xs .badge {
+  top: 0;
+  padding: 1px 5px;
+}
+a.badge:hover,
+a.badge:focus {
+  color: #ffffff;
+  text-decoration: none;
+  cursor: pointer;
+}
+a.list-group-item.active > .badge,
+.nav-pills > .active > a > .badge {
+  color: #428bca;
+  background-color: #ffffff;
+}
+.nav-pills > li > a > .badge {
+  margin-left: 3px;
+}
+.jumbotron {
+  padding: 30px;
+  margin-bottom: 30px;
+  color: inherit;
+  background-color: #eeeeee;
+}
+.jumbotron h1,
+.jumbotron .h1 {
+  color: inherit;
+}
+.jumbotron p {
+  margin-bottom: 15px;
+  font-size: 21px;
+  font-weight: 200;
+}
+.jumbotron > hr {
+  border-top-color: #d5d5d5;
+}
+.container .jumbotron {
+  border-radius: 6px;
+}
+.jumbotron .container {
+  max-width: 100%;
+}
+@media screen and (min-width: 768px) {
+  .jumbotron {
+    padding-top: 48px;
+    padding-bottom: 48px;
+  }
+  .container .jumbotron {
+    padding-left: 60px;
+    padding-right: 60px;
+  }
+  .jumbotron h1,
+  .jumbotron .h1 {
+    font-size: 63px;
+  }
+}
+
+
+.embed-responsive {
+  position: relative;
+  display: block;
+  height: 0;
+  padding: 0;
+  overflow: hidden;
+}
+.embed-responsive .embed-responsive-item,
+.embed-responsive iframe,
+.embed-responsive embed,
+.embed-responsive object {
+  position: absolute;
+  top: 0;
+  left: 0;
+  bottom: 0;
+  height: 100%;
+  width: 100%;
+  border: 0;
+}
+.embed-responsive.embed-responsive-16by9 {
+  padding-bottom: 56.25%;
+}
+.embed-responsive.embed-responsive-4by3 {
+  padding-bottom: 75%;
+}
+.well {
+  min-height: 20px;
+  padding: 19px;
+  margin-bottom: 20px;
+  background-color: #f5f5f5;
+  border: 1px solid #e3e3e3;
+  border-radius: 4px;
+  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
+  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
+}
+.well blockquote {
+  border-color: #ddd;
+  border-color: rgba(0, 0, 0, 0.15);
+}
+.well-lg {
+  padding: 24px;
+  border-radius: 6px;
+}
+.well-sm {
+  padding: 9px;
+  border-radius: 3px;
+}
+.close {
+  float: right;
+  font-size: 21px;
+  font-weight: bold;
+  line-height: 1;
+  color: #000000;
+  text-shadow: 0 1px 0 #ffffff;
+  opacity: 0.2;
+  filter: alpha(opacity=20);
+}
+.close:hover,
+.close:focus {
+  color: #000000;
+  text-decoration: none;
+  cursor: pointer;
+  opacity: 0.5;
+  filter: alpha(opacity=50);
+}
+button.close {
+  padding: 0;
+  cursor: pointer;
+  background: transparent;
+  border: 0;
+  -webkit-appearance: none;
+}
+.modal-open {
+  overflow: hidden;
+}
+.modal {
+  display: none;
+  overflow: hidden;
+  position: fixed;
+  top: 0;
+  right: 0;
+  bottom: 0;
+  left: 0;
+  z-index: 1050;
+  -webkit-overflow-scrolling: touch;
+  outline: 0;
+}
+.modal.fade .modal-dialog {
+  -webkit-transform: translate3d(0, -25%, 0);
+  transform: translate3d(0, -25%, 0);
+  -webkit-transition: -webkit-transform 0.3s ease-out;
+  -moz-transition: -moz-transform 0.3s ease-out;
+  -o-transition: -o-transform 0.3s ease-out;
+  transition: transform 0.3s ease-out;
+}
+.modal.in .modal-dialog {
+  -webkit-transform: translate3d(0, 0, 0);
+  transform: translate3d(0, 0, 0);
+}
+.modal-open .modal {
+  overflow-x: hidden;
+  overflow-y: auto;
+}
+.modal-dialog {
+  position: relative;
+  width: auto;
+  margin: 10px;
+}
+.modal-content {
+  position: relative;
+  background-color: #ffffff;
+  border: 1px solid #999999;
+  border: 1px solid rgba(0, 0, 0, 0.2);
+  border-radius: 6px;
+  -webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
+  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
+  background-clip: padding-box;
+  outline: 0;
+}
+.modal-backdrop {
+  position: fixed;
+  top: 0;
+  right: 0;
+  bottom: 0;
+  left: 0;
+  z-index: 1040;
+  background-color: #000000;
+}
+.modal-backdrop.fade {
+  opacity: 0;
+  filter: alpha(opacity=0);
+}
+.modal-backdrop.in {
+  opacity: 0.5;
+  filter: alpha(opacity=50);
+}
+.modal-header {
+  padding: 15px;
+  border-bottom: 1px solid #e5e5e5;
+  min-height: 16.42857143px;
+}
+.modal-header .close {
+  margin-top: -2px;
+}
+.modal-title {
+  margin: 0;
+  line-height: 1.42857143;
+}
+.modal-body {
+  position: relative;
+  padding: 15px;
+}
+.modal-footer {
+  padding: 15px;
+  text-align: right;
+  border-top: 1px solid #e5e5e5;
+}
+.modal-footer .btn + .btn {
+  margin-left: 5px;
+  margin-bottom: 0;
+}
+.modal-footer .btn-group .btn + .btn {
+  margin-left: -1px;
+}
+.modal-footer .btn-block + .btn-block {
+  margin-left: 0;
+}
+.modal-scrollbar-measure {
+  position: absolute;
+  top: -9999px;
+  width: 50px;
+  height: 50px;
+  overflow: scroll;
+}
+@media (min-width: 768px) {
+  .modal-dialog {
+    width: 600px;
+    margin: 30px auto;
+  }
+  .modal-content {
+    -webkit-box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
+    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
+  }
+  .modal-sm {
+    width: 300px;
+  }
+}
+@media (min-width: 992px) {
+  .modal-lg {
+    width: 900px;
+  }
+}
+
+.thumbnail {
+  display: block;
+  padding: 4px;
+  margin-bottom: 20px;
+  line-height: 1.42857143;
+  background-color: #ffffff;
+  border: 1px solid #dddddd;
+  border-radius: 4px;
+  -webkit-transition: all 0.2s ease-in-out;
+  -o-transition: all 0.2s ease-in-out;
+  transition: all 0.2s ease-in-out;
+}
+.thumbnail > img,
+.thumbnail a > img {
+  margin-left: auto;
+  margin-right: auto;
+}
+a.thumbnail:hover,
+a.thumbnail:focus,
+a.thumbnail.active {
+  border-color: #428bca;
+}
+.thumbnail .caption {
+  padding: 9px;
+  color: #333333;
+}
+.alert {
+  padding: 15px;
+  margin-bottom: 20px;
+  border: 1px solid transparent;
+  border-radius: 4px;
+}
+.alert h4 {
+  margin-top: 0;
+  color: inherit;
+}
+.alert .alert-link {
+  font-weight: bold;
+}
+.alert > p,
+.alert > ul {
+  margin-bottom: 0;
+}
+.alert > p + p {
+  margin-top: 5px;
+}
+.alert-dismissable,
+.alert-dismissible {
+  padding-right: 35px;
+}
+.alert-dismissable .close,
+.alert-dismissible .close {
+  position: relative;
+  top: -2px;
+  right: -21px;
+  color: inherit;
+}
+.alert-success {
+  background-color: #dff0d8;
+  border-color: #d6e9c6;
+  color: #3c763d;
+}
+.alert-success hr {
+  border-top-color: #c9e2b3;
+}
+.alert-success .alert-link {
+  color: #2b542c;
+}
+.alert-info {
+  background-color: #d9edf7;
+  border-color: #bce8f1;
+  color: #31708f;
+}
+.alert-info hr {
+  border-top-color: #a6e1ec;
+}
+.alert-info .alert-link {
+  color: #245269;
+}
+.alert-warning {
+  background-color: #fcf8e3;
+  border-color: #faebcc;
+  color: #8a6d3b;
+}
+.alert-warning hr {
+  border-top-color: #f7e1b5;
+}
+.alert-warning .alert-link {
+  color: #66512c;
+}
+.alert-danger {
+  background-color: #f2dede;
+  border-color: #ebccd1;
+  color: #a94442;
+}
+.alert-danger hr {
+  border-top-color: #e4b9c0;
+}
+.alert-danger .alert-link {
+  color: #843534;
+}
+@-webkit-keyframes progress-bar-stripes {
+  from {
+    background-position: 40px 0;
+  }
+  to {
+    background-position: 0 0;
+  }
+}
+@keyframes progress-bar-stripes {
+  from {
+    background-position: 40px 0;
+  }
+  to {
+    background-position: 0 0;
+  }
+}
+
+.media,
+.media-body {
+  overflow: hidden;
+  zoom: 1;
+}
+.media,
+.media .media {
+  margin-top: 15px;
+}
+.media:first-child {
+  margin-top: 0;
+}
+.media-object {
+  display: block;
+}
+.media-heading {
+  margin: 0 0 5px;
+}
+.media > .pull-left {
+  margin-right: 10px;
+}
+.media > .pull-right {
+  margin-left: 10px;
+}
+.media-list {
+  padding-left: 0;
+  list-style: none;
+}
+.list-group {
+  margin-bottom: 20px;
+  padding-left: 0;
+}
+.list-group-item {
+  position: relative;
+  display: block;
+  padding: 10px 15px;
+  margin-bottom: -1px;
+  background-color: #ffffff;
+  border: 1px solid #dddddd;
+}
+.list-group-item:first-child {
+  border-top-right-radius: 4px;
+  border-top-left-radius: 4px;
+}
+.list-group-item:last-child {
+  margin-bottom: 0;
+  border-bottom-right-radius: 4px;
+  border-bottom-left-radius: 4px;
+}
+.list-group-item > .badge {
+  float: right;
+}
+.list-group-item > .badge + .badge {
+  margin-right: 5px;
+}
+a.list-group-item {
+  color: #555555;
+}
+a.list-group-item .list-group-item-heading {
+  color: #333333;
+}
+a.list-group-item:hover,
+a.list-group-item:focus {
+  text-decoration: none;
+  color: #555555;
+  background-color: #f5f5f5;
+}
+.list-group-item.disabled,
+.list-group-item.disabled:hover,
+.list-group-item.disabled:focus {
+  background-color: #eeeeee;
+  color: #777777;
+  cursor: not-allowed;
+}
+.list-group-item.disabled .list-group-item-heading,
+.list-group-item.disabled:hover .list-group-item-heading,
+.list-group-item.disabled:focus .list-group-item-heading {
+  color: inherit;
+}
+.list-group-item.disabled .list-group-item-text,
+.list-group-item.disabled:hover .list-group-item-text,
+.list-group-item.disabled:focus .list-group-item-text {
+  color: #777777;
+}
+.list-group-item.active,
+.list-group-item.active:hover,
+.list-group-item.active:focus {
+  z-index: 2;
+  color: #ffffff;
+  background-color: #428bca;
+  border-color: #428bca;
+}
+.list-group-item.active .list-group-item-heading,
+.list-group-item.active:hover .list-group-item-heading,
+.list-group-item.active:focus .list-group-item-heading,
+.list-group-item.active .list-group-item-heading > small,
+.list-group-item.active:hover .list-group-item-heading > small,
+.list-group-item.active:focus .list-group-item-heading > small,
+.list-group-item.active .list-group-item-heading > .small,
+.list-group-item.active:hover .list-group-item-heading > .small,
+.list-group-item.active:focus .list-group-item-heading > .small {
+  color: inherit;
+}
+.list-group-item.active .list-group-item-text,
+.list-group-item.active:hover .list-group-item-text,
+.list-group-item.active:focus .list-group-item-text {
+  color: #e1edf7;
+}
+.list-group-item-success {
+  color: #3c763d;
+  background-color: #dff0d8;
+}
+a.list-group-item-success {
+  color: #3c763d;
+}
+a.list-group-item-success .list-group-item-heading {
+  color: inherit;
+}
+a.list-group-item-success:hover,
+a.list-group-item-success:focus {
+  color: #3c763d;
+  background-color: #d0e9c6;
+}
+a.list-group-item-success.active,
+a.list-group-item-success.active:hover,
+a.list-group-item-success.active:focus {
+  color: #fff;
+  background-color: #3c763d;
+  border-color: #3c763d;
+}
+.list-group-item-info {
+  color: #31708f;
+  background-color: #d9edf7;
+}
+a.list-group-item-info {
+  color: #31708f;
+}
+a.list-group-item-info .list-group-item-heading {
+  color: inherit;
+}
+a.list-group-item-info:hover,
+a.list-group-item-info:focus {
+  color: #31708f;
+  background-color: #c4e3f3;
+}
+a.list-group-item-info.active,
+a.list-group-item-info.active:hover,
+a.list-group-item-info.active:focus {
+  color: #fff;
+  background-color: #31708f;
+  border-color: #31708f;
+}
+.list-group-item-warning {
+  color: #8a6d3b;
+  background-color: #fcf8e3;
+}
+a.list-group-item-warning {
+  color: #8a6d3b;
+}
+a.list-group-item-warning .list-group-item-heading {
+  color: inherit;
+}
+a.list-group-item-warning:hover,
+a.list-group-item-warning:focus {
+  color: #8a6d3b;
+  background-color: #faf2cc;
+}
+a.list-group-item-warning.active,
+a.list-group-item-warning.active:hover,
+a.list-group-item-warning.active:focus {
+  color: #fff;
+  background-color: #8a6d3b;
+  border-color: #8a6d3b;
+}
+.list-group-item-danger {
+  color: #a94442;
+  background-color: #f2dede;
+}
+a.list-group-item-danger {
+  color: #a94442;
+}
+a.list-group-item-danger .list-group-item-heading {
+  color: inherit;
+}
+a.list-group-item-danger:hover,
+a.list-group-item-danger:focus {
+  color: #a94442;
+  background-color: #ebcccc;
+}
+a.list-group-item-danger.active,
+a.list-group-item-danger.active:hover,
+a.list-group-item-danger.active:focus {
+  color: #fff;
+  background-color: #a94442;
+  border-color: #a94442;
+}
+.list-group-item-heading {
+  margin-top: 0;
+  margin-bottom: 5px;
+}
+.list-group-item-text {
+  margin-bottom: 0;
+  line-height: 1.3;
+}
+.panel {
+  margin-bottom: 20px;
+  background-color: #ffffff;
+  border: 1px solid transparent;
+  border-radius: 4px;
+  -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
+  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
+}
+.panel-body {
+  padding: 15px;
+}
+.panel-heading {
+  padding: 10px 15px;
+  border-bottom: 1px solid transparent;
+  border-top-right-radius: 3px;
+  border-top-left-radius: 3px;
+}
+.panel-heading > .dropdown .dropdown-toggle {
+  color: inherit;
+}
+.panel-title {
+  margin-top: 0;
+  margin-bottom: 0;
+  font-size: 16px;
+  color: inherit;
+}
+.panel-title > a {
+  color: inherit;
+}
+.panel-footer {
+  padding: 10px 15px;
+  background-color: #f5f5f5;
+  border-top: 1px solid #dddddd;
+  border-bottom-right-radius: 3px;
+  border-bottom-left-radius: 3px;
+}
+.panel > .list-group {
+  margin-bottom: 0;
+}
+.panel > .list-group .list-group-item {
+  border-width: 1px 0;
+  border-radius: 0;
+}
+.panel > .list-group:first-child .list-group-item:first-child {
+  border-top: 0;
+  border-top-right-radius: 3px;
+  border-top-left-radius: 3px;
+}
+.panel > .list-group:last-child .list-group-item:last-child {
+  border-bottom: 0;
+  border-bottom-right-radius: 3px;
+  border-bottom-left-radius: 3px;
+}
+.panel-heading + .list-group .list-group-item:first-child {
+  border-top-width: 0;
+}
+.list-group + .panel-footer {
+  border-top-width: 0;
+}
+.panel > .table,
+.panel > .table-responsive > .table,
+.panel > .panel-collapse > .table {
+  margin-bottom: 0;
+}
+.panel > .table:first-child,
+.panel > .table-responsive:first-child > .table:first-child {
+  border-top-right-radius: 3px;
+  border-top-left-radius: 3px;
+}
+.panel > .table:first-child > thead:first-child > tr:first-child td:first-child,
+.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child td:first-child,
+.panel > .table:first-child > tbody:first-child > tr:first-child td:first-child,
+.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child td:first-child,
+.panel > .table:first-child > thead:first-child > tr:first-child th:first-child,
+.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child th:first-child,
+.panel > .table:first-child > tbody:first-child > tr:first-child th:first-child,
+.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child th:first-child {
+  border-top-left-radius: 3px;
+}
+.panel > .table:first-child > thead:first-child > tr:first-child td:last-child,
+.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child td:last-child,
+.panel > .table:first-child > tbody:first-child > tr:first-child td:last-child,
+.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child td:last-child,
+.panel > .table:first-child > thead:first-child > tr:first-child th:last-child,
+.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child th:last-child,
+.panel > .table:first-child > tbody:first-child > tr:first-child th:last-child,
+.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child th:last-child {
+  border-top-right-radius: 3px;
+}
+.panel > .table:last-child,
+.panel > .table-responsive:last-child > .table:last-child {
+  border-bottom-right-radius: 3px;
+  border-bottom-left-radius: 3px;
+}
+.panel > .table:last-child > tbody:last-child > tr:last-child td:first-child,
+.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child td:first-child,
+.panel > .table:last-child > tfoot:last-child > tr:last-child td:first-child,
+.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child td:first-child,
+.panel > .table:last-child > tbody:last-child > tr:last-child th:first-child,
+.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child th:first-child,
+.panel > .table:last-child > tfoot:last-child > tr:last-child th:first-child,
+.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child th:first-child {
+  border-bottom-left-radius: 3px;
+}
+.panel > .table:last-child > tbody:last-child > tr:last-child td:last-child,
+.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child td:last-child,
+.panel > .table:last-child > tfoot:last-child > tr:last-child td:last-child,
+.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child td:last-child,
+.panel > .table:last-child > tbody:last-child > tr:last-child th:last-child,
+.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child th:last-child,
+.panel > .table:last-child > tfoot:last-child > tr:last-child th:last-child,
+.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child th:last-child {
+  border-bottom-right-radius: 3px;
+}
+.panel > .panel-body + .table,
+.panel > .panel-body + .table-responsive {
+  border-top: 1px solid #dddddd;
+}
+.panel > .table > tbody:first-child > tr:first-child th,
+.panel > .table > tbody:first-child > tr:first-child td {
+  border-top: 0;
+}
+.panel > .table-bordered,
+.panel > .table-responsive > .table-bordered {
+  border: 0;
+}
+.panel > .table-bordered > thead > tr > th:first-child,
+.panel > .table-responsive > .table-bordered > thead > tr > th:first-child,
+.panel > .table-bordered > tbody > tr > th:first-child,
+.panel > .table-responsive > .table-bordered > tbody > tr > th:first-child,
+.panel > .table-bordered > tfoot > tr > th:first-child,
+.panel > .table-responsive > .table-bordered > tfoot > tr > th:first-child,
+.panel > .table-bordered > thead > tr > td:first-child,
+.panel > .table-responsive > .table-bordered > thead > tr > td:first-child,
+.panel > .table-bordered > tbody > tr > td:first-child,
+.panel > .table-responsive > .table-bordered > tbody > tr > td:first-child,
+.panel > .table-bordered > tfoot > tr > td:first-child,
+.panel > .table-responsive > .table-bordered > tfoot > tr > td:first-child {
+  border-left: 0;
+}
+.panel > .table-bordered > thead > tr > th:last-child,
+.panel > .table-responsive > .table-bordered > thead > tr > th:last-child,
+.panel > .table-bordered > tbody > tr > th:last-child,
+.panel > .table-responsive > .table-bordered > tbody > tr > th:last-child,
+.panel > .table-bordered > tfoot > tr > th:last-child,
+.panel > .table-responsive > .table-bordered > tfoot > tr > th:last-child,
+.panel > .table-bordered > thead > tr > td:last-child,
+.panel > .table-responsive > .table-bordered > thead > tr > td:last-child,
+.panel > .table-bordered > tbody > tr > td:last-child,
+.panel > .table-responsive > .table-bordered > tbody > tr > td:last-child,
+.panel > .table-bordered > tfoot > tr > td:last-child,
+.panel > .table-responsive > .table-bordered > tfoot > tr > td:last-child {
+  border-right: 0;
+}
+.panel > .table-bordered > thead > tr:first-child > td,
+.panel > .table-responsive > .table-bordered > thead > tr:first-child > td,
+.panel > .table-bordered > tbody > tr:first-child > td,
+.panel > .table-responsive > .table-bordered > tbody > tr:first-child > td,
+.panel > .table-bordered > thead > tr:first-child > th,
+.panel > .table-responsive > .table-bordered > thead > tr:first-child > th,
+.panel > .table-bordered > tbody > tr:first-child > th,
+.panel > .table-responsive > .table-bordered > tbody > tr:first-child > th {
+  border-bottom: 0;
+}
+.panel > .table-bordered > tbody > tr:last-child > td,
+.panel > .table-responsive > .table-bordered > tbody > tr:last-child > td,
+.panel > .table-bordered > tfoot > tr:last-child > td,
+.panel > .table-responsive > .table-bordered > tfoot > tr:last-child > td,
+.panel > .table-bordered > tbody > tr:last-child > th,
+.panel > .table-responsive > .table-bordered > tbody > tr:last-child > th,
+.panel > .table-bordered > tfoot > tr:last-child > th,
+.panel > .table-responsive > .table-bordered > tfoot > tr:last-child > th {
+  border-bottom: 0;
+}
+.panel > .table-responsive {
+  border: 0;
+  margin-bottom: 0;
+}
+.panel-group {
+  margin-bottom: 20px;
+}
+.panel-group .panel {
+  margin-bottom: 0;
+  border-radius: 4px;
+}
+.panel-group .panel + .panel {
+  margin-top: 5px;
+}
+.panel-group .panel-heading {
+  border-bottom: 0;
+}
+.panel-group .panel-heading + .panel-collapse > .panel-body {
+  border-top: 1px solid #dddddd;
+}
+.panel-group .panel-footer {
+  border-top: 0;
+}
+.panel-group .panel-footer + .panel-collapse .panel-body {
+  border-bottom: 1px solid #dddddd;
+}
+.panel-default {
+  border-color: #dddddd;
+}
+.panel-default > .panel-heading {
+  color: #333333;
+  background-color: #f5f5f5;
+  border-color: #dddddd;
+}
+.panel-default > .panel-heading + .panel-collapse > .panel-body {
+  border-top-color: #dddddd;
+}
+.panel-default > .panel-heading .badge {
+  color: #f5f5f5;
+  background-color: #333333;
+}
+.panel-default > .panel-footer + .panel-collapse > .panel-body {
+  border-bottom-color: #dddddd;
+}
+.panel-primary {
+  border-color: #428bca;
+}
+.panel-primary > .panel-heading {
+  color: #ffffff;
+  background-color: #428bca;
+  border-color: #428bca;
+}
+.panel-primary > .panel-heading + .panel-collapse > .panel-body {
+  border-top-color: #428bca;
+}
+.panel-primary > .panel-heading .badge {
+  color: #428bca;
+  background-color: #ffffff;
+}
+.panel-primary > .panel-footer + .panel-collapse > .panel-body {
+  border-bottom-color: #428bca;
+}
+.panel-success {
+  border-color: #d6e9c6;
+}
+.panel-success > .panel-heading {
+  color: #3c763d;
+  background-color: #dff0d8;
+  border-color: #d6e9c6;
+}
+.panel-success > .panel-heading + .panel-collapse > .panel-body {
+  border-top-color: #d6e9c6;
+}
+.panel-success > .panel-heading .badge {
+  color: #dff0d8;
+  background-color: #3c763d;
+}
+.panel-success > .panel-footer + .panel-collapse > .panel-body {
+  border-bottom-color: #d6e9c6;
+}
+.panel-info {
+  border-color: #bce8f1;
+}
+.panel-info > .panel-heading {
+  color: #31708f;
+  background-color: #d9edf7;
+  border-color: #bce8f1;
+}
+.panel-info > .panel-heading + .panel-collapse > .panel-body {
+  border-top-color: #bce8f1;
+}
+.panel-info > .panel-heading .badge {
+  color: #d9edf7;
+  background-color: #31708f;
+}
+.panel-info > .panel-footer + .panel-collapse > .panel-body {
+  border-bottom-color: #bce8f1;
+}
+.panel-warning {
+  border-color: #faebcc;
+}
+.panel-warning > .panel-heading {
+  color: #8a6d3b;
+  background-color: #fcf8e3;
+  border-color: #faebcc;
+}
+.panel-warning > .panel-heading + .panel-collapse > .panel-body {
+  border-top-color: #faebcc;
+}
+.panel-warning > .panel-heading .badge {
+  color: #fcf8e3;
+  background-color: #8a6d3b;
+}
+.panel-warning > .panel-footer + .panel-collapse > .panel-body {
+  border-bottom-color: #faebcc;
+}
+.panel-danger {
+  border-color: #ebccd1;
+}
+.panel-danger > .panel-heading {
+  color: #a94442;
+  background-color: #f2dede;
+  border-color: #ebccd1;
+}
+.panel-danger > .panel-heading + .panel-collapse > .panel-body {
+  border-top-color: #ebccd1;
+}
+.panel-danger > .panel-heading .badge {
+  color: #f2dede;
+  background-color: #a94442;
+}
+.panel-danger > .panel-footer + .panel-collapse > .panel-body {
+  border-bottom-color: #ebccd1;
+}
+
+
+.pull-right {
+  float: right !important;
+}
+.pull-left {
+  float: left !important;
+}
+.hide {
+  display: none !important;
+}
+.show {
+  display: block !important;
+}
+.invisible {
+  visibility: hidden;
+}
+.text-hide {
+  font: 0/0 a;
+  color: transparent;
+  text-shadow: none;
+  background-color: transparent;
+  border: 0;
+}
+.hidden {
+  display: none !important;
+  visibility: hidden !important;
+}
+.affix {
+  position: fixed;
+  -webkit-transform: translate3d(0, 0, 0);
+  transform: translate3d(0, 0, 0);
+}
+@-ms-viewport {
+  width: device-width;
+}
+.visible-xs,
+.visible-sm,
+.visible-md,
+.visible-lg {
+  display: none !important;
+}
+.visible-xs-block,
+.visible-xs-inline,
+.visible-xs-inline-block,
+.visible-sm-block,
+.visible-sm-inline,
+.visible-sm-inline-block,
+.visible-md-block,
+.visible-md-inline,
+.visible-md-inline-block,
+.visible-lg-block,
+.visible-lg-inline,
+.visible-lg-inline-block {
+  display: none !important;
+}
+@media (max-width: 767px) {
+  .visible-xs {
+    display: block !important;
+  }
+  table.visible-xs {
+    display: table;
+  }
+  tr.visible-xs {
+    display: table-row !important;
+  }
+  th.visible-xs,
+  td.visible-xs {
+    display: table-cell !important;
+  }
+}
+@media (max-width: 767px) {
+  .visible-xs-block {
+    display: block !important;
+  }
+}
+@media (max-width: 767px) {
+  .visible-xs-inline {
+    display: inline !important;
+  }
+}
+@media (max-width: 767px) {
+  .visible-xs-inline-block {
+    display: inline-block !important;
+  }
+}
+@media (min-width: 768px) and (max-width: 991px) {
+  .visible-sm {
+    display: block !important;
+  }
+  table.visible-sm {
+    display: table;
+  }
+  tr.visible-sm {
+    display: table-row !important;
+  }
+  th.visible-sm,
+  td.visible-sm {
+    display: table-cell !important;
+  }
+}
+@media (min-width: 768px) and (max-width: 991px) {
+  .visible-sm-block {
+    display: block !important;
+  }
+}
+@media (min-width: 768px) and (max-width: 991px) {
+  .visible-sm-inline {
+    display: inline !important;
+  }
+}
+@media (min-width: 768px) and (max-width: 991px) {
+  .visible-sm-inline-block {
+    display: inline-block !important;
+  }
+}
+@media (min-width: 992px) and (max-width: 1199px) {
+  .visible-md {
+    display: block !important;
+  }
+  table.visible-md {
+    display: table;
+  }
+  tr.visible-md {
+    display: table-row !important;
+  }
+  th.visible-md,
+  td.visible-md {
+    display: table-cell !important;
+  }
+}
+@media (min-width: 992px) and (max-width: 1199px) {
+  .visible-md-block {
+    display: block !important;
+  }
+}
+@media (min-width: 992px) and (max-width: 1199px) {
+  .visible-md-inline {
+    display: inline !important;
+  }
+}
+@media (min-width: 992px) and (max-width: 1199px) {
+  .visible-md-inline-block {
+    display: inline-block !important;
+  }
+}
+@media (min-width: 1200px) {
+  .visible-lg {
+    display: block !important;
+  }
+  table.visible-lg {
+    display: table;
+  }
+  tr.visible-lg {
+    display: table-row !important;
+  }
+  th.visible-lg,
+  td.visible-lg {
+    display: table-cell !important;
+  }
+}
+@media (min-width: 1200px) {
+  .visible-lg-block {
+    display: block !important;
+  }
+}
+@media (min-width: 1200px) {
+  .visible-lg-inline {
+    display: inline !important;
+  }
+}
+@media (min-width: 1200px) {
+  .visible-lg-inline-block {
+    display: inline-block !important;
+  }
+}
+@media (max-width: 767px) {
+  .hidden-xs {
+    display: none !important;
+  }
+}
+@media (min-width: 768px) and (max-width: 991px) {
+  .hidden-sm {
+    display: none !important;
+  }
+}
+@media (min-width: 992px) and (max-width: 1199px) {
+  .hidden-md {
+    display: none !important;
+  }
+}
+@media (min-width: 1200px) {
+  .hidden-lg {
+    display: none !important;
+  }
+}
+.visible-print {
+  display: none !important;
+}
+@media print {
+  .visible-print {
+    display: block !important;
+  }
+  table.visible-print {
+    display: table;
+  }
+  tr.visible-print {
+    display: table-row !important;
+  }
+  th.visible-print,
+  td.visible-print {
+    display: table-cell !important;
+  }
+}
+.visible-print-block {
+  display: none !important;
+}
+@media print {
+  .visible-print-block {
+    display: block !important;
+  }
+}
+.visible-print-inline {
+  display: none !important;
+}
+@media print {
+  .visible-print-inline {
+    display: inline !important;
+  }
+}
+.visible-print-inline-block {
+  display: none !important;
+}
+@media print {
+  .visible-print-inline-block {
+    display: inline-block !important;
+  }
+}
+@media print {
+  .hidden-print {
+    display: none !important;
+  }
+}
+
+.glyphicon {
+  position: relative;
+  top: 1px;
+  display: inline-block;
+  font-family: 'Glyphicons Halflings';
+  font-style: normal;
+  font-weight: normal;
+  line-height: 1;
+  -webkit-font-smoothing: antialiased;
+  -moz-osx-font-smoothing: grayscale;
+}
+.glyphicon-asterisk:before {
+  content: "\2a";
+}
+.glyphicon-plus:before {
+  content: "\2b";
+}
+.glyphicon-euro:before {
+  content: "\20ac";
+}
+.glyphicon-minus:before {
+  content: "\2212";
+}
+.glyphicon-cloud:before {
+  content: "\2601";
+}
+.glyphicon-envelope:before {
+  content: "\2709";
+}
+.glyphicon-pencil:before {
+  content: "\270f";
+}
+.glyphicon-glass:before {
+  content: "\e001";
+}
+.glyphicon-music:before {
+  content: "\e002";
+}
+.glyphicon-search:before {
+  content: "\e003";
+}
+.glyphicon-heart:before {
+  content: "\e005";
+}
+.glyphicon-star:before {
+  content: "\e006";
+}
+.glyphicon-star-empty:before {
+  content: "\e007";
+}
+.glyphicon-user:before {
+  content: "\e008";
+}
+.glyphicon-film:before {
+  content: "\e009";
+}
+.glyphicon-th-large:before {
+  content: "\e010";
+}
+.glyphicon-th:before {
+  content: "\e011";
+}
+.glyphicon-th-list:before {
+  content: "\e012";
+}
+.glyphicon-ok:before {
+  content: "\e013";
+}
+.glyphicon-remove:before {
+  content: "\e014";
+}
+.glyphicon-zoom-in:before {
+  content: "\e015";
+}
+.glyphicon-zoom-out:before {
+  content: "\e016";
+}
+.glyphicon-off:before {
+  content: "\e017";
+}
+.glyphicon-signal:before {
+  content: "\e018";
+}
+.glyphicon-cog:before {
+  content: "\e019";
+}
+.glyphicon-trash:before {
+  content: "\e020";
+}
+.glyphicon-home:before {
+  content: "\e021";
+}
+.glyphicon-file:before {
+  content: "\e022";
+}
+.glyphicon-time:before {
+  content: "\e023";
+}
+.glyphicon-road:before {
+  content: "\e024";
+}
+.glyphicon-download-alt:before {
+  content: "\e025";
+}
+.glyphicon-download:before {
+  content: "\e026";
+}
+.glyphicon-upload:before {
+  content: "\e027";
+}
+.glyphicon-inbox:before {
+  content: "\e028";
+}
+.glyphicon-play-circle:before {
+  content: "\e029";
+}
+.glyphicon-repeat:before {
+  content: "\e030";
+}
+.glyphicon-refresh:before {
+  content: "\e031";
+}
+.glyphicon-list-alt:before {
+  content: "\e032";
+}
+.glyphicon-lock:before {
+  content: "\e033";
+}
+.glyphicon-flag:before {
+  content: "\e034";
+}
+.glyphicon-headphones:before {
+  content: "\e035";
+}
+.glyphicon-volume-off:before {
+  content: "\e036";
+}
+.glyphicon-volume-down:before {
+  content: "\e037";
+}
+.glyphicon-volume-up:before {
+  content: "\e038";
+}
+.glyphicon-qrcode:before {
+  content: "\e039";
+}
+.glyphicon-barcode:before {
+  content: "\e040";
+}
+.glyphicon-tag:before {
+  content: "\e041";
+}
+.glyphicon-tags:before {
+  content: "\e042";
+}
+.glyphicon-book:before {
+  content: "\e043";
+}
+.glyphicon-bookmark:before {
+  content: "\e044";
+}
+.glyphicon-print:before {
+  content: "\e045";
+}
+.glyphicon-camera:before {
+  content: "\e046";
+}
+.glyphicon-font:before {
+  content: "\e047";
+}
+.glyphicon-bold:before {
+  content: "\e048";
+}
+.glyphicon-italic:before {
+  content: "\e049";
+}
+.glyphicon-text-height:before {
+  content: "\e050";
+}
+.glyphicon-text-width:before {
+  content: "\e051";
+}
+.glyphicon-align-left:before {
+  content: "\e052";
+}
+.glyphicon-align-center:before {
+  content: "\e053";
+}
+.glyphicon-align-right:before {
+  content: "\e054";
+}
+.glyphicon-align-justify:before {
+  content: "\e055";
+}
+.glyphicon-list:before {
+  content: "\e056";
+}
+.glyphicon-indent-left:before {
+  content: "\e057";
+}
+.glyphicon-indent-right:before {
+  content: "\e058";
+}
+.glyphicon-facetime-video:before {
+  content: "\e059";
+}
+.glyphicon-picture:before {
+  content: "\e060";
+}
+.glyphicon-map-marker:before {
+  content: "\e062";
+}
+.glyphicon-adjust:before {
+  content: "\e063";
+}
+.glyphicon-tint:before {
+  content: "\e064";
+}
+.glyphicon-edit:before {
+  content: "\e065";
+}
+.glyphicon-share:before {
+  content: "\e066";
+}
+.glyphicon-check:before {
+  content: "\e067";
+}
+.glyphicon-move:before {
+  content: "\e068";
+}
+.glyphicon-step-backward:before {
+  content: "\e069";
+}
+.glyphicon-fast-backward:before {
+  content: "\e070";
+}
+.glyphicon-backward:before {
+  content: "\e071";
+}
+.glyphicon-play:before {
+  content: "\e072";
+}
+.glyphicon-pause:before {
+  content: "\e073";
+}
+.glyphicon-stop:before {
+  content: "\e074";
+}
+.glyphicon-forward:before {
+  content: "\e075";
+}
+.glyphicon-fast-forward:before {
+  content: "\e076";
+}
+.glyphicon-step-forward:before {
+  content: "\e077";
+}
+.glyphicon-eject:before {
+  content: "\e078";
+}
+.glyphicon-chevron-left:before {
+  content: "\e079";
+}
+.glyphicon-chevron-right:before {
+  content: "\e080";
+}
+.glyphicon-plus-sign:before {
+  content: "\e081";
+}
+.glyphicon-minus-sign:before {
+  content: "\e082";
+}
+.glyphicon-remove-sign:before {
+  content: "\e083";
+}
+.glyphicon-ok-sign:before {
+  content: "\e084";
+}
+.glyphicon-question-sign:before {
+  content: "\e085";
+}
+.glyphicon-info-sign:before {
+  content: "\e086";
+}
+.glyphicon-screenshot:before {
+  content: "\e087";
+}
+.glyphicon-remove-circle:before {
+  content: "\e088";
+}
+.glyphicon-ok-circle:before {
+  content: "\e089";
+}
+.glyphicon-ban-circle:before {
+  content: "\e090";
+}
+.glyphicon-arrow-left:before {
+  content: "\e091";
+}
+.glyphicon-arrow-right:before {
+  content: "\e092";
+}
+.glyphicon-arrow-up:before {
+  content: "\e093";
+}
+.glyphicon-arrow-down:before {
+  content: "\e094";
+}
+.glyphicon-share-alt:before {
+  content: "\e095";
+}
+.glyphicon-resize-full:before {
+  content: "\e096";
+}
+.glyphicon-resize-small:before {
+  content: "\e097";
+}
+.glyphicon-exclamation-sign:before {
+  content: "\e101";
+}
+.glyphicon-gift:before {
+  content: "\e102";
+}
+.glyphicon-leaf:before {
+  content: "\e103";
+}
+.glyphicon-fire:before {
+  content: "\e104";
+}
+.glyphicon-eye-open:before {
+  content: "\e105";
+}
+.glyphicon-eye-close:before {
+  content: "\e106";
+}
+.glyphicon-warning-sign:before {
+  content: "\e107";
+}
+.glyphicon-plane:before {
+  content: "\e108";
+}
+.glyphicon-calendar:before {
+  content: "\e109";
+}
+.glyphicon-random:before {
+  content: "\e110";
+}
+.glyphicon-comment:before {
+  content: "\e111";
+}
+.glyphicon-magnet:before {
+  content: "\e112";
+}
+.glyphicon-chevron-up:before {
+  content: "\e113";
+}
+.glyphicon-chevron-down:before {
+  content: "\e114";
+}
+.glyphicon-retweet:before {
+  content: "\e115";
+}
+.glyphicon-shopping-cart:before {
+  content: "\e116";
+}
+.glyphicon-folder-close:before {
+  content: "\e117";
+}
+.glyphicon-folder-open:before {
+  content: "\e118";
+}
+.glyphicon-resize-vertical:before {
+  content: "\e119";
+}
+.glyphicon-resize-horizontal:before {
+  content: "\e120";
+}
+.glyphicon-hdd:before {
+  content: "\e121";
+}
+.glyphicon-bullhorn:before {
+  content: "\e122";
+}
+.glyphicon-bell:before {
+  content: "\e123";
+}
+.glyphicon-certificate:before {
+  content: "\e124";
+}
+.glyphicon-thumbs-up:before {
+  content: "\e125";
+}
+.glyphicon-thumbs-down:before {
+  content: "\e126";
+}
+.glyphicon-hand-right:before {
+  content: "\e127";
+}
+.glyphicon-hand-left:before {
+  content: "\e128";
+}
+.glyphicon-hand-up:before {
+  content: "\e129";
+}
+.glyphicon-hand-down:before {
+  content: "\e130";
+}
+.glyphicon-circle-arrow-right:before {
+  content: "\e131";
+}
+.glyphicon-circle-arrow-left:before {
+  content: "\e132";
+}
+.glyphicon-circle-arrow-up:before {
+  content: "\e133";
+}
+.glyphicon-circle-arrow-down:before {
+  content: "\e134";
+}
+.glyphicon-globe:before {
+  content: "\e135";
+}
+.glyphicon-wrench:before {
+  content: "\e136";
+}
+.glyphicon-tasks:before {
+  content: "\e137";
+}
+.glyphicon-filter:before {
+  content: "\e138";
+}
+.glyphicon-briefcase:before {
+  content: "\e139";
+}
+.glyphicon-fullscreen:before {
+  content: "\e140";
+}
+.glyphicon-dashboard:before {
+  content: "\e141";
+}
+.glyphicon-paperclip:before {
+  content: "\e142";
+}
+.glyphicon-heart-empty:before {
+  content: "\e143";
+}
+.glyphicon-link:before {
+  content: "\e144";
+}
+.glyphicon-phone:before {
+  content: "\e145";
+}
+.glyphicon-pushpin:before {
+  content: "\e146";
+}
+.glyphicon-usd:before {
+  content: "\e148";
+}
+.glyphicon-gbp:before {
+  content: "\e149";
+}
+.glyphicon-sort:before {
+  content: "\e150";
+}
+.glyphicon-sort-by-alphabet:before {
+  content: "\e151";
+}
+.glyphicon-sort-by-alphabet-alt:before {
+  content: "\e152";
+}
+.glyphicon-sort-by-order:before {
+  content: "\e153";
+}
+.glyphicon-sort-by-order-alt:before {
+  content: "\e154";
+}
+.glyphicon-sort-by-attributes:before {
+  content: "\e155";
+}
+.glyphicon-sort-by-attributes-alt:before {
+  content: "\e156";
+}
+.glyphicon-unchecked:before {
+  content: "\e157";
+}
+.glyphicon-expand:before {
+  content: "\e158";
+}
+.glyphicon-collapse-down:before {
+  content: "\e159";
+}
+.glyphicon-collapse-up:before {
+  content: "\e160";
+}
+.glyphicon-log-in:before {
+  content: "\e161";
+}
+.glyphicon-flash:before {
+  content: "\e162";
+}
+.glyphicon-log-out:before {
+  content: "\e163";
+}
+.glyphicon-new-window:before {
+  content: "\e164";
+}
+.glyphicon-record:before {
+  content: "\e165";
+}
+.glyphicon-save:before {
+  content: "\e166";
+}
+.glyphicon-open:before {
+  content: "\e167";
+}
+.glyphicon-saved:before {
+  content: "\e168";
+}
+.glyphicon-import:before {
+  content: "\e169";
+}
+.glyphicon-export:before {
+  content: "\e170";
+}
+.glyphicon-send:before {
+  content: "\e171";
+}
+.glyphicon-floppy-disk:before {
+  content: "\e172";
+}
+.glyphicon-floppy-saved:before {
+  content: "\e173";
+}
+.glyphicon-floppy-remove:before {
+  content: "\e174";
+}
+.glyphicon-floppy-save:before {
+  content: "\e175";
+}
+.glyphicon-floppy-open:before {
+  content: "\e176";
+}
+.glyphicon-credit-card:before {
+  content: "\e177";
+}
+.glyphicon-transfer:before {
+  content: "\e178";
+}
+.glyphicon-cutlery:before {
+  content: "\e179";
+}
+.glyphicon-header:before {
+  content: "\e180";
+}
+.glyphicon-compressed:before {
+  content: "\e181";
+}
+.glyphicon-earphone:before {
+  content: "\e182";
+}
+.glyphicon-phone-alt:before {
+  content: "\e183";
+}
+.glyphicon-tower:before {
+  content: "\e184";
+}
+.glyphicon-stats:before {
+  content: "\e185";
+}
+.glyphicon-sd-video:before {
+  content: "\e186";
+}
+.glyphicon-hd-video:before {
+  content: "\e187";
+}
+.glyphicon-subtitles:before {
+  content: "\e188";
+}
+.glyphicon-sound-stereo:before {
+  content: "\e189";
+}
+.glyphicon-sound-dolby:before {
+  content: "\e190";
+}
+.glyphicon-sound-5-1:before {
+  content: "\e191";
+}
+.glyphicon-sound-6-1:before {
+  content: "\e192";
+}
+.glyphicon-sound-7-1:before {
+  content: "\e193";
+}
+.glyphicon-copyright-mark:before {
+  content: "\e194";
+}
+.glyphicon-registration-mark:before {
+  content: "\e195";
+}
+.glyphicon-cloud-download:before {
+  content: "\e197";
+}
+.glyphicon-cloud-upload:before {
+  content: "\e198";
+}
+.glyphicon-tree-conifer:before {
+  content: "\e199";
+}
+.glyphicon-tree-deciduous:before {
+  content: "\e200";
+}
+
+article,
+aside,
+details,
+figcaption,
+figure,
+footer,
+header,
+hgroup,
+main,
+nav,
+section,
+summary {
+  display: block;
+}
+audio,
+canvas,
+progress,
+video {
+  display: inline-block;
+  vertical-align: baseline;
+}
+audio:not([controls]) {
+  display: none;
+  height: 0;
+}
+[hidden],
+template {
+  display: none;
+}
+a {
+  background: transparent;
+}
+a:active,
+a:hover {
+  outline: 0;
+}
+abbr[title] {
+  border-bottom: 1px dotted;
+}
+b,
+strong {
+  font-weight: bold;
+}
+dfn {
+  font-style: italic;
+}
+h1 {
+  font-size: 2em;
+  margin: 0.67em 0;
+}
+mark {
+  background: #ff0;
+  color: #000;
+}
+small {
+  font-size: 80%;
+}
+sub,
+sup {
+  font-size: 75%;
+  line-height: 0;
+  position: relative;
+  vertical-align: baseline;
+}
+sup {
+  top: -0.5em;
+}
+sub {
+  bottom: -0.25em;
+}
+img {
+  border: 0;
+}
+svg:not(:root) {
+  overflow: hidden;
+}
+figure {
+  margin: 1em 40px;
+}
+hr {
+  -moz-box-sizing: content-box;
+  box-sizing: content-box;
+  height: 0;
+}
+pre {
+  overflow: auto;
+}
+code,
+kbd,
+pre,
+samp {
+  font-family: monospace, monospace;
+  font-size: 1em;
+}
+button,
+input,
+optgroup,
+select,
+textarea {
+  color: inherit;
+  font: inherit;
+  margin: 0;
+}
+button {
+  overflow: visible;
+}
+button,
+select {
+  text-transform: none;
+}
+button,
+html input[type="button"],
+input[type="reset"],
+input[type="submit"] {
+  -webkit-appearance: button;
+  cursor: pointer;
+}
+button[disabled],
+html input[disabled] {
+  cursor: default;
+}
+button::-moz-focus-inner,
+input::-moz-focus-inner {
+  border: 0;
+  padding: 0;
+}
+input {
+  line-height: normal;
+}
+input[type="checkbox"],
+input[type="radio"] {
+  box-sizing: border-box;
+  padding: 0;
+}
+input[type="number"]::-webkit-inner-spin-button,
+input[type="number"]::-webkit-outer-spin-button {
+  height: auto;
+}
+input[type="search"] {
+  -webkit-appearance: textfield;
+  -moz-box-sizing: content-box;
+  -webkit-box-sizing: content-box;
+  box-sizing: content-box;
+}
+input[type="search"]::-webkit-search-cancel-button,
+input[type="search"]::-webkit-search-decoration {
+  -webkit-appearance: none;
+}
+fieldset {
+  border: 1px solid #c0c0c0;
+  margin: 0 2px;
+  padding: 0.35em 0.625em 0.75em;
+}
+legend {
+  border: 0;
+  padding: 0;
+}
+textarea {
+  overflow: auto;
+}
+optgroup {
+  font-weight: bold;
+}
+table {
+  border-collapse: collapse;
+  border-spacing: 0;
+}
+td,
+th {
+  padding: 0;
+}
+@media print {
+  * {
+    text-shadow: none !important;
+    color: #000 !important;
+    background: transparent !important;
+    box-shadow: none !important;
+  }
+  a,
+  a:visited {
+    text-decoration: underline;
+  }
+  a[href]:after {
+    content: " (" attr(href) ")";
+  }
+  abbr[title]:after {
+    content: " (" attr(title) ")";
+  }
+  a[href^="javascript:"]:after,
+  a[href^="#"]:after {
+    content: "";
+  }
+  pre,
+  blockquote {
+    border: 1px solid #999;
+    page-break-inside: avoid;
+  }
+  thead {
+    display: table-header-group;
+  }
+  tr,
+  img {
+    page-break-inside: avoid;
+  }
+  img {
+    max-width: 100% !important;
+  }
+  p,
+  h2,
+  h3 {
+    orphans: 3;
+    widows: 3;
+  }
+  h2,
+  h3 {
+    page-break-after: avoid;
+  }
+  select {
+    background: #fff !important;
+  }
+  .navbar {
+    display: none;
+  }
+  .table td,
+  .table th {
+    background-color: #fff !important;
+  }
+  .btn > .caret,
+  .dropup > .btn > .caret {
+    border-top-color: #000 !important;
+  }
+  .label {
+    border: 1px solid #000;
+  }
+  .table {
+    border-collapse: collapse !important;
+  }
+  .table-bordered th,
+  .table-bordered td {
+    border: 1px solid #ddd !important;
+  }
+}
+@font-face {
+  font-family: 'Glyphicons Halflings';
+  src: url('../fonts/glyphicons-halflings-regular.eot');
+  src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
+}
+
+[data-trans="tr069"] {
+  display: none !important;
+}
diff --git a/lynq/S300/ap/app/zte_webui/i18n/Messages_en.properties b/lynq/S300/ap/app/zte_webui/i18n/Messages_en.properties
new file mode 100755
index 0000000..d5bc7a8
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/i18n/Messages_en.properties
@@ -0,0 +1,1722 @@
+#menu 英文

+pc_version = PC

+mobile_version = Mobile

+home = Home

+phonebook = Phonebook

+sms = SMS

+sd = SD Card

+setting = Settings

+status = Information

+net_select = Network Selection

+dial_setting = Dial-up Settings

+apn_setting = APN

+wifi_advance = Advanced Settings

+management = Management

+net_setting = Connection Settings

+quick_setting = Quick Settings

+

+device_info = Status Information

+traffic_statistics = Statistics

+traffic_alert = Data Management

+

+wifi = Wi-Fi Settings

+wifi_basic = Basic Settings

+device_setting = Device Settings

+sim = SIM Card

+device = Device

+router_setting = Router

+mac_filter = WLAN MAC Filter

+

+wps = WPS

+sleep_mode = Power-save

+lan = LAN

+

+firewall = Firewall

+system_security = System Security

+port_forward = Port Forwarding

+port_filter = Port Filtering

+fastboot = Fast Boot

+display_password = Display Password

+display_QR = Display QR Code

+cable = cable

+wireless = wireless

+

+my_router = Network Settings

+net_surfing = Connect Status

+

+#validate

+phonenumbers_check = Input 5 phone numbers at most, and separate them by ';'

+required = Required

+remote = Please fix this field

+url = Please input a valid URL

+siteLink_check = Please input a valid URL

+siteName_check = Please input a valid name

+date = Please input a valid date

+dateISO = Please input a valid date (ISO)

+number = Please input a valid digit

+digits = Please input integer only

+decimalRange = Please enter a positive number and decimal places a maximum of 2

+any_digits = Please input integer only

+creditcard = Please input a valid credit card number

+equalTo = Please input the same value again

+accept = Please input a value with a valid extension

+maxlength = Please input no more than {0} characters

+minlength = Please input at least {0} characters

+rangelength = Please input a value between {0} and {1} characters in length

+range = Please input a value between {0} and {1}

+max = Please input a value less than or equal to {0}

+min = Please input a value greater than or equal to {0}

+ssid = Please input a valid SSID

+ssid_ap = Please input a valid SSID(, ; " \ are invalid characters)

+email_check = Please input a valid email

+ipv4 = Please input a valid IP address

+ipv6 = Please enter a valid IPv6 address

+name_check = Please input a valid name

+phonenumber_check = Please input a valid phone number

+sms_service_center_check = Please enter a valid center number

+pin_check = Please input 4 to 8 digits

+puk_check = Please input 8 digits.

+password_check = Please input a valid password

+manage_info_check = Please input a valid password

+subnetmask_check = Invalid subnet mask

+dhcp_check = DHCP {0} IP is not in the range of LAN subnet

+dns_check = Invalid DNS. DNS can''t be 255.255.255.255 or 0.0.0.0

+start = start

+end = end

+dhcpCompare = Invalid IP address. Start IP shouldn't be greater than end IP

+ipRange = IP pool can't contain LAN IP address (DHCP start IP should be greater than LAN IP address)

+lanip_check = Please input a valid IP address

+ip_check = Please input a full and valid IP address

+dmz_ip_check = Please input a valid IP address

+wps_pin_check = Invalid PIN number

+wps_pin_length_check = Please enter 4 or 8 digits

+browse_sdcard = View SD card

+portCompare = Invalid port range

+comment_check = Invalid character

+check_file_path = The folder name contains invalid characters

+check_filefold_name = The folder name contains invalid characters: ` ~ # & * + | \ : ? / < > . " '

+apn_check = Please input a valid APN

+ppp_username_check = Please input a valid username

+ppp_password_check = Please input a valid password

+unlock_code_check =  Please input a valid unlock code. The code must be 0-9, a-f or A-F, and its length must be 16 characters.

+apn_profile_name_check = The APN profile name contains invalid characters

+dlna_name_check = The Device Name must be 0-9, a-z, A-Z or _

+wifi_password_check = Please input a valid password

+wifi_wep_password_check = Please input 5 or 13 ASCII characters or input 10 or 26 Hex characters.

+range_except = Input a value between {0} and {1}, except for that between 32000 and 32007

+

+#common

+copyright = Copyright &copy; 2010-2022 demo Corporation. All rights reserved

+enable = Enable

+disable = Disable

+apply = Apply

+cancel = Cancel

+clear = Clear

+reset = Reset

+add = Add

+add_new = Add New

+save = Save

+new = New

+view = View

+select = Select

+edit = Edit

+delete = Delete

+delete_all = Delete All

+success_info = Success

+error_info = Failure

+connect = Connect

+disconnect = Disconnect

+connected = Connected

+disconnected = Disconnected

+connecting = Connecting…

+disconnecting = Disconnecting…

+cancelconnect = Cancel Connect

+confirm = Confirm

+prompt = Prompt

+info = Information

+alert = Alert

+yes = Yes

+no = No

+ok = OK

+back = Back

+exit = Exit

+next_step = Next

+prev_step = Previous

+next_page = &gt;&gt;

+prev_page = &lt;&lt;

+root = Root

+create = Create

+speed = Speed

+upload = Upload

+download = Download

+uploaded = Uploaded

+downloaded = Downloaded

+on = On

+off = Off

+need_login_again = You''re logged out of your account. Please login again.

+modify = Change

+content = Content

+time = Time

+processing = Processing...

+saving = Saving...

+deleting = Deleting...

+scanning = State: scanning...

+dlna_scanning = DLNA state: rescanning...

+scanned = DLNA state: rescan complete.

+need_rescan = DLNA state: need rescan.

+sending = Sending...

+creating = Creating...

+uploading = Uploading...

+waiting = Waiting...

+leave_page_info = You have unsaved changes. Are you sure you want to continue?

+colon = :

+page = Page:

+go = GO

+ALL = ALL

+open_source_licenses = Open Source Licenses

+vertical_bar = |

+#security

+security_policy = Security Policy

+security_mode = Security Mode

+security_mode_OPEN = OPEN

+security_mode_SHARED = SHARED

+security_mode_WPA2PSK = WPA2(AES)-PSK

+security_mode_WPAPSKWPA2PSK = WPA-PSK/WPA2-PSK

+security_mode_WPA3Personal = WPA3-Personal

+security_mode_WPA2WPA3 = WPA2(AES)/WPA3-Personal

+wpa = WPA

+pass_phrase = Pass Phrase

+

+#station

+station_info = Connected Devices

+station_number = No.

+host_name = Host Name

+

+#Wifi Basic

+multi_ssid_enable = Multi SSID Switch

+multi_ssid_1 = Main SSID

+multi_ssid_2 = Guest SSID

+multi_ssid_enable_confirm = If enable multi-SSID, Internet Wi-Fi will be disabled. Continue?

+multi_ssid_enable_confirm2 = If enable multi-SSID, Internet Wi-Fi will be disabled. And all connected Wi-Fi devices will probably need to reconnect. Continue?

+multi_ssid_max_access_number_alert = The combined max access number of Main SSID and Guest SSID can''t be more than {0}!

+network_band_selection = Band Selection 

+network_mode = Network Mode

+network_name = Network Name(SSID)

+broadcast_network_name = SSID Broadcast

+country_region_code = Country/Region Code

+frequency_channel = Frequency (Channel)

+rate = Rate

+max_station_number = Max Station Number

+wifi_basic_note = When clicking Apply, any connected Wi-Fi devices will need to reconnect.

+wifi_disconnect_confirm = All connected Wi-Fi devices will need to reconnect. <br/>Do you want to continue?

+wifi_disconnect_confirm2 = All connected Wi-Fi devices will probably need to reconnect. <br/>Do you want to continue?

+network_mode_2 = 802.11 n only

+network_mode_4 = 802.11 b/g/n

+network_mode_5 = 802.11 a only

+network_mode_6 = 802.11 b/g/n/ax

+frequency_channel_0 = Auto

+frequency_channel_1 = (CH1)

+frequency_channel_2 = (CH2)

+frequency_channel_3 = (CH3)

+frequency_channel_4 = (CH4)

+frequency_channel_5 = (CH5)

+frequency_channel_6 = (CH6)

+frequency_channel_7 = (CH7)

+frequency_channel_8 = (CH8)

+frequency_channel_9 = (CH9)

+frequency_channel_10 = (CH10)

+frequency_channel_11 = (CH11)

+frequency_channel_12 = (CH12)

+frequency_channel_13 = (CH13)

+frequency_channel_14 = (Channel 14)

+frequency_channel_15 = (Channel 15)

+frequency_channel_16 = (Channel 16)

+frequency_channel_17 = (Channel 17)

+frequency_channel_18 = (Channel 18)

+frequency_channel_19 = (Channel 19)

+frequency_channel_20 = (Channel 20)

+frequency_channel_21 = (Channel 21)

+frequency_channel_22 = (Channel 22)

+frequency_channel_23 = (Channel 23)

+frequency_channel_24 = (Channel 24)

+frequency_channel_25 = (Channel 25)

+frequency_channel_26 = (Channel 26)

+frequency_channel_36 = (Channel 36)

+frequency_channel_40 = (Channel 40)

+frequency_channel_44 = (Channel 44)

+frequency_channel_48 = (Channel 48)

+frequency_channel_149 = (Channel 149)

+frequency_channel_153 = (Channel 153)

+frequency_channel_157 = (Channel 157)

+frequency_channel_161 = (Channel 161)

+frequency_channel_165 = (Channel 165)

+rate_0 = Auto

+rate_1 = 1 Mbps

+rate_2 = 2 Mbps

+rate_3 = 5.5 Mbps

+rate_4 = 6 Mbps

+rate_5 = 6.5 Mbps

+rate_6 = 9 Mbps

+rate_7 = 11 Mbps

+rate_8 = 12 Mbps

+rate_9 = 13 Mbps

+rate_10 = 18 Mbps

+rate_11 = 19.5 Mbps

+rate_12 = 24 Mbps

+rate_13 = 26 Mbps

+rate_14 = 36 Mbps

+rate_15 = 39 Mbps

+rate_16 = 48 Mbps

+rate_17 = 52 Mbps

+rate_18 = 54 Mbps

+rate_19 = 58.5 Mbps

+rate_20 = 65 Mbps

+cannot_operate_when_wifi_connected = You can''t operate when Wi-Fi is connected!

+network_mode_select_2 = 802.11 n only

+network_mode_select_4 = 802.11 b/g/n

+network_mode_select_6 = 802.11 b/g/n/ax

+network_modes_band_select_2 = 802.11 n only

+network_modes_band_select_4 = 802.11 a/n

+network_modes_band_select_5 = 802.11 a only

+

+#net select

+auto_select = Automatic

+manual_select = Manual

+auto_select_type_WCDMA_preferred = Automatic

+auto_select_type_LTE_preferred = Automatic

+auto_select_type_NETWORK_auto = Automatic

+auto_select_type_Only_LTE = 4G Only

+auto_select_type_WCDMA_AND_LTE = 4G/3G Only

+auto_select_type_Only_WCDMA = 3G Only

+auto_select_type_TD_W = 3G Only

+auto_select_type_Only_GSM = 2G Only

+

+search = Search

+searching_net = Searching, please wait...

+registering_net = Registering, please wait...

+network_list = Network List

+register = Register

+auto = Auto

+unknown = Unknown

+available = Available

+current = Current

+forbidden = Forbidden

+net_select_note_automatic = Automatic: The device will search available network automatically.

+net_select_note_manual = Manual: The device will search available network manually.

+net_status = Status

+mccmnc = MCCMNC

+option = Option

+networktype = Network Type

+subnet = Act

+

+#home

+ap_station_clear = Clear all

+current_flux = Current Data

+total_flux = Total Used Data

+connected_time = Duration

+flux_up = Upload

+flux_down = Download

+traffic_current_connection = Current Connection

+traffic_current_month_data = Current Month

+traffic_total_traffic = Total Used Data

+traffic_used_data_month = Data usage of this month:

+traffic_used_time_month = The online time of this month:

+traffic_data_approximated = Data usage is approximate only. For actual usage, please refer to your network operator.

+traffic_used_month = Used:

+traffic_left_month = Left:

+traffic_exceeded_month = Exceeded:

+traffic_total_month = Limit:

+traffic_apply_volume_limit = Data Management

+traffic_data_limit_type = Data Type

+traffic_data = Data

+traffic_time = Time

+traffic_limit_data_month = Monthly

+traffic_alert_when_data_reach = Remind me

+traffic_limit_time_month = Monthly

+traffic_alert_when_time_reach = Remind me

+traffic_million_byte = MB

+traffic_percent = %

+traffic_limit_disconnect_msg = Your data/time used reaches {0} percent. Do you want to disconnect from network?

+traffic_limit_connect_msg = Your data/time used reaches {0} percent. Do you still want to connect to network?

+traffic_limit_msg = Your data/time used reaches {0} percent.

+traffic_beyond_disconnect_msg = Your data/time used exceeds limit. Do you want to disconnect from network?

+traffic_beyond_connect_msg = Your data/time used exceeds limit. Do you still want to connect to network?

+traffic_beyond_msg = Your data/time used exceeds limit.

+traffic_calibrate_note = Support data calibrate function. If the data that web page displayed is not in agreement with the actual used, you can modify the used data by this operation.

+traffic_note = Remind me when used data/time reaches specified percentage.

+traffic_over_note = When the data plan''s unit is MB, the used data should be less than 4096TB.

+traffic_clear_confirm = Are you sure to clear?

+traffic_not_support = The current mode does not support this feature.

+

+#APN

+apn_currentApn = Current APN

+apn_mode = Mode

+apn_auto_apn = Auto

+apn_manual_apn = Manual

+apn_profile = Profile

+apn_profile_name = Profile Name

+apn = APN

+apn_ipv4_apn = IPv4 APN

+apn_ipv6_apn = IPv6 APN

+apn_dns_mode = DNS Mode

+apn_dns_mode_ipv4 = IPv4 DNS Mode

+apn_dns_mode_ipv6 = IPv6 DNS Mode

+apn_auto_dns = Auto

+apn_manual_dns = Manual

+apn_dns1 = DNS 1

+apn_dns2 = DNS 2

+apn_dns1_ipv4 = IPv4 DNS 1

+apn_dns2_ipv4 = IPv4 DNS 2

+apn_dns1_ipv6 = IPv6 DNS 1

+apn_dns2_ipv6 = IPv6 DNS 2

+apn_authentication = Authentication

+apn_authentication_ipv4 = IPv4 Authentication

+apn_authentication_ipv6 = IPv6 Authentication

+apn_user_name = User Name

+apn_user_name_ipv4 = IPv4 User Name

+apn_user_name_ipv6 = IPv6 User Name

+apn_password = Password

+apn_password_ipv4 = IPv4 Password

+apn_password_ipv6 = IPv6 Password

+apn_pdp_type = PDP Type

+set_default = Set as default

+apn_save_profile_exist = Profile Name already exists, please select another name.

+apn_delete_cant_delete_default = You can''t delete the default profile!

+apn_delete_confirm = Are you sure to delete?

+apn_cant_modify_status = Can''t change the current APN setting when the network is {0}!

+apn_cant_modify_current = You can''t change the APN that is in use!

+apn_cant_delete_current = You can''t delete the current profile!

+apn_profile_full = You can only add {0} items at most!

+dial_num = Dial No.

+apn_no_select_alert = Please choose a valid profile!

+

+#Status bar

+network_status = Network Status

+connection_status = Wireless Broadband Connection status

+rj45_connection_status = Cable Broadband Connection status

+battery = Battery

+charging = Charging

+sim_status = SIM Status

+sim_status_modem_waitpin = Invalid SIM card

+sim_status_modem_waitpuk = Invalid SIM card

+sim_status_modem_sim_undetected = Invalid SIM card

+sim_status_modem_undetected = Invalid SIM card

+sim_status_modem_imsi_waitnck = Invalid SIM card

+sim_status_modem_sim_destroy = Invalid SIM card

+sim_status_modem_destroy = Invalid SIM card

+sim_status_modem_init_complete = Valid SIM card

+sim_status_modem_ready = SIM is ready

+wifi_status = Wi-Fi Status

+wifi_status_on = Wi-Fi on

+wifi_status_off = Wi-Fi off

+wifi_status1 = Number of users:1

+wifi_status2 = Number of users:2

+wifi_status3 = Number of users:3

+wifi_status4 = Number of users:4

+wifi_status5 = Number of users:5

+wifi_status6 = Number of users:6

+wifi_status7 = Number of users:7

+wifi_status8 = Number of users:8

+wifi_status9 = Number of users:9

+wifi_status10 = Number of users:10

+enable_pin = Enable PIN

+remaining_time = Remaining Time

+signal = Signal

+network_type = Network type

+network_type_limited_service = Limited Service

+network_type_no_service = No Service

+network_provider = Operator

+roaming_status = Roaming status

+sim_status_ready = SIM is ready

+sim_status_waitpin = Ready to input PIN

+sim_status_waitpuk = Ready to input PUK

+sim_status_undetected = No SIM card detected

+sim_status_waitnck = Ready to input NCK

+sim_status_destroy = SIM is corrupted

+signal_strength = Signal strength

+signal_strength_label = Signal Strength

+battery_level = Battery level

+

+#dial_setting

+dial_note = WAN Connection Status

+dial_mode = Connection Mode

+dial_mode_cpe = Dial-up Mode

+dial_roam_info = The Roaming Setting is disabled. To enable it, please go to setting page and click in the checkbox.

+dial_setting_note_automatic = Automatic: The device will automatically connect to network when it is powered on.

+dial_setting_note_manual = Manual: The device will connect to network manually.

+dial_roaming_remind = Check here, you can connect to internet in the roaming status.

+dial_roaming_connect = Your device is roaming. Connecting to network may occur additional charges. Continue?

+

+#phonebook

+search = Search

+save_location = Save Location

+save_location_0 = SIM Card

+save_location_1 = Device

+group_all = All

+group_null = -

+group_common = Common

+group_family = Family

+group_friend =  Friend

+group_colleague = Colleague

+name = Name

+mobile_phone_number = Mobile Number

+home_phone_number = Home Number

+office_phone_number = Office Number

+mail = Email

+group = Group

+no_data_selected = Please select an item!

+confirm_data_delete = Are you sure to delete?

+confirm_pb_delete = Delete selected contact(s)?

+too_many_data_selected = Too many numbers are selected! Please select one number!

+delete_fail_try_again = Delete failed, please try again.

+max_send_number = You can enter 5 phone numbers at most!

+send = Send

+send_sms = Send Message

+new_message = New SMS

+send_numbers = Number

+contents = Contents

+device_full =  Phonebook space on your device is full!

+sim_full = SIM card is full!

+phonebook_init_fail = The phone book failed to initialize!<br/>Please check SIM card and restart the device.

+sim_removed = SIM card was removed!

+change_device_to_sim_confirm = Information may be lost, and whether there is a need to continue to deposit?

+

+#SMS

+smslist = Device SMS

+sms_setting = SMS Settings

+sim_messages = SIM SMS

+refresh = Refresh

+forward = Forward

+draft = Draft

+send_fail_try_again = Send failed.

+sms_content_required = Please type a SMS.

+sms_contact_required = Please select a contact.

+select_some_options = You can choose 5 contacts at most

+select_an_option = Select an Option

+chat_input_placehoder = Please type message here

+sms_chat_input_confirm = Please press Enter or enter ";" to complete

+sms_capacity_will_full = SMS capacity will be full, please delete some SMS

+sms_capacity_is_full = SMS capacity is full, please delete some SMS

+sms_capacity_is_full_for_send = SMS capacity is full, please delete some SMS to receive or send message.

+sms_capacity_will_full_just = SMS capacity will be full, you could send {0} SMS(s)

+sms_init_fail = SMS failed to initialize!<br/>Please check SIM card and restart the device.

+sms_resending = Resending SMS...

+sms_resend_fail = SMS resend failure.

+sms_stop_sending = Stop Sending

+sms_unread_count = Unread SMS

+sms_delivery_report_1 = SMS is delivered.

+sms_delivery_report_2 = SMS is undelivered.

+sms_delivery_report_3 = Sending SMS...

+sms_report = Delivery Report

+sms_cancel_sending = Cancelling...

+sms_save_draft_success = SMS is saved as a draft

+sms_save_draft_failed = Draft save failed

+sms_to_save_draft = SMS was modified, save it as a draft?

+sms_no_recipient = Your SMS doesn''t have any recipients, and this SMS will be discarded.

+phone_number_invalid = Phone number invalid

+sms_to = To:

+confirm_sms_delete = Delete selected message(s)?

+sms_save_tip = Saving...

+

+#login

+password = Password

+puk = PUK

+login = Login

+logout = Logout

+new_pin = New PIN

+confirm_pin = Confirm New PIN

+puk_locked = Your SIM card is locked permanently. Please contact your operator.

+password_error = Password is incorrect!

+password_error_left = Password is incorrect!<br/>You have {0} attempt(s) left.

+password_error_account_lock = Your account is locked. <br/>Remaining time:

+password_error_five_times = You''ve input 5 times incorrectly. Retry in 5 minutes.

+password_error_account_lock_time = Your account is locked. <br/>Please try later.

+enter_pin = SIM card is locked, please input PIN to unlock.

+enter_puk = SIM card is PIN-locked, please input PUK to unlock.

+last_enter_pin = Final attempt. If incorrect again, your SIM card will be locked!

+last_enter_puk = Final attempt. If incorrect again, your SIM card will be corrupted!

+attempts_left = Attempts Left:

+pin_error = PIN is incorrect!

+puk_error = PUK is incorrect!

+confirm_logout = Do you want to logout?

+

+#advanced password

+password_management = Login Password

+current_password = Current Password

+new_password = New Password

+confirm_password = Confirm New Password

+current_password_error = Current password is incorrect!

+password_note_info = You can change login password on this page.

+password_note_valid = The password can''t be empty and must contain at most 32 characters.

+password_note_input = The password contains 0-9 a-z A-Z ! # $ * + , - . % : = ? @ [ ] ^ _ { | } ~

+password_note_first_change = Please change your initial login password!

+password_note_too_low = Your password complexity is too low (the password could contain uppercase and lowercase letters, numbers, special characters and no less than 8 characters). Do you want to continue?

+

+#advanced pin

+pin = PIN

+current_pin = Current PIN

+pin_management = PIN Management

+pin_status = PIN Status

+modify_pin = Change PIN

+cannot_operate_when_connected = Can''t operate when connecting to network!

+cannot_change_pin_when_connected = Can''t change PIN when connecting to network!

+pin_note_info = Apply PIN security settings in PIN Management to prevent unauthorized use of the SIM, USIM, or UIM card. If you want to change current settings, please disconnect from network first.

+pin_note_operator = If enable PIN, you may need to enter PIN when the device is powered on. If disable PIN, no PIN is required.

+pin_note_modify = You can change PIN when PIN is enabled.

+

+#lan

+lan_setting = LAN Interface Setup

+ip_address = IP Address

+subnet_mask = Subnet Mask

+mac_address = MAC Address

+dhcp_server = DHCP Server

+dhcp_ip_pool = DHCP IP Pool

+dhcp_lease = DHCP Lease Time

+hours = hour(s)

+minutes = minute(s)

+lan_note = Your settings will take effect after restarting your device.

+lan_note_ip_address = IP Address: LAN IP address of the router. You can access page management on device via this IP address.

+lan_note_subnet_mask = Subnet Mask: Subnet mask for IP address.

+lan_note_dhcp_server_enable = DHCP Server Enable: If the Dynamic Host Configuration Protocol (DHCP) service is enabled, the device allocates IP addresses to clients connected to it.

+lan_note_dhcp_server_disable = DHCP Server Disable: If the Dynamic Host Configuration Protocol (DHCP) service is disabled, the device does not allocate IP addresses to clients connected to it and IP addresses must be entered manually from each client.

+lan_note_dhcp_ip_pool = DHCP IP Pool: Starting and Ending IP address specify IP address range which is assigned by DHCP server to access devices. The IP address out of this range cannot be assigned by DHCP server.

+lan_note_dhcp_lease_time = DHCP Lease Time: Lease Time specifies how long a computer can use IP address. If the device will continue to use IP address, it must initiate request again before lease time expires. This IP address will not assign to other device until the old device initiates no request when its lease time expires.

+lan_confirm_reopen = Your settings will take effect after restarting your device. Do you want to continue?<br/><br/><i>Note: Click Yes to submit the request and restart the device. If you choose No, it means that you give up the current operation.</i>

+lan_tip_staticip_notsame = IP Address and static IP address can''t be in the same segment!

+

+#sms_setting

+sms_validity = Validity

+sms_validity_twelve_hours = 12 Hours

+sms_validity_one_day = 1 Day

+sms_validity_one_week = 1 Week

+sms_validity_largest = Maximum

+center_number = Center Number

+delivery_report = Delivery Report

+list = List

+

+#restore

+restore = Reset

+restore_title = Reset Factory Settings

+restore_button = Reset Factory Settings

+restore_confirm = Parameters will be reset to factory defaults, the device will restart. Continue?

+restore_when_connected = Please disconnect from WAN first!

+restoring = Resetting factory settings

+restore_note_info = Click Reset to reset all settings to defaults, and the device will restart automatically.

+

+#wps

+wps_note_all = WPS (Wi-Fi Protected Setup) is a standard that allows users to set up a wireless network in an easy and secure way without specific configuration, such as: SSID, security mode and password.

+wps_note_pin = PIN: You need to enter the PIN that is generated by the access client.

+wps_note_pbc = PBC: You can select the PBC (Push Button Configuration) on the web page or hold the WPS button for 3-4 seconds on the device to enable WPS function.

+wps_note_wait = The device will wait for receiving the access request of wireless access client within 2 minutes.

+wps_pin = PIN

+wps_pbc = PBC

+wps_wifi_off = You can''t operate when Wi-Fi is off!

+wps_auth_open = Current encryption type does not support WPS.

+wps_on_info = WPS is enabled now, please try again later.

+wps_ssid_broadcast_disable = You can''t operate when SSID broadcast is disabled!

+

+#sleep mode

+wifi_sleep = Wi-Fi Sleep

+sleep_time = Sleep after

+sleep_mode_-1 = Never Sleep

+sleep_mode_5 = 5 Minutes

+sleep_mode_10 = 10 Minutes

+sleep_mode_20 = 20 Minutes

+sleep_mode_30 = 30 Minutes

+sleep_mode_60 = 1 Hour

+sleep_mode_120 = 2 Hours

+wifi_sleep_note_info = Sleep after: When there''s no Wi-Fi connection in specific time, Wi-Fi will be unavailable, and the system will turn to sleep mode for power-saving.

+wifi_sleep_confirm = The current setting changes may restart Wi-Fi, continue any way?

+

+#system security

+remote_management = Remote Management (via WAN)

+ping_from_wan = Ping From WAN Filter

+

+#portforward

+protocol_TCP&UDP = TCP+UDP

+protocol_TCP = TCP

+protocol_UDP = UDP

+virtual_server_setting = Virtual Server Settings

+port_forward_setting = Port Forwarding Settings

+port_forward_list = Current Virtual Servers in system

+port_forward_note_info = Configure a Port Forward to enable external computers to access WWW, FTP or other services provided by LAN.

+port_forward_note_port = Port Range: Set port numbers to be forwarded.

+port_forward_note_ip_address = IP Address: Set the source IP address which you want to forward.

+port_forward_note_protocol = Protocol: Set the protocol for forwarding.

+port_forward_note_comment = Comment: Type comment for Port Forwarding rule. It contains 0-9 a-z A-Z ! # ( ) + - . / % = ? @ ^ _ { | } ~ .

+port_range = Port Range

+protocol = Protocol

+comment = Comment

+ipExam = (e.g., 192.168.0.101)

+rules_max = The rule number exceeds {0}.

+rule_exist = This rule already exists.

+rule_max_note = The maximum number of rules is 10.

+rule_max_note_v4v6 = The maximum of rules for IPv4 and IPv6 is 10 respectively.

+

+rules_max_v4v6 =  The {0} rule number exceeds {1}.

+rule_exist_v4v6 = This {0} rule already exists.

+

+#quick setting

+step_number_1 = 1

+step_number_2 = 2

+step_number_3 = 3

+step_number_4 = 4

+step_number_5 = 5

+step_number_6 = 6

+step_name_1 = 1.Quick Setup

+step_name_2 = 2.PPP Profile Configuration

+step_name_3 = 3.PPP Authentication

+step_name_4 = 4.SSID Configuration

+step_name_5 = 5.Security Configuration

+step_name_6 = Configuration as Follows

+step1_exp1 = The wizard will show you how to set up basic parameters of gateway safely: Click "Previous" & "Next" to navigate, and click "Apply" to save settings.For advanced parameters, set them in other menu.

+step1_exp2 = Set basic parameters in this wizard. For advanced parameters, set them in other menu.

+apn_settings = APN Settings

+step2_auto_apn_explain = If you select Auto APN, the second step, i.e., PPP Authentication, will be skipped.

+step2_profile_name_explain = Profile Name: The default profile that you use currently.

+ppp_authentication = PPP Authentication

+step3_authentication_apn_explain1 = Authentication: It is provided by your Internet Service Provider (ISP). Password Authentication Protocol (PAP) provides a simple method without encryption for the peer to establish its identity using a 2-way handshake. Challenge-Handshake Authentication Protocol (CHAP) is used to periodically verify the identity of the peer using a 3-way handshake.

+step3_authentication_apn_explain2 = User Name: It is used to obtain authentication from the ISP when connection is established.

+step3_authentication_apn_explain3 = Password: It is used to obtain authentication from the ISP when connection is established.

+step3_username_password_explain = Click "Set as default" to set this profile as the default profile.

+ssid_title = SSID

+ssid_name = Network Name(SSID)

+ssid_broadcast = SSID Broadcast

+step4_ssid_explain = Network Name: Service Set Identifier (SSID). Enter name of your wireless local area network (WLAN), which is less than 32 characters.

+step4_ssid_broadcast_explain1 = SSID Broadcast: Disable or Enable (Default) this function. Once enabled, the router will broadcast SSID, and other devices can discover and connect to it.

+step4_ssid_broadcast_explain2 = Disable: The gateway disables broadcasting and hides the name of your network.

+step5_encryption_mode_info = Security Mode:

+step5_encryption_mode_explain1 = OPEN: Authentication and encryption won''t be performed. There are risks that private information may be intercepted, or network may be used by unauthorized individuals. This encryption scheme isn''t recommended.

+step5_encryption_mode_explain2 = WPA2(AES)-PSK: It is the secure version of WPA with implementation of the 802.11i standard.

+step5_encryption_mode_explain3 = WPA-PSK/WPA2-PSK: WPA Pre-Shared Key (WPA-PSK). WPA2-PSK is the secure version of WPA with implementation of the 802.11i standard.

+step5_encryption_mode_explain4 = Pass Phrase: The pass-phrase contains 0-9 a-z A-Z ! # ( ) + - . / % = ? @ ^ _  { | } ~

+step6_apply_explain = You need to reconnect wireless network when committing.

+quick_setting_wifi_disable_confirm = 1. Wi-Fi is off, the settings for Wi-Fi won''t take effect.<br\>Continue?

+quick_setting_param_changed_confirm = 1. Connected Wi-Fi devices probably need to reconnect when Wi-Fi configuration changes.<br\>Continue?

+#SD Card

+sdcard = SD Card

+httpshare = HTTP Share

+sd_card_mode = Mode

+sd_card_share_setting = Share Setting

+sd_card_share_usb_mode = USB

+sd_card_share_http_share_mode = HTTP SHARE

+http_title = HTTP Share Settings

+sd_card_status = Status

+sd_card_file_to_share = File to Share

+sd_card_access_type = Access Type

+sd_card_path_to_share = Path to Share

+sd_card_entire_sd_card = Entire SD Card

+sd_card_custom_setting = Custom 

+sd_card_read_write = Read/Write

+sd_card_readonly = Read Only

+sd_card_share_setting_no_sdcard = No SD Card!

+sd_card_share_setting_exist = The folder/file already exists!

+sd_card_share_setting_noexist = The folder/file does not exist!

+sd_card_status_info_0 = No SD Card!

+sd_card_status_info_1 = SD Card already exists and can be used now

+sd_card_status_info_2 = SD Card already exists, but it is invalid now! Please retry in 5 minutes. If still invalid, please check SD Card!

+sd_card_status_info_2_reason = Possible reasons are as follows

+sd_card_status_info_2_reason_1 = SD card is of NTFS format, please switch to USB mass storage.

+sd_card_status_info_2_reason_2 = SD card is loading, please retry in 5 minutes. If still invalid, please check SD card.

+sd_card_invalid_chars_cant_download = The file name contains invalid characters and can not be downloaded! (< > " '' & + / \\ : * | # ? ~ ` are invalid characters)

+note_not_support_fs_ntfs = In HTTP Share Mode, the device only supports FAT/FAT32 file system!

+note_web_share_mode = HTTP Share Mode: Share SD card via web browser. The removable drive mapping of SD card via USB port will be disabled.

+note_usb_access = USB Access Only: By the removable drive mapping, user can access SD card via USB cable only. The web page of sharing SD card will be disabled.

+note_http_share_usb_access = USB Access Only: By the removable drive mapping, user can access SD card via USB cable only. The web page of sharing SD card will be disabled.

+note_http_share_cannot_access = You can''t access this page!

+note_path_to_share_example = Path to Share: You can input the sharing path, such as /Picture. By typing only a slash in Path to Share filed, you agree to share entire SD card.

+note_upload_not_refresh = When you''re in process of downloading or uploading the file, please don''t refresh the page!

+note_upload_single_file_2g = The single file upload can not be above 2G.

+note_upload_filelenth_25 = The name of the file / folder name modification function supports 25 characters at most.

+note_uploading_not_refresh = Uploading, please don''t refresh the page!

+note_invalid_file_path = Path to Share can''t be a dot, and can''t contain following characters: < > " '' & + / \\ : * | # ? ~ `

+browse_btn = Browse

+change_btn = Change

+no_file_selected = No file selected...

+sd_no_file_selected = Please select a file

+sd_name = Name

+sd_path = Path:

+sd_rename = Rename

+sd_download = Download

+sd_file_size = File Size

+sd_update_time = Updated Time

+no_sdcard = No SD Card!

+no_exist = The file is not exist!

+sd_card_folder_name_is_null = Please enter a name

+get_file_list_failure = Get file list failed

+create_folder_failure = Create folder failed

+delete_folder_failure = Delete folder/file failed

+sd_card_path_too_long = File path too long.

+sd_file_size_too_big = The file is too large. The single file upload can not be above 2G.

+sd_file_name_invalid = File name containing * is not supported. Please update the file name.

+back_to_login = Back to Login

+sd_config_changed_reload = The settings for SD card share are changed, and the page will reload.

+sd_upload_space_not_enough = The space is not enough!

+sd_upload_data_lost = Upload failed, please retry.

+sd_upload_file_is_downloading = File is downloading, try later!

+sd_share_path_is_invalid = Path to Share is invalid, please set the share path

+sd_share_path_cant_rename = The folder was shared and cannot be renamed.

+sd_share_path_cant_delete = The folder "{0}" was shared and cannot be deleted.

+sd_share_path_invalid = The shared path does not exist.

+sd_file_processing_cant_delete = File is being used, cannot be deleted.

+sd_file_processing_cant_rename = File is being used, cannot be renamed.

+sd_not_support = The card format don''t support or other reasons, please re-insert or replace SD card.

+sd_usb_forbidden = The card is busy now, cannot be changed.

+sd_upload_rename = The file already exists! Please change the file name and select "yes" to continue. Select "no" will cancel the upload.

+sd_upload_rename_null = Can''t be empty or more than 25 characters!

+

+#port filter

+filter_basic_setting = Basic Settings

+port_filter_enabled = MAC/IP/Port Filtering

+default_policy = Default Policy

+default_policy_note = You can set firewall policies to protect your network from viruses, worms and malicious activities on the Internet.

+default_policy_note_filter = Only when filtering is enabled, the filter policy is available.

+accepted = Accepted

+dropped = Dropped

+port_filter_setting = MAC/IP/Port Filtering Settings

+mac_address = MAC Address

+macExam = (e.g., 00:1E:90:FF:FF:FF)

+dest_ip_address = Dest. IP Address

+source_ip_address = Source IP Address

+port_filter_action = Action

+filter_accept = Accept

+filter_drop = Drop

+protocol_None = ALL

+protocol_ICMP = ICMP

+port_filter_list = Current MAC/IP/Port Filtering Rules in System

+dest_port_range = Dest. Port Range

+source_port_range = Source Port Range

+filter_accept_note = Others would be accepted.

+filter_drop_note = Others would be dropped.

+filter_optional = Please input any IP, MAC or/and port value

+mac_check = Invalid MAC address

+filter_ip_setting = IP Settings

+filter_ipv4 = IPv4

+filter_ipv6 = IPv6

+ip_type = IP Type

+source_ipv6_address = Source IPv6 Address

+dest_ipv6_address = Dest. IPv6 Address

+port_filter_note_mac_address = MAC Address: Set MAC address to be filtered.

+port_filter_note_source_ip_address = Source IP Address: Set source IP address to be filtered.

+port_filter_note_dest_ip_address = Dest IP Address: Set dest IP address to be filtered.

+port_filter_note_protocol = Protocol: Set protocol to be used for filtering.

+port_filter_note_source_port_range = Source Port Range: Set source port numbers to be filtered.

+port_filter_note_dest_port_range = Dest Port Range: Set dest port numbers to be filtered.

+port_filter_note_action = Action: Set to handle the packet if it matches with the rule.

+port_filter_note_comment = Comment: Enter comment for filter settings. It contains 0-9 a-z A-Z ! # ( ) + - . / % = ? @ ^ _ { | } ~ .

+port_filter_note_info = The filter policies are matched one by one with the rules. And if met this provision, it won''t continue to match the rules listed below.

+confirm_data_effect = Your settings may not take effect immediately. If you need to fully take effect, proposed restart the device. Continue?

+

+#wifi_range

+wifi_range_settings = Wi-Fi Performance Settings

+wifi_range = Wi-Fi Coverage

+wifi_short_mode = Short Wi-Fi Coverage - Best battery life

+wifi_medium_mode = Medium Wi-Fi Coverage

+wifi_long_mode = Long Wi-Fi Coverage

+wifi_des_short_mode = Short Wi-Fi Coverage

+wifi_des_medium_mode = Medium Wi-Fi Coverage

+wifi_des_long_mode = Long Wi-Fi Coverage

+wifi_range_note_range = Wi-Fi Coverage:

+wifi_range_note_short = Short Wi-Fi Coverage: Coverage and launch small power consumption, it is the best battery life.

+wifi_range_note_medium = Medium Wi-Fi Coverage: Coverage and emission power consumption is half of equipment support ability, normal power consume.

+wifi_range_note_long = Long Wi-Fi Coverage: Maximum emission power and coverage, if the terminal device still connect to your Wi-Fi network, which will decrease battery life.

+wifi_range_note_short_cpe = Short Wi-Fi Coverage: Minimum power consumption and coverage.

+wifi_range_note_medium_cpe = Medium Wi-Fi Coverage: 50% of device power consumption and coverage.

+wifi_range_note_long_cpe = Long Wi-Fi Coverage: Maximum power consumption and coverage.

+

+#upnp

+upnp = UPnP

+upnp_setting = UPnP Settings

+upnp_note_info = Universal Plug and Play (UPnP) is a set of networking protocols that allows networked devices, such as PC, printers, Internet gateways, Wi-Fi access points and mobile devices, to seamlessly discover each other''s presence on the network and establish functional network services for data sharing, communications, and entertainment.

+

+#dmz

+dmz = DMZ

+dmz_setting = DMZ Settings

+dmz_note_info = If a terminal device can''t run network applications via this device, please enter IP address of the terminal device in the entry box when DMZ is enabled.

+dmz_note_function = You can configure DMZ address, enable or disable DMZ on this page.

+

+#Device Information

+max_access_num = Max Access Number

+lan_domain = LAN Domain

+sim_serial_number = SIM Card Number

+software_version = Software Version

+firmware_version = Firmware Version

+hardware_version = Hardware Version

+imei = IMEI

+imsi = IMSI

+wan_ip_address = WAN IP Address

+ipv6_wan_ip_address = WAN IPv6 Address

+network_name_ssid1 = Network Name (Main SSID)

+pass_phrase_ssid1 = Pass Phrase (Main SSID)

+max_access_num_ssid1 = Max Access Number (Main SSID)

+network_name_ssid2 = Network Name (Guest SSID)

+pass_phrase_ssid2 = Pass Phrase (Guest SSID)

+max_access_num_ssid2 = Max Access Number (Guest SSID)

+

+#port map

+port_map = Port Mapping

+port_map_basic = Basic Settings

+port_map_setting = Port Mapping Settings

+source_port = Src. Port

+dest_port = Dest. Port

+port_map_list = Current Port Mapping Rules in System

+port_map_note_info = Configure a Port Mapping to enable external computers to access WWW, FTP or other services provided by LAN.

+port_map_note_port = Src. Port/Dest Port: The port of the computer that provides services.

+port_map_note_dest_ip_address = Dest. IP Address: Specify a computer located at LAN to provide services.

+port_map_note_protocol = Protocol: Protocols applied by services.

+port_map_note_comment = Comment: Type comment for Port Mapping rule. It contains 0-9 a-z A-Z ! # ( ) + - . / % = ? @ ^ _ { | } ~ .

+

+#USSD Info

+USSD = USSD

+ussd = USSD

+ussd_send_to = Send to

+ussd_send = Send

+ussd_cancel = Cancel

+ussd_reply_to = Reply to

+ussd_reply = Reply

+ussd_contents = Contents

+ussd_timeout = Network Timeout!

+ussd_operation_timeout = Operation Timeout!

+ussd_no_service = No Network Service!

+ussd_retry = Operation Failed! Please Retry!

+ussd_unsupport = USSD is unsupported!

+ussd_info_error = Get Information Error!

+ussd_fail = Operation Failed!

+ussd_error_input = Error Input!

+ussd_note1 = You can send a command to the network (have predefined numbers or symbols), the network will be based on the instruction for you to provide the corresponding services.

+

+#dlna setting

+dlna_setting = DLNA Settings

+dlna_language = Language

+dlna_language_chinese = Chinese

+dlna_language_english = English

+dlna_device_name = Device Name

+dlna_media_type = Shared Media Type

+dlna_media_info = Share Settings

+dlna_audio = Music

+dlna_image = Image

+dlna_video = Video

+dlna_rescan = Rescan

+dlna_note_info = You can set Digital Living Network Alliance(DLNA) when SD card is available or HTTP Share Mode is enabled.

+dlna_note_httpshare = You can set Digital Media Server (DMS) language, device name, and media type which you want to share on this page.

+dlna_note_rescan = In order to allow DLNA multimedia database to be synchronized with SD card, please rescan.

+

+#nosimcard

+no_sim_card_title = System Information

+no_sim_card_message = No SIM Card or SIM Card invalid!

+

+#network_locked

+network_locked = SIM Lock!

+network_locked_explain = This device is network locked. Please contact your service provider to get unlock code.

+network_locked_times_explain =  Attempts left for unlock code input:

+network_locked_enter_explain = Please input unlock code:

+network_locked_zero_times = This device is network locked. Please contact your service provider.

+

+#update_info

+update_info = Update Information

+update_no_info = Software is up to date

+update_new_version_found = New version available

+update_current_version = Current Version

+update_new_version = New Version

+update_link_prompt = Click the following links to download update tools.

+update_skip_btn = Apply

+update_id_skip_info = If you don''t want to update, please click &quot;Skip&quot;.

+update_remind = Remind me when new version found.

+update_management = Update Management

+update_log = Bug Fixed

+update_note = Note

+update_notice = New version found. For more details, please goto Settings->Device Settings->Update management

+update_note_info = Click the link to download update tool.

+update_note_install = Extract update tool and then run it to start updating.

+update_note_linux = Can''t upgrade online in Linux. Please upgrade in Windows or on a Mac.

+update_status = Status

+update_settings = Update

+wifi_connect_alert = You can only update by connecting the ethernet cable.

+

+#AP_Station

+ap_station = Internet Wi-Fi

+ap_station_switch = Internet Wi-Fi Switch

+ap_station_wlan_mode = Preferred Network

+ap_station_wifi_prior = Wi-Fi

+ap_station_3g_prior = WWAN

+ap_station_current_status = Current Status

+ap_station_wlan_connected = Wi-Fi connected

+ap_station_wan_connected = WAN connected

+ap_station_no_connection = No connection

+ap_station_hotspot_list = Wi-Fi Hotspot

+ap_station_connect = Connect

+ap_station_disconnect = Disconnect

+ap_station_add_hotspot = Add Wi-Fi Hotspot

+ap_station_edit_hotspot = Edit Wi-Fi Hotspot

+ap_station_show_password = Display Password

+ap_station_encrypt_type = Encryption Type

+ap_station_wep_keys = WEP Keys

+ap_station_encrypt_type_none = NO ENCRYPTION

+ap_station_encrypt_type_wep = WEP

+ap_station_wep_key_type_ascii = ASCII

+ap_station_wep_key_type_hex = HEX

+ap_station_cipher = WPA Algorithms

+ap_station_cipher_TKIP = TKIP

+ap_station_cipher_AES = AES

+ap_station_cipher_AUTO = AUTO

+ap_station_security_mode_OPEN = OPEN

+ap_station_security_mode_WPAPSKWPA2PSK = WPA-PSK/WPA2-PSK

+ap_station_security_mode_SHARED = SHARED

+ap_station_security_mode_WPAPSK = WPA-PSK

+ap_station_security_mode_WPA2PSK = WPA2-PSK

+ap_station_security_mode_EAPAKASIM = EAP-AKA/SIM

+ap_station_security_mode_EAP-SIM/AKA = EAP-SIM/AKA

+ap_station_security_mode_WPA3Personal = WPA3-Personal

+ap_station_security_mode_WPA2WPA3 = WPA2(AES)/WPA3-Personal

+ap_station_wep_default_key = Default Key

+ap_station_wep_key = Key

+ap_station_wep_key_0 = Key 1

+ap_station_wep_key_1 = Key 2

+ap_station_wep_key_2 = Key 3

+ap_station_wep_key_3 = Key 4

+ap_station_exceed_list_max = The max number of AP is {0}!

+ap_station_search_hotspot_fail = Search hotspot failure!

+ap_station_connect_change_alert = Will disconnect from WAN. Continue?

+ap_station_update_fail = Operate failed. The hotspot is in connection.

+ap_station_enable_confirm = Multi SSID cannot be used when Internet Wi-Fi is being used. Multi SSID is automatically turned OFF if Internet Wi-Fi is ON. Still change settings?

+ap_station_processing = Background busy, please try again.

+ap_station_exist = Hot spots of the same name already exist.

+ap_connect_error = Failed to connect {0}!

+

+#fastboot

+fastboot = Fast Boot

+fastboot_setting = Fast Boot Settings

+fastboot_note = If enable Fast Boot function, your device will start in a short time.

+

+#notes

+wifi_channel_bandwidth = Channel Bandwidth

+

+home_note = The table shows the information of connected wireless device(s).

+

+sms_setting_note_validity = Validity: Set valid period of outgoing messages.

+sms_setting_note_center_number = Center Number: Enter SMS center number. For more information, please contact your service provider.

+sms_setting_note_delivery_report = Delivery Report: Receive or reject a prompt informing you that the message is delivered to the recipient.

+

+apn_note_whole_page = You can set the Access Point Name(APN) on this page.

+apn_note_mode = Mode: If a fixed APN is provided by your service provider, select Manual APN. Otherwise, please select Auto APN, and the device will automatically obtain parameters.

+apn_note_profile = Profile: It contains one or more profile names.

+apn_note_pdp_type = PDP Type: IPv4/IPv6/IPv4&IPv6.

+apn_note_profile_name = Profile Name: It refers to the name that you assign to the new profile.

+apn_note_apn = APN: Access Point Name. The APN contains 0-9 a-z A-Z . - and it can''t start with and end with .or -.

+apn_note_dns_mode = DNS Mode: If a fixed IP address is provided by your service provider, select Manual DNS. Otherwise, please select Auto DNS, and the device will automatically obtain parameters.

+apn_note_authentication = Authentication: It is provided by your Internet Service Provider(ISP).Password Authentication Protocol (PAP) provides a simple method without encryption for the peer to establish its identity using a 2-way handshake. Challenge-Handshake Authentication Protocol (CHAP) is used to periodically verify the identity of the peer using a 3-way handshake.

+apn_note_username = User Name: User name is used to obtain authentication from the ISP when the connection is established.

+apn_note_password = Password: Password is used to obtain authentication from the ISP when the connection is established.

+apn_note_set_default = Click "Set as default" to set this profile as the default profile.

+

+wifi_basic_note_multi_ssid_switch = Multi SSID Switch: 2 SSID can be used at the same time.

+wifi_basic_note_network_name = Network Name(SSID): SSID can be understood as network name. When change the SSID, please enter a string less than 32 characters as the name for your Wi-Fi. The string contains numbers, letters (a-z, A-Z), special characters (!#()+-./%=?@^_{|}~) and space, and it can''t start and end with space.

+wifi_basic_note_network_name_input = The network name contains 0-9 a-z A-Z ! # ( ) + - . / % = ? @ ^ _ { | } ~ and space, and it can''t start and end with space.

+wifi_basic_note_broadcast = SSID Broadcast: If enable this function, the device will broadcast SSID. Other wireless devices will discover and connect to this device.

+wifi_basic_note_security_mode = Security Mode:

+wifi_basic_note_no_encryption = OPEN: Unencrypted mode. There are risks that network will be used by unauthorized individuals. This encryption mode isn't recommended.

+wifi_basic_note_shared = SHARED(WEP): Link authentication mode is shared key authentication, the encryption method is WEP.

+wifi_basic_note_wpa_psk_aes = WPA2(AES)-PSK: It is the secure version of WPA with implementation of the 802.11i standard.

+wifi_basic_note_wpa_psk = WPA-PSK/WPA2-PSK: WPA Pre-Shared Key (WPA-PSK). WPA2-PSK is the secure version of WPA with implementation of the 802.11i standard.

+wifi_basic_note_wpa3 = WPA3-Personal: It is the successor to WPA2.

+wifi_basic_note_wpa2_wpa3 = WPA2(AES)/WPA3-Personal: WPA2-PSK is the secure version of WPA with implementation of the 802.11i standard. WAP3 is the successor to WPA2.

+wifi_basic_note_pass_phrase = Pass Phrase: The pass-phrase contains 0-9 a-z A-Z ! # ( ) + - . / % = ? @ ^ _ { | } ~

+wifi_basic_note_max_station_number1 = Max Station Number: You can select the maximum number of wireless terminals which can connect to the device.The Wi-Fi Hotspot connected by Internet Wi-Fi is also calculated.

+wifi_basic_note_max_station_number = Max Station Number: You can select the maximum number of wireless terminals which can connect to the device.

+

+wifi_advanced_note_whole_page = You can set Wi-Fi advanced characters on this page.

+wifi_advanced_note_band_selection = Band Selection: The Wi-Fi operating band for your device.

+wifi_advanced_note_network_mode = Network Mode: The Wi-Fi operating network mode for your device.

+wifi_advanced_note_country_code = Country/Region Code: The Country/Region Code for your device.

+wifi_advanced_note_frequency = Frequency (Channel): Select appropriate channel to optimize the performance and coverage of your wireless network.

+

+ap_station_note_info = Please make sure that the IP address of Wi-Fi hotspot you''ve connected isn''t in the range of this device IP address, or you won''t have access to Internet via the Wi-Fi hotspot.

+ap_station_note_disable_info = If enable multi-SSID, Internet Wi-Fi will be disabled.

+ap_station_on_info = You can''t operate when Wi-Fi is enabled!

+

+wif_filter_note1 = Set MAC address filtering mode in the WLAN MAC Filter drop-down list box.

+wif_filter_note2 = Ruleless:Disable the WLAN MAC fliter.

+wif_filter_note3 = White List:Allow a client to connect to the device using the WLAN if the client's MAC address exists in the MAC Address list.

+wif_filter_note4 = Black List:Deny a client's connection to the device using the WLAN if the client's MAC address exists in the MAC Address list.

+

+#restart

+restart = Restart

+restart_button = Restart Device

+restart_confirm = Restart the device?

+restarting = Restarting Device

+

+#diconneted_operate_note

+diconneted_operate_note = To change current setting, please disconnect from network.

+diconneted_network_confirm = This operation may disconnect from network, continue any way?

+

+#ota_update

+ota_update = Update Management

+ota_title = Update

+ota_no_new_version = No new version found.

+ota_new_version = Found new version. Do you want to update?

+ota_connect_server = Connecting to server

+ota_connect_server_successfully = Connected to server successfully

+ota_downloading = Downloading...

+ota_download_failed = Download failed

+ota_no_network = No network

+ota_network_disconnected = Please connect to network before updating!

+ota_interrupted_alert = Found new version. Please login to update!

+ota_interrupted = Resume the downloading task which was interrupted before?

+ota_download_success = Download completed, and the device will restart. Please wait. Please do not power off, or reset factory settings, or turn off the device during the update.

+ota_pkg_download_success = Upgrade package has been downloaded already, and the device will restart. Please wait. Please do not power off, or reset factory settings, or turn off the device during the update.

+ota_update_success = Updated successfully!

+ota_update_failed = Update failed.

+ota_connect_server_failed = Unable to connect to server.

+ota_download_warning = Make sure there''s enough battery; Don''t force stop during download process.

+ota_update_warning = Attention: Don''t force stop during update process.

+ota_cancel = Update has been cancelled!

+ota_pkg_exceed = The update package is too large!

+ota_have_cancel = You have already cancelled!

+ota_roamming = The Roaming Setting is disabled. To enable it, please click in the checkbox  on this page.

+ota_low_battery = Download completed and battery is low, please charge before update!

+ota_pkg_low_battery = Upgrade package has been downloaded already,and battery is low, please charge before update!

+ota_md5_error = Check update package failed.

+ota_version = Version:

+ota_update_setting = Auto Check Settings

+ota_auto_update_switch = Auto-check New Version

+ota_update_interval_day = Auto-check Cycle

+ota_roaming_setting = Roaming Settings

+ota_update_roaming_remind = Check this option, the device will update when roaming, which will incur roaming charges.

+ota_update_manual = Check New Version

+ota_check_new_version = Check

+ota_check_new_version_desc = Click Check button for checking new version immediately.

+ota_check_roaming_confirm = You are on roaming! Would you like to continue?

+ota_update_every_day = Every day

+ota_update_15_day = 15 days

+ota_update_30_day = 30 days

+ota_new_version_checking = Checking new version...

+ota_update_running = Checking is ongoing...

+ota_check_fail = Check new version failed!

+ota_manual_upgrade_url = Upgrade File Download Address 

+fota_package_already_download = Upgrade package has been downloaded,after waiting for equipment to restart to complete.

+software_upload = Software Upload

+upload_update_success = The upgrade file upload successful and will be about to restart,do not power off.

+upload_update_failed0 = parse file failed.   

+upload_update_failed1 = verify file failed.   

+upload_update_failed2 = write file failed.   

+upload_update_failed3 = write update flag failed.

+upload_update_failed4 = verify flash failed.

+error_file_selected = please choose right files.

+upload_tip = Should not close,refresh or open more webui,when uploading until restart.

+########CPE more wording##############

+opmode = Change Mode

+wds = WDS

+url_filter = URL Filtering

+

+voip_settings = VoIP Settings

+voip_basic_settings = Basic Settings

+voip_user_details = User Details

+voip_advanced_settings = Advanced Settings

+voip_supplementary_service = Supplementary Service

+

+url_check = invalid URL

+url_filter_check = invalid url filter format

+sntp_invalid_server_name = Invalid URL format or invalid ip address

+server_alreay_exist = This server is already exist

+forwarding_uri_check = Invalid Value

+

+wifi_switch = Wi-Fi Switch

+ap_isolation = AP Isolation

+#mac filter

+black_list = Black List

+black_list_switch = Black List Switch

+block = Block

+black_list_max = The max number of black list is 10!

+mac_repeat_tip = Please delete the repeated MAC addresses!

+black_yourself_tip = You can''t block yourself!

+wifi_status11 = Number of users:11

+wifi_status12 = Number of users:12

+wifi_status13 = Number of users:13

+wifi_status14 = Number of users:14

+wifi_status15 = Number of users:15

+wifi_status16 = Number of users:16

+wifi_status17 = Number of users:17

+wifi_status18 = Number of users:18

+wifi_status19 = Number of users:19

+wifi_status20 = Number of users:20

+wifi_status21 = Number of users:21

+wifi_status22 = Number of users:22

+wifi_status23 = Number of users:23

+wifi_status24 = Number of users:24

+wifi_status25 = Number of users:25

+wifi_status26 = Number of users:26

+wifi_status27 = Number of users:27

+wifi_status28 = Number of users:28

+wifi_status29 = Number of users:29

+wifi_status30 = Number of users:30

+wifi_status31 = Number of users:31

+wifi_status32 = Number of users:32

+

+auto_connect = Auto Connect

+manual_connect = Manual Connect

+

+default_Gateway = Default Gateway

+primary_dns = Primary DNS Server

+secondary_dns = Secondary DNS Server

+gateway_check = Please input a valid gateway

+

+mac_filter_lable = MAC Filter Format

+

+wlan_mac_filter_0 = Ruleless

+wlan_mac_filter_1 = White List

+wlan_mac_filter_2 = Black List

+

+#SNTP

+local_current_time = Current Local Time

+time_set_mode = Time Set Mode

+time_set_time_manual = Manual Set Time

+time_set_time_auto = Sntp auto Synchronization

+year = Year

+month = Month

+date = Date

+hour = Hour

+minute = Minute

+second = Second

+sunday = Sunday

+monday = Monday

+tuesday = Tuesday

+wednesday = Wednesday

+thursday = Thursday

+friday = Friday

+saturday = Saturday

+stnp_server1 = SNTP Server1

+stnp_server2 = SNTP Server2

+stnp_server3 = SNTP Server3

+time_zone = Time Zone

+daylight_saving_time = Daylight Saving Time

+daylightsave_0 = Disable

+daylightsave_1 = Enable

+sntp_syn_time_wan_connected = SNTP time synchronization can be used after networking!

+operation_not_supported = operation not supported!

+network_terminated = USSD terminated by network

+upgrade_file_nomatch = You do not select the root_uImage or modem.zip!

+upgrade_confirm = Do you really want to upgrade the Image?

+upgrading = Upgrading, please wait....

+upgrading_alert = Upgrading, please don''t cut off your power supply. After upgrade, it will restart automaticly!

+upgrad_note = Please select the version you want to upgrade, then click the ''Apply'' button to start upgrade.

+sntp_processing = Synchronizing, please wait....

+sntp_req_success = The SNTP request has been sent!

+time_zone_<-12>12_0 = (GMT-12:00) Dateline West

+time_zone_SST11_0 = (GMT-11:00) Midway Islands, Samoa

+time_zone_<-10>10_0 = (GMT-10:00) Hawaii

+time_zone_<-09>9_0 = (GMT-09:00) Alaska

+time_zone_PST8PDT,M3.2.0,M11.1.0_0 = (GMT-08:00) Pacific time (USA and Canada), Tijuana

+time_zone_<-07>7_0 = (GMT-07:00) Mountain time (USA and Canada)

+time_zone_<-07>7_1 = (GMT-07:00) Arizona

+time_zone_MST7MDT,M4.1.0,M10.5.0_2 = (GMT-07:00) Chihuahua, La Paz, Mazza Tran

+time_zone_<-06>6_0 = (GMT-06:00) Saskatchewan

+time_zone_<-06>6_1 = (GMT-06:00) Central time (USA and Canada)

+time_zone_<-06>6_2 = (GMT-06:00) Central America

+time_zone_<-06>6_3 = (GMT-06:00) Guadalajara City, Mexico City, Monterey

+time_zone_<-05>5_0 = (GMT-05:00) Bogota, Lima, Quito

+time_zone_<-05>5_1 = (GMT-05:00) Eastern time (USA and Canada)

+time_zone_EST5EDT,M3.2.0,M11.1.0_2 = (GMT-05:00) Indiana (East)

+#time_zone_-4.5 = (GMT-04:30)

+time_zone_AST4ADT,M3.2.0,M11.1.0_0 = (GMT-04:00) Atlantic time (Canada)

+time_zone_<-04>4_1 = (GMT-04:00) Caracas, La Paz

+time_zone_<-04>4<-03>,M8.2.6/24,M5.2.6/24_2 = (GMT-04:00) Santiago

+time_zone_NST3:30NDT,M3.2.0,M11.1.0_0 = (GMT-03:30) Newfoundland

+time_zone_<-03>3_0 = (GMT-03:00) Brasilia

+time_zone_<-03>3_1 = (GMT-03:00) Buenos Aires, Georgetown

+time_zone_<-03>3_2 = (GMT-03:00) Greenland

+time_zone_<-02>2_0 = (GMT-02:00) Mid-Atlantic

+time_zone_<-01>1_0 = (GMT-01:00) Cape Verde Islands

+time_zone_<-01>1<+00>,M3.5.0/0,M10.5.0/1_1 = (GMT-01:00) Azores

+time_zone_GMT0IST,M3.5.0/1,M10.5.0_0 = (GMT) GMT: Dublin, Edinburgh, London, Lisbon

+time_zone_WET0WEST,M3.5.0,M10.5.0/3_1 = (GMT) Casablanca, Monrovia

+time_zone_CET-1CEST,M3.5.0,M10.5.0/3_0 = (GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna

+time_zone_CET-1CEST,M3.5.0,M10.5.0/3_1 = (GMT+01:00) Belgrad, Bratislava, Budapest, Ljubljana, Prague

+time_zone_CET-1CEST,M3.5.0,M10.5.0/3_2 = (GMT+01:00) Brussels, Copenhagen, Madrid, Paris

+time_zone_CET-1CEST,M3.5.0,M10.5.0/3_3 = (GMT+01:00) Sarajevo, Skopje, Warsaw, Zagreb

+time_zone_<+01>-1_4 = (GMT+01:00) Western Central African

+time_zone_EET-2EEST,M3.5.0/3,M10.5.0/4_0 = (GMT+02:00) Bucharest

+time_zone_CAT-2_1 = (GMT+02:00) Pretoria, Harare

+time_zone_EET-2EEST,M3.5.0/3,M10.5.0/4_2 = (GMT+02:00) Helsinki, Kiev, Riga, Sofia, Tallinn, Vilnius

+time_zone_EET-2_3 = (GMT+02:00) Cairo

+time_zone_EET-2EEST,M3.5.0/3,M10.5.0/4_4 = (GMT+02:00) Athens, Beirut, Istanbul, Minsk

+time_zone_IST-2IDT,M3.4.5/02:00:00,M10.5.0/02:00:00_5 = (GMT+02:00) Jerusalem

+time_zone_<+03>-3_0 = (GMT+03:00) Baghdad

+time_zone_<+03>-3_1 = (GMT+03:00) Riyadh, Kuwait

+time_zone_<+03>-3_2 = (GMT+03:00) Moscow, St Petersburg, Volgograd

+time_zone_EAT-3_3 = (GMT+03:00) Nairobi

+time_zone_<+0330>-3:30<+0430>,J80/0,J264/0_0 = (GMT+03:30) Teheran

+time_zone_<+04>-4_0 = (GMT+04:00) Abu Zabi, Muscat

+time_zone_<+04>-4_1 = (GMT+04:00) Baku, Tbilisi, Yerevan

+time_zone_<+0430>-4:30_0 = (GMT+04:30) Kabul

+time_zone_<+05>-5_0 = (GMT+05:00) Yekaterinburg

+time_zone_PKT-5_1 = (GMT+05:00) Islamabad, Karachi, Tashkent

+time_zone_<+0530>-5:30_0 = (GMT+05:30) Madras, Calcutta, Mumbai, New Delhi

+time_zone_<+0545>-5:45_0 = (GMT+05:45) Kathmandu

+time_zone_<+06>-6_0 = (GMT+06:00) Ala Mutu, Novosibirsk

+time_zone_<+06>-6_1 = (GMT+06:00) Dhaka, Astana

+time_zone_<+06>-6_2 = (GMT+06:00) Sri Haya Ed Denny Pla

+time_zone_<+0630>-6:30_0 = (GMT+06:30) Yangon

+time_zone_<+07>-7_0 = (GMT+07:00) Krasnoyarsk

+time_zone_<+07>-7_1 = (GMT+07:00) Bangkok, Hanoi, Jakarta

+time_zone_CST-8_0 = (GMT+08:00) Beijing, Chongqing, Hongkong Special Administrative Region, Urumqi

+time_zone_<+08>-8_1 = (GMT+08:00) Kuala Lumpur, Singapore

+time_zone_AWST-8_2 = (GMT+08:00) Perth

+time_zone_CST-8_3 = (GMT+08:00) Taipei

+time_zone_<+08>-8_4 = (GMT+08:00) Irkutsk, Ulam Batu

+time_zone_JST-9_0 = (GMT+09:00) Osaka, Sapporo, Tokyo

+time_zone_KST-9_1 = (GMT+09:00) Seoul

+time_zone_<+09>-9_2 = (GMT+09:00) Yakutsk

+time_zone_ACST-9:30ACDT,M10.1.0,M4.1.0/3_0 = (GMT+09:30) Adelaide

+time_zone_ACST-9:30_1 = (GMT+09:30) Darwin

+time_zone_AEST-10_0 = (GMT+10:00) Brisbane

+time_zone_<+10>-10_1 = (GMT+10:00) Vladivostok

+time_zone_<+10>-10_2 = (GMT+10:00) Guam, Port Moresby

+time_zone_AEST-10AEDT,M10.1.0,M4.1.0/3_3 = (GMT+10:00) Hobart

+time_zone_AEST-10AEDT,M10.1.0,M4.1.0/3_4 = (GMT+10:00) Canberra, Melbourne, Sydney

+time_zone_<+11>-11_0 = (GMT+11:00) Magadan, Solomon islands, New Caledonia

+time_zone_<+12>-12_0 = (GMT+12:00) Wellington, Oakland

+time_zone_<+12>-12_1 = (GMT+12:00) Fiji, Kamchatka, Marshall Islands

+time_zone_<+13>-13_0 = (GMT+13:00) Nukualofa

+

+#operation mode

+opmode_auto = Automatic

+opmode_bridge = Bridge Mode

+opmode_cable = Cable Broadband Mode

+opmode_gateway = Wireless Broadband Mode

+EthPort_Status = Ethernet Port Status

+change_mode = Change Mode

+current_mode = Current Mode:

+change = Change

+change_mode_alert = Cable Broadband mode can only use Wi-Fi to access, please remember Wi-Fi SSID and password! Continue?

+opmode_msg1 = If wireless broadband mode is enabled, please remove network cable of public network.

+opmode_msg2 = The device will be restarted when operation mode is changed.

+opmode_msg3 = The network cable of public network has been removed.

+#pppoe dial

+pppoe_mode = PPPoE

+pppoe_success = PPPoE dial successfully

+pppoe_fail = PPPoE dial failed

+pppoe_processing = PPPoE dialing

+static_success = Successfully set static IP

+static_fail = Set static IP failed

+static_processing = Setting static IP

+dyn_success = Successfully obtained dynamic IP

+dyn_fail = Obtain dynamic IP failed

+dyn_processing = Obtaining dynamic IP

+pppoe_msg = The network cable of public network has been removed

+pppoe_message_send_fail = Send message failed!

+ip_gate_not_same = IP Address and Default Gateway can''t be same!

+ip_innergate_not_same = IP Address and  LAN IP address of the router can''t be in the same segment!

+auto_success = AUTO dial successfully

+auto_fail = AUTO dial failed

+auto_processing = AUTO dialing

+#url filter

+url_filter_list = Current URL Filtering

+url_filter_max = The maximum number of URL filter rules is {0}

+url_repeated = This URL already exists.

+url_note1 = You can set the web address of URL filter to protect your network from some of the bad site.

+url_note2 = URL: Set the URL address that needs to be filtered.

+

+#wds

+wds_mode = WDS Mode

+wds_mode_0 = Disable

+wds_mode_1 = RootAP Mode

+wds_mode_2 = Bridge Mode

+wds_mode_3 = Repeater Mode

+repeater_ssid = Repeater SSID

+wpa_algorithms = WPA Algorithms

+enable_wds_confirm = If enable WDS, Wi-Fi basic settings will be disabled. Continue?

+#sys log

+sys_log = System Log

+log_setting = Log Settings

+syslog_mode_all = All

+syslog_mode_wan_connect = WAN Connect

+syslog_mode_sms = SMS

+syslog_mode_tr069 = tr069

+syslog_mode_voip = VoIP

+syslog_mode_dlna = DLNA

+syslog_mode_wlan = WLAN

+syslog_mode_router = Router

+view_log = View log

+log_info = Log information

+

+#add at 2013.6.20

+periodic_inform = Periodic Inform

+periodic_inform_interval = Periodic Inform Interval

+periodic_inform_time = Periodic Inform Time

+certificate_import = Certificate

+import_certificate_btn = Import

+certificate_file_nomatch = You do not select the ca-cert.crt!

+#voip setting

+outbound_mode = Outbound Mode

+outbound_server = Outbound Server

+outbound_port = Outbound Port

+stun_mode = STUN Mode

+stun_server = STUN Server

+register_every = Register Every

+advanced_options = Advanced Options

+sip_port = SIP Port

+rtp_port = RTP Port

+voip_outbound_port_check = Invalid port.

+voip_time_check = Invalid register time.

+timeRange = [1, 3600] seconds

+voip_sip_port_check = Invalid port.

+voip_port_compare = Invalid port range.

+warn_information = The parameters of VoIP set success, please register again.

+#voip user details

+user_details_title = SIP Server and Configuration

+sip_register_server = SIP Register Server

+sip_domain = SIP Domain

+sip_realm = SIP Realm

+sip_proxy_mode = SIP Proxy Mode

+sip_proxy_server = SIP Proxy Server

+authorization = Authorization

+display_name = Display Name

+authorized_user_name = Authorized User Name

+authorized_password = Authorized Password

+voip_register_status = VoIP Register Status

+register_failed = Register Fail

+register_success = Register Success

+register_connecting = Register Connecting

+unregister = Unregister

+deregister = Deregister

+sip_domain_check = SIP Domain Address invalid

+sip_realm_check = SIP Realm invalid

+sip_proxy_server_check = IP Proxy Server invalid

+display_name_check = Display Name invalid

+authorized_username_check = Authorized User Name invalid

+account_password_check = Password invalid

+#voip advanced settings

+sip_advanced_options = Advanced Options

+adv_sip_t38 = T.38 FAX Encoder

+sip_dtmf = DTMF

+voip_sip_dtmf_method_inband = InBand

+voip_sip_dtmf_method_rfc2833 = RFC2833

+voip_sip_dtmf_method_sipinfo = SIPInfo

+sip_encoder = Encoder

+voip_sip_encoder_method_0 = G.711 u-Law

+voip_sip_encoder_method_1 = G.711 a-Law

+voip_sip_encoder_method_2 = G.722

+voip_sip_encoder_method_3 = G.729

+voip_sip_encoder_method_4 = G.726-16kps

+voip_sip_encoder_method_5 = G.726-24kps

+voip_sip_encoder_method_6 = G.726-32kps

+voip_sip_encoder_method_7 = G.726-40kps

+sip_vad = VAD

+sip_cng = CNG

+#voip supplementary service

+sip_protocol_voip = VoIP supplementary service

+sip_protocol_call_forw = Call Forwarding

+voip_forwarding_mode_1 = Unconditional forwarding

+voip_forwarding_mode_2 = When busy

+voip_forwarding_mode_3 = When no answer

+voip_forwarding_mode_0 = Cancel all forwarding

+sip_protocol_forw_uri = Forwarding URI

+show_msg = Please press '*80' on the phone!

+sip_protocol_incoming_call = Do Not Disturb

+sip_protocol_call_waiting = Call Waiting

+wds_note = WDS: Wireless Distribution System

+#voip user details

+connect_note = Please connect to internet if you want to use VoIP phone!

+#fota

+upgrade_pack_fix_success = Upgrade success!

+upgrade_pack_fix_failed = Upgrade failed!

+have_new_version = New version is found,the device will update.

+

+######key same value different###########

+dmz_note_info = If a terminal device can''t run network applications via this device, please enter IP address of the terminal device in the entry box when DMZ is enabled.

+dlna_note_info = DLNA: Digital Living Network Alliance.

+dlna_note_httpshare = You can set Digital Media Server (DMS) device name, and media type which you want to share on this page.

+#############串口转网口###################

+switch_port_title = Switch ethernet port to serial port

+open_serial_port = Turn ethernet port to serial port

+close_serial_port = Close ethernet port to serial port

+switching = switching...

+##############定时重启功能wording###################

+restart_schedule = Restart Schedule

+enable_reboot_switch = Turn on automatic restart function

+restart_schedule_time = Scheduled restart time

+enable_reboot_byday = Automatic restart schedule based on every day

+enable_reboot_byweek = Automatic restart schedule based on the week

+enable_reboot_bymonth = Automatic restart schedule based on the month

+synchronized = synchronized

+unsynchronized = unsynchronized

+week = Week

+login_password_length_check = Please input 4 characters at least.

+system_time_not_syn = System time not synchronized!

+fota_note1 = You can set up an auto-check cycle for your device, so that the device automatically detects whether there is a new version of the software.

+local_note = You can choose the upgrade file on the local computer, upgrade the device software to the selected version, complete the system repair and optimization.

+

+#new word

+modify_password = Modify Login Password

+

+#parental control

+parental_control = Parental Control

+pc_children_group = Kids Devices

+pc_children_group_manage = Kids Manage

+pc_manage = Manage

+pc_no_children_device = Not set Kids Devices

+pc_children_group_desc = All kids devices will follow network access policy

+pc_edit_host_name = Edit the hostname:

+pc_internet_rule = Network Access Policy

+pc_time_limited =  Online Time Setting

+pc_site_white_list = Website Whitelist

+pc_manage_children_group = Manage Kids Devices

+pc_current_attached_devices = Current Devices

+pc_action = Operation

+pc_remove = Remove

+pc_remove_all = Remove All

+pc_add = Add

+pc_leave = Leave

+pc_add_white_site = Add The White List

+pc_in_child_group = Added as kids device

+pc_forbid_time = Not Allow

+pc_allow_time = Allow

+pc_setting_desc = Click with your mouse to allow or forbid network access

+pc_name = Name

+pc_link = URL

+pc_not_save = Data not saved, please pay attention to save

+pc_link_exist = URL already exists!

+no_data = No data

+sun = SUN

+mon = MON

+tues = TUES

+wed = WED

+thur = THUR

+fri = FRI

+sat = SAT

+

+#定时休眠唤醒

+tsw_settings = Wi-Fi Awake Settings

+tsw = Wi-Fi Awake

+time_sleep_wake_up = Wi-Fi Awake Settings

+tsw_timer_on = Wake-up Time

+tsw_timer_off = Sleep Time

+tsw_sys_time_mode_alert = Please connect to the network and using the SNTP auto synchronizing time.

+tsw_time_interval_alert = The time interval should not be less than 10 minutes.

+

+#new wording

+advanced_settings = Advanced Settings

+others = Others

+others_restart_reset = Restart and Reset

+others_note_info = Please login again after rebooting or resetting router

+

+pwd_sub_title = Manage information about your wireless router

+pwd_note = When you log in wireless router, need to input this password (password is different from your wireless network password)

+current_network = Current Network

+

+wifi_wireless_settings = Wi-Fi Settings

+wifi_main_sub_title = Set up wireless hotspot so that your mobile phone or laptop could access network via it

+wifi_broadcast_desc = SSID Broadcast

+wifi_isolated_desc = All the wireless client device is completely isolated

+

+detail_info = Detail Information

+sd_u_share = SD Sharing

+

+settings_wireless = Wi-Fi Settings

+settings_internet = Network Settings

+not_connect_network = Disconnected

+

+traffic_data_plan = Statistics

+traffic_pie_title = Data Plan

+traffic_sub_title = You can create statistic plan, query used and left statistic

+traffic_used = Used

+traffic_used_text = {0} Used

+traffic_limit_data = Data Plan

+traffic_limit_data_text = {0} Data Plan

+traffic_alert_reach_text = When reached {0}%, {1} to remind me

+traffic_data_left_text = {0} of remaining

+traffic_when = When reached

+traffic_remind_me = %, to remind me

+traffic_remind_me_time = , to remind me

+traffic_limit_time_text = {0} Plan

+traffic_limit_time_h = {0} Hour(s) Plan

+traffic_limit_time_m = {0} Minute(s) Plan

+traffic_not_set_limited = Not set, click Settings

+

+echarts_used = Used

+echarts_left1 = Left

+echarts_alert = Alert

+echarts_alarm = Used(exceed alert)

+echarts_free = Left

+echarts_full = Exceed

+echarts_no = Not set

+

+3g = 3G

+wan = WAN

+connection_mode = Connection Mode

+wireless_access_device = Wireless Access Device

+cable_access_device = Cable Access Devices

+station_info_sub_title = All of wireless devices connected to this router will show on the page, including device name and MAC address

+station_info_desc = More access control options, please click here

+

+device_unit = &nbsp;

+ota_last_update_check = Last Update Time:

+main_ssid_num = Main SSID ({0})

+guest_ssid_num = Guest SSID ({0})

+wifi_slider_desc = * Drag the progress bar has adjusted the SSID maximum access number

+wif_guest_disabled = Guest SSID is disabled

+

+phone_number = Number

+equalToPin = The PINs you've entered do not match

+equalToPassword = The passwords you've entered do not match

+

+pppoe_mode_type_PPPOE = PPPoE

+pppoe_mode_type_STATIC = Static IP

+pppoe_mode_type_DHCP = Dynamic IP

+pppoe_mode_type_AUTO = Auto

+

+tsw_note = Awake Settings: When awake settings is enabled, device will automatically sleep; Wi-Fi will be unavailable.

+tsw_note_on = Wake-up Time: You can set the wake-up time.

+tsw_note_off = Sleep Time: You can set the sleep time.

+

+parent_control_note_kids = Kids Devices: Show Kids devices.

+parent_control_note_manage = Kids Management: Manage Kids devices.

+parent_control_note_time = Online Time Setting: Set online time for kids.

+parent_control_note_whitelist = Website Whitelist: Set website white list for kids to access websites.

+

+wan_note_dial = Dial-up Mode:

+wan_note_connection_mode = Please select network connection mode for your device:

+wan_note_connection_mode_pppoe = PPPoE: Access Internet. You may ask your network provider for PPPoE username and password.

+wan_note_connection_mode_dhcp =  Dynamic IP: Access Internet via dynamic IP address.

+wan_note_connection_mode_static = Static IP: Access Internet via static IP address. Please set IP address, subnet mask, default gateway, primary and secondary DNS.

+wan_note_user_name = User Name: Enter your PPPoE account.

+wan_note_password = Password: Enter your PPPoE password.

+wan_note_connection_mode_auto = AUTO: Access Internet via dynamic IP address or PPPoE. You may ask your network provider for PPPoE username and password.

+parent_control_note_siteName = The White List namecan''t contain following characters: < > [ ] * $ & : , ; " ' ` / \\ | ? ¥

+parent_control_note_siteLink = The white list link should start with "http://" or "https://".

+firewal_note = Note : Firewall''s related rule settings may not take effect immediately, need to wait for a few minutes or restart the device. If you need to take effect immediately, it is recommended to restart the device.

+

+wps_pin_validator = Please input a valid PIN number

+device_rename = Please input a valid name.

+

+turnoff_button = Turn Off Device

+others_turn_off= Turn Off Device

+turnoff_confirm  = Turn Off the device?

+turnoff = Turn Off...

+setting_no_change = Your settings did not change.

+Extend_accessDevice = The Max Station Number is not less than current access device number.

+

+TBcheck = Please input a value between 1 and 4095

+apn_pdptype_change_note = If the setting is changed,you may have a risk not to visit the Webpage by {0}. Then please try {1} to visit.

+apn_alert = This operation may restart the device. Continue any way?

+apn_alert_restart = The default APN settings are successful and the device is being restarted.

+apn_diconneted_network_confirm = This operation may disconnect from network, continue any way?

+

+#super

+super = Lock cell Settings

+lockCell_settings = Lock cell Settings

+v4_settings = Lock(V4 Encryption)

+cell_id1 = Cell Id 1

+cell_id2 = Cell Id 2

+cell_id3 = Cell Id 3

+cell_id4 = Cell Id 4

+cell_id5 = Cell Id 5

+v4_check = Invalid character, The character must be 0-9, a-z, A-Z

+v4_note = Your settings will take effect after restarting your device,Do you want to continue?

+

+export_title = Export settings

+band_3 = Band 3

+band_8 = Band 8

+band_38 = Band 38

+band_39 = Band 39

+band_40 = Band 40

+band_info = Band Settings

+cell_id = Current registration Cell

+lock_apply = Lock

+unlock_apply= Unlock

+sinr = SINR

+band_cell_settings = Band Cell Settings

+export = Export

+cell_not_correct= Not Lock Cell,Connected Fail!

+cell_id_lock = Locked Cell

+

+sip_uri_format = URI format

+user_name = User Name

+pin_v4_encrypt = PIN encrypt

+wep_cannot_2040 = When Current Security Mode of Main SSID or Guest SSID is OPEN (WEP) or SHARED, Channel Bandwidth can''t be 20MHz/40MHz!

+2040_cannot_wep = When Channel Bandwidth is 20MHz/40MHz, Current Security Mode of SSID can''t be OPEN (WEP) or SHARED.

+wifi_device_busy = Wi-Fi driver is busy, please wait...

+manufactory_code = Manufactory Code

+key_version_number = Key Version Number

+key_value = Key Value

+

+white_list = White List

+black_enable= Black list

+white_enable = White list

+mac_white_address = MAC Address

+max_white_list = The maximum number of white list is 6.

+LockCell_note1 =  Cell locking is for the LTE network community lock, the current registration area and locking the same cell allows network, currently registered residential and residential lock inconsistent when inhibit the initiation network.

+LockCell_note2 =  Residential lock to open and save the locking area not is empty, network community of the current registration of every boot and timing 8:00/14:00/20:00 ratio on the and locking area is the same, if different is broken network processing.

+mac_blank = MAC Address can''t be empty.

+

+vlan_switch = VLAN Switch

+vlan_notice = If you choose the Disable, it will take effect after restarting your device. Do you want to continue?

+vlan_notice2 = If you want to Enable this function, the Multi SSID Switch must be Enable. Do you want to open Multi SSID Switch and Enable this function?

+ap_hide = AP Hide

+

+urlparent = The end of URL can''t follow with /.

+not_change_mode = The device is setting parameters, please wait...

+#device

+device_status = Device Status

+device_status_0 = Decrypted

+device_status_1 = Encrypted

+

+######DDNS###########

+ddns = DDNS

+Hash value is empty = Hash value is empty!

+DDNS Provider is empty = DDNS Provider is empty!

+register successful = Register successful

+login error = Login error

+network error = Network error

+registering = Registering

+not registered = Not registered

+error registering = Error registering

+error = error

+ddns_set_mode = DDNS

+mode_set_mode_1 = Enable

+mode_set_mode_0 = Disable

+mode_select_auto = Auto

+mode_select_manual = Manual

+ddns_mode = DDNS Mode

+Auto = Auto

+Manual = Manual

+DDNS_Status = DDNS Status

+DDNSHashValue = Hash Value

+ddns_ProviderList = Dynamic DNS Provider

+ddns_account = Account

+ddns_passwd = Password

+ddns_domainName = Domain Name

+ddns_hashvalue_check = Invalid character, The character must be 0-9, a-z, A-Z or =

+ddns_note1 = You can set the dynamic domain name service to assign a fixed domain name for the dynamic IP WAN address.

+ddns_note2 = Dynamic DNS Provider: Set the server which will provide dynamic domain name service.

+ddns_note3 = Password: The pass-phrase contains: 0-9 a-z A-Z ! # $ * + , - . % : = ? @ [ ] ^ _ { | } ~ 

+ddns_note4 = Domain Name: Set the domain name you want to apply for.

+ddns_note5 = Hash Value: DDNS hash value, you need to fill in the Hash value when select the freedns server. It contains: 0-9 a-z A-Z 或 = 

+

+#tr069

+tr069 = TR069

+cwmp_enaled = Enable TR069

+server_url = ACS URL

+server_username = ACS Username

+server_password = ACS Password

+enable_cycle_reporting = Enable Periodic Inform

+periodi_reporting_interval = Periodic inform interval

+cpe_username = Connection Request Username

+cpe_password = Connection Request Password

+stun_enable = STUN Enable

+url_span = URL type prefixed with [http|https]

+string_range_is = String length range is :

+stun_server_address = STUN Server Address

+stun_server_port = STUN Server Port

+stun_username = STUN Username

+stun_password = STUN Password

+stun_min_keepalive_period = Min KeepAlive Period

+stun_max_keepalive_period = Max KeepAlive Period

+stun_udp_notfication_limit = UDP Notification Limit

+stun_udp_connection_request_address = UDP Connection Request Address

+stun_nat_detected = NAT Detected

+stun_port_span = (0~65535)

+stun_time_span = Seconds[1~86400]

+stun_limit_span = Seconds[5~86400]

+periodic_interval_span = Seconds[20~86400]

+stun_interval_span = Seconds[10~86400]

diff --git a/lynq/S300/ap/app/zte_webui/i18n/Messages_zh-cn.properties b/lynq/S300/ap/app/zte_webui/i18n/Messages_zh-cn.properties
new file mode 100755
index 0000000..0c80881
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/i18n/Messages_zh-cn.properties
@@ -0,0 +1,1726 @@
+#menu 中文字符

+pc_version = PC版

+mobile_version = 手机版

+home = 首页

+phonebook = 电话本

+sms = 短信

+sd = SD卡

+setting = 设置

+status = 基本信息

+net_select = 找网方式

+dial_setting = 拨号设置

+apn_setting = APN设置

+wifi_advance = 高级设置

+management = 管理

+net_setting = 联网设置

+quick_setting = 快速设置

+

+device_info = 状态信息

+traffic_statistics = 流量统计

+traffic_alert = 流量管理

+

+wifi = Wi-Fi 设置

+wifi_basic = 基本设置

+device_setting = 设备设置

+sim = SIM卡侧

+device = 设备侧

+router_setting = 路由

+mac_filter = 无线MAC过滤

+

+wps = WPS

+sleep_mode = 省电

+lan = 局域网

+

+firewall = 防火墙

+system_security = 系统安全

+port_forward = 端口转发

+port_filter = 端口过滤

+fastboot = 快速开机

+display_password = 显示密码

+display_QR = 显示二维码

+cable = 有线

+wireless = 无线

+

+my_router = 网络设置

+net_surfing = 网络连接

+

+#validate

+phonenumbers_check = 最多可输入 5 个电话号码,并且用 ';' 将号码隔开

+required = 必填项

+remote = 请修正该字段

+url = 请输入有效的网址

+siteLink_check = 请输入有效的网址

+siteName_check = 请输入有效的网站名

+date = 请输入有效的日期

+dateISO = 请输入有效的日期 (ISO)

+number = 请输入有效的数字

+digits = 只能输入整数

+decimalRange = 请输入正数且小数位最多2位

+any_digits = 只能输入整数

+creditcard = 请输入有效的信用卡号

+equalTo = 请再次输入相同的值

+accept = 请输入拥有效后缀名的字符串

+maxlength = 最多输入 {0} 个字符

+minlength = 最少输入 {0} 个字符

+rangelength = 请输入一个长度介于 {0} 和 {1} 之间的字符串

+range = 请输入一个介于{0}和{1}之间的值

+max = 请输入一个最大为 {0} 的值

+min = 请输入一个最小为 {0} 的值

+ssid = 请输入有效的 SSID

+ssid_ap = 请输入有效的 SSID(无效字符包括 , ; " \)

+email_check = 请输入有效的邮箱

+ipv4 = 请输入有效的 IP 地址

+ipv6 = 请输入有效的 IPv6 地址

+name_check = 请输入有效的姓名

+phonenumber_check = 请输入有效的电话号码

+sms_service_center_check = 请输入有效的短信中心号码

+pin_check = 请输入 4 到 8 位的数字

+puk_check = 请输入 8 位数字

+password_check = 请输入有效的密码

+manage_info_check = 请输入有效的密码

+subnetmask_check = 无效的子网掩码

+dns_check = 无效的 DNS,DNS不能为255.255.255.255或0.0.0.0

+dhcp_check = DHCP 的 {0}IP 超出局域网子网范围

+start = 起始

+end = 结束

+dhcpCompare = 无效的 IP 地址,起始地址不能大于结束地址

+ipRange = IP 地址池不能包含局域网 IP 地址(DHCP 起始地址应该比局域网 IP 地址大)

+lanip_check = 请输入有效的 IP 地址

+ip_check = 请输入完整且有效的 IP 地址

+dmz_ip_check = 请输入有效的 IP 地址

+wps_pin_check = 无效的 PIN

+wps_pin_length_check = 请输入4位或8位数字

+browse_sdcard = 查看 SD 卡

+portCompare = 无效的端口范围

+comment_check = 无效字符

+check_file_path = 文件夹名称中包含无效的字符

+check_filefold_name = 文件夹名称中包含无效的字符: ` ~ # & * + | \ : ? / < > . " '

+apn_check = 请输入有效的 APN

+ppp_username_check = 请输入有效的用户名

+ppp_password_check = 请输入有效的密码

+unlock_code_check =  请输入正确的解锁码。解锁码只能输入 0-9、a-f、A-F,并且长度为 16 个字符

+apn_profile_name_check = APN 配置文件名称中包含无效的字符

+dlna_name_check = 设备名称只能输入 0-9、a-z、A-Z 或 _

+wifi_password_check = 请输入有效的密码

+wifi_wep_password_check = 请输入 5 或 13 位ASCII密钥,或者输入 10 或 26 位 Hex 密钥。

+range_except = 请输入有效值,有效范围:{0}-{1}。(32000-32007 的范围值除外)。

+

+#common

+copyright = Copyright &copy; 2010-2022 示例公司 版权所有

+enable=启用

+disable=关闭

+apply= 应用

+cancel = 取消

+clear = 清除

+reset = 重置

+add = 添加

+add_new = 新增

+save = 保存

+new = 新建

+view = 查看

+select = 选择

+edit = 编辑

+delete = 删除

+delete_all = 删除所有

+success_info = 成功

+error_info = 失败

+connect = 连接

+disconnect = 断开连接

+connected = 已连接

+disconnected = 已断开连接

+connecting = 正在连接…

+disconnecting = 正在断开连接…

+cancelconnect = 取消连接

+confirm = 确认

+prompt = 提示

+info = 信息

+alert = 提醒

+yes = 是

+no = 否

+ok = 确定

+back = 返回

+exit = 退出

+next_step = 下一步

+prev_step = 上一步

+next_page = &gt;&gt;

+prev_page = &lt;&lt;

+root = 根目录

+create = 创建

+speed = 速率

+upload = 上传

+download = 下载

+uploaded = 已上传

+downloaded = 已下载

+on = 打开

+off = 关闭

+need_login_again = 您的帐户已退出,请重新登录。

+modify = 更改

+content = 内容

+time = 时间

+processing = 处理中…

+saving = 保存中…

+deleting = 删除中…

+scanning = 状态:扫描中…

+dlna_scanning = 状态:扫描中…

+scanned = 状态:扫描结束。

+need_rescan = 状态: 需要重新扫描。

+sending = 发送中…

+creating = 创建中…

+uploading = 上传中…

+waiting = 请稍等…

+leave_page_info = 您有未保存的修改。您确定要继续吗?

+colon = :

+page = 页码:

+go = 跳转

+ALL = 全部

+open_source_licenses = 开放源代码许可

+vertical_bar = |

+

+#security

+security_policy = 安全策略

+security_mode = 安全模式

+security_mode_OPEN = OPEN

+security_mode_SHARED = SHARED

+security_mode_WPA2PSK = WPA2(AES)-PSK

+security_mode_WPAPSKWPA2PSK = WPA-PSK/WPA2-PSK

+security_mode_WPA3Personal = WPA3-Personal

+security_mode_WPA2WPA3 = WPA2(AES)/WPA3-Personal

+wpa = WPA

+pass_phrase = 密码

+

+#Station

+station_info = 接入设备

+station_number = 序号

+host_name = 主机名

+

+#Wifi Basic

+multi_ssid_enable = 多重网络名称开关

+multi_ssid_1 = 主SSID

+multi_ssid_2 = 副SSID

+multi_ssid_enable_confirm = 如果开启“多重网络名称”,Internet Wi-Fi 功能将会停用。您要继续吗?

+multi_ssid_enable_confirm2 = 如果开启“多重网络名称”,Internet Wi-Fi 功能将会停用。且已连接的 Wi-Fi 设备可能需要重连。您要继续吗?

+multi_ssid_max_access_number_alert = 主SSID 和 副SSID 的最大接入数之和不能超过 {0}!

+network_band_selection = 频段选择

+network_mode = 网络模式

+network_name = 网络名称(SSID)

+broadcast_network_name = SSID 广播

+country_region_code = 国家/地区 码

+frequency_channel = 信道

+rate = 速率

+max_station_number = 最大接入数

+wifi_basic_note = 点击“应用”时,任意已连接的 Wi-Fi 设备需要重新连接。

+wifi_disconnect_confirm = 所有已连接的 Wi-Fi 设备需要重连。您要继续吗?

+wifi_disconnect_confirm2 = 已连接的 Wi-Fi 设备可能需要重连。您要继续吗?

+network_mode_2 = 仅 802.11 n

+network_mode_4 = 802.11 b/g/n

+network_mode_5 = 仅 802.11 a

+network_mode_6 = 802.11 b/g/n/ax

+frequency_channel_0 = 自动

+frequency_channel_1 = (频道 1)

+frequency_channel_2 = (频道 2)

+frequency_channel_3 = (频道 3)

+frequency_channel_4 = (频道 4)

+frequency_channel_5 = (频道 5)

+frequency_channel_6 = (频道 6)

+frequency_channel_7 = (频道 7)

+frequency_channel_8 = (频道 8)

+frequency_channel_9 = (频道 9)

+frequency_channel_10 = (频道 10)

+frequency_channel_11 = (频道 11)

+frequency_channel_12 = (频道 12)

+frequency_channel_13 = (频道 13)

+frequency_channel_14 = (频道 14)

+frequency_channel_15 = (频道 15)

+frequency_channel_16 = (频道 16)

+frequency_channel_17 = (频道 17)

+frequency_channel_18 = (频道 18)

+frequency_channel_19 = (频道 19)

+frequency_channel_20 = (频道 20)

+frequency_channel_21 = (频道 21)

+frequency_channel_22 = (频道 22)

+frequency_channel_23 = (频道 23)

+frequency_channel_24 = (频道 24)

+frequency_channel_25 = (频道 25)

+frequency_channel_26 = (频道 26)

+frequency_channel_36 = (频道 36)

+frequency_channel_40 = (频道 40)

+frequency_channel_44 = (频道 44)

+frequency_channel_48 = (频道 48)

+frequency_channel_149 = (频道 149)

+frequency_channel_153 = (频道 153)

+frequency_channel_157 = (频道 157)

+frequency_channel_161 = (频道 161)

+frequency_channel_165 = (频道 165)

+rate_0 = 自动

+rate_1 = 1 Mbps

+rate_2 = 2 Mbps

+rate_3 = 5.5 Mbps

+rate_4 = 6 Mbps

+rate_5 = 6.5 Mbps

+rate_6 = 9 Mbps

+rate_7 = 11 Mbps

+rate_8 = 12 Mbps

+rate_9 = 13 Mbps

+rate_10 = 18 Mbps

+rate_11 = 19.5 Mbps

+rate_12 = 24 Mbps

+rate_13 = 26 Mbps

+rate_14 = 36 Mbps

+rate_15 = 39 Mbps

+rate_16 = 48 Mbps

+rate_17 = 52 Mbps

+rate_18 = 54 Mbps

+rate_19 = 58.5 Mbps

+rate_20 = 65 Mbps

+cannot_operate_when_wifi_connected = Wi-Fi 连接时无法进行该操作!

+network_mode_select_2 = 仅 802.11 n

+network_mode_select_3 = 802.11 b/g

+network_mode_select_4 = 802.11 b/g/n

+network_mode_select_6 = 802.11 b/g/n/ax

+network_modes_band_select_2 = 仅802.11 n

+network_modes_band_select_4 = 802.11 a/n

+network_modes_band_select_5 = 仅 802.11 a

+

+#net select

+auto_select = 自动

+manual_select = 手动

+auto_select_type_WCDMA_preferred = 自动

+auto_select_type_LTE_preferred = 自动

+auto_select_type_NETWORK_auto = 自动

+auto_select_type_Only_LTE = 仅4G

+auto_select_type_WCDMA_AND_LTE = 仅4G/3G

+auto_select_type_Only_WCDMA = 仅3G

+auto_select_type_TD_W = 仅3G

+auto_select_type_Only_GSM = 仅2G

+

+search = 搜索

+searching_net = 搜索中,请稍候...

+registering_net = 注册中,请稍候...

+network_list = 网络列表

+register = 注册

+auto = 自动

+unknown = 未知

+available = 可用

+current = 当前

+forbidden = 禁止

+net_select_note_automatic = 自动:该设备将会自动搜索可用网络。

+net_select_note_manual = 手动:将会手动搜索可用网络。

+net_status = 网络状态

+mccmnc = MCCMNC

+option = 选项

+networktype = 网络类型

+subnet = 制式

+

+#home

+ap_station_clear = 清空

+current_flux = 当前流量

+total_flux = 已用总流量

+connected_time = 持续时间

+flux_up = 上传速率

+flux_down = 下载速率

+traffic_current_connection = 当前连接

+traffic_current_month_data = 当月

+traffic_total_traffic = 已用总流量

+traffic_used_data_month = 本月流量使用情况:

+traffic_used_time_month = 本月上网时间:

+traffic_data_approximated = 流量仅供参考,建议向运营商查询以获得准确流量。

+traffic_used_month = 已用:

+traffic_left_month = 剩余:

+traffic_exceeded_month = 超出:

+traffic_total_month = 限额:

+traffic_apply_volume_limit = 流量管理

+traffic_data_limit_type = 套餐形式

+traffic_data = 流量

+traffic_time = 时间

+traffic_limit_data_month = 每月

+traffic_alert_when_data_reach = 提醒设置

+traffic_limit_time_month = 当月配额

+traffic_alert_when_time_reach = 提醒设置

+traffic_million_byte = MB

+traffic_percent = %

+traffic_limit_disconnect_msg = 您的流量/时间已经达到 {0}%,要断开网络连接吗?

+traffic_limit_connect_msg = 您的流量/时间已经达到 {0}%,要继续连接网络吗?

+traffic_limit_msg = 您的流量/时间已经达到 {0}%。

+traffic_beyond_disconnect_msg = 您的流量/时间已超出配额,要断开网络连接吗?

+traffic_beyond_connect_msg = 您的流量/时间已超出配额,要继续连接网络吗?

+traffic_beyond_msg = 您的流量/时间已超出配额。

+traffic_calibrate_note = 支持手动校准流量功能。如果页面流量统计与实际有偏差,您可以修改实际已用流量。

+traffic_note = 当已用流量/时间达到设置的百分比时提醒我。

+traffic_over_note = 当流量套餐单位为MB时,已使用流量的统计范围需小于4096TB。

+traffic_clear_confirm = 您确定要清除吗?

+traffic_not_support = 当前模式不支持此功能。

+

+#APN

+apn_currentApn = 当前 APN

+apn_mode = 模式

+apn_auto_apn = 自动

+apn_manual_apn = 手动

+apn_profile = 配置文件

+apn_profile_name = 配置文件名称

+apn = APN

+apn_ipv4_apn = IPv4 APN

+apn_ipv6_apn = IPv6 APN

+apn_dns_mode = DNS 模式

+apn_dns_mode_ipv4 = IPv4 DNS 模式

+apn_dns_mode_ipv6 = IPv6 DNS 模式

+apn_auto_dns = 自动

+apn_manual_dns = 手动

+apn_dns1 = DNS 1

+apn_dns2 = DNS 2

+apn_dns1_ipv4 = IPv4 DNS 1

+apn_dns2_ipv4 = IPv4 DNS 2

+apn_dns1_ipv6 = IPv6 DNS 1

+apn_dns2_ipv6 = IPv6 DNS 2

+apn_authentication = 鉴权方式

+apn_authentication_ipv4 = IPv4 鉴权方式

+apn_authentication_ipv6 = IPv6 鉴权方式

+apn_user_name = 用户名

+apn_user_name_ipv4 = IPv4 用户名

+apn_user_name_ipv6 = IPv6 用户名

+apn_password = 密码

+apn_password_ipv4 = IPv4 密码

+apn_password_ipv6 = IPv6 密码

+apn_pdp_type = PDP 类型

+set_default = 设为默认

+apn_save_profile_exist = 配置文件名称已存在,请选择其他名称。

+apn_delete_cant_delete_default = 无法删除默认配置文件。

+apn_delete_confirm = 确定删除?

+apn_cant_modify_status = 网络为 {0} 时无法更改当前的 APN 设置! 

+apn_cant_modify_current = 无法更改正在使用的 APN!

+apn_cant_delete_current = 无法删除正在使用的配置文件!

+apn_profile_full = 最多只能添加 {0} 项设置!

+dial_num = 拨号号码

+apn_no_select_alert = 请选择有效的配置文件!

+

+#Status bar

+network_status = 网络状态

+connection_status = 无线宽带连接状态

+rj45_connection_status = 有线宽带连接状态

+battery = 电量

+charging = 充电中

+sim_status = SIM卡状态

+sim_status_modem_waitpin = 无效的 SIM卡

+sim_status_modem_waitpuk = 无效的 SIM卡

+sim_status_modem_sim_undetected = 无效的 SIM卡

+sim_status_modem_undetected = 无效的 SIM卡

+sim_status_modem_imsi_waitnck = 无效的 SIM卡

+sim_status_modem_sim_destroy = 无效的 SIM卡

+sim_status_modem_destroy = 无效的 SIM卡

+sim_status_modem_init_complete = 有效的 SIM卡

+sim_status_modem_ready = SIM卡就绪

+wifi_status = Wi-Fi 状态

+wifi_status_on = Wi-Fi 开

+wifi_status_off = Wi-Fi 关

+wifi_status1 = 用户数:1

+wifi_status2 = 用户数:2

+wifi_status3 = 用户数:3

+wifi_status4 = 用户数:4

+wifi_status5 = 用户数:5

+wifi_status6 = 用户数:6

+wifi_status7 = 用户数:7

+wifi_status8 = 用户数:8

+wifi_status9 = 用户数:9

+wifi_status10 = 用户数:10

+enable_pin = 启用 PIN

+remaining_time = 剩余时间

+signal = 信号

+network_type = 网络类型

+network_type_limited_service = 服务受限

+network_type_no_service = 无服务

+network_provider = 运营商

+roaming_status = 漫游状态

+sim_status_ready = SIM卡就绪

+sim_status_waitpin = 等待输入 PIN

+sim_status_waitpuk = 等待输入 PUK

+sim_status_undetected = 未检测到 SIM卡

+sim_status_waitnck = 等待输入 NCK

+sim_status_destroy = SIM卡已损毁

+signal_strength = 信号强度

+signal_strength_label = 信号强度

+battery_level = 电量

+

+#dial_setting

+dial_note = WAN 连接状态

+dial_mode = 连接模式

+dial_mode_cpe = 拨号方式

+dial_roam_info = 您尚未开启漫游设置。要开启漫游功能,请到设置页面中勾选复选框。

+dial_setting_note_automatic = 自动:开机后,设备会自动连接到网络。

+dial_setting_note_manual = 手动:开机后,设备需要手动连接到网络。

+dial_roaming_remind = 勾选此项,您可以在漫游状态下连接到网络,且可能会产生额外费用。

+dial_roaming_connect = 设备处于漫游状态,连接网络会使您的资费增加。确定继续?

+

+#phonebook

+search = 搜索

+save_location = 存储位置

+save_location_0 = SIM卡

+save_location_1 = 设备

+group_all = 全部

+group_null = -

+group_common = 普通

+group_family = 家人

+group_friend =  朋友

+group_colleague = 同事

+name = 姓名

+mobile_phone_number = 移动电话

+home_phone_number = 住宅电话

+office_phone_number = 单位电话

+mail = 邮箱

+group = 群组

+no_data_selected = 请选择一项!

+confirm_data_delete = 确定删除?

+confirm_pb_delete = 确定要删除所选联系人吗?

+too_many_data_selected = 选择电话号码过多,请选择一个电话号码!

+delete_fail_try_again = 删除失败,请重试。

+max_send_number = 最多输入 5 个电话号码!

+send = 发送

+send_sms = 发送短信

+new_message = 新短信

+send_numbers = 电话号码

+contents = 短信内容

+device_full = 设备的电话本存储空间已满!

+sim_full = SIM卡已满!

+phonebook_init_fail = 电话本初始化失败!<br/>请检查SIM卡并重启设备。

+sim_removed = SIM卡已被移除!

+change_device_to_sim_confirm = 可能会丢掉信息,是否需要继续转存?

+

+#SMS

+smslist = 设备侧短信

+sms_setting = 短信设置

+sim_messages = SIM侧短信

+refresh = 刷新

+forward = 转发

+draft = 草稿

+send_fail_try_again = 发送失败。

+sms_content_required = 请输入短信息内容。

+sms_contact_required = 请选择联系人。

+select_some_options = 最多可选择5位联系人

+select_an_option = 请选择一个选项

+chat_input_placehoder = 请在此输入信息

+sms_chat_input_confirm = 请按回车键或者用分号完成输入

+sms_capacity_will_full = 短信容量将满,请删除部分短信

+sms_capacity_is_full = 短信容量满,请删除部分短信

+sms_capacity_is_full_for_send = 短信容量满,请删掉部分短信以正常收发新信息。

+sms_capacity_will_full_just = 容量将满,您最多只能发送 {0} 条。

+sms_init_fail = 短信初始化失败!<br/>请检查SIM卡并重启设备。

+sms_resending = 正在重发短信...

+sms_resend_fail = 短信重发失败。

+sms_stop_sending = 停止发送

+sms_unread_count = 未读短信

+sms_delivery_report_1 = 短信已送达对方。

+sms_delivery_report_2 = 短信未送达对方。

+sms_delivery_report_3 = 正在发送短信...

+sms_report = 发送报告

+sms_cancel_sending = 取消中…

+sms_save_draft_success = 短信已存为草稿

+sms_save_draft_failed = 草稿保存失败

+sms_to_save_draft = 短信已修改,要存为草稿吗?

+sms_no_recipient = 您尚未选择收件人,该短信将被舍弃。

+phone_number_invalid = 电话号码无效

+sms_to = 接收人:

+confirm_sms_delete = 确定要删除所选信息吗?

+sms_save_tip = 保存草稿中...

+

+#login

+password = 密码

+puk = PUK

+login = 登录

+logout = 退出

+new_pin = 新 PIN

+confirm_pin = 确认新 PIN

+puk_locked = 您的 SIM卡已彻底锁定。请联系您的运营商。

+password_error = 密码不正确!

+password_error_left = 密码不正确!<br/>您的剩余尝试次数:{0}。

+password_error_account_lock = 你的账户被锁定。<br/>剩余时间:

+password_error_five_times = 您已经输错5次。请5分钟后再试。

+password_error_account_lock_time = 您的账户已被锁定。<br/>请稍后再试。

+enter_pin = SIM卡已锁,请输入 PIN码以解锁。

+enter_puk = SIM卡 PIN码已锁,请输入 PUK码以解锁。

+last_enter_pin = 最后尝试机会。如果再次错误,您的 SIM卡将被锁定!

+last_enter_puk = 最后尝试机会。如果再次错误,您的 SIM卡将会损毁!

+attempts_left = 剩余次数:

+pin_error = PIN码不正确!

+puk_error = PUK码不正确!

+confirm_logout = 您要注销吗?

+

+#advanced password

+password_management = 登录密码

+current_password = 当前密码

+new_password = 新密码

+confirm_password = 确认新密码

+current_password_error = 当前密码错误!

+password_note_info = 您可以在该网页更改登录密码。

+password_note_valid = 密码不能为空,且最多包含 32 个字符。

+password_note_input = 密码的有效字符包含:0-9 a-z A-Z ! # $ * + , - . % : = ? @ [ ] ^ _ { | } ~

+password_note_first_change = 请修改您的初始登陆密码!

+password_note_too_low = 您的密码复杂度太低(密码中可以包含大小写字母、数字、特殊字符,且不小于8位)。您要继续吗?

+

+#advanced pin

+pin = PIN

+current_pin = 当前 PIN

+pin_management = PIN码管理

+pin_status = PIN码状态

+modify_pin = 更改 PIN

+cannot_operate_when_connected = 网络连接时无法进行该操作!

+cannot_change_pin_when_connected = 网络连接时无法更改 PIN!

+pin_note_info = “PIN码管理”提供PIN保密设置功能,防止对SIM/USIM/UIM卡的非授权使用。如果要改变当前设置,请先断开网络。

+pin_note_operator = 启用PIN码后,下次启动设备时,需要输入PIN码;关闭PIN码后,下次启动设备时,不需要输入PIN码。

+pin_note_modify = 启用PIN码后,可修改PIN码。

+

+#lan

+lan_setting = 局域网接口设置

+ip_address = IP 地址

+subnet_mask = 子网掩码

+mac_address = MAC地址

+dhcp_server = DHCP服务

+dhcp_ip_pool = DHCP IP池

+dhcp_lease = DHCP租期

+hours = 小时

+minutes = 分钟

+lan_note = 新的设置会在设备重启后生效。

+lan_note_ip_address = IP 地址:路由器局域网的IP地址,使用该IP地址可以通过浏览器管理设备。

+lan_note_subnet_mask = 子网掩码:对应 IP 地址的子网掩码。

+lan_note_dhcp_server_enable = DHCP服务启用:如果开启DHCP(Dynamic Host Configuration Protocol,动态主机配置协议)服务,设备将会为所连接的客户端自动分配IP地址。

+lan_note_dhcp_server_disable = DHCP服务关闭:如果关闭DHCP服务,设备将不会为连接的客户端自动分配IP地址,客户端必须手动输入IP地址。

+lan_note_dhcp_ip_pool = DHCP IP 池:起始IP地址和终止IP地址指定了DHCP服务器分配给接入设备的IP地址范围。这个范围之外的地址不能由DHCP服务器分配。

+lan_note_dhcp_lease_time = DHCP 租期时间:租期时间表示计算机获取IP地址后可以使用这个IP地址的期限,到达租期时间后,如果客户端需要继续使用这个地址,必须在到期前重新发起请求。只有当原来的客户端租期到期并且不再发起续租请求时,这个地址才能分配给其他客户端使用。

+lan_confirm_reopen = 您的设置将在设备重启后生效。您要继续吗?<br/><br/><i>注意:选择是,表示提交请求并重启设备。如果选择否,表示您放弃当前的选择。</i>

+lan_tip_staticip_notsame = 路由器局域网的IP地址不能与静态IP地址在同一个网段内!

+

+#sms_setting

+sms_validity = 有效期

+sms_validity_twelve_hours = 12 小时

+sms_validity_one_day = 1 天

+sms_validity_one_week = 1 周

+sms_validity_largest = 最长

+center_number = 中心号码

+delivery_report = 发送报告

+list = 列表

+

+#restore

+restore = 恢复出厂

+restore_title = 恢复出厂设置

+restore_button = 恢复出厂设置

+restore_confirm = 所有参数将恢复为出厂设置,设备会重启。确定继续?

+restore_when_connected = 请先断开 WAN 网络!

+restoring = 出厂设置恢复中

+restore_note_info = 点击“恢复出厂”以将所有设置还原为默认值,并且设备会自动重启。

+

+#wps

+wps_note_all = WPS(Wi-Fi Protected Setup)代表Wi-Fi保护设置,是一个简单且安全地建立无线网络的标准,您可以通过这一过程轻松地将无线客户端连接到设备,而无需进行任何具体的配置,例如SSID、安全模式和密码。

+wps_note_pin = PIN:您需要输入客户端的PIN码。

+wps_note_pbc = PBC:您可以在该网页选择PBC(Push Button Configuration)或者长按(3-4秒)设备上的WPS按键启用WPS功能。

+wps_note_wait = 该设备在 2 分钟内会等候接收无线接入客户端的访问请求。

+wps_pin = PIN

+wps_pbc = PBC

+wps_wifi_off = Wi-Fi 关闭时无法进行操作!

+wps_auth_open = 当前的加密类型不支持WPS。

+wps_on_info = WPS 已经启用,请稍后再试!

+wps_ssid_broadcast_disable = SSID 广播关闭时无法进行该操作!

+

+#sleep mode

+wifi_sleep = Wi-Fi 休眠设置

+sleep_time = 休眠时间

+sleep_mode_-1 = 从不休眠

+sleep_mode_5 = 5分钟

+sleep_mode_10 = 10分钟

+sleep_mode_20 = 20分钟

+sleep_mode_30 = 30分钟

+sleep_mode_60 = 1小时

+sleep_mode_120 = 2小时

+wifi_sleep_note_info = 休眠时间:当在指定的时间内无 Wi-Fi 连接时,Wi-Fi 功能将会停用,系统会转入休眠模式以节省电量。

+wifi_sleep_confirm = 当前设置改变时将会重启wifi,是否继续?

+

+#system security

+remote_management = 远程管理(通过 WAN 口)

+ping_from_wan = 从外网 PING 入

+

+#portforward

+protocol_TCP&UDP = TCP+UDP

+protocol_TCP = TCP

+protocol_UDP = UDP

+virtual_server_setting = 虚拟服务器设置

+port_forward_setting = 端口转发设置

+port_forward_list = 系统当前虚拟服务器

+port_forward_note_info = 配置端口转发以启用外部计算机,访问局域网提供的网络、FTP 或其他服务。

+port_forward_note_port = 端口范围:设置要转发的源端口数量。

+port_forward_note_ip_address = IP 地址:设置要转发的源 IP 地址。

+port_forward_note_protocol = 协议:设置用于转发的协议。

+port_forward_note_comment = 注释:输入用于转发设置的注释。有效字符包含:0-9 a-z A-Z ! # ( ) + - . / % = ? @ ^ _ { | } ~ 。

+port_range = 端口范围

+protocol = 协议

+comment = 注释

+ipExam = (例如:192.168.0.101)

+rules_max = 规则数量已达最大值{0}。

+rule_exist = 规则已经存在。

+rule_max_note = 规则的最大数量为 10。

+rule_max_note_v4v6 = IPv4 或 IPv6 规则的最大数量为 10。

+

+rules_max_v4v6 =  {0}规则数量已达最大值{1}。

+rule_exist_v4v6 = {0}规则已经存在。

+

+#quick setting

+step_number_1 = 1

+step_number_2 = 2

+step_number_3 = 3

+step_number_4 = 4

+step_number_5 = 5

+step_number_6 = 6

+step_name_1  = 1.快速设置

+step_name_2  = 2.APN 设置

+step_name_3  = 3.PPP 鉴权

+step_name_4  = 4.SSID 配置

+step_name_5  = 5.安全配置

+step_name_6  = 配置如下

+step1_exp1 = 该向导帮助您安全设置网关基本参数:点击“上一步”和“下一步”进行导航;点击“应用”以保存设置。您也可以在其他菜单中设置高级参数。

+step1_exp2 = 在该向导中设置基本参数。您也可以在其他菜单中设置高级参数。

+apn_settings = APN 设置

+step2_auto_apn_explain = 如果您选择了“自动 APN”,将跳过第二步设置(PPP 鉴权)。

+step2_profile_name_explain = 配置文件名称:您当前使用的默认配置文件。

+ppp_authentication = PPP 鉴权

+step3_authentication_apn_explain1 = 鉴权方式:由您的互联网服务提供商 (ISP) 来提供。密码验证协议 (PAP) 不用加密就可以通过两次握手建立对端的身份。询问握手认证协议(CHAP)通过三次握手周期性的校验对端的身份。

+step3_authentication_apn_explain2 = 用户名:用于建立连接时,从互联网服务提供商获取验证。

+step3_authentication_apn_explain3 = 密码:用于建立连接时,从互联网服务提供商获取验证。

+step3_username_password_explain = 点击“设为默认”以将该配置文件设置为默认配置文件。

+ssid_title = SSID

+ssid_name = 网络名称 (SSID)

+ssid_broadcast = SSID 广播

+step4_ssid_explain = 网络名称:服务集标识符 (SSID)。输入无线局域网 (WLAN) 名称,最多 32 个字符。

+step4_ssid_broadcast_explain1 = SSID 广播:停用或启用(默认为启用)该功能。一旦启用该功能,路由器将会广播 SSID,其他设备将会发现该设备并进行连接。

+step4_ssid_broadcast_explain2 = 禁用:网关停止广播 SSID,在网络中隐藏您的网络名称。

+step5_encryption_mode_info = 安全模式:

+step5_encryption_mode_explain1 = OPEN:不进行验证以及加密。这可能会导致个人信息被拦截,或者网络被他人滥用,因此不推荐使用此方式。

+step5_encryption_mode_explain2 = WPA2(AES)-PSK:WPA2(AES)-PSK 是 Wi-Fi 网络安全存取 (WPA) 的安全保护版本,该版本施行了802.11i 无线安全标准。

+step5_encryption_mode_explain3 = WPA-PSK/WPA2-PSK:WPA 预共享密钥 (WPA-PSK)。以纯文本 (ASCII) 密码的方式输入预共享密钥。WPA2-PSK 是 Wi-Fi 网络安全存取 (WPA) 的安全保护版本,该版本施行了802.11i 无线安全标准。

+step5_encryption_mode_explain4 = 密码:密码的有效字符包含:0-9 a-z A-Z ! # ( ) + - . / % = ? @ ^ _  { | } ~

+step6_apply_explain = 一旦设置完成时,您需要重新连接无线网络。

+quick_setting_wifi_disable_confirm = 1、Wi-Fi 已关闭,与 Wi-Fi 相关的设置不会生效。<br\>要继续吗?

+quick_setting_param_changed_confirm = 1、Wi-Fi 配置更改后已连接的 Wi-Fi 设备可能需要重连。<br\>要继续吗?

+#SD Card

+sdcard = SD卡

+httpshare = HTTP 共享

+sd_card_mode = 模式

+sd_card_share_setting = 共享设置

+sd_card_share_usb_mode = USB

+sd_card_share_http_share_mode = HTTP 共享

+http_title = HTTP 共享设置

+sd_card_status = 状态

+sd_card_file_to_share = 共享文件

+sd_card_access_type = 访问类型

+sd_card_path_to_share = 路径共享

+sd_card_entire_sd_card = 整个SD卡

+sd_card_custom_setting = 自定义

+sd_card_read_write = 读/写

+sd_card_readonly = 只读

+sd_card_share_setting_no_sdcard = 无 SD卡!

+sd_card_share_setting_exist = 该文件或文件夹已经存在!

+sd_card_share_setting_noexist = 该文件或文件夹不存在!

+sd_card_status_info_0 = 无 SD卡!

+sd_card_status_info_1 = SD卡存在,现在可以使用了

+sd_card_status_info_2 = SD卡存在,但目前处于无效状态,请 5 秒后重试。如果无法使用,请检查 SD卡!

+sd_card_status_info_2_reason = 可能的原因如下

+sd_card_status_info_2_reason_1 = SD卡格式是NTFS,请切换至USB方式使用。

+sd_card_status_info_2_reason_2 = SD卡内容正在加载中,请5分钟后再试;如果仍然无效,请检查SD卡。

+sd_card_invalid_chars_cant_download = 文件名称中包含无效的字符,无法下载!(无效字符包括 < > " '' & + / \\ : * | # ? ~ `)。

+note_not_support_fs_ntfs = 在 HTTP 共享模式下,设备仅支持 FAT/FAT32 文件系统!

+note_web_share_mode = HTTP 分享模式:通过网络浏览器分享 SD 卡。此模式将会停用通过 USB 端口访问 SD 卡的可移动驱动器映射功能。

+note_usb_access = 仅通过 USB 访问:在可移动的驱动器映射模式下,用户仅能通过 USB 数据线来访问 SD 卡。共享的 SD 卡的网页将会停用。

+note_http_share_usb_access = 仅通过 USB 访问:在可移动的驱动器映射模式下,用户仅能通过 USB 数据线来访问 SD 卡。共享的 SD 卡的网页将会停用。

+note_http_share_cannot_access = 无法访问此页面!

+note_path_to_share_example = 路径共享:您可以输入共享路径,例如:/Picture。当仅输入斜线号“/”时,表示共享整个SD卡。

+note_upload_not_refresh = 当下载或者上传文件时,请不要刷新该网页!

+note_upload_single_file_2g = 单个文件上传最大支持2G。

+note_upload_filelenth_25 = 文件名、文件夹名称修改支持最长25个字符。

+note_uploading_not_refresh = 文件上传中,请不要刷新该页面!

+note_invalid_file_path = 路径共享不能为单独的小数点,也不能包含以下字符: < > " '' & + / \\ : * | # ? ~ `

+browse_btn = 浏览

+change_btn = 更改

+no_file_selected = 未选择文件

+sd_no_file_selected = 请选择一个文件

+sd_name = 名称

+sd_path = 路径:

+sd_rename = 重命名

+sd_download = 下载

+sd_file_size = 文件大小

+sd_update_time = 更新时间

+no_sdcard = 无 SD卡!

+no_exist = 文件不存在!

+sd_card_folder_name_is_null = 请输入名称

+get_file_list_failure = 获取文件列表失败

+create_folder_failure = 创建文件夹失败

+delete_folder_failure = 删除文件或文件夹失败

+sd_card_path_too_long = 文件路径过长。

+sd_file_size_too_big = 文件过大。单个文件上传最大支持2G。

+sd_file_name_invalid = 本设备不支持含有*号的文件名,请更新文件名。

+back_to_login = 返回登录

+sd_config_changed_reload = SD卡共享设置已改变,页面将重新加载。

+sd_upload_space_not_enough = SD卡空间不足!

+sd_upload_data_lost = 文件上传出现异常,请重试。

+sd_upload_file_is_downloading = 文件正在下载中,请稍候!

+sd_share_path_is_invalid = 共享路径无效,请重新设置

+sd_share_path_cant_rename = 文件夹已共享,无法重命名。

+sd_share_path_cant_delete = 文件夹“{0}”已共享,无法删除。

+sd_share_path_invalid = 共享路径失效。

+sd_file_processing_cant_delete = 文件正在被使用,无法删除。

+sd_file_processing_cant_rename = 文件正在被使用,无法重命名。

+sd_not_support = SD卡格式不支持或其它原因,请重新插入或更换SD卡。

+sd_usb_forbidden = SD卡正在被使用,无法切换。

+sd_upload_rename = 该文件已经存在!如需继续上传请修改文件名并选择“是”。选择“否”将取消上传。

+sd_upload_rename_null = 文件名不能为空或超过25个字符!

+

+#port filter

+filter_basic_setting = 基本设置

+port_filter_enabled = MAC/IP/端口过滤

+default_policy = 默认策略

+default_policy_note = 您可以设置防火墙策略以保护网络免受病毒、蠕虫和恶意网络行为的攻击。

+default_policy_note_filter = 过滤策略仅在启用过滤功能时可用。

+accepted = 放行

+dropped = 丢弃

+port_filter_setting = MAC/IP/端口过滤设置

+mac_address = MAC 地址

+macExam = (例如:00:1E:90:FF:FF:FF)

+dest_ip_address = 目的 IP 地址

+source_ip_address = 源 IP 地址

+port_filter_action = 操作

+filter_accept = 放行

+filter_drop = 丢弃

+protocol_None = 全部

+protocol_ICMP = ICMP

+port_filter_list = 系统当前 MAC/IP/端口过滤规则

+dest_port_range = 目的端口范围

+source_port_range = 源端口范围

+filter_accept_note = 其它数据包会被放行。

+filter_drop_note = 其它数据包会被丢弃。

+filter_optional = 请输入IP,MAC 或者端口值

+mac_check = 无效的 MAC 地址

+filter_ip_setting = IP设置

+filter_ipv4 = IPv4

+filter_ipv6 = IPv6

+ip_type = IP 类型

+source_ipv6_address = 源 IPv6 地址

+dest_ipv6_address = 目的 IPv6 地址

+port_filter_note_mac_address = MAC 地址:设置要过滤的 MAC 地址。

+port_filter_note_source_ip_address = 源 IP 地址:设置要过滤的源 IP 地址。

+port_filter_note_dest_ip_address = 目的 IP 地址:设置要过滤的目的 IP 地址。

+port_filter_note_protocol = 协议:设置用于过滤的协议。

+port_filter_note_source_port_range = 源端口范围:设置要过滤的源端口数量。

+port_filter_note_dest_port_range = 目的端口范围:设置要过滤的目的端口数量。

+port_filter_note_action = 操作:如果信息包与规则相符,可设置处理信息包。

+port_filter_note_comment = 注释:输入用于过滤设置的注释。有效字符包含:0-9 a-z A-Z ! # ( ) + - . / % = ? @ ^ _ { | } ~ 。

+port_filter_note_info = 过滤策略同规则是一一对应的。如果与此条款相抵触,将不会继续同下列规则匹配。

+confirm_data_effect = 您的设置可能不会立即生效,如果需要全部生效,建议重启设备,是否继续?

+

+#wifi_range

+wifi_range_settings = Wi-Fi 性能设置

+wifi_range = Wi-Fi 覆盖范围

+wifi_short_mode = 近距离 Wi-Fi 范围 - 最佳电池续航

+wifi_medium_mode = 中距离 Wi-Fi 范围

+wifi_long_mode = 远距离 Wi-Fi 范围

+wifi_des_short_mode = 近距离 Wi-Fi 范围

+wifi_des_medium_mode = 中距离 Wi-Fi 范围

+wifi_des_long_mode = 远距离 Wi-Fi 范围

+wifi_range_note_range = Wi-Fi 范围:

+wifi_range_note_short =  近距离 Wi-Fi 范围:覆盖范围和发射功耗小,是最佳电池续航方案。

+wifi_range_note_medium = 中距离 Wi-Fi 范围:覆盖范围和发射功耗是设备支持能力的一半,正常耗电。

+wifi_range_note_long = 远距离 Wi-Fi 范围:设备最大发射功耗和覆盖范围,如果一直有终端接入,耗电会增加,减少电池续航。

+wifi_range_note_short_cpe =  近距离 Wi-Fi 范围:覆盖范围和发射功耗最小。

+wifi_range_note_medium_cpe = 中距离 Wi-Fi 范围:覆盖范围和发射功耗是设备支持能力的一半。

+wifi_range_note_long_cpe = 远距离 Wi-Fi 范围:设备最大发射功耗和覆盖范围。

+

+#upnp

+upnp = UPnP

+upnp_setting = UPnP 设置

+upnp_note_info = 通用即插即用 (UPnP) 是网络协议集。它允许电脑、打印机、互联网网关、Wi-Fi 接入点和移动设备之间在网络上更方便地进行互相搜索,并为数据共享、通信和娱乐建立功能性的网络服务。

+

+#dmz

+dmz = DMZ

+dmz_setting = DMZ 设置

+dmz_note_info = 如果终端设备无法通过该设备运行网络应用程序,请启用 DMZ,在输入框输入该终端设备的 IP 地址。

+dmz_note_function = 您可以在该网页配置 DMZ 地址、启用或停用 DMZ 功能。

+

+#Device Information

+max_access_num = 最大连接数

+lan_domain = 局域网域名

+sim_serial_number = SIM卡卡号

+software_version = 软件版本

+firmware_version = 固件版本

+hardware_version = 硬件版本

+imei = IMEI

+imsi = IMSI

+wan_ip_address = WAN IP 地址

+ipv6_wan_ip_address = WAN IPv6 地址

+network_name_ssid1 = 网络名称 (主SSID)

+pass_phrase_ssid1 = 密码 (主SSID)

+max_access_num_ssid1 = 最大连接数 (主SSID)

+network_name_ssid2 = 网络名称 (副SSID)

+pass_phrase_ssid2 = 密码 (副SSID)

+max_access_num_ssid2 = 最大连接数 (副SSID)

+

+#port map

+port_map = 端口映射

+port_map_basic = 基本设置

+port_map_setting = 端口映射设置

+source_port = 源端口

+dest_port = 目的端口

+port_map_list = 当前映射规则

+port_map_note_info = 配置端口映射以启用外部计算机,访问局域网提供的网络、FTP 或其他服务。

+port_map_note_port = 源端口/目的端口:提供服务的计算机端口。

+port_map_note_dest_ip_address = 目的 IP 地址:指定一台加入局域网的计算机以提供服务。

+port_map_note_protocol = 协议:由服务应用的协议。

+port_map_note_comment = 注释:输入用于端口映射规则的注释。有效字符包含:0-9 a-z A-Z ! # ( ) + - . / % = ? @ ^ _ { | } ~ 。

+

+#USSD Info

+USSD = USSD

+ussd = USSD

+ussd_send_to = 发送

+ussd_send = 发送

+ussd_cancel = 取消

+ussd_reply_to = 回复

+ussd_reply = 回复

+ussd_contents = 内容

+ussd_timeout = 网络超时!

+ussd_operation_timeout = 操作超时!

+ussd_no_service = 无网络服务!

+ussd_retry = 操作失败!请重试!

+ussd_unsupport = 不支持 USSD 功能!

+ussd_info_error = 获取信息出错!

+ussd_fail = 操作失败!

+ussd_error_input = 输入有误!

+ussd_note1 = 您可以向网络发送一条指令(已预先制定的数字或者符号),网络将会根据指令给您提供相应的服务。

+

+#dlna setting

+dlna_setting = DLNA 设置

+dlna_language = 语言

+dlna_language_chinese = 中文

+dlna_language_english = 英文

+dlna_device_name = 设备名称

+dlna_media_type = 共享媒体类型

+dlna_media_info = 共享设置

+dlna_audio = 音乐

+dlna_image = 图片

+dlna_video = 视频

+dlna_rescan = 重新扫描

+dlna_note_info = 当 SD 卡可用或者 HTTP 共享模式启用时,您可以设置数字生活网络联盟 (DLNA)。

+dlna_note_httpshare = 您可以设置要在该网页上共享的数字媒体服务器 (DMS) 语言、设备名称和媒体类型。

+dlna_note_rescan = 为了使 DLNA 多媒体文件数据库与 SD 卡保持同步,建议重新扫描。

+

+#nosimcard

+no_sim_card_title = 系统信息

+no_sim_card_message = 没有 SIM卡或者 SIM卡无效!

+

+#network_locked

+network_locked = 网络被锁!

+network_locked_explain = 设备的网络被锁,请联系您的服务提供商获取解锁码。

+network_locked_times_explain = 解锁码输入剩余次数:

+network_locked_enter_explain = 请输入解锁码:

+network_locked_zero_times = 网络被锁,请联系您的服务提供商。

+

+#update_info

+update_info = 升级信息

+update_no_info = 当前已是最新版本

+update_new_version_found = 有新版本可用

+update_current_version = 当前版本

+update_new_version = 新版本

+update_link_prompt = 点击下面的链接下载升级工具

+update_skip_btn = 应用

+update_id_skip_info = 如果不想升级至此版本,请点击“跳过”按钮

+update_remind = 有新版本时提醒我。

+update_management = 更新管理

+update_log = 问题解决

+update_note = 备注

+update_notice = 发现新版本。通过“设置->设备设置->更新管理”查看详情。

+update_note_info = 点击链接以下载对应系统的更新工具。

+update_note_install = 解压更新工具并运行,进行版本更新。

+update_note_linux = Linux 系统不支持在线升级。如需升级,请在 Windows 系统或 Mac 上完成。

+update_status = 状态

+update_settings = 升级

+wifi_connect_alert = 您只能通过以太网升级。

+

+#AP_Station

+ap_station = Internet Wi-Fi

+ap_station_switch = Internet Wi-Fi 开关

+ap_station_wlan_mode = 首选网络

+ap_station_wifi_prior = Wi-Fi

+ap_station_3g_prior = WWAN

+ap_station_current_status = 当前状态

+ap_station_wlan_connected = Wi-Fi 已连接

+ap_station_wan_connected = WAN 已连接

+ap_station_no_connection = 无任何连接

+ap_station_hotspot_list = Wi-Fi 热点

+ap_station_connect = 连接

+ap_station_disconnect = 断开连接

+ap_station_add_hotspot = 添加 Wi-Fi 热点

+ap_station_edit_hotspot = 编辑 Wi-Fi 热点

+ap_station_show_password = 显示密码

+ap_station_encrypt_type = 加密方式

+ap_station_wep_keys = WEP密钥

+ap_station_encrypt_type_none = 不加密

+ap_station_encrypt_type_wep = WEP

+ap_station_wep_key_type_ascii = ASCII

+ap_station_wep_key_type_hex = HEX

+ap_station_cipher = WPA算法

+ap_station_cipher_TKIP = TKIP

+ap_station_cipher_AES = AES

+ap_station_cipher_AUTO = AUTO

+ap_station_security_mode_OPEN = OPEN

+ap_station_security_mode_WPAPSKWPA2PSK = WPA-PSK/WPA2-PSK

+ap_station_security_mode_SHARED = SHARED

+ap_station_security_mode_WPAPSK = WPA-PSK

+ap_station_security_mode_WPA2PSK = WPA2-PSK

+ap_station_security_mode_EAPAKASIM = EAP-AKA/SIM

+ap_station_security_mode_EAP-SIM/AKA = EAP-SIM/AKA

+ap_station_security_mode_WPA3Personal = WPA3-Personal

+ap_station_security_mode_WPA2WPA3 = WPA2(AES)/WPA3-Personal

+ap_station_wep_default_key = 网络密钥

+ap_station_wep_key = WEP密钥

+ap_station_wep_key_0 = 密钥 1

+ap_station_wep_key_1 = 密钥 2

+ap_station_wep_key_2 = 密钥 3

+ap_station_wep_key_3 = 密钥 4

+ap_station_exceed_list_max = 最多可添加 {0} 个热点!

+ap_station_search_hotspot_fail = 搜索热点失败!

+ap_station_connect_change_alert = WAN连接将断开,要继续吗?

+ap_station_update_fail = 操作失败,该热点处于连接状态。

+ap_station_enable_confirm = 当Internet Wi-Fi使用时多重网络名称不能使用。如果开启Internet Wi-Fi,多重网络名称将自动关闭,是否修改设置?

+ap_station_processing = 后台忙,请重试。

+ap_station_exist = 存在同名热点。

+ap_connect_error = 无法连接上热点 {0}!

+

+#fastboot

+fastboot = 快速开机

+fastboot_setting = 快速开机设置

+fastboot_note = 如果启用了快速开机功能,设备将花费较短的时间开机。

+

+#notes

+wifi_channel_bandwidth = 频带宽度

+

+home_note = 表格中显示了已连接的无线终端设备信息。

+

+sms_setting_note_validity = 有效期:设置外发短信的有效期。

+sms_setting_note_center_number = 中心号码:请输入短信中心号码。如需详情请联系您的服务提供商。

+sms_setting_note_delivery_report = 发送报告:当短信已送达收件人时,接收或者拒绝送达提示。

+

+apn_note_whole_page = 您可以在该网页设置接入点名称 (APN)。

+apn_note_mode = 模式:如果您的服务提供商向您提供了固定的 APN,请选择“手动 APN”。如果没有提供,请选择“自动 APN”,该设备将会自动获取参数。

+apn_note_profile = 配置文件:包含了一个或多个配置文件名称。

+apn_note_pdp_type = PDP 类型:IPv4/IPv6/IPv4&IPv6。

+apn_note_profile_name = 配置文件名称:有关您指定的新的配置文件的名称。

+apn_note_apn = APN:接入点名称。有效字符包含:0-9 a-z A-Z . - 且开头和结尾不能是 . 或者 - 。

+apn_note_dns_mode = DNS 模式:如果您的服务提供商向您提供了固定的 IP 地址,请选择“手动 DNS”,如果没有提供,请选择“自动 DNS”,该设备将会自动获取参数。

+apn_note_authentication = 鉴权方式:由您的互联网服务提供商 (ISP) 来提供。密码验证协议 (PAP) 不用加密就可以通过两次握手建立对端的身份。询问握手认证协议(CHAP)通过三次握手周期性的校验对端的身份。

+apn_note_username = 用户名:用于建立连接时,从互联网服务提供商处获取验证。

+apn_note_password = 密码:用于建立连接时,从互联网服务提供商处获取验证。

+apn_note_set_default = 点击“设为默认”以将该配置文件设置为默认配置文件。

+

+wifi_basic_note_multi_ssid_switch = 多重网络名称开关:可以同时使用 2 个网络名称。

+wifi_basic_note_network_name = 网络名称(SSID):SSID可以简单地理解为无线网络的名称。修改SSID时,请在本框中输入一个最多不超过32个字符的字符串,该字符串由数字、字母(a-z、A-Z)、特殊字符(!#()+-./%=?@^_{|}~)和空格,且开头和结尾不能是空格。

+wifi_basic_note_network_name_input = 网络名称的有效字符包含:0-9 a-z A-Z ! # ( ) + - . / % = ? @ ^ _ { | } ~ 和空格且开头和结尾不能是空格。

+wifi_basic_note_broadcast = SSID 广播:启用后,设备将会广播其无线网络标识(SSID)。这样附近的计算机或其他无线客户端即可搜索到本路由器的无线信号并连接到该设备。

+wifi_basic_note_security_mode = 安全模式:

+wifi_basic_note_no_encryption = OPEN:无数据加密。这可能会导致网络被他人滥用,因此不推荐使用此方式。

+wifi_basic_note_shared = SHARED(WEP):链路认证方式为共享密钥认证方式,加密方式为WEP加密。

+wifi_basic_note_wpa_psk_aes = WPA2(AES)-PSK: WPA2(AES)-PSK 是 Wi-Fi 网络安全存取 (WPA) 的安全保护版本,该版本施行了802.11i 无线安全标准。

+wifi_basic_note_wpa_psk = WPA-PSK/WPA2-PSK:WPA 预共享密钥 (WPA-PSK)。WPA2-PSK 是 Wi-Fi 网络安全存取 (WPA) 的安全保护版本,该版本施行了802.11i 无线安全标准。

+wifi_basic_note_wpa3 = WPA3-Personal:WPA2加密协议的升级版本。

+wifi_basic_note_wpa2_wpa3 = WPA2(AES)/WPA3-Personal: WPA2-PSK 是 Wi-Fi 网络安全存取 (WPA) 的安全保护版本,该版本施行了802.11i 无线安全标准。WAP3是WPA2加密协议的升级版本。

+wifi_basic_note_pass_phrase = 密码:密码的有效字符包含:0-9 a-z A-Z ! # ( ) + - . / % = ? @ ^ _ { | } ~

+wifi_basic_note_max_station_number1 = 最大接入数:通过本操作,可以选择连接到该设备的最大无线终端接入数。通过Internet Wi-Fi功能连接的Wi-Fi热点也属于该设备的无线终端接入设备。

+wifi_basic_note_max_station_number = 最大接入数:通过本操作,可以选择连接到该设备的最大无线终端接入数。

+

+wifi_advanced_note_whole_page = 您可以在该网页设置 Wi-Fi 高级字符。

+wifi_advanced_note_band_selection = 频段选择:Wi-Fi工作的频段。

+wifi_advanced_note_network_mode = 网络模式:Wi-Fi工作的网络模式。

+wifi_advanced_note_country_code = 国家/地区码:设备的国家/地区码。

+wifi_advanced_note_frequency = 信道:选择合适的频道来优化Wi-Fi网络性能和覆盖范围。

+

+ap_station_note_info = 请确保您所连接的 Wi-Fi 热点的IP地址段与本设备的IP地址段不在同一范围内,否则您将无法通过该 Wi-Fi 热点连接网络。

+ap_station_note_disable_info = 如果开启“多重网络名称”,Internet Wi-Fi 功能将会停用。

+ap_station_on_info = Internet Wi-Fi 功能启用时无法进行该操作!

+

+wif_filter_note1 = 无线局域网地址过滤规则设置。

+wif_filter_note2 = 无规则:不启用无线局域网地址过滤规则。

+wif_filter_note3 = 白名单:允许MAC地址列表中的用户通过无线网络与本设备连接。

+wif_filter_note4 = 黑名单:不允许MAC地址列表中的用户通过无线网络与本设备连接。

+

+#restart

+restart = 重启

+restart_button = 重启设备

+restart_confirm = 确定重启设备吗?

+restarting = 设备重启中

+

+#diconneted_operate_note

+diconneted_operate_note = 要更改当前设置,请断开网络连接。

+diconneted_network_confirm = 当前操作将会断开网络,是否继续?

+

+#ota_update

+ota_update = 更新管理

+ota_title = 更新 

+ota_no_new_version = 没有发现新版本。

+ota_new_version = 发现新版本,是否更新? 

+ota_connect_server = 正在连接服务器 

+ota_connect_server_successfully = 连接服务器成功  

+ota_downloading = 正在下载...  

+ota_download_failed = 下载失败  

+ota_no_network = 无网络  

+ota_network_disconnected = 请连接网络后更新! 

+ota_interrupted_alert = 发现新版本,请登陆后更新!

+ota_interrupted = 是否恢复上次被中断的下载任务?

+ota_download_success = 下载完成,设备将重启,请稍候。升级过程中请不要断电、恢复出厂设置或关机。

+ota_pkg_download_success = 升级包已存在,设备将重启,请稍候。升级过程中请不要断电、恢复出厂设置或关机。

+ota_update_success = 更新成功。 

+ota_update_failed = 更新失败。  

+ota_connect_server_failed = 无法连接到服务器  

+ota_download_warning = 请保持电量充足;请不要强制中断下载。 

+ota_update_warning = 注意事项:请不要强制中断更新。 

+ota_cancel = 更新已取消! 

+ota_pkg_exceed = 更新包太大! 

+ota_have_cancel = 你已经选择取消了! 

+ota_roamming = 您尚未开启漫游设置。要开启漫游功能,请勾选本页复选框。

+ota_low_battery = 下载成功,设备电量不足,请充电后再升级! 

+ota_pkg_low_battery = 升级包已存在,设备电量不足,请充电后再升级!

+ota_md5_error = 检测更新包失败。

+ota_version = 版本:

+ota_update_setting = 自动检测设置

+ota_auto_update_switch = 自动检测新版本 

+ota_update_interval_day = 自动检测周期  

+ota_roaming_setting = 漫游设置 

+ota_update_roaming_remind = 勾选此项后,设备将在漫游状态下进行更新,并且会产生漫游费用。

+ota_update_manual = 检测新版本  

+ota_check_new_version = 检测  

+ota_check_new_version_desc = 点击“检测”按钮,立即检测新版本。 

+ota_check_roaming_confirm = 当前处于漫游网络下,您确定要升级吗?

+ota_update_every_day = 每天  

+ota_update_15_day = 15天  

+ota_update_30_day = 30天  

+ota_new_version_checking = 新版本检测中...

+ota_update_running = 检测已经在进行...

+ota_check_fail = 检测新版本失败!

+ota_manual_upgrade_url = 升级文件下载地址

+fota_package_already_download = 升级包已下载,待设备重启后完成升级

+software_upload = 软件升级

+upload_update_success = 升级文件上传成功,即将重启,请勿断电。

+upload_update_failed0 = 文件解析失败。   

+upload_update_failed1 = 文件校验失败。   

+upload_update_failed2 = 文件写入失败。   

+upload_update_failed3 = 升级标志写入失败。

+upload_update_failed4 = Flash校验失败。

+error_file_selected = 请选择正确的升级文件

+upload_tip = 上传中,请勿关闭、刷新或多页面操作webui,直至重启。

+########CPE more wording##############

+opmode = 模式切换

+wds = WDS

+url_filter = URL过滤设置

+

+voip_settings = VoIP设置

+voip_user_details = 用户详情

+voip_advanced_settings = 高级设置

+voip_supplementary_service = 补充业务

+

+url_check = 无效的URL

+url_filter_check = 无效的URL过滤规则

+sntp_invalid_server_name = 无效的URL格式或者IP地址!

+server_alreay_exist = 该服务器已经存在!

+forwarding_uri_check = 无效值

+

+wifi_switch = Wi-Fi开关

+ap_isolation = AP 隔离

+#mac filter

+black_list = 黑名单

+black_list_switch = 黑名单开关

+block = 屏蔽

+black_list_max = 黑名单支持的最大个数是10!

+mac_repeat_tip = 请删除设置列表中重复的MAC地址!

+black_yourself_tip = 你不能屏蔽你自己!

+wifi_status11 = 用户数:11

+wifi_status12 = 用户数:12

+wifi_status13 = 用户数:13

+wifi_status14 = 用户数:14

+wifi_status15 = 用户数:15

+wifi_status16 = 用户数:16

+wifi_status17 = 用户数:17

+wifi_status18 = 用户数:18

+wifi_status19 = 用户数:19

+wifi_status20 = 用户数:20

+wifi_status21 = 用户数:21

+wifi_status22 = 用户数:22

+wifi_status23 = 用户数:23

+wifi_status24 = 用户数:24

+wifi_status25 = 用户数:25

+wifi_status26 = 用户数:26

+wifi_status27 = 用户数:27

+wifi_status28 = 用户数:28

+wifi_status29 = 用户数:29

+wifi_status30 = 用户数:30

+wifi_status31 = 用户数:31

+wifi_status32 = 用户数:32

+

+auto_connect = 自动连接

+manual_connect = 手动连接

+

+default_Gateway = 默认网关

+primary_dns = 首选 DNS

+secondary_dns = 备用 DNS

+gateway_check = 请输入有效的网关

+

+mac_filter_lable = MAC过滤规则

+

+wlan_mac_filter_0 = 无规则

+wlan_mac_filter_1 = 白名单

+wlan_mac_filter_2 = 黑名单

+black_enable= 黑名单

+white_list = 白名单

+white_enable = 白名单

+mac_white_address = MAC 地址

+max_white_list = 白名单最多只能添加6条。

+

+#SNTP

+local_current_time = 本地当前时间

+time_set_mode = 时间设置模式

+time_set_time_manual = 手动设置时间

+time_set_time_auto = 自动同步Sntp

+year = 年

+month = 月

+date = 日

+hour = 时

+minute = 分

+second = 秒

+sunday = 星期日

+monday = 星期一

+tuesday = 星期二

+wednesday = 星期三

+thursday = 星期四

+friday = 星期五

+saturday = 星期六

+stnp_server1 = SNTP 服务器1

+stnp_server2 = SNTP 服务器2

+stnp_server3 = SNTP 服务器3

+time_zone =  时区

+daylight_saving_time = 夏时制

+daylightsave_0 = 禁用

+daylightsave_1 = 启用

+sntp_syn_time_wan_connected = 联网后才可以使用sntp时间同步!

+operation_not_supported = 不支持该操作!

+network_terminated = 网络终止!

+upgrade_file_nomatch = 升级文件错误!

+upgrade_confirm = 您确认要升级吗?

+upgrading = 升级中,请稍等...

+upgrading_alert = 升级中,请勿切断电源。升级后,系统将会自动重启!

+upgrad_note = 请选择您要升级的版本,然后点击“应用”按钮后,开始升级。

+sntp_processing = 同步中,请稍等...

+sntp_req_success = 同步请求已发送!

+time_zone_<-12>12_0 = (GMT-12:00) 日界线西

+time_zone_SST11_0 = (GMT-11:00) 中途岛,萨摩亚群岛

+time_zone_<-10>10_0 = (GMT-10:00) 夏威夷

+time_zone_<-09>9_0 = (GMT-09:00) 阿拉斯加

+time_zone_PST8PDT,M3.2.0,M11.1.0_0 = (GMT-08:00) 太平洋时间(美国和加拿大),蒂华纳

+time_zone_<-07>7_0 = (GMT-07:00) 山地时间(美国和加拿大)

+time_zone_<-07>7_1 = (GMT-07:00) 亚利桑那

+time_zone_MST7MDT,M4.1.0,M10.5.0_2 = (GMT-07:00) 奇瓦瓦,拉巴斯,马扎特兰

+time_zone_<-06>6_0 = (GMT-06:00) 萨斯喀彻温

+time_zone_<-06>6_1 = (GMT-06:00) 中部时间(美国和加拿大)

+time_zone_<-06>6_2 = (GMT-06:00) 中美洲

+time_zone_<-06>6_3 = (GMT-06:00) 瓜达拉哈拉,墨西哥城,蒙特雷

+time_zone_<-05>5_0 = (GMT-05:00) 波哥大,利马,基多

+time_zone_<-05>5_1 = (GMT-05:00) 东部时间(美国和加拿大)

+time_zone_EST5EDT,M3.2.0,M11.1.0_2 = (GMT-05:00) 印第安纳州(东部)

+#time_zone_-4.5 = (GMT-04:30)

+time_zone_AST4ADT,M3.2.0,M11.1.0_0 = (GMT-04:00) 大西洋时间(加拿大)

+time_zone_<-04>4_1 = (GMT-04:00) 加拉加斯,拉巴斯

+time_zone_<-04>4<-03>,M8.2.6/24,M5.2.6/24_2 = (GMT-04:00) 圣地亚哥

+time_zone_NST3:30NDT,M3.2.0,M11.1.0_0 = (GMT-03:30) 纽芬兰

+time_zone_<-03>3_0 = (GMT-03:00) 巴西利亚

+time_zone_<-03>3_1 = (GMT-03:00) 布宜诺斯艾利斯,乔治敦

+time_zone_<-03>3_2 = (GMT-03:00) 格陵兰

+time_zone_<-02>2_0 = (GMT-02:00) 中大西洋

+time_zone_<-01>1_0 = (GMT-01:00) 佛得角群岛

+time_zone_<-01>1<+00>,M3.5.0/0,M10.5.0/1_1 = (GMT-01:00) 亚速尔群岛

+time_zone_GMT0IST,M3.5.0/1,M10.5.0_0 = (GMT) 格林威治标准时间:都柏林,爱丁堡,伦敦,里斯本

+time_zone_WET0WEST,M3.5.0,M10.5.0/3_1 = (GMT) 卡萨布兰卡,蒙罗维亚

+time_zone_CET-1CEST,M3.5.0,M10.5.0/3_0 = (GMT+01:00) 阿姆斯特丹,柏林,伯尔尼,罗马,斯德哥尔摩,维也纳

+time_zone_CET-1CEST,M3.5.0,M10.5.0/3_1 = (GMT+01:00) 贝尔格莱德,布拉迪斯拉发,布达佩斯,卢布尔雅那,布拉格

+time_zone_CET-1CEST,M3.5.0,M10.5.0/3_2 = (GMT+01:00) 布鲁塞尔,哥本哈根,马德里,巴黎

+time_zone_CET-1CEST,M3.5.0,M10.5.0/3_3 = (GMT+01:00) 萨拉热窝,斯科普里,华沙,萨格勒布

+time_zone_<+01>-1_4 = (GMT+01:00) 中非西部

+time_zone_EET-2EEST,M3.5.0/3,M10.5.0/4_0 = (GMT+02:00) 布加勒斯特

+time_zone_CAT-2_1 = (GMT+02:00) 哈拉雷,比勒陀利亚

+time_zone_EET-2EEST,M3.5.0/3,M10.5.0/4_2 = (GMT+02:00) 赫尔辛基,基辅,里加,索非亚,塔林,维尔纽斯

+time_zone_EET-2_3 = (GMT+02:00) 开罗

+time_zone_EET-2EEST,M3.5.0/3,M10.5.0/4_4 = (GMT+02:00) 雅典,贝鲁特,伊斯坦布尔,明斯克

+time_zone_IST-2IDT,M3.4.5/02:00:00,M10.5.0/02:00:00_5 = (GMT+02:00) 耶路撒冷

+time_zone_<+03>-3_0 = (GMT+03:00) 巴格达

+time_zone_<+03>-3_1 = (GMT+03:00) 科威特,利雅得

+time_zone_<+03>-3_2 = (GMT+03:00) 莫斯科,圣彼得堡,伏尔加格勒

+time_zone_EAT-3_3 = (GMT+03:00) 内罗毕

+time_zone_<+0330>-3:30<+0430>,J80/0,J264/0_0 = (GMT+03:30) 德黑兰

+time_zone_<+04>-4_0 = (GMT+04:00) 阿布扎比,马斯喀特

+time_zone_<+04>-4_1 = (GMT+04:00) 巴库,第比利斯,埃里温

+time_zone_<+0430>-4:30_0 = (GMT+04:30) 喀布尔

+time_zone_<+05>-5_0 = (GMT+05:00) 叶卡捷琳堡

+time_zone_PKT-5_1 = (GMT+05:00) 伊斯兰堡,卡拉奇,塔什干

+time_zone_<+0530>-5:30_0 = (GMT+05:30) 马德拉斯,加尔各答,孟买,新德里

+time_zone_<+0545>-5:45_0 = (GMT+05:45) 加德满都

+time_zone_<+06>-6_0 = (GMT+06:00) 阿拉木图,新西伯利亚

+time_zone_<+06>-6_1 = (GMT+06:00) 阿斯塔纳,达卡

+time_zone_<+06>-6_2 = (GMT+06:00) 斯里哈亚华登尼普拉

+time_zone_<+0630>-6:30_0 = (GMT+06:30) 仰光

+time_zone_<+07>-7_0 = (GMT+07:00) 克拉斯诺亚尔斯克

+time_zone_<+07>-7_1 = (GMT+07:00) 曼谷,河内,雅加达

+time_zone_CST-8_0 = (GMT+08:00) 北京,重庆,香港特别行政区,乌鲁木齐

+time_zone_<+08>-8_1 = (GMT+08:00) 吉隆坡,新加坡

+time_zone_AWST-8_2 = (GMT+08:00) 珀斯

+time_zone_CST-8_3 = (GMT+08:00) 台北

+time_zone_<+08>-8_4 = (GMT+08:00) 伊尔库茨克,乌兰巴图

+time_zone_JST-9_0 = (GMT+09:00) 大阪,札幌,东京

+time_zone_KST-9_1 = (GMT+09:00) 汉城

+time_zone_<+09>-9_2 = (GMT+09:00) 雅库茨克

+time_zone_ACST-9:30ACDT,M10.1.0,M4.1.0/3_0 = (GMT+09:30) 阿德莱德

+time_zone_ACST-9:30_1 = (GMT+09:30) 达尔文

+time_zone_AEST-10_0 = (GMT+10:00) 布里斯班

+time_zone_<+10>-10_1 = (GMT+10:00) 弗拉迪沃斯托克

+time_zone_<+10>-10_2 = (GMT+10:00) 关岛,莫尔兹比港

+time_zone_AEST-10AEDT,M10.1.0,M4.1.0/3_3 = (GMT+10:00) 霍巴特

+time_zone_AEST-10AEDT,M10.1.0,M4.1.0/3_4 = (GMT+10:00) 堪培拉,墨尔本,悉尼

+time_zone_<+11>-11_0 = (GMT+11:00) 马加丹,所罗门群岛,新喀里多尼亚

+time_zone_<+12>-12_0 = (GMT+12:00) 奥克兰,惠灵顿

+time_zone_<+12>-12_1 = (GMT+12:00) 斐济,勘察加半岛,马绍尔群岛

+time_zone_<+13>-13_0 = (GMT+13:00) 努库阿洛法

+

+#operation mode

+opmode_auto = 自动模式

+opmode_bridge = 桥模式

+opmode_cable = 有线宽带模式

+opmode_gateway = 无线宽带模式

+EthPort_Status = 以太网端口状态

+change_mode = 选择模式

+current_mode = 当前模式:

+change = 改变

+change_mode_alert = 有线宽带模式只能使用Wi-Fi访问,请记住Wi-Fi SSID和密码!要继续吗?

+

+opmode_msg1 = 无线宽带模式下请将公网网线拔掉。

+opmode_msg2 = 改变工作模式后,设备会自动重启。

+#pppoe dial

+pppoe_mode = PPPoE

+pppoe_success = PPPoE拨号成功

+pppoe_fail = PPPoE拨号失败

+pppoe_processing = 正在进行PPPoE拨号

+static_success = 配置静态IP成功

+static_fail = 配置静态IP失败

+static_processing = 正在获取静态IP

+dyn_success = 动态获取IP成功

+dyn_fail = 动态获取IP失败

+dyn_processing = 正在获取动态IP

+pppoe_msg = 公网网线未连上

+pppoe_message_send_fail = 消息发送失败!

+ip_gate_not_same = IP地址和默认网关不可以相同!

+ip_innergate_not_same = IP地址和局域网的IP地址不可以在同一网段中!

+auto_success = 自动拨号成功

+auto_fail = 自动拨号失败

+auto_processing = 正在进行自动拨号

+#url filter

+url_filter_list = 当前系统的URL过滤规则

+url_filter_max = URL过滤规则最大数量为{0}

+url_repeated = URL已经存在。

+url_note1 = 您可以设置网页地址的过滤以过滤一些不良的网站。

+url_note2 = URL:设置需要过滤的url地址。

+

+#wds

+wds_mode = WDS模式

+wds_mode_0 = 禁用

+wds_mode_1 = RootAP 模式

+wds_mode_2 = Bridge 模式

+wds_mode_3 = Repeater 模式

+repeater_ssid = Repeater SSID

+wpa_algorithms = WPA算法

+enable_wds_confirm = 如果开启WDS,那么Wi-Fi基本设置将被禁用,继续吗?

+#sys log

+sys_log = 系统日志

+log_setting = 日志设置

+syslog_mode_all = 所有

+syslog_mode_wan_connect = WAN Connect

+syslog_mode_sms = SMS

+syslog_mode_tr069 = tr069

+syslog_mode_voip = VoIP

+syslog_mode_dlna = DLNA

+syslog_mode_wlan = Wi-Fi

+syslog_mode_router = Router

+view_log = 查看日志

+log_info = 日志信息

+

+#add at 2013.6.20

+periodic_inform = 周期性通知

+periodic_inform_interval = 周期性通知间隔

+periodic_inform_time = 周期性通知时间

+certificate_import = 证书

+import_certificate_btn = 导入

+certificate_file_nomatch = 证书文件错误

+#voip setting

+outbound_mode = Outbound模式

+outbound_server = Outbound服务器

+outbound_port = Outbound端口

+stun_mode = STUN模式

+stun_server = STUN服务器

+register_every = 注册有效期

+advanced_options = 高级选项

+sip_port = SIP端口

+rtp_port = RTP端口

+voip_outbound_port_check = 无效端口

+voip_time_check = 注册时间无效

+timeRange = [1,3600]秒

+voip_sip_port_check = 无效端口

+voip_port_compare = 无效的端口范围

+warn_information = VoIP参数设置成功,请重新注册。

+#voip user details

+user_details_title = SIP服务器和配置

+sip_register_server = SIP注册服务器

+sip_domain = SIP域

+sip_realm = SIP范围

+sip_proxy_mode = SIP代理模式

+sip_proxy_server = SIP代理服务器

+authorization = 鉴权

+display_name = 显示名称

+authorized_user_name = 鉴权用户名

+authorized_password = 授权密码

+voip_register_status = VoIP注册状态

+register_failed = 注册失败

+register_success = 注册成功

+register_connecting = 注册连接中

+unregister = 注销成功

+deregister = 注销

+sip_domain_check = SIP域地址无效!

+sip_realm_check = SIP域无效!

+sip_proxy_server_check = 代理服务器无效!

+display_name_check = 显示名称无效!

+authorized_username_check = 鉴权用户名无效!

+account_password_check = 密码无效!

+#voip advanced settings

+sip_advanced_options = 高级选项

+adv_sip_t38 = T.38传真编码

+sip_dtmf = DTMF

+voip_sip_dtmf_method_inband = InBand

+voip_sip_dtmf_method_rfc2833 = RFC2833

+voip_sip_dtmf_method_sipinfo = SIPInfo

+sip_encoder = 编码

+voip_sip_encoder_method_0 = G.711 u-Law

+voip_sip_encoder_method_1 = G.711 a-Law

+voip_sip_encoder_method_2 = G.722

+voip_sip_encoder_method_3 = G.729

+voip_sip_encoder_method_4 = G.726-16kps

+voip_sip_encoder_method_5 = G.726-24kps

+voip_sip_encoder_method_6 = G.726-32kps

+voip_sip_encoder_method_7 = G.726-40kps

+sip_vad = VAD

+sip_cng = CNG

+#voip supplementary service

+sip_protocol_voip = VoIP补充业务

+sip_protocol_call_forw = 呼叫转移

+voip_forwarding_mode_1 = 无条件呼叫转移

+voip_forwarding_mode_2 = 遇忙转移

+voip_forwarding_mode_3 = 无应答转移

+voip_forwarding_mode_0 = 禁止所有转移

+sip_protocol_forw_uri = 发送URI

+show_msg = 请在电话上按'*80'!

+sip_protocol_incoming_call = 免扰功能

+sip_protocol_call_waiting = 呼叫等待

+wds_note = WDS:无线分布式系统

+#voip user details

+connect_note = 请先连接网络,再使用VOIP功能!

+#fota

+upgrade_pack_fix_success = 升级成功!

+upgrade_pack_fix_failed = 升级失败!

+have_new_version = 发现新版本,设备将升级。

+######key same value different###########

+dmz_note_info = 如果终端设备无法通过该设备运行网络应用程序,请启用 DMZ,在输入框输入该终端设备的 IP 地址。

+dlna_note_info = DLNA: 数字生活网络联盟。

+dlna_note_httpshare = 您可以设置要在该网页上共享的数字媒体服务器 (DMS) 设备名称和媒体类型。

+#############串口转网口###################

+switch_port_title = 网口转串口

+open_serial_port = 开启网口转串口

+close_serial_port = 关闭网口转串口

+switching = 转换中...

+##############定时重启功能wording###################

+restart_schedule = 定时重启

+enable_reboot_switch = 启动定时重启功能

+restart_schedule_time = 定时重启时间

+enable_reboot_byday = 按天自动重启

+enable_reboot_byweek = 按周自动重启

+enable_reboot_bymonth = 按月自动重启

+synchronized = 已同步

+unsynchronized = 未同步

+week = 星期

+eyeryday = 每日

+login_password_length_check = 请输入至少4位字符。

+system_time_not_syn = 系统时间未同步!

+fota_note1 = 您可以为您的设备设置自动检测周期,使设备定时自动检测是否有新版本的软件。

+local_note = 您可以选择本地电脑中的升级文件,将设备软件升级到选中的版本,完成系统修复和优化。

+

+#new word

+modify_password = 修改登录密码

+

+#家长控制

+parental_control = 家长控制

+pc_children_group = 儿童组设备

+pc_children_group_manage = 儿童组管理

+pc_manage = 管理

+pc_no_children_device = 没有设置儿童组设备

+pc_children_group_desc = 添加到儿童组的所有设备将受到上网规则的限制

+pc_edit_host_name = 修改主机名:

+pc_internet_rule = 上网规则

+pc_time_limited = 上网时间设置

+pc_site_white_list = 网站白名单

+pc_manage_children_group = 管理儿童组设备

+pc_current_attached_devices =当前接入设备

+pc_action = 操作

+pc_remove = 移除

+pc_remove_all = 移除所有

+pc_add = 添加

+pc_leave = 离开

+pc_add_white_site = 添加白名单

+pc_in_child_group = 已在儿童组

+pc_forbid_time = 禁止上网时段

+pc_allow_time = 允许上网时段

+pc_setting_desc =可用鼠标点按设置禁止或允许上网时段

+pc_name = 网站名

+pc_link = 链接

+pc_not_save = 数据还未保存,请注意保存。

+pc_link_exist = 链接已存在!

+no_data = 没有数据

+sun = 周日

+mon = 周一

+tues = 周二

+wed = 周三

+thur = 周四

+fri = 周五

+sat = 周六

+

+#定时休眠唤醒

+tsw_settings = 定时休眠唤醒设置

+tsw = 定时休眠唤醒

+time_sleep_wake_up = 定时休眠唤醒设置

+tsw_timer_on = 定时唤醒时间

+tsw_timer_off = 定时休眠时间

+tsw_sys_time_mode_alert = 请先连接网络,使SNTP同步服务器时间后即可设置。

+tsw_time_interval_alert = 时间间隔不得小于10分钟。

+

+#new wording

+advanced_settings = 高级设置

+others = 其他

+others_restart_reset = 重启与复位

+others_note_info = 当重启或复位路由器后,你需要重新登陆

+

+pwd_sub_title = 管理你的无线路由器有关信息

+pwd_note = 当你登陆无线路由器时,需要输入此密码(不同于你的无线网络密码)

+current_network = 当前网络

+

+wifi_wireless_settings = Wi-Fi设置

+wifi_main_sub_title = 建立你的无线热点,以供手机或笔记本等无线设备上网使用

+wifi_broadcast_desc = SSID 广播

+wifi_isolated_desc = 将所有的无线客户端设备完全隔离

+

+detail_info = 详细信息

+sd_u_share = U盘共享

+

+settings_wireless = 设置无线内网

+settings_internet = 设置外网连接

+not_connect_network = 未连接网络

+

+traffic_data_plan = 流量统计

+traffic_pie_title = 流量套餐

+traffic_sub_title = 您可以在该页面创建流量计划、查询已用流量及剩余流量

+traffic_used = 已使用

+traffic_used_text = {0} 已使用

+traffic_limit_data = 流量套餐

+traffic_limit_data_text = {0} 流量套餐

+traffic_alert_reach_text = 当达到{0}%,{1} 时提醒我

+traffic_data_left_text = {0} 剩余

+traffic_when = 当达到

+traffic_remind_me = %,时提醒我

+traffic_remind_me_time = ,时提醒我

+traffic_limit_time_text = {0}套餐

+traffic_limit_time_h =  {0} 小时套餐

+traffic_limit_time_m =  {0} 分钟套餐

+traffic_not_set_limited = 未设置流量套餐,点按设置

+

+echarts_used = 已使用

+echarts_left1 = 未使用

+echarts_alert = 提醒值

+echarts_alarm = 已使用(超出提醒值)

+echarts_free = 未使用

+echarts_full = 流量超出

+echarts_no = 未设置

+

+3g = 3G

+wan = WAN

+connection_mode = 联网模式

+wireless_access_device = 无线接入设备

+cable_access_device = 有线接入设备

+station_info_sub_title = 本页面显示了连接到本路由器的所有无线终端,其中包括无线终端的设备名称、MAC(介质访问控制)地址

+station_info_desc = 更多的权限控制选项,请查看

+

+device_unit = 台

+ota_last_update_check = 最后更新时间:

+main_ssid_num = 主 SSID ({0})

+guest_ssid_num = 副 SSID ({0})

+wifi_slider_desc = * 拖动进度条已调整各SSID最大可接入数量

+wif_guest_disabled = 副SSID 没有开启

+

+phone_number = 号码

+equalToPin = 两次输入的PIN码不一致

+equalToPassword = 两次输入的密码不一致

+

+pppoe_mode_type_PPPOE = PPPoE

+pppoe_mode_type_STATIC = 静态IP

+pppoe_mode_type_DHCP = 动态IP

+pppoe_mode_type_AUTO = 自动

+

+tsw_note = 定时休眠唤醒功能,当定时休眠唤醒功能打开时,设备将进入休眠状态,此时设备的Wi-Fi功能将会自动关闭。

+tsw_note_on = 定时唤醒时间:您可以设置设备唤醒时间。

+tsw_note_off = 定时休眠时间:您可以设置设备定时休眠时间。

+

+parent_control_note_kids = 儿童组设备:显示当前儿童组设备。

+parent_control_note_manage = 儿童组管理:管理儿童组设备,您可以从当前连接设备列表添加儿童组设备。

+parent_control_note_time = 上网时间设置:设置儿童上网时间规则,即允许儿童设备上网的时间。

+parent_control_note_whitelist = 网站白名单:设置网站白名单,即允许儿童设备访问的网站。

+parent_control_note_siteName = 白名单网站名不能包含以下字符: < > [ ] * $ & : , ; " ' ` / \\ | ? ¥

+parent_control_note_siteLink = 白名单链接输入时请以“http://”或“https://”开头。

+firewal_note = 注意:防火墙相关的规则设置,可能不会立即生效,需等待几分钟或重启设备,如需立即生效,建议重启设备。

+

+wan_note_dial = 拨号方式:

+wan_note_connection_mode = 请为您的设备设置合适的网络连接方式:

+wan_note_connection_mode_pppoe = PPPoE:通过PPPoE方式接入外网,您需要向您的运营商咨询PPPoE用户名和密码。

+wan_note_connection_mode_dhcp =  动态IP:通过动态IP地址方式接入外网。

+wan_note_connection_mode_static = 静态IP:通过设置静态IP地址的方式接入外网,您需要设置IP地址、子网掩码、默认网关、首选DNS及备用DNS。

+wan_note_user_name = 用户名:填写您的PPPoE帐号。

+wan_note_password = 密码:填写您的PPPoE密码。

+wan_note_connection_mode_auto = 自动:自动选择动态IP或PPPoE方式接入外网,您需要向您的运营商咨询PPPoE用户名和密码。

+

+wps_pin_validator = 请输入有效的PIN码

+device_rename = 请输入有效的名称。

+

+turnoff_button = 关机

+others_turn_off = 关机

+turnoff_confirm  = 确定关机吗?

+turnoff = 关机中...

+setting_no_change = 您的设置未发生变化。

+Extend_accessDevice = WIFI最大接入数不能小于当前接入设备数。

+TBcheck = 请输入一个介于1和4095之间的值。

+apn_pdptype_change_note = 如果该设置被改变,通过域名 {0} 访问Web页面可能存在打不开的风险,这时候请尝试 {1} 来访问。

+apn_alert = 当前操作将会重启设备。是否继续?

+apn_alert_restart = 默认APN设置成功,设备正在重启。

+apn_diconneted_network_confirm = 当前操作将会断开网络,是否继续?

+

+#super

+super = 锁小区设置

+lockCell_settings = 锁小区设置

+v4_settings = 机卡互锁 (V4 加密)

+

+cell_id1 = Cell Id 1

+cell_id2 = Cell Id 2

+cell_id3 = Cell Id 3

+cell_id4 = Cell Id 4

+cell_id5 = Cell Id 5

+

+v4_check = 无效字符,只能输入 0-9、a-z、A-Z

+v4_note = 您的设置将在设备重启后生效,您要继续吗?

+export_title = 导出设置

+band_3 = 频段 3

+band_8 = 频段 8

+band_38 = 频段 38

+band_39 = 频段 39

+band_40 = 频段 40

+band_info = 频段设置

+cell_id = 当前注册的小区

+lock_apply = 加锁

+unlock_apply= 解锁

+band_cell_settings = 频段小区设置

+export = 导出

+sinr = SINR

+cell_not_correct = 非锁定小区,联网失败!

+cell_id_lock = 已锁定的小区

+

+sip_uri_format = URI 模式

+user_name = 用户名

+pin_v4_encrypt = PIN 加密

+wep_cannot_2040 = 当主SSID或者副SSID的安全模式是OPEN (WEP)或者SHARED的时候,频带宽度不能是20MHz/40MHz!

+2040_cannot_wep = 当频带宽度是20MHz/40MHz的时候,SSID的安全模式不能为OPEN (WEP)或者SHARED。

+wifi_device_busy = Wi-Fi驱动繁忙中,请稍等...

+v4_settings = 机卡互锁 (V4 加密)

+manufactory_code = 厂商代码

+key_version_number = 密钥版本号

+key_value = 密钥值

+

+LockCell_note1 =  锁小区功能是用于对LTE网络的小区锁定,当前注册小区与锁定小区一致时允许联网,当前注册小区与锁定小区不一致时禁止发起联网。

+LockCell_note2 =  锁定小区功能开启且保存的锁定小区不为空时,每天开机和定时(8:00/14:00/20:00)比对当前注册的网络小区与锁定小区是否相同,如果不同则做断网处理。

+mac_blank = MAC地址不能为空

+

+vlan_switch = VLAN开关

+vlan_notice = 如果您要停用该功能,重启后才生效。请问您是否继续?

+vlan_notice2 = 如果您要开启该功能,多重网络名称开关必须是开启状态。请问您是否开启多重网络名称开关并开启VLAN功能?

+ap_hide = AP隐藏

+

+urlparent = 主域名后面不能再跟随以/开始的内容。

+not_change_mode = 设备正在后台配置相关参数,请稍后尝试

+

+

+#device

+device_status = 设备加密状态

+device_status_0 = 已解密

+device_status_1 = 未解密

+

+######DDNS###########

+ddns = DDNS

+Hash value is empty = Hash 值为空!

+DDNS Provider is empty = DDNS 服务器为空!

+register successful = 注册成功

+login error = 登陆错误

+network error = 网络错误

+registering = 正在注册

+not registered = 未注册

+error registering = 注册失败

+error = 错误

+ddns_set_mode = DDNS

+mode_set_mode_1 = 启用

+mode_set_mode_0 = 禁用

+mode_select_auto = 自动

+mode_select_manual = 手动

+ddns_mode = DDNS 模式

+Auto = 自动

+Manual = 手动

+DDNS_Status = DDNS 状态

+DDNSHashValue = Hash 值

+ddns_ProviderList = 动态DNS服务器

+ddns_account = 用户

+ddns_passwd = 密码

+ddns_domainName = 域名

+ddns_hashvalue_check = 无效字符,只能输入 0-9、a-z、A-Z 或 =

+ddns_note1 = 您可以设置动态域名服务,为动态WAN IP地址分配一个固定域名。

+ddns_note2 = 动态DNS服务器:设置提供动态域名服务的服务器。

+ddns_note3 = 密码:密码的有效字符包含:0-9 a-z A-Z ! # $ * + , - . % : = ? @ [ ] ^ _ { | } ~ 

+ddns_note4 = 域名:设置要申请的域名。

+ddns_note5 = Hash 值:DDNS哈希值,在使用freedns服务器的时候需要。有效字符包含:0-9 a-z A-Z 或 = 

+

+#tr069

+tr069 = TR069

+cwmp_enaled = 开启 TR069

+server_url = ACS服务器URL

+server_username = ACS服务器用户名

+server_password = ACS服务器密码

+enable_cycle_reporting = 开启上报周期

+periodi_reporting_interval = 周期上报间隔

+cpe_username = CPE连接用户名

+cpe_password = CPE连接密码

+stun_enable = 开启STUN

+url_span = 前缀为[http|https]的URL类型

+string_range_is = 字符长度范围是 :

+stun_server_address = STUN服务器地址

+stun_server_port = STUN服务器端口

+stun_username = STUN用户名

+stun_password = STUN密码

+stun_min_keepalive_period = 最短保活期

+stun_max_keepalive_period = 最长保活期

+stun_udp_notfication_limit = UDP请求间隔

+stun_udp_connection_request_address = UDP连接请求地址

+stun_nat_detected = NAT检测

+stun_port_span = (0~65535)

+stun_time_span = 秒[1~86400]

+stun_limit_span = 秒[5~86400]

+periodic_interval_span = 秒[20~86400]

+stun_interval_span = 秒[10~86400]

diff --git a/lynq/S300/ap/app/zte_webui/index.html b/lynq/S300/ap/app/zte_webui/index.html
new file mode 100755
index 0000000..e8a7349
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/index.html
@@ -0,0 +1,164 @@
+<!DOCTYPE html>

+<html>

+<head>

+<meta charset="UTF-8"/>

+<meta name="renderer" content="webkit"/>

+<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"/>

+<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"/>

+<meta http-equiv="Pragma" content="no-cache"/>

+<meta http-equiv="Expires" content="0"/>

+<title></title>

+<script type="text/javascript">

+document.write("<link rel='stylesheet' type='text/css' href='css/csn.css?random=" + Math.random() + "' />");

+document.write("<link rel='stylesheet' type='text/css' href='css/bt_strp.css?random=" + Math.random() + "' />");

+document.write("<link rel='stylesheet' type='text/css' href='css/com.css?random=" + Math.random() + "' />");

+</script>

+<link href="favicon.ico" rel="shortcut icon" />

+<!--[if lt IE 9]>

+<script type="text/javascript">

+document.write("<script type='text/javascript' rc='js/3rd/html5shiv.js?random=" + Math.random() + "'></s" + "cript>");

+document.write("<script type='text/javascript' rc='js/3rd/respond.js?random=" + Math.random() + "'></s" + "cript>");

+</script>

+<![endif]-->

+</head>

+<body>

+<div class="container" id="topContainer">

+    <div id="langLogoBar" class="row">

+        <div class="col-xs-4">

+            <a href="index.html" style="display: none;">

+			<script type="text/javascript">

+			document.write("<img src='pic/res_logo_web.png?random=" + Math.random() + "' />");

+			</script>

+            </a>

+            <!-- <span class="center-block" style="display: inline-block; vertical-align: middle; margin-left: 10px; font-weight: bold;">Mobiletek 4G CPE</span> -->

+        </div>

+        <div id="statusBar" style="display: none;" class="col-xs-8 text-right">

+            <span id="networkType" title="network_type" i18n="true" data-bind="text: networkType" class="statusItem"></span>

+            <span id="operator" title="network_provider" i18n="true" data-bind="text: networkOperator" class="statusItem"></span>

+            <span id="OTA" title="ota_title" i18n="true" data-bind="visible:isShowFotaNewversionIcon()" class="statusItem">

+                <a onclick="return showOTAAlert();">

+				<script type="text/javascript">

+				document.write("<img src='pic/res_update.gif?random=" + Math.random() + "' class='paddingbottom6' />");

+				</script>

+                </a>

+            </span>

+            <span id="signal_strength" title="signal_strength" i18n="true" class="statusItem"><i data-bind="attr:{'class': signalCssClass}" class="signal">&nbsp;</i></span>

+            <span id="connection_status" title="connection_status" i18n="true" class="statusItem"><i data-bind="attr:{'class': connectionCssClass}" class="icon_connection">&nbsp;</i></span>

+            <span id="rj45_connection_status" title="rj45_connection_status" i18n="true" data-bind="visible: isShowRj45ConnectionIcon" class="statusItem"><i data-bind="attr:{'class': rj45ConnectionCssClass}" class="icon_connection">&nbsp;</i></span>

+            <span id="sms_unread_count" title="sms_unread_count" i18n="true" data-bind="visible: smsUnreadCount() > 0 || showSmsDeleteConfirm()" style="display: none; position: relative;" class="statusItem">

+                <a onclick="return gotoSmsList();" href="javascript: void(0)">

+					<script type="text/javascript">

+					document.write("<img data-bind='visible: smsUnreadCount() > 0 && !showSmsDeleteConfirm()' src='./pic/msg_unread.png?random=" + Math.random() + "' class='paddingbottom6'/>");

+					document.write("<img data-bind='visible: showSmsDeleteConfirm()' src='./pic/msg_full.gif?random=" + Math.random() + "' class='paddingbottom6'/>");

+					</script>

+                    <sup data-bind="visible: smsUnreadCount() > 0, text: smsUnreadCount" class="smsUnreadCount"></sup>

+                </a>

+            </span>

+            <span id="statusItemSimStatus" title="sim_status" i18n="true"  class="statusItem"><img data-bind="attr: {src: simStatus}" class="paddingbottom6"/></span>

+            <span id="roamingStatus" title="roaming_status" i18n="true" data-bind="visible: roamingStatus() == 'R'" style="display: none;" class="statusItem">

+			<script type="text/javascript">

+			document.write("<img src='./pic/res_roaming.png?random=" + Math.random() + "' class='paddingbottom6'/>");

+			</script>			

+			</span>

+            <span id="wifi_status" title="wifi_status" i18n="true" data-bind="visible: hasWifi" class="statusItem">

+                <!--img class="paddingbottom6" id="wifi_status_img" data-bind="attr: {src: wifiStatusImg}"/-->

+                <i class="wifi_status" data-bind="attr:{'class': wifiStatusCssClass}">&nbsp;</i>

+            </span>

+            <span title="battery_level" i18n="true" data-bind="visible: hasBattery" class="statusItem"><img id="batteryCharging" data-bind="attr: {src: batteryPers}" class="paddingbottom6"/></span>

+        </div>

+    </div>

+    <div id="manageBar" class="row">

+        <div id="manageContainer" class="col-xs-12 text-right">

+            <span id="logout">

+                <a data-trans="modify_password" href="#pwd_mode" data-bind="visible:showLogout()" class="margin-right-10"></a>

+                <a id="logoutlink" data-trans="logout" href="javascript:void(0)" data-bind="click:logout,visible:showLogout() " style="display: none;" class="margin-right-10"></a>

+            </span>

+            <select id="language" data-bind="options: languages, value: currentLan, optionsText: 'text', optionsValue: 'value', event:{ change: langChangeHandler}" class="marginright10"></select>

+        </div>

+    </div>

+</div>

+<div id="indexContainer" class="container">

+    <div id="mainContainer" style="min-height: 450px;">

+        <div id='container'></div>

+    </div>

+</div>

+<!-- <div id="footer" style="border-top:1px solid #dddddd" class="container margin-top-5">

+    <span data-trans='copyright'></span>&nbsp;  -->

+    <!--span data-trans="vertical_bar"></span> &nbsp;<a href="http://www.demo.com" target="_blank" data-trans="open_source_licenses" class="extendLink"></a-->

+<!-- </div> -->

+

+<div id='result-overlay'>

+    <div class='header'></div>

+    <br/>

+    <div class="text-center">

+        <div>

+            <div id="result-image"></div>

+        </div>

+        <div id="result_wording"></div>

+    </div>

+</div>

+

+<div id='loading'>

+    <div class='header'><span id="loadMsg"></span></div>

+    <br/>

+    <div class="text-center">

+		<div><span id="loading_wording" class="message"></span></div>

+        <img id="loadingImg" src="pic/res_loading.gif?bG9hZGluZy5naWY="/>

+        <div id="loading_container"></div>

+    </div>

+</div>

+

+<div id='progress'>

+    <div class='header'><span id="barMsg"></span></div>

+     <br/>

+     <div class="progress-content">

+         <div class="progress-bar-container">

+             <div id="bar" class="progress-bar"></div>

+             <div id="barValue" class="progress-bar-value"></div>

+         </div>

+         <div id="progress_container" class="progress-prompt"></div>

+     </div>

+ </div>

+<!-- confirm content -->

+<div id='confirm'>

+    <div class='header'><span id="popTitle"></span></div>

+    <div id="confirm-message-container">

+        <div class='icon'><img id='confirmImg'/></div>

+        <div class="confirm-message">

+            <div class='message'></div>

+            <div class='promptDiv'>

+                <input id="promptInput" name="promptInput" type="text" maxlength="25" class="width190"/><br/>

+                <label class="promptErrorLabel colorRed"></label>

+            </div>

+        </div>

+    </div>

+    <div class='buttons'>

+        <input id='okbtn' type="button" data-trans='ok' class="btn btn-default simplemodal-close"/>

+        <input id='yesbtn' type="button" data-trans='yes' class="btn btn-default "/>

+        <input id='nobtn' type="button" data-trans='no' class="btn btn-default simplemodal-close"/>

+    </div>

+</div>

+<div id='popupSettingWindow'>

+    <div class='header'>

+		<p class="tag-popup-close"><a href="javascript:hidePopupSettingWindow();"></a></p>

+	</div>

+	<div id="htmlContainer" class="modal-body"></div>

+</div>

+<div id="buttom-bubble">

+</div>

+<script type="text/x-jquery-tmpl" id="newMessagePopTmpl">

+    <div class="bubbleItem ${report}" id="${mark}">

+        <h3>

+			<span data-trans="${titletrans}">${title}</span> ${name} <a href="javascript:void(0);" data-targetid="${mark}" class="bubbleCloseBtn"></a>

+		</h3>

+        <div class="bubbleContainer">

+            <div class="bubbleContent">${content}</div>

+            <div class="bubbleDatetime">${datetime}</div>

+        </div>

+    </div>

+</script>

+<script type="text/javascript">

+document.write("<script type='text/javascript' data-main='js/main' src='js/3rd/require-jquery.js?random=" + Math.random() + "'></s" + "cript>");

+</script>

+</body>

+</html>

diff --git a/lynq/S300/ap/app/zte_webui/js/com.js b/lynq/S300/ap/app/zte_webui/js/com.js
new file mode 100755
index 0000000..e103a35
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/js/com.js
@@ -0,0 +1,11413 @@
+

+define("service","underscore jquery set CryptoJS".split(" "), function (_, $, config, CryptoJS) {

+    function addTimerSomething(querys, cb) {

+        if (_.isArray(querys)) {

+            for (var i = 0; i < querys.length; i++) {

+                addQueryString(querys[i]);

+            }

+        } else {

+            addQueryString(querys);

+        }

+        addCallback(cb);

+    }

+    function removeTimerSomething(querys, cb) {

+        if (_.isArray(querys)) {

+            for (var i = 0; i < querys.length; i++) {

+                removeQueryString(querys[i]);

+            }

+        } else {

+            removeQueryString(querys);

+        }

+        removeCallback(cb);

+    }

+    function getCurretnMAC() {

+        return getUserMacAddr({}).get_user_mac_addr;

+    }

+    function getDdnsParams(values, callback) {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            return {

+                multi_data: 1,

+                cmd: "DDNS_Enable,DDNS_Mode,DDNSProvider,DDNSAccount,DDNSPassword,DDNS,DDNS_Hash_Value"

+            };

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return {

+                    DDNS_Enable: paramD.DDNS_Enable,

+                    DDNS_Mode: paramD.DDNS_Mode,

+                    DDNSProvider: paramD.DDNSProvider,

+                    DDNSAccount: paramD.DDNSAccount,

+                    DDNSPassword: paramD.DDNSPassword,

+                    DDNS: paramD.DDNS,

+                    DDNS_Hash_Value: paramD.DDNS_Hash_Value

+                }

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setDDNSForward() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = $.extend({}, values);

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+   function getLoginData() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "modem_main_state,puknumber,pinnumber,blc_wan_mode,blc_wan_auto_mode,psw_fail_num_str,login_lock_time,psw_changed";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                if (paramD.blc_wan_mode == "AUTO") {

+                    paramD.blc_wan_mode = paramD.blc_wan_auto_mode ? paramD.blc_wan_auto_mode : 'AUTO_PPP';

+                } else {

+                    paramD.blc_wan_mode = paramD.blc_wan_mode ? paramD.blc_wan_mode : 'PPP';

+                }

+                paramD.psw_fail_num_str = paramD.psw_fail_num_str == '' ? config.MAX_LOGIN_COUNT : paramD.psw_fail_num_str;

+                paramD.login_lock_time = paramD.login_lock_time == '' ? '300' : paramD.login_lock_time;

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function login() {

+        return stuffMake(arguments, {}, prepare, deal, {

+            errorType: 'badPassword'

+        }, true);

+        function prepare(values, isPost) {

+            var obj = {

+                goformId: "LOGIN",

+                password: config.PASSWORD_ENCODE ? Base64.encode(values.password) : values.password

+            };

+            return obj;

+        }

+        function deal(paramD) {

+            if (paramD && (paramD.result == "0" || paramD.result == "4")) {

+                informationAll.isLoggedIn = true;

+                return {

+                    result: true

+                };

+            } else {

+                var loginError = {};

+                switch (paramD.result) {

+                case "1":

+                    loginError = {

+                        errorType: "Login Fail"

+                    };

+                    break;

+                case "2":

+                    loginError = {

+                        errorType: "duplicateUser"

+                    };

+                    break;

+                case "3":

+                    loginError = {

+                        errorType: "badPassword"

+                    };

+                    break;

+                default:

+                    loginError = {

+                        errorType: "Login Fail"

+                    };

+                    break;

+                }

+                informationAll.isLoggedIn = false;

+                return $.extend(errUnknownObj, loginError);

+            }

+        }

+    }

+    function getLoginStatus() {

+        if (informationAll.isLoggedIn != undefined) {

+            return stuffMake(arguments, {

+                status: informationAll.isLoggedIn ? 'loggedIn' : 'loggedOut'

+            });

+        } else {

+            var resultObject = {};

+            if (!config.HAS_LOGIN) {

+                resultObject.status = 'loggedIn';

+                resultObject.errorType = 'no_login';

+                informationAll.isLoggedIn = true;

+            }

+            return stuffMake(arguments, resultObject, prepare, deal, null, false);

+        }

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "loginfo";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.loginfo || paramD.loginfo == "") {

+                var loginStatus = {};

+                switch (paramD.loginfo) {

+                case "ok":

+                    informationAll.isLoggedIn = true;

+                    loginStatus.status = "loggedIn";

+                    break;

+                default:

+                    informationAll.isLoggedIn = false;

+                    loginStatus.status = "loggedOut";

+                    break;

+                }

+                return loginStatus;

+            } else {

+                informationAll.isLoggedIn = undefined;

+                return $.extend(errUnknownObj, {

+                    errorType: "LoginStatusError"

+                });

+            }

+        }

+    }

+    function enterPIN() {

+        return stuffMake(arguments, {}, prepare, deal, {}, true);

+        function prepare(values, isPost) {

+            var obj = {};

+            obj.goformId = "ENTER_PIN";

+            obj.PinNumber = values.PinNumber;

+            return obj;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result === "success") {

+                return {

+                    result: true

+                };

+            } else {

+                return {

+                    result: false

+                };

+            }

+        }

+    }

+    function enterPUK() {

+        return stuffMake(arguments, {}, prepare, deal, {}, true);

+        function prepare(values, isPost) {

+            var obj = {};

+            obj.goformId = "ENTER_PUK";

+            obj.PUKNumber = values.PUKNumber;

+            obj.PinNumber = values.PinNumber;

+            return obj;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result === "success") {

+                return {

+                    result: true

+                };

+            } else {

+                return {

+                    result: false

+                };

+            }

+        }

+    }	

+

+    function getStatusInfo() {

+        if (informationAll.isLoggedIn === undefined) {

+            var loginStatus = getLoginStatus();

+            return {

+                networkType: informationAll.networkType,

+                signalImg: informationAll.signalImg,

+                networkOperator: informationAll.networkOperator,

+                spn_b1_flag: informationAll.spn_b1_flag,

+                spn_name_data: informationAll.spn_name_data,

+                spn_b2_flag: informationAll.spn_b2_flag,

+                connectStatus: informationAll.connectStatus,

+                rj45ConnectStatus: informationAll.rj45ConnectStatus,

+                ssid1AttachedNum: informationAll.ssid1AttachedNum,

+                ssid2AttachedNum: informationAll.ssid2AttachedNum,

+                wirelessDeviceNum: informationAll.ssid1AttachedNum + informationAll.ssid2AttachedNum,

+                roamingStatus: informationAll.roamingStatus,

+                wifiStatus: informationAll.wifiStatus,

+                simStatus: informationAll.simStatus,

+                pinStatus: informationAll.pinStatus,

+                batteryStatus: informationAll.batteryStatus,

+                batteryLevel: informationAll.batteryLevel,

+                batteryPers: informationAll.batteryPers,

+                batteryTime: informationAll.batteryTime,

+                ssid: informationAll.ssid,

+                authMode: informationAll.authMode,

+                data_counter: informationAll.data_counter,

+                isLoggedIn: loginStatus.status == "loggedIn",

+                newSmsReceived: informationAll.newSmsReceived,

+                smsReportReceived: informationAll.smsReportReceived,

+                smsUnreadCount: informationAll.smsUnreadCount,

+                limitVolumeEnable: informationAll.limitVolumeEnable,

+                limitVolumeType: informationAll.limitVolumeType,

+                limitVolumePercent: informationAll.limitVolumePercent,

+                limitVolumeSize: informationAll.limitVolumeSize,

+                connectWifiProfile: informationAll.connectWifiProfile,

+                connectWifiSSID: informationAll.connectWifiSSID,

+                connectWifiStatus: informationAll.connectWifiStatus,

+                multi_ssid_enable: informationAll.multi_ssid_enable,

+                roamMode: informationAll.roamMode,

+                blc_wan_mode: informationAll.blc_wan_mode,

+                current_upgrade_state: informationAll.current_upgrade_state,

+                is_mandatory: informationAll.is_mandatory,

+                new_version_state: informationAll.new_version_state,

+                allowRoamingUpdate: informationAll.allowRoamingUpdate,

+                ap_station_enable: informationAll.ap_station_enable,

+                ap_station_mode: informationAll.ap_station_mode,

+                dialMode: informationAll.dialMode,

+                fota_package_already_download: informationAll.fota_package_already_download,

+                ethWanMode: informationAll.ethWanMode,

+                fota_user_selector: informationAll.fota_user_selector,

+                defaultWanName: informationAll.defaultWanName

+            };

+        }

+        return {

+            networkType: informationAll.networkType,

+            signalImg: informationAll.signalImg,

+            networkOperator: informationAll.networkOperator,

+            spn_b1_flag: informationAll.spn_b1_flag,

+            spn_name_data: informationAll.spn_name_data,

+            spn_b2_flag: informationAll.spn_b2_flag,

+            connectStatus: informationAll.connectStatus,

+            rj45ConnectStatus: informationAll.rj45ConnectStatus,

+            ssid1AttachedNum: informationAll.ssid1AttachedNum,

+            ssid2AttachedNum: informationAll.ssid2AttachedNum,

+            wirelessDeviceNum: informationAll.ssid1AttachedNum + informationAll.ssid2AttachedNum,

+            roamingStatus: informationAll.roamingStatus,

+            wifiStatus: informationAll.wifiStatus,

+            simStatus: informationAll.simStatus,

+            pinStatus: informationAll.pinStatus,

+            batteryStatus: informationAll.batteryStatus,

+            batteryLevel: informationAll.batteryLevel,

+            batteryPers: informationAll.batteryPers,

+            batteryTime: informationAll.batteryTime,

+            ssid: informationAll.ssid,

+            authMode: informationAll.authMode,

+            data_counter: informationAll.data_counter,

+            isLoggedIn: informationAll.isLoggedIn,

+            newSmsReceived: informationAll.newSmsReceived,

+            smsReportReceived: informationAll.smsReportReceived,

+            smsUnreadCount: informationAll.smsUnreadCount,

+            limitVolumeEnable: informationAll.limitVolumeEnable,

+            limitVolumeType: informationAll.limitVolumeType,

+            limitVolumePercent: informationAll.limitVolumePercent,

+            limitVolumeSize: informationAll.limitVolumeSize,

+            connectWifiProfile: informationAll.connectWifiProfile,

+            connectWifiSSID: informationAll.connectWifiSSID,

+            connectWifiStatus: informationAll.connectWifiStatus,

+            multi_ssid_enable: informationAll.multi_ssid_enable,

+            blc_wan_mode: informationAll.blc_wan_mode,

+            roamMode: informationAll.roamMode,

+            current_upgrade_state: informationAll.current_upgrade_state,

+            is_mandatory: informationAll.is_mandatory,

+            new_version_state: informationAll.new_version_state,

+            allowRoamingUpdate: informationAll.allowRoamingUpdate,

+            ap_station_enable: informationAll.ap_station_enable,

+            ap_station_mode: informationAll.ap_station_mode,

+            dialMode: informationAll.dialMode,

+            fota_package_already_download: informationAll.fota_package_already_download,

+            ethWanMode: informationAll.ethWanMode,

+            fota_user_selector: informationAll.fota_user_selector,

+            defaultWanName: informationAll.defaultWanName

+        };

+    }

+    function getConnectionInfo() {

+        var isData = informationAll.limitVolumeType == '1';

+        var result = {

+            data_counter: informationAll.data_counter,

+            connectStatus: informationAll.connectStatus,

+            rj45ConnectStatus: informationAll.rj45ConnectStatus,

+            limitVolumeEnable: informationAll.limitVolumeEnable,

+            limitVolumeType: informationAll.limitVolumeType,

+            limitVolumePercent: informationAll.limitVolumePercent,

+            networkType: informationAll.networkType

+        };

+        if (isData) {

+            result.limitDataMonth = informationAll.limitVolumeSize;

+            result.limitTimeMonth = 0;

+        } else {

+            result.limitTimeMonth = informationAll.limitVolumeSize;

+            result.limitDataMonth = 0;

+        }

+        result.blc_wan_mode = informationAll.blc_wan_mode;

+        return result;

+    }

+    function resetNewSmsReceivedVar() {

+        informationAll.newSmsReceived = false;

+    }

+    function resetSmsReportReceivedVar() {

+        informationAll.smsReportReceived = false;

+    }

+    function getSmsCapability() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "sms_capacity_info";

+            return valueReq;

+        }

+        function deal(paramD) {

+            return {

+                nvTotal: parseInt(paramD.sms_nv_total, 10),

+                nvUsed: parseInt(paramD.sms_nv_rev_total, 10) + parseInt(paramD.sms_nv_send_total, 10) + parseInt(paramD.sms_nv_draftbox_total, 10),

+                simTotal: parseInt(paramD.sms_sim_total, 10),

+                simUsed: parseInt(paramD.sms_sim_rev_total, 10) + parseInt(paramD.sms_sim_send_total, 10) + parseInt(paramD.sms_sim_draftbox_total, 10),

+                nvReceive: parseInt(paramD.sms_nv_rev_total, 10),

+                nvSend: parseInt(paramD.sms_nv_send_total, 10),

+                nvDraft: parseInt(paramD.sms_nv_draftbox_total, 10),

+                simReceive: parseInt(paramD.sms_sim_rev_total, 10),

+                simSend: parseInt(paramD.sms_sim_send_total, 10),

+                simDraft: parseInt(paramD.sms_sim_draftbox_total, 10)

+            };

+        }

+    }

+    function connect() {

+        var callback = arguments[1];

+        var checkPoint = 0;

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.notCallback = true;

+            valueReq.goformId = "CONNECT_NETWORK";

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD.result == "success") {

+                checkPoint = new Date().getTime();

+                addCallback(checkConnectStatus);

+            } else {

+                callback({

+                    result: false

+                });

+            }

+        }

+        function checkConnectStatus(paramD) {

+            if (paramD.ppp_status == "ppp_connecting") {

+                informationAll.connectStatus = "ppp_connecting";

+            } else if (paramD.ppp_status == "ppp_connected") {

+                removeCallback(checkConnectStatus);

+                informationAll.connectStatus = "ppp_connected";

+                callback({

+                    result: true,

+                    status: informationAll.connectStatus

+                });

+            } else if (new Date().getTime() - checkPoint < 1e4) {

+                informationAll.connectStatus = "ppp_connecting";

+            } else {

+                removeCallback(checkConnectStatus);

+                callback({

+                    result: false

+                });

+            }

+        }

+    }

+    function disconnect() {

+        var callback = arguments[1];

+        var checkPoint = 0;

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.notCallback = true;

+            valueReq.goformId = "DISCONNECT_NETWORK";

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD.result == "success") {

+                checkPoint = new Date().getTime();

+                addCallback(checkDisconnectStatus);

+            } else {

+                callback({

+                    result: false

+                });

+            }

+        }

+        function checkDisconnectStatus(paramD) {

+            if (paramD.ppp_status == "ppp_disconnecting") {

+                informationAll.connectStatus = "ppp_disconnecting";

+            } else if (paramD.ppp_status == "ppp_disconnected") {

+                removeCallback(checkDisconnectStatus);

+                informationAll.connectStatus = "ppp_disconnected";

+                callback({

+                    result: true,

+                    status: informationAll.connectStatus

+                });

+            } else if (new Date().getTime() - checkPoint < 1e4) {

+                informationAll.connectStatus = "ppp_disconnecting";

+            } else {

+                removeCallback(checkDisconnectStatus);

+                callback({

+                    result: false

+                });

+            }

+        }

+    }

+    function getApnSettings() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "APN_configtmp0,APN_configtmp1,APN_configtmp2,APN_configtmp3,APN_configtmp4,APN_configtmp5,APN_configtmp6,APN_configtmp7,APN_configtmp8,APN_configtmp9," + "APN_configtmp10,APN_configtmp11,APN_configtmp12,APN_configtmp13,APN_configtmp14,APN_configtmp15,APN_configtmp16,APN_configtmp17,APN_configtmp18,APN_configtmp19," + "ipv6_APN_configtmp0,ipv6_APN_configtmp1,ipv6_APN_configtmp2,ipv6_APN_configtmp3,ipv6_APN_configtmp4,ipv6_APN_configtmp5,ipv6_APN_configtmp6,ipv6_APN_configtmp7,ipv6_APN_configtmp8,ipv6_APN_configtmp9," + "ipv6_APN_configtmp10,ipv6_APN_configtmp11,ipv6_APN_configtmp12,ipv6_APN_configtmp13,ipv6_APN_configtmp14,ipv6_APN_configtmp15,ipv6_APN_configtmp16,ipv6_APN_configtmp17,ipv6_APN_configtmp18,ipv6_APN_configtmp19," + "m_profile_name,profile_name,wan_dial,pdp_type,pdp_select,index,Current_index,apn_auto_config,ipv6_apn_auto_config," + "apn_mode,wan_apn,ppp_auth_mode,ppp_username,ppp_passtmp," + "ipv6_wan_apn,ipv6_pdp_type,ipv6_ppp_auth_mode,ipv6_ppp_username,ipv6_ppp_passtmp,apn_num_preset";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(result) {

+            if (result) {

+                return {

+                    APNs: result.APN_configtmp0 + "||" + result.APN_configtmp1 + "||" + result.APN_configtmp2 + "||" + result.APN_configtmp3 + "||" + result.APN_configtmp4 + "||"

+                    +result.APN_configtmp5 + "||" + result.APN_configtmp6 + "||" + result.APN_configtmp7 + "||" + result.APN_configtmp8 + "||" + result.APN_configtmp9 + "||"

+                    +result.APN_configtmp10 + "||" + result.APN_configtmp11 + "||" + result.APN_configtmp12 + "||" + result.APN_configtmp13 + "||" + result.APN_configtmp14 + "||"

+                    +result.APN_configtmp15 + "||" + result.APN_configtmp16 + "||" + result.APN_configtmp17 + "||" + result.APN_configtmp18 + "||" + result.APN_configtmp19,

+                    ipv6APNs: result.ipv6_APN_configtmp0 + "||" + result.ipv6_APN_configtmp1 + "||" + result.ipv6_APN_configtmp2 + "||" + result.ipv6_APN_configtmp3 + "||" + result.ipv6_APN_configtmp4 + "||"

+                    +result.ipv6_APN_configtmp5 + "||" + result.ipv6_APN_configtmp6 + "||" + result.ipv6_APN_configtmp7 + "||" + result.ipv6_APN_configtmp8 + "||" + result.ipv6_APN_configtmp9 + "||"

+                    +result.ipv6_APN_configtmp10 + "||" + result.ipv6_APN_configtmp11 + "||" + result.ipv6_APN_configtmp12 + "||" + result.ipv6_APN_configtmp13 + "||" + result.ipv6_APN_configtmp14 + "||"

+                    +result.ipv6_APN_configtmp15 + "||" + result.ipv6_APN_configtmp16 + "||" + result.ipv6_APN_configtmp17 + "||" + result.ipv6_APN_configtmp18 + "||" + result.ipv6_APN_configtmp19,

+                    apnMode: result.apn_mode,

+                    profileName: result.m_profile_name || result.profile_name,

+                    wanDial: result.wan_dial,

+                    pdpType: result.pdp_type == 'IP' ? 'IP' : result.ipv6_pdp_type,

+                    pdpSelect: result.pdp_select,

+                    index: result.index,

+                    currIndex: result.Current_index,

+                    autoApns: result.apn_auto_config,

+                    autoApnsV6: result.ipv6_apn_auto_config,

+                    wanApn: result.wan_apn,

+                    authMode: result.ppp_auth_mode.toLowerCase(),

+                    username: result.ppp_username,

+                    password: result.ppp_passtmp,

+                    dnsMode: "",

+                    dns1: "",

+                    dns2: "",

+                    wanApnV6: result.ipv6_wan_apn,

+                    authModeV6: result.ipv6_ppp_auth_mode.toLowerCase(),

+                    usernameV6: result.ipv6_ppp_username,

+                    passwordV6: result.ipv6_ppp_passtmp,

+                    dnsModeV6: "",

+                    dns1V6: "",

+                    dns2V6: "",

+                    apnNumPreset: result.apn_num_preset

+                };

+            } else {

+                return {

+                    result: false

+                };

+            }

+        }

+    }

+    function deleteApn() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {

+                apn_action: "delete",

+                apn_mode: "manual",

+                index: values.index

+            };

+            valueReq.goformId = "APN_PROC_EX";

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD.result == "success") {

+                return {

+                    result: true

+                };

+            } else {

+                return {

+                    result: false

+                };

+            }

+        }

+    }

+    function setDefaultApn() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var requestParam = {

+                goformId: "APN_PROC_EX",

+                apn_mode: values.apnMode

+            };

+            if (values.apnMode == 'manual') {

+                requestParam.apn_action = "set_default";

+                requestParam.set_default_flag = "1";

+                requestParam.pdp_type = values.pdpType;

+                requestParam.index = values.index;

+            }

+            return requestParam;

+        }

+        function deal(paramD) {

+            if (paramD.result == "success") {

+                return {

+                    result: true

+                };

+            } else {

+                return {

+                    result: false

+                };

+            }

+        }

+    }

+    function addOrEditApn() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {

+                goformId: "APN_PROC_EX",

+                apn_action: "save",

+                apn_mode: "manual",

+                profile_name: values.profileName,

+                wan_dial: '*99#',

+                pdp_type: values.pdpType,

+                pdp_select: 'auto',

+                index: values.index

+            };

+            if (values.pdpType == "IP") {

+                $.extend(valueReq, {

+                    wan_apn: values.wanApn,

+                    ppp_auth_mode: values.authMode,

+                    ppp_username: values.username,

+                    ppp_passtmp: values.password,

+                });

+            } else if (values.pdpType == "IPv6") {

+                $.extend(valueReq, {

+                    ipv6_wan_apn: values.wanApnV6,

+                    ipv6_ppp_auth_mode: values.authModeV6,

+                    ipv6_ppp_username: values.usernameV6,

+                    ipv6_ppp_passtmp: values.passwordV6

+                });

+            } else {

+                $.extend(valueReq, {

+                    wan_apn: values.wanApn,

+                    ppp_auth_mode: values.authMode,

+                    ppp_username: values.username,

+                    ppp_passtmp: values.password,

+                    dns_mode: values.dnsMode,

+                    prefer_dns_manual: values.dns1,

+                    standby_dns_manual: values.dns2,

+                    ipv6_wan_apn: values.wanApnV6,

+                    ipv6_ppp_auth_mode: values.authModeV6,

+                    ipv6_ppp_username: values.usernameV6,

+                    ipv6_ppp_passtmp: values.passwordV6

+                });

+            }

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD.result == "success") {

+                return {

+                    result: true

+                };

+            } else {

+                return {

+                    result: false

+                };

+            }

+        }

+    }

+    var timerQueryString = ["modem_main_state", "pin_status", "blc_wan_mode", "blc_wan_auto_mode", "loginfo", "fota_new_version_state", "fota_current_upgrade_state", "fota_upgrade_selector", "network_provider", "is_mandatory", "sta_count", "m_sta_count"];

+    var loginTimerQueryString = ["signalbar", "network_type", "sub_network_type", "ppp_status", "rj45_state", "EX_SSID1", "sta_ip_status", "EX_wifi_profile", "m_ssid_enable", "wifi_cur_state", "SSID1", "simcard_roam", "lan_ipaddr", "battery_charging", "battery_vol_percent", "battery_pers", "spn_name_data", "spn_b1_flag", "spn_b2_flag", "realtime_tx_bytes", "realtime_rx_bytes", "realtime_time", "realtime_tx_thrpt", "realtime_rx_thrpt", "monthly_rx_bytes", "monthly_tx_bytes", "traffic_alined_delta", "monthly_time", "date_month", "data_volume_limit_switch", "data_volume_limit_size", "data_volume_alert_percent", "data_volume_limit_unit", "roam_setting_option", "upg_roam_switch", "fota_package_already_download", 'ssid', 'dial_mode', 'ethwan_mode', 'default_wan_name'];

+    if (config.HAS_SMS) {

+        $.merge(loginTimerQueryString, ["sms_received_flag", "sts_received_flag", 'sms_unread_num']);

+    }

+    var timerCallbackStack = [];

+    var timerCallbacks = [timerUpdateStatus];

+    function timerUpdater() {

+        if (!updateTimerFlag) {

+            setTimeout(function () {

+                timerUpdater();

+            }, 1000);

+            return;

+        }

+        var queryParams = checkTimerUpdaterParameters();

+        reqAsync(queryParams, function (paramD) {

+            for (var i = 0; i < timerCallbacks.length; i++) {

+                if (typeof timerCallbacks[i] === "function") {

+                    timerCallbacks[i](paramD);

+                }

+            }

+            $.merge(timerCallbacks, timerCallbackStack);

+            timerCallbackStack = [];

+            setTimeout(function () {

+                timerUpdater();

+            }, 1000);

+        }, function () {

+            timerUpdaterErrorCallback();

+            setTimeout(function () {

+                timerUpdater();

+            }, 1000);

+        }, false);

+    }

+    function checkTimerUpdaterParameters() {

+        var queryParams = {

+            multi_data: 1,

+        };

+        if (window.location.hash && window.location.hash != '#entry' && informationAll.isLoggedIn) {

+            if (config.HAS_SMS) {

+                queryParams.sms_received_flag_flag = 0;

+                queryParams.sts_received_flag_flag = 0;

+            }

+            if (loginTimerQueryString.length > 0 && _.indexOf(timerQueryString, loginTimerQueryString[0]) == -1) {

+                $.each(loginTimerQueryString, function (i, n) {

+                    timerQueryString.push(n);

+                });

+            }

+        } else {

+            if (loginTimerQueryString.length > 0 && _.indexOf(timerQueryString, loginTimerQueryString[0]) != -1) {

+                timerQueryString = _.without(timerQueryString, loginTimerQueryString);

+            }

+        }

+        queryParams.cmd = timerQueryString.join(",");

+        return queryParams;

+    }

+    function addCallback(cb) {

+        if (_.indexOf(timerCallbackStack, cb) == -1) {

+            timerCallbackStack.push(cb);

+        }

+    }

+    function removeCallback(cb) {

+        timerCallbacks = _.without(timerCallbacks, cb);

+        if (timerCallbacks.length == 0) {

+            timerCallbacks.push(timerUpdateStatus);

+        }

+        return timerCallbackStack;

+    }

+    function addQueryString(query) {

+        if (_.indexOf(timerQueryString, query) == -1) {

+            timerQueryString.push(query);

+        }

+    }

+    function removeQueryString(query) {

+        timerQueryString = _.without(timerQueryString, query);

+        return timerQueryString;

+    }

+    function timerUpdateStatus(paramD) {

+        informationAll.defaultWanName = paramD.default_wan_name;

+        informationAll.signalImg = typeof paramD.signalbar == 'undefined' ? '0' : paramD.signalbar;

+        informationAll.networkType = paramD.sub_network_type ? paramD.sub_network_type : (paramD.network_type ? paramD.network_type : '');

+        if (informationAll.networkType.toLowerCase().indexOf("limited_service") != -1 || informationAll.networkType.toLowerCase().indexOf("limited service") != -1) {

+            informationAll.networkType = "limited_service";

+        } else if (informationAll.networkType.toLowerCase().indexOf("no_service") != -1 || informationAll.networkType.toLowerCase().indexOf("no service") != -1) {

+            informationAll.networkType = "no_service";

+        }

+        informationAll.networkOperator = paramD.network_provider ? paramD.network_provider : '';

+        informationAll.spn_b1_flag = paramD.spn_b1_flag;

+        informationAll.spn_b2_flag = paramD.spn_b2_flag;

+        informationAll.spn_name_data = paramD.spn_name_data;

+        informationAll.connectStatus = typeof paramD.ppp_status == 'undefined' ? 'ppp_disconnected' : paramD.ppp_status;

+        informationAll.rj45ConnectStatus = (typeof paramD.rj45_state == 'undefined' || paramD.rj45_state == '') ? 'dead' : paramD.rj45_state;

+        informationAll.ethWanMode = paramD.ethwan_mode;

+        informationAll.ssid1AttachedNum = paramD.sta_count == "" ? 0 : parseInt(paramD.sta_count, 10);

+        informationAll.ssid2AttachedNum = paramD.m_sta_count == "" ? 0 : parseInt(paramD.m_sta_count, 10);

+        informationAll.roamingStatus = getRoamStatus(informationAll.networkType, paramD.modem_main_state, paramD.simcard_roam);

+        informationAll.wifiStatus = paramD.wifi_cur_state == "1";

+        informationAll.simStatus = paramD.modem_main_state;

+        informationAll.pinStatus = paramD.pin_status;

+        var needMinutes = 3 * 60 * 60;

+        var batteryLevel = (paramD.battery_vol_percent && paramD.battery_vol_percent.length > 0) ? paramD.battery_vol_percent : 100;

+        informationAll.batteryPers = paramD.battery_pers;

+        var remainMinutes = Math.round(needMinutes * (1 - batteryLevel / 100));

+        informationAll.batteryStatus = (typeof paramD.battery_charging == 'undefined') ? '0' : paramD.battery_charging;

+        informationAll.batteryLevel = batteryLevel;

+        informationAll.batteryTime = remainMinutes.toString();

+        informationAll.data_counter = {

+            uploadRate: paramD.realtime_tx_thrpt == '' ? 0 : paramD.realtime_tx_thrpt,

+            downloadRate: paramD.realtime_rx_thrpt == '' ? 0 : paramD.realtime_rx_thrpt,

+            currentSent: paramD.realtime_tx_bytes == '' ? 0 : paramD.realtime_tx_bytes,

+            currentReceived: paramD.realtime_rx_bytes == '' ? 0 : paramD.realtime_rx_bytes,

+            currentConnectedTime: paramD.realtime_time == '' ? 0 : paramD.realtime_time,

+            monthlySent: paramD.monthly_tx_bytes == '' ? 0 : paramD.monthly_tx_bytes,

+            monthlyReceived: paramD.monthly_rx_bytes == '' ? 0 : paramD.monthly_rx_bytes,

+            traffic_alined_delta: paramD.traffic_alined_delta == '' ? 0 : paramD.traffic_alined_delta,

+            monthlyConnectedTime: paramD.monthly_time == '' ? 0 : paramD.monthly_time,

+            month: paramD.date_month == '' ? 1 : paramD.date_month

+        };

+        informationAll.ssid = paramD.SSID1;

+        informationAll.authMode = paramD.AuthMode;

+        informationAll.isLoggedIn = config.HAS_LOGIN ? paramD.loginfo == "ok" : true;

+        if (config.HAS_SMS) {

+            if (!informationAll.newSmsReceived) {

+                informationAll.newSmsReceived = paramD.sms_received_flag > 0;

+            }

+            if (!informationAll.smsReportReceived) {

+                informationAll.smsReportReceived = paramD.sts_received_flag > 0;

+            }

+            if (typeof paramD.sms_dev_unread_num != "undefined") {

+                informationAll.smsUnreadCount = config.SMS_UNREAD_NUM_INCLUDE_SIM ? parseInt(paramD.sms_dev_unread_num | 0, 10) + parseInt(paramD.sms_sim_unread_num | 0, 10) : parseInt(paramD.sms_dev_unread_num | 0, 10);

+            } else {

+                informationAll.smsUnreadCount = parseInt(paramD.sms_unread_num | 0, 10)

+            }

+        }

+        if (paramD.data_volume_limit_switch == '1') {

+            informationAll.limitVolumeEnable = true;

+            informationAll.limitVolumeType = paramD.data_volume_limit_unit == 'data' ? '1' : '0';

+            informationAll.limitVolumePercent = paramD.data_volume_alert_percent;

+            if (paramD.data_volume_limit_unit == 'data') {

+                var limitMonth = paramD.data_volume_limit_size.split("_");

+                informationAll.limitVolumeSize = limitMonth[0] * limitMonth[1] * 1024 * 1024;

+            } else {

+                informationAll.limitVolumeSize = paramD.data_volume_limit_size * 60 * 60;

+            }

+        } else {

+            informationAll.limitVolumeEnable = false;

+            informationAll.limitVolumeType = '1';

+            informationAll.limitVolumePercent = '100';

+            informationAll.limitVolumeSize = '0';

+        }

+        informationAll.connectWifiProfile = paramD.EX_wifi_profile;

+        informationAll.connectWifiSSID = paramD.EX_SSID1;

+        informationAll.connectWifiStatus = paramD.sta_ip_status;

+        informationAll.multi_ssid_enable = paramD.m_ssid_enable;

+        informationAll.roamMode = paramD.roam_setting_option;

+        if (paramD.blc_wan_mode == "AUTO") {

+            informationAll.blc_wan_mode = paramD.blc_wan_auto_mode ? paramD.blc_wan_auto_mode : 'AUTO_PPP';

+        } else {

+            informationAll.blc_wan_mode = paramD.blc_wan_mode ? paramD.blc_wan_mode : 'PPP';

+        }

+        informationAll.new_version_state = paramD.fota_new_version_state == "has_critical" || paramD.fota_new_version_state == "has_optional" || paramD.fota_new_version_state == "already_has_pkg";

+        informationAll.current_upgrade_state = paramD.fota_current_upgrade_state;

+        if (informationAll.current_upgrade_state == "verify_failed") {

+            informationAll.current_upgrade_state = "upgrade_pack_error";

+        }

+        informationAll.fota_user_selector = paramD.fota_upgrade_selector;

+        informationAll.is_mandatory = paramD.is_mandatory == "1" || paramD.fota_new_version_state == "has_critical";

+        informationAll.allowRoamingUpdate = paramD.upg_roam_switch;

+        informationAll.dialMode = paramD.dial_mode;

+        informationAll.fota_package_already_download = paramD.fota_package_already_download;

+    }

+    function timerUpdaterErrorCallback() {

+        informationAll.batteryStatus = '0';

+    }

+    function getRoamStatus(networkType, modemState, simcardRoam) {

+        if (("" == $.trim(networkType)) || "no_service" == networkType.toLowerCase() || "limited_service" == networkType.toLowerCase() || "modem_sim_undetected" == modemState || "modem_waitpin" == modemState || "modem_waitpuk" == modemState) {

+            return false;

+        }

+        if ("Internal" == simcardRoam || "International" == simcardRoam) {

+            return true;

+        } else {

+            return false;

+        }

+    }

+    $(document).ready(function () {

+        setTimeout(function () {

+            timerUpdater();

+        }, 0);

+    });

+    function setNetwork(strNetworkNumber, nRat, nSubAct, callback) {

+        if ((typeof(strNetworkNumber) !== "string") || (strNetworkNumber === "") || (typeof(nRat) !== "number") || (isNaN(nRat))) {

+            if (typeof(callback) === "function") {

+                callback(false);

+                return;

+            }

+        }

+        var nRat1 = -1;

+        if (nRat === 0) {

+            nRat1 = 0;

+        } else if (nRat === 2) {

+            nRat1 = 2;

+        } else if (nRat == 7) {

+            nRat1 = 7;

+        } else {

+            nRat1 = -1;

+        }

+        if (-1 === nRat1) {

+            if (typeof(callback) === "function") {

+                callback(false);

+                return;

+            }

+        }

+        var SubAct;

+        if (nSubAct.toString() == "NaN") {

+            SubAct = "";

+        } else {

+            SubAct = nSubAct;

+        }

+        reqAsync({

+            goformId: "SET_NETWORK",

+            NetworkNumber: strNetworkNumber,

+            Rat: nRat,

+            nSubrat: SubAct

+        }, function (paramD) {

+            if (paramD && paramD.result == "success") {

+                var flag;

+                var counter = 0;

+                var timer = setInterval(function () {

+                    var obj = reqSync({

+                        cmd: 'm_netselect_result',

+                    }, false);

+                    if (!obj) {

+                        callback(false);

+                        return;

+                    }

+                    if (obj.m_netselect_result == "manual_success") {

+                        flag = "1";

+                        window.clearInterval(timer);

+                        callback(true);

+                    } else if (obj.m_netselect_result == "manual_fail") {

+                        flag = "0";

+                        window.clearInterval(timer);

+                        callback(false);

+                    } else if (counter < 120) {

+                        counter++;

+                    } else {

+                        window.clearInterval(timer);

+                        callback(false);

+                    }

+                }, 1000);

+            } else {

+                callback(false);

+            }

+        }, function (paramD) {

+            callback(false);

+        }, true);

+    }

+    function savePhoneBook() {

+        var callback = arguments[1];

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.notCallback = true;

+            valueReq.goformId = "PBM_CONTACT_ADD";

+            valueReq.location = values.location;

+            valueReq.name = encodeMessage(values.name);

+            valueReq.mobilephone_num = values.mobile_phone_number;

+            if (valueReq.location == 1) {

+                valueReq.add_index_pc = values.index;

+                valueReq.homephone_num = values.home_phone_number;

+                valueReq.officephone_num = values.office_phone_number;

+                valueReq.email = encodeMessage(values.mail);

+                valueReq.groupchoose = values.group;

+                if (!valueReq.groupchoose) {

+                    valueReq.groupchoose = "common";

+                }

+            } else {

+                valueReq.edit_index = values.index;

+            }

+            if (values.delId != undefined) {

+                valueReq.delId = values.delId;

+            }

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == "success") {

+                addTimerSomething("pbm_write_flag", checkSavePhoneBook);

+            } else {

+                callback(paramD);

+            }

+        }

+        function checkSavePhoneBook(paramD) {

+            checkPbmWriteFlag(paramD, callback, checkSavePhoneBook);

+        }

+    }

+    function checkPbmWriteFlag(paramD, callback, fn) {

+        if (paramD.pbm_write_flag == "0") {

+            removeTimerSomething("pbm_write_flag", fn);

+            callback({

+                result: "success"

+            });

+        } else if (paramD.pbm_write_flag == "6" || paramD.pbm_write_flag == "7" || paramD.pbm_write_flag == "8" || paramD.pbm_write_flag == "9" || paramD.pbm_write_flag == "10" || paramD.pbm_write_flag == "11" || paramD.pbm_write_flag == "14") {

+            removeTimerSomething("pbm_write_flag", fn);

+            callback({

+                result: "fail"

+            });

+        } else {}

+    }

+    function deletePhoneBooks() {

+        var callback = arguments[1];

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.notCallback = true;

+            valueReq.goformId = "PBM_CONTACT_DEL";

+            valueReq.del_option = "delete_num";

+            valueReq.delete_id = values.indexs.join(",");

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == "success") {

+                addTimerSomething("pbm_write_flag", checkDeletePhoneBooks);

+            } else {

+                callback(paramD);

+            }

+        }

+        function checkDeletePhoneBooks(paramD) {

+            checkPbmWriteFlag(paramD, callback, checkDeletePhoneBooks);

+        }

+    }

+    function deleteAllPhoneBooks() {

+        var callback = arguments[1];

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.notCallback = true;

+            valueReq.goformId = "PBM_CONTACT_DEL";

+            valueReq.del_option = "delete_all";

+            valueReq.del_all_location = values.location;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == "success") {

+                addTimerSomething("pbm_write_flag", checkDeleteAllPhoneBooks);

+            } else {

+                callback(paramD);

+            }

+        }

+        function checkDeleteAllPhoneBooks(paramD) {

+            checkPbmWriteFlag(paramD, callback, checkDeleteAllPhoneBooks);

+        }

+    }

+    function deleteAllPhoneBooksByGroup() {

+        var callback = arguments[1];

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.notCallback = true;

+            valueReq.goformId = "PBM_CONTACT_DEL";

+            valueReq.del_option = "delete_all_by_group";

+            valueReq.del_all_location = 3;

+            valueReq.del_group = values.group;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == "success") {

+                addTimerSomething("pbm_write_flag", checkDeleteAllPhoneBooksByGroup);

+            } else {

+                callback(paramD);

+            }

+        }

+        function checkDeleteAllPhoneBooksByGroup(paramD) {

+            checkPbmWriteFlag(paramD, callback, checkDeleteAllPhoneBooksByGroup);

+        }

+    }

+    function setConnectionMode() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "SET_CONNECTION_MODE";

+            valueReq.ConnectionMode = values.connectionMode;

+            valueReq.roam_setting_option = values.isAllowedRoaming;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                callback(paramD);

+            }

+        }

+    }

+    function getConnectionMode() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "ConnectionMode";

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var result = {};

+                result.connectionMode = paramD.connectionMode;

+                result.isAllowedRoaming = paramD.autoConnectWhenRoaming;

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function _getPhoneBooks(array, location) {

+        if (array[0].data_per_page == 0) {

+            return {

+                "pbm_data": []

+            };

+        }

+        return stuffMake(array, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.mem_store = location;

+            if (location == 2) {

+                valueReq.cmd = "pbm_data_total";

+            } else {

+                valueReq.cmd = "pbm_data_info";

+            }

+            valueReq.page = values.page;

+            valueReq.data_per_page = values.data_per_page;

+            valueReq.orderBy = values.orderBy;

+            valueReq.isAsc = values.isAsc;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.pbm_data) {

+                var books = [];

+                $.each(paramD.pbm_data, function (i) {

+                    books.push({

+                        pbm_id: paramD.pbm_data[i].pbm_id,

+                        pbm_location: paramD.pbm_data[i].pbm_location,

+                        pbm_number: paramD.pbm_data[i].pbm_number,

+                        pbm_anr: paramD.pbm_data[i].pbm_anr,

+                        pbm_anr1: paramD.pbm_data[i].pbm_anr1,

+                        pbm_group: paramD.pbm_data[i].pbm_group,

+                        pbm_name: decodeMessage(paramD.pbm_data[i].pbm_name),

+                        pbm_email: decodeMessage(paramD.pbm_data[i].pbm_email)

+                    });

+                });

+                return {

+                    pbm_data: books

+                };

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getPhoneBooksByGroup() {

+        if (arguments[0].data_per_page == 0) {

+            return {

+                "pbm_data": []

+            };

+        }

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "pbm_data_total";

+            valueReq.mem_store = 3;

+            valueReq.pbm_group = values.group;

+            valueReq.page = values.page;

+            valueReq.data_per_page = values.data_per_page;

+            valueReq.orderBy = values.orderBy;

+            valueReq.isAsc = values.isAsc;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.pbm_data) {

+                var books = [];

+                $.each(paramD.pbm_data, function (i) {

+                    books.push({

+                        pbm_id: paramD.pbm_data[i].pbm_id,

+                        pbm_location: paramD.pbm_data[i].pbm_location,

+                        pbm_number: paramD.pbm_data[i].pbm_number,

+                        pbm_anr: paramD.pbm_data[i].pbm_anr,

+                        pbm_anr1: paramD.pbm_data[i].pbm_anr1,

+                        pbm_group: paramD.pbm_data[i].pbm_group,

+                        pbm_name: decodeMessage(paramD.pbm_data[i].pbm_name),

+                        pbm_email: decodeMessage(paramD.pbm_data[i].pbm_email)

+                    });

+                });

+                return {

+                    pbm_data: books

+                };

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getDevicePhoneBooks() {

+        return _getPhoneBooks(arguments, 1);

+    }

+    function getSIMPhoneBooks() {

+        return _getPhoneBooks(arguments, 0);

+    }

+    function getPhoneBooks() {

+        return _getPhoneBooks(arguments, 2);

+    }

+    function getPhoneBookReady() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "pbm_init_flag";

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getPhoneBookCapacity(array, isSIM) {

+        return stuffMake(array, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "pbm_capacity_info";

+            if (isSIM) {

+                valueReq.pbm_location = "pbm_sim";

+            } else {

+                valueReq.pbm_location = "pbm_native";

+            }

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getSIMPhoneBookCapacity() {

+        var paramD = getPhoneBookCapacity(arguments, true);

+        return {

+            simPbmTotalCapacity: parseInt(paramD.pbm_sim_max_record_num),

+            simPbmUsedCapacity: parseInt(paramD.pbm_sim_used_record_num),

+            simType: paramD.pbm_sim_type,

+            maxNameLen: parseInt(paramD.pbm_sim_max_name_len),

+            maxNumberLen: parseInt(paramD.pbm_sim_max_number_len) > 40 ? 40 : parseInt(paramD.pbm_sim_max_number_len)

+        };

+    }

+    function getDevicePhoneBookCapacity() {

+        var paramD = getPhoneBookCapacity(arguments, false);

+        return {

+            pcPbmTotalCapacity: parseInt(paramD.pbm_dev_max_record_num),

+            pcPbmUsedCapacity: parseInt(paramD.pbm_dev_used_record_num)

+        };

+    }

+    function getAttachedCableDevices() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var obj = {

+                cmd: "lan_station_list"

+            };

+            return obj;

+        }

+        function deal(paramD) {

+            var deviceArr = [];

+            var attachedDevices = paramD.lan_station_list || paramD.station_list;

+            for (var i = 0; attachedDevices && i < attachedDevices.length; i++) {

+                var obj = {};

+                obj.macAddress = attachedDevices[i].mac_addr;

+                var hostname = attachedDevices[i].hostname;

+                obj.hostName = hostname == "" ? $.i18n.prop("unknown") : hostname;

+                obj.ipAddress = attachedDevices[i].ip_addr;

+                deviceArr.push(obj);

+            }

+            return {

+                attachedDevices: deviceArr

+            };

+        }

+    }

+    function getCurrentlyAttachedDevicesInfo() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var obj = {

+                cmd: "station_list"

+            };

+            return obj;

+        }

+        function deal(paramD) {

+            var deviceArr = [];

+            var attachedDevices = paramD.station_list;

+            for (var i = 0; attachedDevices && i < attachedDevices.length; i++) {

+                var obj = {};

+                obj.macAddress = attachedDevices[i].mac_addr;

+                var hostname = attachedDevices[i].hostname;

+                obj.hostName = hostname == "" ? $.i18n.prop("unknown") : hostname;

+                obj.ipAddress = attachedDevices[i].ip_addr;

+                deviceArr.push(obj);

+            }

+            return {

+                attachedDevices: deviceArr

+            };

+        }

+    }	

+

+    function setLanguage() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "SET_WEB_LANGUAGE";

+            valueReq.Language = values.Language;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getLanguage() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "Language";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var result = {};

+                result.Language = (paramD && paramD.Language) ? paramD.Language : "en";

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }	

+

+    function setBearerPreference() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "SET_BEARER_PREFERENCE";

+            valueReq.BearerPreference = values.strBearerPreference;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function scanForNetwork(callback) {

+        $.post("/reqproc/proc_post", {

+            goformId: "SCAN_NETWORK"

+        }, function (paramD) {

+            if (paramD.result == "success") {

+                checkScanStatus();

+            } else {

+                callback(false, []);

+            }

+        }, "json").error(function () {

+            callback(false, []);

+        });

+        function checkScanStatus() {

+            $.getJSON("/reqproc/proc_get", {

+                cmd: "m_netselect_status",

+                "_": new Date().getTime()

+            }, function (paramD) {

+                if (paramD.m_netselect_status == "manual_selecting") {

+                    setTimeout(checkScanStatus, 1000);

+                } else {

+                    $.getJSON("/reqproc/proc_get", {

+                        cmd: "m_netselect_contents",

+                        "_": new Date().getTime()

+                    }, function (paramD2) {

+                        if (trim(paramD2.m_netselect_contents) != "") {

+                            parseScanResult(paramD2.m_netselect_contents);

+                        } else {

+                            callback(false, []);

+                        }

+                    }).error(function () {

+                        callback(false, []);

+                    });

+                }

+            }).error(function () {

+                callback(false, []);

+            });

+        }

+        function parseScanResult(result) {

+            var pattern = /([^,;]*),([^,]*),([^,]*),([^,]*),([^,;]*)/g;

+            var listNetwork = [];

+            var mts;

+            var unit = result.split(";");

+            var unitString = "";

+            for (i = 0; i < unit.length; i++) {

+                var unitLength = unit[i].split(",").length;

+                if (unitLength == 4) {

+                    unitString += unit[i] + ",NON;";

+                } else {

+                    unitString += unit[i] + ";";

+                }

+            }

+            while (mts = pattern.exec(unitString)) {

+                if (mts != null) {

+                    listNetwork.push({

+                        strShortName: mts[2].replace(/\"/g, ''),

+                        strNumeric: mts[3].replace(/\D/g, ''),

+                        nRat: parseInt(mts[4], 10),

+                        nState: parseInt(mts[1], 10),

+                        SubAct: parseInt(mts[5], 10)

+                    });

+                }

+            }

+            callback(true, listNetwork);

+        }

+    }

+	    function getNetSelectInfo() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "current_network_mode,m_netselect_save,net_select_mode,m_netselect_contents,net_select,ppp_status,modem_main_state";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var result = {};

+                result.current_network_mode = paramD.current_network_mode;

+                result.net_select_mode = paramD.net_select_mode;

+                result.m_netselect_save = paramD.m_netselect_save;

+                result.m_netselect_contents = paramD.m_netselect_contents;

+                result.net_select = paramD.net_select;

+                result.ppp_status = paramD.ppp_status;

+                result.modem_main_state = paramD.modem_main_state;

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }	

+

+    function getSMSMessages() {

+        return stuffMake(arguments, {}, prepare, deal, {}, false);

+        function prepare(values, isPost) {

+            var obj = {

+                cmd: "sms_data_total",

+                page: values.page,

+                data_per_page: config.SMS_DATABASE_SORT_SUPPORT ? values.smsCount : 500,

+                mem_store: values.nMessageStoreType,

+                tags: values.tags,

+                order_by: values.orderBy

+            };

+            return obj;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.messages && paramD.messages.length > 0) {

+                return {

+                    messages: parseMessages(paramD.messages)

+                };

+            } else {

+                return {

+                    messages: []

+                };

+            }

+        }

+    }

+    function parseMessages(messages, isReport) {

+        var result = [];

+        for (var i = 0; i < messages.length; i++) {

+            if (!config.SHOW_UN_COMPLETE_CONCAT_SMS && typeof messages[i].received_all_concat_sms != "undefined" && messages[i].received_all_concat_sms == '0') {

+                continue;

+            }

+            var oneMessage = {};

+            oneMessage.id = messages[i].id;

+            oneMessage.number = messages[i].number;

+            oneMessage.content = isReport ? messages[i].content : decodeMessageContent(messages[i].content);

+            oneMessage.time = transTime('20' + messages[i].date);

+            oneMessage.isNew = messages[i].tag == "1";

+            oneMessage.groupId = messages[i].draft_group_id;

+            oneMessage.tag = messages[i].tag;

+            oneMessage.receivedAll = messages[i].received_all_concat_sms == '1';

+            result.push(oneMessage);

+        }

+        if (!config.SMS_DATABASE_SORT_SUPPORT) {

+            var ids = [];

+            var tmpResult = [];

+            for (var i = result.length; i--; ) {

+                var n = result[i];

+                var idx = $.inArray(n.id, ids);

+                if (idx == -1) {

+                    ids.push(n.id);

+                    tmpResult.push(n);

+                } else {

+                    if (n.content.length > tmpResult[idx].content.length) {

+                        tmpResult[idx] = n;

+                    }

+                }

+            }

+            return _.sortBy(tmpResult, function (n) {

+                return 0 - n.id;

+            });

+        } else {

+            return result;

+        }

+    }

+    function decodeMessageContent(msgContent) {

+        return decodeMessage(escapeMessage(msgContent));

+    }

+    function sendSMS() {

+        var callback = arguments[1];

+        var errorCabllback = arguments[2] ? arguments[2] : callback;

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var obj = {

+                goformId: "SEND_SMS",

+                notCallback: true,

+                Number: values.number,

+                sms_time: getCurrentTimeString(),

+                MessageBody: escapeMessage(encodeMessage(values.message)),

+                ID: values.id,

+                encode_type: getEncodeType(values.message).encodeType

+            };

+            return obj;

+        }

+        function deal(paramD) {

+            if (!paramD) {

+                errorCabllback($.extend(errUnknownObj, {

+                        errorType: "sendFail",

+                        errorText: "send_fail_try_again"

+                    }));

+                return;

+            }

+            if (paramD.result == "success") {

+                setTimeout(function () {

+                    getSmsStatusInfo({

+                        smsCmd: 4,

+                        errorType: "sendFail",

+                        errorText: "send_fail_try_again"

+                    }, callback, errorCabllback);

+                }, 1000);

+            } else {

+                errorCabllback($.extend(errUnknownObj, {

+                        errorType: "sendFail",

+                        errorText: "send_fail_try_again"

+                    }));

+            }

+        }

+    }

+    function saveSMS() {

+        var callback = arguments[1];

+        var errorCabllback = arguments[2] ? arguments[2] : callback;

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var obj = {

+                notCallback: true,

+                goformId: "SAVE_SMS",

+                SMSMessage: escapeMessage(encodeMessage(values.message)),

+                SMSNumber: values.numbers.join(";") + ";",

+                Index: values.index,

+                encode_type: getEncodeType(values.message).encodeType,

+                sms_time: values.currentTimeString,

+                draft_group_id: values.groupId

+            };

+            return obj;

+        }

+        function deal(paramD) {

+            if (!paramD) {

+                errorCabllback($.extend(errUnknownObj, {

+                        errorType: "saveFail",

+                        errorText: "save_fail"

+                    }));

+                return;

+            }

+            if (paramD.result == "success") {

+                getSmsStatusInfo({

+                    smsCmd: 5,

+                    errorType: "saveFail",

+                    errorText: "save_fail"

+                }, callback, errorCabllback);

+            } else {

+                errorCabllback($.extend(errUnknownObj, {

+                        errorType: "saveFail",

+                        errorText: "save_fail"

+                    }));

+            }

+        }

+    }

+    function deleteAllMessages() {

+        var callback = arguments[1];

+        var errorCabllback = arguments[2] ? arguments[2] : callback;

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var obj = {

+                goformId: "ALL_DELETE_SMS",

+                notCallback: true,

+                which_cgi: values.location

+            };

+            return obj;

+        }

+        function deal(paramD) {

+            if (!paramD) {

+                errorCabllback($.extend(errUnknownObj, {

+                        errorType: "deleteFail",

+                        errorText: "delete_fail_try_again"

+                    }));

+                return;

+            }

+            if (paramD.result == "success") {

+                addTimerSomething("sms_cmd_status_info", checkDeleteStatus);

+            } else {

+                errorCabllback($.extend(errUnknownObj, {

+                        errorType: "deleteFail",

+                        errorText: "delete_fail_try_again"

+                    }));

+            }

+        }

+        function checkDeleteStatus(paramD) {

+            var status = paramD.sms_cmd_status_info;

+            if (status == "2") {

+                removeTimerSomething("sms_cmd_status_info", checkDeleteStatus);

+                errorCabllback($.extend(errUnknownObj, {

+                        errorType: "deleteFail",

+                        errorText: "delete_fail_try_again"

+                    }));

+            } else if (status == "3") {

+                removeTimerSomething("sms_cmd_status_info", checkDeleteStatus);

+                callback({

+                    result: true

+                });

+            }

+        }

+    }

+    function deleteMessage() {

+        var callback = arguments[1];

+        var errorCabllback = arguments[2] ? arguments[2] : callback;

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var msgIds = values.ids.join(";") + ";";

+            var obj = {

+                goformId: "DELETE_SMS",

+                msg_id: msgIds,

+                notCallback: true

+            };

+            return obj;

+        }

+        function deal(paramD) {

+            if (!paramD) {

+                errorCabllback($.extend(errUnknownObj, {

+                        errorType: "deleteFail",

+                        errorText: "delete_fail_try_again"

+                    }));

+                return;

+            }

+            if (paramD.result == "success") {

+                getSmsStatusInfo({

+                    smsCmd: 6,

+                    errorType: "deleteFail",

+                    errorText: "delete_fail_try_again"

+                }, callback, errorCabllback);

+            } else {

+                errorCabllback($.extend(errUnknownObj, {

+                        errorType: "deleteFail",

+                        errorText: "delete_fail_try_again"

+                    }));

+            }

+        }

+    }

+    function getSmsStatusInfo(obj, callback, errorCabllback) {

+        reqAsync({

+            cmd: "sms_cmd_status_info",

+            sms_cmd: obj.smsCmd,

+        }, function (paramD) {

+            if (paramD) {

+                var status = paramD.sms_cmd_status_result;

+                if (status == "2") {

+                    errorCabllback($.extend(errUnknownObj, {

+                            errorType: obj.errorType,

+                            errorText: obj.errorText

+                        }));

+                } else if (status == "3") {

+                    callback({

+                        result: "success"

+                    });

+                } else {

+                    window.setTimeout(function () {

+                        getSmsStatusInfo(obj, callback, errorCabllback);

+                    }, 1000);

+                }

+            } else {

+                errorCabllback($.extend(errUnknownObj, {

+                        errorType: obj.errorType,

+                        errorText: obj.errorText

+                    }));

+            }

+        }, function (paramD) {

+            errorCabllback($.extend(errUnknownObj, {

+                    errorType: obj.errorType,

+                    errorText: obj.errorText

+                }));

+        }, false);

+    }

+    function getSMSReady() {

+        if (config.smsIsReady) {

+            var callback = arguments[1];

+            if (callback) {

+                return callback({

+                    "sms_cmd": "1",

+                    "sms_cmd_status_result": "3"

+                });

+            } else {

+                return {

+                    "sms_cmd": "1",

+                    "sms_cmd_status_result": "3"

+                };

+            }

+        } else {

+            return stuffMake(arguments, {}, prepare, deal, null, false);

+        }

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "sms_cmd_status_info";

+            valueReq.sms_cmd = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                if (paramD.sms_cmd_status_result == "3") {

+                    config.smsIsReady = true;

+                }

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setSmsRead() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var msgIds = values.ids.join(";");

+            if (values.ids.length > 0) {

+                msgIds += ";";

+            }

+            var obj = {

+                goformId: "SET_MSG_READ",

+                msg_id: msgIds,

+                tag: 0

+            };

+            return obj;

+        }

+        function deal(paramD) {

+            if (paramD.result == "success") {

+                return {

+                    result: true

+                };

+            } else {

+                return {

+                    result: false

+                };

+            }

+        }

+    }

+    function getSMSDeliveryReport() {

+        return stuffMake(arguments, {}, prepare, deal, {}, false);

+        function prepare(values, isPost) {

+            var obj = {

+                cmd: "sms_status_rpt_data",

+                page: values.page,

+                data_per_page: values.smsCount

+            };

+            return obj;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return {

+                    messages: parseMessages(paramD.messages, true)

+                };

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function logout() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var obj = $.extend({}, values);

+            obj.goformId = "LOGOUT";

+            return obj;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == "success") {

+                informationAll.isLoggedIn = false;

+                return {

+                    result: true

+                };

+            } else {

+                return $.extend(errUnknownObj, {

+                    errorType: "loggedOutError"

+                });

+            }

+        }

+    }

+    function changeManageInfo() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var obj = {};

+            obj.newPassword = config.PASSWORD_ENCODE ? Base64.encode(values.newValue) : values.newValue;

+            obj.oldPassword = config.PASSWORD_ENCODE ? Base64.encode(values.oldValue) : values.oldValue;

+            obj.goformId = "CHANGE_PASSWORD";

+            return obj;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result === "success") {

+                return {

+                    result: true

+                };

+            } else {

+                return $.extend(errUnknownObj, {

+                    errorType: "badPassword"

+                });

+            }

+        }

+    }

+    function getPinData() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "pinnumber,pin_status,puknumber";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function enablePin() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var obj = {};

+            obj.goformId = "ENABLE_PIN";

+            obj.OldPinNumber = values.oldPin;

+            return obj;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result === "success") {

+                return {

+                    result: true

+                };

+            } else {

+                return {

+                    result: false

+                };

+            }

+        }

+    }

+    function disablePin() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var obj = {};

+            obj.goformId = "DISABLE_PIN";

+            obj.OldPinNumber = values.oldPin;

+            return obj;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result === "success") {

+                return {

+                    result: true

+                };

+            } else {

+                return {

+                    result: false

+                };

+            }

+        }

+    }

+    function changePin() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var obj = {};

+            obj.goformId = "ENABLE_PIN";

+            obj.OldPinNumber = values.oldPin;

+            obj.NewPinNumber = values.newPin;

+            return obj;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result === "success") {

+                return {

+                    result: true

+                };

+            } else {

+                return {

+                    result: false

+                };

+            }

+        }

+    }

+    function getLanInfo() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "lan_ipaddr,lan_netmask,mac_address,dhcpEnabled,dhcpStart,dhcpEnd,dhcpLease_hour";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var result = {};

+                result.ipAddress = paramD.lan_ipaddr;

+                result.subnetMask = paramD.lan_netmask;

+                result.macAddress = paramD.mac_address;

+                result.dhcpServer = paramD.dhcpEnabled;

+                result.dhcpStart = paramD.dhcpStart;

+                result.dhcpEnd = paramD.dhcpEnd;

+                result.dhcpLease = parseInt(paramD.dhcpLease_hour, 10);

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setLanInfo() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "DHCP_SETTING";

+            valueReq.lanIp = values.ipAddress;

+            valueReq.lanNetmask = values.subnetMask;

+            valueReq.lanDhcpType = values.dhcpServer == "1" ? "SERVER" : "DISABLE";

+            if (valueReq.lanDhcpType == "SERVER") {

+                valueReq.dhcpStart = values.dhcpStart;

+                valueReq.dhcpEnd = values.dhcpEnd;

+                valueReq.dhcpLease = values.dhcpLease;

+            }

+            valueReq.dhcp_reboot_flag = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getSmsSetting() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "sms_parameter_info";

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var result = {};

+                result.centerNumber = paramD.sms_para_sca;

+                result.memStroe = paramD.sms_para_mem_store;

+                result.deliveryReport = paramD.sms_para_status_report;

+                switch (parseInt(paramD.sms_para_validity_period, 10)) {

+                case 143:

+                    result.validity = "twelve_hours";

+                    break;

+                case 167:

+                    result.validity = "one_day";

+                    break;

+                case 173:

+                    result.validity = "one_week";

+                    break;

+                case 244:

+                    result.validity = "largest";

+                    break;

+                case 255:

+                    result.validity = "largest";

+                    break;

+                default:

+                    result.validity = "twelve_hours";

+                    break;

+                }

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setSmsSetting() {

+        var callback = arguments[1];

+        var errorCabllback = arguments[2] ? arguments[2] : callback;

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "SET_MESSAGE_CENTER";

+            valueReq.save_time = values.validity;

+            valueReq.MessageCenter = values.centerNumber;

+            valueReq.status_save = values.deliveryReport;

+            valueReq.save_location = 'native';

+            valueReq.notCallback = true;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (!paramD) {

+                errorCabllback($.extend(errUnknownObj, {

+                        errorType: "smsSettingFail",

+                        errorText: "error_info"

+                    }));

+                return;

+            }

+            if (paramD.result == "success") {

+                getSmsStatusInfo({

+                    smsCmd: 3,

+                    errorType: "smsSettingFail",

+                    errorText: "error_info"

+                }, callback, errorCabllback);

+            } else {

+                errorCabllback($.extend(errUnknownObj, {

+                        errorType: "deleteFail",

+                        errorText: "delete_fail_try_again"

+                    }));

+            }

+        }

+    }

+    function restoreFactorySettings() {

+        var preErrorObj = {};

+        if (config.HAS_PARENTAL_CONTROL && config.currentUserInChildGroup != false) {

+            preErrorObj = {

+                errorType: 'no_auth'

+            };

+        }

+        return stuffMake(arguments, preErrorObj, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "RESTORE_FACTORY_SETTINGS";

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function checkRestoreStatus(successCallback) {

+        var valueReq = {};

+        valueReq.cmd = "restore_flag";

+        valueReq.multi_data = 1;

+        reqAsync(valueReq, function (paramD) {

+            if (paramD && paramD.restore_flag === "1") {

+                successCallback();

+            } else {

+                setTimeout(function () {

+                    checkRestoreStatus(successCallback);

+                }, 5000);

+            }

+        }, function () {

+            setTimeout(function () {

+                checkRestoreStatus(successCallback);

+            }, 5000);

+        }, false);

+    }

+    function getWpsInfo() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "wifi_wps_index,WscModeOption,AuthMode,wifi_cur_state,EncrypType,wps_mode,WPS_SSID,m_ssid_enable,SSID1,m_SSID,m_EncrypType,m_AuthMode,wifi_sta_connection";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var result = {};

+                result.wpsFlag = paramD.WscModeOption;

+                result.authMode = paramD.AuthMode;

+                result.wpsType = paramD.wps_mode;

+                result.radioFlag = paramD.wifi_cur_state == "1" ? "1" : "0";

+                result.encrypType = paramD.EncrypType;

+                result.wpsSSID = paramD.WPS_SSID;

+                result.ssidEnable = paramD.m_ssid_enable;

+                result.ssid = paramD.SSID1;

+                result.multiSSID = paramD.m_SSID;

+                result.m_encrypType = paramD.m_EncrypType;

+                result.wifi_wps_index = paramD.wifi_wps_index;

+                result.AuthMode = paramD.AuthMode;

+                result.m_AuthMode = paramD.m_AuthMode;

+                result.ap_station_enable = paramD.wifi_sta_connection;

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function openWps() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "WIFI_WPS_SET";

+            valueReq.WPS_SSID = values.wpsSSID;

+            valueReq.wps_mode = values.wpsType;

+            valueReq.wifi_wps_index = values.wpsIndex;

+            if (valueReq.wps_mode == 'PIN') {

+                valueReq.wps_pin = values.wpsPin;

+            }

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function openWps_5g() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "WIFI_M_WPS_SET";

+            valueReq.m_WPS_SSID = values.wpsSSID;

+            valueReq.m_wps_mode = values.wpsType;

+            valueReq.m_wifi_wps_index = values.wpsIndex;

+            if (valueReq.m_wps_mode == 'PIN') {

+                valueReq.m_wps_pin = values.wpsPin;

+            }

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getSleepMode() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "Sleep_interval";

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var result = {};

+                result.sleepMode = paramD.Sleep_interval;

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setSleepMode() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "SET_WIFI_SLEEP_INFO";

+            valueReq.sysIdleTimeToSleep = values.sleepMode;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getSysSecurity() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "RemoteManagement,WANPingFilter";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var result = {};

+                result.remoteFlag = paramD.RemoteManagement == "1" ? "1" : "0";

+                result.pingFlag = paramD.WANPingFilter == "1" ? "1" : "0";

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setSysSecurity() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "FW_SYS";

+            valueReq.remoteManagementEnabled = values.remoteFlag;

+            valueReq.pingFrmWANFilterEnabled = values.pingFlag;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getPortForward() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "PortForwardEnable,PortForwardRules_0,PortForwardRules_1,PortForwardRules_2,PortForwardRules_3,PortForwardRules_4,PortForwardRules_5,PortForwardRules_6,PortForwardRules_7,PortForwardRules_8,PortForwardRules_9";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var result = {};

+                result.portForwardEnable = paramD.PortForwardEnable;

+                var rules = [];

+                if (paramD.PortForwardRules_0 != "") {

+                    rules.push([0, paramD.PortForwardRules_0]);

+                }

+                if (paramD.PortForwardRules_1 != "") {

+                    rules.push([1, paramD.PortForwardRules_1]);

+                }

+                if (paramD.PortForwardRules_2 != "") {

+                    rules.push([2, paramD.PortForwardRules_2]);

+                }

+                if (paramD.PortForwardRules_3 != "") {

+                    rules.push([3, paramD.PortForwardRules_3]);

+                }

+                if (paramD.PortForwardRules_4 != "") {

+                    rules.push([4, paramD.PortForwardRules_4]);

+                }

+                if (paramD.PortForwardRules_5 != "") {

+                    rules.push([5, paramD.PortForwardRules_5]);

+                }

+                if (paramD.PortForwardRules_6 != "") {

+                    rules.push([6, paramD.PortForwardRules_6]);

+                }

+                if (paramD.PortForwardRules_7 != "") {

+                    rules.push([7, paramD.PortForwardRules_7]);

+                }

+                if (paramD.PortForwardRules_8 != "") {

+                    rules.push([8, paramD.PortForwardRules_8]);

+                }

+                if (paramD.PortForwardRules_9 != "") {

+                    rules.push([9, paramD.PortForwardRules_9]);

+                }

+                result.portForwardRules = parsePortForwardRules(rules);

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+        function parsePortForwardRules(paramD) {

+            var rules = [];

+            if (paramD && paramD.length > 0) {

+                for (var i = 0; i < paramD.length; i++) {

+                    var aRule = {};

+                    var elements = paramD[i][1].split(",");

+                    aRule.index = paramD[i][0];

+                    aRule.ipAddress = elements[0];

+                    aRule.portRange = elements[1] + ' - ' + elements[2];

+                    aRule.protocol = transProtocol(elements[3]);

+                    aRule.comment = elements[4];

+                    rules.push(aRule);

+                }

+            }

+            return rules;

+        }

+    }

+    function setPortForward() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "FW_FORWARD_ADD";

+            valueReq.ipAddress = values.ipAddress;

+            valueReq.portStart = values.portStart;

+            valueReq.portEnd = values.portEnd;

+            valueReq.protocol = values.protocol;

+            valueReq.comment = values.comment;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function deleteForwardRules() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "FW_FORWARD_DEL";

+            valueReq.delete_id = values.indexs.join(';') + ";";

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function enableVirtualServer() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "VIRTUAL_SERVER";

+            valueReq.PortForwardEnable = values.portForwardEnable;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function wifiDecode(fact1,fact2,encode_aes) {//wifiDecode(paramD.rnum_js,paramD.imei,paramD.WPAPSK1_enaes,paramD.m_WPAPSK1_enaes);

+        var kstr = fact1 + fact2 + "FFFFFFFFFFFFFFFFFFFFFFFF";

+        var kstr_final;

+	var kiv_final;

+

+        kstr_final = kstr.substring(0, 24);

+	kiv_final = kstr.substring(0, 16);

+

+        var tkey = CryptoJS.enc.Latin1.parse(kstr_final);

+	var tiv = CryptoJS.enc.Latin1.parse(kiv_final);

+        var decdata = CryptoJS.AES.decrypt(encode_aes, tkey, {

+            iv: tiv,

+            mode: CryptoJS.mode.CBC,

+            padding: CryptoJS.pad.ZeroPadding

+        }).toString(CryptoJS.enc.Utf8);

+

+        return decdata;

+    }

+    function getQuickSettingInfo() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            var wpask = config.PASSWORD_ENCODE ? ",WPAPSK1_encode" : ",imei,rnum_js,WPAPSK1_enaes";

+            valueReq.cmd = "pdp_type,ipv6_pdp_type,wifi_cur_state,SSID1,HideSSID,AuthMode,WscModeOption,ppp_status,apn_index,ipv6_apn_index,ipv6_APN_index,m_profile_name,apn_mode,EncrypType,DefaultKeyID,Key1Str1,Key2Str1,Key3Str1,Key4Str1" + wpask + ",APN_configtmp0,APN_configtmp1,APN_configtmp2,APN_configtmp3,APN_configtmp4,APN_configtmp5,APN_configtmp6,APN_configtmp7,APN_configtmp8,APN_configtmp9,APN_configtmp10,APN_configtmp11,APN_configtmp12,APN_configtmp13,APN_configtmp14,APN_configtmp15,APN_configtmp16,APN_configtmp17,APN_configtmp18,APN_configtmp19" + ",ipv6_APN_configtmp0,ipv6_APN_configtmp1,ipv6_APN_configtmp2,ipv6_APN_configtmp3,ipv6_APN_configtmp4,ipv6_APN_configtmp5,ipv6_APN_configtmp6,ipv6_APN_configtmp7,ipv6_APN_configtmp8,ipv6_APN_configtmp9,ipv6_APN_configtmp10,ipv6_APN_configtmp11,ipv6_APN_configtmp12,ipv6_APN_configtmp13,ipv6_APN_configtmp14,ipv6_APN_configtmp15,ipv6_APN_configtmp16,ipv6_APN_configtmp17,ipv6_APN_configtmp18,ipv6_APN_configtmp19";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                if (config.PASSWORD_ENCODE) {

+                    paramD.WPAPSK1 = Base64.decode(paramD.WPAPSK1_encode);

+                } else {

+		    paramD.WPAPSK1 = wifiDecode(paramD.rnum_js,paramD.imei,paramD.WPAPSK1_enaes);

+		}

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setQuickSetting4IPv6() {

+        stuffMakeAndCheckServerIsOnline(arguments, prepare, deal);

+        function prepare(values) {

+            var valueReq = {

+                goformId: "QUICK_SETUP_EX",

+                index: values.apn_index,

+                pdp_type: values.pdp_type,

+                apn_mode: values.apnMode,

+                profile_name: values.profile_name,

+                wan_apn: values.wan_apn,

+                ppp_auth_mode: values.ppp_auth_mode,

+                ppp_username: values.ppp_username,

+                ppp_passtmp: values.ppp_passtmp,

+                ipv6_wan_apn: values.ipv6_wan_apn,

+                ipv6_ppp_auth_mode: values.ipv6_ppp_auth_mode,

+                ipv6_ppp_username: values.ipv6_ppp_username,

+                ipv6_ppp_passtmp: values.ipv6_ppp_passtmp,

+                SSID_name: values.SSID_name,

+                SSID_Broadcast: values.SSID_Broadcast,

+                Encryption_Mode_hid: values.Encryption_Mode_hid,

+                security_shared_mode: values.security_shared_mode,

+                WPA_PreShared_Key: config.PASSWORD_ENCODE ? Base64.encode(values.WPA_PreShared_Key) : values.WPA_PreShared_Key,

+                wep_default_key: values.wep_default_key,

+                WPA_ENCRYPTION_hid: values.WPA_ENCRYPTION_hid

+            }

+            valueReq.wep_key_1 = values.wep_key_1;

+            valueReq.wep_key_2 = values.wep_key_2;

+            valueReq.wep_key_3 = values.wep_key_3;

+            valueReq.wep_key_4 = values.wep_key_4;

+            if (values.wep_default_key == '1') {

+                valueReq.WEP2Select = values.WEP2Select;

+            } else if (values.wep_default_key == '2') {

+                valueReq.WEP3Select = values.WEP3Select;

+            } else if (values.wep_default_key == '3') {

+                valueReq.WEP4Select = values.WEP4Select;

+            } else {

+                valueReq.WEP1Select = values.WEP1Select;

+            }

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return $.extend(errUnknownObj, {

+                    errorType: "SetSetUpError"

+                });

+            }

+        }

+    }

+    function stuffMakeAndCheckServerIsOnline(arg, prepare, deal) {

+        var isServerOnline = false;

+        var isCallbackExecuted = false;

+        var values = prepare(arg[0]);

+        var callback = arg[1];

+        var successCallback = function (paramD) {

+            isServerOnline = true;

+            if (!isCallbackExecuted && callback) {

+                callback(deal(paramD));

+            }

+            isCallbackExecuted = true;

+        };

+        var errorMethod = arg[2];

+        var errorCallback = function () {

+            isServerOnline = true;

+            if (errorMethod) {

+                errorMethod();

+            }

+        };

+        reqAsync(values, successCallback, errorCallback, true);

+        addTimeout(function () {

+            if (isServerOnline == false) {

+                var timer = addInterval(function () {

+                    if (isServerOnline == false) {

+                        getLanguage({}, function (paramD) {

+                            window.clearInterval(timer);

+                            successCallback({

+                                result: "success"

+                            });

+                        });

+                    }

+                }, 1000);

+            }

+        }, 5000);

+    }

+    function getSDConfiguration() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {

+                cmd: "sdcard_mode_option,sd_card_state,HTTP_SHARE_STATUS,HTTP_SHARE_WR_AUTH,HTTP_SHARE_FILE",

+                multi_data: 1

+            };

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var fileToShare;

+                if ("mmc2" == paramD.HTTP_SHARE_FILE || "/mmc2" == paramD.HTTP_SHARE_FILE || "/mmc2/" == paramD.HTTP_SHARE_FILE) {

+                    fileToShare = "1";

+                } else {

+                    fileToShare = "0";

+                }

+                var result = {

+                    sd_mode: paramD.sdcard_mode_option == "1" ? "0" : "1",

+                    sd_status: paramD.sd_card_state,

+                    share_status: paramD.HTTP_SHARE_STATUS == "Enabled" ? "1" : "0",

+                    share_auth: paramD.HTTP_SHARE_WR_AUTH == "readOnly" ? "0" : "1",

+                    file_to_share: fileToShare,

+                    share_file: paramD.HTTP_SHARE_FILE

+                };

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setSdCardMode() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {

+                goformId: "HTTPSHARE_MODE_SET",

+                mode_set: values.mode == "0" ? "http_share_mode" : "usb_mode"

+            };

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == 'success') {

+                return {

+                    result: 'success'

+                };

+            } else if (paramD && paramD.result == 'processing') {

+                return {

+                    result: 'processing'

+                };

+            } else {

+                return {

+                    result: false

+                };

+            }

+        }

+    }

+    function checkFileExists() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {

+                goformId: "GOFORM_HTTPSHARE_CHECK_FILE",

+                path_SD_CARD: values.path

+            };

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                if (paramD.result == "no_sdcard") {

+                    return {

+                        status: "no_sdcard"

+                    };

+                } else if (paramD.result == "noexist") {

+                    return {

+                        status: "noexist"

+                    };

+                } else if (paramD.result == "processing") {

+                    return {

+                        status: "processing"

+                    };

+                } else {

+                    return {

+                        status: "exist"

+                    };

+                }

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getFileList() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {

+                goformId: "HTTPSHARE_ENTERFOLD",

+                path_SD_CARD: values.path,

+                indexPage: values.index

+            };

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                if (paramD.result == 'failure') {

+                    return $.extend(errUnknownObj, {

+                        errorType: "get_file_list_failure"

+                    });

+                } else if (paramD.result == "no_sdcard") {

+                    return $.extend(errUnknownObj, {

+                        errorType: "no_sdcard"

+                    });

+                } else {

+                    return parseSdCardFile(paramD.result);

+                }

+            } else {

+                return errUnknownObj;

+            }

+        }

+        function parseSdCardFile(result) {

+            var fileInfo = {};

+            fileInfo.totalRecord = result.totalRecord;

+            var fileArr = [];

+            var details = result.fileInfo;

+            for (var i = 0; details && i < details.length; i++) {

+                if (details[i].fileName == "") {

+                    continue;

+                }

+                var obj = {};

+                obj.fileName = details[i].fileName;

+                obj.attribute = details[i].attribute;

+                obj.size = details[i].size;

+                obj.lastUpdateTime = details[i].lastUpdateTime;

+                fileArr.push(obj);

+            }

+            fileInfo.details = fileArr;

+            return fileInfo;

+        }

+    }

+    function fileRename() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var d = new Date();

+            var currentTime = d.getTime();

+            var zoneOffsetSeconds = d.getTimezoneOffset() * 60;

+            return {

+                goformId: "HTTPSHARE_FILE_RENAME",

+                path_SD_CARD: values.path,

+                OLD_NAME_SD_CARD: values.oldPath,

+                NEW_NAME_SD_CARD: values.newPath,

+                path_SD_CARD_time: transUnixTime(currentTime),

+                path_SD_CARD_time_unix: Math.round((currentTime - zoneOffsetSeconds * 1000) / 1e3)

+            };

+        }

+        function deal(paramD) {

+            if (paramD) {

+                if (paramD.result == "success") {

+                    return {

+                        result: true

+                    };

+                } else if (paramD.result == "no_sdcard") {

+                    return $.extend(errUnknownObj, {

+                        errorType: "no_sdcard"

+                    });

+                } else if (paramD.result == "noexist") {

+                    return $.extend(errUnknownObj, {

+                        errorType: "no_exist"

+                    });

+                } else if (paramD.result == "processing") {

+                    return $.extend(errUnknownObj, {

+                        errorType: "sd_file_processing_cant_rename"

+                    });

+                } else {

+                    return {

+                        result: false

+                    };

+                }

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getSdMemorySizes() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {

+                cmd: "HTTPSHARE_GETCARD_VALUE"

+            };

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (!paramD || (paramD.result && paramD.result == "no_sdcard")) {

+                return $.extend(errUnknownObj, {

+                    errorType: "no_sdcard"

+                });

+            } else {

+                return {

+                    totalMemorySize: paramD.sd_card_total_size == "" ? 0 : paramD.sd_card_total_size * 32 * 1024,

+                    availableMemorySize: paramD.sd_card_avi_space == "" ? 0 : paramD.sd_card_avi_space * 32 * 1024

+                };

+            }

+        }

+    }

+    function deleteFilesAndFolders() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var currentTime = new Date().getTime();

+            var valueReq = {

+                goformId: "HTTPSHARE_DEL",

+                path_SD_CARD: values.path,

+                name_SD_CARD: values.names,

+                path_SD_CARD_time: transUnixTime(currentTime),

+                path_SD_CARD_time_unix: Math.round(currentTime / 1e3)

+            };

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD.result && paramD.result == "failure") {

+                return {

+                    status: "failure"

+                };

+            } else if (paramD.result && paramD.result == "no_sdcard") {

+                return {

+                    status: "no_sdcard"

+                };

+            } else if (paramD.result && paramD.result == "processing") {

+                return {

+                    status: "processing"

+                };

+            } else if (paramD.result && paramD.result == "success") {

+                return {

+                    status: "success"

+                };

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function createFolder() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var d = new Date();

+            var currentTime = d.getTime();

+            var zoneOffsetSeconds = d.getTimezoneOffset() * 60;

+            return {

+                goformId: "HTTPSHARE_NEW",

+                path_SD_CARD: values.path,

+                path_SD_CARD_time: transUnixTime(currentTime),

+                path_SD_CARD_time_unix: Math.round((currentTime - zoneOffsetSeconds * 1000) / 1e3)

+            };

+        }

+        function deal(paramD) {

+            if (paramD.result && paramD.result == "failure") {

+                return $.extend(errUnknownObj, {

+                    errorType: "create_folder_failure"

+                });

+            } else if (paramD.result && paramD.result == "no_sdcard") {

+                return $.extend(errUnknownObj, {

+                    errorType: "no_sdcard"

+                });

+            } else if (paramD.result && paramD.result == "success") {

+                return {

+                    result: true

+                };

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setSdCardSharing() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {

+                goformId: "HTTPSHARE_AUTH_SET",

+                HTTP_SHARE_STATUS: values.share_status == "1" ? "Enabled" : "Disabled",

+                HTTP_SHARE_WR_AUTH: values.share_auth == "1" ? "readWrite" : "readOnly",

+                HTTP_SHARE_FILE: values.share_file

+            };

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                if (paramD.result == "no_sdcard") {

+                    return $.extend(errUnknownObj, {

+                        errorType: "no_sdcard"

+                    });

+                } else {

+                    return {

+                        result: true

+                    };

+                }

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getPortFilter() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "IPPortFilterEnable,DefaultFirewallPolicy,IPPortFilterRules_0,IPPortFilterRules_1,IPPortFilterRules_2,IPPortFilterRules_3,IPPortFilterRules_4,IPPortFilterRules_5,IPPortFilterRules_6,IPPortFilterRules_7,IPPortFilterRules_8,IPPortFilterRules_9";

+            valueReq.cmd += ",IPPortFilterRulesv6_0,IPPortFilterRulesv6_1,IPPortFilterRulesv6_2,IPPortFilterRulesv6_3,IPPortFilterRulesv6_4,IPPortFilterRulesv6_5,IPPortFilterRulesv6_6,IPPortFilterRulesv6_7,IPPortFilterRulesv6_8,IPPortFilterRulesv6_9";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var result = {};

+                result.portFilterEnable = paramD.IPPortFilterEnable;

+                result.defaultPolicy = paramD.DefaultFirewallPolicy;

+                var rules = [];

+                if (paramD.IPPortFilterRules_0 != "") {

+                    rules.push([0, paramD.IPPortFilterRules_0]);

+                }

+                if (paramD.IPPortFilterRules_1 != "") {

+                    rules.push([1, paramD.IPPortFilterRules_1]);

+                }

+                if (paramD.IPPortFilterRules_2 != "") {

+                    rules.push([2, paramD.IPPortFilterRules_2]);

+                }

+                if (paramD.IPPortFilterRules_3 != "") {

+                    rules.push([3, paramD.IPPortFilterRules_3]);

+                }

+                if (paramD.IPPortFilterRules_4 != "") {

+                    rules.push([4, paramD.IPPortFilterRules_4]);

+                }

+                if (paramD.IPPortFilterRules_5 != "") {

+                    rules.push([5, paramD.IPPortFilterRules_5]);

+                }

+                if (paramD.IPPortFilterRules_6 != "") {

+                    rules.push([6, paramD.IPPortFilterRules_6]);

+                }

+                if (paramD.IPPortFilterRules_7 != "") {

+                    rules.push([7, paramD.IPPortFilterRules_7]);

+                }

+                if (paramD.IPPortFilterRules_8 != "") {

+                    rules.push([8, paramD.IPPortFilterRules_8]);

+                }

+                if (paramD.IPPortFilterRules_9 != "") {

+                    rules.push([9, paramD.IPPortFilterRules_9]);

+                }

+                result.portFilterRules = parsePortFilterRules(rules, "IPv4");

+                var v6Rules = [];

+                if (paramD.IPPortFilterRulesv6_0 != "") {

+                    v6Rules.push([10, paramD.IPPortFilterRulesv6_0]);

+                }

+                if (paramD.IPPortFilterRulesv6_1 != "") {

+                    v6Rules.push([11, paramD.IPPortFilterRulesv6_1]);

+                }

+                if (paramD.IPPortFilterRulesv6_2 != "") {

+                    v6Rules.push([12, paramD.IPPortFilterRulesv6_2]);

+                }

+                if (paramD.IPPortFilterRulesv6_3 != "") {

+                    v6Rules.push([13, paramD.IPPortFilterRulesv6_3]);

+                }

+                if (paramD.IPPortFilterRulesv6_4 != "") {

+                    v6Rules.push([14, paramD.IPPortFilterRulesv6_4]);

+                }

+                if (paramD.IPPortFilterRulesv6_5 != "") {

+                    v6Rules.push([15, paramD.IPPortFilterRulesv6_5]);

+                }

+                if (paramD.IPPortFilterRulesv6_6 != "") {

+                    v6Rules.push([16, paramD.IPPortFilterRulesv6_6]);

+                }

+                if (paramD.IPPortFilterRulesv6_7 != "") {

+                    v6Rules.push([17, paramD.IPPortFilterRulesv6_7]);

+                }

+                if (paramD.IPPortFilterRulesv6_8 != "") {

+                    v6Rules.push([18, paramD.IPPortFilterRulesv6_8]);

+                }

+                if (paramD.IPPortFilterRulesv6_9 != "") {

+                    v6Rules.push([19, paramD.IPPortFilterRulesv6_9]);

+                }

+                result.portFilterRules = _.union(result.portFilterRules, parsePortFilterRules(v6Rules, "IPv6"));

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+        function parsePortFilterRules(paramD, ipTypeTmp) {

+            var rules = [];

+            if (paramD && paramD.length > 0) {

+                for (var i = 0; i < paramD.length; i++) {

+                    var aRule = {};

+                    var elements = paramD[i][1].split(",");

+                    aRule.index = paramD[i][0];

+                    aRule.macAddress = elements[11];

+                    aRule.destIpAddress = elements[4] == "any/0" ? "" : elements[4];

+                    aRule.sourceIpAddress = elements[0] == "any/0" ? "" : elements[0];

+                    aRule.destPortRange = elements[6] == '0' ? '' : elements[6] + " - " + elements[7];

+                    aRule.sourcePortRange = elements[2] == '0' ? '' : elements[2] + " - " + elements[3];

+                    aRule.action = elements[9] == 1 ? "filter_accept" : "filter_drop";

+                    aRule.protocol = transProtocol(elements[8]);

+                    aRule.comment = elements[10];

+                    aRule.ipType = ipTypeTmp;

+                    rules.push(aRule);

+                }

+            }

+            return rules;

+        }

+    }

+    function setPortFilterBasic() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "BASIC_SETTING";

+            valueReq.portFilterEnabled = values.portFilterEnable;

+            valueReq.defaultFirewallPolicy = values.defaultPolicy;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setPortFilter() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "ADD_IP_PORT_FILETER_V4V6";

+            valueReq.ip_version = values.ipType;

+            valueReq.mac_address = values.macAddress;

+            valueReq.dip_address = values.destIpAddress;

+            valueReq.sip_address = values.sourceIpAddress;

+            valueReq.dFromPort = values.destPortStart;

+            valueReq.dToPort = values.destPortEnd;

+            valueReq.sFromPort = values.sourcePortStart;

+            valueReq.sToPort = values.sourcePortEnd;

+            valueReq.action = values.action;

+            valueReq.protocol = values.protocol;

+            valueReq.comment = values.comment;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function deleteFilterRules() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            var deleteIds = _.filter(values.indexs, function (item) {

+                return item.length == 1;

+            });

+            valueReq.goformId = "DEL_IP_PORT_FILETER_V4V6";

+            var deletev6Ids = [];

+            _.each(values.indexs, function (item) {

+                if (item.length == 2) {

+                    deletev6Ids.push(item.substring(1));

+                }

+            });

+            valueReq.delete_id_v6 = deletev6Ids.length > 0 ? deletev6Ids.join(';') + ";" : "";

+            valueReq.delete_id = deleteIds.length > 0 ? deleteIds.join(';') + ";" : "";

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getWifiAdvance() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "WirelessMode,CountryCode,Channel,HT_MCS,wifi_band,wifi_11n_cap,MAX_Access_num,m_MAX_Access_num,MAX_Station_num,wifi_sta_connection";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var result = {

+                    mode: paramD.WirelessMode,

+                    countryCode: paramD.CountryCode,

+                    channel: paramD.Channel,

+                    rate: paramD.HT_MCS,

+                    wifiBand: paramD.wifi_band == 'a' ? 'a' : 'b',

+                    bandwidth: paramD.wifi_11n_cap,

+                    MAX_Station_num: $.isNumeric(paramD.MAX_Station_num) ? paramD.MAX_Station_num : config.MAX_STATION_NUMBER,

+                    MAX_Access_num: paramD.MAX_Access_num,

+                    m_MAX_Access_num: paramD.m_MAX_Access_num,

+                    ap_station_enable: paramD.wifi_sta_connection

+                };

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setWifiAdvance() {

+        stuffMakeAndCheckServerIsOnline(arguments, prepare, deal);

+        function prepare(values) {

+            var valueReq = {

+                goformId: "SET_WIFI_INFO",

+                wifiMode: values.mode,

+                countryCode: values.countryCode,

+                MAX_Access_num: values.station,

+                m_MAX_Access_num: values.m_station

+            };

+            if (config.WIFI_BAND_SUPPORT) {

+                valueReq.wifi_band = values.wifiBand;

+            }

+            if (config.WIFI_BAND_SUPPORT && values.wifiBand == 'a') {

+                valueReq.selectedChannel = 'auto';

+            } else {

+                valueReq.selectedChannel = values.channel;

+                valueReq.abg_rate = values.rate;

+            }

+            if (config.WIFI_BANDWIDTH_SUPPORT) {

+                valueReq.wifi_11n_cap = values.bandwidth;

+            }

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getDeviceInfo() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+	    var wpask = config.PASSWORD_ENCODE ? "WPAPSK1_encode,m_WPAPSK1_encode," : "rnum_js,WPAPSK1_enaes,m_WPAPSK1_enaes,";

+            var valueReq = {

+                cmd: "wifi_coverage,m_ssid_enable,imei,network_type,sub_network_type,rssi,rscp,lte_rsrp,imsi,sim_imsi,cr_version,hw_version,MAX_Access_num," + wpask + "SSID1,AuthMode,m_SSID,m_AuthMode,m_HideSSID,m_MAX_Access_num,lan_ipaddr," + "mac_address,msisdn,LocalDomain,wan_ipaddr,static_wan_ipaddr,ipv6_wan_ipaddr,ipv6_pdp_type,pdp_type,ppp_status,sta_ip_status,rj45_state,ethwan_mode",

+                multi_data: 1

+            };

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return {

+                    ssid: paramD.SSID1,

+                    authMode: paramD.AuthMode,

+                    passPhrase: config.PASSWORD_ENCODE ? Base64.decode(paramD.WPAPSK1_encode) : wifiDecode(paramD.rnum_js,paramD.imei,paramD.WPAPSK1_enaes),

+                    m_ssid: paramD.m_SSID,

+                    m_AuthMode: paramD.m_AuthMode,

+                    m_passPhrase: config.PASSWORD_ENCODE ? Base64.decode(paramD.m_WPAPSK1_encode) : wifiDecode(paramD.rnum_js,paramD.imei,paramD.m_WPAPSK1_enaes),

+                    m_max_access_num: paramD.m_MAX_Access_num,

+                    multi_ssid_enable: paramD.m_ssid_enable,

+                    ipAddress: paramD.lan_ipaddr,

+                    wanIpAddress: paramD.wan_ipaddr,

+                    staticWanIpAddress: paramD.static_wan_ipaddr,

+                    ipv6WanIpAddress: paramD.ipv6_wan_ipaddr,

+                    ipv6PdpType: paramD.ipv6_pdp_type,

+                    macAddress: paramD.mac_address,

+                    simSerialNumber: paramD.msisdn,

+                    lanDomain: paramD.LocalDomain,

+                    imei: paramD.imei,

+                    signal: convertSignal(paramD),

+                    imsi: paramD.imsi || paramD.sim_imsi,

+                    sw_version: paramD.cr_version,

+                    hw_version: paramD.hw_version,

+                    max_access_num: paramD.MAX_Access_num,

+                    wifiRange: paramD.wifi_coverage,

+                    pdpType: paramD.pdp_type,

+                    rj45ConnectStatus: (typeof paramD.rj45_state == 'undefined' || paramD.rj45_state == '') ? 'dead' : paramD.rj45_state,

+                    blc_wan_mode: informationAll.blc_wan_mode,

+                    connectStatus: paramD.ppp_status,

+                    wifiConStatus: paramD.sta_ip_status,

+                    ethwan_mode: paramD.ethwan_mode.toUpperCase()

+                };

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getDeviceInfoLow() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {

+                cmd: "imei,rnum_js",

+                multi_data: 1

+            };

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var kstr = paramD.rnum_js + paramD.imei + "FFFFFFFFFFFFFFFFFFFFFFFF";

+                var kstr_final;

+		var kiv_final;

+

+                kstr_final = kstr.substring(0, 24);

+		kiv_final = kstr.substring(0, 16);

+

+                return {

+                    skey: kstr_final,

+		    siv: kiv_final

+            	};

+            } else {

+

+	        return {

+                    skey: "FFFFFFFFFFFFFFFFFFFFFFFF",

+		    siv: "FFFFFFFFFFFFFFFF"

+            	};

+            }

+        }

+    }

+    function getWifiRange() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "wifi_coverage";

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var result = {};

+                result.wifiRangeMode = paramD.wifi_coverage;

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setWifiRange() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "SET_WIFI_COVERAGE";

+            valueReq.wifi_coverage = values.wifiRangeMode;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getUpnpSetting() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "upnpEnabled";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var result = {};

+                result.upnpSetting = paramD.upnpEnabled == "1" ? "1" : "0";

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setUpnpSetting() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "UPNP_SETTING";

+            valueReq.upnp_setting_option = values.upnpSetting;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getDmzSetting() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "DMZEnable,DMZIPAddress";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var result = {};

+                result.dmzSetting = paramD.DMZEnable == "1" ? "1" : "0";

+                result.ipAddress = paramD.DMZIPAddress;

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setDmzSetting() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "DMZ_SETTING";

+            valueReq.DMZEnabled = values.dmzSetting;

+            if (valueReq.DMZEnabled == '1') {

+                valueReq.DMZIPAddress = values.ipAddress;

+            }

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getPortMap() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "PortMapEnable,PortMapRules_0,PortMapRules_1,PortMapRules_2,PortMapRules_3,PortMapRules_4,PortMapRules_5,PortMapRules_6,PortMapRules_7,PortMapRules_8,PortMapRules_9",

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var result = {};

+                result.portMapEnable = paramD.PortMapEnable;

+                var rules = [];

+                if (paramD.PortMapRules_0 != "") {

+                    rules.push([0, paramD.PortMapRules_0]);

+                }

+                if (paramD.PortMapRules_1 != "") {

+                    rules.push([1, paramD.PortMapRules_1]);

+                }

+                if (paramD.PortMapRules_2 != "") {

+                    rules.push([2, paramD.PortMapRules_2]);

+                }

+                if (paramD.PortMapRules_3 != "") {

+                    rules.push([3, paramD.PortMapRules_3]);

+                }

+                if (paramD.PortMapRules_4 != "") {

+                    rules.push([4, paramD.PortMapRules_4]);

+                }

+                if (paramD.PortMapRules_5 != "") {

+                    rules.push([5, paramD.PortMapRules_5]);

+                }

+                if (paramD.PortMapRules_6 != "") {

+                    rules.push([6, paramD.PortMapRules_6]);

+                }

+                if (paramD.PortMapRules_7 != "") {

+                    rules.push([7, paramD.PortMapRules_7]);

+                }

+                if (paramD.PortMapRules_8 != "") {

+                    rules.push([8, paramD.PortMapRules_8]);

+                }

+                if (paramD.PortMapRules_9 != "") {

+                    rules.push([9, paramD.PortMapRules_9]);

+                }

+                result.portMapRules = parsePortMapRules(rules);

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+        function parsePortMapRules(paramD) {

+            var rules = [];

+            if (paramD && paramD.length > 0) {

+                for (var i = 0; i < paramD.length; i++) {

+                    var aRule = {};

+                    var elements = paramD[i][1].split(",");

+                    aRule.index = paramD[i][0];

+                    aRule.sourcePort = elements[1];

+                    aRule.destIpAddress = elements[0];

+                    aRule.destPort = elements[2];

+                    aRule.protocol = transProtocol(elements[3]);

+                    aRule.comment = elements[4];

+                    rules.push(aRule);

+                }

+            }

+            return rules;

+        }

+    }

+    function setPortMap() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "ADD_PORT_MAP";

+            valueReq.portMapEnabled = values.portMapEnable;

+            valueReq.fromPort = values.sourcePort;

+            valueReq.ip_address = values.destIpAddress;

+            valueReq.toPort = values.destPort;

+            valueReq.protocol = values.protocol;

+            valueReq.comment = values.comment;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function enablePortMap() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "ADD_PORT_MAP";

+            valueReq.portMapEnabled = values.portMapEnable;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function deleteMapRules() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "DEL_PORT_MAP";

+            valueReq.delete_id = values.indexs.join(';') + ";";

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getTrafficAlertInfo() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            return {

+                cmd: "data_volume_limit_switch,data_volume_limit_unit,data_volume_limit_size,data_volume_alert_percent,monthly_tx_bytes,monthly_rx_bytes,monthly_time,traffic_alined_delta",

+                multi_data: 1

+            };

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var isData = paramD.data_volume_limit_unit == 'data';

+                var result = {

+                    dataLimitChecked: paramD.data_volume_limit_switch,

+                    dataLimitTypeChecked: isData ? '1' : '0',

+                    limitDataMonth: isData ? paramD.data_volume_limit_size : '0',

+                    alertDataReach: isData ? paramD.data_volume_alert_percent : '0',

+                    limitTimeMonth: isData ? '0' : paramD.data_volume_limit_size,

+                    alertTimeReach: isData ? '0' : paramD.data_volume_alert_percent,

+                    monthlySent: paramD.monthly_tx_bytes == '' ? 0 : paramD.monthly_tx_bytes,

+                    monthlyReceived: paramD.monthly_rx_bytes == '' ? 0 : paramD.monthly_rx_bytes,

+                    monthlyConnectedTime: paramD.monthly_time == '' ? 0 : paramD.monthly_time,

+                    traffic_alined_delta: paramD.traffic_alined_delta == '' ? 0 : paramD.traffic_alined_delta

+                };

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setTrafficAlertInfo() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var isData = values.dataLimitTypeChecked == '1';

+            var valueReq = {

+                goformId: "DATA_LIMIT_SETTING",

+                data_volume_limit_switch: values.dataLimitChecked

+            };

+            if (values.dataLimitChecked == '1') {

+                valueReq.data_volume_limit_unit = isData ? 'data' : 'time';

+                valueReq.data_volume_limit_size = isData ? values.limitDataMonth : values.limitTimeMonth;

+                valueReq.data_volume_alert_percent = isData ? values.alertDataReach : values.alertTimeReach;

+            }

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getUSSDResponse() {

+        var callback = arguments[1];

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            if (values.sendOrReply == "send") {

+                return {

+                    goformId: "USSD_PROCESS",

+                    USSD_operator: values.operator,

+                    USSD_send_number: values.strUSSDCommand,

+                    notCallback: true

+                };

+            } else if (values.sendOrReply == "reply") {

+                return {

+                    goformId: "USSD_PROCESS",

+                    USSD_operator: values.operator,

+                    USSD_reply_number: values.strUSSDCommand,

+                    notCallback: true

+                };

+            }

+        }

+        function deal(paramD) {

+            if (!paramD) {

+                callback(false, "ussd_fail");

+                return;

+            }

+            if (paramD.result == "success") {

+                callbackTemp = callback;

+                getResponse();

+            } else {

+                callback(false, "ussd_fail");

+            }

+        }

+    }

+    function getResponse() {

+        $.ajax({

+            url: "/reqproc/proc_get",

+            data: {

+                cmd: "ussd_write_flag"

+            },

+            cache: false,

+            async: true,

+            dataType: "json",

+            success: function (result) {

+                if (result.ussd_write_flag == "1") {

+                    callbackTemp(false, "ussd_no_service");

+                } else if (result.ussd_write_flag == "4" || result.ussd_write_flag == "unknown" || result.ussd_write_flag == "3") {

+                    callbackTemp(false, "ussd_timeout");

+                } else if (result.ussd_write_flag == "15") {

+                    setTimeout(getResponse, 1000);

+                } else if (result.ussd_write_flag == "10") {

+                    callbackTemp(false, "ussd_retry");

+                } else if (result.ussd_write_flag == "99") {

+                    callbackTemp(false, "ussd_unsupport");

+                } else if (result.ussd_write_flag == "41") {

+                    callbackTemp(false, "operation_not_supported");

+                } else if (result.ussd_write_flag == "2") {

+                    callbackTemp(false, "network_terminated");

+                } else if (result.ussd_write_flag == "16") {

+                    $.ajax({

+                        url: "/reqproc/proc_get",

+                        data: {

+                            cmd: "ussd_data_info"

+                        },

+                        dataType: "json",

+                        async: true,

+                        cache: false,

+                        success: function (paramD) {

+                            var content = {};

+                            content.data = paramD.ussd_data;

+                            content.ussd_action = paramD.ussd_action;

+                            content.ussd_dcs = paramD.ussd_dcs;

+                            callbackTemp(true, content);

+                        },

+                        error: function () {

+                            callbackTemp(false, "ussd_info_error");

+                        }

+                    });

+                } else {

+                    callbackTemp(false, "ussd_fail");

+                }

+            },

+            error: function () {

+                callbackTemp(false, "ussd_fail");

+            }

+        });

+    }

+    function USSDReplyCancel(callback) {

+        $.ajax({

+            url: "/reqproc/proc_post",

+            data: {

+                goformId: "USSD_PROCESS",

+                USSD_operator: "ussd_cancel"

+            },

+            cache: false,

+            dataType: "json",

+            success: function (paramD) {

+                if (paramD.result == "success") {

+                    getCancelResponse();

+                } else {

+                    callback(false);

+                }

+            }

+        });

+        function getCancelResponse() {

+            $.ajax({

+                url: "/reqproc/proc_get",

+                data: {

+                    cmd: "ussd_write_flag"

+                },

+                cache: false,

+                async: true,

+                dataType: "json",

+                success: function (result) {

+                    if (result.ussd_write_flag == "15") {

+                        setTimeout(getCancelResponse, 1000);

+                    } else if (result.ussd_write_flag == "13") {

+                        callback(true);

+                    } else {

+                        callback(false);

+                    }

+                },

+                error: function () {

+                    callback(false);

+                }

+            });

+        }

+    }

+    function unlockNetwork() {

+        var callback = arguments[1];

+        var checkPoint = 0;

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values) {

+            return {

+                goformId: "UNLOCK_NETWORK",

+                notCallback: true,

+                unlock_network_code: values.unlock_network_code

+            };

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == "success") {

+                addCallback(checkUnlockNetworkStatus);

+            } else {

+                callback({

+                    result: 'fail'

+                });

+            }

+        }

+        function checkUnlockNetworkStatus() {

+            if (checkPoint > 5) {

+                removeCallback(checkUnlockNetworkStatus);

+                callback({

+                    result: 'fail'

+                });

+            } else if (informationAll.simStatus != 'modem_imsi_waitnck') {

+                removeCallback(checkUnlockNetworkStatus);

+                callback({

+                    result: 'success'

+                });

+            }

+            checkPoint++;

+        }

+    }

+    function getNetworkUnlockTimes() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            return {

+                cmd: "unlock_nck_time"

+            };

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setUpdateInfoWarning() {

+        var callback = arguments[1];

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values) {

+            return {

+                goformId: "SET_UPGRADE_NOTICE",

+                upgrade_notice_flag: values.upgrade_notice_flag,

+                notCallback: true

+            };

+        }

+        function deal(paramD) {

+            if (paramD.result == "success") {

+                callback(true);

+            } else {

+                callback(false);

+            }

+        }

+    }

+    function getUpdateInfoWarning() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            return {

+                cmd: "upgrade_notice_flag"

+            };

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getAPStationBasic() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            return {

+                multi_data: 1,

+                cmd: "wifi_sta_connection,pswan_priority,wifiwan_priority,ethwan_priority"

+            };

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return {

+                    ap_station_enable: paramD.wifi_sta_connection,

+                    ap_station_mode: parseInt(paramD.wifiwan_priority, 10) > parseInt(paramD.pswan_priority, 10) ? "wifi_pref" : "dial_pref"

+                }

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setAPStationBasic() {

+        var tmp = arguments[0];

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values) {

+            return {

+                goformId: "WIFI_STA_CONTROL",

+                wifi_sta_connection: values.ap_station_enable

+            };

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == "success") {

+                informationAll.ap_station_enable = tmp.ap_station_enable == 1;

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function refreshAPStationStatus() {

+        return getAPStationBasic({}, function (paramD) {

+            informationAll.ap_station_enable = paramD.ap_station_enable == 1;

+            informationAll.ap_station_mode = paramD.ap_station_mode;

+        });

+    }

+    function getHotspotList() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var cmdStr = "wifi_profile_num,wifi_profile";

+            for (var i = 1; i < config.AP_STATION_LIST_LENGTH; i++) {

+                cmdStr = cmdStr + ",wifi_profile" + i;

+            }

+            return {

+                multi_data: 1,

+                cmd: cmdStr

+            };

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var wifiList = [];

+                for (var i = 0; i < config.AP_STATION_LIST_LENGTH; i++) {

+                    var wifiStr = "";

+                    if (i == 0) {

+                        wifiStr = paramD.wifi_profile;

+                    } else {

+                        wifiStr = paramD["wifi_profile" + i];

+                    }

+                    var wifiArray = wifiStr.split(";");

+                    for (var j = 0; j < wifiArray.length; j++) {

+                        var item = wifiArray[j].split(",");

+                        if (!item[0]) {

+                            break;

+                        }

+                        var wifiJson = {

+                            profileName: item[0],

+                            fromProvider: item[1],

+                            connectStatus: item[2],

+                            signal: item[3],

+                            ssid: item[4],

+                            authMode: item[5],

+                            encryptType: item[6],

+                            password: item[7] == "0" ? "" : item[7],

+                            keyID: item[8],

+                            mac: item[9]

+                        };

+                        wifiList.push(wifiJson);

+                    }

+                }

+                return {

+                    hotspotList: wifiList

+                };

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function searchHotspot() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values) {

+            return {

+                goformId: "WLAN_SET_STA_REFRESH"

+            };

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getSearchHotspotList() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            return {

+                multi_data: 1,

+                cmd: "scan_finish,EX_APLIST,EX_APLIST1"

+            }

+        }

+        function deal(paramD) {

+            if (paramD) {

+                if (paramD.scan_finish == "0") {

+                    return {

+                        scan_finish: "0",

+                        hotspotList: []

+                    };

+                }

+                if (paramD.scan_finish == "2") {

+                    return {

+                        scan_finish: "2",

+                        hotspotList: []

+                    };

+                }

+                var wifiList = [];

+                for (var i = 0; i <= 1; i++) {

+                    var wifiStr;

+                    if (i == 0) {

+                        wifiStr = paramD.EX_APLIST;

+                    } else {

+                        wifiStr = paramD.EX_APLIST1;

+                    }

+                    var wifiArray = wifiStr.split(";");

+                    for (var j = 0; j < wifiArray.length; j++) {

+                        var item = wifiArray[j].split(",");

+                        if (!item[0]) {

+                            break;

+                        }

+                        var wifiJson = {

+                            fromProvider: item[0],

+                            connectStatus: item[1],

+                            ssid: item[2],

+                            signal: item[3],

+                            channel: item[4],

+                            authMode: item[5],

+                            encryptType: item[6],

+                            mac: item[7]

+                        }

+                        wifiList.push(wifiJson);

+                    }

+                }

+                return {

+                    scan_finish: "1",

+                    hotspotList: wifiList

+                };

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function creatHotspotString(hotspot) {

+        var tmp = [];

+        tmp.push(hotspot.profileName);

+        tmp.push(hotspot.fromProvider || "0");

+        tmp.push(hotspot.connectStatus || "0");

+        tmp.push(hotspot.signal);

+        tmp.push(hotspot.ssid);

+        tmp.push(hotspot.authMode);

+        tmp.push(hotspot.encryptType);

+        tmp.push(hotspot.password || "0");

+        tmp.push(hotspot.keyID);

+        tmp.push(hotspot.mac);

+        return tmp.join(",");

+    }

+    function saveHotspot() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values) {

+            var apList = values.apList;

+            var action = "modify";

+            if (values.profileName == "") {

+                action = "add";

+                var newName = (jQuery.fn.jquery + Math.random()).replace(/\D/g, "");

+                values.profileName = newName;

+                apList.push({

+                    profileName: newName,

+                    fromProvider: "0",

+                    connectStatus: "0",

+                    signal: values.signal,

+                    ssid: values.ssid,

+                    authMode: values.authMode,

+                    encryptType: values.encryptType,

+                    password: values.password || "0",

+                    keyID: values.keyID,

+                    mac: values.mac

+                });

+            }

+            var wifi = {

+                "profile0": []

+            };

+            for (var i = 1; i < config.AP_STATION_LIST_LENGTH; i++) {

+                wifi["profile" + i] = [];

+            }

+            var activeHotspotStr = "";

+            for (var i = 0; i < apList.length; i++) {

+                var hotspotStr = "";

+                if (values.profileName == apList[i].profileName) {

+                    hotspotStr = creatHotspotString(values);

+                    activeHotspotStr = hotspotStr;

+                } else {

+                    hotspotStr = creatHotspotString(apList[i]);

+                }

+                var index = parseInt(i % 10);

+                wifi["profile" + index].push(hotspotStr);

+            }

+            var profileParams = {

+                wifi_profile: wifi.profile0.join(";")

+            };

+            for (var i = 1; i < config.AP_STATION_LIST_LENGTH; i++) {

+                profileParams["wifi_profile" + i] = wifi["profile" + i].join(";");

+            }

+            var valueReq = $.extend({

+                goformId: "WIFI_SPOT_PROFILE_UPDATE",

+                wifi_profile_num: apList.length,

+                wifi_update_profile: activeHotspotStr,

+                action: action

+            }, profileParams);

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function deleteHotspot() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values) {

+            var apList = values.apList;

+            var wifi = {

+                "profile0": []

+            };

+            for (var i = 1; i < config.AP_STATION_LIST_LENGTH; i++) {

+                wifi["profile" + i] = [];

+            }

+            var foundDelete = false;

+            var activeHotspotStr = "";

+            for (var i = 0; i < apList.length; i++) {

+                var hotspotStr = creatHotspotString(apList[i]);

+                if (apList[i].profileName == values.profileName) {

+                    foundDelete = true;

+                    activeHotspotStr = hotspotStr;

+                    continue;

+                }

+                var idIndex = i;

+                if (foundDelete) {

+                    idIndex = i - 1;

+                }

+                var index = parseInt(idIndex % 10);

+                wifi["profile" + index].push(hotspotStr);

+            }

+            var num = foundDelete ? apList.length - 1 : apList.length;

+            var profileParams = {

+                wifi_profile: wifi.profile0.join(";")

+            };

+            for (var i = 1; i < config.AP_STATION_LIST_LENGTH; i++) {

+                profileParams["wifi_profile" + i] = wifi["profile" + i].join(";");

+            }

+            var valueReq = $.extend({

+                goformId: "WIFI_SPOT_PROFILE_UPDATE",

+                wifi_profile_num: num,

+                wifi_update_profile: activeHotspotStr,

+                action: "delete"

+            }, profileParams);

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function connectHotspot() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values) {

+            return {

+                goformId: "WLAN_SET_STA_CON",

+                EX_SSID1: values.EX_SSID1,

+                EX_AuthMode: values.EX_AuthMode,

+                EX_EncrypType: values.EX_EncrypType,

+                EX_DefaultKeyID: values.EX_DefaultKeyID,

+                EX_WEPKEY: values.EX_WEPKEY,

+                EX_WPAPSK1: values.EX_WPAPSK1,

+                EX_wifi_profile: values.EX_wifi_profile,

+                EX_mac: values.EX_mac

+            };

+        }

+        function deal(paramD) {

+            if (paramD && (paramD.result == "success" || paramD.result == "processing")) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function disconnectHotspot() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values) {

+            return {

+                goformId: "WLAN_SET_STA_DISCON"

+            };

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == "success") {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getOpMode() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            return {

+                multi_data: 1,

+                cmd: "blc_wan_mode,blc_wan_auto_mode,loginfo,ppp_status,rj45_state,ethwan_mode"

+            };

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var result = {};

+                if (paramD.blc_wan_mode == 'AUTO') {

+                    result.blc_wan_mode = paramD.blc_wan_auto_mode ? paramD.blc_wan_auto_mode : 'AUTO_PPP';

+                } else {

+                    result.blc_wan_mode = paramD.blc_wan_mode ? paramD.blc_wan_mode : 'PPP';

+                }

+                result.loginfo = paramD.loginfo;

+                result.ppp_status = paramD.ppp_status;

+                result.rj45_state = (typeof paramD.rj45_state == 'undefined' || paramD.rj45_state == '') ? 'dead' : paramD.rj45_state;

+                result.ethwan_mode = paramD.ethwan_mode.toUpperCase();

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getRj45PlugState() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            return {

+                cmd: "rj45_plug"

+            };

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var result = {};

+                result.rj45_plug = paramD.rj45_plug == "" ? "wan_lan_off" : paramD.rj45_plug;

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function checkOpMode(opmode, rj45state) {

+        if (config.RJ45_SUPPORT) {

+            if (rj45state == "dead" || rj45state == "") {

+                return 'PPP';

+            } else if (!opmode || opmode == "undefined") {

+                if (rj45state == "working") {

+                    return 'PPPOE';

+                } else {

+                    return 'PPP';

+                }

+            } else {

+                return opmode;

+            }

+        } else {

+            return 'PPP';

+        }

+    }

+    function SetOperationMode(values, callback) {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values) {

+            var valueReq = $.extend({

+                goformId: "OPERATION_MODE"

+            }, values);

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == "success") {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getPppoeParams() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            return {

+                multi_data: 1,

+                cmd: "opms_wan_auto_mode,ethwan_mode,pppoe_username,pppoe_cc,ethwan_dialmode,ppp_status,static_wan_ipaddr,static_wan_netmask,static_wan_gateway,static_wan_primary_dns,static_wan_secondary_dns,rj45_state,lan_ipaddr,lan_netmask"

+            };

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return {

+                    opms_wan_auto_mode: paramD.opms_wan_auto_mode,

+                    ethwan_mode: paramD.ethwan_mode.toUpperCase(),

+                    pppoe_username: paramD.pppoe_username,

+                    pppoe_cc: paramD.pppoe_cc,

+                    ethwan_dialmode: paramD.ethwan_dialmode == "manual" ? "manual_dial" : "auto_dial",

+                    ppp_status: paramD.ppp_status,

+                    static_wan_ipaddr: paramD.static_wan_ipaddr,

+                    static_wan_netmask: paramD.static_wan_netmask,

+                    static_wan_gateway: paramD.static_wan_gateway,

+                    static_wan_primary_dns: paramD.static_wan_primary_dns,

+                    static_wan_secondary_dns: paramD.static_wan_secondary_dns,

+                    rj45_state: (typeof paramD.rj45_state == 'undefined' || paramD.rj45_state == '') ? 'dead' : paramD.rj45_state,

+                    lan_ipaddr: paramD.lan_ipaddr,

+                    lan_netmask: paramD.lan_netmask

+                }

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setPppoeDialMode(values, callback) {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values) {

+            var valueReq = $.extend({

+                notCallback: true

+            }, values);

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD.result == "success") {

+                callback({

+                    result: true

+                });

+            } else {

+                callback({

+                    result: false

+                });

+            }

+        }

+    }

+    function getSntpParams(values, callback) {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            return {

+                multi_data: 1,

+                cmd: "sntp_year,sntp_month,sntp_day,sntp_hour,sntp_minute,sntp_second,sntp_time_set_mode,sntp_static_server0,sntp_static_server1,sntp_static_server2,sntp_server0,sntp_server1,sntp_server2,sntp_server3,sntp_server4,sntp_server5,sntp_server6,sntp_server7,sntp_server8,sntp_server9,sntp_other_server0,sntp_other_server1,sntp_other_server2,sntp_timezone,sntp_timezone_index,sntp_dst_enable,ppp_status,sntp_process_result,rj45_state"

+            };

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var sntp_servers = getSntpServers(paramD);

+                return {

+                    sntp_year: paramD.sntp_year,

+                    sntp_month: paramD.sntp_month,

+                    sntp_day: paramD.sntp_day,

+                    sntp_hour: paramD.sntp_hour,

+                    sntp_minute: paramD.sntp_minute,

+                    sntp_second: paramD.sntp_second,

+                    sntp_time_set_mode: paramD.sntp_time_set_mode,

+                    sntp_servers: sntp_servers,

+                    sntp_server0: paramD.sntp_server0,

+                    sntp_server1: paramD.sntp_server1,

+                    sntp_server2: paramD.sntp_server2,

+                    sntp_static_server0: paramD.sntp_static_server0,

+                    sntp_static_server1: paramD.sntp_static_server1,

+                    sntp_static_server2: paramD.sntp_static_server2,

+                    sntp_other_server0: paramD.sntp_other_server0,

+                    sntp_other_server1: paramD.sntp_other_server1,

+                    sntp_other_server2: paramD.sntp_other_server2,

+                    sntp_timezone: paramD.sntp_timezone,

+                    sntp_timezone_index: paramD.sntp_timezone_index ? paramD.sntp_timezone_index : "0",

+                    sntp_dst_enable: paramD.sntp_dst_enable,

+                    ppp_status: paramD.ppp_status,

+                    blc_wan_mode: informationAll.blc_wan_mode,

+                    sntp_process_result: paramD.sntp_process_result,

+                    rj45_state: (typeof paramD.rj45_state == 'undefined' || paramD.rj45_state == '') ? 'dead' : paramD.rj45_state

+                }

+            } else {

+                return errUnknownObj;

+            }

+        }

+        function getSntpServers(paramD) {

+            var serverArray = [];

+            for (var i = 0; i < 3; i++) {

+                var tmp = "sntp_static_server" + (i).toString();

+                if (paramD[tmp] != "") {

+                    var obj = {};

+                    obj.name = paramD[tmp];

+                    obj.value = paramD[tmp];

+                    serverArray.push(obj);

+                }

+            }

+            var otherArray = [{

+                    name: "Other",

+                    value: "Other"

+                }, {

+                    name: "NONE",

+                    value: ""

+                }

+            ];

+            for (var j = 0; j < 2; j++) {

+                serverArray.push(otherArray[j]);

+            }

+            return serverArray;

+        }

+    }

+    function setSNTPDate(values, callback) {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values) {

+            var valueReq = $.extend({}, values);

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == "success") {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setSntpSetting(values, callback) {

+        var valueReq = $.extend({}, values); {

+            $.post("reqproc/proc_post", valueReq, function (paramD) {

+                if (paramD && paramD.result == "success") {

+                    if (values.manualsettime == "auto") {

+                        setTimeout(checkSyncStatus, 2000);

+                        callback(paramD);

+                    } else {

+                        callback(true);

+                    }

+                } else if (paramD && paramD.result == "processing") {

+                    callback(paramD);

+                } else {

+                    callback(false);

+                }

+            }, "json");

+        }

+        function checkSyncStatus() {

+            $.ajax({

+                url: "reqproc/proc_get",

+                dataType: "json",

+                data: {

+                    cmd: "sntp_process_result"

+                },

+                cache: false,

+                async: false,

+                success: function (paramD) {

+                    if (paramD.sntp_process_result == "failure") {

+                        callback(false);

+                    } else if (paramD.sntp_process_result == "success") {

+                        callback(true);

+                    } else {

+                        setTimeout(checkSyncStatus, 2000);

+                    }

+                },

+                error: function () {

+                    callback(false);

+                }

+            });

+        }

+    }

+    function addUrlFilterRule(values, callback) {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values) {

+            var valueReq = $.extend({}, values);

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == "success") {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getUrlFilterList() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            return {

+                cmd: "websURLFilters"

+            };

+        }

+        function deal(paramD) {

+            var urlFilterRules = [];

+            if (paramD) {

+                if (paramD.websURLFilters.length == 0) {

+                    return {

+                        urlFilterRules: []

+                    };

+                } else {

+                    var tempArray = paramD.websURLFilters.split(";");

+                    for (var i = 0; i < tempArray.length; i++) {

+                        var aRule = {};

+                        aRule.index = i;

+                        aRule.url = tempArray[i];

+                        urlFilterRules.push(aRule);

+                    }

+                    return {

+                        urlFilterRules: urlFilterRules

+                    };

+                }

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function deleteSelectedRules(values, callback) {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values) {

+            var valueReq = $.extend({}, values);

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == "success") {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getWdsInfo() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            return {

+                multi_data: "1",

+                cmd: "wifi_wds_mode,wifi_wds_ssid,wifi_wds_AuthMode,wifi_wds_EncrypType,wifi_wds_WPAPSK1,wifi_cur_state "

+            };

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return {

+                    currentMode: paramD.wifi_wds_mode,

+                    wdsSSID: paramD.wifi_wds_ssid,

+                    wdsAuthMode: paramD.wifi_wds_AuthMode,

+                    wdsEncrypType: paramD.wifi_wds_EncrypType,

+                    wdsWPAPSK1: paramD.wifi_wds_WPAPSK1,

+                    RadioOff: paramD.wifi_cur_state == "1" ? "1" : "0"

+                };

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setWDS(values, callback) {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values) {

+            var valueReq = $.extend({}, values);

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == "success") {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getSyslogInfo() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            return {

+                multi_data: "1",

+                cmd: "syslog_mode,debug_level"

+            };

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return {

+                    currentMode: paramD.syslog_mode,

+                    debugLevel: paramD.debug_level

+                };

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setSysLog(values, callback) {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values) {

+            var valueReq = $.extend({}, values);

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == "success") {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getMacFilterInfo() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            return {

+                multi_data: "1",

+                cmd: "ACL_mode,wifi_mac_black_list,wifi_hostname_black_list,wifi_cur_state,user_ip_addr,client_mac_address,wifi_mac_white_list"

+            };

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return {

+                    ACL_mode: paramD.ACL_mode,

+                    wifi_mac_black_list: paramD.wifi_mac_black_list,

+                    wifi_hostname_black_list: paramD.wifi_hostname_black_list,

+                    RadioOff: paramD.wifi_cur_state == "1" ? "1" : "0",

+                    user_ip_addr: paramD.user_ip_addr,

+                    client_mac_address: paramD.client_mac_address,

+                    wifi_mac_white_list: paramD.wifi_mac_white_list

+                };

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setMacFilter() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values) {

+            var valueReq = $.extend({

+                goformId: 'WIFI_MAC_FILTER',

+            }, values);

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == "success") {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getFastbootSetting() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values) {

+            return {

+                cmd: "mgmt_quicken_power_on,need_hard_reboot,need_sim_pin",

+                multi_data: 1

+            };

+        }

+        function deal(paramD) {

+            return {

+                fastbootEnabled: paramD.mgmt_quicken_power_on == '1' ? '1' : '0',

+                need_hard_reboot: paramD.need_hard_reboot,

+                need_sim_pin: paramD.need_sim_pin == 'yes' ? 'yes' : 'no'

+            };

+        }

+    }

+    function setFastbootSetting() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values) {

+            return {

+                goformId: "MGMT_CONTROL_POWER_ON_SPEED",

+                mgmt_quicken_power_on: values.fastbootEnabled

+            };

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == "success") {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function turnOffDevice() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "TURN_OFF_DEVICE";

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function restart() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "REBOOT_DEVICE";

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getScheduleSetting() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "schedule_restart_enable,schedule_restart_hour,schedule_restart_minute";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var result = {};

+                result.scheduleSetting = paramD.schedule_restart_enable == "1" ? "1" : "0";

+                result.scheduleHour = paramD.schedule_restart_hour;

+                result.scheduleMinute = paramD.schedule_restart_minute;

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setScheduleSetting() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "SCHEDULE_SETTING";

+            valueReq.scheduleEnabled = values.scheduleSetting;

+            if (valueReq.scheduleEnabled == '1') {

+                valueReq.scheduleHour = values.scheduleHour;

+                valueReq.scheduleMinute = values.scheduleMinute;

+            }

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getCwmpSetting() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "cwmp_enable,acs_url,acs_username,acs_password,periodic_enable,periodic_interval,cpe_username,cpe_password";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var result = {};

+                result.cwmpSetting = paramD.cwmp_enable == "1" ? "1" : "0";

+                result.acsUrl = paramD.acs_url;

+                result.acsUsername = paramD.acs_username;

+                result.acsPassword = paramD.acs_password;

+                result.periodicEnabled = paramD.periodic_enable == "1" ? "1" : "0";

+                result.periodicInterval = paramD.periodic_interval;

+                result.cpeUsername = paramD.cpe_username;

+                result.cpePassword = paramD.cpe_password;

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setCwmpSetting() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "CWMP_SETTING";

+            valueReq.cwmpEnabled = values.cwmpSetting;

+            if (valueReq.cwmpEnabled == '1') {

+                valueReq.acsUrl = values.acsUrl;

+                valueReq.acsUsername = values.acsUsername;

+                valueReq.acsPassword = values.acsPassword;

+                valueReq.periodicEnabled = values.periodicEnabled;

+                if (valueReq.periodicEnabled == '1') {

+                    valueReq.periodicInterval = values.periodicInterval;

+                }

+                valueReq.cpeUsername = values.cpeUsername;

+                valueReq.cpePassword = values.cpePassword;

+            }

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getNewVersionState() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "fota_new_version_state,fota_current_upgrade_state,fota_package_already_download";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var hasNewVersion = (paramD.fota_new_version_state == 'has_critical' || paramD.fota_new_version_state == 'has_optional' || paramD.fota_new_version_state == 'already_has_pkg');

+                paramD.hasNewVersion = hasNewVersion;

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getMandatory() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            if (config.UPGRADE_TYPE == "OTA") {

+                valueReq.cmd = "is_mandatory";

+            } else {

+                valueReq.cmd = "fota_new_version_state";

+            }

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                if (config.UPGRADE_TYPE == "OTA") {

+                    return {

+                        "is_mandatory": paramD.is_mandatory == "1"

+                    };

+                } else {

+                    return {

+                        "is_mandatory": paramD.fota_new_version_state == "has_critical"

+                    };

+                }

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getUpgradeResult() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "upgrade_result";

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getCurrentUpgradeState() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "fota_current_upgrade_state";

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                paramD.current_upgrade_state = paramD.fota_current_upgrade_state;

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getPackSizeInfo() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "fota_pkg_total_size,fota_dl_pkg_size";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setUpgradeSelectOp() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "IF_UPGRADE";

+            valueReq.select_op = values.selectOp;

+            if (valueReq.select_op == 'check') {

+                valueReq.ota_manual_check_roam_state = 1;

+            }

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getOTAUpdateSetting() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "fota_updateMode,fota_updateIntervalDay,fota_allowRoamingUpdate";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return {

+                    updateMode: paramD.fota_updateMode,

+                    updateIntervalDay: paramD.fota_updateIntervalDay,

+                    allowRoamingUpdate: paramD.fota_allowRoamingUpdate

+                };

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setOTAUpdateSetting() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "SetUpgAutoSetting";

+            valueReq.UpgMode = values.updateMode;

+            valueReq.UpgIntervalDay = values.updateIntervalDay;

+            valueReq.UpgRoamPermission = values.allowRoamingUpdate;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == "success") {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getManualOTAUpdateSetting() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "fota_manualUpgradeURL";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return {

+                    updateURL: paramD.fota_manualUpgradeURL

+                };

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setManualOTAUpdateSetting() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "SetUpgManualSetting";

+            valueReq.UpgURL = values.updateURL;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == "success") {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getOTAlastCheckTime() {

+        return getParams({

+            nv: ['dm_last_check_time']

+        }, arguments[1], arguments[2]);

+    }

+    function getSignalStrength() {

+        return getParams({

+            nv: ['network_type', 'sub_network_type', 'rssi', 'rscp', 'lte_rsrp']

+        }, arguments[1], arguments[2]);

+    }

+    function clearUpdateResult() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "RESULT_RESTORE";

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == "success") {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function childGroupList() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {

+                cmd: "childGroupList"

+            };

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && (paramD.childGroupList || paramD.devices)) {

+                return paramD;

+            } else {

+                return {

+                    devices: []

+                };

+            }

+        }

+    }

+    function addChildGroup() {

+        return stuffMake(arguments, config.currentUserInChildGroup == false ? {}

+             : {

+            errorType: 'no_auth'

+        }, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {

+                goformId: "ADD_DEVICE",

+                mac: values.macAddress

+            };

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == 'success') {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function removeChildGroup() {

+        return stuffMake(arguments, config.currentUserInChildGroup == false ? {}

+             : {

+            errorType: 'no_auth'

+        }, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {

+                goformId: "DEL_DEVICE",

+                mac: values.mac

+            };

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == 'success') {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function checkCurrentUserInChildGroup(devices) {

+        if (typeof config.currentUserInChildGroup == "undefined") {

+            var childGroupDevice = [];

+            if (typeof devices != "undefined") {

+                childGroupDevice = devices;

+            } else {

+                childGroupDevice = childGroupList({}).devices;

+            }

+            var userMacAddr = getUserMacAddr({}).get_user_mac_addr;

+            var found = _.find(childGroupDevice, function (item) {

+                return item.mac == userMacAddr;

+            });

+            config.currentUserInChildGroup = typeof found != 'undefined';

+            return {

+                result: typeof found != 'undefined'

+            };

+        }

+        return {

+            result: config.currentUserInChildGroup

+        };

+    }

+    function getUserMacAddr() {

+        return getParams({

+            nv: 'get_user_mac_addr'

+        }, arguments[1], arguments[2]);

+    }

+    function getHostNameList() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {

+                cmd: "hostNameList"

+            };

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && (paramD.hostNameList || paramD.devices)) {

+                return paramD;

+            } else {

+                return {

+                    devices: []

+                };

+            }

+        }

+    }

+    function editHostName() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {

+                goformId: "EDIT_HOSTNAME",

+                mac: values.mac,

+                hostname: values.hostname

+            };

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == 'success') {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getSiteWhiteList() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {

+                cmd: "site_white_list"

+            };

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && (paramD.site_white_list || paramD.siteList)) {

+                return paramD;

+            } else {

+                return {

+                    siteList: []

+                };

+            }

+        }

+    }

+    function removeSiteWhite() {

+        return stuffMake(arguments, config.currentUserInChildGroup == false ? {}

+             : {

+            errorType: 'no_auth'

+        }, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {

+                goformId: "REMOVE_WHITE_SITE",

+                ids: values.ids.join(',')

+            };

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == 'success') {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function saveSiteWhite() {

+        return stuffMake(arguments, config.currentUserInChildGroup == false ? {}

+             : {

+            errorType: 'no_auth'

+        }, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {

+                goformId: "ADD_WHITE_SITE",

+                name: values.name,

+                site: values.site

+            };

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == 'success') {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getTimeLimited() {

+        var defaultResult = {

+            '0': [],

+            '1': [],

+            '2': [],

+            '3': [],

+            '4': [],

+            '5': [],

+            '6': []

+        };

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {

+                cmd: "time_limited"

+            };

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return parseTimeLimited(paramD);

+            } else {

+                return defaultResult;

+            }

+        }

+        function parseTimeLimited(paramD) {

+            if (paramD.time_limited == '') {

+                return {

+                    time_limited: []

+                };

+            }

+            var weeks = paramD.time_limited.split(';');

+            _.each(weeks, function (week) {

+                var weekTime = week.split('+');

+                if (weekTime.length == 2) {

+                    defaultResult[weekTime[0]] = weekTime[1].split(',');

+                }

+            });

+            return defaultResult;

+        }

+    }

+    function saveTimeLimited() {

+        return stuffMake(arguments, config.currentUserInChildGroup == false ? {}

+             : {

+            errorType: 'no_auth'

+        }, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {

+                goformId: "SAVE_TIME_LIMITED",

+                time_limited: values.time

+            };

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == 'success') {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getTsw() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {

+                cmd: "openEnable,closeEnable,openTime,closeTime",

+                multi_data: '1'

+            };

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                if (paramD.openTime.indexOf(':') != -1) {

+                    var open = paramD.openTime.split(':');

+                    paramD.openH = leftInsert(open[0], 2, '0');

+                    paramD.openM = leftInsert(open[1], 2, '0');

+                } else {

+                    paramD.openH = '06';

+                    paramD.openM = '00';

+                }

+                if (paramD.closeTime.indexOf(':') != -1) {

+                    var close = paramD.closeTime.split(':');

+                    paramD.closeH = leftInsert(close[0], 2, '0');

+                    paramD.closeM = leftInsert(close[1], 2, '0');

+                } else {

+                    paramD.closeH = '22';

+                    paramD.closeM = '00';

+                }

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function saveTsw() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {

+                goformId: "SAVE_TSW",

+                openEnable: values.openEnable,

+                closeEnable: values.closeEnable

+            };

+            if (values.openEnable == '1') {

+                valueReq.openTime = values.openTime;

+                valueReq.closeTime = values.closeTime;

+            }

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == 'success') {

+                return paramD;

+            } else if (paramD && paramD.result == 'failure') {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function trafficCalibration() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {

+                goformId: "FLOW_CALIBRATION_MANUAL",

+                calibration_way: values.way,

+                time: values.way == 'time' ? values.value : 0,

+                data: values.way == 'data' ? values.value : 0

+            };

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == 'success') {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getParams() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            if (_.isArray(values.nv)) {

+                valueReq.cmd = values.nv.join(',');

+                valueReq.multi_data = 1;

+            } else {

+                valueReq.cmd = values.nv;

+            }

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getRedirectData() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "vwim_mc_state,traffic_overrun,detect_new_version";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var result = {};

+                result.vwim_mc_state = paramD.vwim_mc_state;

+                result.traffic_overrun = paramD.traffic_overrun;

+                result.detect_new_version = paramD.detect_new_version;

+                result.blc_wan_mode = informationAll.blc_wan_mode;

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function clearRedirectFlag() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "CLEAR_REDIRECT_FLAG";

+            valueReq.flag_id = values.redirectFlags;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getV4Switch() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "lock_zone_enable,pin_interlock_and_V4_lock";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setV4Switch() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "PIN_LOCK_V4_ENCODE";

+            valueReq.pin_interlock_and_V4_lock = values.pin_interlock_and_V4_lock;

+            valueReq.TspLock_key_data = values.TspLock_key_data;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == "success") {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getCellId() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "cell_id_list,global_cell_id,network_type,sub_network_type,cell_not_correct";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setCellIdSwitch() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "LOCK_ZONE";

+            valueReq.lock_zone_enable = values.lock_zone_enable;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD && paramD.result == "success") {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getUpdateType() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {

+                cmd: "update_type"

+            };

+            return valueReq;

+        }

+        function deal(paramD) {

+            return {

+                update_type: paramD.update_type ? paramD.update_type : "mifi_fota"

+            }

+        }

+    }

+    function getSecurityInfo() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.cmd = "AuthMode,passPhrase";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var result = {};

+                result.AuthMode = paramD.AuthMode;

+                result.passPhrase = config.PASSWORD_ENCODE ? Base64.decode(paramD.passPhrase) : paramD.passPhrase;

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    //can delete

+    function setSecurityInfo() {

+        return stuffMake(arguments, {}, prepare, deal, null, true);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            valueReq.goformId = "SET_WIFI_SECURITY_INFO";

+            valueReq.AuthMode = values.AuthMode;

+            if (valueReq.AuthMode == "WPAPSKWPA2PSK") {

+                valueReq.passPhrase = config.PASSWORD_ENCODE ? Base64.encode(values.passPhrase) : values.passPhrase;

+            }

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }	

+    function setWifiBasic() {

+        stuffMakeAndCheckServerIsOnline(arguments, prepare, deal);

+        function prepare(values) {

+            var valueReq = {

+                goformId: "SET_WIFI_SSID1_SETTINGS",

+                ssid: values.SSID,

+                broadcastSsidEnabled: values.broadcast,

+                MAX_Access_num: values.station,

+                security_mode: values.AuthMode,

+                cipher: values.cipher,

+                NoForwarding: values.NoForwarding,

+                show_qrcode_flag: values.show_qrcode_flag

+            };

+            if (config.WIFI_WEP_SUPPORT) {

+                valueReq.wep_default_key = values.wep_default_key;

+                valueReq.wep_key_1 = values.wep_key_1;

+                valueReq.wep_key_2 = values.wep_key_2;

+                valueReq.wep_key_3 = values.wep_key_3;

+                valueReq.wep_key_4 = values.wep_key_4;

+                if (values.wep_default_key == '1') {

+                    valueReq.WEP2Select = values.WEP2Select;

+                } else if (values.wep_default_key == '2') {

+                    valueReq.WEP3Select = values.WEP3Select;

+                } else if (values.wep_default_key == '3') {

+                    valueReq.WEP4Select = values.WEP4Select;

+                } else {

+                    valueReq.WEP1Select = values.WEP1Select;

+                }

+            }

+            if (values.AuthMode == "WPAPSK" || values.AuthMode == "WPA2PSK" || values.AuthMode == "WPAPSKWPA2PSK" || values.AuthMode == "WPA3Personal" || values.AuthMode == "WPA2WPA3") {

+                valueReq.security_shared_mode = values.cipher;

+                valueReq.passphrase = config.PASSWORD_ENCODE ? Base64.encode(values.passPhrase) : values.passPhrase;

+            } else if (values.AuthMode == "SHARED") {

+                valueReq.security_shared_mode = "WEP";

+                valueReq.security_mode = "SHARED";

+            } else {

+                if (values.encryptType == "WEP") {

+                    valueReq.security_shared_mode = "WEP";

+                    valueReq.security_mode = "OPEN";

+                } else {

+                    valueReq.security_shared_mode = "NONE";

+                }

+            }

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function setWifiBasic4SSID2() {

+        stuffMakeAndCheckServerIsOnline(arguments, prepare, deal);

+        function prepare(values) {

+            var valueReq = {

+                goformId: "SET_WIFI_SSID2_SETTINGS",

+                m_SSID: values.m_SSID,

+                m_HideSSID: values.m_broadcast,

+                m_MAX_Access_num: values.m_station,

+                m_AuthMode: values.m_AuthMode,

+                cipher: values.m_cipher,

+                m_NoForwarding: values.m_NoForwarding,

+                m_show_qrcode_flag: values.m_show_qrcode_flag

+            };

+            if (config.WIFI_WEP_SUPPORT) {

+                valueReq.m_DefaultKeyID = values.m_wep_default_key;

+                valueReq.m_Key1Str1 = values.m_wep_key_1;

+                valueReq.m_Key2Str1 = values.m_wep_key_2;

+                valueReq.m_Key3Str1 = values.m_wep_key_3;

+                valueReq.m_Key4Str1 = values.m_wep_key_4;

+                if (values.m_wep_default_key == '1') {

+                    valueReq.m_Key2Type = values.m_WEP2Select;

+                } else if (values.m_wep_default_key == '2') {

+                    valueReq.m_Key3Type = values.m_WEP3Select;

+                } else if (values.m_wep_default_key == '3') {

+                    valueReq.m_Key4Type = values.m_WEP4Select;

+                } else {

+                    valueReq.m_Key1Type = values.m_WEP1Select;

+                }

+            }

+            if (values.m_AuthMode == "WPAPSK" || values.m_AuthMode == "WPA2PSK" || values.m_AuthMode == "WPAPSKWPA2PSK" || values.m_AuthMode == "WPA3Personal" || values.m_AuthMode == "WPA2WPA3") {

+                valueReq.m_EncrypType = values.m_cipher;

+                valueReq.m_WPAPSK1 = config.PASSWORD_ENCODE ? Base64.encode(values.m_passPhrase) : values.m_passPhrase;

+            } else if (values.m_AuthMode == "SHARED") {

+                valueReq.m_EncrypType = "WEP";

+                valueReq.m_security_mode = "SHARED";

+            } else {

+                if (values.m_encryptType == "WEP") {

+                    valueReq.m_EncrypType = "WEP";

+                    valueReq.m_security_mode = "OPEN";

+                } else {

+                    valueReq.m_EncrypType = "NONE";

+                }

+            }

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function getWifiBasic() {

+        return stuffMake(arguments, {}, prepare, deal, null, false);

+        function prepare(values, isPost) {

+            var valueReq = {};

+            var wpapsk = config.PASSWORD_ENCODE ? "WPAPSK1_encode,m_WPAPSK1_encode," : "imei,rnum_js,WPAPSK1_enaes,m_WPAPSK1_enaes,";

+            valueReq.cmd = "m_ssid_enable,wifi_cur_state,NoForwarding,m_NoForwarding," + wpapsk + "MAX_Station_num," + "SSID1,AuthMode,HideSSID,MAX_Access_num,show_qrcode_flag,EncrypType,Key1Str1,Key2Str1,Key3Str1,Key4Str1,DefaultKeyID," + "m_SSID,m_AuthMode,m_HideSSID,m_MAX_Access_num,m_EncrypType,m_show_qrcode_flag,m_DefaultKeyID,m_Key1Str1,m_Key2Str1,m_Key3Str1,m_Key4Str1,rotationFlag,wifi_sta_connection";

+            valueReq.multi_data = 1;

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                var result = {

+                    wifi_enable: paramD.wifi_cur_state == "1" ? "1" : "0",

+                    multi_ssid_enable: paramD.m_ssid_enable,

+                    MAX_Station_num: $.isNumeric(paramD.MAX_Station_num) ? paramD.MAX_Station_num : config.MAX_STATION_NUMBER,

+                    AuthMode: paramD.AuthMode,

+                    SSID: paramD.SSID1,

+                    broadcast: paramD.HideSSID,

+                    apIsolation: paramD.NoForwarding,

+                    passPhrase: config.PASSWORD_ENCODE ? Base64.decode(paramD.WPAPSK1_encode) : wifiDecode(paramD.rnum_js,paramD.imei,paramD.WPAPSK1_enaes),

+                    MAX_Access_num: paramD.MAX_Access_num,

+                    cipher: paramD.EncrypType == "TKIP" ? "0" : paramD.EncrypType == "AES" ? 1 : 2,

+                    encryptType: paramD.EncrypType,

+                    show_qrcode_flag: paramD.show_qrcode_flag == "1" ? true : false,

+                    keyID: paramD.DefaultKeyID,

+                    Key1Str1: paramD.Key1Str1,

+                    Key2Str1: paramD.Key2Str1,

+                    Key3Str1: paramD.Key3Str1,

+                    Key4Str1: paramD.Key4Str1,

+                    m_SSID: paramD.m_SSID,

+                    m_broadcast: paramD.m_HideSSID,

+                    m_apIsolation: paramD.m_NoForwarding,

+                    m_MAX_Access_num: paramD.m_MAX_Access_num,

+                    m_AuthMode: paramD.m_AuthMode,

+                    m_passPhrase: config.PASSWORD_ENCODE ? Base64.decode(paramD.m_WPAPSK1_encode) : wifiDecode(paramD.rnum_js,paramD.imei,paramD.m_WPAPSK1_enaes),

+                    m_cipher: paramD.m_EncrypType == "TKIP" ? "0" : paramD.m_EncrypType == "AES" ? 1 : 2,

+                    m_show_qrcode_flag: paramD.m_show_qrcode_flag == "1" ? true : false,

+                    m_encryptType: paramD.m_EncrypType,

+                    m_keyID: paramD.m_DefaultKeyID,

+                    m_Key1Str1: paramD.m_Key1Str1,

+                    m_Key2Str1: paramD.m_Key2Str1,

+                    m_Key3Str1: paramD.m_Key3Str1,

+                    m_Key4Str1: paramD.m_Key4Str1,

+                    rotationFlag: paramD.rotationFlag,

+                    ap_station_enable: paramD.wifi_sta_connection

+                };

+                return result;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }	

+    function setWifiBasicMultiSSIDSwitch() {

+        stuffMakeAndCheckServerIsOnline(arguments, prepare, deal);

+        function prepare(values) {

+            var paraTemp = values;

+            if (values.wifiEnabled == '0') {

+                paraTemp = {

+                    wifiEnabled: values.wifiEnabled

+                }

+            }

+            var valueReq = $.extend({

+                goformId: "SET_WIFI_INFO",

+            }, paraTemp);

+            return valueReq;

+        }

+        function deal(paramD) {

+            if (paramD) {

+                return paramD;

+            } else {

+                return errUnknownObj;

+            }

+        }

+    }

+    function stuffMake(array, result, prepare, dealMethod, errorObject, isPost) {

+        var values = array[0],

+        callback = array[1],

+        errorCallback = array[2];

+        var objectToReturn;

+        if (result && typeof result.errorType === 'string') {

+            objectToReturn = $.extend(errUnknownObj, result);

+            if (!callback) {

+                return objectToReturn;

+            }

+            doCallback(objectToReturn, callback, errorCallback);

+        } else {

+            objectToReturn = $.extend({}, result);

+            var valueReq;

+            if (prepare) {

+                valueReq = prepare(values, isPost);

+            } else {

+                valueReq = values;

+            }

+            if (!callback) {

+                if (valueReq && (valueReq.cmd || valueReq.goformId)) {

+                    var r = reqSync(valueReq, isPost);

+                    if (dealMethod) {

+                        objectToReturn = $.extend({}, dealMethod(r));

+                    } else {

+                        objectToReturn = r;

+                    }

+                }

+                return objectToReturn;

+            } else {

+                if (valueReq && (valueReq.cmd || valueReq.goformId)) {

+                    reqAsync(valueReq, function (paramD) {

+                        if (dealMethod) {

+                            objectToReturn = $.extend({}, dealMethod(paramD));

+                        } else {

+                            objectToReturn = $.extend({}, paramD);

+                        }

+                        if (!valueReq.notCallback) {

+                            doCallback(objectToReturn, callback, errorCallback);

+                        }

+                    }, function () {

+                        if (errorObject) {

+                            objectToReturn = $.extend(errUnknownObj, errorObject);

+                        } else {

+                            objectToReturn = $.extend(errUnknownObj, {

+                                errorType: 'Unknown'

+                            });

+                        }

+                        doCallback(objectToReturn, callback, errorCallback);

+                    }, isPost);

+                } else {

+                    doCallback(objectToReturn, callback, errorCallback);

+                }

+            }

+        }

+        function doCallback(resultToReturn, callback, errorCallback) {

+            errorCallback = errorCallback ? errorCallback : callback;

+            if (isErrorObject(resultToReturn)) {

+                switch (resultToReturn.errorType) {

+                case 'cellularNetworkError':

+                case 'deviceError':

+                case 'wifiConnectionError':

+                    window.receivedNonSpecificError(resultToReturn);

+                    break;

+                default:

+                    errorCallback(resultToReturn);

+                }

+            } else {

+                callback(resultToReturn);

+            }

+        }

+    }	

+    function reqSync(values, isPost) {

+        return reqAJAX(values, null, null, false, isPost);

+    }

+    function reqAsync(values, successCallback, errorCallback, isPost) {

+        reqAJAX(values, successCallback, errorCallback, true, isPost);

+    }

+    function getString(values){

+    var regexp = /^[A-z0-9]+$/;

+    var matches = values.match(regexp);

+    if (matches == null){

+        return "error";

+    } else {

+        return values;

+    }

+    }

+    function reqAJAX(values, successCallback, errorCallback, async, isPost) {

+        var result = null;

+        $.ajax({

+            type: !!isPost ? "POST" : "GET",

+            url: isPost ? "/reqproc/proc_post" : values.cmd ? "/reqproc/proc_get" : "/reqproc/proc_post",

+            data: values,

+            dataType: "json",

+            async: !!async,

+            cache: false,

+            error: function (paramD) {

+                if (async) {

+                    errorCallback(paramD);

+                } else if (paramD.status == 200) {

+                    result = jQuery.parseJSON('(' + getString(paramD.responseText) + ')');

+                }

+            },

+            success: function (paramD) {

+                if (async) {

+                    successCallback(paramD);

+                } else {

+                    result = paramD;

+                }

+            }

+        });

+        if (!async) {

+            return result;

+        }

+    }

+	    var informationAll = {

+        networkType: "",

+        signalImg: "0",

+        spn_b1_flag: "1",

+        spn_name_data: "",

+        spn_b2_flag: "1",

+        networkOperator: "China Mobile",

+        connectStatus: "ppp_disconnected",

+        rj45ConnectStatus: "rj45_dead",

+        attachedDevices: [],

+        ssid1AttachedNum: 0,

+        ssid2AttachedNum: 0,

+        data_counter: {

+            uploadRate: 0,

+            downloadRate: 0,

+            totalSent: 0,

+            totalReceived: 0,

+            totalConnectedTime: 0,

+            currentSent: 0,

+            currentReceived: 0,

+            currentConnectedTime: 0,

+            monthlySent: 0,

+            monthlyReceived: 0,

+            monthlyConnectedTime: 0,

+            month: ''

+        },

+        newSmsReceived: false,

+        smsReportReceived: false,

+        smsUnreadCount: "0",

+        isLoggedIn: undefined,

+        limitVolumeEnable: false,

+        limitVolumeType: '1',

+        limitVolumePercent: "100",

+        limitVolumeSize: "0",

+        allowRoamingUpdate: "0",

+        blc_wan_mode: "",

+        ap_station_enable: undefined,

+        ap_station_mode: undefined,

+        dialMode: '',

+        ethWanMode: 'AUTO',

+        fota_user_selector: '',

+        defaultWanName: ""

+    };

+    var errUnknownObj = {

+        errorType: 'UnknownError',

+        errorId: '123',

+        errorText: 'UnknownError'

+    };

+    var updateTimerFlag = true;	

+    return {

+        clearRedirectFlag: clearRedirectFlag,

+        connect: connect,

+        disconnect: disconnect,

+        getSIMPhoneBookCapacity: getSIMPhoneBookCapacity,

+        getDevicePhoneBookCapacity: getDevicePhoneBookCapacity,

+		getDevicePhoneBooks: getDevicePhoneBooks,

+        getSIMPhoneBooks: getSIMPhoneBooks,

+        getPhoneBooks: getPhoneBooks,

+        getPhoneBookReady: getPhoneBookReady,

+        getPhoneBooksByGroup: getPhoneBooksByGroup,

+        deletePhoneBooks: deletePhoneBooks,

+        deleteAllPhoneBooks: deleteAllPhoneBooks,

+        deleteAllPhoneBooksByGroup: deleteAllPhoneBooksByGroup,		

+        savePhoneBook: savePhoneBook,

+        deleteAllMessages: deleteAllMessages,

+        deleteMessage: deleteMessage,

+        setSmsRead: setSmsRead,

+        sendSMS: sendSMS,

+        saveSMS: saveSMS,

+        getSMSReady: getSMSReady,

+        getSMSMessages: getSMSMessages,

+        getSMSDeliveryReport: getSMSDeliveryReport,

+        getSmsCapability: getSmsCapability,

+        resetNewSmsReceivedVar: resetNewSmsReceivedVar,

+        resetSmsReportReceivedVar: resetSmsReportReceivedVar,

+        getSmsSetting: getSmsSetting,

+        setSmsSetting: setSmsSetting,

+		getAttachedCableDevices: getAttachedCableDevices,

+		getCurrentlyAttachedDevicesInfo: getCurrentlyAttachedDevicesInfo,

+		getConnectionInfo: getConnectionInfo,

+        getRedirectData: getRedirectData,

+        getLanguage: getLanguage,

+        setLanguage: setLanguage,

+        getNetSelectInfo: getNetSelectInfo,		

+        getSecurityInfo: getSecurityInfo,

+        setSecurityInfo: setSecurityInfo,

+        getStatusInfo: getStatusInfo,

+        getConnectionMode: getConnectionMode,

+        setConnectionMode: setConnectionMode,

+        getWifiBasic: getWifiBasic,

+        setWifiBasic: setWifiBasic,

+        setWifiBasic4SSID2: setWifiBasic4SSID2,

+        setWifiBasicMultiSSIDSwitch: setWifiBasicMultiSSIDSwitch, 

+        getWpsInfo: getWpsInfo,

+        openWps: openWps,

+        getSleepMode: getSleepMode,

+        setSleepMode: setSleepMode,

+        getWifiAdvance: getWifiAdvance,

+        setWifiAdvance: setWifiAdvance,

+        getWifiRange: getWifiRange,

+        setWifiRange: setWifiRange,

+

+        getLoginStatus: getLoginStatus,

+        getLoginData: getLoginData,

+        login: login,

+        logout: logout, 

+        changeManageInfo: changeManageInfo,

+        getPinData: getPinData,

+        enablePin: enablePin,

+        disablePin: disablePin,

+        changePin: changePin,

+		enterPIN: enterPIN,

+        enterPUK: enterPUK,

+        getLanInfo: getLanInfo,

+        setLanInfo: setLanInfo,       

+        getApnSettings: getApnSettings,

+        deleteApn: deleteApn,

+        setDefaultApn: setDefaultApn,

+        addOrEditApn: addOrEditApn,

+        getQuickSettingInfo: getQuickSettingInfo,

+        setQuickSetting4IPv6: setQuickSetting4IPv6,

+        scanForNetwork: scanForNetwork,

+        setBearerPreference: setBearerPreference,

+        editHostName: editHostName,

+        getSiteWhiteList: getSiteWhiteList,

+        removeSiteWhite: removeSiteWhite,

+        saveSiteWhite: saveSiteWhite,

+        setNetwork: setNetwork,

+        getUpnpSetting: getUpnpSetting,

+        setUpnpSetting: setUpnpSetting,

+        getDmzSetting: getDmzSetting,

+        setDmzSetting: setDmzSetting,

+        getDeviceInfo: getDeviceInfo,

+        getDeviceInfoLow: getDeviceInfoLow,

+        getPortForward: getPortForward,

+        setPortForward: setPortForward,

+        getPortFilter: getPortFilter,

+        setPortFilterBasic: setPortFilterBasic,

+        setPortFilter: setPortFilter,

+        deleteFilterRules: deleteFilterRules,

+        getPortMap: getPortMap,

+        setPortMap: setPortMap,

+        enablePortMap: enablePortMap,

+        deleteMapRules: deleteMapRules,

+        getTrafficAlertInfo: getTrafficAlertInfo,

+        setTrafficAlertInfo: setTrafficAlertInfo,

+        getCurrentUpgradeState: getCurrentUpgradeState,

+        setUpgradeSelectOp: setUpgradeSelectOp,

+        addTimerThings: addTimerSomething,

+        removeTimerThings: removeTimerSomething,

+        getPackSizeInfo: getPackSizeInfo,

+        getMandatory: getMandatory,

+        getOTAUpdateSetting: getOTAUpdateSetting,

+        setOTAUpdateSetting: setOTAUpdateSetting,

+        getManualOTAUpdateSetting: getManualOTAUpdateSetting,

+        setManualOTAUpdateSetting: setManualOTAUpdateSetting,

+        getSignalStrength: getSignalStrength,

+        getOTAlastCheckTime: getOTAlastCheckTime,

+        clearUpdateResult: clearUpdateResult,

+        refreshAPStationStatus: refreshAPStationStatus,

+        getSntpParams: getSntpParams,

+        setSntpSetting: setSntpSetting,

+        setSNTPDate: setSNTPDate,

+        restoreFactorySettings: restoreFactorySettings,

+        checkRestoreStatus: checkRestoreStatus,

+        getSysSecurity: getSysSecurity,

+        setSysSecurity: setSysSecurity,

+        deleteForwardRules: deleteForwardRules,

+        enableVirtualServer: enableVirtualServer,

+        getSDConfiguration: getSDConfiguration,

+        setSdCardMode: setSdCardMode,

+        checkFileExists: checkFileExists,

+        getFileList: getFileList,

+        fileRename: fileRename,

+        getSdMemorySizes: getSdMemorySizes,

+        deleteFilesAndFolders: deleteFilesAndFolders,

+        createFolder: createFolder,

+        setSdCardSharing: setSdCardSharing,

+        setUpdateInfoWarning: setUpdateInfoWarning,

+        getUpdateInfoWarning: getUpdateInfoWarning,

+        getAPStationBasic: getAPStationBasic,

+        setAPStationBasic: setAPStationBasic,

+        getWdsInfo: getWdsInfo,

+        setWDS: setWDS,

+        addUrlFilterRule: addUrlFilterRule,

+        getUrlFilterList: getUrlFilterList,

+        deleteSelectedRules: deleteSelectedRules,

+        getMacFilterInfo: getMacFilterInfo,

+        setMacFilter: setMacFilter,

+        getFastbootSetting: getFastbootSetting,

+        setFastbootSetting: setFastbootSetting,

+        turnOffDevice: turnOffDevice,

+        restart: restart,

+        getScheduleSetting: getScheduleSetting,

+        setScheduleSetting: setScheduleSetting,

+        getCwmpSetting: getCwmpSetting,

+        setCwmpSetting: setCwmpSetting,

+        updateTimerFlag: updateTimerFlag,

+        childGroupList: childGroupList,

+        addChildGroup: addChildGroup,

+        removeChildGroup: removeChildGroup,

+        checkCurrentUserInChildGroup: checkCurrentUserInChildGroup,

+        getTimeLimited: getTimeLimited,

+        saveTimeLimited: saveTimeLimited,

+        getHostNameList: getHostNameList,

+        getHotspotList: getHotspotList,

+        searchHotspot: searchHotspot,

+        getSearchHotspotList: getSearchHotspotList,

+        saveHotspot: saveHotspot,

+        deleteHotspot: deleteHotspot,

+        connectHotspot: connectHotspot,

+        disconnectHotspot: disconnectHotspot,

+        getOpMode: getOpMode,

+        getRj45PlugState: getRj45PlugState,

+        SetOperationMode: SetOperationMode,

+        getPppoeParams: getPppoeParams,

+        setPppoeDialMode: setPppoeDialMode,

+        getTsw: getTsw,

+        saveTsw: saveTsw,

+        trafficCalibration: trafficCalibration,

+        getParams: getParams,

+        getNewVersionState: getNewVersionState,

+        getUpgradeResult: getUpgradeResult,

+        getV4Switch: getV4Switch,

+        setV4Switch: setV4Switch,

+        getCellId: getCellId,

+        setCellIdSwitch: setCellIdSwitch,

+        getDdnsParams: getDdnsParams,

+        setDDNSForward: setDDNSForward,

+        getUpdateType: getUpdateType,

+        getCurretnMAC: getCurretnMAC,

+        getUSSDResponse: getUSSDResponse,

+        USSDReplyCancel: USSDReplyCancel,

+        getNetworkUnlockTimes: getNetworkUnlockTimes,

+        unlockNetwork: unlockNetwork,	

+        getSyslogInfo: getSyslogInfo,

+        setSysLog: setSysLog,		

+    };

+});

+

+ // Router����

+

+define("adm_lan","jquery knockout set service".split(" "),

+

+    function ($, ko, config, service) {

+

+    var originfrmLan = "";

+

+    // ��ȡ·�����������Ϣ

+    function getLanInfo() {

+        return service.getLanInfo();

+    }	

+

+    function hex(val) {

+        var h = (val - 0).toString(16);

+        if (h.length == 1)

+            h = '0' + h;

+        return h.toUpperCase();

+    }	

+

+    function LanViewModel() {

+        var target = this;

+

+        var info = getLanInfo();

+

+        target.dhcpStart = ko.observable(info.dhcpStart);

+        target.dhcpEnd   = ko.observable(info.dhcpEnd);

+        target.dhcpLease = ko.observable(info.dhcpLease);		

+

+        target.ipAddress  = ko.observable(info.ipAddress);

+        target.subnetMask = ko.observable(info.subnetMask);

+        target.dhcpServer = ko.observable(info.dhcpServer);

+

+		target.macAddress = ko.observable(info.macAddress);

+        target.showMacAddress = ko.observable(config.SHOW_MAC_ADDRESS);

+

+        target.hasWifi        = ko.observable(config.HAS_WIFI);

+        target.hasUssd        = config.HAS_USSD;

+        target.hasDdns        = config.DDNS_SUPPORT;

+

+        target.hasUpdateCheck = config.HAS_UPDATE_CHECK;

+

+        target.clear = function () {

+            clearTimer();

+            init();

+            clearValidateMsg();

+        };		

+

+        target.refreshStatus = function () {

+            var connInfo = service.getConnectionInfo();

+            if (connInfo.connectStatus == 'ppp_disconnected') {

+                $('input', '#frmLan').each(function () {

+                    $(this).attr("disabled", false);

+                });

+            } else {

+                $('input', '#frmLan').each(function () {

+                    $(this).attr("disabled", true);

+                });

+

+                clearValidateMsg();

+            }

+        };

+

+        // ������Ӧ�������������ñ���

+        target.saveAct = function () {

+            showLoading();

+            var params = {

+                ipAddress:  target.ipAddress(),

+                subnetMask: target.subnetMask(),

+                dhcpServer: target.dhcpServer(),

+                dhcpStart:  target.dhcpStart(),

+                dhcpEnd:    target.dhcpEnd(),

+                dhcpLease:  target.dhcpLease()

+            };

+

+            service.setLanInfo(params, function (result) {

+                if (result.result == "success") {

+                    successOverlay();

+                    target.clear();

+                } else {

+                    errorOverlay();

+                }

+            });

+        };		

+

+        // ������Ӧ�������������ñ���

+        target.save = function () {

+            var frmLanObj = $('#frmLan').serialize();

+            if (frmLanObj == originfrmLan) {

+                showAlert("setting_no_change");

+                return false;

+            }

+            if (config.RJ45_SUPPORT) {

+                var pppObj = service.getPppoeParams();

+                if (sf_isValidate_StaticIP(pppObj.static_wan_ipaddr, target.ipAddress(), target.subnetMask())) {

+                    showAlert("lan_tip_staticip_notsame");

+                    return false;

+                }

+            }

+            showConfirm("lan_confirm_reopen", function () {

+                target.saveAct();

+            });

+        };

+

+            target.refreshStatus();

+            // dhcpServer�л���Ӧ����

+            target.dhcpServerHandler = function () {

+                $("#txtIpAddress").parent().find(".error").hide();

+                $("#txtIpAddress").show();

+                return true;

+            };

+        addTimeout(function () {

+            originfrmLan = $('#frmLan').serialize();

+        }, 500);

+    }

+

+

+    function sf_opAnd4Byte(i_v1, i_v2) {

+        var index;

+        var var1 = [];

+        var var2 = [];

+        var result='0x';

+

+        for (index=2,index_tmp=0; index<10; index+=2,index_tmp++) {

+            var1[index_tmp]='0x'+i_v1.substring(index,index+2);

+            var2[index_tmp]='0x'+i_v2.substring(index,index+2);

+        }

+

+        for (index=0; index<4; index++) {

+            result = result + hex(var1[index]&var2[index]);

+        }

+

+        return result - 0;

+    }

+

+    // ������ر���У�����	

+    $.validator.addMethod("dhcp_check", function (i_value, i_element, i_parameter) {

+        var dhcpIp =  i_parameter == "start" ?  $('#txtDhcpIpPoolStart').val() : $('#txtDhcpIpPoolEnd').val();

+        var result = sf_isValidate_Gateway($('#txtIpAddress').val(), $('#txtSubnetMask').val(), dhcpIp);

+        return this.optional(i_element) || result;

+    });

+

+    $.validator.addMethod("dhcpCompare", function (i_value, i_element, i_parameter) {

+        var result;

+        if(i_parameter == "#txtDhcpIpPoolStart") {

+            result = sf_isValidate_StartEndIp($('#txtIpAddress').val(), $('#txtSubnetMask').val(), $(i_parameter).val(), i_value);

+        }

+        else {

+            result = sf_isValidate_StartEndIp($('#txtIpAddress').val(), $('#txtSubnetMask').val(), i_value, $(i_parameter).val());

+        }

+        return result != 1;

+    });

+

+    $.validator.addMethod("ipRange", function (i_value, i_element, i_parameter) {

+        var DHCP_flag = false;

+        if($('#dhcpEnable').is(':checked')){

+            DHCP_flag = true;

+        }

+        var result = sf_isValidate_StartEndIp(i_value, $('#txtSubnetMask').val(), $('#txtDhcpIpPoolStart').val(), $('#txtDhcpIpPoolEnd').val(), DHCP_flag);

+        return result != 2;

+    });

+

+    $.validator.addMethod("subnetmask_check", function (i_value, i_element, i_parameter) {

+        var result = sf_isValidate_Netmask(i_value);

+        return this.optional(i_element) || result;

+    });	

+

+

+    // ��̬��ЧIPУ�麯��

+    function sf_isValidate_StaticIP(i_ip, i_lanIp, i_lanMask){

+            if(!i_ip || !i_lanIp || !i_lanMask){//������������

+                return false;

+            }

+

+		       //������IP���

+            if (i_ip == i_lanIp) { 

+                return true;

+            }

+

+            var res1 = [];

+            var res2 = [];

+

+            var mask_array = [];

+

+            ip_array = i_ip.split(".");

+            lanIp_array = i_lanIp.split(".");

+            mask_array  = i_lanMask.split(".");

+            for(var index = 0; index < ip_array.length; index += 1){

+                res1.push(parseInt(mask_array[index]) & parseInt(ip_array[index]));

+                res2.push(parseInt(mask_array[index]) & parseInt(lanIp_array[index]));

+            }

+            if(res2.join(".") != res1.join(".")){//�ڲ�ͬ����

+                return false;

+            }else{//��ͬһ����

+                return true;

+            }

+        }

+

+

+    function sf_isValidate_NetmaskIP(i_ip) {

+        return (i_ip == 255

+      		 || i_ip == 254 

+			 || i_ip == 252 

+			 || i_ip == 248

+             || i_ip == 240 

+			 || i_ip == 224 

+			 || i_ip == 192 

+			 || i_ip == 128

+			 || i_ip == 0);

+    }

+

+	function sf_convertIpToString(i_ip)

+	{

+        var s_i1 = i_ip.indexOf('.');

+        var s_i2 = i_ip.indexOf('.', (s_i1 + 1));

+        var s_i3 = i_ip.indexOf('.', (s_i2 + 1));

+        o_ip = hex(i_ip.substring(0, s_i1)) + hex(i_ip.substring((s_i1 + 1), s_i2)) + hex(i_ip.substring((s_i2 + 1), s_i3)) + hex(i_ip.substring((s_i3 + 1), i_ip.length));

+        o_ip = '0x' + o_ip;

+

+        return 	o_ip;	

+	}

+

+	function sf_getIpString_3(i_ip)

+	{

+        var i1 = i_ip.indexOf('.');

+        var i2 = i_ip.indexOf('.', (i1 + 1));

+        var i3 = i_ip.indexOf('.', (i2 + 1));

+        var i4 = i_ip.substring((i3+1),i_ip.length)-0;

+

+        return 	i4;	

+	}	

+

+

+    // ����У�麯��

+    function sf_isValidate_Gateway(i_wanIp, i_netmaskIp, i_gatewayIp) {

+	    var s_wanIp = sf_convertIpToString(i_wanIp);

+		var lan4 = sf_getIpString_3(i_wanIp);

+

+	    var s_netmaskIp = sf_convertIpToString(i_netmaskIp);

+		var mask4 = sf_getIpString_3(i_netmaskIp);		

+

+	    var s_gatewayIp = sf_convertIpToString(i_gatewayIp);

+		var pool4 = sf_getIpString_3(i_gatewayIp);	

+

+        var net_no;

+        var lo_broadcast;		

+

+        if (sf_opAnd4Byte(s_wanIp, s_netmaskIp) != sf_opAnd4Byte(s_gatewayIp, s_netmaskIp)) {

+            return false;

+        }

+

+        net_no       = (lan4 & mask4);

+        lo_broadcast =  (lan4 & mask4) + (255-mask4);

+

+        return !(pool4==net_no || pool4==lo_broadcast);		

+

+    }	

+

+	// ��������У�麯��		

+    function sf_isValidate_Netmask(i_netmask) {

+        var addr = i_netmask.split(".");

+

+		if ("0.0.0.0" == i_netmask || "255.255.255.255" == i_netmask) {

+            return false;

+        }

+

+        if (addr.length != 4) {

+            return false;

+        }

+

+        addr[0] = parseInt(addr[0]);

+        addr[1] = parseInt(addr[1]);

+        addr[2] = parseInt(addr[2]);

+        addr[3] = parseInt(addr[3]);

+

+        if (addr[3] != 0) {

+            if (addr[0] != 255 || addr[1] != 255 || addr[2] != 255) {

+                return false;

+            } else {

+                if (!sf_isValidate_NetmaskIP(addr[3])) {

+                    return false;

+                }

+            }

+        }

+

+        if (addr[2] != 0) {

+            if (addr[0] != 255 || addr[1] != 255) {

+                return false;

+            } else {

+                if (!sf_isValidate_NetmaskIP(addr[2])) {

+                    return false;

+                }

+            }

+        }

+

+        if (addr[1] != 0) {

+            if (addr[0] != 255) {

+                return false;

+            } else {

+                if (!sf_isValidate_NetmaskIP(addr[1])) {

+                    return false;

+                }

+            }

+        }

+

+        if (addr[0] != 255) {

+            return false;

+        }

+

+        return true;

+    }

+

+    // DHCP IP��У�麯��

+    function sf_isValidate_StartEndIp(i_lanIpaddr, i_netIp, i_startIp, i_endIp, i_DHCPFlag) {

+	    s_startIp = sf_convertIpToString(i_startIp);

+		s_endIp   = sf_convertIpToString(i_endIp);

+		s_lanIp   = sf_convertIpToString(i_lanIpaddr);

+

+		if(s_startIp>s_endIp) {

+            return 1;

+        }

+

+        if(s_lanIp >= s_startIp && s_lanIp <= s_endIp) {

+            return 2;

+        }

+

+        return 0;		

+	}

+

+

+    function init() {

+        var container = $('#container');

+        ko.cleanNode(container[0]);

+        var fwVm = new LanViewModel();

+        ko.applyBindings(fwVm, container[0]);

+

+        addInterval(fwVm.refreshStatus, 1000);

+

+        $('#frmLan').validate({

+            submitHandler:function () {

+                fwVm.save();

+            },

+

+            rules:{

+                txtIpAddress: {

+                    lanip_check: true,

+                    ipRange: true

+                },

+                txtSubnetMask: {

+                    ipv4: true,

+                    subnetmask_check: true

+                },

+                txtDhcpIpPoolStart: {

+                    lanip_check: true,

+                    dhcp_check: "start",

+                    dhcpCompare: "#txtDhcpIpPoolEnd"

+                },

+                txtDhcpIpPoolEnd: {

+                    lanip_check: true,

+                    dhcp_check: "end",

+                    dhcpCompare: "#txtDhcpIpPoolStart"

+                },

+                txtDhcpLease: {

+                    range: [1, 65535],

+                    digits: true

+                }

+            },

+

+            groups: {

+                lanip_check: "txtDhcpIpPoolStart txtDhcpIpPoolEnd"

+            },

+

+            errorPlacement: function (error, element) {

+                if (element.attr("name") == "txtDhcpLease") {

+                    error.insertAfter("#errorHolder");

+                } else if (element.attr("name") == "txtDhcpIpPoolStart") {

+                    error.insertAfter("#txtDhcpIpPoolEnd");

+                } else {

+                    error.insertAfter(element);

+                }

+			}

+        });

+

+    }

+

+

+    return {

+        init:init

+    }

+});

+

+define("tr069","jquery knockout set service".split(" "),

+

+    function ($, ko, config, service) {

+        function Tr069ViewModel() {

+            var target = this;

+            target.hasUssd = config.HAS_USSD;

+            target.hasDdns = config.DDNS_SUPPORT;

+            target.hasUpdateCheck = config.HAS_UPDATE_CHECK;

+

+            var cwmpInfo = service.getCwmpSetting();

+

+            target.cwmp_active = ko.observable(cwmpInfo.cwmpSetting);

+            target.cwmp_acs_server_url = ko.observable(cwmpInfo.acsUrl);

+            target.cwmp_acs_username = ko.observable(cwmpInfo.acsUsername);

+            target.cwmp_acs_password = ko.observable(cwmpInfo.acsPassword);

+            target.cwmp_periodic_inform_active = ko.observable(cwmpInfo.periodicEnabled);

+            target.cwmp_periodic_inform_interval = ko.observable(cwmpInfo.periodicInterval);

+            target.cwmp_conn_request_username = ko.observable(cwmpInfo.cpeUsername);

+            target.cwmp_conn_request_password = ko.observable(cwmpInfo.cpePassword);

+

+            // target.cwmp_stun_active=ko.observable('');

+            // target.cwmp_stun_server_addr=ko.observable('');

+            // target.cwmp_stun_server_port=ko.observable('');

+            // target.cwmp_stun_username=ko.observable('');

+            // target.cwmp_stun_password=ko.observable('');

+            // target.cwmp_stun_min_keep_alive_interval=ko.observable('');

+            // target.cwmp_stun_max_keep_alive_interval=ko.observable('');

+            // target.cwmp_udp_notify_limit_num=ko.observable('');

+            // target.cwmp_udp_conn_req_addr=ko.observable('');

+            // target.cwmp_nat_detected_mark=ko.observable('');

+

+            // target.btn=function(name,id,enableName){

+            //     if($('#'+id).is(':checked')){

+            //         $("."+name).animate({left: '22px'});

+            //         //$('#'+name).css('background-color','#FD8204');

+            //         if(enableName==='cwmp_active'){

+            //             target.cwmp_active('1')

+            //         }

+            //         else{

+            //             target.cwmp_stun_active("1")

+            //         }

+            //     }

+            //     else{

+            //         $("."+name).animate({left: '-1px'});

+            //         $('#'+name).css('background-color','white');

+            //         if(enableName==='cwmp_active'){

+            //             target.cwmp_active('0')

+            //         }

+            //         else{

+            //             target.cwmp_stun_active("0")

+            //         }

+            //     }

+            // }

+            // ���TR069

+            target.setting= function() {

+                showLoading();

+                var param = {};

+                param.cwmpSetting = target.cwmp_active();

+                param.acsUrl = target.cwmp_acs_server_url();

+                param.acsUsername = target.cwmp_acs_username();

+                param.acsPassword = target.cwmp_acs_password();

+                param.periodicEnabled = target.cwmp_periodic_inform_active();

+                param.periodicInterval =target.cwmp_periodic_inform_interval();

+                param.cpeUsername = target.cwmp_conn_request_username();

+                param.cpePassword = target.cwmp_conn_request_password();

+                service.setCwmpSetting(param, function (result) {

+                    if (result.result != "success") {

+                        errorOverlay();

+                    } else {

+                        successOverlay();

+                    }

+                });

+            }

+            // ���STUN

+            target.stun=function(){

+                console.log(99999);

+            }

+        }

+

+        function init() {

+            var container = $('#container');

+            ko.cleanNode(container[0]);

+            var imVm = new Tr069ViewModel();

+            ko.applyBindings(imVm, container[0]);

+

+            $('#frmTr069').validate({

+                submitHandler:function () {

+                    imVm.setting();

+                },

+                rules:{

+                    cwmp_acs_server_url: {

+                        url_span: false

+                    },

+                },

+            });

+            $('#frmTrtun').validate({

+                submitHandler:function () {

+                    imVm.stun();

+                },

+                rules:{},

+            });

+            $.validator.addMethod("url_span", validURLWithProtocol);

+        }

+    return {

+        init:init

+    }

+});

+

+// others ����:Fast Boot Settings��Restart and Reset��SNTP��Turn Off Device��PIN Management

+define("adm_others","jquery knockout set service underscore".split(" "),

+

+    function ($, ko, config, service, _) {

+

+		var timeSetModes = _.map(config.sntpTimeSetMode, function(item) {

+			return new Option(item.name, item.value);

+		});

+

+		var timeZones    = _.map(config.timeZone, function(item){

+			return new Option(item.name, item.value);

+		});

+

+		var daylightSave = _.map(config.daylightSave, function(item){

+			return new Option(item.name, item.value);

+		});

+

+		var sv_sntpYears    = [];

+		var sv_sntpMonths   = [];

+		var sv_sntpDates    = [];  //���ݴ�С����������

+		var sv_sntpHours    = [];

+		var sv_sntpMinutes  = [];

+        var sc_startpHours  = [];

+		var sc_startMinutes = [];

+

+		var sf_bigMonth     = [1, 3, 5, 7, 8, 10, 12];

+		var sf_smallMonth   = [4, 6, 9, 11];

+

+		function sf_produceArray(start, end, arryName) {

+			var item = {};

+			for(var i = start; i <= end; i++) {

+				item.name  = i;

+				item.value = i;

+				arryName.push(new Option(item.name, item.value));

+			}

+		}

+

+		//�����ꡢ�¡�ʱ���ֵ�����

+		sf_produceArray(2000, 2030, sv_sntpYears);

+		sf_produceArray(1, 12, sv_sntpMonths);

+		sf_produceArray(0, 23, sv_sntpHours);

+		sf_produceArray(0, 59, sv_sntpMinutes);			

+        sf_produceArray(0, 23, sc_startpHours);

+		sf_produceArray(0, 59, sc_startMinutes);		

+

+        function othersViewModel() {

+            var target = this;

+

+			var inChildGroup = false;

+            var scheduleInfo = service.getScheduleSetting();

+

+            target.fastbootSupport    = config.FAST_BOOT_SUPPORT;

+            target.turnOffSupport     = config.TURN_OFF_SUPPORT;     

+            target.SNTPSupport        = config.HAS_SNTP;

+			target.hasUssd            = config.HAS_USSD;

+			target.hasDdns            = config.DDNS_SUPPORT;

+			target.hasUpdateCheck     = config.HAS_UPDATE_CHECK;

+            target.scheduleSetting = ko.observable(scheduleInfo.scheduleSetting);

+            target.scheduleHour = ko.observable(parseInt(scheduleInfo.scheduleHour));

+            target.scheduleMinute = ko.observable(parseInt(scheduleInfo.scheduleMinute));

+            target.scr_hours   = ko.observableArray(sc_startpHours);

+			target.scr_minutes = ko.observableArray(sc_startMinutes);

+

+

+            if (config.HAS_PARENTAL_CONTROL) {

+                inChildGroup = service.checkCurrentUserInChildGroup().result;

+            }

+            target.currentUserInChildGroup = ko.observable(inChildGroup);

+

+            var sv_fastbootInfo = service.getFastbootSetting();

+            target.fastbootEnableFlag =  ko.observable(config.RJ45_SUPPORT ? (sv_fastbootInfo.need_sim_pin != "yes" && service.getRj45PlugState().rj45_plug == "wan_lan_off") : sv_fastbootInfo.need_sim_pin != "yes");

+            target.fastbootSetting = ko.observable(sv_fastbootInfo.fastbootEnabled);

+

+

+            // @method addInterval		

+			addInterval(function(){

+				target.fastbootEnableFlag(config.RJ45_SUPPORT ? (sv_fastbootInfo.need_sim_pin != "yes" && service.getRj45PlugState().rj45_plug == "wan_lan_off") : sv_fastbootInfo.need_sim_pin != "yes");

+			}, 1000);				

+

+            // �ָ���������

+            // @event restore

+            target.restore = function () {

+                showConfirm("restore_confirm", function () {

+                    showLoading("restoring");

+                    service.restoreFactorySettings({}, function (info) {

+                        if (info && info.result == "success") {

+                            successOverlay();

+                        } else {

+                            errorOverlay();

+                        }

+                    }, function (result) {

+                        if (isErrorObject(result) && result.errorType == 'no_auth') {

+                            errorOverlay();

+                        }

+                    });

+                });

+            };

+

+            target.restart = function () {

+                showConfirm("restart_confirm", function () {

+                    restartDevice(service);

+                });

+            };

+

+            target.scheduleRestart = function () {

+                showLoading();

+                var params = {};

+                params.scheduleSetting = target.scheduleSetting();

+                params.scheduleHour = target.scheduleHour();

+                params.scheduleMinute = target.scheduleMinute();

+                service.setScheduleSetting(params, function (result) {

+                    if (result.result != "success") {

+                        errorOverlay();

+                    } else {

+                        successOverlay();

+                    }

+                });

+            };

+

+            // ���ٿ��ػ�����

+            target.saveFastBoot = function() {

+                showLoading();

+                var params = {

+                    fastbootEnabled: target.fastbootSetting(),

+                    need_hard_reboot: sv_fastbootInfo.need_hard_reboot

+                };

+                service.setFastbootSetting(params, function(result) {

+                    if (result.result == "success") {

+                        successOverlay();

+                    } else {

+                        errorOverlay();

+                    }

+                });

+            };

+

+            // �ػ�

+            target.turnoff = function () {

+                showConfirm("turnoff_confirm", function () {

+                    showLoading("turnoff");

+                    service.turnOffDevice({}, function (info) {

+                        if (info && info.result == "success") {

+                            successOverlay();

+                        } else {

+                            errorOverlay();

+                        }

+                    }, $.noop);

+                });

+            };

+

+			//SNTP����serverУ׼ʱ��

+			service.setSNTPDate({

+				goformId: "SNTP_Getdatastatic"

+			});

+

+			var target       = this;

+			var sntpInfo   = service.getSntpParams();

+

+			globalTime     = new Date(parseInt(sntpInfo.sntp_year, 10),parseInt(sntpInfo.sntp_month, 10)-1, parseInt(sntpInfo.sntp_day, 10), parseInt(sntpInfo.sntp_hour, 10), parseInt(sntpInfo.sntp_minute, 10), parseInt(sntpInfo.sntp_second, 10));

+

+			target.day       = ko.observable();

+			target.localTime = ko.observable();

+

+			//��ʼ����ǰ����ʱ��

+			//target.updateCurrentTime; cov_2

+			target.timeSetModes    = ko.observableArray(timeSetModes);

+			target.isManualSetTime = ko.observable(false);

+			target.isAutoSntpTime  = ko.observable(false);

+

+			target.currentMode = ko.observable(sntpInfo.sntp_time_set_mode);

+

+			changeSetTimeMode();

+			target.changeSetTimeMode = function(){

+				changeSetTimeMode();

+			};

+

+			target.currentYear   = ko.observable(parseInt(sntpInfo.sntp_year, 10));

+			target.currentMonth  = ko.observable(parseInt(sntpInfo.sntp_month, 10));

+			target.currentDate   = ko.observable(parseInt(sntpInfo.sntp_day, 10));

+			target.currentHour   = ko.observable(parseInt(sntpInfo.sntp_hour, 10));

+			target.currentMinute = ko.observable(parseInt(sntpInfo.sntp_minute, 10));

+

+

+			// ��Ҫ��������ˢ�������б����ݣ�ע��˳�� 

+

+			target.years  = ko.observableArray(sv_sntpYears);

+			target.months = ko.observableArray(sv_sntpMonths);				

+			//���û�ѡ���·ݵ�ʱ��ı�����ѡ����ѡ��

+			target.initDateList = function(){

+				initDateList();

+				target.dates(sv_sntpDates);

+			}

+

+			//��ʼ�������б�

+			initDateList();

+			target.dates   = ko.observableArray(sv_sntpDates);

+			target.hours   = ko.observableArray(sv_sntpHours);

+			target.minutes = ko.observableArray(sv_sntpMinutes);

+

+			//�Զ�SNTP��ȡʱ�����ݰ󶨴���

+			var serverArray = _.map(sntpInfo.sntp_servers, function(item) {

+				return new Option(item.name, item.value)

+			});

+

+			target.serverList          = ko.observableArray(serverArray);

+

+			// �������ֲ����޸ģ��޸��޷�ˢ����ҳ

+

+			target.currentServer0 = ko.observable(sntpInfo.sntp_server0);

+			target.currentServer1 = ko.observable(sntpInfo.sntp_server1);

+			target.currentServer2 = ko.observable(sntpInfo.sntp_server2);

+			target.customServer0 = ko.observable(sntpInfo.sntp_other_server0);

+			target.customServer1 = ko.observable(sntpInfo.sntp_other_server1);

+			target.customServer2 = ko.observable(sntpInfo.sntp_other_server2);

+			target.isOther0 = ko.observable(false);

+			target.isOther1 = ko.observable(false);

+			target.isOther2 = ko.observable(false);

+

+			initOtherServer();

+

+			target.changeServerSelect = function(){

+				initOtherServer();

+			}

+

+			target.timeZones           = ko.observableArray(timeZones);

+			target.currentTimeZone     = ko.observable(sntpInfo.sntp_timezone + "_" + sntpInfo.sntp_timezone_index);

+			target.daylightSaves       = ko.observableArray(daylightSave);

+			target.currentDaylightSave = ko.observable(sntpInfo.sntp_dst_enable);

+

+			//���µ�ǰ��ʾʱ��

+			target.updateCurrentTime = function() {

+			    var globalDay = globalTime.getDay();

+

+				switch(globalDay){

+				    case 6:

+				    	target.day($.i18n.prop("saturday"));

+				    	break;		

+				    case 5:

+				    	target.day($.i18n.prop("friday"));

+				    	break;	

+				    case 4:

+				    	target.day($.i18n.prop("thursday"));

+				    	break;	

+				    case 3:

+				    	target.day($.i18n.prop("wednesday"));

+				    	break;

+				    case 2:

+				    	target.day($.i18n.prop("tuesday"));

+				    	break;	

+				    case 1:

+				    	target.day($.i18n.prop("monday"));

+				    	break;						

+				    case 0:

+				    	target.day($.i18n.prop("sunday"));

+				    	break;

+				    default:

+			        	break;

+				}

+

+				var localCurrentTime = globalTime.getFullYear() + "-" + getTwoDigit(globalTime.getMonth()+1) + "-" + getTwoDigit(globalTime.getDate()) + " " + getTwoDigit(globalTime.getHours()) + ":" + getTwoDigit(globalTime.getMinutes()) + ":" + getTwoDigit(globalTime.getSeconds());

+				target.localTime(localCurrentTime);

+				globalTime.setTime(globalTime.getTime()+1000);			

+			};

+

+            // SNTP����		

+			target.apply = function(){

+				var tmpArray = [];

+				for(var i=0; i< sntpInfo.sntp_servers.length; i++){

+					tmpArray.push(sntpInfo.sntp_servers[i].value);

+				}

+				var staInfo = service.getStatusInfo();

+				if(!checkConnectedStatus(staInfo.connectStatus, staInfo.rj45ConnectStatus, staInfo.connectWifiStatus) && target.currentMode() == "auto"){

+					showAlert("sntp_syn_time_wan_connected");

+					return;

+				}

+

+				showLoading("");

+				var requestParams = {

+					goformId: "SNTP",

+					manualsettime : target.currentMode(),

+					sntp_server1_ip : target.currentServer0(),

+					sntp_server2_ip : target.currentServer1(),

+					sntp_server3_ip : target.currentServer2(),

+					sntp_other_server0 : target.customServer0(),

+					sntp_other_server1 : target.customServer1(),

+					sntp_other_server2 : target.customServer2(),

+					timezone : target.currentTimeZone().split("_")[0],

+					sntp_timezone_index : target.currentTimeZone().split("_")[1],

+					DaylightEnabled : target.currentDaylightSave(),

+					time_year : target.currentYear(),

+					time_month : target.currentMonth(),

+					time_day : target.currentDate(),

+					time_hour : target.currentHour(),

+					time_minute : target.currentMinute()

+				};

+

+				service.setSntpSetting(requestParams, function(data2){

+					if(data2) {

+					    if(data2.result == "success" && target.currentMode() == "auto"){

+                            successOverlay("sntp_req_success");

+							//hideLoading();

+						}else if(data2.result == "processing" && target.currentMode() == "auto"){

+							successOverlay("sntp_processing");

+						}else{

+							//����serverУ׼ʱ��

+							service.setSNTPDate({

+								goformId: "SNTP_Getdatastatic"

+							}, function(result){

+									var sntpInfo = 	service.getSntpParams();

+									globalTime = new Date(parseInt(sntpInfo.sntp_year, 10),parseInt(sntpInfo.sntp_month, 10)-1, parseInt(sntpInfo.sntp_day, 10), parseInt(sntpInfo.sntp_hour, 10), parseInt(sntpInfo.sntp_minute, 10), parseInt(sntpInfo.sntp_second, 10));

+									successOverlay();

+							});

+						}

+					} else {

+						errorOverlay();

+					}

+				});

+			}

+

+            // �ֶ�/�Զ��л���Ӧ����		

+			function changeSetTimeMode() {

+				if(target.currentMode() == "manual") {

+					target.isManualSetTime(true);

+					target.isAutoSntpTime(false);

+				} else {

+					target.isManualSetTime(false);

+					target.isAutoSntpTime(true);

+				}

+				return true;

+			}

+

+            // ��ʼ��ʱ��

+			function initDateList(){

+				sv_sntpDates = [];

+				if($.inArray(parseInt(target.currentMonth(), 10), sf_smallMonth) != -1) {

+					sf_produceArray(1, 30, sv_sntpDates);

+				} else if($.inArray(parseInt(target.currentMonth(), 10), sf_bigMonth) != -1) {

+					sf_produceArray(1, 31, sv_sntpDates);

+				} else if(parseInt(target.currentYear(), 10)%4 == 0) {

+					sf_produceArray(1, 29, sv_sntpDates);

+				} else {

+					sf_produceArray(1, 28, sv_sntpDates);

+				}

+			}

+

+            // ��ʼ������������			

+			function initOtherServer(){

+				target.isOther0(target.currentServer0() == "Other");

+				target.isOther1(target.currentServer1() == "Other");

+				target.isOther2(target.currentServer2() == "Other");

+				!target.isOther0() && $("#sntp_server0").find(".error").hide();

+				!target.isOther1() && $("#sntp_server1").find(".error").hide();

+				!target.isOther2() && $("#sntp_server2").find(".error").hide();

+			}

+

+

+        }

+

+	    // ��ʼ�� ViewModel����������ͼ��

+        function init() {

+            var fwVm = new othersViewModel();

+            var container = $('#container')[0];

+		    ko.cleanNode(container);

+            ko.applyBindings(fwVm, container);

+			fwVm.updateCurrentTime();

+

+		    addInterval(function(){

+			    fwVm.updateCurrentTime();

+		    }, 1000);

+

+		    $("#sntpForm").validate({

+			    submitHandler: function(){

+				    fwVm.apply();

+			    },

+			    rules: {

+				    sntp_other_server0 : "sntp_invalid_server_name",

+				    sntp_other_server1 : "sntp_invalid_server_name",

+				    sntp_other_server2 : "sntp_invalid_server_name"

+			    }

+		    });

+        }

+

+        return {

+            init:init

+        }

+    });

+// ������� �

+

+define("adm_management","jquery knockout set service underscore CryptoJS".split(" "),

+

+    function ($, ko, config, service, _, CryptoJS) {

+

+        function manageViewModel() {

+            var target = this;

+

+            target.currentValue = ko.observable();

+            target.newValue     = ko.observable();

+            target.confirmValue = ko.observable();

+

+            function sf_changeValue() {

+            var sv_manageInfo = {};

+            if (config.PASSWORD_ENCODE) {

+                sv_manageInfo.oldValue = target.currentValue();

+                sv_manageInfo.newValue = target.newValue(); 

+            } else {            

+                var pwdRegex = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{8,32}');

+

+                if (!pwdRegex.test(target.newValue())) {

+                    showConfirm("password_note_too_low", function () {

+

+                    var kparam = service.getDeviceInfoLow();

+                    var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);

+					var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);

+                    var cipherold = CryptoJS.AES.encrypt(target.currentValue(), tkey, {

+                            iv: tiv,

+                            mode: CryptoJS.mode.CBC,

+                            padding: CryptoJS.pad.ZeroPadding

+                            }).toString();

+                    var ciphernew = CryptoJS.AES.encrypt(target.newValue(), tkey, {

+                            iv: tiv,

+                            mode: CryptoJS.mode.CBC,

+                            padding: CryptoJS.pad.ZeroPadding

+                            }).toString();

+

+                    sv_manageInfo.oldValue = cipherold;

+                    sv_manageInfo.newValue = ciphernew;

+

+                    showLoading();

+

+                    service.changeManageInfo(sv_manageInfo, function (resultInfo) {

+                        target.cancel();

+                        if (resultInfo && resultInfo.result == true) {

+                            successOverlay();

+                        } else {

+                            if (resultInfo && resultInfo.errorType == "badPassword") {

+                                hideLoading();

+                                showAlert("current_password_error",function(){

+                                    $("#txtCurrent").focus();

+                                });

+                            } else {

+                                errorOverlay();

+                            }

+                        }

+                    });

+                    });

+                    return;

+               }

+                var kparam = service.getDeviceInfoLow();

+                var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);

+		var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);

+                var cipherold = CryptoJS.AES.encrypt(target.currentValue(), tkey, {

+                        iv: tiv,

+                        mode: CryptoJS.mode.CBC,

+                        padding: CryptoJS.pad.ZeroPadding

+                        }).toString();

+                var ciphernew = CryptoJS.AES.encrypt(target.newValue(), tkey, {

+                        iv: tiv,

+                        mode: CryptoJS.mode.CBC,

+                        padding: CryptoJS.pad.ZeroPadding

+                        }).toString();

+

+                sv_manageInfo.oldValue = cipherold;

+                sv_manageInfo.newValue = ciphernew;

+                }

+

+                showLoading();

+

+                service.changeManageInfo(sv_manageInfo, function (resultInfo) {

+                    target.cancel();

+                    if (resultInfo && resultInfo.result == true) {

+                        successOverlay();

+                    } else {

+                        if (resultInfo && resultInfo.errorType == "badPassword") {

+                            hideLoading();

+                            showAlert("current_password_error",function(){

+                                $("#txtCurrent").focus();

+                            });

+                        } else {

+                            errorOverlay();

+                        }

+                    }

+                });     

+            }

+

+            // ������������

+            function sf_cancel() {

+                target.currentValue("");

+                target.newValue("");

+                target.confirmValue("");

+            }           

+

+            target.cancel = sf_cancel;

+

+            // �޸�����

+            target.changeValue = sf_changeValue;

+        }

+

+        function init() {

+            var container = $('#container');

+            ko.cleanNode(container[0]);

+            var fwVm = new manageViewModel();

+            ko.applyBindings(fwVm, container[0]);

+

+            $('#frmPassword').validate({

+                submitHandler:function () {

+                    fwVm.changeValue();

+                },

+                rules:{

+                    txtCurrent:"manage_info_check",

+                    txtNew:"manage_info_check",

+                    txtConfirm:{ equalTo:"#txtNew"}

+                }

+            });

+        }

+

+        return {

+            init:init

+        }

+    }

+);

+// PIN�����

+

+define("adm_pin","jquery knockout set service".split(" "),

+

+    function ($, ko, config, service) {

+        var pageState = {common:0, requirePin:1, modifyPin:2, requirePuk:3, destroyed:4};

+        var pinStatus = {enable:"1", disable:"0"};

+

+

+        function pinViewModel() {

+            var target = this;

+            var sv_currentPinData     = service.getPinData();

+

+            target.isDataCard         = config.PRODUCT_TYPE == 'DATACARD';

+            target.originPinStatus    = ko.observable(sv_currentPinData.pin_status);

+

+            target.pinStatus          = ko.observable(sv_currentPinData.pin_status);

+            target.pinNumber          = ko.observable(sv_currentPinData.pinnumber);

+            target.pukNumber          = ko.observable(sv_currentPinData.puknumber);

+

+            target.currentPin         = ko.observable();

+            target.newPin             = ko.observable();

+            target.confirmPin         = ko.observable();

+

+            target.puk                = ko.observable();

+

+            target.pageState          = ko.observable();

+            // ���������ɹ���־λ

+            target.operateSuccessFlag = true;

+

+			target.callback           = sf_callback;		

+

+			function sf_callback(info) {

+                if (info && info.result == true) {

+                    target.operateSuccessFlag = true;

+                    successOverlay();

+                } else {

+                    target.operateSuccessFlag = false;

+

+                    // ���һ��ǰҪ������ʾ					 

+                    if(target.pinNumber() == 2){

+                      showAlert("last_enter_pin");    

+                    } else if(target.pukNumber() == 2){

+                      showAlert("last_enter_puk");    

+                    }

+                    else{

+                      errorOverlay();      

+                    }   

+                }

+                init(target);

+            }

+

+

+            // ȷ����ť�¼������������޸�PIN������PUK����PIN������PIN��ʹ��״̬

+

+            function sf_changePin() {

+                if (target.isConnectedNetWork()) {

+                    showAlert("cannot_operate_when_connected");

+                    return;

+                }

+

+                if (target.pageState() == pageState.common) {

+                    return;

+                }

+

+                var sv_pinPara = {

+                    oldPin:target.currentPin(),

+                    newPin:target.newPin()

+                };

+                showLoading();

+

+                if (target.pageState() == pageState.modifyPin) {

+                    service.changePin(sv_pinPara, target.callback);

+                } else if (target.pageState() == pageState.requirePuk) {

+                    sv_pinPara = {

+                        PinNumber:target.newPin(),

+                        PUKNumber:target.puk()

+                    };

+                    service.enterPUK(sv_pinPara, target.callback);

+                } else {

+                    if (target.pinStatus() == pinStatus.enable) {

+                        service.enablePin(sv_pinPara, target.callback);

+                    } else {

+                        service.disablePin(sv_pinPara, target.callback);

+                    }

+                }

+            }	

+

+

+			// ȡ���¼�����

+            function sf_cancel() {

+                target.pageState(pageState.common);

+                target.pinStatus(target.originPinStatus());

+                target.clear();

+            }		

+

+            // ���ҳ������ͼ����Ϣ

+			function sf_clear() {

+                target.confirmPin("");			

+                target.currentPin("");

+                target.newPin("");

+                target.puk("");

+                clearValidateMsg();

+            }	

+

+            // �������ݣ����õ�ǰ��ҳ��״̬

+            function sf_computePageState(i_pinData) {

+                if (i_pinData.pinnumber > 0) {

+                    //�����ɹ�ҳ��ص���ʼ״̬������ʧ�ܲ���pinnumber>0,ҳ�治��ת

+                    if (target.operateSuccessFlag) {

+                        target.cancel();

+                    } else {

+                        target.clear();

+                    }

+                } else {

+                    target.clear();

+                    if (i_pinData.puknumber > 0) {

+                        target.pageState(pageState.requirePuk);

+                    } else {

+                        target.pageState(pageState.destroyed);

+                    }

+                }

+            }

+

+            // ����PIN�޸�״̬�¼�����

+			function sf_displayModifyPinPage() {

+                if (target.isConnectedNetWork()) {

+                    showAlert("cannot_operate_when_connected");

+                    return;

+                }

+                target.pinStatus(target.originPinStatus());

+                target.pageState(pageState.modifyPin);

+                target.clear();

+            }

+

+			// ����ҳ��Ԫ�ص�ʹ��״̬

+			function sf_fixPageEnable() {

+                if (target.isConnectedNetWork()) {

+                    $('#frmPin :input').each(function () {

+                        disableBtn($(this));

+                    });

+                    clearValidateMsg();

+                } else {

+                    $('#frmPin :input').each(function () {

+                        if (this.id == "txtPin" || this.id == "btnPinApply") {

+                            if (target.pageState() == pageState.common) {

+                                disableBtn($(this));

+                                return;

+                            }

+                        }

+                        if (this.id == "btnModifyPin") {

+                            if (target.originPinStatus() != pinStatus.enable) {

+                                disableBtn($(this));

+                                return;

+                            }

+                        }

+                        if (this.id == "pinEnable" || this.id == "pinDisable") {

+                            if (target.pageState() == pageState.modifyPin) {

+                                disableBtn($(this));

+                                return;

+                            }

+                        }

+                        enableBtn($(this));

+                    });

+

+                }

+            }

+

+			// �Ƿ�������

+			function sf_isConnectedNetWork() {

+                var info = service.getConnectionInfo();

+                return info.connectStatus == "ppp_connected";

+            }

+

+            // PINʹ�ܸı�ʱ�¼�����

+			function sf_pinStatusChangeEvent() {

+                if (target.pinStatus() == target.originPinStatus()) {

+                    target.pageState(pageState.common);

+                } else {

+                    target.pageState(pageState.requirePin);

+                }

+                target.clear();

+            }

+

+            target.changePin            = sf_changePin;

+            target.cancel               = sf_cancel;

+            target.clear                = sf_clear;	

+            target.computePageState     = sf_computePageState;

+

+            target.computePageState(sv_currentPinData);			

+

+            target.displayModifyPinPage = sf_displayModifyPinPage;   

+            target.fixPageEnable        = sf_fixPageEnable;		

+            target.isConnectedNetWork   = sf_isConnectedNetWork;

+

+            target.pinStatusChangeEvent = ko.dependentObservable(sf_pinStatusChangeEvent, this);			

+        }

+

+        function init(oldViewModel) {

+

+            var fwVm = oldViewModel;		

+

+            if (fwVm) {

+                var sv_currentPinData = service.getPinData();

+                fwVm.originPinStatus(sv_currentPinData.pin_status);

+                fwVm.pinNumber(sv_currentPinData.pinnumber);

+                fwVm.pukNumber(sv_currentPinData.puknumber);

+                fwVm.computePageState(sv_currentPinData);

+            } else {

+                fwVm = new pinViewModel();

+                addInterval(function () {

+                    fwVm.fixPageEnable();

+                }, 1000);

+            }

+

+            var container = $('#container')[0];

+		    ko.cleanNode(container);

+            ko.applyBindings(fwVm, container);

+            fwVm.fixPageEnable();

+

+            $('#frmPin').validate({

+                submitHandler:function () {

+                    fwVm.changePin();

+                },

+                rules:{

+                    txtPuk:"puk_check",

+                    txtPin:"pin_check",

+                    txtNewPin:"pin_check",

+                    txtConfirmPin:{equalToPin:"#txtNewPin"}

+                }

+            });

+        }

+

+        return {

+            init:init

+        }

+    }

+);

+

+// ��������

+define("adm_quick_set","jquery knockout set service underscore CryptoJS".split(" "),

+

+    function ($, ko, config, service, _, CryptoJS) {

+

+        var sv_wifiState = {ok:0, wps_on:1, wifi_off:2};

+        var sv_apnMode   = {auto:"auto", manual:"manual"};

+        var sv_minStep   = 1;

+        var sv_maxStep   = 5;

+

+        // ��ȡ��Ȩ��ʽ

+        function sf_fetchAuthenticationModes() {

+            return _.map(config.APN_AUTH_MODES, function (item) {

+                return new Option(item.name, item.value);

+            });

+        }

+

+        // WIFI��ȫģʽѡ��

+        var sv_securityModes = _.map(config.WIFI_WEP_SUPPORT ? config.AUTH_MODES_WEP : config.AUTH_MODES, function (item) {

+            return new Option(item.name, item.value);

+        });

+

+

+        function quickSettingViewModel() {

+            var target = this;

+

+            var sv_quickSettingInfo        = service.getQuickSettingInfo();

+

+            target.currentStep            = ko.observable(sv_minStep);

+            target.ipType                 = ko.observable(sv_quickSettingInfo.pdp_type == "IP" ? "IP" : sv_quickSettingInfo.ipv6_pdp_type);			

+            target.supportIPv6            = config.IPV6_SUPPORT;

+            target.supportIpv4AndIpv6     = config.IPV4_AND_V6_SUPPORT;

+

+            target.wpsFlag                = ko.observable(sv_quickSettingInfo.WscModeOption);		

+

+            function sf_apnDisabled() {

+                return (sv_quickSettingInfo.apn_index < config.defaultApnSize || sv_quickSettingInfo.ppp_status == "ppp_connected" || sv_quickSettingInfo.ppp_status == "ppp_connecting");

+            }

+

+			function sf_apnModeDisabled() {

+                return (sv_quickSettingInfo.ppp_status == "ppp_connected" || sv_quickSettingInfo.ppp_status == "ppp_connecting" || (!target.profileName() && target.apnMode() == sv_apnMode.auto));//ѡ��Ϊ�ջ��������ӻ�������

+            }	

+

+            function sf_currAPN() {

+                var sv_APNText = sv_quickSettingInfo["APN_configtmp" + sv_quickSettingInfo.apn_index];

+                var strIPv6APN = sv_quickSettingInfo["ipv6_APN_configtmp" + sv_quickSettingInfo.apn_index];

+

+                var sv_apn     = [];

+                var sv_ipv6APNItems = [];

+

+                if (sv_APNText) {

+                    sv_apn = sv_APNText.split("($)");

+                }

+

+                if (strIPv6APN) {

+                    sv_ipv6APNItems = strIPv6APN.split("($)");

+                }

+

+                return {

+                    m_profile_name:sv_apn[0],

+                    wan_apn:sv_apn[1],

+                    ppp_auth_mode: sv_apn[4] == "" || typeof(sv_apn[4]) == "undefined" ? "" : sv_apn[4].toLowerCase(),					

+                    ppp_username:sv_apn[5],

+                    ppp_passtmp:sv_apn[6],						

+                    pdp_type: sv_apn[7],			

+                    ipv6_wan_apn:sv_ipv6APNItems[1],	

+                    ipv6_ppp_auth_mode:typeof(sv_ipv6APNItems[4]) == "undefined" || sv_ipv6APNItems[4] == ""? "" : sv_ipv6APNItems[4].toLowerCase(),

+                    ipv6_ppp_username:sv_ipv6APNItems[5],					

+                    ipv6_ppp_passtmp:sv_ipv6APNItems[6],					

+                    ipv6_pdp_type:sv_ipv6APNItems[7]			

+                }

+            }			

+

+            // ��ǰAPN����			

+            target.currAPN                = ko.computed(sf_currAPN);

+

+			target.apn                    = ko.observable(target.currAPN().wan_apn);

+			target.ipv6_apn               = ko.observable(target.currAPN().ipv6_wan_apn);

+            target.ipv6_selectedAuthMode  = ko.observable(target.currAPN().ipv6_ppp_auth_mode);				

+            target.ipv6_username          = ko.observable(target.currAPN().ipv6_ppp_username);

+            target.ipv6_password          = ko.observable(target.currAPN().ipv6_ppp_passtmp);			

+			target.profileName            = ko.observable(target.currAPN().m_profile_name);	

+			target.selectedAuthMode       = ko.observable(target.currAPN().ppp_auth_mode);

+            target.username               = ko.observable(target.currAPN().ppp_username);

+            target.password               = ko.observable(target.currAPN().ppp_passtmp);

+

+            target.transAPN               = ko.observable("apn_ipv4_apn");

+			target.transAPNIPv6           = ko.observable("apn_ipv6_apn");			

+            target.transAuthMode          = ko.observable("apn_authentication_ipv4");

+			target.transAuthModeIPv6      = ko.observable("apn_authentication_ipv6");

+            target.transUserName          = ko.observable("apn_user_name_ipv4");

+            target.transPassword          = ko.observable("apn_password_ipv4");     

+            target.transUserNameIPv6      = ko.observable("apn_user_name_ipv6");

+            target.transPasswordIPv6      = ko.observable("apn_password_ipv6");	

+

+

+

+            target.apnDisabled            = ko.computed(sf_apnDisabled);

+			target.apnMode                = ko.observable(sv_quickSettingInfo.apn_mode);	

+            target.apnModeDisabled        = ko.computed(sf_apnModeDisabled);

+            target.authModes              = ko.observableArray(sf_fetchAuthenticationModes());

+

+            if (target.ipType() == "IPv6") {

+                target.showIPv4 = false;

+                target.showIPv6 = true;

+                target.transAPNIPv6("apn");

+                target.transAuthModeIPv6("apn_authentication");

+                target.transUserNameIPv6("apn_user_name");

+                target.transPasswordIPv6("apn_password");

+            } else if (config.IPV4_AND_V6_SUPPORT && target.ipType() == "IPv4v6") {

+                target.showIPv4 = true;

+                target.showIPv6 = true;

+                //ʹ��Ĭ��

+            } else if (target.ipType() == "IP" || target.ipType() == "IPv4") {

+                target.showIPv4 = true;

+                target.showIPv6 = false;

+                target.transAPN("apn");

+                target.transAuthMode("apn_authentication");

+                target.transUserName("apn_user_name");

+                target.transPassword("apn_password");

+            } else { //pdp_type == "IPv4v6" && config.IPV4V6_SUPPORT

+                target.showIPv4 = true;

+                target.showIPv6 = false;

+                target.transAPN("apn");

+                target.transAuthMode("apn_authentication");

+                target.transUserName("apn_user_name");

+                target.transPassword("apn_password");

+            }

+

+            target.wifiDisabled                  = (sv_quickSettingInfo.wifi_cur_state != "1");

+            target.ssid                          = ko.observable(sv_quickSettingInfo.SSID1);

+            target.broadcast                     = ko.observable(sv_quickSettingInfo.HideSSID);

+	    target.hasWifiWep                    = config.WIFI_WEP_SUPPORT;

+	    target.hasWifiWpa3                   = config.WIFI_WAP3_SUPPORT;

+	    target.hasWifiWpa23                  = config.WIFI_WPA2_WAP3_SUPPORT;

+

+            target.securityModes                 = ko.observableArray(sv_securityModes);

+            target.selectedSecurityMode          = ko.observable(sv_quickSettingInfo.AuthMode);

+            target.WPAKey                        = ko.observable(sv_quickSettingInfo.WPAPSK1);

+

+            target.apnMode_display               = ko.observable("");

+

+            target.apnMode_trans                 = ko.computed(sf_apnMode_trans);

+            target.selectedAuthMode_display      = ko.computed(sf_selectedAuthMode_display);

+            target.ipv6_selectedAuthMode_display = ko.computed(sf_ipv6_selectedAuthMode_display);

+

+            target.showWifiPassword              = ko.observable(false);

+            target.showWifiPasswordHandler       = sf_showWifiPasswordHandler;

+

+			//�ж��Ƿ���802 n only��

+			var sv_adInfo                        = service.getWifiAdvance();

+			target.adBand                        = ko.observable(sv_adInfo.wifiBand);

+			target.adMode                        = ko.observable(sv_adInfo.mode);

+

+			target.encryptType                   = ko.observable(sv_quickSettingInfo.EncrypType);

+			target.keyID                         = ko.observable(sv_quickSettingInfo.DefaultKeyID);

+			target.wepPassword                   = ko.observable("");

+

+			target.getWepPassword                = sf_getWepPassword;

+			target.wepPassword(target.getWepPassword());

+			target.profileChangeHandler          = sf_profileChangeHandler;

+

+            target.broadcast_display             = ko.observable("");

+            target.broadcast_trans               = ko.computed(sf_broadcast_trans);

+

+            target.selectedSecurityMode_display  = ko.observable();   

+            target.selectedSecurityMode_trans    = ko.computed(sf_selectedSecurityMode_trans);

+

+

+            target.callback                      = sf_callback;

+            target.next                          = sf_button_next;			

+            target.previous                      = sf_button_previous;					

+            target.save                          = sf_button_save;

+

+			function sf_apnMode_trans() {

+                if (sv_apnMode.auto == target.apnMode()) {

+                    target.apnMode_display($.i18n.prop("apn_auto_apn"));

+                    return "apn_auto_apn";

+                } else {

+                    target.apnMode_display($.i18n.prop("apn_manual_apn"));

+                    return "apn_manual_apn";

+                }

+            }

+

+			function sf_broadcast_trans() {

+                if ("0" == target.broadcast()) {

+                    target.broadcast_display($.i18n.prop("enable"));

+                    return "enable";

+                } else {

+                    target.broadcast_display($.i18n.prop("disable"));

+                    return "disable";

+                }

+            }

+

+			function sf_button_next() {

+                var currentStep = target.currentStep();

+                var toStep = target.currentStep() + 1;

+                sf_changeStep(toStep);

+

+                if (currentStep == 1 && target.apnMode() == sv_apnMode.auto) {

+                    toStep = target.currentStep() + 1;

+                    sf_changeStep(toStep);

+                }

+            }

+

+			function sf_button_previous() {

+

+                var currentStep = target.currentStep();

+                var toStep = target.currentStep() - 1;

+

+                sf_changeStep(toStep);

+

+                if (currentStep == 3 && target.apnMode() == sv_apnMode.auto) {

+                    toStep = target.currentStep() - 1;

+                    sf_changeStep(toStep);

+                }

+            }

+			function sf_button_save() {

+                var submit = function () {

+                    sf_quickSetting4IPv6();

+                };

+                var result = sf_isDisabled_Wifi();

+                if(result == sv_wifiState.wifi_off){

+                    showConfirm("quick_setting_wifi_disable_confirm", submit);

+                } else if (result == sv_wifiState.wps_on) {

+                    showAlert("wps_on_info");

+                } else{

+                    showConfirm("quick_setting_param_changed_confirm", submit);//submit();

+                }

+            }

+            // ���������ύ��Ļص�����

+			function sf_callback(data) {

+                if (data.result == "success") {

+                    successOverlay();

+                    location.hash = "#network_choose";

+                }

+                else {

+                    errorOverlay();

+                }

+            }

+

+            // �任����ʱ����

+            function sf_changeStep(i_step) {

+                if (i_step > sv_maxStep) {

+                    i_step = sv_maxStep;

+                } else if (i_step < sv_minStep) {

+                    i_step = sv_minStep;

+                }

+

+                target.currentStep(i_step);

+                return true;

+            }			

+

+			function sf_ipv6_selectedAuthMode_display() {

+                var mode = target.ipv6_selectedAuthMode();

+                return sf_getAuthModeNameByValue(mode);

+            }

+			// ���ݼ�Ȩģʽ��ֵ��������

+            function sf_getAuthModeNameByValue(authMode) {

+                for (var i = 0; i < config.APN_AUTH_MODES.length; i++) {

+                    if (authMode == config.APN_AUTH_MODES[i].value) {

+                        return config.APN_AUTH_MODES[i].name;

+                    }

+                }

+            }

+

+			function sf_getWepPassword(){

+				return target.keyID() == '3' ? sv_quickSettingInfo.Key4Str1 : (target.keyID() == '2' ? sv_quickSettingInfo.Key3Str1 : target.keyID() == '1' ? sv_quickSettingInfo.Key2Str1 : sv_quickSettingInfo.Key1Str1);

+			}

+

+            function sf_isDisabled_Wifi() {

+                var s_wpsInfo = service.getWpsInfo();

+                if(s_wpsInfo.radioFlag == "0"){

+                    return sv_wifiState.wifi_off;

+                }else if (s_wpsInfo.wpsFlag == '1') {

+                    return sv_wifiState.wps_on;

+                }

+                return sv_wifiState.ok;

+            }			

+			function sf_profileChangeHandler(i_data, i_event) {

+			    $("#pwdWepKey").parent().find("label[class='error']").hide();		

+			    target.wepPassword(target.getWepPassword());

+			    return true;

+		    }

+

+           // ���������ύ(֧��IPv6��

+            function sf_quickSetting4IPv6() {

+                showLoading();

+                var useIPv4ForV6 = config.IPV4V6_SUPPORT && target.currAPN().pdp_type == "IPv4v6";

+

+                var ciphertext = "";

+                if (config.PASSWORD_ENCODE) {

+		    ciphertext = target.WPAKey();

+		} else {

+                    var kparam = service.getDeviceInfoLow();

+                    var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);

+		    var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);

+                    ciphertext = CryptoJS.AES.encrypt(target.WPAKey(), tkey, {

+                        iv: tiv,

+                        mode: CryptoJS.mode.CBC,

+                        padding: CryptoJS.pad.ZeroPadding

+                        }).toString();

+		}

+

+                var s_quickSettingParameters = {

+                    apn_index: sv_quickSettingInfo.apn_index,

+                    apnMode: target.apnMode(),		

+                    Encryption_Mode_hid: target.selectedSecurityMode(),	

+                    ipv6_ppp_auth_mode: useIPv4ForV6 ? target.selectedAuthMode() : target.ipv6_selectedAuthMode(),

+                    ipv6_ppp_username: useIPv4ForV6 ? target.username() : target.ipv6_username(),

+                    ipv6_ppp_passtmp: useIPv4ForV6 ? target.password() : target.ipv6_password(),	

+                    ipv6_wan_apn: useIPv4ForV6 ? target.apn() : target.ipv6_apn(),					

+                    pdp_type: target.ipType(),

+                    ppp_auth_mode: target.selectedAuthMode(),

+                    ppp_username: target.username(),

+                    ppp_passtmp: target.password(),

+                    profile_name: target.profileName(),

+                    //Ŀǰ����ģʽֻ��2�֣�����3������Ϊ�̶�ֵ

+                    //�����Ҫ����Ϊ5�֣�����ֵ��Ҫ����

+                    security_shared_mode: "NONE",					

+                    SSID_Broadcast: target.broadcast(),

+                    SSID_name: target.ssid(),

+                    wan_apn: target.apn(),		

+                    wep_default_key: 0,				

+                    WPA_ENCRYPTION_hid: target.selectedSecurityMode() == "OPEN" ? "NONE" : target.selectedSecurityMode() == "WPA2PSK" ? 1 : 2,					

+                    WPA_PreShared_Key: ciphertext

+                }

+

+				s_quickSettingParameters.wep_default_key = target.keyID();	

+

+				if(target.encryptType() == "SHARED" || target.selectedSecurityMode() == "WEP") {

+

+					s_quickSettingParameters.security_shared_mode = "WEP";

+

+                    s_quickSettingParameters.wep_key_1 = sv_quickSettingInfo.Key1Str1;

+					s_quickSettingParameters.wep_key_2 = sv_quickSettingInfo.Key2Str1;

+					s_quickSettingParameters.wep_key_3 = sv_quickSettingInfo.Key3Str1;

+					s_quickSettingParameters.wep_key_4 = sv_quickSettingInfo.Key4Str1;

+

+					var WEPSelectTmp = '0';

+

+                    if(target.wepPassword().length =='5' ||target.wepPassword().length =='13'){

+						WEPSelectTmp = '1';	

+					}else{

+						WEPSelectTmp = '0';	

+					}	

+

+					if(target.keyID() =='3'){

+						s_quickSettingParameters.wep_key_4  = target.wepPassword();

+						s_quickSettingParameters.WEP4Select = WEPSelectTmp;						

+					}else if(target.keyID() =='2'){	

+						s_quickSettingParameters.wep_key_3  = target.wepPassword();

+						s_quickSettingParameters.WEP3Select = WEPSelectTmp;						

+					}else if(target.keyID() =='1'){						

+						s_quickSettingParameters.wep_key_2  = target.wepPassword();

+						s_quickSettingParameters.WEP2Select = WEPSelectTmp;					

+					}else{

+						s_quickSettingParameters.wep_key_1  = target.wepPassword();

+						s_quickSettingParameters.WEP1Select = WEPSelectTmp;					

+					}					

+				}else if(target.encryptType() == "WPAPSKWPA2PSK") {

+					s_quickSettingParameters.security_shared_mode = "NONE";

+				}else {

+					s_quickSettingParameters.security_shared_mode = "NONE";

+				}

+

+                service.setQuickSetting4IPv6(s_quickSettingParameters, target.callback);

+            }			

+

+			function sf_selectedAuthMode_display() {

+                var mode = target.selectedAuthMode();

+                return sf_getAuthModeNameByValue(mode);

+            }

+

+            function sf_selectedSecurityMode_trans() {

+                var mode = target.selectedSecurityMode();

+				var modesOption = config.WIFI_WEP_SUPPORT ? config.AUTH_MODES_WEP : config.AUTH_MODES;

+                for (var i = 0; i < modesOption.length; i++) {

+                    if (mode == modesOption[i].value) {

+                        target.selectedSecurityMode_display($.i18n.prop("security_mode_" +  modesOption[i].value));

+                        return "security_mode_" +  modesOption[i].value;

+                    }

+                }

+            }

+

+			function sf_showWifiPasswordHandler(){

+				$("#pwdWepKey").parent().find(".error").hide();

+                $("#codeWPAKey").parent().find(".error").hide();

+                var checkbox = $("#showWifiPassword:checked");

+                if(checkbox && checkbox.length == 0){

+                    target.showWifiPassword(true);

+                }else{

+                    target.showWifiPassword(false);

+                }

+            }			

+

+        }

+

+        function init() {

+            var container = $('#container');

+            ko.cleanNode(container[0]);

+            var fwVm = new quickSettingViewModel();

+            ko.applyBindings(fwVm, container[0]);

+

+            $('#quickSettingForm').validate({

+                submitHandler:function () {

+                    if (fwVm.currentStep() < 5) {

+                        fwVm.next();

+                    } else {

+                        fwVm.save();

+                    }

+                },

+                rules:{

+                    txtAPN:"apn_check",

+                    txtIPv6APN:"apn_check",

+                    txtSSID:'ssid',

+                    pwdWepKey:{wifi_wep_password_check:true,wifi_password_check: true},

+                    txtWepKey:{wifi_wep_password_check:true,wifi_password_check: true},

+                    txtWPAKey:'wifi_password_check',

+                    codeWPAKey:'wifi_password_check',

+                    txtUserName:'ppp_username_check',

+                    txtIPv6UserName:'ppp_username_check',

+                    txtSecretCode:"ppp_secretcode_check",

+                    txtIPv6SecretCode:"ppp_secretcode_check"

+                },

+                errorPlacement:function (error, element) {

+                    var id = element.attr("id");

+                    if (id == "pwdWepKey" || id == "txtWepKey"){

+						error.insertAfter("#lblShowWepPassword");

+					} else if (id == "txtWPAKey" || id == "codeWPAKey") {

+                        error.insertAfter("#lblShowWifiPassword");

+                    } else {

+                        error.insertAfter(element);

+                    }

+                }

+            });

+        }

+

+        return {

+            init:init

+        };

+    }

+);

+

+define("main","set service knockout underscore jquery statusBar echarts".split(" "), function (set, fnc, libko, libus, libjq, barStat, echarts) {

+

+    var chartOptions = {

+        color: ['red', 'red', 'red', 'red', 'red'],	

+        series: [{

+                name: '��������',

+                type: 'pie',

+                radius: ['0', '72'],

+                itemStyle: {

+                    normal: {

+                        label: {

+                            show: false

+                        },

+                        labelLine: {

+                            show: false

+                        }

+                    }

+                },

+                data: [],

+                selectedOffset: 3

+            }

+        ],

+		animation: false,

+        title: {

+            text: '',

+            x: 'center',

+            y: 'center',

+            itemGap: 0,

+            textStyle: {

+                color: '#FFF',

+                fontFamily: '΢���ź�',

+                fontSize: 20,

+                fontWeight: 'bolder'

+            },

+            subtextStyle: {

+                color: '#FFF',

+                fontFamily: '΢���ź�',

+                fontSize: 16,

+                fontWeight: 'bolder'

+            }

+        },

+        tooltip: {

+            formatter: "{b}"

+        },

+    };

+	var languageOld = window.language;

+	var num_refresh = 0;

+	var traffic_graphic_chart = null;

+    var connStat = {

+        CONNECTED: 1,

+        DISCONNECTED: 2,

+        CONNECTING: 3,

+        DISCONNECTING: 4

+    };

+	function init() {

+        num_refresh = 0;

+        homeUtil.oldUsedData = null;

+        homeUtil.oldAlarmData = null;

+        traffic_graphic_chart = echarts.init(libjq("#traffic_graphic")[0]);

+        var container = libjq('#container')[0];

+        libko.cleanNode(container);

+        var tmp = new VmHome();

+        libko.applyBindings(tmp, container);

+		var data = fnc.getLoginData();

+		var psw_flg = data.psw_changed;

+		if (psw_flg != "1") {

+			showConfirm("password_note_first_change", function () {

+                    window.location.hash = '#pwd_mode';

+                });

+			return;

+		}										

+    }

+

+    var homeUtil = {

+        initStatus: null,

+        initShownStatus: function (data) {

+            this.initStatus = {};

+            var ipv6Mode = data.ipv6PdpType.toLowerCase().indexOf("v6") > 0;

+            if (set.RJ45_SUPPORT) {

+                var mode = checkCableMode(data.blc_wan_mode);

+                if (mode) {

+                    this.initStatus.showIpv6WanIpAddr = false;

+                    this.initStatus.showIpv4WanIpAddr = true;

+                } else if (set.IPV6_SUPPORT) {

+                    if (data.pdpType == "IP") {

+                        this.initStatus.showIpv6WanIpAddr = false;

+                        this.initStatus.showIpv4WanIpAddr = true;

+                    } else if (ipv6Mode) {

+                        if (data.ipv6PdpType == "IPv6") {

+                            this.initStatus.showIpv6WanIpAddr = true;

+                            this.initStatus.showIpv4WanIpAddr = false;

+                        } else {

+                            this.initStatus.showIpv6WanIpAddr = true;

+                            this.initStatus.showIpv4WanIpAddr = true;

+                        }

+                    }

+                } else {

+                    this.initStatus.showIpv6WanIpAddr = false;

+                    this.initStatus.showIpv4WanIpAddr = true;

+                }

+            } else {

+                if (set.IPV6_SUPPORT) {

+                    if (data.pdpType == "IP") {

+                        this.initStatus.showIpv6WanIpAddr = false;

+                        this.initStatus.showIpv4WanIpAddr = true;

+                    } else if (ipv6Mode) {

+                        if (data.ipv6PdpType == "IPv6") {

+                            this.initStatus.showIpv6WanIpAddr = true;

+                            this.initStatus.showIpv4WanIpAddr = false;

+                        } else {

+                            this.initStatus.showIpv6WanIpAddr = true;

+                            this.initStatus.showIpv4WanIpAddr = true;

+                        }

+                    }

+                } else {

+                    this.initStatus.showIpv6WanIpAddr = false;

+                    this.initStatus.showIpv4WanIpAddr = true;

+                }

+            }

+        },

+        wanIpGet: function (data) {

+            var addrInfo = {

+                wanIpAddress: '',

+                ipv6WanIpAddress: ''

+            };

+            addrInfo.wanIpAddress = verifyDeviceInfo(data.wanIpAddress);

+            addrInfo.ipv6WanIpAddress = verifyDeviceInfo(data.ipv6WanIpAddress);

+            return addrInfo;

+        },

+        cachedAPStationBasic: null,

+        cachedConnectionMode: null,

+        getCanConnectNetWork: function (param) {

+            var status = fnc.getStatusInfo();

+            if (status.simStatus != "modem_init_complete") {

+                return false;

+            }

+            var typeNetworkTmp = status.networkType.toLowerCase();

+            if (typeNetworkTmp == 'searching') {

+                return false;

+            }

+            if (typeNetworkTmp == '' || typeNetworkTmp == 'limited service') {

+                typeNetworkTmp = 'limited_service';

+            }

+            if (typeNetworkTmp == 'no service') {

+                typeNetworkTmp = 'no_service';

+            }

+            if (typeNetworkTmp == 'limited_service' || typeNetworkTmp == 'no_service') {

+                if (param.cStatus() != connStat.CONNECTED) {

+                    return false;

+                }

+            }

+            if (set.AP_STATION_SUPPORT) {

+                if (status.connectWifiStatus == "connect") {

+                    if (status.ap_station_mode == "wifi_pref") {

+                        return false;

+                    }

+                }

+            }

+            return true;

+        },

+        doConnect: function () {

+            showLoading('connecting');

+            fnc.connect({}, function (data) {

+                if (data.result) {

+                    successOverlay();

+                } else {

+                    errorOverlay();

+                }

+            });

+        },

+        refreshHomeData: function (param) {

+            var info = fnc.getConnectionInfo();

+            param.connectStatus(info.connectStatus);

+            param.canConnect(this.getCanConnectNetWork(param));

+            param.networkType(homeUtil.getNetworkType(info.networkType));

+            if (info.connectStatus == "ppp_connected") {

+                param.current_Flux(transUnit(parseInt(info.data_counter.currentReceived, 10) + parseInt(info.data_counter.currentSent, 10), false));

+                param.connected_Time(transSecond2Time(info.data_counter.currentConnectedTime));

+                param.up_Speed(transUnit(info.data_counter.uploadRate, true));

+                param.down_Speed(transUnit(info.data_counter.downloadRate, true));

+            } else {

+                param.current_Flux(transUnit(0, false));

+                param.connected_Time(transSecond2Time(0));

+                param.up_Speed(transUnit(0, true));

+                param.down_Speed(transUnit(0, true));

+            }

+            param.trafficAlertEnable(info.limitVolumeEnable);

+            if (info.limitVolumeEnable) {

+                if (info.limitVolumeType == '1') {

+                    param.trafficUsed(transUnit(parseInt(info.data_counter.monthlySent, 10) + parseInt(info.data_counter.monthlyReceived, 10), false));

+                    param.trafficLimited(transUnit(info.limitDataMonth, false));

+                } else {

+                    param.trafficUsed(transSecond2Time(info.data_counter.monthlyConnectedTime));

+                    param.trafficLimited(transSecond2Time(info.limitTimeMonth));

+                }

+            }

+            if (languageOld != window.language) {

+                languageOld = window.language;

+                num_refresh = 1;

+            }

+            if (param.showTraffic()) {

+                homeUtil.updateEcharts(info);

+            } else {

+                homeUtil.allFreeEcharts();

+            }

+            homeUtil.refreshStationInfo(param);

+        },

+        allFreeEcharts: function () {

+            var usedData = homeUtil.data.free;

+            usedData.value = 1;

+            usedData.selected = false;

+            usedData.name = libjq.i18n.prop("echarts_no");

+            chartOptions.series[0].data = [usedData];

+            chartOptions.title.text = '';

+            homeUtil.setEcharts(chartOptions, libjq.i18n.prop("echarts_no"));

+        },

+        getNetworkType: function (networkType) {

+            var typeNetworkTmp = networkType.toLowerCase();

+            if (typeNetworkTmp == '' || typeNetworkTmp == 'limited service') {

+                typeNetworkTmp = 'limited_service';

+            }

+            if (typeNetworkTmp == 'no service') {

+                typeNetworkTmp = 'no_service';

+            }

+            if (typeNetworkTmp == 'limited_service' || typeNetworkTmp == 'no_service') {

+                return libjq.i18n.prop("network_type_" + typeNetworkTmp);

+            } else {

+                return networkType;

+            }

+        },

+        data: {

+            full: {

+                value: 30,

+                name: '��������',

+                itemStyle: {

+                    normal: {

+                        color: '#DF4313'

+                    }

+                }

+            },		

+            used: {

+                value: 30,

+                name: '��ʹ��',

+                itemStyle: {

+                    normal: {

+                        color: '#8CC916'

+                    }

+                }

+            },

+            left1: {

+                value: 50,

+                name: '����ֵ��δʹ��',

+                itemStyle: {

+                    normal: {

+                        color: '#D8D8D8'

+                    }

+                }

+            },

+            free: {

+                value: 50,

+                name: 'δʹ��',

+                itemStyle: {

+                    normal: {

+                        color: '#D8D8D8'

+                    }

+                }

+            },

+            alert: {

+                value: 1,

+                name: '����ֵ',

+                itemStyle: {

+                    normal: {

+                        color: '#FF5500'

+                    }

+                }

+            },

+            alarm: {

+                value: 19.7,

+                name: '������',

+                itemStyle: {

+                    normal: {

+                        color: '#8CC916'

+                    }

+                }

+            },

+            start: {

+                value: 50,

+                name: '����ֵ��δʹ��',

+                itemStyle: {

+                    normal: {

+                        color: '#D8D8D8'

+                    }

+                }

+            },

+        },

+		getDataInfo: function (value) {

+            return {

+                data: /\d+(.\d+)?/.exec(value)[0],

+                unit: /[A-Z]{1,2}/.exec(value)[0]

+            }

+        },

+        oldAlarmData: null,

+        oldUsedData: null,

+        updateEcharts: function (info) {

+            var startName = libjq.i18n.prop("echarts_no");

+            num_refresh++;

+            if (num_refresh % 10 != 2) {

+                return false;

+            }

+            var total = 0,

+            used = 0,

+            reach = 0,

+            left = 0,

+            alarm = 0,

+            left1 = 0;

+            if (info.limitVolumeEnable) {

+                startName = libjq.i18n.prop("echarts_used");

+                chartOptions.series[0].data = [];

+                if (info.limitVolumeType == '1') {

+                    var limitedDataFormatted = transUnit(info.limitDataMonth, false);

+                    chartOptions.series[0].data = [];

+                    if (info.limitDataMonth == 0) {

+                        var usedData = homeUtil.data.used;

+                        usedData.value = 1;

+                        usedData.selected = false;

+                        usedData.name = libjq.i18n.prop("echarts_used");

+                        chartOptions.series[0].data.push(usedData);

+                    } else {

+                        var dataInfo = homeUtil.getDataInfo(limitedDataFormatted);

+                        total = dataInfo.data * homeUtil.getUnitValue(dataInfo.unit) * 1048576;

+                        used = parseInt(info.data_counter.monthlySent, 10) + parseInt(info.data_counter.monthlyReceived, 10);

+                        reach = total * info.limitVolumePercent / 100;

+                        if (used >= total) {

+                            var fullData = homeUtil.data.full;

+                            fullData.value = 100;

+                            fullData.name = libjq.i18n.prop("echarts_full");

+                            chartOptions.series[0].data.push(fullData);

+                            startName = libjq.i18n.prop("echarts_full");

+                        } else {

+                            if (reach - used > 0) {

+                                left1 = reach - used;

+                                left = total - reach;

+                            } else {

+                                alarm = used - reach;

+                                left = total - used;

+                            }

+                            var usedData = homeUtil.data.used;

+                            if (reach - used > 0) {

+                                usedData.value = used;

+                            } else {

+                                usedData.value = reach;

+                            }

+                            usedData.name = libjq.i18n.prop("echarts_used");

+                            chartOptions.series[0].data.push(usedData);

+                            if (left1 > 0) {

+                                var left1Data = homeUtil.data.left1;

+                                left1Data.value = left1;

+                                left1Data.name = libjq.i18n.prop("echarts_left1");

+                                chartOptions.series[0].data.push(left1Data);

+                            }

+                            var alertData = homeUtil.data.alert;

+                            alertData.value = total / 200;

+                            alertData.name = libjq.i18n.prop("echarts_alert");

+                            chartOptions.series[0].data.push(alertData);

+                            if (alarm > 0) {

+                                var alarmData = homeUtil.data.alarm;

+                                alarmData.value = alarm;

+                                alarmData.name = libjq.i18n.prop("echarts_alarm");

+                                chartOptions.series[0].data.push(alarmData);

+                            }

+                            var freeData = homeUtil.data.free;

+                            freeData.value = left;

+                            freeData.name = libjq.i18n.prop("echarts_free");

+                            chartOptions.series[0].data.push(freeData);

+                        }

+                    }

+                } else {

+                    chartOptions.series[0].data = [];

+                    if (info.limitTimeMonth == 0) {

+                        var usedData = homeUtil.data.used;

+                        usedData.value = 1;

+                        usedData.selected = false;

+                        usedData.name = libjq.i18n.prop("echarts_used");

+                        chartOptions.series[0].data.push(usedData);

+                    } else {

+                        total = info.limitTimeMonth;

+                        used = info.data_counter.monthlyConnectedTime;

+                        reach = total * info.limitVolumePercent / 100;

+                        if (used >= total) {

+                            var fullTime = homeUtil.data.full;

+                            fullTime.value = 100;

+                            fullTime.name = libjq.i18n.prop("echarts_full");

+                            chartOptions.series[0].data.push(fullTime);

+                            startName = libjq.i18n.prop("echarts_full");

+                        } else {

+                            if (reach - used > 0) {

+                                left1 = reach - used;

+                                left = total - reach;

+                            } else {

+                                alarm = used - reach;

+                                left = total - used;

+                            }

+                            var usedTime = homeUtil.data.used;

+                            if (reach - used > 0) {

+                                usedTime.value = used;

+                            } else {

+                                usedTime.value = reach;

+                            }

+                            usedTime.name = libjq.i18n.prop("echarts_used");

+                            chartOptions.series[0].data.push(usedTime);

+                            if (left1 > 0) {

+                                var left1Time = homeUtil.data.left1;

+                                left1Time.value = left1;

+                                left1Time.name = libjq.i18n.prop("echarts_left1");

+                                chartOptions.series[0].data.push(left1Time);

+                            }

+                            var alertTime = homeUtil.data.alert;

+                            alertTime.value = total / 200;

+                            alertTime.name = libjq.i18n.prop("echarts_alert");

+                            chartOptions.series[0].data.push(alertTime);

+                            if (alarm > 0) {

+                                var alarmTime = homeUtil.data.alarm;

+                                alarmTime.value = alarm;

+                                alarmTime.name = libjq.i18n.prop("echarts_alarm");

+                                chartOptions.series[0].data.push(alarmTime);

+                            }

+                            var freeTime = homeUtil.data.free;

+                            freeTime.value = left;

+                            freeTime.name = libjq.i18n.prop("echarts_free");

+                            chartOptions.series[0].data.push(freeTime);

+                        }

+                    }

+                }

+            } else {

+                var usedData = homeUtil.data.used;

+                usedData.value = 1;

+                usedData.selected = false;

+                usedData.name = libjq.i18n.prop("echarts_no");

+                chartOptions.series[0].data = [usedData];

+                chartOptions.title.text = '';

+            }

+            var firstEle = libus.find(chartOptions.series[0].data, function (n) {

+                return n.name == libjq.i18n.prop("echarts_used");

+            });

+            var alarmEle = libus.find(chartOptions.series[0].data, function (n) {

+                return n.name == libjq.i18n.prop("echarts_alarm");

+            });

+            if (!alarmEle) {

+                alarmEle = {

+                    value: 0

+                };

+            }

+            if (typeof firstEle == "undefined") {

+                homeUtil.setEcharts(chartOptions, startName);

+            } else if (homeUtil.oldUsedData != firstEle.value || homeUtil.oldAlarmData != alarmEle.value) {

+                homeUtil.oldUsedData = firstEle.value;

+                homeUtil.oldAlarmData = alarmEle.value;

+                homeUtil.setEcharts(chartOptions, startName);

+            }

+        },

+        getUnitValue: function (unit) {

+            unit = unit.toUpperCase();

+            if (unit == 'GB') {

+                return '1024';

+            } else if (unit == 'TB') {

+                return '1048576';

+            } else {

+                return '1';

+            }

+        },		

+        setEcharts: function (options, startName) {

+            var startPart = homeUtil.data.start;

+            startPart.value = 0;

+            startPart.name = startName;

+            startPart.selected = false;

+            var arr = [startPart].concat(options.series[0].data);

+            options.series[0].data = arr;

+            traffic_graphic_chart.setOption(options, true);

+            addTimeout(function () {

+                traffic_graphic_chart.resize();

+            }, 1000);

+        },

+        refreshStationInfo: function (param) {

+            param.wirelessDeviceNum(fnc.getStatusInfo().wirelessDeviceNum);

+            if (num_refresh % 10 == 2) {

+                fnc.getAttachedCableDevices({}, function (data) {

+                    param.wireDeviceNum(data.attachedDevices.length);

+                });

+            }

+        },		

+        getUnit: function (val) {

+            if (val == '1024') {

+                return 'GB';

+            } else if (val == '1048576') {

+                return 'TB';

+            } else {

+                return 'MB';

+            }

+        },

+        refreshOpmodeInfo: function (param) {

+            var obj = fnc.getOpMode();

+            param.isLoggedIn(obj.loginfo == "ok");

+            var currentMode = checkCableMode(obj.blc_wan_mode);

+            if (param.opCurMode() && !currentMode) {

+                var data = fnc.getLoginData();

+                var state = data.modem_main_state;

+                if (state == "modem_sim_undetected" || state == "modem_undetected" || state == "modem_sim_destroy" || state == "modem_waitpin" || state == "modem_waitpuk" || state == "modem_imsi_waitnck") {

+                    window.location.reload();

+                    return;

+                }

+            }

+            param.opCurMode(currentMode);

+            if (currentMode && obj.ethwan_mode == "DHCP") {

+                param.enableFlag(false);

+            } else if ((!currentMode && obj.ppp_status != "ppp_disconnected") || (currentMode && obj.rj45_state != "idle" && obj.rj45_state != "dead")) {

+                param.enableFlag(true);

+            } else {

+                param.enableFlag(false);

+            }

+            var mode = (obj.blc_wan_mode == "AUTO_PPP" || obj.blc_wan_mode == "AUTO_PPPOE") ? "AUTO" : obj.blc_wan_mode;

+            var currentOpMode = "";

+            switch (mode) {

+            case "AUTO":

+                currentOpMode = "opmode_auto";

+                break;

+            case "PPPOE":

+                currentOpMode = "opmode_cable";

+                break;

+            case "PPP":

+                currentOpMode = "opmode_gateway";

+                break;

+            default:

+                break;

+            }

+            libjq("#opmode").attr("data-trans", currentOpMode).text(libjq.i18n.prop(currentOpMode));

+            param.isShowHomeConnect(!currentMode);

+            param.showTraffic(set.TRAFFIC_SUPPORT && !currentMode);

+            param.isSupportQuicksetting(set.HAS_QUICK_SETTING && !currentMode);

+        }

+    };

+	function VmHome() {

+        var target = this;

+        target.hasSms = set.HAS_SMS;

+        target.hasPhonebook = set.HAS_PHONEBOOK;

+        target.isSupportSD = set.SD_CARD_SUPPORT;

+        target.isCPE = set.PRODUCT_TYPE == 'CPE';

+        target.hasRj45 = set.RJ45_SUPPORT;

+        target.notDataCard = set.PRODUCT_TYPE != 'DATACARD';

+        target.hasParentalControl = set.HAS_PARENTAL_CONTROL;

+        var wifiInfo = fnc.getWifiBasic();

+        if (set.WIFI_SUPPORT_QR_SWITCH) {

+            target.showQRCode = set.WIFI_SUPPORT_QR_CODE && wifiInfo.show_qrcode_flag;

+        } else {

+            target.showQRCode = set.WIFI_SUPPORT_QR_CODE;

+        }

+        if(set.WIFI_SUPPORT_QR_CODE){

+            target.qrcodeSrc = './pic/qrcode_ssid_wifikey.png?_=' + libjq.now();

+        } else {

+            target.qrcodeSrc = './pic/res_blacktrans.png';

+        }

+        if (target.hasRj45) {

+            var opModeObj = checkCableMode(fnc.getOpMode().blc_wan_mode);

+            target.opCurMode = libko.observable(opModeObj);

+            target.isShowHomeConnect = libko.observable(!opModeObj);

+            target.showTraffic = libko.observable(set.TRAFFIC_SUPPORT && !opModeObj);

+            target.isSupportQuicksetting = libko.observable(set.HAS_QUICK_SETTING && !opModeObj);

+        } else {

+            target.isShowHomeConnect = libko.observable(true);

+            target.showTraffic = libko.observable(set.TRAFFIC_SUPPORT);

+            target.isSupportQuicksetting = libko.observable(set.HAS_QUICK_SETTING);

+        }

+        if (set.PRODUCT_TYPE == 'DATACARD') {

+            libjq('#home_image').addClass('data-card');

+        }

+        var info = fnc.getConnectionInfo();

+        target.networkType = libko.observable(homeUtil.getNetworkType(info.networkType));

+        target.connectStatus = libko.observable(info.connectStatus);

+        target.canConnect = libko.observable(false);

+        target.cStatus = libko.computed(function () {

+            if (target.connectStatus().indexOf('_connected') != -1) {

+                return connStat.CONNECTED;

+            } else if (target.connectStatus().indexOf('_disconnecting') != -1) {

+                return connStat.DISCONNECTING;

+            } else if (target.connectStatus().indexOf('_connecting') != -1) {

+                return connStat.CONNECTING;

+            } else {

+                return connStat.DISCONNECTED;

+            }

+        });

+        target.current_Flux = libko.observable(transUnit(0, false));

+        target.connected_Time = libko.observable(transSecond2Time(0));

+        target.up_Speed = libko.observable(transUnit(0, true));

+        target.down_Speed = libko.observable(transUnit(0, true));

+        target.isLoggedIn = libko.observable(false);

+        target.enableFlag = libko.observable(true);

+        target.simSerialNumber = libko.observable('');

+        target.imei = libko.observable('');

+        target.imsi = libko.observable('');

+        target.ssid = libko.observable('');

+        target.hasWifi = set.HAS_WIFI;

+        target.showMultiSsid = libko.observable(set.HAS_MULTI_SSID && wifiInfo.multi_ssid_enable == "1");

+        target.trafficAlertEnable = libko.observable(false);

+        target.trafficUsed = libko.observable('');

+        target.trafficLimited = libko.observable('');

+        target.wireDeviceNum = libko.observable(fnc.getAttachedCableDevices().attachedDevices.length);

+        target.wirelessDeviceNum = libko.observable(fnc.getStatusInfo().wirelessDeviceNum);

+        target.showOpModeWindow = function () {

+            if (target.enableFlag()) {

+                return;

+            }

+            showSettingWindow("change_mode", "opmode_popup", "opmode_popup", 400, 300, function () {});

+        };

+        target.currentOpMode = libko.observable("0");

+        var popoverShown = false;

+        libjq('#showDetailInfo').popover({

+            html: true,

+            placement: 'top',

+            trigger: 'focus',

+            title: function () {

+                return libjq.i18n.prop('device_info')

+            },

+            content: function () {

+                return getDetailInfoContent();

+            }

+        }).on('shown.bs.popover', function () {

+            popoverShown = true;

+        }).on('hidden.bs.popover', function () {

+            popoverShown = false;

+        });

+        function fetchDeviceInfo() {

+            var data = fnc.getDeviceInfo();

+            target.simSerialNumber(verifyDeviceInfo(data.simSerialNumber));

+            target.imei(verifyDeviceInfo(data.imei));

+            target.imsi(verifyDeviceInfo(data.imsi));

+            target.ssid(verifyDeviceInfo(data.ssid));

+            target.showMultiSsid(set.HAS_MULTI_SSID && data.multi_ssid_enable == "1");

+            return data;

+        }

+        fetchDeviceInfo();

+        function getDetailInfoContent() {

+            var data = fetchDeviceInfo();

+            homeUtil.initShownStatus(data);

+            var addrInfo = homeUtil.wanIpGet(data);

+            var compiled = libus.template(libjq("#detailInfoTmpl").html());

+            var tmpl = compiled({

+                simSerialNumber: verifyDeviceInfo(data.simSerialNumber),

+                imei: verifyDeviceInfo(data.imei),

+                imsi: verifyDeviceInfo(data.imsi),

+                signal: signalFormat(data.signal),

+                hasWifi: set.HAS_WIFI,

+                isCPE: set.PRODUCT_TYPE == 'CPE',

+                hasRj45: set.RJ45_SUPPORT,

+                showMultiSsid: set.HAS_MULTI_SSID && data.multi_ssid_enable == "1",

+                ssid: verifyDeviceInfo(data.ssid),

+                max_access_num: verifyDeviceInfo(data.max_access_num),

+                m_ssid: verifyDeviceInfo(data.m_ssid),

+                m_max_access_num: verifyDeviceInfo(data.m_max_access_num),

+                wifi_long_mode: "wifi_des_" + data.wifiRange,

+                lanDomain: verifyDeviceInfo(data.lanDomain),

+                ipAddress: verifyDeviceInfo(data.ipAddress),

+                showMacAddress: set.SHOW_MAC_ADDRESS,

+                macAddress: verifyDeviceInfo(data.macAddress),

+                showIpv4WanIpAddr: homeUtil.initStatus.showIpv4WanIpAddr,

+                wanIpAddress: addrInfo.wanIpAddress,

+                showIpv6WanIpAddr: homeUtil.initStatus.showIpv6WanIpAddr,

+                ipv6WanIpAddress: addrInfo.ipv6WanIpAddress,

+                sw_version: verifyDeviceInfo(data.sw_version),

+                hw_version: verifyDeviceInfo(data.hw_version)

+            });

+            return libjq(tmpl).translate();

+        }

+        target.connectHandler = function () {

+            if (target.connectStatus() == "ppp_connected") {

+                showLoading('disconnecting');

+                fnc.disconnect({}, function (data) {

+                    if (data.result) {

+                        successOverlay();

+                    } else {

+                        errorOverlay();

+                    }

+                });

+            } else {

+                if (fnc.getStatusInfo().roamingStatus) {

+                    showConfirm('dial_roaming_connect', function () {

+                        target.connect();

+                    });

+                } else {

+                    target.connect();

+                }

+            }

+        };

+        target.connect = function () {

+            var statusInfo = fnc.getStatusInfo();

+            var trafficResult = barStat.getTrafficResult(statusInfo);

+            if (statusInfo.limitVolumeEnable && trafficResult.showConfirm) {

+                var confirmMsg = null;

+                if (trafficResult.usedPercent > 100) {

+                    confirmMsg = {

+                        msg: 'traffic_beyond_connect_msg'

+                    };

+                    barStat.setTrafficAlertPopuped(true);

+                } else {

+                    confirmMsg = {

+                        msg: 'traffic_limit_connect_msg',

+                        params: [trafficResult.limitPercent]

+                    };

+                    barStat.setTrafficAlert100Popuped(false);

+                }

+                showConfirm(confirmMsg, function () {

+                    homeUtil.doConnect();

+                });

+            } else {

+                homeUtil.doConnect();

+            }

+        };

+        fnc.getSignalStrength({}, function (data) {

+            var signalTxt = signalFormat(convertSignal(data));

+            libjq("#fresh_signal_strength").text(signalTxt);

+            if (popoverShown) {

+                libjq("#popoverSignalTxt").text(signalTxt);

+            }

+        });

+        homeUtil.refreshHomeData(target);

+        addInterval(function () {

+            fnc.getSignalStrength({}, function (data) {

+                var signalTxt = signalFormat(convertSignal(data));

+                libjq("#fresh_signal_strength").text(signalTxt);

+                if (popoverShown) {

+                    libjq("#popoverSignalTxt").text(signalTxt);

+                }

+            });

+            homeUtil.refreshHomeData(target);

+        }, 1000);

+        if (target.hasRj45) {

+            homeUtil.refreshOpmodeInfo(target);

+            addInterval(function () {

+                homeUtil.refreshOpmodeInfo(target);

+            }, 1000);

+        }

+        target.showNetworkSettingsWindow = function () {

+            if (target.hasRj45) {

+                fnc.getOpMode({}, function (data) {

+                    var mode = checkCableMode(data.blc_wan_mode);

+                    if (mode) {

+                        window.location.hash = '#network_set';

+                    } else {

+                        window.location.hash = '#conn_set';

+                    }

+                });

+            } else {

+                window.location.hash = '#conn_set';

+            }

+        }

+    };

+    return {

+        init: init

+    };

+});

+

+

+define("language","knockout service jquery set underscore".split(" "), 

+    function(ko, service, $, config, _) {

+

+    //  ��ȡ��ǰ������

+    function getCurrentLanguage() {

+        return service.getLanguage();

+    }		

+

+    //  �������������������Դ������ҳ���ϵ�body����

+    //  @param {String} current ������:zh-cn

+    function loadLanguageAndRefresh(current){

+        window.CURRENT_LANGUAGE = current;

+        $("body").attr('lang', current);

+        $.i18n.properties({

+            name:'Messages',

+            path:'i18n/',

+            mode:'map',

+            cache: true,

+            language:current,

+            callback: function() {

+                jQuery.validator.messages = $.i18n.map;

+                $('body').translate();

+            }

+        });

+    }

+

+	window.language = null;

+

+

+    function LanguageViewModel() {

+        var target = this;

+        var currentLan = getCurrentLanguage();

+        var languages = _.map(config.LANGUAGES, function(item) {

+            return new Option(item.name, item.value);

+        });

+

+        document.title = config.WEBUI_TITLE;

+        if($('#webui_title')[0]) {

+            $('#webui_title').html(config.WEBUI_TITLE);

+        }

+

+        target.languages   = ko.observableArray(languages);

+        target.currentLan = ko.observable(currentLan.Language);

+		window.language      = target.currentLan();

+

+        //  �л������¼�����

+        //  @event langChangeHandler 

+        target.langChangeHandler = function(info, event) {

+            clearValidateMsg();

+

+            service.setLanguage({Language: target.currentLan()}, function() {

+                loadLanguageAndRefresh(target.currentLan());

+				window.language = target.currentLan();

+            });

+        };

+

+        // ���������б���ˢ�½���

+        loadLanguageAndRefresh(target.currentLan());

+    }

+

+    //  ��ʼ������VM����

+    function init() {

+        ko.applyBindings(new LanguageViewModel(), $('#language')[0]);

+    }

+

+    return {

+        init: init

+    };

+});

+

+

+// ��½ ģ��

+define("entry","jquery knockout set service underscore menu logout CryptoJS".split(" "), 

+	function($, ko,config, service, _, menu, logout, CryptoJS) {

+

+

+        var pageState      = {LOGIN:0, WAIT_PIN:1, WAIT_PUK:2, PUK_LOCKED:3, LOGGEDIN:4, LOADING:5};

+        var timer          = loginStatusCheckingTimer();

+        var loginLockTimer = 0;

+        var lastLoginStatus = "0";

+

+        function loginViewModel() {

+            var target        = this;

+            var data        = service.getLoginData();

+            var loginStatus = service.getLoginStatus();

+

+            target.confirmPIN           = ko.observable();	

+            target.leftSeconds          = ko.observable(0);				

+            target.loginCount           = ko.observable(0);

+            target.loginSecuritySupport = ko.observable(config.LOGIN_SECURITY_SUPPORT);

+            target.newPIN               = ko.observable();			

+            target.password             = ko.observable();

+            target.PIN                  = ko.observable();

+            target.pinNumber            = ko.observable(data.pinnumber);			

+            target.PUK                  = ko.observable();

+            target.pukNumber            = ko.observable(data.puknumber);	

+            target.showEntrance         = ko.observable(false);

+            target.sharePathInvalid     = ko.observable(false);			

+            target.uiLoginTimer         = ko.observable(300);

+

+            // ע��˳�򣬵���ǰ����޷�ˢ�³�����

+            target.accountLocked        = ko.computed(function () {

+                return target.loginCount() == config.MAX_LOGIN_COUNT && target.leftSeconds() != '-1';

+            });			

+

+            target.leftUnlockTime       = ko.computed(function () {

+                target.leftSeconds();

+                var formatted = transSecond2Time(target.uiLoginTimer());

+                return formatted.substring(formatted.indexOf(':') + 1, formatted.length);

+            });

+

+

+            if(config.SD_CARD_SUPPORT){

+                service.getSDConfiguration({}, function (data) {

+                    target.showEntrance(data.sd_status == "1" && data.share_status == "1" && data.sd_mode == "0");

+                    if(target.showEntrance()){

+                        service.checkFileExists({

+                            path: data.share_file

+                        }, function (data1) {

+                            if (data1.status == 'exist' || data1.status == 'processing') {

+                                target.sharePathInvalid(false);

+                            } else {

+                                target.sharePathInvalid(true);

+                            }

+                        });

+                    }

+                });

+            }

+

+            var state = computePageState(loginStatus, data);

+            target.pageState = ko.observable(state);

+            if (state == pageState.LOADING) {

+                addTimeout(refreshPage, 500);

+            }

+            setFocus();

+

+

+            // login �¼�����

+

+            target.login = function () {

+                if(config.LOGIN_SECURITY_SUPPORT && target.accountLocked()){

+                    showAlert("password_error_account_lock_time", function () {

+                        setFocus();

+                    });

+                    return false;

+                }

+                target.pageState(pageState.LOADING);

+                window.clearInterval(timer);

+                var ciphertext = "";

+                if (config.PASSWORD_ENCODE) {

+		    ciphertext = target.password();

+		} else {

+                    var kparam = service.getDeviceInfoLow();

+                    var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);

+		    var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);

+                    ciphertext = CryptoJS.AES.encrypt(target.password(), tkey, {

+                        iv: tiv,

+                        mode: CryptoJS.mode.CBC,

+                        padding: CryptoJS.pad.ZeroPadding

+                        }).toString();

+		}

+                service.login({

+                    password:ciphertext

+                }, function (info) {

+                    setTimeout(function () {

+                        timer = loginStatusCheckingTimer();

+                    }, 1300);

+                    if (info.result) {

+                        target.pageState(pageState.LOGGEDIN);

+                        if(config.LOGIN_SECURITY_SUPPORT){

+                            target.loginCount(0);

+                            target.uiLoginTimer(300);

+                            clearInterval(loginLockTimer);

+                        }

+                        $("#container").empty();

+                        window.location.hash = "#main";

+                        logout.init();

+                    } else {

+                        target.password("");

+                        if(config.LOGIN_SECURITY_SUPPORT){

+                            target.checkLoginData(function(){

+                                if (target.loginCount() == config.MAX_LOGIN_COUNT) {

+                                    showAlert("password_error_five_times", function () {

+                                        setFocus();

+                                    });

+                                    target.startLoginLockInterval();

+                                } else {

+                                    showAlert({msg: 'password_error_left', params: [config.MAX_LOGIN_COUNT - target.loginCount()]}, function () {

+                                        setFocus();

+                                    });

+                                }

+                            });

+                        }else {

+                            showAlert("password_error", function () {

+                                setFocus();

+                            });

+                        }

+                        target.pageState(pageState.LOGIN);

+                    }

+                });

+            };

+

+

+

+

+            // ��ȡ��¼�����Ϣ          

+            target.checkLoginData = function(cb){

+                service.getLoginData({}, function(r){

+                    var failTimes = parseInt(r.psw_fail_num_str, 10);

+                    target.loginCount(config.MAX_LOGIN_COUNT - failTimes);

+                    target.leftSeconds(r.login_lock_time);

+                    target.uiLoginTimer(r.login_lock_time);

+                    if($.isFunction(cb)){

+                        cb();

+                    } else if (target.loginCount() == config.MAX_LOGIN_COUNT) {

+                        target.startLoginLockInterval();

+                    }

+                });

+            };

+

+            // ��������ʱ��ʱ����

+            target.startLoginLockInterval = function () {

+                loginLockTimer = setInterval(function () {

+                    service.getLoginData({}, function (data) {

+                        if (data.login_lock_time <= 0 || data.psw_fail_num_str == 5) {

+                            target.loginCount(0);

+                            clearInterval(loginLockTimer);

+                        }

+                        if(target.leftSeconds() != data.login_lock_time){

+                            target.leftSeconds(data.login_lock_time);

+                            target.uiLoginTimer(data.login_lock_time);

+                        } else {

+                            target.uiLoginTimer(target.uiLoginTimer() > 0 ? target.uiLoginTimer() - 1 : 0);

+                        }

+                    });

+                }, 1000);

+            };            

+

+            target.checkLoginData();

+

+

+

+            // ��֤����PIN�¼�����

+            target.enterPIN = function () {

+                target.pageState(pageState.LOADING);

+                var pin = target.PIN();

+                service.enterPIN({

+                    PinNumber:pin

+                }, function (data) {

+                    if (!data.result) {

+                        showAlert("pin_error", function () {

+                            refreshPage();

+                        });

+                        target.PIN('');

+                    } else {

+                        refreshPage();

+                    }

+                });

+            };

+

+            function setFocus(){

+                setTimeout(function () {

+                    var txtAdmin = $('#txtAdmin:visible');

+                    var txtPIN = $('#txtPIN:visible');

+                    var txtPUK = $('#txtPUK:visible');

+                    if (txtAdmin.length > 0) {

+                        txtAdmin.focus();

+                    } else if (txtPIN.length > 0) {

+                        txtPIN.focus();

+                    } else if (txtPUK.length > 0) {

+                        txtPUK.focus();

+                    }

+                }, 100);

+            }            

+

+

+            // ˢ��ҳ��״̬           

+            function refreshPage() {

+                var data = service.getLoginData();

+                var loginStatus = service.getLoginStatus();

+                var state = computePageState(loginStatus, data);

+                if (state == pageState.LOADING) {

+                    addTimeout(refreshPage, 500);

+                } else {

+                    target.pageState(state);

+                    target.pinNumber(data.pinnumber);

+                    target.pukNumber(data.puknumber);

+                }

+                setFocus();

+            }

+

+            // ����PUK������PIN�¼�����

+            target.enterPUK = function () {

+                target.pageState(pageState.LOADING);

+                var newPIN = target.newPIN();

+                var confirmPIN = target.confirmPIN();

+                var params = {};

+                params.PinNumber = newPIN;

+                params.PUKNumber = target.PUK();

+                service.enterPUK(params, function (data) {

+                    if (!data.result) {

+                        showAlert("puk_error", function () {

+                            refreshPage();

+                        });

+                        target.PUK('');

+                        target.newPIN('');

+                        target.confirmPIN('');

+                    } else {

+                        refreshPage();

+                    }

+                });

+            };            

+

+

+

+            // ���ݵ�¼״̬��SIM��״̬����ҳ��״̬

+            function checkPinAfterLogin(loginStatus, data) {

+                if (loginStatus.status == "loggedIn") {

+                    var currentState = data.modem_main_state; // cov_2

+                    if (currentState == "modem_waitpin") {

+                        return pageState.WAIT_PIN;

+                    } else if ((currentState == "modem_waitpuk" || data.pinnumber == 0) && (data.puknumber != 0)) {

+                        return pageState.WAIT_PUK;

+                    } else if ((data.puknumber == 0 || currentState == "modem_sim_destroy")

+                        && currentState != "modem_sim_undetected" && currentState != "modem_undetected") {

+                        return pageState.PUK_LOCKED;

+                    } else {

+                        return pageState.LOGGEDIN;

+                    }

+                } else {

+                    var currentState = data.modem_main_state;

+                    if ($.inArray(currentState, config.TEMPORARY_MODEM_MAIN_STATE) != -1) {

+                        return pageState.LOADING;

+                    } else {

+                        return pageState.LOGIN;

+                    }

+                }

+            }			

+

+            // ���ݵ�¼״̬��SIM��״̬����ҳ��״̬

+            function computePageState(loginStatus, data) {

+                //PX-880 �ȵ�¼�ٽ���PIN��֤������router���ԭ�򣬵�¼��PIN��֤���ڵ�¼ҳ����У������ݿ�����֤����һ�¡�

+                if (config.LOGIN_THEN_CHECK_PIN) {

+                    return checkPinAfterLogin(loginStatus, data);

+                } else {

+                    return loginAfterCheckPin(loginStatus, data);

+                }

+            }

+

+            // ���ݵ�¼״̬��SIM��״̬����ҳ��״̬

+            function loginAfterCheckPin(loginStatus, data) {

+                if (loginStatus.status == "loggedIn") {

+                    return pageState.LOGGEDIN;

+                } else {

+                    var currentState = data.modem_main_state;

+						if ($.inArray(currentState, config.TEMPORARY_MODEM_MAIN_STATE) != -1) {

+							return pageState.LOADING;

+						} else if (currentState == "modem_waitpin") {

+							return pageState.WAIT_PIN;

+						} else if ((currentState == "modem_waitpuk" || parseInt(data.pinnumber) === 0) && (parseInt(data.puknumber) != 0)) {

+							return pageState.WAIT_PUK;

+						} else if ((parseInt(data.puknumber) === 0 || currentState == "modem_sim_destroy") && currentState != "modem_sim_undetected" && currentState != "modem_undetected") {

+							return pageState.PUK_LOCKED;

+						} else {

+							return pageState.LOGIN;

+					}                    

+                }

+            }

+        }

+

+

+        // ��鵱ǰwindow.location.hash���쳣����ת��index.html      

+        function gotoLogin() {

+            if (window.location.hash != config.defaultRoute && _.indexOf(config.GUEST_HASH, window.location.hash) == -1) {

+                if (!manualLogout && lastLoginStatus == "1") {

+                    manualLogout = false;

+                    lastLoginStatus = 'UNREAL';

+                    showAlert('need_login_again', function () {

+                        window.location = "index.html";

+                    });

+                } else if (lastLoginStatus == 'UNREAL') {

+                    //do nothing, only popup need_login_again alert one time

+                    return;

+                } else {

+                    window.location = "index.html";

+                }

+            }

+        }

+

+        // ��ʱ����¼״̬      

+        function loginStatusCheckingTimer() {

+            return setInterval(function () {

+                var info = service.getStatusInfo();

+                if (!info.isLoggedIn) {

+                    gotoLogin();

+                    return;

+                }

+                lastLoginStatus = service.getStatusInfo().isLoggedIn ? "1" : "0";

+            }, 1000);

+        }	

+

+        function init() {

+            var info = service.getStatusInfo();

+            if (info.isLoggedIn) {

+                window.location.hash = '#main';

+                return;

+            }

+

+            var container = $('#container')[0];

+            ko.cleanNode(container);

+            var fwVm = new loginViewModel();

+            ko.applyBindings(fwVm, container);

+

+            $('#frmLogin').validate({

+                submitHandler:function () {

+                    fwVm.login();

+                },

+                rules: {

+                    txtAdmin: 'login_password_length_check'

+                }

+            });

+            $('#frmPIN').validate({

+                submitHandler:function () {

+                    fwVm.enterPIN();

+                },

+                rules:{

+                    txtPIN:"pin_check"

+                }

+            });

+            $('#frmPUK').validate({

+                submitHandler:function () {

+                    fwVm.enterPUK();

+                },

+                rules:{

+                    txtNewPIN:"pin_check",

+                    txtConfirmPIN:{equalToPin:"#txtNewPIN"},

+                    txtPUK:"puk_check"

+                }

+            });

+        }

+

+

+        return {

+            init:init,

+            gotoLogin:gotoLogin

+        };

+    });

+

+

+// Logout �

+define("logout","set service knockout underscore jquery".split(" "),

+    function (config, service, ko, _, $) {

+

+    function logoutViewModel() {

+        var target = this;

+        // ��ȡ�Ƿ��¼

+        var loginFlag = function () {

+            var loginInfo = service.getLoginStatus();

+            return (loginInfo.status == "loggedIn");

+        }

+        ();

+        target.loggedIn = ko.observable(loginFlag);

+

+        // �˳�ϵͳ

+        target.logout = function () {

+            showConfirm("confirm_logout", function () {

+                manualLogout = true;

+                service.logout({}, setLocation());

+            });

+        };

+

+        // �Ƿ���ʾ�˳���ť

+        target.showLogout = function () {

+            if (config.HAS_LOGIN) {

+                return target.loggedIn();

+            } else {

+                return false;

+            }

+        };

+    }

+    function setLocation() {

+        window.location = 'index.html';

+    }

+    function initialize() {

+        var fwVm = new logoutViewModel();

+        bindContainer(fwVm);

+    }

+    function bindContainer(fwVm) {

+        var con = $('#logout')[0];

+        ko.cleanNode(con);

+        ko.applyBindings(fwVm, con);

+    }

+    return {

+        init: initialize

+    };

+});

+

+// operation mode �

+define("opmode","knockout service jquery set underscore".split(" "),

+

+    function (ko, service, $, config, _) {

+

+	function currentOperationModeViewMode(){

+		var target = this;

+		target.isLoggedIn = ko.observable(false);	

+		target.enableFlag = ko.observable(false);

+

+		target.showOpModeWindow = function () {

+			showSettingWindow("change_mode", "opmode_popup", "opmode_popup", 400, 300, function () {

+			});

+		};

+		target.currentOpMode = ko.observable("0");

+

+		service.getOpMode({}, function(info){

+			target.isLoggedIn(info.loginfo == "ok");

+			if (info.opms_wan_mode != "PPP" && info.rj45_state != "idle" && info.rj45_state != "dead") {

+				target.enableFlag(false);

+			} else if (info.opms_wan_mode == "PPP" && info.ppp_status != "ppp_disconnected") {

+				target.enableFlag(false);

+			} else if(info.opms_wan_mode == "DHCP"){

+				target.enableFlag(true);

+			} else {

+				target.enableFlag(true);

+			}

+

+			var opmsWanMode = (info.opms_wan_mode == "DHCP" || info.opms_wan_mode == "STATIC") ? "PPPOE" : info.opms_wan_mode;

+

+			var currentOperationMode = "";

+			switch(opmsWanMode){

+				case "BRIDGE":

+					currentOperationMode = "opmode_bridge";

+					break;

+				case "PPP":

+					currentOperationMode = "opmode_gateway";

+					break;					

+				case "PPPOE":

+					currentOperationMode = "opmode_cable";

+					break;

+				default:

+					break;

+			}

+			$("#opmode").attr("data-trans", currentOperationMode).text($.i18n.prop(currentOperationMode));

+		});

+        // ��ʱ��ѯ����ģʽ���״̬�����ý���״̬

+		setInterval(function(){

+			var object = service.getConnectionInfo();

+			if(object.opms_wan_mode == "DHCP") {

+				target.enableFlag(true);

+			} else if((object.opms_wan_mode == "PPP" && object.ppp_status != "ppp_disconnected") || (object.opms_wan_mode != "PPP" && object.rj45_state != "idle" && object.rj45_state != "dead")) {

+				target.enableFlag(false);

+			} else {

+				target.enableFlag(true);

+			}

+		}, 1000);

+	}

+

+	function init() {

+		var container = $('#currentOpMode')[0];

+        ko.cleanNode(container);

+        var fwVm = new currentOperationModeViewMode();

+        ko.applyBindings(fwVm, container);

+	}

+

+	return {

+		init:init

+	};

+});

+

+// operation mode popup�

+

+define("opmode_popup","knockout service jquery set underscore".split(" "),

+

+    function (ko, service, $, config, _) {

+

+    function operationModeViewMode() {

+		var target = this;

+		var currentSelectedOperationMode = "";

+		target.selectedMode = ko.observable("0");	

+

+	    // ��ʼ������ģʽ��ʾ	

+		service.getOpMode({}, function(info){

+			if(info.blc_wan_mode == "AUTO_PPP"){

+                currentSelectedOperationMode = "AUTO";

+            }else if(info.blc_wan_mode == "AUTO_PPPOE"){

+                currentSelectedOperationMode = "AUTO";

+            }else if(info.blc_wan_mode == "PPPOE"){

+                currentSelectedOperationMode = "PPPOE";

+            }else{

+                currentSelectedOperationMode = info.blc_wan_mode;

+            }

+			target.selectedMode(currentSelectedOperationMode);

+		});

+

+	    // ģʽ����/�л�	

+		target.changeOpMode = function(){

+			var userSelectedOperationMode = $('input:radio[name="opMode"]:checked').val();

+            var messageText = "";

+			if(userSelectedOperationMode == currentSelectedOperationMode) {

+				hidePopupSettingWindow();

+				return;

+			}

+            if(userSelectedOperationMode == "LTE_BRIDGE"){

+                messageText = "opmode_msg3";

+            }else{

+                messageText = "opmode_msg2";

+            }

+			showConfirm(messageText, function(){

+                showLoading();

+				service.SetOperationMode({

+					opMode: userSelectedOperationMode

+				},function(info){

+					if (info && info.result == "success") {

+						var currentOperationMode = "";

+						switch(userSelectedOperationMode){

+							case "AUTO":

+								currentOperationMode = "opmode_auto"

+								break;

+							case "PPP":

+								currentOperationMode = "opmode_gateway";

+								break;

+							case "PPPOE":

+								currentOperationMode = "opmode_cable";

+								break;								

+							default:

+								break;

+						}

+						$("#opmode").attr("data-trans", currentOperationMode).text($.i18n.prop(currentOperationMode));

+						successOverlay();						

+					} else {

+						errorOverlay();

+					}

+				});

+			});

+

+		}

+

+	}

+

+	function init() {

+		var fwVm = new operationModeViewMode();

+		ko.applyBindings(fwVm, $('#popupSettingWindow')[0]);

+

+		$("#opmode_form").validate({

+			submitHandler: function(){

+				fwVm.changeOpMode();

+			}

+		});

+	}

+

+	return {

+		init:init

+	};

+});

+

+define("router","underscore jquery menu set service".split(" "),

+    function (_, $, menu, config, service) {

+    var currentHash = '';

+    var container = $('#container');

+

+    //�뿪����ʱ����Ƿ��������޸ģ����������ʾ

+    checkFormContentModify = function (href) {

+        if (config.CONTENT_MODIFIED.modified && window.location.hash != href) {

+            if (config.CONTENT_MODIFIED.message == 'sms_to_save_draft') {

+                config.CONTENT_MODIFIED.callback.ok(config.CONTENT_MODIFIED.data);

+                config.resetContentModifyValue();

+                window.location.hash = href;

+            } else {

+                showConfirm(config.CONTENT_MODIFIED.message, {

+                    ok: function () {

+                        config.CONTENT_MODIFIED.callback.ok(config.CONTENT_MODIFIED.data);

+                        config.resetContentModifyValue();

+                        window.location.hash = href;

+                    },

+                    no: function () {

+                        var result = config.CONTENT_MODIFIED.callback.no(config.CONTENT_MODIFIED.data);

+                        if (!result) {

+                            window.location.hash = href;

+                            config.resetContentModifyValue();

+                        }

+                    }

+                });

+            }

+            return false;

+        } else {

+            return true;

+        }

+    };

+

+    //��ʱ�鿴SIM����״̬������ǰSIM��״̬��Ϊ����״̬��δ��ʾnosimcardҳ�棬����ʾnosimcardҳ��,�Ա��ⲻ�ر�webui�����²���豸�󣬲����ж�SIM��״̬������

+    function checkSimCardStatus() {

+        setInterval(function () {

+            var data = service.getStatusInfo();

+            var match = menu.findMenu();

+            if (match.length == 0) {

+                return false;

+            }

+            var requirePinHash = ["phonebook", "sms_list"];

+            var isRequirePin = ($.inArray(match[0].path, requirePinHash) != -1);

+            if (match[0].checkSIMStatus === true) {

+                var simstatus = data.simStatus == "modem_sim_undetected"

+                     || data.simStatus == "modem_sim_destroy" || data.simStatus == "modem_waitpin"

+                     || data.simStatus == "modem_waitpuk";

+                var netlockstatus = data.simStatus == "modem_imsi_waitnck";

+                if (data.isLoggedIn && (

+                        ($('#div-nosimcard')[0] == undefined && simstatus)

+                         || ($('#div-network-lock')[0] == undefined && netlockstatus)

+                         || (($('#div-nosimcard')[0] != undefined || $('#div-network-lock')[0] != undefined) && data.simStatus == "modem_init_complete"))) {

+                    fixedLoadResources(match[0], data.simStatus, isRequirePin);

+                }

+            }

+        }, 1000);

+    }

+

+    //����¼ҳ�汳��

+    function checkLoginPageBg() {

+        var h = window.location.hash;

+        if (h == '#entry' || _.indexOf(config.GUEST_HASH, h) != -1) {

+            $("#manageContainer").attr("style", "margin-top:-36px;");

+        } else {

+            $("#manageContainer").attr("style", "margin-top:0px;");

+        }

+

+        if (window.location.hash == '#entry') {

+            $("#mainContainer").addClass('loginBackgroundBlue');

+        } else {

+            var mainContainer = $("#mainContainer");

+            if (mainContainer.hasClass('loginBackgroundBlue')) {

+                $("#container").css({

+                    margin: 0

+                });

+                mainContainer.removeClass('loginBackgroundBlue').height('auto');

+            }

+        }

+    }

+

+    function fixedLoadResources(menuItem, simStatus, isRequirePin) {

+        var item = {};

+        $.extend(item, menuItem);

+        //û��SIM��ʱ�����homeҳ�治��������

+        //���类��ʱ��homeҳ����ʾ����ҳ��

+        if (simStatus == "modem_sim_undetected" || simStatus == "modem_sim_destroy") {

+            if (!isRequirePin) {

+                item.path = "sim_abnormal";

+            }

+        } else if (simStatus == "modem_waitpin" || simStatus == "modem_waitpuk") {

+            item.path = "sim_abnormal";

+        } else if (simStatus == "modem_imsi_waitnck") {

+            item.path = "locknet";

+        }

+        //load tmpl and controller js

+        loadResources(item);

+    }

+

+    //���ݲ˵�����item���ض�Ӧ����Դ

+    function loadResources(item) {

+        var pId = item.path.replace(/\//g, '_');

+        var $body = $('body').removeClass();

+        if (pId != 'entry' && pId != 'main') {

+            $body.addClass('beautiful_bg page_' + pId);

+        } else {

+            $body.addClass('page_' + pId);

+        }

+        clearTimer();

+        hideLoading();

+        var tmplPath = 'text!tmpl/' + item.path + '.html';

+        //TODO: prevent first menu click cover the second menu content, need test with device

+        require([tmplPath, item.path], function (tmpl, viewModel) {

+            container.stop(true, true);

+            container.hide();

+            container.html(tmpl);

+            viewModel.init();

+            //support backward/forward

+            menu.refreshMenu();

+            $('#container').translate();

+            menu.activeSubMenu();

+

+            $("form").attr("autocomplete", "off");

+            container.fadeIn();

+        });

+    }

+    //�ȶ�hash״̬, ����仯������µ�hashƥ��˵�����,ƥ�䲻��ʱ��ת��homeҳ��, ƥ����ʱ��¼hashֵ����̬���ض�Ӧ����Դ�ļ�

+    function hashCheck() {

+        if (window.location.hash != currentHash) {

+            //�����½���������, ��½�û����ʷǵ�¼�û�ʱҳ�治��ת

+            var info = service.getStatusInfo();

+            if (window.location.hash == config.defaultRoute || _.indexOf(config.GUEST_HASH, window.location.hash) != -1) {

+                if (info.isLoggedIn) {

+                    window.location.hash = currentHash == "" ? "#main" : currentHash;

+                    return;

+                }

+            }

+

+            var match = menu.findMenu();

+

+            if (match.length == 0) {

+                window.location.hash = config.defaultRoute;

+            } else {

+                //��¼ʱ��鹤��ģʽ������ģʽ������������Ҫ���SIM��״̬�����¼���,����ģʽ�������治��Ҫ���SIM��״̬�����¼���

+                if (config.RJ45_SUPPORT && window.location.hash == "#main") {

+                    if ((match[0].checkSIMStatus && checkCableMode(info.blc_wan_mode)) || (!match[0].checkSIMStatus && !checkCableMode(info.blc_wan_mode))) {

+                        window.location.reload();

+                        return;

+                    }

+                }

+                //TODO: �����˵����Ӧ�����˵���һ����л�ʱ�����¼�������, ��TODO: click the same menu ʵ�ַ�ʽ����

+                var oldMenu = menu.findMenu(currentHash);

+                currentHash = match[0].hash;

+                if (currentHash == "#entry") {

+                    $('#indexContainer').addClass('login-page-bg');

+                    menu.rebuild();

+                } else {

+                    $('#indexContainer').removeClass('login-page-bg');

+                }

+

+                if (oldMenu.length != 0 && match[0].path == oldMenu[0].path && match[0].level != oldMenu[0].level && match[0].level != '1' && oldMenu[0].level != '1') {

+                    return;

+                }

+

+                checkLoginPageBg();

+                var requirePinHash = ["phonebook", "sms_list"];

+                var isRequirePin = ($.inArray(match[0].path, requirePinHash) != -1);

+                if (match[0].checkSIMStatus === true || isRequirePin) {

+                    //simStatus is undefined when refreshing page

+                    if (info.simStatus == undefined) {

+                        showLoading('waiting');

+                        function checkSIM() {

+                            var data = service.getStatusInfo();

+                            if (data.simStatus == undefined || $.inArray(data.simStatus, config.TEMPORARY_MODEM_MAIN_STATE) != -1) {

+                                addTimeout(checkSIM, 500);

+                            } else {

+                                fixedLoadResources(match[0], data.simStatus, isRequirePin);

+                                hideLoading();

+                            }

+                        }

+                        checkSIM();

+                    } else {

+                        fixedLoadResources(match[0], info.simStatus, isRequirePin);

+                    }

+                } else {

+                    loadResources(match[0]);

+                }

+            }

+        }

+    }

+

+    //Ĭ�����ҳ��Ϊ#main, ��ʱ���hash״̬

+    function init() {

+        checkSimCardStatus();

+        window.location.hash = window.location.hash || "#main";

+        //if support onhashchange then use. If ie8 in ie7 mode, it doesn't trigger onhashchange.

+        if (('onhashchange' in window) && ((typeof document.documentMode === 'undefined') || document.documentMode == 8)) {

+            window.onhashchange = hashCheck;

+            hashCheck();

+        } else {

+            setInterval(hashCheck, 200);

+        }

+

+        //����޸���ҳ������, �뿪ʱ������ʾ

+        $("a[href^='#']").die('click').live('click', function () {

+            var $this = $(this);

+            config.CONTENT_MODIFIED.checkChangMethod();

+            return checkFormContentModify($this.attr('href'));

+        });

+    }

+

+    return {

+        init: init

+    };

+});

+

+// statusBar �

+

+define("statusBar", "knockout jquery underscore service set menu tooltip".split(" "), 

+

+    function (ko, $, _, service, config, menu, tooltip) {

+

+	var sv__hasCheckedSMSCapacity   = false;	

+    var sv__initSMSCompleted        = false;		

+    var sv_newSMSMessageInDealing   = false;		

+    var sv_fotaUpdateCancel         = null;

+	var sv_batteryCheckTimer        = 0;	

+    var sv_dbMessageIds             = [];	

+    var sv_fotaResultAlertPopuped   = false;

+    var sv_isFirstLoadNewMessage    = true;	

+    var isLoggedIn                  = true;		

+    var sv_messagePopStack          = {};

+    var sv_newMessagePopTemplate    = null;	

+    var sv_resetTrafficAlertPopuped = false;

+    var sv_simMessageListTemplate   = null;

+    var sv_smsListTemplate          = null;		

+    var sv_trafficAlertPopuped_100  = false;		

+    var sv_trafficAlertPopuped      = false;

+    var sv_timer                    = 0;

+

+    // ��ȡ״̬��Ϣ�������硢SIM��WIFI��

+    var getCurrentStatusInfo = function () {

+        return service.getStatusInfo();

+    };

+

+    function statusViewModel() {

+        var target         = this;

+        var info           = getCurrentStatusInfo();

+		var roamStatus   = info.roamingStatus ? true : false;

+		var $langLogoBar = $("#langLogoBar");

+

+

+        // �����������¼�����

+		function sf_connect() {

+            showLoading("connecting");

+            service.connect({}, function (data) {

+                if (data.result) {

+                    refreshWifiConnectStatus(target, data.status);

+                }

+                successOverlay();

+            }, function (data) {

+                errorOverlay();

+            });

+        }

+        // �Ͽ������¼�����

+		function sf_disconnect() {

+            showLoading("disconnecting");

+            service.disconnect({}, function (data) {

+                if (data.result) {

+                    refreshWifiConnectStatus(target, data.status);

+                }

+                successOverlay();

+            }, function (data) {

+                errorOverlay();

+            });

+        }			

+

+        if(info.isLoggedIn){

+        	if(!$langLogoBar.hasClass("langborderBg")){

+                $langLogoBar.addClass("langborderBg");

+        	}

+        	$("#statusBar:hidden").show();

+        } else {

+        	if($langLogoBar.hasClass("langborderBg")){

+                $langLogoBar.removeClass("langborderBg");

+        	}

+        	$("#statusBar:visible").hide();

+        }	

+

+

+        //target.attachedDevices        = ko.observable(info.attachedDevices);

+        target.batteryLevel             = ko.observable(info.batteryLevel + '%');

+        target.batteryPers              = ko.observable(sf_getBatteryLevelImage(info.batteryPers, info.batteryStatus));		

+        target.batteryStatus            = ko.observable(info.batteryStatus);	

+        target.connectionCssClass       = ko.observable("");		

+        target.connectStatus            = ko.observable(info.connectStatus);

+        target.connectStatusText        = ko.observable();

+        target.connectStatusTrans       = ko.observable();

+        target.hasWifi                  = ko.observable(config.HAS_WIFI);

+        target.hasBattery               = ko.observable(config.HAS_BATTERY);		

+        target.isLoggedIn               = ko.observable(info.isLoggedIn);

+        target.isShowConnectionIcon     = ko.observable(false);

+		target.isShowFotaNewversionIcon = ko.observable(info.new_version_state && info.fota_package_already_download != "yes" && !config.isShowFotaIcon);		

+        target.isShowRj45ConnectionIcon = ko.observable(false);

+        target.networkOperator          = ko.observable(sf_getNetWorkProvider(info.spn_b1_flag,info.spn_name_data,info.spn_b2_flag,info.networkOperator,roamStatus));		

+        target.networkType              = ko.observable(getNetworkType(info.networkType));

+        target.pinStatus                = ko.observable(info.pinStatus);

+        target.pinStatusText            = ko.observable();	

+        target.rj45ConnectionCssClass   = ko.observable("");		

+        target.roamingStatus            = ko.observable(info.roamingStatus ? "R" : "");

+        target.showAttachedDevices      = ko.observable(info.wifiStatus);		

+        target.showSmsDeleteConfirm     = ko.observable(false);

+        target.smsUnreadCount           = ko.observable(0);

+        target.simStatus                = ko.observable(sf_convertSimStatusToImage(info.simStatus));

+        target.signalCssClass           = ko.observable(sf_getSignalCssClass(info.signalImg, info.networkType, info.simStatus));		

+        target.updateType               = ko.observable(service.getUpdateType().update_type);

+        target.wifiStatusCssClass       = ko.observable(sf_getWifiStatusCssClass(info.wifiStatus, info.wirelessDeviceNum));

+        target.wifiStatusImg            = ko.observable(sf_getWifiStatusImage(info.wifiStatus, info.wirelessDeviceNum));

+

+        sf_getConnectionCssClass(target, info.connectStatus, info.data_counter, info.connectWifiSSID, info.connectWifiStatus, info.rj45ConnectStatus);	

+

+        target.connect    = sf_connect;

+        target.disconnect = sf_disconnect;

+    }

+

+	function sf_gotoSmsList(){

+        var s_href = '#msg_main';

+        if(window.location.hash == '#msg_main'){

+            s_href = '#msg_list';

+        }

+		config.CONTENT_MODIFIED.checkChangMethod();

+        if(checkFormContentModify(s_href)){

+            window.location.hash = s_href;

+        }

+    }

+

+    gotoSmsList = sf_gotoSmsList;	

+

+    function sf_getNetWorkProvider(i_spnB1Flag, i_spnNameData, i_spnB2Flag, i_networkProvider, i_roamStatus) {

+        if (i_spnNameData == "") {

+            return i_networkProvider;

+        } else {

+            i_spnNameData = decodeMessage(i_spnNameData);

+            if (i_spnB1Flag == "0" && i_spnB2Flag == "0") {

+                if (i_roamStatus) {//����

+                    return i_spnNameData == i_networkProvider ? i_networkProvider : (i_spnNameData + '  ' + i_networkProvider);

+                } else {//������

+                    return i_spnNameData;

+                }

+            }else if (i_spnB1Flag == "1" && i_spnB2Flag == "1") {

+                if (i_roamStatus) {//����

+                    return i_networkProvider;

+                } else {//������

+                    return i_spnNameData == i_networkProvider ? i_networkProvider : (i_spnNameData + '  ' + i_networkProvider);

+                }

+            } else if (i_spnB1Flag == "1") {

+                return i_spnNameData == i_networkProvider ? i_networkProvider : (i_spnNameData + '  ' + i_networkProvider);

+            } else if (i_spnB2Flag == "1") {

+                if (i_roamStatus) {//����

+                    return i_networkProvider;

+                } else {//������

+                    return i_spnNameData;

+                }

+            } 

+            return "";

+        }

+    }

+

+    // �����¶���Ϣ��ʾ���������������

+    function sf_addNewMessage(i_message, i_isUpdate, i_type){

+    	config.smsMaxId = i_message.id;

+    	var now = $.now();

+    	sv_messagePopStack["m" + now] = now;

+    	var name = i_message.number;

+    	if(sv_isFirstLoadNewMessage && config.phonebook && config.phonebook.length == 0){

+    		sv_isFirstLoadNewMessage = false;

+    		if(config.HAS_PHONEBOOK){

+				sf_getPhoneBooks();

+			}else{

+				config.phonebook = [];

+			}

+    	}

+    	for(i in config.phonebook){

+    		if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){

+    			name = config.phonebook[i].pbm_name;

+    			break;

+    		}

+    	}

+		var s_newMsg = {

+			mark : "m" + now,

+			name: name,

+			title: $.i18n.prop("sms"),

+			titleTrans: "sms",

+			tag: i_message.tag,

+			content : i_message.content,

+			datetime : i_message.time

+		};

+		if(sv_newMessagePopTemplate == null){

+			sv_newMessagePopTemplate = $.template("newMessagePopTmpl", $("#newMessagePopTmpl"));

+		}

+        $(".bubbleItem:not(.report)", "#buttom-bubble").remove();

+        $.tmpl("newMessagePopTmpl", s_newMsg).appendTo("#buttom-bubble");

+		if((window.location.hash == "#msg_main" || window.location.hash == "#msg_list") && i_type == "1"){

+            //sf_dealChosenNumber(s_newMsg.name, i_message.number);

+			var s_inChating = config.currentChatObject && config.currentChatObject == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH);

+			var s_itemId = getLastNumber(i_message.number, config.SMS_MATCH_LENGTH);

+			var item = $("#smslist-item-" + s_itemId);

+			if(item && item.length > 0){

+                // �Ѵ������ݣ��������ݵ���˳��

+				for(var i = 0; config.listMsgs && i < config.listMsgs.length; i++){

+					if(getLastNumber(config.listMsgs[i].number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){

+						config.listMsgs[i].id = i_message.id;

+						config.listMsgs[i].latestId = i_message.id;

+						config.listMsgs[i].latestSms = i_message.content;

+						config.listMsgs[i].latestTime = i_message.time;

+						if(!i_isUpdate){

+							config.listMsgs[i].newCount++;

+							config.listMsgs[i].totalCount++;

+						}

+						break;

+					}

+				}

+				item.find(".smslist-item-checkbox p.checkbox").attr("id", i_message.id);

+				item.find(".smslist-item-checkbox input:checkbox").val(i_message.id).attr("id", "checkbox" + i_message.id);

+				if(!i_isUpdate){

+					var s_itemCount = item.find(".smslist-item-total-count").text();

+					s_itemCount = Number(s_itemCount.substring(1, s_itemCount.length - 1));

+					item.find(".smslist-item-total-count").text("(" + (s_itemCount + 1) + ")");

+					if(!config.currentChatObject || config.currentChatObject != getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){

+						var s_newNum = item.find(".smslist-item-new-count").removeClass("hide");

+						if(s_newNum && s_newNum.text().length > 0){

+							s_newNum.text(Number(s_newNum.text()) + 1);

+						}else{

+							s_newNum.text(1);

+						}

+					}

+				}

+				if(item.find(".smslist-item-draft-flag").length > 0){

+					if (config.currentChatObject && config.currentChatObject == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)) {

+					    item.find(" td:nth-child(2)").removeClass("font-weight-bold");

+				    } else {

+					    item.find(" td:nth-child(2)").addClass("font-weight-bold");

+				    }

+				}else{

+					var msgContent = item.find(".smslist-item-msg").text(i_message.content);

+				    msgContent.closest('td').prop('title', i_message.content);

+				    item.find("span.clock-time").text(i_message.time);

+					if (config.currentChatObject && config.currentChatObject == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)) {

+					    msgContent.closest('tr').removeClass("font-weight-bold");

+				    } else {

+					    msgContent.closest('tr').addClass("font-weight-bold");

+				    }

+				}

+				item.find(".smslist-item-repeat span").die().click(function() {

+					forwardClickHandler(i_message.id);

+				});

+

+				var s_tmpItem = item;

+				item.hide().remove();

+				$("#smslist-table").prepend(s_tmpItem.show());

+			} else {

+                // ��������б��в�������Ӧ����ϵ�˶�Ϣ��Ӧ�ڶ����б�����������

+				var s_theName = "";

+				if(config.phonebook && config.phonebook.length > 0) {

+					for(i in config.phonebook){

+						if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){

+							s_theName = config.phonebook[i].pbm_name;

+							break;

+						}

+					}

+				}

+				var s_theNewMessage = {

+					id : i_message.id,

+					name : s_theName,

+					number : i_message.number,

+					latestId :i_message.id,

+					totalCount : 1,

+					newCount : s_inChating ? 0 : 1,

+					latestSms : i_message.content,

+					latestTime : i_message.time,

+					checked : false,

+					hasDraft : false,

+					itemId : getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)

+				};

+				if(sv_smsListTemplate == null){

+					sv_smsListTemplate = $.template("smsTableTmpl", $("#smsTableTmpl"));

+				}

+				$.tmpl("smsTableTmpl", {data: [s_theNewMessage]}).prependTo("#smslist-table");

+            }

+            if(config.HAS_PHONEBOOK){

+                $(".sms-add-contact-icon").removeClass("hide");

+            }else{

+                $(".sms-add-contact-icon").addClass("hide");

+            }

+			if(s_inChating){

+				var talkItem = $("#talk-item-" + i_message.id, "#chatlist");

+				if (talkItem && talkItem.length > 0) {// ���¼�����������

+					$(".J_content pre", talkItem).html(dealContent(i_message.content));

+					$(".time .smslist-item-time", talkItem).text(i_message.time);

+					$(".smslist-item-repeat", talkItem).die().click(

+							function() {

+								forwardClickHandler(i_message.id);

+							});

+					$(".smslist-item-delete", talkItem).die().click(

+							function() {

+								deleteSingleItemClickHandler(i_message.id);

+							});

+				} else {// �����µĻظ�����

+					$("#smsOtherTmpl").tmpl(i_message).appendTo("#chatlist");

+					$(".clear-container", "#chatpanel").animate({

+						scrollTop : $("#chatlist").height()

+					});

+				}

+                if (!config.SMS_SET_READ_WHEN_COMPLETE) {

+                    service.setSmsRead({ids: [i_message.id]}, $.noop);

+                } else if (config.SMS_SET_READ_WHEN_COMPLETE && i_message.receivedAll) {

+                    service.setSmsRead({ids: [i_message.id]}, $.noop);

+                }

+			}

+            enableCheckbox($("#smslist-checkAll"));

+		}

+		if(window.location.hash == "#msg_sim" && i_type == "0"){

+			// ��������б��в�������Ӧ����ϵ�˶�Ϣ��Ӧ�ڶ����б�����������

+				var s_theName = "";

+				if(config.phonebook && config.phonebook.length > 0) {

+					for(i in config.phonebook){

+						if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){

+							s_theName = config.phonebook[i].pbm_name;

+							break;

+						}

+					}

+				}

+				var s_theNewMessage = {

+					id : i_message.id,

+					name : s_theName,

+					number : i_message.number,

+					content : i_message.content,

+					time : i_message.time,

+					tag: i_message.tag,

+					checked : false,

+					itemId : getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)

+				};

+				if(i_isUpdate){

+					var s_item = $(".simMsgList-item-class-" + s_theNewMessage.id);

+				    s_item.hide().remove();				

+				}

+				if(sv_simMessageListTemplate == null){

+					sv_simMessageListTemplate = $.template("ssimMessageListTemplate", $("#simMessageListTemplate"));

+				}

+				$.tmpl("simMessageListTemplate", {data: [s_theNewMessage]}).prependTo("#simMsgList_container");

+		}

+	}

+

+ 	function sf_checkBatteryStatusForFota(){

+	  var s_state = service.getCurrentUpgradeState();

+	  if(s_state.current_upgrade_state == 'low_battery'){

+			showInfo('ota_low_battery');

+			clearInterval(sv_batteryCheckTimer);

+		}

+	} 

+

+    // ��SIM��״̬ת��Ϊ��Ӧ����������

+    function sf_convertSimStatusToImage(i_status) {

+        var s_image;

+        switch (i_status) {

+            case "modem_destroy":

+                s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_destroy");

+                break;

+            case "modem_imsi_waitnck":

+                s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_waitnck");

+                break;				

+            case "modem_init_complete":

+                s_image = "./pic/simcard_detected.png";//$.i18n.prop("sim_status_ready");

+                break;	

+            case "modem_sim_destroy":

+                s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_destroy");

+                break;				

+            case "modem_sim_undetected":

+                s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_undetected");

+                break;

+            case "modem_undetected":

+                s_image = "./pic/simcard_undetected.png";

+                break;				

+            case "modem_waitpin":

+                s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_waitpin");

+                break;

+            case "modem_waitpuk":

+                s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_waitpuk");

+                break;

+

+            default:

+                s_image = "./pic/simcard_detected.png";//$.i18n.prop("sim_status_ready");

+                break;

+        }

+        return s_image;

+    }

+

+    function sf_dealChosenNumber(i_choosenName, i_choosenNum) {

+        setTimeout(function () {

+            var s_choosen  = $("#chosenUserSelect");

+            var s_options = $("option", s_choosen);

+            for (var index  = 0; index < s_options.length; index++) {

+                if (getLastNumber(i_choosenNum, config.SMS_MATCH_LENGTH) == s_options[index].value) {

+

+                    s_options[index].text  = i_choosenName + '/' + i_choosenNum;

+					s_options[index].value = i_choosenNum;

+

+                    break;

+                }

+            }

+            s_choosen.trigger("liszt:updated");

+        }, 0);

+    } 

+

+	// ˫�첽��ȡ�豸���sim����ö���Ϣ��������ϲ�

+	function sf_dealPhoneBooksResult(i_books){

+		if($.isArray(i_books.pbm_data) && i_books.pbm_data.length > 0){

+			config.phonebook = i_books.pbm_data;

+		}

+	}	

+

+    // �������µ�5������Ϣ����δ���ӵ������б��еĵ�����ʾ

+    function sf_filterNewMessage(i_messages, i_type){

+    	if(!config.dbMsgs){

+    		config.dbMsgs = [];

+    	}

+    	if(sv_dbMessageIds.length == 0){

+    		$.each(config.dbMsgs, function(index_1, i_element){

+    			sv_dbMessageIds.push(i_element.id);

+    		});

+    	}

+    	$.each(i_messages, function(index_2, i_element){

+    		if($.inArray(i_element.id, sv_dbMessageIds) == -1){//�����¶���

+    			sv_dbMessageIds.push(i_element.id);

+    			config.dbMsgs.push(i_element);

+    			if(i_element.tag == '1'){

+    				sf_addNewMessage(i_element, false, i_type);

+    			}

+    		}else{

+    			for(var index = 0; index < config.dbMsgs.length; index++){//���¼�������

+    				if(config.dbMsgs[index].id == i_element.id && config.dbMsgs[index].content != i_element.content && i_element.tag == '1'){

+    					config.dbMsgs[index].content = i_element.content;

+    					sf_addNewMessage(i_element, true, i_type);

+    					break;

+    				}

+    			}

+    		}

+    	});

+    }

+

+    // ������ת��Ϊ��ӦͼƬ

+    function sf_getBatteryLevelImage(pers, i_status) {

+    	var s_Image = null;

+		if ("0" == i_status) {

+			if ("-1" == pers) {

+				s_Image = null;

+			} else if ("1" == pers) {

+				s_Image = "pic/power_one.png";

+			} else if ("2" == pers) {

+				s_Image = "pic/power_two.png";

+			} else if ("3" == pers) {

+				s_Image = "pic/power_three.png";

+			} else if ("4" == pers) {

+				s_Image = "pic/power_full.png";

+			} else { //"5" == pers || "0" == pers

+				s_Image = "pic/power_out.png";

+			}

+		} else {

+			s_Image = "pic/power_charging.gif";

+		}

+		return s_Image;

+    }

+

+    // ��ȡ����״̬��CSS��ʽ

+    function sf_getConnectionCssClass(i_fwVm, i_status, i_data_counter, i_wifiSSID, i_wifiStatus, i_rj45Status) {

+

+        var s_rj45ConnectionStatus = "icon_connection ";

+        var s_connectionStatus     = "icon_connection ";

+

+        if(i_rj45Status == "connect"){

+            s_rj45ConnectionStatus += "connecting";

+        }else if(i_rj45Status == "working"){

+            s_rj45ConnectionStatus += "rj45_connected";

+        }else{

+            s_rj45ConnectionStatus += "disconnect";			

+        }

+

+        if (i_status == "ppp_connecting" || i_status == "wifi_connecting") {

+            s_connectionStatus += "connecting";

+        } else if(i_status == "ppp_connected") {//CPE ppp_statusΪnone ready��ֵ

+            if (i_data_counter.uploadRate != '0' && i_data_counter.downloadRate != '0') {

+                s_connectionStatus += "connectionBoth";

+            } else if (i_data_counter.uploadRate != '0' && i_data_counter.downloadRate == '0') {

+                s_connectionStatus += "connectionUp";

+            } else if (i_data_counter.uploadRate == '0' && i_data_counter.downloadRate != '0') {

+                s_connectionStatus += "connectionDown";

+            } else {

+                s_connectionStatus += "connectionNone";

+            }

+        } else if (i_status == "ppp_disconnected") {

+            if (i_wifiSSID && i_wifiStatus == "connect") {

+                service.getHotspotList({}, function (data) {

+                    var s_cssName = "icon_connection ";

+                    var s_css = "connecting ";

+                    for (var i = 0, len = data.hotspotList.length; i < len; i++) {

+                        if (data.hotspotList[i].connectStatus == "1") {

+                            s_css = "wifi_connected";

+                            break;

+                        }

+                    }

+                    s_cssName += s_css;

+                    i_fwVm.connectionCssClass(s_cssName);

+                });

+                i_fwVm.rj45ConnectionCssClass(s_rj45ConnectionStatus);

+                return;

+            } else if (i_wifiSSID && (i_wifiStatus == "connecting" || i_wifiStatus =="dhcping")) {

+                s_connectionStatus += "connecting";

+            } else {

+                s_connectionStatus += "disconnect";

+            }

+        }  else {

+            s_connectionStatus += "disconnect";

+        }

+

+        i_fwVm.connectionCssClass(s_connectionStatus);

+        i_fwVm.rj45ConnectionCssClass(s_rj45ConnectionStatus);

+    }

+

+	// ��ȡ�绰����Ϣ

+	function sf_getPhoneBooks() {

+		var s_books = service.getPhoneBooks({

+            page : 0,

+            data_per_page : 2000,

+            orderBy : "id",

+            isAsc : false

+		});

+		sf_dealPhoneBooksResult(s_books);

+	}

+

+	// ��ȡ�ź�����CSS��ʽ

+    function sf_getSignalCssClass(siganl, networkType, simStatus) {

+    	networkType = networkType.toLowerCase();

+    	simStatus = simStatus ? simStatus.toLowerCase() : '';

+    	if(networkType == '' || networkType == 'limited_service' || networkType == 'no_service' || networkType == 'limited service' || networkType == 'no service'

+            || simStatus != 'modem_init_complete'){

+    		siganl = '_none';

+    	}

+        return "signal signal" + siganl;

+    }

+

+    function sf_getWifiStatusCssClass(i_status, i_deviceSize) {

+        if (i_status) {

+            if (i_deviceSize == 0) {

+                return "wifi_status0";

+            } else {

+                return "wifi_status" + i_deviceSize;

+            }

+        } else {

+            return "wifi_status_off";

+        }

+    }

+

+    // ����wifi״̬��ȡwifi��ͼƬ��Դ

+    function sf_getWifiStatusImage(i_status, i_deviceSize) {

+		if (i_status) {

+			if (i_deviceSize == 0) {

+				return "./pic/wlan0.png";

+			} else {

+				return "./pic/wlan" + i_deviceSize + ".png";

+			}

+		} else {

+			return "./pic/wlan_off.png";

+		}

+	}	

+

+    // ��ȡ��������������С���������ؽ���

+    function sf_refreshFotaDownloadProgress(){

+        service.getPackSizeInfo({}, function (data) {

+            var percents;

+            if (parseInt(data.fota_pkg_total_size) == 0) {

+                percents = 0;

+            } else {

+                percents = parseInt(parseInt(data.fota_dl_pkg_size) * 100 / parseInt(data.fota_pkg_total_size));

+            }

+            if (percents > 100) {

+                percents = 100;

+            }

+            if (percents >= 0) {

+                if (percents > 95) {

+                    showProgressBar("ota_update", "<br/>" + $.i18n.prop("ota_update_warning"));

+                }

+                setProgressBar(percents);

+            }

+        });

+    }		

+

+    // �������ŷ��ͱ���

+    function sf_responseSmsReport(){

+    	if(sv_isFirstLoadNewMessage && config.phonebook && config.phonebook.length == 0){

+

+    		sv_isFirstLoadNewMessage = false;

+

+    		if(config.HAS_PHONEBOOK){

+				sf_getPhoneBooks();

+			}else{

+				config.phonebook = [];

+			}

+    	}

+    	service.getSMSDeliveryReport({

+    		page: 0,

+    		smsCount: 10

+    	}, function(data){

+    		var s_messages = data.messages;

+    		var s_nums = [];

+    		$.each(s_messages, function(i, i_message){

+    			if($.inArray(i_message.number, s_nums) == -1){

+    				s_nums.push(i_message.number);

+                    window.setTimeout(function(){

+    					var s_now = $.now();

+    					sv_messagePopStack["m" + s_now] = s_now;

+    					i_message.name = i_message.number;

+    					for(i in config.phonebook){

+    						if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){

+    							i_message.name = config.phonebook[i].pbm_name;

+    							break;

+    						}

+    					}

+    					var s_msgContent = $.i18n.prop("sms_delivery_report_" + i_message.content);

+

+    					var s_newMsg = {

+    							mark : "m" + s_now,

+    							name: i_message.name,

+    							title: $.i18n.prop("sms_report"),

+    							titleTrans: "sms_report",

+    							content : s_msgContent,

+    							datetime : i_message.time,

+    							report : 'report'

+    					};

+

+    					if(sv_newMessagePopTemplate == null){

+    						sv_newMessagePopTemplate = $.template("newMessagePopTmpl", $("#newMessagePopTmpl"));

+    					}

+

+                        $(".report", "#buttom-bubble").remove();

+    					$.tmpl("newMessagePopTmpl", s_newMsg).appendTo("#buttom-bubble");

+    				}, 100);

+    			}

+    		});

+    	}, function(){

+    		//No Deal

+    	});

+    }

+

+    function sf_simStatusInvalid(simStatus){

+        return simStatus == 'modem_sim_undetected' || simStatus == 'modem_undetected' || simStatus == 'modem_sim_destroy'

+            || simStatus == 'modem_waitpin' || simStatus == 'modem_waitpuk' || simStatus == 'modem_imsi_waitnck';

+    }	

+

+    // ��ʾFOTA������ǰ״̬

+    function sf_showFotaCurrentStatus() {

+        sv_fotaUpdateCancel = true;

+		var r = service.getNewVersionState();

+

+        function showProgress() {

+            var upgradingState = ["downloading"];

+            var info = service.getCurrentUpgradeState();

+            if(info.current_upgrade_state.toLowerCase() == "idle") {

+                addTimeout(showProgress, 1000);

+            } else if(($.inArray(info.current_upgrade_state, upgradingState) != -1)&&(r.fota_new_version_state != "already_has_pkg")) {

+                hideLoading();

+                sf_showFotaUpgradeStatus();

+            }

+        }

+        if (!($("#progress").is(":visible"))) {

+            showProgress();

+        }

+        var times = 0;

+        var getOTAUpgradeState = function () {

+            var data = null;

+            if (times <= 3) {

+                times = times + 1;

+                data = service.getCurrentUpgradeState();

+            } else {

+                data = getCurrentStatusInfo();

+            }

+            var state = data.current_upgrade_state;

+            if(sv_fotaUpdateCancel && isLoggedIn == true){

+

+				if(r.fota_new_version_state == "already_has_pkg"){

+					if(state == 'low_battery'){

+                        hideProgressBar();

+                        sv_fotaUpdateCancel = false;

+					    service.removeTimerThings('fota_current_upgrade_state',function(){});

+                        showInfo('ota_pkg_low_battery');

+                        window.clearTimeout(sv_timer);

+                        return;

+                    }else if(state == 'prepare_install'){

+                        hideProgressBar();

+                        sv_fotaUpdateCancel = false;

+                        service.removeTimerThings('fota_current_upgrade_state',function(){});

+                        showInfo('ota_pkg_download_success');

+                        window.clearTimeout(sv_timer);

+                        sv_batteryCheckTimer = setInterval(function () {

+                            sf_checkBatteryStatusForFota();

+                            }, 1000);

+                        return;

+				    } 

+				}else if(state == 'downloading') {

+                    sf_refreshFotaDownloadProgress();

+                }else if(state == 'download_failed') {

+                    hideProgressBar();

+                    sv_fotaUpdateCancel = false;

+                    showAlert('ota_download_failed');

+                    window.clearTimeout(sv_timer);

+                    return;

+                }else if(state == 'low_battery'){

+                    hideProgressBar();

+                    sv_fotaUpdateCancel = false;

+					service.removeTimerThings('fota_current_upgrade_state',function(){});

+                    showInfo('ota_low_battery');

+                    window.clearTimeout(sv_timer);

+                    return;

+                }else if(state == 'prepare_install'){

+                    hideProgressBar();

+                    sv_fotaUpdateCancel = false;

+                    service.removeTimerThings('fota_current_upgrade_state',function(){});

+                    showInfo('ota_download_success');

+                    window.clearTimeout(sv_timer);

+                    sv_batteryCheckTimer = setInterval(function () {

+                        sf_checkBatteryStatusForFota();

+                    }, 1000);

+                    return;

+                }else{

+                    sv_fotaUpdateCancel = false;

+                    hideProgressBar();

+                    window.clearTimeout(sv_timer);

+                    return;

+                }

+                sv_timer = window.setTimeout(getOTAUpgradeState , 1000);

+            }

+        };

+

+        if(sv_fotaUpdateCancel && isLoggedIn == true){

+            sv_timer = window.setTimeout(getOTAUpgradeState , 100);

+        }else{

+            window.clearTimeout(sv_timer);

+        }

+    }	

+

+    // ��ʾFota�������

+    function sf_showFotaUpdateResult(i_otaResult) {

+        if ((!($("#loading").is(":visible"))) && (!($("#confirm").is(":visible")))) {

+            var s_message = i_otaResult ? "ota_update_success" : "ota_update_failed";

+            sv_fotaResultAlertPopuped = true;

+            showAlert(s_message, function () {

+                sv_fotaResultAlertPopuped = false;

+                if (config.UPGRADE_TYPE == "OTA") {

+                    service.clearUpdateResult({}, $.noop());

+                }

+            });

+        } else {

+            window.setTimeout(function () {

+                sf_showFotaUpdateResult(i_otaResult)

+            }, 1000);

+        }

+    }	

+

+    // ��ʾ��ǰ����״̬

+    function sf_showFotaUpgradeStatus() {

+        var s_data        = service.getMandatory();

+        var s_isMandatory = s_data.is_mandatory;

+        var s_sizeInfo    =service.getPackSizeInfo();

+		var s_percents;

+

+        if (parseInt(s_sizeInfo.fota_pkg_total_size) == 0) {

+            s_percents = 0;

+        } else {

+            s_percents = parseInt(parseInt(s_sizeInfo.fota_dl_pkg_size) * 100 / parseInt(s_sizeInfo.fota_pkg_total_size));

+        }

+        if (s_percents > 100) {

+            s_percents = 100;

+        }

+

+        if (s_isMandatory) {

+            showProgressBar("ota_update", "<br/>" + $.i18n.prop("ota_update_warning"));

+        } else {

+            var cancelHtml = "";

+            if (config.UPGRADE_TYPE == "OTA") {

+                cancelHtml = "<br/><br/><button id='btnStopUpgrade' onclick='stopOTAUpgrade();' class='btn-1 btn-primary'>" + $.i18n.prop("cancel") + "</button>";

+            }

+            showProgressBar("ota_update", "<br/>" + $.i18n.prop("ota_update_warning") + cancelHtml);

+        }

+

+        //setProgressBar(0);

+       if (s_percents >= 0) {

+            setProgressBar(s_percents);       

+       }

+    }

+

+

+

+

+

+    function sf_startFotaUpgrade(){

+        service.setUpgradeSelectOp({selectOp:'1'},function(result){

+            if (result.result == "success"){

+                sf_showFotaCurrentStatus();

+            }});

+    }

+

+    function cancelFotaUpgrade(){

+        service.setUpgradeSelectOp({selectOp:'0'},function(result){ });

+    }

+

+

+    function refreshFotaStatusForUserSelector(choice){

+        var info = getCurrentStatusInfo();

+        if(choice){

+			var modeData = service.getOpMode();

+            if (!checkConnectedStatus(info.connectStatus, modeData.rj45_state, info.connectWifiStatus)) {

+                showAlert("ota_network_disconnected");

+                return;

+            }

+

+            if(info.fota_user_selector == 'none'){

+                sf_startFotaUpgrade();

+            }else if(info.fota_user_selector == 'accept'){

+                sf_showFotaCurrentStatus();

+            }else if(info.fota_user_selector == 'cancel'){

+                showAlert("ota_have_cancel");

+            }else if(info.fota_user_selector == 'downloading_cancel'){

+                showAlert("ota_have_cancel");

+            }

+        }else{

+            if(info.fota_user_selector == 'none'){

+                cancelFotaUpgrade();

+            }else if(info.fota_user_selector == 'accept'){

+                sf_showFotaCurrentStatus();

+            }else if(info.fota_user_selector == 'cancel'){

+                // todo: 

+            }else if(info.fota_user_selector == 'downloading_cancel'){

+                // todo: 

+            }

+        }

+    }

+

+

+    // ��ʾ���°汾�������ж��Ƿ������ʾ

+    function showFotaStatusForUserToConfirm(upgradeState) {

+        var upgState = upgradeState.current_upgrade_state;

+        if (upgState == 'upgrade_pack_redownload') {

+            showConfirm("ota_interrupted", {ok: function () {

+                refreshFotaStatusForUserSelector(1);

+            }, no: function () {

+                refreshFotaStatusForUserSelector(0);

+            }});

+        } else {

+            var upgradingState = ["prepare_install", "low_battery",

+                "connecting_server", "connect_server_success", "downloading", "accept"];

+            if ($.inArray(upgState, upgradingState) != -1) {

+                sf_showFotaCurrentStatus();

+            } else {

+

+                showConfirm($.i18n.prop('ota_new_version'), {ok: function () {

+                    refreshFotaStatusForUserSelector(1);

+					config.ISNOW_NOTICE = false;

+                }, no: function () {

+                    refreshFotaStatusForUserSelector(0);

+					config.ISNOW_NOTICE = false;

+                }});

+            }

+        }

+    }

+

+    showOTAAlert = function () {

+		config.ISNOW_NOTICE = true;

+        var is_mandatory = service.getMandatory().is_mandatory;

+        if (is_mandatory) {

+            sf_showFotaCurrentStatus();

+        } else {

+            var upgradeState = {};

+            upgradeState = service.getCurrentUpgradeState();

+            showFotaStatusForUserToConfirm(upgradeState);

+        }

+    };

+

+    // ��ֹFota����

+    stopOTAUpgrade = function () {

+        service.setUpgradeSelectOp({selectOp:'2'},function(result){ });

+        sv_fotaUpdateCancel = false;

+        window.clearTimeout(sv_timer);

+        hideLoading();

+        showAlert('ota_cancel');

+    };

+

+    // �������������Ƿ����ѹ�

+    function setTrafficAlertPopuped(val){

+    	sv_trafficAlertPopuped = !!val;

+        sv_trafficAlertPopuped_100 = !!val;

+        if(!val){

+            sv_resetTrafficAlertPopuped = true;

+        }

+    }

+

+    function setTrafficAlert100Popuped(val){

+        sv_trafficAlertPopuped_100 = !!val;

+        if(!val){

+            sv_resetTrafficAlertPopuped = true;

+        }

+    }

+

+    // ���������ṹ

+    function getTrafficResult(info){

+        var s_trafficResult = {

+            showConfirm : false,

+            limitPercent : info.limitVolumePercent

+        };

+        if(info.limitVolumeType == '1'){

+            var monthlyTraffic = parseInt(info.data_counter.monthlySent, 10) + parseInt(info.data_counter.monthlyReceived, 10);

+            s_trafficResult.usedPercent = monthlyTraffic / info.limitVolumeSize * 100;

+            if(s_trafficResult.usedPercent > s_trafficResult.limitPercent){

+                s_trafficResult.showConfirm = true;

+                s_trafficResult.type = 'data';

+            }

+        }else{

+            s_trafficResult.usedPercent = info.data_counter.monthlyConnectedTime / info.limitVolumeSize * 100;

+            if(s_trafficResult.usedPercent > s_trafficResult.limitPercent){

+                s_trafficResult.showConfirm = true;

+                s_trafficResult.type = 'time';

+            }

+        }

+        return s_trafficResult;

+    }

+

+	// ��ʼ�� ViewModel����������ͼ��

+    function init() {

+        if(config.PRODUCT_TYPE == 'DATACARD') {

+            $('#statusBar').addClass('padding-right-90');

+            $('#language').addClass('data-card-language');

+        }

+        //preload img 

+        var imgAlert   = $('<img />').attr('src', 'pic/res_alert.png');

+        var imgConfirm = $('<img />').attr('src', 'pic/res_confirm.png');

+        var imgInfo    = $('<img />').attr('src', 'pic/res_info.png');

+

+        window.setTimeout(function () {

+

+            var fwVm = new statusViewModel();

+

+            ko.applyBindings(fwVm, $('#statusBar')[0]);

+

+            window.setInterval(function () {

+                var info          = getCurrentStatusInfo();

+				var s_roamStatus    = info.roamingStatus ? true : false;

+                var $langLogoBar  = $("#langLogoBar");

+                isLoggedIn        = info.isLoggedIn;

+

+

+                //fwVm.attachedDevices(info.attachedDevices);	

+                fwVm.batteryLevel(info.batteryLevel + '%');				

+                fwVm.batteryPers(sf_getBatteryLevelImage(info.batteryPers, info.batteryStatus));

+                fwVm.batteryStatus(info.batteryStatus);				

+				fwVm.isShowFotaNewversionIcon(info.new_version_state && info.fota_user_selector && info.fota_package_already_download != "yes" && config.ISNOW_NOTICE && fwVm.updateType() == 'mifi_fota');

+				fwVm.isShowRj45ConnectionIcon(config.RJ45_SUPPORT);

+                fwVm.networkOperator(sf_getNetWorkProvider(info.spn_b1_flag,info.spn_name_data,info.spn_b2_flag,info.networkOperator,s_roamStatus));

+                fwVm.networkType(getNetworkType(info.networkType));

+                fwVm.pinStatus(info.pinStatus);

+                fwVm.roamingStatus(info.roamingStatus ? "R" : "");

+                fwVm.showAttachedDevices(info.wifiStatus);

+                fwVm.simStatus(sf_convertSimStatusToImage(info.simStatus));				

+                fwVm.signalCssClass(sf_getSignalCssClass(info.signalImg, info.networkType, info.simStatus));				

+                fwVm.isLoggedIn(info.isLoggedIn);

+                fwVm.wifiStatusCssClass(sf_getWifiStatusCssClass(info.wifiStatus, info.wirelessDeviceNum));

+                fwVm.wifiStatusImg(sf_getWifiStatusImage(info.wifiStatus, info.wirelessDeviceNum));	

+

+				if(config.HAS_SMS ){

+					if(!sv__hasCheckedSMSCapacity && info.isLoggedIn){

+						checkSMSCapacity(info.smsUnreadCount);

+					} else {

+						fwVm.smsUnreadCount(info.smsUnreadCount);

+					}

+                }

+

+                sf_getConnectionCssClass(fwVm, info.connectStatus, info.data_counter, info.connectWifiSSID, info.connectWifiStatus, info.rj45ConnectStatus);

+                refreshWifiConnectStatus(fwVm, info.connectStatus,info.connectWifiSSID,info.connectWifiStatus);

+                checkTrafficLimitAlert(fwVm, info);

+                updateStatusBarTrans({simStatus: info.simStatus, wifiStatus: info.wifiStatus, deviceSize: info.wirelessDeviceNum, networkType: info.networkType});

+

+                if(info.isLoggedIn){

+                	$("#statusBar:hidden").show();

+                } else {

+                	$("#statusBar:visible").hide();

+                }

+            }, 500);

+

+            if(config.HAS_SMS){

+                window.setInterval(function(){

+                    if(fwVm.isLoggedIn()){

+                        checkSMSCapacity();

+                    }

+                }, 10000);

+                checkSmsModelReady();

+            }

+

+            window.setInterval(function() {

+                var data = getCurrentStatusInfo();

+				var upgradingState = ["prepare_install", "low_battery", "download_success","downloading"];

+

+                if (fwVm.isLoggedIn() == true && !($("#progress").is(":visible")) && data.defaultWanName != ""){                    

+					 	if ($.inArray(data.current_upgrade_state, upgradingState) != -1){

+                        if(null == sv_fotaUpdateCancel){

+                            if(!data.is_mandatory){

+                                $.modal.close();

+                            }

+                            sf_showFotaCurrentStatus();

+                        }else if(false == sv_fotaUpdateCancel){

+                            sv_fotaUpdateCancel = null;

+                        }

+                    }

+                }

+            }, 1000);

+

+            var checkFotaUpgradeResult = function () {

+                var info = service.getStatusInfo();

+                if (info.isLoggedIn) {

+                    service.getUpgradeResult({}, function (data) {

+                        if (data.upgrade_result == "success") {

+                            sf_showFotaUpdateResult(true);

+                        } else if (data.upgrade_result == "fail") {

+                            sf_showFotaUpdateResult(false);

+                        } else {

+                            window.setTimeout(checkFotaUpgradeResult, 1000);

+                        }

+                    }, function () {

+                        window.setTimeout(checkFotaUpgradeResult, 1000);

+                    });

+                } else {

+                    window.setTimeout(checkFotaUpgradeResult, 1000);

+                }

+            };

+            if(fwVm.updateType() == "mifi_fota"){

+                checkFotaUpgradeResult();

+                window.setInterval(function () {

+                    var info = getCurrentStatusInfo();

+                    if (info.isLoggedIn && info.defaultWanName != "") { 

+                        if(info.new_version_state && info.fota_package_already_download != "yes" && !config.ALREADY_NOTICE){

+                            service.getUpgradeResult({}, function (data) {

+                                if (data.upgrade_result == "success") {

+                                    sf_showFotaUpdateResult(true);

+                                } else if (data.upgrade_result == "fail") {

+                                    sf_showFotaUpdateResult(false);

+                                } else {

+                                    if(sv_fotaResultAlertPopuped == false){

+                                        config.ALREADY_NOTICE = true;

+                                        showOTAAlert();

+                                    }

+                                }

+                            });

+                        }

+                    }

+                }, 1000);

+            }

+			function checkSMSCapacity(unreadCount){

+				service.getSmsCapability({}, function(info){

+					var showSmsConfirm = false;

+					if(info.nvTotal != 0 && info.nvUsed >= info.nvTotal){

+						$("#sms_unread_count").attr("tipTitle", "sms_capacity_is_full");

+						showSmsConfirm = true;

+					} else if(info.nvTotal != 0 && info.nvUsed + 5 >= info.nvTotal) {

+						$("#sms_unread_count").attr("tipTitle", "sms_capacity_will_full");

+						showSmsConfirm = true;

+					} else {

+						$("#sms_unread_count").attr("tipTitle", "sms_unread_count");

+					}

+					fwVm.showSmsDeleteConfirm(showSmsConfirm);

+					if(typeof unreadCount != "undefined"){

+						fwVm.smsUnreadCount(unreadCount);

+					}

+					sv__hasCheckedSMSCapacity = true;

+				});

+			}

+        }, 1200);

+

+        tooltip.init();

+

+        // ����Ϣģ���ʼ��״̬

+        function checkSmsModelReady(){

+            var info = getCurrentStatusInfo();

+            if(info.isLoggedIn){

+                service.getSMSReady({}, function (data) {

+                    if (data.sms_cmd_status_result == "1") {

+                        window.setTimeout(function(){checkSmsModelReady();}, 1000);

+                    } else {

+                        sv__initSMSCompleted = true;

+                    }

+                });

+            } else {

+                window.setTimeout(function(){checkSmsModelReady();}, 1000);

+            }

+        }

+

+        // ����������״̬

+        checkTrafficLimitAlert = function(fwVm, info){

+	    if(window.location.hash == '#entry'){

+                return false;

+            }

+            var APStationEnabled = config.AP_STATION_SUPPORT ? service.getStatusInfo().ap_station_enable : 'undefined';

+			var trafficResult    = getTrafficResult(info);

+            var inShow           = $("#confirm-container:visible").length > 0;

+            // var notPPP           = (config.PRODUCT_TYPE == 'CPE' && checkCableMode(info.blc_wan_mode)) ? true : false;

+            var notPPP = false;

+

+            // ��ȡAp Stationʹ��״̬���������ѷ�ʽ

+            if (config.AP_STATION_SUPPORT && (typeof APStationEnabled == "undefined" || APStationEnabled === '')) {

+                service.refreshAPStationStatus({}, $.noop());

+                return false;

+            }

+            APStationEnabled = APStationEnabled == 1;

+

+            if (!info.isLoggedIn || inShow || (sv_trafficAlertPopuped && sv_trafficAlertPopuped_100) || !info.limitVolumeEnable || (!APStationEnabled && !(info.connectStatus == "ppp_connected")) || notPPP) {

+                return false;

+            }

+

+            if(sv_resetTrafficAlertPopuped){

+                window.setTimeout(function () {

+                    sv_resetTrafficAlertPopuped = false;

+                }, 2000);

+                return false;

+            }

+

+        	if(trafficResult.showConfirm){

+

+                var confirmMessage = null;

+

+                if(trafficResult.usedPercent > 100 && !sv_trafficAlertPopuped_100){

+

+                    sv_trafficAlertPopuped     = true;

+					sv_trafficAlertPopuped_100 = true;

+

+                    confirmMessage = {msg: APStationEnabled ? 'traffic_beyond_msg' : 'traffic_beyond_disconnect_msg'};

+

+                } else if (!sv_trafficAlertPopuped) {

+

+                    sv_trafficAlertPopuped     = true;

+                    sv_trafficAlertPopuped_100 = false;

+                    confirmMessage = {msg: APStationEnabled ? 'traffic_limit_msg' : 'traffic_limit_disconnect_msg',

+                        params: [trafficResult.limitPercent]};

+                }

+

+                if (confirmMessage != null) {

+                    if (APStationEnabled) {

+                        showAlert(confirmMessage);

+                    } else {

+                        showConfirm(confirmMessage, function () {

+                            showLoading("disconnecting");

+                            service.disconnect({}, function (data) {

+                                if (data.result) {

+                                    successOverlay();

+                                } else {

+                                    errorOverlay();

+                                }

+                            });

+                        });

+                    }

+                }

+            }

+            return true;

+        };

+

+        // ����״̬�е�tooltip

+        function updateStatusBarTrans(status){

+    		$("#statusItemSimStatus").attr("tipTitle", "sim_status_" + status.simStatus);

+    		if (status.wifiStatus) {

+				if (status.deviceSize == 0) {

+					$("#wifi_status").attr("tipTitle","wifi_status_on");

+				} else {

+					$("#wifi_status").attr("tipTitle","wifi_status" + status.deviceSize);

+				}

+			} else {

+				$("#wifi_status").attr("tipTitle","wifi_status_off");

+			}

+        }

+

+

+        // ˢ��wifi��������״̬

+        function refreshWifiConnectStatus(fwVm, status, wifiSSID, wifiStatus) {

+            fwVm.connectStatus(status);

+            if (status == "ppp_disconnecting") {

+                fwVm.connectStatusTrans("disconnecting");

+                fwVm.connectStatusText($.i18n.prop("disconnecting"));

+            } else if (status == "ppp_connecting") {

+                fwVm.connectStatusTrans("connecting");

+                fwVm.connectStatusText($.i18n.prop("connecting"));

+            } else if (status == "ppp_connected") {

+                fwVm.connectStatusTrans("connected");

+                fwVm.connectStatusText($.i18n.prop("connected"));

+            } else if(wifiSSID){

+                if(wifiStatus =="dhcping" || wifiStatus =="connecting"){

+                    fwVm.connectStatus("wifi_connecting");

+                    fwVm.connectStatusTrans("connecting");

+                    fwVm.connectStatusText($.i18n.prop("connecting"));

+                }else if(wifiStatus =="connect"){

+                    fwVm.connectStatus("wifi_connect");

+                    fwVm.connectStatusTrans("connected");

+                    fwVm.connectStatusText($.i18n.prop("connected"));

+                }else{

+                    fwVm.connectStatus("ppp_disconnected");

+                    fwVm.connectStatusTrans("disconnected");

+                    fwVm.connectStatusText($.i18n.prop("disconnected"));

+                }

+            }else{

+                fwVm.connectStatusTrans("disconnected");

+                fwVm.connectStatusText($.i18n.prop("disconnected"));

+            }

+        }

+

+        // ��ȡ��ǰ����״̬

+        getNetworkType = function(networkType) {

+			var networkTypeTmp = networkType.toLowerCase();

+			if (networkTypeTmp == '' || networkTypeTmp == 'limited service') {

+				networkTypeTmp = 'limited_service';

+			}

+			if(networkTypeTmp == 'no service') {

+				networkTypeTmp = 'no_service';

+			}

+			if (networkTypeTmp == 'limited_service' || networkTypeTmp == 'no_service') {

+				$("#networkType", "#statusBar").attr("data-trans", "network_type_" + networkTypeTmp);

+				return $.i18n.prop("network_type_" + networkTypeTmp);

+			} else {

+                $("#networkType", "#statusBar").removeAttr("data-trans");

+                return networkType;

+            }

+		};

+

+		if(config.HAS_SMS && menu.checkIsMenuExist("sms_list")){

+            window.setInterval(function () {

+                var info = getCurrentStatusInfo();

+        		if(window.location.hash == "#entry" || sf_simStatusInvalid(info.simStatus)){

+        			return;

+        		}

+        		for(key in sv_messagePopStack){

+        			var val = sv_messagePopStack[key];

+        			if($.now() - val > 5000){

+        				delete(sv_messagePopStack["m" + val]);

+        				var node = $(".bubbleItem#m" + val, "#buttom-bubble");

+        				node.fadeOut(1000, function(){

+        					$(this).remove();

+        				});

+        			}

+        		}

+        		if(info.isLoggedIn){

+        			if(info.newSmsReceived && !sv_newSMSMessageInDealing){

+                        sv_newSMSMessageInDealing = true;

+        				service.resetNewSmsReceivedVar();

+        				sf_checkNewMessages();

+        			}

+        			if(info.smsReportReceived){

+        				service.resetSmsReportReceivedVar();

+        				sf_responseSmsReport();

+        			}

+        		}

+			}, 1000);

+

+            if(config.SMS_DATABASE_SORT_SUPPORT){

+                window.setInterval(function(){

+                    if(menu.checkIsMenuExist("sms_list")){

+                        var info = getCurrentStatusInfo();

+                        if(info.isLoggedIn && sv__initSMSCompleted && !sv_newSMSMessageInDealing && !sf_simStatusInvalid(info.simStatus)){

+                            sv_newSMSMessageInDealing = true;

+                            sf_checkNewMessages();

+                        }

+                    }

+                }, 20001);

+            }

+		}

+

+    	function sf_checkNewMessages(){

+

+            var s_tags     = 1;		

+            var s_smsCount = 5;

+

+            if(!config.dbMsgs || config.dbMsgs.length == 0){

+                s_smsCount = 500;

+                s_tags     = 10;

+            }

+            service.getSMSMessages({

+                page : 0,

+                smsCount : s_smsCount,

+                nMessageStoreType : 0,

+                tags : s_tags,

+                orderBy : "order by id desc"

+            }, function(data){

+                if(data && data.messages){

+                    sf_filterNewMessage(data.messages, 0);

+                }

+                sv_newSMSMessageInDealing = false;

+            });	

+            service.getSMSMessages({

+                page : 0,

+                smsCount : s_smsCount,

+                nMessageStoreType : 1,

+                tags : s_tags,

+                orderBy : "order by id desc"

+            }, function(data){

+                if(data && data.messages){

+                    sf_filterNewMessage(data.messages, 1);

+                }

+                sv_newSMSMessageInDealing = false;

+            });

+    	}

+

+        if(config.HAS_SMS){

+            $(".bubbleItem", "#buttom-bubble").live("mouseover", function(){

+                var $this = $(this);

+                delete(sv_messagePopStack[$this.attr("id")]);

+            }).live("mouseout", function(){

+                    var $this = $(this);

+                    var now = $.now();

+                    sv_messagePopStack["m" + now] = now;

+                    $this.attr("id", "m" + now);

+                    $(".bubbleItem h3 a.bubbleCloseBtn", "#buttom-bubble").data("targetid", "m" + now);

+                });

+

+            $(".bubbleItem h3 a.bubbleCloseBtn", "#buttom-bubble").die().live("click", function(){

+                var id = $(this).data("targetid");

+                delete(sv_messagePopStack[id]);

+                var node = $(".bubbleItem#" + id, "#buttom-bubble");

+                node.fadeOut(1000, function(){

+                    $(this).remove();

+                });

+            });

+        }

+    }

+

+

+    return {

+        init:init,

+        setTrafficAlertPopuped: setTrafficAlertPopuped,

+        setTrafficAlert100Popuped: setTrafficAlert100Popuped,

+        getTrafficResult: getTrafficResult,

+        showOTAAlert:showOTAAlert

+    };

+});

+

+// ����ͳ������ģ��

+define("status_traffic_alert","jquery knockout service statusBar echarts".split(" "), 

+

+    function ($, ko, service, status, echarts) {

+

+    var sv_trafficGraph          = null;

+    var sv_sourceData     = null;

+    var sv_usedDataModified = false;

+    var sv_usedTimeModified = false;	

+

+    var sv_trafficStaticalInfo = {

+        // ����ͼ��ʼֵ

+        data: {

+            alarm: {          

+

+                itemStyle: {

+                    normal: {

+                        color: '#8CC916'

+                    }

+                },

+				name: '������',

+				value: 19.7

+            },

+            alert: {      

+

+                itemStyle: {

+                    normal: {

+                        color: '#FF5500'

+                    }

+                },

+				name: '����ֵ',

+				value: 1

+            },	

+            free: {             

+

+                itemStyle: {

+                    normal: {

+                        color: '#D8D8D8'

+                    }

+                },

+				name: 'δʹ��',

+				value: 50

+            },

+            full: {

+

+

+                itemStyle: {

+                    normal: {

+                        color: '#DF4313'

+                    }

+                },

+				name: '��������',

+				value: 30

+            },			

+            left1: {            

+

+                itemStyle: {

+                    normal: {

+                        color: '#D8D8D8'

+                    }

+                },

+				name: '����ֵ��δʹ��',

+				value: 50,

+            },			

+            start: {

+

+                itemStyle: {

+                    normal: {

+                        color: '#D8D8D8'

+                    }

+                },

+				name: '����ֵ��δʹ��',

+				value: 50

+            },

+            used: {

+

+                itemStyle: {

+                    normal: {

+                        color: '#8CC916'

+                    }

+                },

+				name: '��ʹ��',

+				value: 30

+            }

+        },	

+        cacheEle: {},

+        // Ԫ�ػ�ȡ

+        getEle: function (i_elementId) {

+            if (this.cacheEle.hasOwnProperty('id')) {

+                return this.cacheEle[i_elementId];

+            } else {

+                this.cacheEle[i_elementId] = $("#" + i_elementId);

+                return this.cacheEle[i_elementId];

+            }

+        },

+        // ��ȡ�����澯״ֵ̬

+        fetchTrafficAlertInfo: function(){

+            sv_sourceData = getTrafficAlertInfo();

+            return sv_sourceData;

+        },		

+        // ��ȡ����ֵ�Ͷ�Ӧ��λֵ

+        getTrafficStatisticalDatalnfo: function (i_valueInfo) {

+            return {

+                data: /\d+(.\d+)?/.exec(i_valueInfo)[0],

+                unit: /[A-Z]{1,2}/.exec(i_valueInfo)[0]

+            }

+        },

+

+        // ��ȡʱ��ʱ���֡���

+        getTrafficTimeHours: function (i_time) {

+            var s_timeArray = i_time.split(':');

+            return {

+                h: parseInt(s_timeArray[0], 10),

+                m: parseInt(s_timeArray[1], 10),

+                s: parseInt(s_timeArray[2], 10)

+            }

+        },

+        // ��ȡͳ��ʱ��Ͷ�Ӧ��λֵ

+        getTrafficTimeInfo: function (i_valueInfo) {

+            return {

+                data: /\d+(.\d+)?/.exec(i_valueInfo)[0],

+                unit: /[a-z]{4,6}/.exec(i_valueInfo)[0]

+            }

+        },

+        // ʱ�任���S

+        getTrafficTimeToSeconds: function (i_time) {

+            var s_FormattedTime = this.getTrafficTimeHours(i_time);

+            return s_FormattedTime.h * 3600 + s_FormattedTime.m * 60 + s_FormattedTime.s;

+        },			

+        // ͨ�����ƻ�ȡ������λ

+        getTrafficUnitByScale: function (i_scale) {

+            if (i_scale == '1024') {

+                return 'GB';

+            } else if (i_scale == '1048576') {

+                return 'TB';

+            } else {

+                return 'MB';

+            }

+        },			

+        // ��λ��Ӧֵ��ȡ

+        getTrafficValueByStatisticalUnit: function (i_unit) {

+            i_unit = i_unit.toLowerCase();

+            if(i_unit == 'minute'){

+				return '60';

+			} else if (i_unit == 'gb') {

+                return '1024';

+            } else if(i_unit == 'hour'){

+				return '3600';

+			} else if (i_unit == 'tb') {

+                return '1048576';

+            } else {

+                return '1';

+            }

+        },

+

+        // �������Ƿ�ɱ༭

+        isFormEditable: function (fwVm) {

+            var s_dataPageEditState = fwVm.dataLimitTypeChecked() == '1' && (fwVm.viewEditUsedData() || fwVm.viewEditAlertData() || fwVm.viewEditTotalData());

+            var s_timePageEditState = fwVm.dataLimitTypeChecked() == '0' && (fwVm.viewEditUsedTime() || fwVm.viewEditAlertTime() || fwVm.viewEditTotalTime());

+            if (s_dataPageEditState || s_timePageEditState) {

+                $('.border-color-transition:visible').addClass('attention-focus');

+                addTimeout(function () {

+                    $('.border-color-transition:visible').removeClass('attention-focus');

+                }, 1500);

+                return true;

+            } else {

+                var s_result = false;

+                if (fwVm.dataLimitTypeChecked() == 1) {

+                    if (fwVm.alertDataReach() == '0') {

+                        fwVm.editAlertDataHandler();

+                        s_result = true;

+                    }

+                    if (fwVm.limitDataMonth() == '0') {

+                        fwVm.editTotalDataHandler();

+                        s_result = true;

+                    }

+                } else {

+					if (fwVm.alertTimeReach() == '0') {

+                        fwVm.editAlertTimeHandler();

+                        s_result = true;

+                    }

+                    if (fwVm.limitTimeMonth() == '0') {

+                        fwVm.editTotalTimeHandler();

+                        s_result = true;

+                    }

+                }

+

+                if (s_result) {

+                    $('.border-color-transition:visible').addClass('attention-focus');

+                    addTimeout(function () {

+                        $('.border-color-transition:visible').removeClass('attention-focus');

+                    }, 1500);

+                }

+                return s_result;

+            }

+        },

+

+        // ˢ������ͼ��Ϣ�����������ֵ����ʾ���

+

+        refreshFlowDiagramInfo: function (fwVm) {

+            var s_alarm  = 0;

+            var s_left   = 0;

+            var s_left1  = 0;

+            var s_reach  = 0;	

+            var s_total  = 0;

+            var s_used   = 0;

+

+

+            var s_startName = $.i18n.prop("echarts_no");

+

+            if (sv_sourceData.dataLimitChecked == '1') { //if (fwVm.dataLimitChecked() == '1') { //����

+	        	s_startName = $.i18n.prop("echarts_used");

+	        	sv_trafficGraphOptions.series[0].data = [];    

+

+				if (fwVm.dataLimitTypeChecked() == '1') { // ����

+                    sv_trafficGraphOptions.title.text = "";

+                    sv_trafficGraphOptions.series[0].data = [];

+

+                    if (fwVm.limitDataMonth() == 0) {

+                        var s_usedData = sv_trafficStaticalInfo.data.used;

+                        s_usedData.value = 1;

+                        s_usedData.name = $.i18n.prop("echarts_used");

+                        s_usedData.selected = false;

+                        sv_trafficGraphOptions.series[0].data.push(s_usedData);

+                    } else {

+                        s_total = fwVm.limitDataMonth() * fwVm.selectedDataUnit() * 1048576;

+                        s_used  = parseInt(sv_sourceData.monthlySent, 10) + parseInt(sv_sourceData.monthlyReceived, 10);

+                        s_reach = s_total * fwVm.alertDataReach() / 100;

+

+                        if (s_used >= s_total) {

+                            var s_fullData    = sv_trafficStaticalInfo.data.full;

+                            s_fullData.value  = 100;

+                            s_fullData.name   = $.i18n.prop("echarts_full");

+                            sv_trafficGraphOptions.series[0].data.push(s_fullData);

+                            s_startName = $.i18n.prop("echarts_full");

+                        } else {

+                            if (s_reach > s_used) { 

+                                s_left1 = s_reach - s_used;

+                                s_left  = s_total - s_reach;

+                            } else { 

+                                s_alarm = s_used - s_reach;

+                                s_left  = s_total - s_used;

+                            }

+

+                            var s_usedData = sv_trafficStaticalInfo.data.used;

+                            if (s_reach - s_used > 0) {

+                                s_usedData.value = s_used;

+                            } else {

+                                s_usedData.value = s_reach;

+                            }

+                            s_usedData.name = $.i18n.prop("echarts_used");

+                            sv_trafficGraphOptions.series[0].data.push(s_usedData);

+

+                            if (s_left1 > 0) {

+                                var s_left1Data     = sv_trafficStaticalInfo.data.left1;

+                                s_left1Data.value   = s_left1;

+                                s_left1Data.name    = $.i18n.prop("echarts_left1");

+                                sv_trafficGraphOptions.series[0].data.push(s_left1Data);

+                            }

+

+                            var s_alertData         = sv_trafficStaticalInfo.data.alert;

+                            s_alertData.value       = s_total / 200;

+                            s_alertData.name        = $.i18n.prop("echarts_alert");

+                            sv_trafficGraphOptions.series[0].data.push(s_alertData);

+

+                            if (s_alarm > 0) {

+                                var s_alarmData     = sv_trafficStaticalInfo.data.alarm;

+                                s_alarmData.value   = s_alarm;

+                                s_alarmData.name    = $.i18n.prop("echarts_alarm");

+                                sv_trafficGraphOptions.series[0].data.push(s_alarmData);

+                            }

+

+                            var s_freeData          = sv_trafficStaticalInfo.data.free;

+                            s_freeData.value        = s_left;

+                            s_freeData.name         = $.i18n.prop("echarts_free");

+                            sv_trafficGraphOptions.series[0].data.push(s_freeData);

+                        }

+                    }	

+

+				}else{// ʱ��

+

+                    sv_trafficGraphOptions.series[0].data = [];

+

+                    if (fwVm.limitTimeMonth() == 0) {

+                        var s_usedData        = sv_trafficStaticalInfo.data.used;

+                        s_usedData.value      = 1;

+                        s_usedData.selected   = false;

+                        s_usedData.name       = $.i18n.prop("echarts_used");

+                        sv_trafficGraphOptions.series[0].data.push(s_usedData);

+                    } else {

+                        s_total  = fwVm.limitTimeMonth() * fwVm.selectedTimeUnit();

+                        s_used   = sv_sourceData.monthlyConnectedTime;

+                        s_reach  = s_total * fwVm.alertTimeReach() / 100;

+

+                        if (s_used >= s_total) {

+                            var fullTime   = sv_trafficStaticalInfo.data.full;

+                            fullTime.value = 100;

+                            fullTime.name  = $.i18n.prop("echarts_full");

+                            sv_trafficGraphOptions.series[0].data.push(fullTime);

+                            s_startName    = $.i18n.prop("echarts_full");

+                        } else {

+                            if (s_reach - s_used > 0) {

+                                s_left1 = s_reach - s_used;

+                                s_left  = s_total - s_reach;

+                            } else {

+                                s_alarm = s_used  - s_reach;

+                                s_left  = s_total - s_used;

+                            }

+

+                            var s_usedTime = sv_trafficStaticalInfo.data.used;

+                            if (s_reach - s_used > 0) {

+                                s_usedTime.value = s_used;

+                            } else {

+                                s_usedTime.value = s_reach;

+                            }

+                            s_usedTime.name = $.i18n.prop("echarts_used");

+                            sv_trafficGraphOptions.series[0].data.push(s_usedTime);

+

+                            if (s_left1 > 0) {

+                                var s_left1Time    = sv_trafficStaticalInfo.data.left1;

+                                s_left1Time.value  = s_left1;

+                                s_left1Time.name   = $.i18n.prop("echarts_left1");

+                                sv_trafficGraphOptions.series[0].data.push(s_left1Time);

+                            }

+

+                            var s_alertTime        = sv_trafficStaticalInfo.data.alert;

+                            s_alertTime.value      = s_total / 200;

+                            s_alertTime.name       = $.i18n.prop("echarts_alert");

+                            sv_trafficGraphOptions.series[0].data.push(s_alertTime);

+

+                            if (s_alarm > 0) {

+                                var s_alarmTime      = sv_trafficStaticalInfo.data.alarm;

+                                s_alarmTime.value    = s_alarm;

+                                s_alarmTime.name     = $.i18n.prop("echarts_alarm");

+                                sv_trafficGraphOptions.series[0].data.push(s_alarmTime);

+                            }

+

+                            var s_freeTime         = sv_trafficStaticalInfo.data.free;

+                            s_freeTime.value       = s_left;

+                            s_freeTime.name        = $.i18n.prop("echarts_free");

+                            sv_trafficGraphOptions.series[0].data.push(s_freeTime);

+                        }

+                    }		

+                } 

+            } else {

+                var s_usedData      = sv_trafficStaticalInfo.data.used;

+                s_usedData.value    = 1;

+                s_usedData.selected = false;

+                s_usedData.name     = $.i18n.prop("echarts_no");

+

+                sv_trafficGraphOptions.series[0].data = [s_usedData];

+                sv_trafficGraphOptions.title.text     = '';			

+            }

+            sv_trafficStaticalInfo.setFlowDiagramInfo(sv_trafficGraphOptions, s_startName);

+        },

+

+

+		// �ػ�����ͼ

+        setFlowDiagramInfo: function (i_options, i_startName) {

+            var s_startPart = sv_trafficStaticalInfo.data.start;

+

+            s_startPart.name     = i_startName;			

+            s_startPart.selected = false;

+            s_startPart.value    = 0;

+

+            var s_arr = [s_startPart].concat(i_options.series[0].data);

+            i_options.series[0].data = s_arr;

+            sv_trafficGraph.setOption(i_options, true);

+

+            addTimeout(function () {

+                sv_trafficGraph.resize();

+            }, 1000);

+        }

+    };

+

+

+    // ����ͼ��������

+    var sv_trafficGraphOptions = {

+        animation: false,

+        color: ['red', 'red', 'red', 'red', 'red'],

+        series: [

+            {

+                name: '��������',

+                radius: ['0', '75'],

+                selectedOffset: 3,				

+                type: 'pie',				

+                data: [

+

+                ],			

+                itemStyle: {

+                    normal: {

+                        labelLine: {

+                            show: false

+                        },

+                        label: {

+                            show: false

+                        }

+                    }

+                }				

+            }

+        ],		

+        title: {

+            itemGap: 0,

+			      text: '',

+            subtextStyle: {

+                color: '#FFF',

+                fontFamily: '΢���ź�',

+                fontSize: 16,

+                fontWeight: 'bolder'

+            },				  

+            textStyle: {

+                color: '#FFF',

+                fontFamily: '΢���ź�',

+                fontSize: 20,

+                fontWeight: 'bolder'

+            },

+            x: 'center',

+            y: 'center'			

+        },

+		tooltip: {

+            formatter: "{b}"

+        }      

+    };

+

+

+    // ��ȡ������������

+    function getTrafficAlertInfo() {

+        return service.getTrafficAlertInfo();

+    }

+

+

+

+    // ��������ViewModel

+

+    function trafficViewModel() {

+

+        var target         = this;

+

+        var info                    = sv_trafficStaticalInfo.fetchTrafficAlertInfo();	

+        var dataMonth               = info.limitDataMonth.split("_");

+

+        sv_usedDataModified         = false;

+        sv_usedTimeModified         = false;

+

+        target.alertDataReach               = ko.observable(info.alertDataReach || 0);		

+        target.alertTimeReach               = ko.observable(info.alertTimeReach || 0);

+        target.dataLimitChecked             = ko.observable(info.dataLimitChecked == '0' ? '0' : '1');

+        target.dataLimitTypeChecked         = ko.observable(info.dataLimitTypeChecked == '0' ? '0' : '1');

+        target.limitTimeMonth               = ko.observable(info.limitTimeMonth || 0);	

+

+

+        // ע��˳�� 

+        target.usedDataText                 = ko.observable(transUnit(parseInt(info.monthlySent, 10) + parseInt(info.monthlyReceived, 10), false));

+        var sv_staticalDataInfo             = sv_trafficStaticalInfo.getTrafficStatisticalDatalnfo(target.usedDataText());

+        var sv_staticalInfoData             = sv_staticalDataInfo.data;

+        target.dataUsed                     = ko.observable(sv_staticalInfoData);	

+        var sv_staticalInfoUnit             = sv_staticalDataInfo.unit;

+        target.selectedDataUsedUnit         = ko.observable(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(sv_staticalInfoUnit));

+        target.usedDataTextDescData         = ko.observable("");

+

+        target.limitDataMonth               = ko.observable(dataMonth[0] || 0);		

+        target.selectedDataUnit             = ko.observable(dataMonth[1] || 1);		

+

+        var limitDataMonthTmp               = transUnit(target.limitDataMonth() * target.selectedDataUnit() * 1024 * 1024, false);

+        var limitDataMonthUnitTmp           = limitDataMonthTmp.substring(limitDataMonthTmp.length-2);

+        target.limitDataMonth(limitDataMonthTmp.substring(0, limitDataMonthTmp.length-2));

+        target.selectedDataUnit(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(limitDataMonthUnitTmp));	

+

+        target.usedDataTextDesc             = ko.computed(sf_usedDataTextDesc);	

+        target.limitDataMonthDescData       = ko.observable("");

+        target.limitDataMonthDesc           = ko.computed(sf_limitDataMonthDesc);	

+        target.alertDataReachDescData       = ko.observable("");		

+        target.alertDataReachDesc           = ko.computed(sf_alertDataReachDesc);	

+        target.leftDataDescData             = ko.observable("");

+        target.leftDataDesc                 = ko.computed(sf_leftDataDesc);	

+        target.monthlyConnectedTime         = ko.observable(transSecond2Time(info.monthlyConnectedTime));

+

+		var sv_timeInfo1                    = sv_trafficStaticalInfo.getTrafficTimeInfo(transTimeUnit(info.monthlyConnectedTime));

+        target.usedTime                     = ko.observable(sv_timeInfo1.data);		

+		target.selectedTimeUsedUnit         = ko.observable(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(sv_timeInfo1.unit));	

+

+        target.usedTimeTextDescData         = ko.observable("");

+        target.usedTimeTextDesc             = ko.computed(sf_usedTimeTextDesc);		

+

+		var  sv_timeInfoNew                 = sv_trafficStaticalInfo.getTrafficTimeInfo(transTimeUnit(parseFloat(target.limitTimeMonth()) * 3600));

+		target.selectedTimeUnit             = ko.observable(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(sv_timeInfoNew.unit));

+		target.limitTimeMonth(sv_timeInfoNew.data);

+

+

+        target.limitTimeMonthDescData       = ko.observable("");

+		target.limitTimeMonthDescText       = ko.observable("traffic_limit_time_h");		        

+        target.limitTimeMonthDesc           = ko.computed(sf_limitTimeMonthDesc);

+        target.alertTimeReachDescData       = ko.observable("");       	

+        target.alertTimeReachDesc           = ko.computed(sf_alertTimeReachDesc);

+        target.leftTimeDescData             = ko.observable("");        

+        target.leftTimeDesc                 = ko.computed(sf_leftTimeDesc);

+        target.save                         = sf_save;		

+        target.viewEditUsedData             = ko.observable(false);

+        target.editUsedDataHandler          = sf_editUsedDataHandler;

+        target.editUsedDataSaveHandler      = sf_editUsedDataSaveHandler;		

+        target.saveUsedData                 = sf_saveUsedData;		

+        target.editUsedDataCancelHandler    = sf_editUsedDataCancelHandler;

+        target.viewEditTotalData            = ko.observable(false);

+		target.editTotalDataHandler         = sf_editTotalDataHandler;

+		target.editTotalDataSaveHandler     = sf_editTotalDataSaveHandler;

+        target.editTotalDataCancelHandler   = sf_editTotalDataCancelHandler;

+        target.viewEditAlertData            = ko.observable(false);

+		target.editAlertDataHandler         = sf_editAlertDataHandler;

+		target.editAlertDataSaveHandler     = sf_editAlertDataSaveHandler;

+		target.editAlertDataCancelHandler   = sf_editAlertDataCancelHandler;

+        target.viewEditUsedTime             = ko.observable(false);

+		target.editUsedTimeHandler          = sf_editUsedTimeHandler;	

+		target.saveUsedTime                 = sf_saveUsedTime;

+		target.editUsedTimeSaveHandler      = sf_editUsedTimeSaveHandler;

+		target.editUsedTimeCancelHandler    = sf_editUsedTimeCancelHandler;

+		target.viewEditTotalTime            = ko.observable(false);

+		target.editTotalTimeHandler         = sf_editTotalTimeHandler ;

+        target.editTotalTimeSaveHandler     = sf_editTotalTimeSaveHandler;	

+		target.editTotalTimeCancelHandler   = sf_editTotalTimeCancelHandler;

+		target.viewEditAlertTime            = ko.observable(false);

+        target.editAlertTimeHandler         = sf_editAlertTimeHandler;		

+        target.editAlertTimeSaveHandler     = sf_editAlertTimeSaveHandler;

+        target.editAlertTimeCancelHandler   = sf_editAlertTimeCancelHandler;

+        sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);		

+

+

+        // ��������������

+		function sf_alertDataReachDesc() {

+            if(isNaN(target.limitDataMonth() * target.selectedDataUnit() * target.alertDataReach())) {

+                target.alertDataReachDescData(target.alertDataReach() + ', ');

+                return $.i18n.prop('traffic_alert_reach_text', target.alertDataReach(), ' ');

+            }

+

+            var s_value = transUnit(target.limitDataMonth() * target.selectedDataUnit() * target.alertDataReach() * 1048576 / 100, false);

+            target.alertDataReachDescData(target.alertDataReach() + ',' + s_value);

+            return $.i18n.prop('traffic_alert_reach_text', target.alertDataReach(), s_value);

+        }

+		// ʱ������������

+        function sf_alertTimeReachDesc() {

+            if(isNaN(target.limitTimeMonth() * target.alertTimeReach())) {

+                target.alertTimeReachDescData(target.alertTimeReach() + ', ');

+                return $.i18n.prop('traffic_alert_reach_text', target.alertTimeReach(), ' ');

+            }

+            var s_value = transSecond2Time(target.limitTimeMonth() * target.selectedTimeUnit() * target.alertTimeReach() / 100);

+            target.alertTimeReachDescData(target.alertTimeReach() + ',' + s_value);

+            return $.i18n.prop('traffic_alert_reach_text', target.alertTimeReach(), s_value);

+        }	

+

+

+        // ��������ֵȡ���༭��ť�¼�

+		function sf_editAlertDataCancelHandler() {

+            target.alertDataReach(sv_trafficStaticalInfo.getEle('editAlertData').data('oldValue'));

+            target.viewEditAlertData(false);

+        }		

+

+        // ��������ֵ�༭��ť�¼�

+		function sf_editAlertDataHandler() {

+            sv_trafficStaticalInfo.getEle('editAlertData').data('oldValue', target.alertDataReach());

+            target.viewEditAlertData(true);

+        }

+

+        // ��������ֵ����༭��ť�¼�

+		function sf_editAlertDataSaveHandler() {

+            if (sv_trafficStaticalInfo.getEle('alertDataReach').valid()) {

+                target.viewEditAlertData(false);

+            }

+        }

+

+        // ʱ������ֵȡ���༭��ť�¼�

+		function sf_editAlertTimeCancelHandler() {

+            target.alertTimeReach(sv_trafficStaticalInfo.getEle('editAlertTime').data('oldValue'));

+            target.viewEditAlertTime(false);

+        }	 

+        // ʱ������ֵ�༭��ť�¼�

+		function sf_editAlertTimeHandler() {

+            sv_trafficStaticalInfo.getEle('editAlertTime').data('oldValue', target.alertTimeReach());

+            target.viewEditAlertTime(true);

+        } 		

+        // ʱ������ֵ����༭��ť�¼�

+		function sf_editAlertTimeSaveHandler() {

+            if (sv_trafficStaticalInfo.getEle('alertTimeReach').valid()) {

+                target.viewEditAlertTime(false);

+            }

+        }		

+

+        // �ײ������༭��ť�¼�

+		function sf_editTotalDataHandler() {

+            sv_trafficStaticalInfo.getEle('editTotalData').data('oldValue', target.limitDataMonth());

+            sv_trafficStaticalInfo.getEle('selectedDataUnit').data('oldValue', target.selectedDataUnit());

+            target.viewEditTotalData(true);

+        }

+

+        // �ײ���������༭��ť�¼�

+		function sf_editTotalDataSaveHandler() {

+            if (sv_trafficStaticalInfo.getEle('limitDataMonth').valid()) {

+                target.usedDataText(transUnit(target.limitDataMonth() * target.selectedDataUnit() * 1048576, false));

+                target.viewEditTotalData(false);

+            }

+        }

+

+        // �ײ�����ȡ���༭��ť�¼�

+		function sf_editTotalDataCancelHandler() {

+            target.limitDataMonth(sv_trafficStaticalInfo.getEle('editTotalData').data('oldValue'));

+            target.selectedDataUnit(sv_trafficStaticalInfo.getEle('selectedDataUnit').data('oldValue'));

+            target.viewEditTotalData(false);

+        }

+        // �ײ�ʱ��ȡ���༭��ť�¼�

+		function sf_editTotalTimeCancelHandler() {

+            target.limitTimeMonth(sv_trafficStaticalInfo.getEle('editTotalTime').data('oldValue'));

+            target.viewEditTotalTime(false);

+        }       

+        // �ײ�ʱ��༭��ť�¼�

+		function sf_editTotalTimeHandler() {

+            sv_trafficStaticalInfo.getEle('editTotalTime').data('oldValue', target.limitTimeMonth());

+            target.viewEditTotalTime(true);

+        }       

+        // �ײ�ʱ�䱣��༭��ť�¼�

+		function sf_editTotalTimeSaveHandler() {

+            if (sv_trafficStaticalInfo.getEle('limitTimeMonth').valid()) {

+                target.viewEditTotalTime(false);

+            }

+        }		

+

+        // ��������ȡ���༭��ť�¼�

+		function sf_editUsedDataCancelHandler() {

+            target.dataUsed(sv_trafficStaticalInfo.getEle('editUsedData').data('oldValue'));

+            target.selectedDataUsedUnit(sv_trafficStaticalInfo.getEle('selectedDataUsedUnit').data('oldValue'));

+            sv_trafficStaticalInfo.getEle('editUsedDataCancel').siblings('label.error').hide();

+            target.viewEditUsedData(false);

+        }	

+        // ���������༭��ť�¼�

+		function sf_editUsedDataHandler() {

+            sv_trafficStaticalInfo.getEle('editUsedData').data('oldValue', target.dataUsed());

+            sv_trafficStaticalInfo.getEle('selectedDataUsedUnit').data('oldValue', target.selectedDataUsedUnit());

+            target.dataUsed(target.dataUsed());

+            target.viewEditUsedData(true);

+        }	

+        // �����������水ť�¼�

+		function sf_editUsedDataSaveHandler() {

+            if (sv_trafficStaticalInfo.getEle('dataUsed').valid()) {

+                sv_usedDataModified = true;

+                target.viewEditUsedData(false);

+            }

+        }		

+        // ����ʱ��ȡ���༭��ť�¼�

+		function sf_editUsedTimeCancelHandler() {

+            target.usedTime(sv_trafficStaticalInfo.getEle('editUsedTime').data('oldValue'));

+            target.viewEditUsedTime(false);

+        }		

+        // ����ʱ��༭��ť�¼�

+		function sf_editUsedTimeHandler() {

+            sv_trafficStaticalInfo.getEle('editUsedTime').data('oldValue', target.usedTime());

+            target.viewEditUsedTime(true);

+        }

+

+        // ����ʱ�䱣��༭��ť�¼�

+		function sf_editUsedTimeSaveHandler() {

+            if (sv_trafficStaticalInfo.getEle('usedTime').valid()) {

+                target.monthlyConnectedTime(transSecond2Time(parseFloat(target.usedTime()) * target.selectedTimeUsedUnit()));

+                target.viewEditUsedTime(false);

+                sv_usedTimeModified = true;

+            }

+        }

+

+		// ʣ������������	

+        function sf_leftDataDesc() {

+            var s_left = (target.limitDataMonth() * target.selectedDataUnit() - target.dataUsed() * target.selectedDataUsedUnit()) * 1048576;

+            if(s_left < 0) {

+                s_left = 0;

+            }

+

+            if(isNaN(s_left)) {

+                target.leftDataDescData('');

+                return $.i18n.prop('traffic_data_left_text', ' ');

+            }

+

+            target.leftDataDescData(transUnit(s_left, false));

+            return $.i18n.prop('traffic_data_left_text', transUnit(s_left, false));

+        }	

+		//ʣ��ʱ��������

+		function sf_leftTimeDesc() {

+            var s_surplus = target.limitTimeMonth() * target.selectedTimeUnit() - sv_trafficStaticalInfo.getTrafficTimeToSeconds(target.monthlyConnectedTime());

+            if(s_surplus < 0) {

+                s_surplus = 0;

+            }

+

+            if(isNaN(s_surplus)) {

+                target.leftTimeDescData(' ');

+                return $.i18n.prop('traffic_data_left_text', ' ');

+            }

+            target.leftTimeDescData(transSecond2Time(s_surplus));

+            return $.i18n.prop('traffic_data_left_text', transSecond2Time(s_surplus));

+        }

+		// �ײ�����������

+		function sf_limitDataMonthDesc() {

+            if(isNaN(target.limitDataMonth())) {

+                target.limitDataMonthDescData("");

+                return $.i18n.prop('traffic_limit_data_text', ' ');

+            }else{

+			    // todo

+			}

+

+            target.limitDataMonthDescData(target.limitDataMonth() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUnit()));

+            return $.i18n.prop('traffic_limit_data_text', target.limitDataMonth() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUnit()));

+        }	

+		// �ײ�ʱ��������	

+		function sf_limitTimeMonthDesc() {

+            if(isNaN(target.limitTimeMonth())) {

+                target.limitTimeMonthDescData(' ');

+				target.limitTimeMonthDescText('traffic_limit_time_h');

+                return $.i18n.prop('traffic_limit_time_h', ' ');

+            }else{

+			    // todo:

+			}

+

+            target.limitTimeMonthDescData(target.limitTimeMonth());

+

+			if(target.selectedTimeUnit() == "60"){

+				target.limitTimeMonthDescText('traffic_limit_time_m');

+				return $.i18n.prop('traffic_limit_time_m', target.limitTimeMonth());

+			}else{

+				target.limitTimeMonthDescText('traffic_limit_time_h');

+				return $.i18n.prop('traffic_limit_time_h', target.limitTimeMonth());

+			}		

+        }

+

+        // Ӧ�ð�ť�¼�

+        function sf_save() {

+            if (sv_trafficStaticalInfo.isFormEditable(target) && target.dataLimitChecked() == '1') {

+                return false;

+            }

+

+            if (target.selectedDataUnit() == '1' && target.selectedDataUsedUnit() == '1048576' && target.dataLimitTypeChecked() == "1" && target.dataLimitChecked() == '1' && !(parseInt(target.dataUsed(), 10) < parseInt('4096', 10)) ) {

+                showAlert('traffic_over_note');

+				return false;

+            }

+

+            showLoading();

+            service.setTrafficAlertInfo({

+			    alertDataReach: parseInt(target.alertDataReach(), 10),

+				alertTimeReach: parseInt(target.alertTimeReach(), 10),

+                dataLimitChecked: target.dataLimitChecked(),

+                dataLimitTypeChecked: target.dataLimitTypeChecked(),

+                limitDataMonth: target.limitDataMonth() + "_" + target.selectedDataUnit(),             

+                limitTimeMonth: target.selectedTimeUnit() == "60" ? target.limitTimeMonth()/60 : target.limitTimeMonth()//save by hours               

+            }, function (data) {

+                if (data.result == 'success') {

+                    if(target.dataLimitTypeChecked() == "1" && sv_usedDataModified) {

+                        target.saveUsedData();

+                    } else if(target.dataLimitTypeChecked() == "0" && sv_usedTimeModified) {

+                        target.saveUsedTime();

+                    } else {

+                        sv_trafficStaticalInfo.fetchTrafficAlertInfo();

+                        sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);

+                        status.setTrafficAlertPopuped(false);

+                        successOverlay();

+                    }

+                } else {

+                    errorOverlay();

+                }

+            }, function () {

+                sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);

+                errorOverlay();

+            });

+        }		

+

+        // ����������������	

+		function sf_saveUsedData() {

+            var val = target.dataUsed() * target.selectedDataUsedUnit();

+            service.trafficCalibration({

+                way: 'data',

+                value: val

+            }, function(){

+                sv_trafficStaticalInfo.fetchTrafficAlertInfo();

+                sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);

+                successOverlay();

+                target.viewEditUsedData(false);

+                status.setTrafficAlertPopuped(false);

+                sv_usedDataModified = false;

+            }, function(){

+                sv_trafficStaticalInfo.fetchTrafficAlertInfo();

+                sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);

+                errorOverlay();

+            });

+        }	

+

+

+

+		function sf_saveUsedTime() {

+            service.trafficCalibration({

+                way: 'time',

+                value: target.selectedTimeUsedUnit() == "60" ? parseFloat(target.usedTime())/60 : target.usedTime()

+            }, function(){

+                sv_trafficStaticalInfo.fetchTrafficAlertInfo();

+                sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);

+                successOverlay();

+                target.monthlyConnectedTime(transSecond2Time(parseFloat(target.usedTime()) * target.selectedTimeUsedUnit()));

+                target.viewEditUsedTime(false);

+                status.setTrafficAlertPopuped(false);

+                sv_usedTimeModified = false;

+            }, function(){

+                sv_trafficStaticalInfo.fetchTrafficAlertInfo();

+                sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);

+                errorOverlay();

+            });

+        }	

+

+

+        // ��������������	

+		function sf_usedDataTextDesc() {

+            if(isNaN(target.dataUsed())) {

+                target.usedDataTextDescData("");

+                return $.i18n.prop('traffic_used_text', ' ');

+            }

+            target.usedDataTextDescData(target.dataUsed() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUsedUnit()));

+            return $.i18n.prop('traffic_used_text', target.dataUsed() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUsedUnit()));

+        }		

+        // ����ʱ��������

+        function sf_usedTimeTextDesc() {

+            target.usedTimeTextDescData(target.monthlyConnectedTime());

+            return $.i18n.prop('traffic_used_text', target.monthlyConnectedTime());

+        }			

+

+

+    }

+

+    function init() {

+        sv_trafficGraph = echarts.init($("#traffic_graphic")[0]);

+        window.onresize = sv_trafficGraph.resize;

+        var s_container = $('#container');

+        ko.cleanNode(s_container[0]);

+        var fwVm = new trafficViewModel();

+        ko.applyBindings(fwVm, s_container[0]);

+        $('#trafficAlertForm').validate({

+            submitHandler: function () {

+                fwVm.save();

+            },

+

+

+            errorPlacement: function (error, para) {

+                if (para.attr("name") == "alertDataReach") {

+                    error.insertAfter("#editAlertDataDiv");

+                } else if (para.attr("name") == "alertTimeReach") {

+                    error.insertAfter("#editAlertTimeDiv");

+                } else if (para.attr("name") == "dataUsed") {

+                    error.insertAfter("#editUsedDataDiv");

+                } else if (para.attr("name") == "limitDataMonth") {

+                    error.insertAfter("#editTotalDataDiv");

+                } else if (para.attr("name") == "limitTimeMonth") {

+                    error.insertAfter("#editTotalTimeDiv");

+                } else if (para.attr("name") == "usedTime") {

+                    error.insertAfter("#editUsedTimeDiv");

+                } else {

+                    error.insertAfter(para);

+                }

+            },

+

+            rules: {

+			    alertDataReach: {

+                    range: [ 1, 100 ],

+					digits: true

+                },

+                alertTimeReach: {

+                    range: [ 1, 100 ],

+                    digits: true

+                },

+                dataUsed: {

+					range : [ 0, 9999 ],

+					decimalRange : true

+                },

+                limitDataMonth: {

+					range : [ 1, 9999 ],

+					decimalRange : true

+                },

+                limitTimeMonth: {

+					range : [ 1, 9999 ],

+					decimalRange : true

+                },

+				usedTime: {

+					range : [ 0, 9999 ],

+					decimalRange : true

+                }  

+            }			

+

+        });

+

+		var sv_originalLan = window.language;

+		window.setInterval(function(){			

+			if(sv_originalLan != window.language){

+				sv_originalLan = window.language;

+				sv_trafficStaticalInfo.refreshFlowDiagramInfo(fwVm);

+			}

+        }, 1000);

+

+    }

+

+    return {

+        init: init

+    };

+});

+

+// ״̬����ʾ��ʵ��

+define("tooltip",[ "jquery" ], 

+

+	function($) {	

+

+

+			// ����Ԫ��λ����Ϣ

+			// @method calculatePositionInfo

+			// @param trigger Ԫ��

+			// @param tooltip ״̬��

+			// @param {JSON} config �����

+

+			function calculatePositionInfo(trigger, tooltip, config) {

+				var top      = trigger.offset().top; 

+				var left     = trigger.offset().left; 

+				var position = config.position[0];

+				var height   = tooltip.outerHeight() + trigger.outerHeight();

+				var width    = tooltip.outerWidth() + trigger.outerWidth();

+

+				top         -= tooltip.outerHeight() - config.offset[0];

+				left        += trigger.outerWidth()  + config.offset[1];

+

+				if (/iPad/i.test(navigator.userAgent)) {

+					top -= $(window).scrollTop();

+				}

+

+				if (position == 'center') {

+					top += height / 2;

+				}

+				if (position == 'bottom') {

+					top += height;

+				}

+				position = config.position[1];

+				if (position == 'center') {

+					left -= width / 2;

+				}else if (position == 'left') {

+					left -= width;

+				}

+

+				return {

+					top : top,

+					left : left

+				};

+			}	

+

+			// ״̬����ʼ��

+			function init() {

+

+				$(".statusItem", "#statusBar").each(function(i, n){

+					var $this = $(this);

+					$this.attr("tipTitle", $this.attr("title")).removeAttr("title");

+				}).hover(

+						function() {

+							var $this = $(this);

+							var title = $this.attr("tipTitle");

+							var tooltip = $("<div>").addClass("tooltip in").appendTo(document.body).hide()

+									.append($this.attr("i18n") ? $.i18n.prop(title) : title);

+							if ($this.attr("i18n")) {

+								tooltip.attr("data-trans", title).attr("id", "tooltip_" + $this.attr("id"));

+							}

+							var pos = calculatePositionInfo($this, tooltip, {

+								position : [ 'bottom', 'center' ],

+								offset : [ 0, 0 ]

+							});

+							tooltip.css({

+								position : 'absolute',

+								top : pos.top,

+								left : pos.left

+							}).show();

+						}, function() {

+							$(".tooltip").hide().remove();

+						});

+			}

+

+			return {

+				init : init

+			};

+		});

+

+define("menu","set service knockout underscore jquery".split(" "),

+    function (set, fnc, libko, libus, libjq) {

+    var displayMenuWhenLogout = false;

+    var vmMenu;

+    var menu = [];

+    var menuResource = "";

+

+    function menuExistCheck(path) {

+        for (var i = 0; i < menu.length; i++) {

+            if (menu[i].path == path) {

+                return true;

+            }

+        }

+        return false;

+    }

+

+    function getIsLoggedin() {

+        var loginStatus = fnc.getLoginStatus();

+        return (loginStatus.status == "loggedIn");

+    }

+

+    function buildNew() {

+        var loggedIn = getIsLoggedin();

+        var menuMain = libus.filter(menu, function (param) {

+            return (param.level == '1' && ((param.requireLogin && loggedIn) || !param.requireLogin) && param.hash != "#entry");

+        });

+        vmMenu.menuMain(menuMain);

+        vmMenu.loggedIn(loggedIn);

+

+        getMainWth(vmMenu.menuMain().length);

+        vmMenu.showMenu(loggedIn || displayMenuWhenLogout);

+        libjq("#nav").translate();

+    }

+

+    function getMainWth(len) {

+        var width = 100 / len;

+        libjq('ul#list-nav li').each(function () {

+            libjq(this).css('width', width + '%');

+        });

+    }

+

+    function menuRefresh() {

+        var currentHash = window.location.hash;

+        var itmRoot = libus.find(menu, function (param) {

+            return param.hash == currentHash;

+        });

+        while (itmRoot.parent) {

+            itmRoot = libus.find(menu, function (param) {

+                return param.hash == itmRoot.parent;

+            });

+        }

+        if (!itmRoot.parent) {

+            libjq("#list-nav li").removeClass("active");

+            var mid = itmRoot.hash.substring(1, itmRoot.hash.length);

+            libjq("#list-nav li[mid=" + mid + "]").addClass("active");

+        }

+        vmMenu.changeMenu(itmRoot);

+    }

+

+    function menuSearch(hashVal) {

+        hashVal = hashVal || window.location.hash;

+        var loggedIn = getIsLoggedin();

+        return libus.filter(menu, function (param) {

+            return (hashVal == param.hash && ((param.requireLogin && loggedIn) || !param.requireLogin));

+        });

+    }

+

+    function menuRenderSub(level, baseItem) {

+        var levelItem = libus.find(menu, function (param) {

+            return param.parent == baseItem.hash && param.path == baseItem.path;

+        });

+        libjq(".menu-" + level + "-level").removeClass("active");

+        if (levelItem) {

+            if (level == "two") {

+                menuRenderSub("three", levelItem);

+                //forward/backward support

+                clickMenuTrig(levelItem.hash, level);

+            }

+            libjq(".menu-" + level + "-level." + levelItem.hash.substring(1)).addClass("active");

+        }

+    }

+

+    function menuActSub() {

+        var currentHash = window.location.hash;

+        var itmRoot = libus.find(menu, function (param) {

+            return param.hash == currentHash;

+        });

+        if (itmRoot.level == 1) {

+            menuRenderSub("two", itmRoot);

+        }

+        if (itmRoot.level == 2) {

+            menuRenderSub("three", itmRoot);

+            //forward/backward support

+            clickMenuTrig(itmRoot.hash, itmRoot.level);

+        }

+        if (itmRoot.level == 3) {

+            //forward/backward support

+            clickMenuTrig(itmRoot.parent, itmRoot.level);

+            libjq(".menu-three-level").removeClass("active");

+            libjq(".menu-three-level." + itmRoot.hash.substring(1)).addClass("active");

+        }

+    }

+

+    function clickMenuTrig(hash, level) {

+        libjqobj = libjq(".menu-two-level." + hash.substring(1));

+        var levelArr = ['3', 'three', '2', 'two'];

+        if (libus.indexOf(levelArr, level) != -1 && libjqobj.hasClass('active')) {

+            return;

+        }

+

+        libjqobj.siblings().removeClass('active');

+        libjqobj.addClass('active');

+

+        libjqobj.siblings().not('.menu-two-level').slideUp();

+        libjqobj.next().has('ul li').slideDown();

+    }

+

+    set.blc_wan_mode = fnc.getOpMode().blc_wan_mode;

+    if (!set.RJ45_SUPPORT) {

+        menuResource = "menu";

+    } else {

+        switch (set.blc_wan_mode) {

+        case "PPPOE":

+        case "AUTO_PPPOE":

+            menuResource = "menu_pppoe";

+            break;

+        default:

+            menuResource = "menu";

+            break;

+        }

+    }

+

+    require([set.DEVICE + '/' + menuResource], function (otherMenu) {

+        menu = otherMenu;

+        if (set.SD_CARD_SUPPORT) {

+            menu = menu.concat([{ hash: '#httpshare_guest', path: 'sd_httpshare', level: '', requireLogin: false, checkSIMStatus: false}, 

+						{ hash: '#sdcard', path: 'sd', level: '', requireLogin: true, checkSIMStatus: false}, 

+						{ hash: '#httpshare', path: 'sd_httpshare', level: '', requireLogin: true, checkSIMStatus: false}]);

+        }

+    });

+

+    function initialize() {

+        vmMenu = new Menu_vm();

+    }

+

+    function Menu_vm() {

+        var loginState = getIsLoggedin();

+		var target = this;

+        target.loggedIn = libko.observable(loginState);

+

+        target.showMenu = libko.observable(loginState || displayMenuWhenLogout);

+

+        var menuMain = libus.filter(menu, function (param) {

+            return (param.level == '1' && ((param.requireLogin && target.loggedIn()) || !param.requireLogin) && param.hash != "#entry");

+        });

+

+        target.menuMain = libko.observableArray(menuMain);

+        target.secondMenu = libko.observableArray([]);

+        //target.curThirdMenu; cov_2

+        target.changeMenu = function (data) {

+            var secondMenu = getSubMenu(data);

+            if (secondMenu.length == 0) {

+                libjq("#container").addClass("fixContainerWidth");

+            } else {

+                libjq("#container").removeClass("fixContainerWidth");

+            }

+

+            target.secondMenu(secondMenu);

+            return true;

+        };

+        target.thirdMenu = function () {

+            return target.curThirdMenu;

+        };

+        target.getThirdMenu = function (data) {

+            target.curThirdMenu = getSubMenu(data);

+        };

+        function getSubMenu(data) {

+            return libus.filter(menu, function (param) {

+                return ((param.parent && param.parent == data.hash) && ((param.requireLogin && target.loggedIn()) || !param.requireLogin));

+            });

+        }

+    }

+

+    return {

+        activeSubMenu: menuActSub,

+        checkIsMenuExist: menuExistCheck,

+        findMenu: menuSearch,

+        rebuild: buildNew,

+        refreshMenu: menuRefresh,

+		init: initialize

+    };

+});

diff --git a/lynq/S300/ap/app/zte_webui/js/ext/menu.js b/lynq/S300/ap/app/zte_webui/js/ext/menu.js
new file mode 100755
index 0000000..4eeb17f
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/js/ext/menu.js
@@ -0,0 +1,315 @@
+define(function () {

+    var needLogin = true;

+    var menu = [{

+            hash: '#tr069',

+            path: 'tr069',

+            level: '3',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#more',

+            path: 'adm_others',

+            level: '3',

+            parent: '#local_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#filter_url',

+            path: 'firewall_url_filter',

+            level: '3',

+            parent: '#filter_main',

+            requireLogin: needLogin

+        }, {

+            hash: '#demilitarized_zone',

+            path: 'firewall_dmz_set',

+            level: '3',

+            parent: '#filter_main',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#universal_plug_and_play',

+            path: 'firewall_upnp_set',

+            level: '3',

+            parent: '#filter_main',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#map_port',

+            path: 'firewall_port_map',

+            level: '3',

+            parent: '#filter_main',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#foward_port',

+            path: 'firewall_port_forward',

+            level: '3',

+            parent: '#filter_main',

+            requireLogin: needLogin

+        }, {

+            hash: '#filter_port',

+            path: 'firewall_port_filter',

+            level: '3',

+            parent: '#filter_main',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#wlan_sleep',

+            path: 'wifi_sleep_mode',

+            level: '3',

+            parent: '#local_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#pin_mode',

+            path: 'adm_pin',

+            level: '3',

+            parent: '#local_set',

+            requireLogin: needLogin,

+            checkSIMStatus: true

+        }, {

+            hash: '#pwd_mode',

+            path: 'adm_management',

+            level: '3',

+            parent: '#local_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#filter_mac',

+            path: 'wifi_mac_filter',

+            level: '3',

+            parent: '#wlan_basic',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#wlan_wps',

+            path: 'wifi_wps',

+            level: '3',

+            parent: '#wlan_basic',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#wlan_adv',

+            path: 'wifi_advance',

+            level: '3',

+            parent: '#wlan_basic',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#conn_device',

+            path: 'wifi_station_info',

+            level: '3',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#wlan_guset',

+            path: 'wifi_guest',

+            level: '3',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#wlan_main',

+            path: 'wifi_main',

+            level: '3',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#fota',

+            path: 'ota_update',

+            level: '3',

+            parent: '#local_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#dynamic_dns',

+            path: 'ddns',

+            level: '3',

+            parent: '#local_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#cgdcont_set',

+            path: 'network_apn_set',

+            level: '3',

+            parent: '#network_set',

+            requireLogin: needLogin,

+            checkSIMStatus: true

+        }, {

+            hash: '#network_choose',

+            path: 'network_net_select',

+            level: '3',

+            parent: '#network_set',

+            requireLogin: needLogin,

+            checkSIMStatus: true

+        }, {

+            hash: '#conn_set',

+            path: 'network_dial_set',

+            level: '3',

+            parent: '#network_set',

+            requireLogin: needLogin,

+            checkSIMStatus: true

+        },

+        {

+            hash: '#wlan_station',

+            path: 'wifi_ap_station',

+            level: '2',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#msg_set',

+            path: 'sms_set',

+            level: '2',

+            parent: '#msg_main',

+            requireLogin: needLogin,

+            checkSIMStatus: true

+        }, {

+            hash: '#msg_sim',

+            path: 'sms_sim_messages',

+            level: '2',

+            parent: '#msg_main',

+            requireLogin: needLogin,

+            checkSIMStatus: true

+        }, {

+            hash: '#msg_list',

+            path: 'sms_list',

+            level: '2',

+            parent: '#msg_main',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#flow_ctl',

+            path: 'status_traffic_alert',

+            level: '1',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#pb_work_grp',

+            path: 'phonebook',

+            level: '2',

+            parent: '#pb_main',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#pb_friend_grp',

+            path: 'phonebook',

+            level: '2',

+            parent: '#pb_main',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#pb_family_grp',

+            path: 'phonebook',

+            level: '2',

+            parent: '#pb_main',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#pb_com_grp',

+            path: 'phonebook',

+            level: '2',

+            parent: '#pb_main',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#pb_all_grp',

+            path: 'phonebook',

+            level: '2',

+            parent: '#pb_main',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#usat',

+            path: 'ussd',

+            level: '2',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#route_set',

+            path: 'adm_lan',

+            level: '2',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#filter_main',

+            path: 'firewall',

+            level: '2',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#local_set',

+            path: 'adm_management',

+            level: '2',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#wlan_basic',

+            path: 'wifi_basic',

+            level: '2',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#network_set',

+            path: 'network_dial_set_cpe',

+            level: '2',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#fast_set',

+            path: 'adm_quick_set',

+            level: '2',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: true

+        },

+        {

+            hash: '#child_ctl',

+            path: 'firewall_parental_control',

+            level: '1',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#normal_set',

+            path: 'adm_quick_set',

+            level: '1',

+            requireLogin: needLogin,

+            checkSIMStatus: true

+        }, {

+            hash: '#pb_main',

+            path: 'phonebook',

+            level: '1',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#msg_main',

+            path: 'sms_list',

+            level: '1',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#main',

+            path: 'main',

+            level: '1',

+            requireLogin: needLogin,

+            checkSIMStatus: true

+        }, {

+            hash: '#entry',

+            path: 'entry',

+            level: '1',

+            requireLogin: false,

+            checkSIMStatus: false

+        },

+    ];

+

+    return menu;

+});

diff --git a/lynq/S300/ap/app/zte_webui/js/ext/menu_pppoe.js b/lynq/S300/ap/app/zte_webui/js/ext/menu_pppoe.js
new file mode 100755
index 0000000..b50f29a
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/js/ext/menu_pppoe.js
@@ -0,0 +1,315 @@
+define(function () {

+    var needLogin = true;

+    var menu = [{

+            hash: '#tr069',

+            path: 'tr069',

+            level: '3',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#more',

+            path: 'adm_others',

+            level: '3',

+            parent: '#local_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#filter_url',

+            path: 'firewall_url_filter',

+            level: '3',

+            parent: '#filter_main',

+            requireLogin: needLogin

+        }, {

+            hash: '#demilitarized_zone',

+            path: 'firewall_dmz_set',

+            level: '3',

+            parent: '#filter_main',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#universal_plug_and_play',

+            path: 'firewall_upnp_set',

+            level: '3',

+            parent: '#filter_main',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#map_port',

+            path: 'firewall_port_map',

+            level: '3',

+            parent: '#filter_main',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#foward_port',

+            path: 'firewall_port_forward',

+            level: '3',

+            parent: '#filter_main',

+            requireLogin: needLogin

+        }, {

+            hash: '#filter_port',

+            path: 'firewall_port_filter',

+            level: '3',

+            parent: '#filter_main',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#wlan_sleep',

+            path: 'wifi_sleep_mode',

+            level: '3',

+            parent: '#local_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#pin_mode',

+            path: 'adm_pin',

+            level: '3',

+            parent: '#local_set',

+            requireLogin: needLogin,

+            checkSIMStatus: true

+        }, {

+            hash: '#pwd_mode',

+            path: 'adm_management',

+            level: '3',

+            parent: '#local_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#filter_mac',

+            path: 'wifi_mac_filter',

+            level: '3',

+            parent: '#wlan_basic',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#wlan_wps',

+            path: 'wifi_wps',

+            level: '3',

+            parent: '#wlan_basic',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#wlan_adv',

+            path: 'wifi_advance',

+            level: '3',

+            parent: '#wlan_basic',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#conn_device',

+            path: 'wifi_station_info',

+            level: '3',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#wlan_guset',

+            path: 'wifi_guest',

+            level: '3',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#wlan_main',

+            path: 'wifi_main',

+            level: '3',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#fota',

+            path: 'ota_update',

+            level: '3',

+            parent: '#local_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#dynamic_dns',

+            path: 'ddns',

+            level: '3',

+            parent: '#local_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#cgdcont_set',

+            path: 'network_apn_set',

+            level: '3',

+            parent: '#network_set',

+            requireLogin: needLogin,

+            checkSIMStatus: true

+        }, {

+            hash: '#network_choose',

+            path: 'network_net_select',

+            level: '3',

+            parent: '#network_set',

+            requireLogin: needLogin,

+            checkSIMStatus: true

+        }, {

+            hash: '#conn_set',

+            path: 'network_dial_set',

+            level: '3',

+            parent: '#network_set',

+            requireLogin: needLogin,

+            checkSIMStatus: true

+        },

+        {

+            hash: '#wlan_station',

+            path: 'wifi_ap_station',

+            level: '2',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#msg_set',

+            path: 'sms_set',

+            level: '2',

+            parent: '#msg_main',

+            requireLogin: needLogin,

+            checkSIMStatus: true

+        }, {

+            hash: '#msg_sim',

+            path: 'sms_sim_messages',

+            level: '2',

+            parent: '#msg_main',

+            requireLogin: needLogin,

+            checkSIMStatus: true

+        }, {

+            hash: '#msg_list',

+            path: 'sms_list',

+            level: '2',

+            parent: '#msg_main',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#flow_ctl',

+            path: 'status_traffic_alert',

+            level: '1',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#pb_work_grp',

+            path: 'phonebook',

+            level: '2',

+            parent: '#pb_main',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#pb_friend_grp',

+            path: 'phonebook',

+            level: '2',

+            parent: '#pb_main',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#pb_family_grp',

+            path: 'phonebook',

+            level: '2',

+            parent: '#pb_main',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#pb_com_grp',

+            path: 'phonebook',

+            level: '2',

+            parent: '#pb_main',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#pb_all_grp',

+            path: 'phonebook',

+            level: '2',

+            parent: '#pb_main',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#usat',

+            path: 'ussd',

+            level: '2',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#route_set',

+            path: 'adm_lan',

+            level: '2',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#filter_main',

+            path: 'firewall',

+            level: '2',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#local_set',

+            path: 'adm_management',

+            level: '2',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#wlan_basic',

+            path: 'wifi_basic',

+            level: '2',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#network_set',

+            path: 'network_dial_set_cpe',

+            level: '2',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#fast_set',

+            path: 'adm_quick_set',

+            level: '2',

+            parent: '#normal_set',

+            requireLogin: needLogin,

+            checkSIMStatus: true

+        },

+        {

+            hash: '#child_ctl',

+            path: 'firewall_parental_control',

+            level: '1',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#normal_set',

+            path: 'adm_quick_set',

+            level: '1',

+            requireLogin: needLogin,

+            checkSIMStatus: true

+        }, {

+            hash: '#pb_main',

+            path: 'phonebook',

+            level: '1',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#msg_main',

+            path: 'sms_list',

+            level: '1',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#main',

+            path: 'main',

+            level: '1',

+            requireLogin: needLogin,

+            checkSIMStatus: false

+        }, {

+            hash: '#entry',

+            path: 'entry',

+            level: '1',

+            requireLogin: false,

+            checkSIMStatus: false

+        },

+    ];

+

+    return menu;

+});

diff --git a/lynq/S300/ap/app/zte_webui/js/ext/set_realtek.js b/lynq/S300/ap/app/zte_webui/js/ext/set_realtek.js
new file mode 100755
index 0000000..2313bab
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/js/ext/set_realtek.js
@@ -0,0 +1,87 @@
+define(function () {

+    var config = {

+        WEBUI_TITLE: '4G CPE',

+        PRODUCT_TYPE: 'CPE', // ��Ʒ����UFI��CPE

+        HAS_BLACK_AND_WHITE_FILTER: true, //�Ƿ�֧�ֺڰ�����

+        AP_STATION_SUPPORT: false,

+        MAX_STATION_NUMBER: 8,

+        STATION_BLOCK_SUPPORT: true, // �������豸�Ƿ�֧��Block����

+        HAS_MULTI_SSID: false, //��ssid����

+        WIFI_BANDWIDTH_SUPPORT_40MHZ: true, //Ƶ�������Ƿ�֧��40MHZ,reltekоƬ֧��

+        WIFI_BANDWIDTH_SUPPORT: true,

+        WIFI_BAND_SUPPORT: true,

+        SD_CARD_SUPPORT: false, //�Ƿ�֧��SD��

+        DDNS_SUPPORT: false, //DDNS

+        NETWORK_UNLOCK_SUPPORT: true,

+        NETWORK_MODES : [ {

+            name : '802.11 b/g/n',

+            value : '4'

+        } ],

+        WIFI_SUPPORT_QR_CODE: false,

+        HAS_PHONEBOOK: true,

+        HAS_BATTERY: true, //�Ƿ��е��

+		FAST_BOOT_SUPPORT: false, //�Ƿ�֧�ֿ��ٿ���

+        TURN_OFF_SUPPORT: false, //�Ƿ�֧�ֹػ�

+		WIFI_SLEEP_SUPPORT: false, // �Ƿ�֧��wifi����

+        HAS_USSD: true, // 是否支持USSD功能,

+        WIFI_WAP3_SUPPORT: false, //是否支持wifi WAP3加密

+        WIFI_WPA2_WAP3_SUPPORT: false, //是否支持wifi WPA2/WAP3兼容模式

+        //station����ģʽ

+        //wifi加密模式

+        AUTH_MODES: [{

+            name: 'NO ENCRYPTION',

+            value: 'OPEN'

+        }, {

+            name: 'WPA2(AES)-PSK',

+            value: 'WPA2PSK'

+        }, {

+            name: 'WPA-PSK/WPA2-PSK',

+            value: 'WPAPSKWPA2PSK'

+        }

+    ],

+    AUTH_MODES_WEP: [{

+            name: 'NO ENCRYPTION',

+            value: 'OPEN'

+        }, {

+            name: 'SHARED',

+            value: 'SHARED'

+        }, {

+            name: 'WPA2(AES)-PSK',

+            value: 'WPA2PSK'

+        }, {

+            name: 'WPA-PSK/WPA2-PSK',

+            value: 'WPAPSKWPA2PSK'

+        }

+    ],

+        AUTH_MODES_ALL: [{

+                name: 'NO ENCRYPTION',

+                value: 'OPEN'

+            }, {

+                name: 'SHARED',

+                value: 'SHARED'

+            }, {

+                name: 'WPA-PSK',

+                value: 'WPAPSK'

+            }, {

+                name: 'WPA2-PSK',

+                value: 'WPA2PSK'

+            }, {

+                name: 'WPA-PSK/WPA2-PSK',

+                value: 'WPAPSKWPA2PSK'

+            }

+        ],

+        AUTO_MODES: [{

+                name: 'Automatic',

+                value: 'NETWORK_auto'

+            }, {

+                name: '4G Only',

+                value: 'Only_LTE'

+            }, {

+                name: '3G Only',

+                value: 'Only_WCDMA'

+            }

+        ]

+    };

+

+    return config;

+});

diff --git a/lynq/S300/ap/app/zte_webui/js/lib.js b/lynq/S300/ap/app/zte_webui/js/lib.js
new file mode 100755
index 0000000..0703ce2
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/js/lib.js
@@ -0,0 +1,1168 @@
+function restartDevice(service) {

+    showLoading("restarting");

+    service.restart({}, function (data) {

+        if (data && data.result == "success") {

+            successOverlay();

+        } else {

+            errorOverlay();

+        }

+    }, $.noop);

+}

+function signalFormat(signal) {

+    if (signal) {

+        if (signal > 0) {

+            return "-" + signal + " dBm";

+        } else {

+            return signal + " dBm";

+        }

+    } else {

+        return "— —";

+    }

+}

+function convertSignal(data) {

+    var type_2g = ["GSM", "GPRS", "EDGE", "G", "E"];

+    var type_3g = ["UMTS", "HSDPA", "HSUPA", "HSPA", "HSPA+", "DC-HSPA+", "WCDMA", "TD-SCDMA", "TD", "3G", "TD_SCDMA"];

+    var type_4g = ["LTE", "4G", "FDD", "TDD", "TDD-LTE", "FDD-LTE", "TDD_LTE", "FDD_LTE"];

+    var network_type = data.sub_network_type ? data.sub_network_type : (data.network_type ? data.network_type : '');

+    if ($.inArray(network_type, type_2g) != -1) {

+        return data.rssi;

+    } else if ($.inArray(network_type, type_3g) != -1) {

+        return data.rscp;

+    } else if ($.inArray(network_type, type_4g) != -1) {

+        return data.lte_rsrp;

+    }

+}

+

+function verifyDeviceInfo(field) {

+    if (field && field != "" && field != "0.0.0.0") {

+        return field;

+    } else {

+        return "— —";

+    }

+}

+$(document).ready(function () {

+    $("body").click(function (evt) {

+        var $popover = $(".popover");

+        var $target = $(evt.target);

+        if ((evt.target.id != $popover.data('source') && $target.parents('.popover').length == 0) || $target.hasClass("popover-close")) {

+            popover.close();

+        }

+    });

+});

+var popover = {

+    popoverEle: null,

+    _init: function () {

+        if (this.popoverEle == null) {

+            $("body").append('<div class="popover"></div>');

+            this.popoverEle = $(".popover");

+        }

+    },

+    open: function (opt) {

+        this._init();

+        var offset = opt.target.offset();

+        var top = offset.top + opt.target.outerHeight();

+        this.popoverEle.html(opt.html).css({

+            width: opt.width,

+            left: offset.left,

+            top: top

+        }).data({

+            source: opt.target[0].id

+        }).translate();

+        setTimeout(function () {

+            popover.popoverEle.show();

+        }, 100);

+        this.popoverEle.translate();

+        opt.validation && opt.validation.apply();

+    },

+    close: function () {

+        this.popoverEle && this.popoverEle.fadeOut();

+    },

+    show: function () {

+        this.popoverEle && this.popoverEle.show();

+    },

+    hide: function () {

+        this.popoverEle && this.popoverEle.hide();

+    }

+};

+function isWifiConnected(user_ip_addr, station_list) {

+    return !!_.find(station_list, function (station) {

+        return station.ip_addr == user_ip_addr;

+    });

+}

+function trim(stringToTrim) {

+    return stringToTrim.replace(/^\s+|\s+$/g, "");

+}

+

+function renderCustomElement(container) {

+    if (!container) {

+        container = $("#container");

+    }

+    var radios = container.find("input[type='radio']");

+    var checkboxes = container.find("input[type='checkbox']");

+    $.each(radios, function (i, n) {

+        var $el = $(n),

+        ch = 'checked',

+        checkAction = $el.prop('checked') ? true : false;

+        $el.closest('.radio')[checkAction ? 'addClass' : 'removeClass'](ch) && checkAction ? $el.attr(ch, true) : $el.removeAttr(ch);

+    });

+    $.each(checkboxes, function (i, n) {

+        var $el = $(n),

+        ch = 'checked',

+        checkAction = $el.prop('checked') ? true : false;

+        $el.closest('.checkbox')[checkAction ? 'addClass' : 'removeClass'](ch) && checkAction ? $el.attr(ch, true) : $el.removeAttr(ch);

+    });

+}

+

+function getSelectValFromChosen(choices) {

+    var choicesNums = [];

+    $.each(choices, function (i, n) {

+        var arr = $(n).text().split('/');

+        choicesNums.push(arr[arr.length - 1]);

+    });

+    return choicesNums;

+}

+function syncSelectAndChosen(select, choices) {

+    var choicesNums = getSelectValFromChosen(choices);

+    select.val(choicesNums);

+    return choicesNums;

+}

+

+function getPercent(numerator, denominator, accuracy) {

+    if (accuracy) {

+        accuracy = accuracy * 10;

+    } else {

+        accuracy = 100;

+    }

+    return roundToTwoDecimalNumber(numerator / denominator * accuracy) + "%";

+}

+function checkConnectedStatus(modemConnStatus, rj45ConnStatus, apConnStatus) {

+    return modemConnStatus == "ppp_connected" || rj45ConnStatus == "working" || apConnStatus == "connect";

+}

+

+function enableBtn(ele) {

+    ele.removeAttr("disabled").removeClass("disabled");

+}

+function replaceSpaceWithNbsp(str) {

+    return str.replace(/ /g, '&nbsp;');

+}

+function URLEncodeComponent(url) {

+    return encodeURIComponent(url);

+}

+function URLEncode(url) {

+    return encodeURI(url);

+}

+function checkCableMode(currentMode) {

+    return currentMode == "PPPOE" || currentMode == "AUTO_PPPOE";

+}

+function disableBtn(ele) {

+    ele.attr("disabled", "disabled").removeClass("focusIn").addClass("disabled");

+}

+var Escape = {

+    html: function (string) {

+        return (string + '').replace(/[&<>"'\/`]/g, Escape._htmlReplacer);

+    },

+    regex: function (string) {

+        return (string + '').replace(/[\-$\^*()+\[\]{}|\\,.?\s]/g, '\\$&');

+    },

+    _htmlReplacer: function (match) {

+        return Escape.HTML_CHARS[match];

+    },

+    HTML_CHARS: {

+        '&': '&amp;',

+        '<': '&lt;',

+        '>': '&gt;',

+        '"': '&quot;',

+        "'": '&#x27;',

+        '/': '&#x2F;',

+        '`': '&#x60;'

+    }

+};

+function roundToTwoDecimalNumber(num) {

+    return Math.round(num * 100) / 100;

+}

+function HTMLEncode(html) {

+    return Escape.html(html);

+}

+function HTMLDecode(text) {

+    var temp = document.createElement("div");

+    temp.innerHTML = text;

+    var output = temp.innerText || temp.textContent;

+    output = output.replace(new RegExp("&nbsp;", "gm"), " ");

+    temp = null;

+    return output;

+}

+function getDisplayVolume1(volume, isSpeed) {

+    volume = parseInt(volume, 10);

+    if (volume == "" || volume == "0") {

+        return "";

+    }

+    var needReverse = false;

+    if (volume < 0) {

+        needReverse = true;

+        volume = 0 - volume;

+    }

+    var numberOfBytesInOneB = 1;

+    var numberOfBytesInOneKB = numberOfBytesInOneB * 1024;

+    var numberOfBytesInOneMB = numberOfBytesInOneKB * 1024;

+    var numberOfBytesInOneGB = numberOfBytesInOneMB * 1024;

+    var numberOfBytesInOneTB = numberOfBytesInOneGB * 1024;

+    var labelForOneB = isSpeed ? 'b' : 'B';

+    var labelForOneKB = isSpeed ? 'Kb' : 'KB';

+    var labelForOneMB = isSpeed ? 'Mb' : 'MB';

+    var labelForOneGB = isSpeed ? 'Gb' : 'GB';

+    var labelForOneTB = isSpeed ? 'Tb' : 'TB';

+    if (isSpeed) {

+        volume = volume * 8;

+    }

+    var vol = volume / numberOfBytesInOneTB;

+    var displayString = roundToTwoDecimalNumber(vol) + labelForOneTB;

+    if (vol < 0.5) {

+        vol = volume / numberOfBytesInOneGB;

+        displayString = roundToTwoDecimalNumber(vol) + labelForOneGB;

+        if (vol < 0.5) {

+            vol = volume / numberOfBytesInOneMB;

+            displayString = roundToTwoDecimalNumber(vol) + labelForOneMB;

+            if (isSpeed) {

+                if (vol < 0.5) {

+                    vol = volume / numberOfBytesInOneKB;

+                    displayString = roundToTwoDecimalNumber(vol) + labelForOneKB;

+                    if (vol < 0.5) {

+                        vol = volume;

+                        displayString = roundToTwoDecimalNumber(vol) + labelForOneB;

+                    }

+                }

+            }

+        }

+    }

+    if (needReverse) {

+        displayString = "-" + displayString;

+    }

+    return displayString;

+}

+function getDisplayVolume(volume, isSpeed) {

+    volume = parseInt(volume, 10);

+    if (volume == "" || volume == "0") {

+        return "";

+    }

+    var needReverse = false;

+    if (volume < 0) {

+        needReverse = true;

+        volume = 0 - volume;

+    }

+    var numberOfBytesInOneB = 1;

+    var numberOfBytesInOneKB = numberOfBytesInOneB * 1024;

+    var numberOfBytesInOneMB = numberOfBytesInOneKB * 1024;

+    var numberOfBytesInOneGB = numberOfBytesInOneMB * 1024;

+    var numberOfBytesInOneTB = numberOfBytesInOneGB * 1024;

+    var labelForOneB = isSpeed ? 'b' : 'B';

+    var labelForOneKB = isSpeed ? 'Kb' : 'KB';

+    var labelForOneMB = isSpeed ? 'Mb' : 'MB';

+    var labelForOneGB = isSpeed ? 'Gb' : 'GB';

+    var labelForOneTB = isSpeed ? 'Tb' : 'TB';

+    if (isSpeed) {

+        volume = volume * 8;

+    }

+    var vol = volume / numberOfBytesInOneTB;

+    var displayString = roundToTwoDecimalNumber(vol) + labelForOneTB;

+    if (vol < 0.5) {

+        vol = volume / numberOfBytesInOneGB;

+        displayString = roundToTwoDecimalNumber(vol) + labelForOneGB;

+        if (vol < 0.5) {

+            vol = volume / numberOfBytesInOneMB;

+            displayString = roundToTwoDecimalNumber(vol) + labelForOneMB;

+            if (vol < 0.5) {

+                vol = volume / numberOfBytesInOneKB;

+                displayString = roundToTwoDecimalNumber(vol) + labelForOneKB;

+                if (vol < 0.5) {

+                    vol = volume;

+                    displayString = roundToTwoDecimalNumber(vol) + labelForOneB;

+                }

+            }

+        }

+    }

+    if (needReverse) {

+        displayString = "-" + displayString;

+    }

+    return displayString;

+}

+function transUnit(data, isSpeed) {

+    var result = getDisplayVolume1(data, isSpeed);

+    if (result == "") {

+        result = isSpeed ? "0b" : "0MB";

+    }

+    if (isSpeed) {

+        result += "/s";

+    }

+    return result;

+}

+function transTimeUnit(data) {

+    data = parseFloat(data);

+    if (data == "") {

+        return result = "0hour";

+    }

+    var needReverse = false;

+    if (data < 0) {

+        needReverse = true;

+        data = 0 - data;

+    }

+    var labelForOneMinute = 'minute';

+    var labelForOneHour = 'hour';

+    var vol = data / 3600;

+    var result = roundToTwoDecimalNumber(vol) + labelForOneHour;

+    if (vol < 1) {

+        vol = data / 60;

+        result = roundToTwoDecimalNumber(vol) + labelForOneMinute;

+    }

+    if (needReverse) {

+        result = "-" + result;

+    }

+    return result;

+}

+function transSecond2Time(secs) {

+    secs = parseInt(secs, 10);

+    var isNegative = false;

+    if (secs < 0) {

+        isNegative = true;

+        secs = 0 - secs;

+    }

+    var hour = Math.floor(secs / 3600);

+    secs = secs % 3600;

+    var minu = Math.floor(secs / 60);

+    secs = secs % 60;

+    return (isNegative ? '-' : '') + leftInsert(hour, 2, '0') + ":" + leftInsert(minu, 2, '0') + ":" + leftInsert(secs, 2, '0');

+}

+function leftInsert(value, length, placeholder) {

+    var len = value.toString().length;

+    for (; len < length; len++) {

+        value = placeholder + value;

+    }

+    return value;

+}

+

+var _timeoutStack = [];

+var _intervalStack = [];

+function addTimeout(code, delay) {

+    var time = window.setTimeout(code, delay);

+    _timeoutStack.push(time);

+    return time;

+}

+function addInterval(code, delay) {

+    var time = window.setInterval(code, delay);

+    _intervalStack.push(time);

+    return time;

+}

+function clearTimer() {

+    clearTimeoutTimer();

+    clearIntervalTimer();

+}

+function clearTimeoutTimer() {

+    for (var i = 0; i < _timeoutStack.length; i++) {

+        window.clearTimeout(_timeoutStack[i]);

+    }

+    _timeoutStack = [];

+}

+function clearIntervalTimer() {

+    for (var i = 0; i < _intervalStack.length; i++) {

+        window.clearInterval(_intervalStack[i]);

+    }

+    _intervalStack = [];

+}

+$(document).ready(function () {

+    $("[manualControl!=true].checkbox").live("click", function (event) {

+        var $this = $(this);

+        if ($this.hasClass('disable')) {

+            return false;

+        }

+        var checkbox = $this.find("input:checkbox");

+        if (checkbox.attr("checked")) {

+            checkbox.removeAttr("checked");

+        } else {

+            checkbox.attr("checked", "checked");

+        }

+        checkCheckbox(checkbox);

+        event.stopPropagation();

+        return true;

+    });

+    $('input[type="text"][noAction!="true"],input[type="password"][noAction!="true"],select').live("focusin", function (event) {

+        $(this).addClass("focusIn");

+    }).live("focusout", function (event) {

+        $(this).removeClass("focusIn");

+    });

+    $(".form-note .notes-title").live('click', function () {

+        var $this = $(this);

+        $this.siblings("ul.notes-content:first").slideToggle();

+        $this.toggleClass("notes-dot");

+    });

+});

+var GSM7_Table = ["000A", "000C", "000D", "0020", "0021", "0022", "0023", "0024", "0025", "0026", "0027", "0028", "0029", "002A", "002B", "002C", "002D", "002E", "002F", "0030", "0031", "0032", "0033", "0034", "0035", "0036", "0037", "0038", "0039", "003A", "003A", "003B", "003C", "003D", "003E", "003F", "0040", "0041", "0042", "0043", "0044", "0045", "0046", "0047", "0048", "0049", "004A", "004B", "004C", "004D", "004E", "004F", "0050", "0051", "0052", "0053", "0054", "0055", "0056", "0057", "0058", "0059", "005A", "005B", "005C", "005D", "005E", "005F", "0061", "0062", "0063", "0064", "0065", "0066", "0067", "0068", "0069", "006A", "006B", "006C", "006D", "006E", "006F", "0070", "0071", "0072", "0073", "0074", "0075", "0076", "0077", "0078", "0079", "007A", "007B", "007C", "007D", "007E", "00A0", "00A1", "00A3", "00A4", "00A5", "00A7", "00BF", "00C4", "00C5", "00C6", "00C7", "00C9", "00D1", "00D6", "00D8", "00DC", "00DF", "00E0", "00E4", "00E5", "00E6", "00E8", "00E9", "00EC", "00F1", "00F2", "00F6", "00F8", "00F9", "00FC", "0393", "0394", "0398", "039B", "039E", "03A0", "03A3", "03A6", "03A8", "03A9", "20AC"];

+var GSM7_Table_Extend = ["007B", "007D", "005B", "005D", "007E", "005C", "005E", "20AC", "007C"];

+function getEncodeType(strMessage) {

+    var encodeType = "GSM7_default";

+    var gsm7_extend_char_len = 0;

+    if (!strMessage) {

+        return {

+            encodeType: encodeType,

+            extendLen: gsm7_extend_char_len

+        };

+    }

+    for (var i = 0; i < strMessage.length; i++) {

+        var charCode = strMessage.charCodeAt(i).toString(16).toUpperCase();

+        while (charCode.length != 4) {

+            charCode = "0" + charCode;

+        }

+        if ($.inArray(charCode, GSM7_Table_Extend) != -1) {

+            gsm7_extend_char_len++;

+        }

+        if ($.inArray(charCode, GSM7_Table) == -1) {

+            encodeType = "UNICODE";

+            gsm7_extend_char_len = 0;

+            break;

+        }

+    }

+    return {

+        encodeType: encodeType,

+        extendLen: gsm7_extend_char_len

+    };

+}

+function encodeMessage(textString) {

+    var haut = 0;

+    var result = '';

+    if (!textString)

+        return result;

+    for (var i = 0; i < textString.length; i++) {

+        var b = textString.charCodeAt(i);

+        if (haut != 0) {

+            if (0xDC00 <= b && b <= 0xDFFF) {

+                result += dec2hex(0x10000 + ((haut - 0xD800) << 10) + (b - 0xDC00));

+                haut = 0;

+                continue;

+            } else {

+                haut = 0;

+            }

+        }

+        if (0xD800 <= b && b <= 0xDBFF) {

+            haut = b;

+        } else {

+            cp = dec2hex(b);

+            while (cp.length < 4) {

+                cp = '0' + cp;

+            }

+            result += cp;

+        }

+    }

+    return result;

+}

+var specialChars = ['000D', '000A', '0009', '0000'];

+var specialCharsIgnoreWrap = ['0009', '0000'];

+function decodeMessage(str, ignoreWrap) {

+    if (!str)

+        return "";

+    var specials = specialCharsIgnoreWrap;

+    return str.replace(/([A-Fa-f0-9]{1,4})/g, function (matchstr, parens) {

+        if ($.inArray(parens, specials) == -1) {

+            return hex2char(parens);

+        } else {

+            return '';

+        }

+    });

+}

+function dec2hex(textString) {

+    return (textString + 0).toString(16).toUpperCase();

+}

+function hex2char(hex) {

+    var result = '';

+    var n = parseInt(hex, 16);

+    if (n <= 0xFFFF) {

+        result += String.fromCharCode(n);

+    } else if (n <= 0x10FFFF) {

+        n -= 0x10000;

+        result += String.fromCharCode(0xD800 | (n >> 10)) + String.fromCharCode(0xDC00 | (n & 0x3FF));

+    }

+    return result;

+}

+function renderCheckbox() {

+    var checkboxToggle = $(".checkboxToggle");

+    checkboxToggle.each(function () {

+        checkBoxesSize($(this));

+    });

+    var checkboxes = $(".checkbox").not("[class*='checkboxToggle']").find("input:checkbox");

+    if (checkboxes.length == 0) {

+        disableCheckbox(checkboxToggle);

+    } else {

+        enableCheckbox(checkboxToggle);

+    }

+    checkboxes.each(function () {

+        checkCheckbox($(this));

+    });

+}

+function checkBoxesSize(selectAll) {

+    var target = selectAll.attr("target");

+    var boxSize = $("#" + target + " .checkbox input:checkbox").length;

+    var checkedBoxSize = $("#" + target + " .checkbox input:checkbox:checked").length;

+    var checkbox = selectAll.find("input:checkbox");

+    if (boxSize != 0 && boxSize == checkedBoxSize) {

+        checkbox.attr("checked", "checked");

+    } else {

+        checkbox.removeAttr("checked");

+    }

+    checkP(checkbox);

+}

+function checkSelectAll(selectAll, target) {

+    var theCheckbox = $("#" + target + " .checkbox input:checkbox");

+    if (selectAll.attr("checked")) {

+        theCheckbox.attr("checked", "checked");

+    } else {

+        theCheckbox.removeAttr("checked");

+    }

+    theCheckbox.each(function () {

+        checkCheckbox($(this));

+    });

+}

+function checkCheckbox(checkbox) {

+    if (checkbox.closest("p.checkbox").hasClass("checkboxToggle")) {

+        checkSelectAll(checkbox, checkbox.closest("p.checkbox").attr("target"));

+    }

+    checkP(checkbox);

+    checkBoxesSize($("#" + checkbox.attr("target")));

+}

+function checkP(checkbox) {

+    if (checkbox.attr("checked")) {

+        checkbox.closest("p.checkbox").addClass("checkbox_selected");

+    } else {

+        checkbox.closest("p.checkbox").removeClass("checkbox_selected");

+    }

+}

+function removeChecked(id) {

+    $("#" + id).removeClass("checkbox_selected").find("input:checkbox").removeAttr("checked");

+}

+function disableCheckbox(checkbox) {

+    var chk = checkbox.find("input:checkbox");

+    if (chk.attr("checked")) {

+        checkbox.addClass('checked_disable');

+    } else {

+        checkbox.addClass('disable');

+    }

+}

+function enableCheckbox(checkbox) {

+    checkbox.removeClass('disable').removeClass("checked_disable");

+}

+function tryToDisableCheckAll(checkbox, len) {

+    if (len == 0) {

+        disableCheckbox(checkbox);

+    } else {

+        enableCheckbox(checkbox);

+    }

+}

+

+function escapeMessage(msg) {

+    return msg;

+}

+function parseTime(date) {

+    if (date.indexOf("+") > -1) {

+        date = date.substring(0, date.lastIndexOf("+"));

+    }

+    var dateArr;

+    if (date.indexOf(",") > -1) {

+        dateArr = date.split(",");

+    } else {

+        dateArr = date.split(";");

+    }

+    if (dateArr.length == 0) {

+        return "";

+    } else {

+        var time = dateArr[0] + "-" + dateArr[1] + "-" + dateArr[2] + " " + leftInsert(dateArr[3], 2, '0') + ":" + leftInsert(dateArr[4], 2, '0') + ":"

+            +leftInsert(dateArr[5], 2, '0');

+        return time;

+    }

+}

+function transTime(data) {

+    var dateArr = data.split(",");

+    if (dateArr.length == 0 || ("," + data + ",").indexOf(",,") != -1) {

+        return "";

+    } else {

+        var time = dateArr[0] + "/" + dateArr[1] + "/" + dateArr[2] + " " + leftInsert(dateArr[3], 2, '0') + ":" + leftInsert(dateArr[4], 2, '0') + ":"

+            +leftInsert(dateArr[5], 2, '0');

+        return time;

+    }

+}

+function getSmsCount(str) {

+    var encodeType = getEncodeType(str);

+    var len = str.length,

+    gsm7 = encodeType.encodeType != "UNICODE",

+    needChunking = false,

+    chunkSize = 0;

+    if (gsm7) {

+        needChunking = (len + encodeType.extendLen) > 160;

+        chunkSize = 153;

+    } else {

+        needChunking = len > 70;

+        chunkSize = 67;

+    }

+    if (needChunking) {

+        return Math.ceil((len + encodeType.extendLen) / chunkSize);

+    } else {

+        return 1;

+    }

+}

+function getInsertPos(textbox) {

+    var iPos = 0;

+    if (textbox.selectionStart || textbox.selectionStart == "0") {

+        iPos = textbox.selectionStart;

+    } else if (document.selection) {

+        textbox.focus();

+        var range = document.selection.createRange();

+        var rangeCopy = range.duplicate();

+        rangeCopy.moveToElementText(textbox);

+        while (range.compareEndPoints("StartToStart", rangeCopy) > 0) {

+            range.moveStart("character", -1);

+            iPos++;

+        }

+    }

+    return iPos;

+}

+function setInsertPos(textbox, iPos) {

+    textbox.focus();

+    if (textbox.selectionStart || textbox.selectionStart == "0") {

+        textbox.selectionStart = iPos;

+        textbox.selectionEnd = iPos;

+    } else if (document.selection) {

+        var range = textbox.createTextRange();

+        range.moveStart("character", iPos);

+        range.collapse(true);

+        range.select();

+    }

+}

+function isIntNum(input, num) {

+    for (var i = 1; i < 6; i++) {

+        if (input == i * num) {

+            return true;

+        }

+    }

+    return false;

+}

+

+function transUnixTime(millisecond) {

+    var time = new Date(parseInt(millisecond, 10));

+    var year = time.getFullYear();

+    var month = leftPad(time.getMonth() + 1, 2, "0");

+    var date = leftPad(time.getDate(), 2, "0");

+    var hour = leftPad(time.getHours(), 2, "0");

+    var minute = leftPad(time.getMinutes(), 2, "0");

+    var second = leftPad(time.getSeconds(), 2, "0");

+    return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;

+}

+function leftPad(value, length, placeholder) {

+    var len = value.toString().length;

+    for (; len < length; len++) {

+        value = placeholder + value;

+    }

+    return value;

+};

+function convertNumberToId(number) {

+    return number.replace(/[\+\*#]/g, '_');

+}

+function getLastNumber(number, len) {

+    if (number.length > len) {

+        return convertNumberToId(number.substring(number.length - len, number.length));

+    }

+    return convertNumberToId(number);

+}

+function fixTableHeight() {

+    if ($.browser.msie) {

+        var heightTimer = setInterval(function () {

+            var $table = $(".fixTableScroll")[0];

+            if ($table) {

+                var scrollHeight = $table.scrollHeight;

+                if (scrollHeight != 0) {

+                    $table.style.height = scrollHeight + 20;

+                    window.clearInterval(heightTimer);

+                }

+            } else {

+                window.clearInterval(heightTimer);

+            }

+        }, 300);

+    }

+}

+function refreshTableHeight() {

+    if ($.browser.msie) {

+        $(".fixTableScroll")[0].style.height = $(".fixTableScroll .ko-grid-container")[0].scrollHeight + 35;

+    }

+}

+

+function popup(option) {

+    $.modal.close();

+    var minHeight = option.minHeight || 140;

+    $('#confirm').modal({

+        zIndex: 3000,

+        position: ["30%"],

+        overlayId: 'confirm-overlay',

+        containerId: 'confirm-container',

+        escClose: false,

+        minHeight: minHeight

+    });

+    var $confirmDiv = $('div#confirm');

+    $('#confirmImg', $confirmDiv).attr('src', option.img);

+    $('#popTitle', $confirmDiv).html($.i18n.prop(option.title));

+    if (typeof option.msg != 'string') {

+        var params = [option.msg.msg];

+        params.push(option.msg.params);

+        $('.message', $confirmDiv).html($.i18n.prop.apply(null, _.flatten(params)));      

+    } else {

+		$('.message', $confirmDiv).html($.i18n.prop(option.msg));

+    }

+    var $promptDiv = $("div.promptDiv", $confirmDiv);

+    if (option.showInput === true) {

+        $promptDiv.show();

+        $("input#promptInput", $promptDiv).val(option.defaultValue ? option.defaultValue : "");

+        $(".promptErrorLabel", $promptDiv).empty();

+    } else {

+        $promptDiv.hide();

+    }

+    window.setTimeout(function () {

+        $(':input:enabled:visible:first', '#confirm-container').focus();

+    }, 0);

+}

+function showSettingWindow(title, htmlPath, jsPath, minWidth, minHeight, callback) {

+    var option = {

+        title: title,

+        htmlPath: htmlPath,

+        jsPath: jsPath,

+        minHeight: minHeight,

+        minWidth: minWidth

+    };

+    var callbackIsFunction = $.isFunction(callback);

+    var callbackIsPojo = $.isPlainObject(callback);

+    popupSettingWindow(option);

+}

+function popupSettingWindow(option) {

+    $.modal.close();

+    var minHeight = option.minHeight || 140;

+    var minWidth = option.minWidth || 400;

+    var subContainer = $("#htmlContainer");

+    var tmplPath = 'text!tmpl/' + option.htmlPath + '.html';

+    require([tmplPath, option.jsPath], function (tmpl, viewModel) {

+        subContainer.stop(true, true);

+        subContainer.hide();

+        subContainer.html(tmpl);

+        viewModel.init();

+        $('#htmlContainer').translate();

+        subContainer.show();

+        $('#htmlContainer').css("opacity", 50);

+    });

+    $('#popupSettingWindow').modal({

+        zIndex: 3000,

+        position: ["30%"],

+        escClose: false,

+        minWidth: minWidth,

+        minHeight: minHeight,

+        maxWidth: 400,

+        opacity: 50

+    });

+}

+function hidePopupSettingWindow() {

+    $("#popupSettingWindow").remove();

+    $.modal.close();

+}

+function showInfo(msgObj, minHeight) {

+    var option = {

+        title: 'info',

+        img: 'pic/res_info.png',

+        msg: msgObj,

+        minHeight: minHeight

+    };

+    popup(option);

+    $('#yesbtn, #nobtn').hide();

+    $('#okbtn').unbind('click').click(function () {

+        $.modal.close();

+    }).show();

+}

+function showPrompt(msgObj, callback, minHeight, defaultValue, checkPromptInput, NobtnCallback) {

+    var option = {

+        title: 'prompt',

+        img: 'pic/res_confirm.png',

+        msg: msgObj,

+        minHeight: minHeight,

+        showInput: true,

+        defaultValue: defaultValue

+    };

+    popup(option);

+    $('#yesbtn, #nobtn').unbind('click').show();

+    $('#okbtn').hide();

+    $('#yesbtn').click(function () {

+        if ($.isFunction(checkPromptInput)) {

+            if (!checkPromptInput()) {

+                return false;

+            };

+        }

+        if ($.isFunction(callback)) {

+            if (callback()) {

+                $.modal.close();

+            }

+        }

+    });

+    $('#nobtn').click(function () {

+        if ($.isFunction(NobtnCallback)) {

+            NobtnCallback();

+        }

+        $.modal.close();

+    });

+    if ($.isFunction(checkPromptInput)) {

+        $("#promptInput", "#confirm").unbind('input propertychange').bind('input propertychange', function () {

+            if ($.isFunction(checkPromptInput)) {

+                checkPromptInput();

+            }

+        });

+    }

+    $("#promptInput", "#confirm").unbind('keypress').bind('keypress', function (event) {

+        if (event.keyCode == 13) {

+            $('#yesbtn').trigger("click");

+        }

+    });

+}

+function showConfirm(msgObj, callback, minHeight, yesTrans, noTrans) {

+    if (yesTrans) {

+        $('#yesbtn').attr("data-trans", yesTrans);

+    } else {

+        $('#yesbtn').attr("data-trans", "yes");

+    }

+    if (noTrans) {

+        $('#nobtn').attr("data-trans", noTrans);

+    } else {

+        $('#nobtn').attr("data-trans", "no");

+    }

+    $('#yesbtn, #nobtn').translate();

+    var option = {

+        title: 'confirm',

+        img: 'pic/res_confirm.png',

+        msg: msgObj,

+        minHeight: minHeight

+    };

+    popup(option);

+    $('#yesbtn, #nobtn').show();

+    $('#okbtn').hide();

+    var callbackIsFunction = $.isFunction(callback);

+    var callbackIsPojo = $.isPlainObject(callback);

+    $('#yesbtn').unbind('click').click(function () {

+        $.modal.close();

+        if (callbackIsFunction) {

+            callback();

+        } else if (callbackIsPojo && $.isFunction(callback.ok)) {

+            callback.ok();

+        }

+    });

+    $('#nobtn').unbind('click').click(function () {

+        $.modal.close();

+        if (callbackIsPojo && $.isFunction(callback.no)) {

+            callback.no();

+        }

+    });

+}

+function showAlert(msgObj, callback, minHeight) {

+    var option = {

+        title: 'alert',

+        img: 'pic/res_alert.png',

+        msg: msgObj,

+        minHeight: minHeight

+    };

+    popup(option);

+    $('#yesbtn, #nobtn').hide();

+    $('#okbtn').unbind('click').click(function () {

+        $.modal.close();

+        if ($.isFunction(callback)) {

+            callback();

+        }

+    }).show();

+}

+function loadingMsgChange(msg) {

+    $('#loadMsg').html($.i18n.prop(msg));

+}

+function hideLoading() {

+    $('#confirm-overlay').css("cursor", "default");

+    $.modal.close();

+    $('#loadMsg').html('');

+}

+function getRandomInt(n) {

+    return Math.round(Math.random() * n);

+}

+function getCurrentDatetime() {

+    var d = new Date();

+    return d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate() + " " + d.getHours() + ":" + d.getMinutes()

+     + ":" + d.getSeconds();

+}

+function getRandomDatetime() {

+    var d = new Date();

+    return d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate() + " " + getRandomInt(24) + ":" + getRandomInt(60)

+     + ":" + getRandomInt(60);

+}

+function getRandomDatetimeSep() {

+    var d = new Date();

+    return d.getFullYear() + "," + (d.getMonth() + 1) + "," + d.getDate() + "," + getRandomInt(24) + "," + getRandomInt(60)

+     + "," + getRandomInt(60);

+}

+function getCurrentTimeString(theTime) {

+    var time = "";

+    var d = theTime ? theTime : new Date();

+    time += (d.getFullYear() + "").substring(2) + ";";

+    time += getTwoDigit((d.getMonth() + 1)) + ";" + getTwoDigit(d.getDate()) + ";" + getTwoDigit(d.getHours()) + ";"

+    +getTwoDigit(d.getMinutes()) + ";" + getTwoDigit(d.getSeconds()) + ";";

+    if (d.getTimezoneOffset() < 0) {

+        time += "+" + (0 - d.getTimezoneOffset() / 60);

+    } else {

+        time += (0 - d.getTimezoneOffset() / 60);

+    }

+    return time;

+}

+function getTwoDigit(num) {

+    num += "";

+    while (num.length < 2) {

+        num = "0" + num;

+    }

+    return num;

+}

+function showLoading(msg, content, contentAlert) {

+    if (msg) {

+        $('#loadMsg').html($.i18n.prop(msg));

+    } else {

+        $('#loadMsg').html('');

+    }

+    $('#loading').modal({

+        zIndex: 3000,

+        position: ['30%'],

+        overlayId: 'confirm-overlay',

+        containerId: 'confirm-container',

+        minHeight: 140,

+        persist: true,

+        focus: false,

+        escClose: false

+    });

+    var loading = $("#loading #loading_container");

+    var a = "<a href='javascript:void(0)'>&nbsp;</a>";

+    if (content) {

+        loading.html(content + a);

+    } else {

+        loading.html(a);

+    }

+    if (contentAlert) {

+        $('#loading #loading_wording').html($.i18n.prop(contentAlert));

+    } else {

+        $("#loading #loading_wording").html("");

+    }

+    $("a:last", loading).focus().hide();

+}

+function hideProgressBar() {

+    $.modal.close();

+    setProgressBar(0);

+    $('#barMsg').html('');

+}

+function setProgressBar(percents) {

+    jQuery("#bar").width(400 * percents / 100);

+    jQuery("#barValue").text(percents + "%");

+}

+

+function showProgressBar(msg, content) {

+    if (msg) {

+        $('#barMsg').html($.i18n.prop(msg));

+    }

+    $('#progress').modal({

+        zIndex: 3000,

+        position: ['30%'],

+        overlayId: 'confirm-overlay',

+        containerId: 'confirm-container',

+        minHeight: 140,

+        persist: true,

+        focus: false,

+        escClose: false

+    });

+    if (content) {

+        $("#progress #progress_container").html(content);

+    } else {

+        $("#progress #progress_container").html("");

+    }

+}

+

+function showInfoMsg(msg, nameText, tmp) {

+    $.modal.close();

+    if (msg) {

+        $('#result-image', '#result-overlay').removeClass().addClass(nameText);

+        $('#result_wording').html('<h2>' + $.i18n.prop(msg) + '</h2>');

+    }

+    $('#result-overlay').modal({

+        zIndex: 3000,

+        position: ['30%'],

+        overlayId: 'confirm-overlay',

+        containerId: 'confirm-container',

+        minHeight: 140,

+        persist: true,

+        focus: false,

+        escClose: false

+    });

+    var count = 3;

+    var overlayTimer = setInterval(function () {

+        count--;

+        if (count == 0) {

+            clearInterval(overlayTimer);

+            if ($('#result-overlay:visible').length > 0) {

+                $.modal.close();

+            }

+        }

+    }, 1000);

+}

+function errorOverlay(msg, isContinueLoading) {

+    showInfoMsg(msg ? msg : 'error_info', 'overlay-error', !isContinueLoading);

+}

+function successOverlay(msg, isContinueLoading) {

+    showInfoMsg(msg ? msg : 'success_info', 'overlay-success', !isContinueLoading);

+}

+function transOption(transid, isChannel) {

+    if (isChannel) {

+        return function (item) {

+            if (item.value != 0) {

+                var val = item.value.split("_");

+                return val[1] + "MHz " + $.i18n.prop(transid + '_' + val[0]);

+            } else {

+                return $.i18n.prop(transid + '_0');

+            }

+        };

+    }

+    return function (item) {

+        return $.i18n.prop(transid + '_' + item.value);

+    };

+}

+function getFileType(fileName) {

+    var ext = fileName.split('.').pop().toLowerCase();

+    for (type in extMap) {

+        if ($.inArray(ext, extMap[type]) != -1) {

+            return type;

+        }

+    }

+    return "file";

+}

+var extMap = {

+    mp3: ["mp3", "wma", "wav"],

+    film: ["mp4", "avi", "rm", "rmvb", "3gp", "mpeg"],

+    picture: ["jpeg", "jpg", "gif", "bmp", "png"],

+    pdf: ['pdf'],

+    rar: ['rar', '7z', 'zip', 'gzip', 'gz', 'tar'],

+    doc: ['doc', 'docx'],

+    ppt: ['ppt', 'pptx'],

+    xls: ['xls', 'xlsx'],

+    xml: ['xml']

+};

+function checkRange(str, min, max) {

+    var intVal = parseInt(str, 10);

+    return !(intVal > max || intVal < min);

+}

+function transProtocolValue(proto) {

+    switch (proto) {

+    case "TCP":

+    case "UDP":

+    case "ICMP":

+        return proto;

+    case "TCP&UDP":

+        return "TCP+UDP";

+    case "None":

+    default:

+        return "ALL";

+    }

+}

+function transProtocol(proto) {

+    var type = "ALL";

+    if ("1" == proto)

+        type = "TCP";

+    else if ("2" == proto)

+        type = "UDP";

+    else if ("3" == proto)

+        type = "TCP+UDP";

+    else if ("4" == proto)

+        type = "ICMP";

+    else if ("5" == proto)

+        type = "ALL";

+    return type;

+}

+function updateLength(sms_content) {

+    var length = 0;

+    var tmpchr;

+    var index = 0;

+    for (var i = 0; i < sms_content.length; i++) {

+        tmpchr = sms_content.charAt(i);

+        length = length + 1;

+        if ((tmpchr == "[") || (tmpchr == "]") || (tmpchr == "{") || (tmpchr == "}") || (tmpchr == "|") || (tmpchr == "\\") || (tmpchr == "^") || (tmpchr == "~") || (tmpchr == "€")) {

+            length = length + 1;

+        }

+        index = i;

+        if (length == 765) {

+            break;

+        }

+        if (length > 765) {

+            index = i - 1;

+            length = length - 2;

+            break;

+        }

+    }

+    return {

+        index: index,

+        length: length

+    };

+}

+function clearValidateMsg(areaId) {

+    areaId = areaId || '*';

+    $(areaId + ' label.error').remove();

+}

+function isErrorObject(object) {

+    return typeof object.errorType === 'string';

+}

+var manualLogout = false;

+

+// 新增TR069

+function validURLWithProtocol(str_url) {

+    var strRegex = '^((http|https)+://)'

+        + '((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])([.](25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])){3}'// IP范围1.0.0.0~255.255.255.255 

+        + '|'

+        + '([a-zA-Z0-9][-a-zA-Z0-9]{0,62}[.])*'

+        + '[a-zA-Z0-9][-a-zA-Z0-9]{0,62}[.]'

+        + '[a-zA-Z]{2,6})'

+        + '(:[0-9]{1,5})?'

+        + '((/?)|'

+        + '(/[0-9a-zA-Z_!~*\'().;?:@&=+$,%#-]+)+/?)$';

+    var ipv6Reg = '^((http|https)+://)\\[(([0-9a-fA-F]{0,4})([:]{0,1})){1,8}\\](:[0-9]{1,5})?((/?)|(/[0-9a-zA-Z_!~*\'().;?:@&=+$,%#-]+)+/?)$';

+    var rev6 = new RegExp(ipv6Reg);

+    var re = new RegExp(strRegex);

+    if (re.test(str_url)) {

+        if (excludedFTPSpclIp(str_url) == false)

+            return false;

+        return true;

+    }

+    else if ((rev6.test(str_url))) {

+        var istart = str_url.indexOf('[') + 1;

+        var iend = str_url.indexOf(']');

+        if (istart == -1 || iend == -1) {

+            return false;

+        }

+        var strIpv6 = str_url.substring(istart, iend);

+        if (!v6IpVerify(strIpv6)) {

+            return false;

+        }

+        return true;

+    }

+    else {

+        return false;

+    }

+};

+function excludedFTPSpclIp(str_url){

+    var ipstr='';

+    var strRegex = '^((ftp|ftps|http|https)+://)((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])([.](25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])){3})'

+        + '(:[0-9]{1,5})?((/?)|(/[0-9a-zA-Z_!~*\'().;?:@&=+$,%#-]+)+/?)$';

+    var re=new RegExp(strRegex); 

+    if (re.test(str_url)){

+        ipstr=str_url.substring(str_url.indexOf("://")+3);

+        if(ipstr.indexOf("/")!=-1){

+            ipstr=ipstr.substring(0,ipstr.indexOf("/"));

+        }

+        if(ipstr.indexOf(":")!=-1){

+            ipstr=ipstr.substring(0,ipstr.indexOf(":"));

+        }

+        if(ipstr!=""&&false==IpAddrVerify(ipstr))

+            return false;

+    }

+    return true;

+}

diff --git a/lynq/S300/ap/app/zte_webui/js/net.js b/lynq/S300/ap/app/zte_webui/js/net.js
new file mode 100755
index 0000000..22a9d2b
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/js/net.js
@@ -0,0 +1,4233 @@
+

+define("firewall_url_filter","underscore jquery knockout set service".split(" "),

+    function (_, $, ko, config, service) {

+

+    //system url filter setting VM

+     

+    function UrlFilterSettingVM() {

+        var target = this;

+        var urlFltInfo = service.getUrlFilterList();

+        var columnsTmpl = [{

+                columnType: "checkbox",

+                rowText: "index",

+                width: "30%"

+            }, {

+                headerTextTrans: "url",

+                rowText: "url",

+                width: "70%"

+            }

+        ];

+        target.rules = ko.observableArray(urlFltInfo.urlFilterRules);

+

+        target.gridTemplate = new ko.simpleGrid.viewModel({

+            data: target.rules(),

+            idName: "index",

+            columns: columnsTmpl,

+            tmplType: 'list',

+            pageSize: 10

+        });

+

+        target.clear = clearFunc;

+		

+        target.callback = callbackFunc;

+		//删除规则

+         

+        target.deleteRule = deleteRuleFunc;

+		

+        //添加规则

+         

+        target.addRule = addRuleFunc;

+		function callbackFunc(elem) {

+            if (elem.result != "success") {

+                errorOverlay();                

+            } else {

+				target.clear();

+                initialize(target);

+                successOverlay();

+                $("#urlFilters").translate();

+            }

+		}

+		

+		//添加规则

+		function addRuleFunc() {

+            if (target.rules().length >= config.urlFilterMax) {

+                showAlert({

+                    msg: "url_filter_max",

+                    params: config.urlFilterMax

+                });

+                return false;

+            }

+            var tmpArr = [];

+            for (var idx = 0; idx < target.rules().length; idx++) {

+                tmpArr.push(target.rules()[idx].url);

+            }

+            if ($.inArray($("#addURLFilter").val(), tmpArr) != -1) {

+                showAlert("url_repeated");

+                return false;

+            }

+

+            showLoading();

+            var urlFltParams = {

+                goformId: "URL_FILTER_ADD",

+                addURLFilter: $("#addURLFilter").val()

+            };

+            service.addUrlFilterRule(urlFltParams, target.callback);

+        }

+		//删除规则

+		function deleteRuleFunc() {

+            showConfirm('confirm_data_delete', function () {

+                showLoading();

+                var urlFltParams = {

+                    goformId: "URL_FILTER_DELETE",

+                    url_filter_delete_id: target.gridTemplate.selectedIds().join(";") + ";"

+                };

+                service.deleteSelectedRules(urlFltParams, target.callback);

+            });

+        }

+		

+    }

+	

+		function clearFunc() {

+            $("#addURLFilter").val("");

+        }

+		

+    //页面初始化

+     

+    function initialize() {

+       

+        var vm = new UrlFilterSettingVM();

+		bindContainer(vm);

+    }

+	function bindContainer(vm){

+		var container = $('#container');

+        ko.cleanNode(container[0]);

+		ko.applyBindings(vm, container[0]);

+        $('#urlFilterForm').validate({

+            submitHandler: function () {

+                vm.addRule();

+            },

+            rules: {

+                addURLFilter: 'url_filter_check'

+            }

+        });

+

+        $("#urlFilterListForm").validate({

+            submitHandler: function () {

+                vm.deleteRule();

+            }

+        });

+	}

+

+    return {

+        init: initialize

+    };

+});

+

+define("firewall_upnp_set","underscore jquery knockout set service".split(" "),

+    function (_, $, ko, config, service) {

+

+    //system upnp setting VM

+     

+    function UpnpSettingVM() {

+        var target = this;

+        var upnpInfo = getUpnpSetting();

+

+        target.upnpSetting = ko.observable(upnpInfo.upnpSetting);

+

+        target.save = saveFunc;

+		function saveFunc() {

+            showLoading();

+            var upnpParams = {};

+            upnpParams.upnpSetting = target.upnpSetting();

+            service.setUpnpSetting(upnpParams, function (rlt) {

+                if (rlt.result == "success") {

+                    successOverlay();

+                } else {

+                    errorOverlay();

+                }

+            });

+

+        }

+    }

+	

+		

+    //获取upnp 信息

+     

+    function getUpnpSetting() {

+        return service.getUpnpSetting();

+    }

+

+    //初始化UpnpSettingVM model

+     

+    function initialize() {

+        

+        var vm = new UpnpSettingVM();

+		bindContainer(vm);

+        

+    }

+	function bindContainer(vm) {

+		var container = $('#container');

+        ko.cleanNode(container[0]);

+		ko.applyBindings(vm, container[0]);

+        $('#upnpSettingForm').validate({

+            submitHandler: function () {

+                vm.save();

+            }

+        });

+	}

+

+    return {

+        init: initialize

+    };

+});

+

+define("firewall_upnp_set","underscore jquery knockout set service".split(" "),

+    function (_, $, ko, config, service) {

+

+    //system upnp setting VM

+     

+    function UpnpSettingVM() {

+        var target = this;

+        var upnpInfo = getUpnpSetting();

+

+        target.upnpSetting = ko.observable(upnpInfo.upnpSetting);

+

+        target.save = saveFunc;

+		function saveFunc() {

+            showLoading();

+            var upnpParams = {};

+            upnpParams.upnpSetting = target.upnpSetting();

+            service.setUpnpSetting(upnpParams, function (rlt) {

+                if (rlt.result == "success") {

+                    successOverlay();

+                } else {

+                    errorOverlay();

+                }

+            });

+

+        }

+    }

+	

+		

+    //获取upnp 信息

+     

+    function getUpnpSetting() {

+        return service.getUpnpSetting();

+    }

+

+    //初始化UpnpSettingVM model

+     

+    function initialize() {

+        

+        var vm = new UpnpSettingVM();

+		bindContainer(vm);

+        

+    }

+	function bindContainer(vm) {

+		var container = $('#container');

+        ko.cleanNode(container[0]);

+		ko.applyBindings(vm, container[0]);

+        $('#upnpSettingForm').validate({

+            submitHandler: function () {

+                vm.save();

+            }

+        });

+	}

+

+    return {

+        init: initialize

+    };

+});

+

+//端口映射

+ 

+define("firewall_port_map","underscore jquery knockout set service".split(" "),

+    function (_, $, ko, config, service) {

+

+    var protocolModes = _.map(config.MAP_PROTOCOL_MODES, function (ele) {

+        return new Option(ele.name, ele.value);

+    });

+

+    var columnsTmpl = [{

+            columnType: "checkbox",

+            rowText: "index",

+            width: "8%"

+        }, {

+            headerTextTrans: "source_port",

+            rowText: "sourcePort",

+            width: "20%"

+        }, {

+            headerTextTrans: "dest_ip_address",

+            rowText: "destIpAddress",

+            width: "20%"

+        }, {

+            headerTextTrans: "dest_port",

+            rowText: "destPort",

+            width: "20%"

+        }, {

+            headerTextTrans: "protocol",

+            rowText: "protocol",

+            width: "12%"

+        }, {

+            headerTextTrans: "comment",

+            rowText: "comment",

+            width: "20%"

+        }

+    ];

+

+    //prot_map VM

+     

+    function PortMapVM() {

+        var target = this;

+        var mapInfo = getPortMap();

+

+        target.oriPortMapEnable = ko.observable(mapInfo.portMapEnable);

+        target.rules = ko.observableArray(mapInfo.portMapRules);

+        target.portMapEnable = ko.observable(mapInfo.portMapEnable);

+

+		

+        target.comment = ko.observable('');

+        target.selectedMode = ko.observable('TCP&UDP');

+        target.modes = ko.observableArray(protocolModes);

+		

+        target.destPort = ko.observable('');

+        target.destIpAddress = ko.observable('');

+        target.sourcePort = ko.observable('');

+

+

+

+        target.gridTemplate = new ko.simpleGrid.viewModel({

+            data: target.rules(),

+            idName: "index",

+            columns: columnsTmpl,

+            tmplType: 'list',

+            pageSize: 10

+        });

+

+        //设定,新增,删除回调函数

+         

+        target.callback = callbackFunc;

+		

+		//删除规则

+         

+        target.deleteMapRules = deleteMapRulesFunc;

+		

+		//检查新增规则是否已经存在

+         

+        target.checkExist = checkExistFunc;

+		

+        //设定端口映射

+         

+        target.enablePortMap = enablePortMapFunc;

+

+        //保存规则

+         

+        target.save = saveFunc;

+		        

+		//保存规则

+		function saveFunc() {

+            if (target.rules().length >= config.portForwardMax) {

+                showAlert({

+                    msg: "rules_max",

+                    params: config.portForwardMax

+                });

+                return;

+            }

+

+            if (target.checkExist()) {

+                showAlert("rule_exist");

+                return;

+            }

+

+            showLoading();

+            var mapParams = {};

+            mapParams.portMapEnable = target.portMapEnable();

+            mapParams.sourcePort = target.sourcePort();

+            mapParams.destIpAddress = target.destIpAddress();

+            mapParams.destPort = target.destPort();

+            mapParams.protocol = target.selectedMode();

+            mapParams.comment = target.comment();

+            service.setPortMap(mapParams, target.callback);

+        }

+		

+		//检查新增规则是否已经存在

+		function checkExistFunc() {

+            var newMapRule = {

+                sourcePort: target.sourcePort(),

+                destIpAddress: target.destIpAddress(),

+                destPort: target.destPort(),

+                protocol: transProtocolValue(target.selectedMode())

+            };

+

+            var oldMapRule;

+            var mapRules = target.rules();

+            for (var idx = 0; idx < mapRules.length; idx++) {

+                oldMapRule = {

+                    sourcePort: mapRules[idx].sourcePort,

+                    destIpAddress: mapRules[idx].destIpAddress,

+                    destPort: mapRules[idx].destPort,

+                    protocol: mapRules[idx].protocol

+                };

+

+                if (_.isEqual(newMapRule, oldMapRule)) {

+                    return true;

+                }

+            }

+            return false;

+        }

+		

+		//设定端口映射

+		function enablePortMapFunc() {

+            showLoading();

+            var mapParams = {};

+            mapParams.portMapEnable = target.portMapEnable();

+            service.enablePortMap(mapParams, target.callback);

+        }

+		

+		//删除规则

+		function deleteMapRulesFunc() {

+            var ids = target.gridTemplate.selectedIds();

+            if (ids.length == 0) {

+                showAlert("no_data_selected");

+                return;

+            }

+

+            showConfirm("confirm_data_delete", function () {

+                showLoading();

+                var mapParams = {};

+                mapParams.indexs = ids;

+                service.deleteMapRules(mapParams, target.callback);

+            });

+        }

+		

+		//设定,新增,删除回调函数

+		function callbackFunc(ret) {

+            if (ret.result == "success") {

+                clear();

+                initialize(target);

+                successOverlay();

+            } else {

+                errorOverlay();

+            }

+        }

+

+        //情况添加规则输入

+         

+        function clear() {

+            target.sourcePort('');

+            target.destIpAddress('');

+            target.destPort('');

+            target.selectedMode('TCP&UDP');

+            target.comment('');

+        }

+    }

+

+    //获取port map信息

+     

+    function getPortMap() {

+        return service.getPortMap();

+    }

+

+	function bindingContainer(vm){

+		var container = $('#container');

+        ko.cleanNode(container[0]);

+        ko.applyBindings(vm, container[0]);

+

+	}

+    //初始化port map view model

+     

+    function initialize(viewModel) {

+        var vm;

+        if (viewModel) {

+            vm = viewModel;

+            var mapInfo = getPortMap();

+            vm.portMapEnable(mapInfo.portMapEnable);

+            vm.oriPortMapEnable(mapInfo.portMapEnable);

+            vm.rules(mapInfo.portMapRules);

+            vm.gridTemplate.clearAllChecked();

+            vm.gridTemplate.data(mapInfo.portMapRules);

+            refreshTableHeight();

+            renderCheckbox();

+            return;

+        }

+

+        vm = new PortMapVM();

+        bindingContainer(vm);

+        fixTableHeight();

+

+        $('#mapBasicForm').validate({

+            submitHandler: function () {

+                vm.enablePortMap();

+            }

+        });

+

+        $('#portMapListForm').validate({

+            submitHandler: function () {

+                vm.deleteMapRules();

+            }

+        });

+

+        $('#portMapForm').validate({

+            submitHandler: function () {

+                vm.save();

+            },

+            rules: {

+                txtDestIpAddress: {

+                    ip_check: true

+                },

+                txtSourcePort: {

+                    digits: true,

+                    range_except: [1, 65000]

+                },

+                txtDestPort: {

+                    digits: true,

+                    range_except: [1, 65000]

+                },

+                txtComment: {

+                    comment_check: true

+                }

+            },

+            errorPlacement: function (error, element) {

+                if (element.attr("name") == "txtDestIpAddress") {

+                    error.appendTo("#txtDestIpAddressErrorDiv");

+                } else if (element.attr("name") == "txtSourcePort") {

+                    error.appendTo("#txtSourcePortErrorDiv");

+                } else if (element.attr("name") == "txtDestPort") {

+                    error.appendTo("#txtDestPortErrorDiv");

+                } else

+                    error.insertAfter(element);

+            }

+        });

+    }

+

+    return {

+        init: initialize

+    };

+});

+

+//端口转发

+ 

+define("firewall_port_forward","underscore jquery knockout set service".split(" "),

+    function (_, $, ko, config, service) {

+

+    var protocolModes = _.map(config.FORWARD_PROTOCOL_MODES, function (ele) {

+        return new Option(ele.name, ele.value);

+    });

+    //列表模板的columns项

+     

+    var columnsTmpl = [{

+            columnType: "checkbox",

+            rowText: "index",

+            width: "8%"

+        }, {

+            headerTextTrans: "ip_address",

+            rowText: "ipAddress",

+            width: "23%"

+        }, {

+            headerTextTrans: "port_range",

+            rowText: "portRange",

+            width: "23%"

+        }, {

+            headerTextTrans: "protocol",

+            rowText: "protocol",

+            width: "23%"

+        }, {

+            headerTextTrans: "comment",

+            rowText: "comment",

+            width: "23%"

+        }

+    ];

+

+    //prot_forward VM

+     

+    function PortForwardVM() {

+        var target = this;

+        var fwdinfo = getPortForward();

+

+        target.portForwardEnable = ko.observable(fwdinfo.portForwardEnable);

+        target.oriPortForwardEnable = ko.observable(fwdinfo.portForwardEnable);

+		

+        target.portEnd = ko.observable('');

+        target.portStart = ko.observable('');

+        target.ipAddress = ko.observable('');

+		

+        target.comment = ko.observable('');

+        target.selectedMode = ko.observable('3');

+        target.modes = ko.observableArray(protocolModes);

+

+        target.rules = ko.observableArray(fwdinfo.portForwardRules);

+		

+		//设定,新增,删除回调函数

+         

+        target.callback = callbackFunc;

+		

+        //创建列表模板

+         

+        target.gridTemplate = new ko.simpleGrid.viewModel({

+            data: target.rules(),

+            idName: "index",

+            columns: columnsTmpl,

+            tmplType: 'list',

+            pageSize: 10

+        });

+

+        //检查新增规则是否已经存在

+         

+        target.checkExist = checkExistFunc;

+				

+		//保存规则

+         

+        target.save = saveFunc;

+		

+		//删除规则

+         

+        target.deleteForwardRules = deleteForwardRulesFunc;

+		

+        //设定虚拟服务器

+         

+        target.enableVirtualServer = enableVirtualServerFunc;

+		

+		//设定虚拟服务器

+		function enableVirtualServerFunc() {

+            showLoading();

+            var fwdParams = {};

+            fwdParams.portForwardEnable = target.portForwardEnable();

+            service.enableVirtualServer(fwdParams, target.callback);

+        }

+		

+		//删除规则

+		function deleteForwardRulesFunc() {

+            var ids = target.gridTemplate.selectedIds();

+            if (ids.length == 0) {

+                showAlert("no_data_selected");

+                return;

+            }

+

+            showConfirm("confirm_data_delete", function () {

+                showLoading('deleting');

+                var fwdParams = {};

+                fwdParams.indexs = ids;

+                service.deleteForwardRules(fwdParams, target.callback);

+            });

+        }

+		

+		//保存规则

+		function saveFunc() {

+            if (target.rules().length >= config.portForwardMax) {

+                showAlert({

+                    msg: "rules_max",

+                    params: config.portForwardMax

+                });

+                return;

+            }

+

+            if (target.checkExist()) {

+                showAlert("rule_exist");

+                return;

+            }

+

+            showLoading();

+            var fwdParams = {};

+            fwdParams.comment = target.comment();

+            fwdParams.protocol = target.selectedMode();

+            fwdParams.portEnd = target.portEnd();

+            fwdParams.portStart = target.portStart();

+            fwdParams.ipAddress = target.ipAddress();

+            service.setPortForward(fwdParams, target.callback);

+        }

+         //情况添加规则输入

+        function clear() {

+            target.ipAddress('');

+            target.portStart('');

+            target.portEnd('');

+            target.selectedMode('TCP&UDP');

+            target.comment('');

+        }

+		

+		//设定,新增,删除回调函数

+		function callbackFunc(ret) {

+            if (ret.result == "success") {

+                clear();

+                initialize(target);

+                successOverlay();

+            } else {

+                errorOverlay();

+            }

+        }

+

+		//检查新增规则是否已经存在

+		function checkExistFunc() {

+            var newRule = {

+                ipAddress: target.ipAddress(),

+                portRange: target.portStart() + ' - ' + target.portEnd(),

+                protocol: transProtocolValue(target.selectedMode())

+            };

+

+            var oldRule;

+            var fwdrules = target.rules();

+            for (var ki = 0; ki < fwdrules.length; ki++) {

+                oldRule = {

+                    ipAddress: fwdrules[ki].ipAddress,

+                    portRange: fwdrules[ki].portRange,

+                    protocol: fwdrules[ki].protocol

+                };

+

+                if (_.isEqual(newRule, oldRule)) {

+                    return true;

+                }

+            }

+            return false;

+        }

+    }

+

+    //获取port forward信息

+     

+    function getPortForward() {

+        return service.getPortForward();

+    }

+

+    //初始化port forward view model

+     

+    function initialize(viewModel) {

+        var vm;

+        if (viewModel) {

+            vm = viewModel;

+            var fwdinfo = getPortForward();

+            vm.gridTemplate.clearAllChecked();

+            vm.gridTemplate.data(fwdinfo.portForwardRules);

+            vm.rules(fwdinfo.portForwardRules);

+            vm.portForwardEnable(fwdinfo.portForwardEnable);

+            vm.oriPortForwardEnable(fwdinfo.portForwardEnable);

+            refreshTableHeight();

+            return;

+        }

+

+        vm = new PortForwardVM();

+        bindContainer(vm);

+		

+        fixTableHeight();

+        renderCheckbox();

+

+        $('#virtualServerForm').validate({

+            submitHandler: function () {

+                vm.enableVirtualServer();

+            }

+        });

+

+        $('#portForwardListForm').validate({

+            submitHandler: function () {

+                vm.deleteForwardRules();

+            }

+        });

+

+        $('#portForwardForm').validate({

+            submitHandler: function () {

+                vm.save();

+            },

+            rules: {

+                txtIpAddress: {

+                    ip_check: true

+                },

+                txtPortStart: {

+                    digits: true,

+                    range: [1, 65535],

+                    portCompare: "#txtPortEnd"

+                },

+                txtPortEnd: {

+                    digits: true,

+                    range: [1, 65535],

+                    portCompare: "#txtPortStart"

+                },

+                txtComment: {

+                    comment_check: true

+                }

+            },

+            groups: {

+                range: "txtPortStart txtPortEnd"

+            },

+            errorPlacement: function (error, element) {

+                if (element.attr("name") == "txtIpAddress") {

+                    error.appendTo("#ipErrorDiv");

+                } else if (element.attr("name") == "txtPortStart" || element.attr("name") == "txtPortEnd") {

+                    error.appendTo("#portRangeErrorDiv");

+                } else

+                    error.insertAfter(element);

+            }

+        });

+    }

+	

+	function bindContainer(vm){

+		var container = $('#container');

+        ko.cleanNode(container[0]);

+        ko.applyBindings(vm, container[0]);

+

+	}

+	

+

+    return {

+        init: initialize

+    };

+});

+

+define("firewall_port_filter","underscore jquery knockout set service".split(" "),

+    function (_, $, ko, config, service) {

+

+    var PROTOCOLS = {

+        ICMP: 'ICMP',

+        NONE: 'None'

+    };

+

+    var columnsTmpl = [{

+            columnType: "checkbox",

+            rowText: "index",

+            width: "4%"

+        }, {

+            headerTextTrans: "mac_address",

+            rowText: "macAddress",

+            width: "12%"

+        }, {

+            headerTextTrans: "ip_type",

+            rowText: "ipType",

+            width: "5%",

+            display: config.IPV6_SUPPORT

+        }, {

+            headerTextTrans: "source_ip_address",

+            rowText: "sourceIpAddress",

+            width: "12%"

+        }, {

+            headerTextTrans: "dest_ip_address",

+            rowText: "destIpAddress",

+            width: "12%"

+        }, {

+            headerTextTrans: "protocol",

+            rowText: "protocol",

+            width: "12%",

+            needTrans: true

+        }, {

+            headerTextTrans: "source_port_range",

+            rowText: "sourcePortRange",

+            width: "12%"

+        }, {

+            headerTextTrans: "dest_port_range",

+            rowText: "destPortRange",

+            width: "12%"

+        }, {

+            headerTextTrans: "port_filter_action",

+            rowText: "action",

+            width: "12%",

+            needTrans: true

+        }, {

+            headerTextTrans: "comment",

+            rowText: "comment",

+            width: "12%"

+        }

+    ];

+

+    var protocolModes = _.map(config.FILTER_PROTOCOL_MODES, function (elem) {

+        return new Option(elem.name, elem.value);

+    });

+    //prot_filter VM

+     

+    function PortFilterVM() {

+        var target = this;

+        var info = getPortFilter();

+		

+        target.oriDefaultPolicy = ko.observable(info.defaultPolicy);

+        target.defaultPolicy = ko.observable(info.defaultPolicy);

+        target.oriPortFilterEnable = ko.observable(info.portFilterEnable);

+        target.portFilterEnable = ko.observable(info.portFilterEnable);

+        target.rules = ko.observableArray(info.portFilterRules);

+		

+        target.ipv6Support = ko.observable(config.IPV6_SUPPORT);

+        target.comment = ko.observable('');

+        target.selectedMode = ko.observable('5');

+        target.modes = ko.observableArray(protocolModes);

+        target.sourcePortEnd = ko.observable('');

+        target.sourcePortStart = ko.observable('');

+        target.destPortEnd = ko.observable('');

+        target.destPortStart = ko.observable('');

+        target.destIpv6Address = ko.observable('');

+        target.sourceIpv6Address = ko.observable('');

+        target.sourceIpAddress = ko.observable('');

+        target.destIpAddress = ko.observable('');

+        target.macAddress = ko.observable('');

+        target.portFilterAction = ko.observable('');

+

+        target.ipType = ko.observable('ipv4');

+

+        //设定,新增,删除回调函数

+         

+        target.callback = callbackFunc;

+		

+        //创建列表模板

+         

+        target.gridTemplate = new ko.simpleGrid.viewModel({

+            data: target.rules(),

+            idName: "index",

+            columns: columnsTmpl,

+            tmplType: 'list',

+            pageSize: 20

+        });

+        //default policy change handler

+         

+        target.policyChangeHandler = policyChangeHandlerFunc;

+

+        //保存规则

+         

+        target.save = saveFunc;

+	

+        //设定过滤基本信息

+         

+        target.setPortFilterBasic = setPortFilterBasicFunc;

+		

+		//清空添加规则输入

+         

+        target.clear = clearFunc;

+

+        //检查新增规则是否已经存在

+         

+        target.checkExist = checkExistFunc;

+

+		//ip类型变化事件监听

+         

+        target.ipTypeChangeHandler = ipTypeChangeHandlerFunc;

+		

+        //协议变化事件监听

+         

+        target.protocolChangeHandler = protocolChangeHandlerFunc;

+

+        //删除规则

+         

+        target.deleteFilterRules = deleteFilterRulesFunc;

+

+        //init to call

+        target.policyChangeHandler();

+		

+		//设定,新增,删除回调函数

+		function callbackFunc(ret) {

+            if (ret.result != "success") {

+                errorOverlay();

+            } else {

+                target.clear();

+                initialize(target);

+                successOverlay();

+            }

+        }

+		//default policy change handler

+		function policyChangeHandlerFunc() {

+            var action = target.defaultPolicy() != "1" ? "Drop" : "Accept";

+            target.portFilterAction(action);

+            return true;

+        }

+		

+		//保存规则

+		function saveFunc() {

+            target.sourceIpAddress(target.sourceIpAddress().replace(/\s+/g, ''));

+            target.destIpAddress(target.destIpAddress().replace(/\s+/g, ''));

+            target.sourceIpv6Address(target.sourceIpv6Address().replace(/\s+/g, ''));

+            target.destIpv6Address(target.destIpv6Address().replace(/\s+/g, ''));

+            target.macAddress(target.macAddress().replace(/\s+/g, ''));

+            if (target.ipv6Support() == false) {

+                if (target.rules().length >= config.portForwardMax) {

+                    showAlert({

+                        msg: "rules_max",

+                        params: config.portForwardMax

+                    });

+                    return;

+                }

+

+                if (target.checkExist()) {

+                    showAlert("rule_exist");

+                    return;

+                }

+

+            } else {

+				var type = target.ipType() == "ipv4" ? "IPv4" : "IPv6";

+                var oldRules = _.filter(target.rules(), function (item) {

+                    return item.ipType == type;

+                });

+

+                if (oldRules.length >= config.portForwardMax) {

+                    showAlert({

+                        msg: "rules_max_v4v6",

+                        params: [type, config.portForwardMax]

+                    });

+                    return;

+                }

+

+                if (target.checkExist()) {

+                    showAlert({

+                        msg: "rule_exist_v4v6",

+                        params: type

+                    });

+                    return;

+                }

+            }

+            showConfirm("confirm_data_effect", function () {

+                showLoading();

+                var fltParams = {};

+                fltParams.macAddress = target.macAddress();

+

+                if (target.ipv6Support() && target.ipType() != 'ipv6') {

+                    fltParams.destIpAddress = target.destIpAddress();

+                    fltParams.sourceIpAddress = target.sourceIpAddress();

+                } else {

+                    fltParams.destIpAddress = target.destIpv6Address();

+                    fltParams.sourceIpAddress = target.sourceIpv6Address();

+                }

+				

+                fltParams.ipType = target.ipType();

+                fltParams.comment = target.comment();

+                fltParams.protocol = target.selectedMode();

+                fltParams.action = target.portFilterAction();

+                fltParams.sourcePortEnd = target.sourcePortEnd();

+                fltParams.sourcePortStart = target.sourcePortStart();

+                fltParams.destPortEnd = target.destPortEnd();

+                fltParams.destPortStart = target.destPortStart();

+                service.setPortFilter(fltParams, target.callback);

+            });

+        }

+		

+		//设定过滤基本信息

+		function setPortFilterBasicFunc() {

+            showLoading();

+            var elems = {};

+            elems.defaultPolicy = target.defaultPolicy();

+            elems.portFilterEnable = target.portFilterEnable();

+            service.setPortFilterBasic(elems, target.callback);

+        }

+		//清空添加规则输入

+		function clearFunc() {

+            target.comment('');

+            target.selectedMode('None');

+            target.sourcePortEnd('0');

+            target.sourcePortStart('0');

+            target.destPortEnd('0');

+            target.destPortStart('0');

+            target.sourceIpv6Address('');

+            target.sourceIpAddress('');

+            target.destIpv6Address('');

+            target.destIpAddress('');

+            target.macAddress('');

+            clearValidateMsg();

+        }

+		

+		//检查新增规则是否已经存在

+		function checkExistFunc() {

+            target.macAddress(target.macAddress().toUpperCase());

+            var currIpType = target.ipType().toUpperCase();

+            var newRule = {

+                macAddress: target.macAddress(),

+                destIpAddress: currIpType == "IPV4" ? target.destIpAddress() : target.destIpv6Address(),

+                sourceIpAddress: currIpType == "IPV4" ? target.sourceIpAddress() : target.sourceIpv6Address(),

+                destPortRange: target.destPortStart() == '0' ? '' : target.destPortStart() + ' - ' + target.destPortEnd(),

+                sourcePortRange: target.sourcePortStart() == '0' ? '' : target.sourcePortStart() + ' - ' + target.sourcePortEnd(),

+                action: target.portFilterAction() == "Drop" ? "filter_drop" : "filter_accept",

+                protocol: transProtocolValue(target.selectedMode()),

+                ipType: currIpType

+            };

+

+            var oldRule;

+            var rules = target.rules();

+            for (var ki = 0; ki < rules.length; ki++) {

+                oldRule = {

+                    macAddress: rules[ki].macAddress,

+                    destIpAddress: rules[ki].destIpAddress,

+                    sourceIpAddress: rules[ki].sourceIpAddress,

+                    destPortRange: rules[ki].destPortRange,

+                    sourcePortRange: rules[ki].sourcePortRange,

+                    action: rules[ki].action,

+                    protocol: rules[ki].protocol,

+                    ipType: rules[ki].ipType.toUpperCase()

+                };

+

+                if (_.isEqual(newRule, oldRule)) {

+                    return true;

+                }

+            }

+            return false;

+        }

+		

+		//协议变化事件监听

+		function protocolChangeHandlerFunc() {

+            if (target.selectedMode() == PROTOCOLS.ICMP || target.selectedMode() == PROTOCOLS.NONE) {

+                target.sourcePortEnd('0');

+                target.sourcePortStart('0');

+                target.destPortEnd('0');

+                target.destPortStart('0');

+                clearValidateMsg('#portRangeArea');

+            } else {

+                target.sourcePortEnd('65535');

+                target.sourcePortStart('1');

+                target.destPortEnd('65535');

+                target.destPortStart('1');

+            }

+            return true;

+        }

+		

+		//删除规则

+		function deleteFilterRulesFunc() {

+            var ids = target.gridTemplate.selectedIds();

+            if (ids.length == 0) {

+                showAlert("no_data_selected");

+                return;

+            }

+

+            showConfirm("confirm_data_effect", function () {

+                showLoading('deleting');

+                var rules = {};

+                rules.indexs = ids;

+                service.deleteFilterRules(rules, target.callback);

+            });

+        }

+		

+    }

+

+    //获取port filter信息

+     

+    function getPortFilter() {

+        return service.getPortFilter();

+    }

+		

+	//ip类型变化事件监听

+	function ipTypeChangeHandlerFunc() {

+        clearValidateMsg();

+        return true;

+    }

+	

+    //初始化port filter view model

+     

+    function initialize(viewModel) {

+        var vm;

+        if (viewModel) {

+            vm = viewModel;

+            var fltinfo = getPortFilter();

+            vm.gridTemplate.clearAllChecked();

+            vm.gridTemplate.data(fltinfo.portFilterRules);

+			vm.defaultPolicy(fltinfo.defaultPolicy);

+            vm.oriDefaultPolicy(fltinfo.defaultPolicy);

+            vm.portFilterEnable(fltinfo.portFilterEnable);

+            vm.oriPortFilterEnable(fltinfo.portFilterEnable);

+            vm.rules(fltinfo.portFilterRules);

+            refreshTableHeight();

+            $('#portFilters').find('tbody').translate();

+            renderCheckbox();

+            $('.notes-content').translate();

+            return;

+        }

+

+        vm = new PortFilterVM();

+        var container = $('#container');

+        ko.cleanNode(container[0]);

+        ko.applyBindings(vm, container[0]);

+

+        fixTableHeight();

+

+        $('#filterBasicForm').validate({

+            submitHandler: function () {

+                showConfirm("confirm_data_effect", function () {

+                    vm.setPortFilterBasic();

+                });

+            }

+        });

+

+        $('#portFilterListForm').validate({

+            submitHandler: function () {

+                vm.deleteFilterRules();

+            }

+        });

+

+        $('#portFilterForm').validate({

+            submitHandler: function () {

+                vm.save();

+            },

+            rules: {

+                txtMacAddress: {

+                    filter_optional: true,

+                    mac_check: true

+                },

+                txtDestIpAddress: {

+                    ip_check: true

+                },

+                txtSourceIpAddress: {

+                    ip_check: true

+                },

+                txtSourceIpv6Address: {

+                    ipv6: true

+                },

+                txtDestIpv6Address: {

+                    ipv6: true

+                },

+                txtDestPortStart: {

+                    digits: true,

+                    range: [1, 65535],

+                    portCompare: "#txtDestPortEnd"

+                },

+                txtDestPortEnd: {

+                    digits: true,

+                    range: [1, 65535],

+                    portCompare: "#txtDestPortStart"

+                },

+                txtSourcePortStart: {

+                    digits: true,

+                    range: [1, 65535],

+                    portCompare: "#txtSourcePortEnd"

+                },

+                txtSourcePortEnd: {

+                    digits: true,

+                    range: [1, 65535],

+                    portCompare: "#txtSourcePortStart"

+                },

+

+                txtComment: {

+                    comment_check: true

+                }

+            },

+            groups: {

+                destPort: "txtDestPortStart txtDestPortEnd",

+                sourcePort: "txtSourcePortStart txtSourcePortEnd"

+            },

+            errorPlacement: function (error, element) {

+                if (element.attr("name") == "txtMacAddress") {

+                    error.appendTo("#macErrorDiv");

+                } else if (element.attr("name") == "txtDestPortStart" || element.attr("name") == "txtDestPortEnd") {

+                    error.appendTo("#destPortErrorDiv");

+                } else if (element.attr("name") == "txtSourcePortStart" || element.attr("name") == "txtSourcePortEnd") {

+                    error.appendTo("#sourcePortErrorDiv");

+                } else

+                    error.insertAfter(element);

+            }

+        });

+    }

+

+    $.validator.addMethod("filter_optional", function (value, element, param) {

+        var result = _.any(['#txtMacAddress', '#txtDestIpAddress', '#txtSourceIpAddress', '#txtSourceIpv6Address', '#txtDestIpv6Address'],

+                function (item) {

+            var tmp = $(item).val().replace(/\s+/g, '');

+            return $(item + ':visible').length > 0 && tmp != '';

+        });

+

+        var portResult = _.any(['#txtDestPortStart', '#txtDestPortEnd', '#txtSourcePortStart', '#txtSourcePortEnd'],

+                function (item) {

+            return $(item).val() != '0';

+        });

+

+        return result || portResult;

+    });

+

+    return {

+        init: initialize

+    };

+});

+

+//家长控制

+ 

+define("firewall_parental_control","underscore jquery knockout set service".split(" "),

+    function (_, $, ko, config, service) {

+

+    var maxItem = 10;

+    var pcVm = null;

+    var PAGES = {

+        MAIN: 0,

+        MANAGE: 1,

+        RULE: 2

+    };

+	

+	

+    function ParentalControlVM() {

+        var target = this;

+        var hostNameList = service.getHostNameList({}).devices;

+        target.currentPage = ko.observable(PAGES.MAIN);

+        target.pages = PAGES;

+

+

+        target.childGroupList = ko.observable([]);

+        target.childGroupMac = ko.computed(function () {

+            return _.map(target.childGroupList(), function (data) {

+                return data.mac;

+            });

+        });

+		

+        target.currentUserInChildGroup = ko.observable(true);

+        //获取儿童组设备列表

+         

+        target.fetchChildGroupList = fetchChildGroupListFunc;

+		

+        target.fetchChildGroupList();

+

+        target.manageHandler = manageHandlerFunc;

+		function manageHandlerFunc() {

+            target.currentPage(PAGES.MANAGE);

+            target.fetchAttachedDevices();

+        }

+        target.attachedDevices = ko.observable([]);

+        //获取已连接设备列表

+         

+        target.fetchAttachedDevices = fetchAttachedDevicesFunc;

+		

+

+		//儿童组设备 标签按钮事件

+         

+        target.backToMainHandler = backToMainHandlerFunc;

+		

+		

+        ko.computed(function () {

+            target.attachedDevices();

+            target.childGroupList();

+            $("#pc_children_group_form").translate();

+        }).extend({

+            notify: 'always',

+            throttle: 300

+        });

+        

+        //添加至儿童组

+         

+        function addChildGroupFun(flag, eleData) {

+            showLoading();

+            service.addChildGroup(eleData, function (data) {

+                target.fetchChildGroupList(function () {

+                    target.fetchAttachedDevices(function () {

+                        hideLoading();

+                        if (flag) {

+                            service.logout({}, function () {

+                                window.location = 'index.html';

+                            });

+                        }

+                    });

+                });

+            }, function (data) {

+                errorOverlay();

+            });

+        }

+		

+        //移除按钮事件

+         

+        target.removeChildGroupHandler = removeChildGroupHandlerFunc;

+		

+		

+        //添加按钮事件

+         

+        target.addChildGroupHandler = addChildGroupHandlerFunc;

+		

+

+        target.dealElement = dealElementFunc;

+		

+		

+		

+        //取消编辑主机名按钮事件

+         

+        target.cancelEditHostNameHandler = cancelEditHostNameHandlerFunc;

+		

+        //主机名编辑保存按钮事件

+         

+        target.saveHostNameHandler = saveHostNameHandlerFunc;

+		

+        //主机名编辑按钮事件

+         

+        target.editHostNameHandler = editHostNameHandlerFunc;

+		

+		

+        target.selectedIds = ko.observableArray([]);

+        target.siteList = ko.observable([]);

+        /////////////////////////////////////////////////////////////////

+        target.disableAdd = ko.computed(function () {

+            return target.siteList().length == maxItem;

+        });

+        

+        ko.computed(function () {

+            target.siteList();

+            target.selectedIds();

+            setTimeout(function () {

+                renderCheckbox();

+            }, 100);

+            $("#pc_site_white_list_form").translate();

+        });

+		

+        //网站白名单添加按钮事件

+         

+        target.openAddSitePopoverHandler = openAddSitePopoverHandlerFunc;

+		

+        //网站白名单列表选择框点击事件

+         

+        target.checkboxClickHandler = checkboxClickHandlerFunc;

+		

+		//获取网站白名单列表

+         

+        target.fetchSiteWhiteList = fetchSiteWhiteListFunc;

+		

+		//网站白名单删除函数

+         

+        function removeSiteWhiteItem(ids) {

+            showConfirm('confirm_data_delete', function () {

+                showLoading();

+                service.removeSiteWhite({

+                    ids: ids

+                }, function (data) {

+                    target.fetchSiteWhiteList(function () {

+                        successOverlay();

+                    });

+                }, function (data) {

+                    target.fetchSiteWhiteList(function () {

+                        errorOverlay();

+                    });

+                });

+            });

+        }

+		//网站白名单删除所有按钮事件

+         

+        target.removeAllWhiteSite = removeAllWhiteSiteFunc;

+		

+        //网站白名单删除按钮事件

+         

+        target.removeSelectedWhiteSite = removeSelectedWhiteSiteFunc;

+		

+        //网站白名单移除按钮事件

+         

+        target.removeWhiteSite = removeWhiteSiteFunc;

+		

+        

+        

+        //网站白名单添加框保存按钮事件

+         

+        target.saveSiteWhite = saveSiteWhiteFunc;

+		

+        //////////////////////////////////////////////////////////////////

+        target.notSave = ko.observable(false);

+        //获取时间限制信息

+         

+        target.fetchTimeLimited = fetchTimeLimitedFunc;

+		

+        

+        //上网时间设置时间表格事件绑定

+         

+        target.bindEvent = bindEventFunc;

+		

+		//上网时间设置保存按钮事件

+         

+        target.saveTimeLimitedHandler = saveTimeLimitedHandlerFunc;

+		

+        //////////////////////////////////////////////////////////////////

+        var isBinded = false;

+        //上网规则标签点击事件

+         

+        target.openRulePage = openRulePageFunc;

+		function openRulePageFunc() {

+            if (target.currentPage() == PAGES.RULE) {

+                return;

+            }

+            target.currentPage(PAGES.RULE);

+            target.currentUserInChildGroup(service.checkCurrentUserInChildGroup().result);

+            initTableData();

+            if (!isBinded) {

+                if (!target.currentUserInChildGroup()) {

+                    target.bindEvent();

+                }

+                isBinded = true;

+            }

+            showLoading();

+            target.fetchTimeLimited();

+            target.fetchSiteWhiteList(function () {

+                hideLoading();

+            });

+        }

+		

+		//获取儿童组设备列表

+		function fetchChildGroupListFunc(cb) {

+            service.childGroupList({}, function (data) {

+                target.currentUserInChildGroup(service.checkCurrentUserInChildGroup(data.devices).result);

+                target.childGroupList([]);

+                _.map(data.devices, function (elem, idx) {

+                    elem.idx = idx;

+                    elem.hostname = pcUtil.getHostName(elem.hostname, elem.mac, hostNameList);

+                });

+                target.childGroupList(data.devices);

+                if (_.isFunction(cb)) {

+                    cb.apply(this);

+                }

+            });

+		}

+		

+		//获取已连接设备列表

+		function fetchAttachedDevicesFunc(cb) {

+            target.attachedDevices([]);

+            var counter = 0;

+            var currDevices = [];

+            //RJ45 已连接设备

+            service.getAttachedCableDevices({}, function (data) {

+                counter++;

+                var devs = _.map(data.attachedDevices, function (elem) {

+                    elem.idx = _.uniqueId('wireless_');

+                    elem.hostName = pcUtil.getHostName(elem.hostName, elem.macAddress, hostNameList);

+                    elem.inChildGroup = _.contains(target.childGroupMac(), elem.macAddress);

+                    return elem;

+                });

+                if (counter != 1) {

+                    target.attachedDevices(_.flatten([currDevices, devs]));

+                    if (_.isFunction(cb)) {

+                        cb.apply(this);

+                    }

+                } else {

+                    currDevices = devs;

+                }

+            });

+			

+            //wifi 已连接设备

+            service.getCurrentlyAttachedDevicesInfo({}, function (data) {

+                counter++;

+                var devs = _.map(data.attachedDevices, function (elem) {

+                    elem.idx = _.uniqueId('wireless_');

+                    elem.hostName = pcUtil.getHostName(elem.hostName, elem.macAddress, hostNameList);

+                    elem.inChildGroup = _.contains(target.childGroupMac(), elem.macAddress);

+                    return elem;

+                });

+                if (counter != 1) {

+                    target.attachedDevices(_.flatten([currDevices, devs]));

+                    if (_.isFunction(cb)) {

+                        cb.apply(this);

+                    }

+                } else {

+                    currDevices = devs;

+                }

+            });

+		}

+		//儿童组设备 标签按钮事件

+		function backToMainHandlerFunc() {

+			target.currentPage(PAGES.MAIN);

+		}

+		

+		//移除按钮事件

+		function removeChildGroupHandlerFunc(ele) {

+            showLoading();

+            service.removeChildGroup(ele, function (data) {

+                target.fetchChildGroupList(function () {

+                    target.fetchAttachedDevices(function () {

+                        hideLoading();

+                    });

+                });

+            }, function (data) {

+                errorOverlay();

+            });

+        }

+		

+		//添加按钮事件

+		function addChildGroupHandlerFunc(data) {

+            var uMacAddr = service.getCurretnMAC();

+            if (uMacAddr != data.macAddress) {

+                addChildGroupFun(false, data);

+            } else {

+                showConfirm("parental_add_self", function () {

+                    addChildGroupFun(true, data);

+                })

+            }

+        }

+		

+		//取消编辑主机名按钮事件

+		function cancelEditHostNameHandlerFunc(eleData) {

+            target.dealElement(false, eleData.idx);

+        }

+		

+		//主机名编辑保存按钮事件

+		function saveHostNameHandlerFunc(ele) {

+            var $hostInput = $("#hostname_input_" + ele.idx);

+            var hostname = $.trim($hostInput.val());

+			if (hostname.indexOf(" ") == 0 || hostname.lastIndexOf(" ") == (hostname.length - 1) || /[\*\+\$\[&:,;<>'"\\`\]¥]{1,32}/.test(hostname)) {

+                showAlert('modify_hostname_invalid');

+                return false;

+            }else if (hostname == '') {

+                $(".promptErrorLabel", "#confirm-message-container").text($.i18n.prop("required"));

+                var $closestTD = $hostInput.closest('td').addClass('has-error');

+                addTimeout(function () {

+                    $closestTD.removeClass('has-error');

+                }, 5000);

+                showAlert('required');

+                return false;

+            }  

+            showLoading();

+            ele.hostname = hostname;

+            service.editHostName(ele, function () {

+                service.getHostNameList({}, function (hostNameData) {

+                    hostNameList = hostNameData.devices;

+                    target.fetchChildGroupList(function () {

+                        hideLoading();

+                    });

+                    target.fetchAttachedDevices();

+                });

+            }, function () {

+                errorOverlay();

+            });

+        }

+		

+		//主机名编辑按钮事件

+		function editHostNameHandlerFunc(ele) {

+            $("#hostname_input_" + ele.idx).val(ele.hostname);

+            target.dealElement(true, ele.idx);

+            return false;

+        }

+		//网站白名单添加按钮事件

+		function openAddSitePopoverHandlerFunc() {

+            var addNewSiteTmpl = $("#addNewSiteTmpl").html();

+            popover.open({

+                target: $("#openAddSiteBtn"),

+                html: addNewSiteTmpl,

+                width: "300px",

+                validation: addValidation

+            });

+        }

+		

+		//网站白名单列表选择框点击事件

+		function checkboxClickHandlerFunc(eleData, evt) {

+            addTimeout(function () {

+                target.selectedIds(getSelectedValues());

+            }, 100);

+        }

+		//获取网站白名单列表

+		function fetchSiteWhiteListFunc(cb) {

+            service.getSiteWhiteList({}, function (eledata) {

+                target.selectedIds([]);

+                target.siteList(eledata.siteList);

+                _.isFunction(cb) && cb.apply(this);

+            }, function () {

+                target.siteList([]);

+                _.isFunction(cb) && cb.apply(this);

+            });

+        }

+		

+		//网站白名单删除所有按钮事件

+		function removeAllWhiteSiteFunc() {

+            removeSiteWhiteItem(getAllCheckboxValues());

+        }

+		//网站白名单删除按钮事件

+		function removeSelectedWhiteSiteFunc() {

+            removeSiteWhiteItem(getSelectedValues());

+        }

+		//网站白名单移除按钮事件

+		function removeWhiteSiteFunc(ele, evt) {

+            removeSiteWhiteItem([ele.id]);

+        }

+		

+		//网站白名单添加框保存按钮事件

+		function saveSiteWhiteFunc(name, site) {

+            popover.hide();

+            var matched = _.find(target.siteList(), function (one) {

+                return one.site == site;

+            });

+            if (matched) {

+                showAlert("pc_link_exist", function () {

+                    setTimeout(function () {

+                        popover.show();

+                    }, 200);

+                });

+                return false;

+            }

+

+            showLoading();

+            service.saveSiteWhite({

+                name: name,

+                site: site

+            }, function () {

+                target.fetchSiteWhiteList(function () {

+                    popover.close();

+                    successOverlay();

+                });

+            }, function () {

+                target.fetchSiteWhiteList(function () {

+                    errorOverlay();

+                    popover.show();

+                });

+            });

+        }

+		

+		//上网时间设置时间表格事件绑定

+		function bindEventFunc() {

+            $("td:not('.col-head')", "#pc_time_limited_tbody").addClass('cursorhand').die().click(function () {

+                target.notSave(true);

+                $(this).toggleClass('active');

+            }).hover(function () {

+                var $this = $(this);

+                var w = $this.data('week');

+                var h = $this.data('hour');

+                $("tr:nth-child(" + (w + 1) + ") td:first-child", "#pc_time_limited_tbody").addClass('time_td_hover');

+                $("#col_" + h).addClass('time_td_hover');

+                if ($this.not('.active')) {

+                    $this.addClass('time_td_hover');

+                }

+            }, function () {

+                var $this = $(this);

+                var w = $this.data('week');

+                var h = $this.data('hour');

+                $("tr:nth-child(" + (w + 1) + ") td:first-child", "#pc_time_limited_tbody").removeClass('time_td_hover');

+                $("#col_" + h).removeClass('time_td_hover');

+                $this.removeClass('time_td_hover');

+            });

+        }

+		

+		//上网时间设置保存按钮事件

+		function saveTimeLimitedHandlerFunc() {

+            showLoading();

+            var tds = getSelectedTds();

+            var timeStr = getSavedData(tds);

+            service.saveTimeLimited({

+                time: timeStr

+            }, function () {

+                target.notSave(false);

+                successOverlay();

+            }, function () {

+                errorOverlay();

+            });

+        }

+		

+    }

+	

+		function dealElementFunc(flag, idx) {

+            if (flag == false) {

+                $("#edit_btn_" + idx + ",#hostname_txt_" + idx).show();

+                $("#save_btn_" + idx + ",#cancel_btn_" + idx + ",#hostname_input_" + idx).hide();

+            } else {

+                $("#edit_btn_" + idx + ",#hostname_txt_" + idx).hide();

+                $("#save_btn_" + idx + ",#cancel_btn_" + idx + ",#hostname_input_" + idx).show();

+            }

+        }

+

+		//获取时间限制信息

+		function fetchTimeLimitedFunc() {

+            service.getTimeLimited({}, function (ele) {

+                for (var ki in ele) {

+                    for (var idx = 0; idx < ele[ki].length; idx++) {

+                        var id = 'td_' + ki + '_' + ele[ki][idx];

+                        $("#" + id).addClass('active');

+                    }

+                }

+            }, function () {});

+        }

+

+    var pcUtil = {

+        getHostName: function (hostName, mac, hostNameList) {

+            var ele = _.find(hostNameList, function (ele) {

+                return ele.mac == mac;

+            });

+            return ele ? ele.hostname : hostName;

+        }

+    };

+	function getCheckboxValues(flag) {

+        var selectedValues = [];

+        $(":checkbox" + (flag ? ":checked" : ""), "#pb_white_list").each(function (i, n) {

+            selectedValues.push(n.value)

+        });

+        return selectedValues;

+    }

+    //获取列表中被选中项的value值

+     

+    function getSelectedValues() {

+        return getCheckboxValues(true);

+    }

+    function getAllCheckboxValues() {

+        return getCheckboxValues(false);

+    }

+    

+    //增加网站白名单表单提交函数绑定和校验规则设置

+     

+    function addValidation() {

+        $('#whiteSiteAddForm').validate({

+            submitHandler: function () {

+                var name = $("#siteName").val();

+                var site = $("#siteLink").val();

+                pcVm.saveSiteWhite(name, site);

+            },

+            rules: {

+                siteName: 'siteName_check',

+                siteLink: 'siteLink_check'

+            }

+        });

+    }

+	

+    function getSavedData(timeDatas) {

+        var ret = '';

+        for (var ki in timeDatas) {

+            var hours = _.sortBy(timeDatas[ki], function (n) {

+                return n;

+            });

+            if (timeDatas[ki].length) {

+                ret += ki + '+';

+                ret += hours.join(',');

+                ret += ';'

+            }

+        }

+        return ret.substring(0, ret.length - 1);

+    }

+    //获取时间表格选中的时间

+     

+    function getSelectedTds() {

+        var defaultValue = {

+            '0': [],

+            '1': [],

+            '2': [],

+            '3': [],

+            '4': [],

+            '5': [],

+            '6': []

+        };

+        $("td.active", "#pc_time_limited_tbody").each(function (i, n) {

+            var $this = $(n);

+            var week = $this.data('week');

+            var hour = $this.data('hour');

+            defaultValue[week].push(hour);

+        });

+        return defaultValue;

+    }

+

+	function convertHour(hour) {

+        if (hour <= 16) {

+            return hour + 7;

+        } else {

+            return hour - 17;

+        }

+    }

+    //初始化时间表格

+     

+    function initTableData() {

+        $("tr", "#pc_time_limited_tbody").each(function (idx, n) {

+            var $tr = $(n);

+            $("td:not(:first)", $tr).each(function (j, m) {

+                var $td = $(m);

+                var hour = convertHour(j);

+                $td.attr({

+                    id: 'td_' + idx + '_' + hour

+                }).data({

+                    week: idx,

+                    hour: hour

+                });

+            });

+        });

+        $("td.active", "#pc_time_limited_tbody").removeClass("active");

+        $("thead td:not(:first)", "#pc_time_limited_form").each(function (idx, n) {

+            var hour = convertHour(idx);

+            $(n).attr({

+                id: 'col_' + hour

+            });

+        });

+        pcVm.notSave(false);

+    }

+

+    

+    //页面初始化

+     

+    function initialize() {

+       

+        pcVm = new ParentalControlVM();

+		bindContainer(pcVm);

+    }

+	function bindContainer(pcVm)

+	{

+		var container = $('#container');

+        ko.cleanNode(container[0]);

+        ko.applyBindings(pcVm, container[0]);

+	}

+

+    return {

+        init: initialize

+    };

+});

+

+define("firewall_dmz_set","underscore jquery knockout set service".split(" "),

+    function ( _, $, ko, config, service) {

+

+    //system dmz setting VM

+     

+    function DmzSettingVM() {

+        var target = this;

+        var dmzInfo = getDmzSetting();

+        target.dmzSetting = ko.observable(dmzInfo.dmzSetting);

+        target.ipAddress = ko.observable(dmzInfo.ipAddress);

+        target.isDataCard = config.PRODUCT_TYPE == 'DATACARD';

+

+        target.clear = clearFunc;

+        //应用按钮事件

+         

+        target.save = saveFunc;

+		

+		function saveFunc() {

+			showLoading();

+			var params = {};

+			params.dmzSetting = target.dmzSetting();

+			params.ipAddress = target.ipAddress();

+			service.setDmzSetting(params, function (result) {

+				if (result.result != "success") {

+					errorOverlay();

+				} else {

+					target.clear();

+					successOverlay();

+				}

+			});

+		}

+		

+    }

+	

+	function clearFunc() {

+		initialize();

+    }

+	

+	

+    //获取dmz 信息

+     

+    function getDmzSetting() {

+        return service.getDmzSetting();

+    }

+

+    //初始化DmzSettingVM model

+     

+    function initialize() {

+        

+        var dmzVm = new DmzSettingVM();

+        bindContainer(dmzVm);

+    }

+	function bindContainer(dmzVm){

+		var container = $('#container');

+        ko.cleanNode(container[0]);

+		ko.applyBindings(dmzVm, container[0]);

+        $('#dmzSettingForm').validate({

+            submitHandler: function () {

+                dmzVm.save();

+            },

+            rules: {

+                txtIpAddress: 'dmz_ip_check'

+            }

+        });

+	}

+

+    return {

+        init: initialize

+    };

+});

+

+define("firewall","underscore jquery knockout set service".split(" "),

+

+function(_, $, ko, config, service) {

+

+    function FirewallVM() {

+        var target = this;

+		target.hasDdns = config.DDNS_SUPPORT;

+		target.hasUpdateCheck = config.HAS_UPDATE_CHECK;

+		target.hasUrlFilter = config.HAS_URL;

+		target.hasUssd = config.HAS_USSD;

+		target.hasUpnp = config.HAS_UPNP;

+    }

+

+	function initialize() {        

+        var fwVm = new FirewallVM();

+		bindingContainer(fwVm);

+    }

+	function bindingContainer(fwVm)

+	{

+		var container = $('#container');

+        ko.cleanNode(container[0]);

+        ko.applyBindings(fwVm, container[0]);

+	}

+	return {

+		init : initialize

+	};

+});

+

+define("ddns","underscore jquery knockout set service".split(" "), function (_, $, ko, config, service) {

+    var ddnsSetModes = _.map(config.DDNSSetMode, newOption);

+    var ddnsProviderList = _.map(config.DDNSDDP, newOption);

+    var ddns_mode_select = _.map(config.ddns_Modeselect, newOption);

+    function newOption(optItem) {

+        return new Option(optItem.name, optItem.value);

+    }

+    function DdnsViewModel() {

+        var target = this;

+        target.hasUssd = config.HAS_USSD;

+        target.hasUpdateCheck = config.HAS_UPDATE_CHECK;

+        var data = service.getDdnsParams();

+        target.ddnsSetModes = ko.observableArray(ddnsSetModes);

+        target.ddnsProviderList = ko.observableArray(ddnsProviderList);

+        target.ddns_mode_select = ko.observableArray(ddns_mode_select);

+        target.currentMode = ko.observable(data.DDNS_Enable);

+        target.currentModeselect = ko.observable(data.DDNS_Mode);

+        target.currentProviderList = ko.observable("dyndns.org");

+        $.each(config.DDNSDDP, function (i, n) {

+            if (data.DDNSProvider == n.value) {

+                target.currentProviderList(data.DDNSProvider);

+            }

+        });

+        target.DDNSaccount = ko.observable(data.DDNSAccount);

+        target.DDNSpasswd = ko.observable(data.DDNSPassword);

+        target.DDNSname = ko.observable(data.DDNS);

+        target.DDNS_HashValue = ko.observable(data.DDNS_Hash_Value);

+        target.isddnsStatusTrans = ko.observable();

+        target.isEnableSet = ko.observable();

+        target.isHashValue = ko.observable();

+        target.isddnsaccount = ko.observable();

+        target.isddnspasswd = ko.observable();

+        target.isDDNSStatus = ko.observable();

+        target.isddnsdomainName = ko.observable();

+        target.isNone = ko.observable();

+        target.onStates = ko.observable();

+        target.showPassword_ddns = ko.observable(false);

+        target.showPasswordHandler_ddns = showPasswordHandler_ddns;

+        changeddnsProviderList();

+        target.changeDdnsProvider = changeDdnsProviderFunc;

+        changeSetDdnsMode();

+        target.changeSetDdnsMode = changeSetDdnsModeFunc;

+        updateScanDdnsStatus();

+        target.apply = applyFunc;

+        function updateScanDdnsStatus() {

+            var trans = "";

+            $.getJSON("/reqproc/proc_get", {

+                cmd: "getddns_status",

+                "_": new Date().getTime()

+            }, function (data) {

+                if (data.getddns_status == "0") {

+                    trans = "register successful";

+                    target.onStates(true);

+                } else if (data.getddns_status == "1") {

+                    trans = "login error";

+                    target.onStates(true);

+                } else if (data.getddns_status == "2") {

+                    trans = "network error";

+                    target.onStates(true);

+                } else if (data.getddns_status == "3") {

+                    trans = "registering";

+                    target.onStates(true);

+                } else if (data.getddns_status == "4") {

+                    trans = "not registered";

+                    target.onStates(true);

+                } else if (data.getddns_status == "5") {

+                    trans = "error registering";

+                    target.onStates(true);

+                } else if (data.getddns_status == "-1") {

+                    trans = "";

+                    target.onStates(true);

+                }

+                target.isddnsStatusTrans($.i18n.prop(trans));

+                addTimeout(updateScanDdnsStatus, 2000);

+            });

+        }

+        function changeSetDdnsMode() {

+            if (target.currentMode() != "1") {

+                target.isEnableSet(false);

+            } else {

+                target.isEnableSet(true);

+            }

+            return true;

+        }

+        function changeSetDdnsModeFunc() {

+            changeSetDdnsMode();

+        }

+        function showPasswordHandler_ddns() {

+            $("#ddns_secretcode_input").parent().find(".error").hide();

+            var checkbox = $("#showPassword_ddns:checked");

+            if (checkbox && checkbox.length == 0) {

+                target.showPassword_ddns(true);

+            } else {

+                target.showPassword_ddns(false);

+            }

+        }

+        function changeDdnsProviderFunc() {

+            if (data.DDNSProvider != target.currentProviderList()) {

+                target.DDNSaccount("");

+                target.DDNSpasswd("");

+                target.DDNSname("");

+            } else {

+                target.DDNSaccount(data.DDNSAccount);

+                target.DDNSpasswd(data.DDNSPassword);

+                target.DDNSname(data.DDNS);

+            }

+            changeddnsProviderList();

+        }

+        function changeddnsProviderList() {

+            if (target.currentProviderList() != "none") {

+                target.isddnsaccount(true);

+                target.isddnspasswd(true);

+                target.isddnsdomainName(true);

+                target.isHashValue(true);

+                target.isDDNSStatus(true);

+            } else {

+                target.isddnsaccount(false);

+                target.isddnspasswd(false);

+                target.isddnsdomainName(false);

+                target.isHashValue(false);

+                target.isDDNSStatus(false);

+            }

+            if (target.currentProviderList() != "freedns.afraid.org") {

+                target.isHashValue(false);

+            } else {

+                target.isHashValue(true);

+            }

+            return true;

+        }

+        function applyFunc() {

+            showLoading();

+            var params = {};

+            params.goformId = "DDNS";

+            params.DDNS_Enable = target.currentMode();

+            if (target.currentMode() == "1") {

+                params.DDNS_Mode = target.currentModeselect();

+                params.DDNSProvider = target.currentProviderList();

+                if (target.currentProviderList() != "none") {

+                    params.DDNS = target.DDNSname();

+                    params.DDNSPassword = target.DDNSpasswd();

+                    params.DDNSAccount = target.DDNSaccount();

+                }

+                if (target.currentProviderList() == "freedns.afraid.org") {

+                    params.DDNS_Hash_Value = target.DDNS_HashValue();

+                }

+            }

+            service.setDDNSForward(params, function (result) {

+                if (result.result == "success") {

+                    successOverlay();

+                    data = service.getDdnsParams();

+                } else {

+                    errorOverlay();

+                }

+            });

+        }

+    }

+    function initialize() {

+        var container = $('#container');

+        ko.cleanNode(container[0]);

+        var vm = new DdnsViewModel();

+        ko.applyBindings(vm, container[0]);

+        $("#ddnsForm").validate({

+            submitHandler: function () {

+                vm.apply();

+            },

+            rules: {

+                ddns_secretcode_input: "secretcode_check",

+                DDNS_Hash_Value: "ddns_hashvalue_check",

+                ddns_secretcode_inputshow: "secretcode_check"

+            },

+            errorPlacement: function (error, element) {

+                var id = element.attr("id");

+                if (id == "ddns_secretcode_input" || id == "ddns_secretcode_inputshow") {

+                    error.insertAfter("#lblShowPassword");

+                } else {

+                    error.insertAfter(element);

+                }

+            }

+        });

+    }

+    return {

+        init: initialize

+    };

+});

+

+

+//选网模块

+ 

+define("network_net_select","underscore jquery knockout set service".split(" "),

+    function (_, $, ko, config, service) {

+

+    var selectModes = _.map(config.AUTO_MODES, function (item) {

+        return new Option(item.name, item.value);

+    });

+

+    //选网功能view model

+     

+    function NetSelectVM() {

+        var target = this;

+

+        target.networkList = ko.observableArray([]);

+        target.selectNetwork = ko.observable('');

+        target.enableFlag = ko.observable(true);

+        target.types = ko.observableArray(selectModes);

+        target.selectedType = ko.observable();

+        target.selectMode = ko.observable();

+

+		target.networkText = networkTextFunc;

+		

+		target.networkStatusId = networkStatusIdFunc;

+		

+        target.networkStatus = networkStatusFunc;

+

+        target.subnetworkType = subnetworkTypeFunc;

+

+		target.networkType = networkTypeFunc;

+

+        target.operatorName = operatorNameFunc;

+

+        target.networkValue = networkValueFunc;

+

+        target.networkTypeId = networkTypeIdFunc;

+

+        target.subnetTypeId = subnetTypeIdFunc;

+       //手动搜网.

+         

+        target.search = searchFunc;

+

+        //自动选网时设置网络模式.

+         

+        target.save = saveFunc;

+

+        target.checkEnable = checkEnableFunc;

+

+        //注册选择的网络.

+         

+        target.register = registerFunc;

+

+        //init data

+        target.checkEnable();

+        var info = getNetSelectInfo();

+        if ("manual_select" == info.net_select_mode || "manual_select" == info.m_netselect_save) {

+            target.selectMode("manual_select");

+        } else {

+            target.selectMode("auto_select");

+        }

+

+        target.selectedType(info.net_select);

+		

+		//注册选择的网络.

+		function registerFunc() {

+            showLoading('registering_net');

+            var networkToSet = target.selectNetwork().split(',');

+            service.setNetwork(networkToSet[0], parseInt(networkToSet[1]), parseInt(networkToSet[2]), function (result) {

+                if (result) {

+                    target.networkList([]);

+                    var autoType = getNetSelectInfo();

+                    target.selectedType(autoType.net_select);

+                    successOverlay();

+                } else {

+                    errorOverlay();

+                }

+            });

+        }

+		

+		function checkEnableFunc() {

+            var status = service.getStatusInfo();

+            if (status.connectStatus == "ppp_connected" || status.connectStatus == "ppp_connecting") {

+                target.enableFlag(false);

+            } else {

+                target.enableFlag(true);

+            }

+        }

+		

+		//自动选网时设置网络模式.

+		function saveFunc() {

+            showLoading();

+

+            //AutoSelect call SetBearerPreference

+            var params = {};

+            params.strBearerPreference = target.selectedType();

+            service.setBearerPreference(params, function (result) {

+                if (result.result == "success") {

+                    target.networkList([]);

+                    successOverlay();

+                } else {

+                    errorOverlay();

+                }

+            });

+        }

+		

+		//手动搜网.

+		function searchFunc() {

+            showLoading('searching_net');

+            service.scanForNetwork(function (result, networkList) {

+                hideLoading();

+                if (result) {

+                    target.networkList(networkList);

+                    for (var i = 0; i < networkList.length; i++) {

+                        var n = networkList[i];

+                        if (n.nState == '2') {

+                            target.selectNetwork(n.strNumeric + ',' + n.nRat + ',' + n.SubAct);

+                            return;

+                        }

+                    }

+                } else {

+                    target.networkList([]);

+                }

+            });

+        }

+		

+		function subnetTypeIdFunc(data) {

+            return getSubNetworkTypeTog(data.nRat, data.SubAct);

+        }

+		

+		function networkTypeIdFunc(data) {

+            return getNetworkType(data.nRat);

+        }

+		

+		function networkValueFunc(data) {

+            var result = [];

+            result.push(data.strNumeric); //strNumeric

+            result.push(data.nRat); //nRat

+            result.push(data.SubAct);

+            return result.join(',');

+        }

+		

+		function operatorNameFunc(data) {

+            return data.strShortName;

+        }

+		

+		function networkTypeFunc(data) {

+            var result = getNetworkType(data.nRat);

+            if (result == "auto")

+                result = $.i18n.prop("auto");

+            return result;

+        }

+		

+		function subnetworkTypeFunc(data) {

+            var result = getSubNetworkTypeTog(data.nRat, data.SubAct);

+            return result;

+        }

+		

+		function networkStatusFunc(data) {

+            return $.i18n.prop(getNetworkStatusTog(data.nState));

+        }

+		

+		function networkStatusIdFunc(data) {

+            return getNetworkStatusTog(data.nState);

+        }

+		

+		function networkTextFunc(data) {

+            return data.strNumeric;

+        }

+

+    }

+

+    //获取网络选择信息.

+     

+    function getNetSelectInfo() {

+        return service.getNetSelectInfo();

+    }

+

+    //搜网结果中的状态转换为对应的语言项.

+     

+    function getNetworkStatusTog(status) {

+        if ("3" == status) {

+            return "forbidden";

+        } else if ("2" == status) {

+            return "current";

+        } else if ("1" == status) {

+            return "available";

+        }else if ("0" == status) {

+            return "unknown";

+        }

+    }

+	//子网络类型转换.

+     

+    function getSubNetworkTypeTog(type, subtype) {

+        var type_3g = [2, 4, 5, 6, 8];

+        if ("1" == subtype) {

+            if ("7" == type) {

+                subtype = "FDD-LTE";

+            } else if ($.inArray(type, type_3g) != -1) {

+                subtype = "WCDMA";

+            }else {

+                subtype = "GSM";

+            }

+        } else if ("0" == subtype) {

+            if ("7" == type) {

+                subtype = "TD-LTE";

+            } else if ($.inArray(type, type_3g) != -1) {

+                subtype = "TD-SCDMA";

+            } else {

+                subtype = "GSM";

+            }

+        } else {

+            subtype = "";

+        }

+        return subtype;

+    }

+    //网络类型转换.

+     

+    function getNetworkType(type) {

+        if ("7" == type) {

+            return "4G";

+        } else if ("2" == type) {

+            return "3G";

+        } else if ("0" == type) {

+            return "2G";

+        } else {

+            return "auto";

+        }

+    }

+

+    function bindContainer(vm){

+	

+        var container = $('#container');

+        ko.cleanNode(container[0]);

+        ko.applyBindings(vm, container[0]);

+	}

+

+    //初始化选网功能view model.

+     

+    function initialize() {

+        var vm = new NetSelectVM();

+		bindContainer(vm);

+        addInterval(vm.checkEnable, 1000);

+    }

+

+    return {

+        init: initialize

+    };

+});

+define("locknet","jquery knockout service jquery set main".split(" "),

+    function ($, ko, service, config, home) {

+

+    function initialize() {

+        var container = $('#container')[0];

+        ko.cleanNode(container);

+        var vm = new locknetViewMode();

+        ko.applyBindings(vm, container);

+

+        $("#frmNetworkLock").validate({

+            submitHandler: function () {

+                vm.unlock();

+            },

+            rules: {

+                txtLockNumber: "unlock_code_check"

+            }

+        });

+    }

+

+    function locknetViewMode() {

+        var target = this;

+        var curCableMode = false;

+        target.isCPE = config.PRODUCT_TYPE == 'CPE';

+        target.hasRj45 = config.RJ45_SUPPORT;

+        target.hasSms = config.HAS_SMS;

+        target.hasPhonebook = config.HAS_PHONEBOOK;

+        target.isSupportSD = config.SD_CARD_SUPPORT;

+        if (config.WIFI_SUPPORT_QR_SWITCH == false) {

+            target.showQRCode = config.WIFI_SUPPORT_QR_CODE;

+        } else {

+            var wifiInfo = service.getWifiBasic();

+            target.showQRCode = config.WIFI_SUPPORT_QR_CODE && wifiInfo.show_qrcode_flag;

+        }

+        if(config.WIFI_SUPPORT_QR_CODE){

+            target.qrcodeSrc = './pic/qrcode_ssid_wifikey.png?_=' + $.now();

+        } else {

+            target.qrcodeSrc = './pic/res_blacktrans.png';

+        }

+        target.hasParentalControl = ko.observable(config.HAS_PARENTAL_CONTROL && curCableMode);

+        target.deviceInfo = ko.observable([]);

+        target.isHomePage = ko.observable(false);

+        if (window.location.hash == "#main") {

+            target.isHomePage(true);

+        }

+

+        target.supportUnlock = config.NETWORK_UNLOCK_SUPPORT;

+        target.unlockCode = ko.observable();

+

+        var info = service.getNetworkUnlockTimes();

+        target.times = ko.observable(info.unlock_nck_time);

+

+        //显示工作模式设置窗口

+        target.showOpModeWindow = showOpModeWindowFunc;

+		

+        target.isLoggedIn = ko.observable(false);

+        target.enableFlag = ko.observable(false);

+        //解锁

+        target.unlock = unlockFunc;

+

+        //更新工作模式状态

+        target.refreshOpmodeInfo = refreshOpmodeInfoFunc;

+		

+        //定时检查工作模式状态

+        if (target.hasRj45) {

+            target.refreshOpmodeInfo();

+            addInterval(function () {

+                target.refreshOpmodeInfo();

+            }, 1000);

+        }

+		

+		//更新工作模式状态

+		function refreshOpmodeInfoFunc() {

+            var obj = service.getStatusInfo();

+            target.isLoggedIn(obj.isLoggedIn);

+

+            if (!curCableMode && checkCableMode(obj.blc_wan_mode)) { //如果有线,则重新加载

+                window.location.reload();

+                return;

+            }

+

+            curCableMode = checkCableMode(obj.blc_wan_mode);

+            target.hasParentalControl(config.HAS_PARENTAL_CONTROL && curCableMode);

+            if (curCableMode && obj.ethWanMode.toUpperCase() == "DHCP") {

+                target.enableFlag(true);

+            } else if ((!curCableMode && obj.connectStatus != "ppp_disconnected") || (curCableMode && obj.rj45ConnectStatus != "idle" && obj.rj45ConnectStatus != "dead")) {

+                target.enableFlag(false);

+            } else {

+                target.enableFlag(true);

+            }

+            var getMode = (obj.blc_wan_mode == "AUTO_PPP" || obj.blc_wan_mode == "AUTO_PPPOE") ? "AUTO" : obj.blc_wan_mode;

+            var currMode = "";

+            switch (getMode) {

+			case "PPP":

+                currMode = "opmode_gateway";

+                break;

+			case "PPPOE":

+                currMode = "opmode_cable";

+                break;

+            case "AUTO":

+                currMode = "opmode_auto";

+                break;

+            default:

+                break;

+            }

+            $("#opmode").attr("data-trans", currMode).text($.i18n.prop(currMode));

+        }

+		

+		//解锁

+		function unlockFunc() {

+            showLoading();

+            service.unlockNetwork({

+                unlock_network_code: target.unlockCode()

+            }, function (data) {

+                target.unlockCode("");

+                if (data && data.result == "success") {

+                    successOverlay();

+                    if (window.location.hash == "#main") {

+                        setTimeout(function () {

+                            window.location.reload();

+                        }, 500);

+                    } else {

+                        window.location.hash = "#main";

+                    }

+                } else {

+                    var info = service.getNetworkUnlockTimes();

+                    target.times(info.unlock_nck_time);

+                    errorOverlay();

+                }

+            })

+        }

+		

+		//显示工作模式设置窗口

+		function showOpModeWindowFunc() {

+            showSettingWindow("change_mode", "opmode_popup", "opmode_popup", 400, 300, function () {});

+        }

+    }

+

+    return {

+        init: initialize

+    };

+});

+

+// RJ45联网设置模块

+ 

+define("network_dial_set_cpe","underscore jquery knockout set service".split(" "),

+function(_, $, ko, config, service) {

+	var dialActions = _.map(config.dialActions, function(elem){

+		return new Option(elem.name, elem.value);

+	});

+	

+	var dialModes = _.map(config.pppoeModes, function(elem) {

+		return new Option(elem.name, elem.value);

+	});

+		

+    var checkStatusTimer = 0;

+    var checkConCounter = 0;

+    var timeoutTipShowed = false;

+

+    // 联网设置view model.

+     

+	function PPPoEViewModel() {

+		var pppObj = service.getPppoeParams();

+        var ethParams = pppObj;

+		var target = this;

+		

+		target.staticNoticeShow = ko.observable();

+		target.dhcpNoticeShow = ko.observable();

+		target.pppoeNoticeShow = ko.observable();

+		target.autoNoticeShow = ko.observable();

+		target.staticNotice = ko.observable();

+		target.dhcpNotice = ko.observable();

+		target.pppoeNotice = ko.observable();

+		target.autoNotice = ko.observable();

+		target.dhcpNoticeText = ko.observable();

+		target.staticNoticeText = ko.observable();

+		target.pppoeNoticeText = ko.observable();

+        target.autoNoticeText = ko.observable();		

+		target.currentMode = ko.observable(pppObj.ethwan_mode);//auto dhcp pppoe static

+		target.showPassword = ko.observable(false);

+		target.modes = ko.observableArray(dialModes);

+		target.isPppoeMode = ko.observable(false);

+		target.isStaticMode = ko.observable(false);

+		target.isAutoMode = ko.observable(false);

+		target.action = ko.observable();

+		target.btnTrans = ko.observable();

+		target.enableFlag = ko.observable();

+		target.isShowDisbtn = ko.observable();

+		target.isShowCancelbtn = ko.observable();

+		

+		if(pppObj.rj45_state == "dead"){

+			checkRj45DeadTip();

+		} else if(pppObj.rj45_state == "connect"){

+			timeoutTipShowed = true;

+			setRj45CheckTimer("connect");

+		} else if(pppObj.rj45_state == "working"){

+			setRj45WorkingTip();

+		}

+		

+		target.user = ko.observable(pppObj.pppoe_username);

+		target.password = ko.observable(pppObj.pppoe_cc);

+		target.autoUser = ko.observable(pppObj.pppoe_username);

+		target.autoPassword = ko.observable(pppObj.pppoe_cc);

+		target.pppMode = ko.observable(pppObj.ethwan_dialmode);

+		initContronler();

+		

+

+		//下拉框选择改变下面DIV模块

+		target.changeModeDiv = changeModeDivFunc;

+				

+		target.radioHandler = radioHandlerFunc;

+				

+		target.primaryDNS = ko.observable(pppObj.static_wan_primary_dns);

+		target.secondaryDNS = ko.observable(pppObj.static_wan_secondary_dns);

+		target.ipAddress = ko.observable(pppObj.static_wan_ipaddr);

+		target.subnetMask = ko.observable(pppObj.static_wan_netmask);

+		target.defaultGateway = ko.observable(pppObj.static_wan_gateway);

+		

+		addInterval(function(){

+			ethParams = service.getPppoeParams();

+			pppObj.rj45_state = ethParams.rj45_state;

+			initContronler();

+		}, 1000);

+		

+        // 取消连接按钮事件.

+         					

+		target.cancelConnect = cancelConnectFunc;

+		

+        // 应用按钮事件.

+         		

+		target.save = saveFunc;

+		

+		 //密码显示事件

+        target.showPasswordHandler = function () {

+            var checkbox = $("#showPassword:checked");

+            if (checkbox && checkbox.length == 0) {

+                target.showPassword(true);

+            } else {

+                target.showPassword(false);

+            }

+        };

+		

+        // 更新当前界面状态、按钮、提示语等.

+         			

+		function initContronler() {	

+            checkRj45DeadTip();		

+			if(target.currentMode() == "PPPOE"){

+				target.isPppoeMode(true);

+				target.isStaticMode(false);

+				target.isAutoMode(false);

+				target.staticNoticeShow(false);

+				target.dhcpNoticeShow(false);	

+				target.autoNoticeShow(false);	

+			} else if(target.currentMode() == "AUTO"){

+				target.isStaticMode(false);

+				target.isPppoeMode(false);

+				target.isAutoMode(true);

+				target.dhcpNoticeShow(false);

+				target.pppoeNoticeShow(false);

+				target.staticNoticeShow(false);

+			} else if(target.currentMode() == "STATIC"){

+				target.isStaticMode(true);

+				target.isPppoeMode(false);

+				target.isAutoMode(false);

+				target.dhcpNoticeShow(false);

+				target.pppoeNoticeShow(false);

+				target.autoNoticeShow(false);

+			} else{

+				target.isStaticMode(false);

+				target.isPppoeMode(false);

+				target.isAutoMode(false);

+				target.staticNoticeShow(false);

+				target.pppoeNoticeShow(false);

+                target.autoNoticeShow(false);					

+			}

+			if(ethParams.ethwan_dialmode != "auto_dial" && (pppObj.rj45_state == "working" || pppObj.rj45_state =="connect") ){

+				target.enableFlag(false);

+			} else {

+				target.enableFlag(true);

+			}

+			if(pppObj.rj45_state == "connect"){

+				if(target.pppMode() == "auto_dial"){

+					target.action("connect");

+				}else{

+					target.action("disconnect");

+				}					

+			} else if(pppObj.rj45_state == "working"){

+				target.action("disconnect");

+			}else{

+				target.action("connect");

+			}

+			//应用/连接按钮

+			if(target.pppMode() != "auto_dial" && target.currentMode() == ethParams.ethwan_mode){

+				target.btnTrans("connect");

+			} else{

+				target.btnTrans("apply");

+			}

+			if(pppObj.rj45_state != "idle"){

+				$("#pppoeApply").attr("disabled", true);

+		    }else {

+				$("#pppoeApply").attr("disabled", false);

+            }

+			

+			//取消/断开按钮

+			target.isShowDisbtn(target.pppMode() != "auto_dial" && pppObj.rj45_state == "working");

+			target.isShowCancelbtn(target.pppMode() != "auto_dial" && pppObj.rj45_state == "connect");

+			

+			$("#pppoeApply").translate();

+		}

+        // 设置后通过定时检查rj45_state状态,判断连接或断开操作结果.

+         		

+	    function setRj45CheckTimer(action){

+            checkStatusTimer && window.clearInterval(checkStatusTimer);

+            if("connect" != action){				

+                checkStatusTimer = addInterval(function () {

+                    checkDisconnectStatus();

+                }, 2000);

+            }else{

+                if(target.currentMode() == "PPPOE"){

+                    target.pppoeNoticeShow(true);

+                    target.pppoeNotice("pppoe_processing");

+                    target.pppoeNoticeText($.i18n.prop("pppoe_processing"));

+                } else if(target.currentMode() == "STATIC"){

+                    target.staticNoticeShow(true);

+                    target.staticNotice("static_processing");

+                    target.staticNoticeText($.i18n.prop("static_processing"));

+                } else if(target.currentMode() == "DHCP"){

+                    target.dhcpNoticeShow(true);

+                    target.dhcpNotice("dyn_processing");

+                    target.dhcpNoticeText($.i18n.prop("dyn_processing"));

+                }else{

+                    target.autoNoticeShow(true);

+                    target.autoNotice("auto_processing");

+                    target.autoNoticeText($.i18n.prop("auto_processing"));

+                }

+                checkStatusTimer = addInterval(function () {

+                    checkConnectionStatus();

+                }, 2000);

+            }			

+        }

+        // 设置后通过定时检查rj45_state状态,判断连接操作结果.

+         			

+        function checkConnectionStatus(){

+            if(checkConCounter < 1){

+				checkConCounter++;

+				return;

+            }

+            if(pppObj.rj45_state == "connect"){

+                if(target.currentMode() != ethParams.ethwan_mode){

+                    if(target.currentMode() == "AUTO"){

+                        target.autoNoticeShow(true);

+                    }else if(target.currentMode() == "PPPOE"){

+                        target.pppoeNoticeShow(true);

+                    }else if(target.currentMode() == "STATIC"){

+                        target.staticNoticeShow(true);

+                    }else if(target.currentMode() == "DHCP"){

+                        target.dhcpNoticeShow(true);

+                    }

+                }

+                if(checkConCounter > 6){

+                    if(timeoutTipShowed == false){

+                        timeoutTipShowed = true;

+                        showAlert("ussd_operation_timeout");

+                    }

+                }

+                checkConCounter++;

+            } else if (pppObj.rj45_state == "working") {

+                hideLoading();

+                setRj45WorkingTip();

+                window.clearInterval(checkStatusTimer);						

+            } else if (pppObj.rj45_state == "dead") {

+				hideLoading();

+				checkRj45DeadTip();

+                window.clearInterval(checkStatusTimer);

+            } else if(pppObj.rj45_state == "idle"){

+                hideLoading();

+                if(target.currentMode() == "DHCP" && ethParams.ethwan_mode == "DHCP") {

+                    timeoutTipShowed == false && target.dhcpNoticeShow(true);

+                    target.dhcpNotice("dyn_fail");

+                    target.dhcpNoticeText($.i18n.prop("dyn_fail"));

+                }

+                if(target.currentMode() == "STATIC" && ethParams.ethwan_mode == "STATIC") {

+                    timeoutTipShowed == false && target.staticNoticeShow(true);

+                    target.staticNotice("static_fail");

+                    target.staticNoticeText($.i18n.prop("static_fail"));

+                }

+                if(target.currentMode() == "PPPOE" && ethParams.ethwan_mode == "PPPOE") {

+                    timeoutTipShowed == false && target.pppoeNoticeShow(true);

+                    target.pppoeNotice("pppoe_fail");

+                    target.pppoeNoticeText($.i18n.prop("pppoe_fail"));

+                }

+                if(target.currentMode() == "AUTO" && ethParams.ethwan_mode == "AUTO") {

+                    timeoutTipShowed == false && target.autoNoticeShow(true);

+                    target.autoNotice("auto_fail");

+                    target.autoNoticeText($.i18n.prop("auto_fail"));

+                }

+                window.clearInterval(checkStatusTimer);

+            }   else{

+                hideLoading();

+				window.clearInterval(checkStatusTimer);

+			}

+        }

+		// 设置连接成功时提示语状态.

+         		

+        function setRj45WorkingTip(){

+            if(target.currentMode() == ethParams.ethwan_mode){

+                if(target.currentMode() == "AUTO") {

+                    target.autoNoticeShow(true);

+                    target.autoNotice("auto_success");

+                    target.autoNoticeText($.i18n.prop("auto_success"));

+                }else if(target.currentMode() == "PPPOE") {

+                    target.pppoeNoticeShow(true);

+                    target.pppoeNotice("pppoe_success");

+                    target.pppoeNoticeText($.i18n.prop("pppoe_success"));

+                }else if(target.currentMode() == "STATIC") {

+                    target.staticNoticeShow(true);

+                    target.staticNotice("static_success");

+                    target.staticNoticeText($.i18n.prop("static_success"));

+                }else if(target.currentMode() == "DHCP" ) {

+                    target.dhcpNoticeShow(true);

+                    target.dhcpNotice("dyn_success");

+                    target.dhcpNoticeText($.i18n.prop("dyn_success"));

+                }

+            }

+        }

+		

+		// 设置网线断开提示语状态.

+         		

+        function checkRj45DeadTip(){

+            if(pppObj.rj45_state != "dead"){

+                if(target.currentMode() == "AUTO"  && target.autoNotice() == "pppoe_msg") {

+                    target.autoNoticeShow(false);

+                }else if(target.currentMode() == "PPPOE"  && target.pppoeNotice() == "pppoe_msg") {

+                    target.pppoeNoticeShow(false);

+                }else if(target.currentMode() == "STATIC"  && target.staticNotice() == "pppoe_msg") {

+                    target.staticNoticeShow(false);

+                }else if(target.currentMode() == "DHCP" && target.dhcpNotice() == "pppoe_msg") {

+                    target.dhcpNoticeShow(false);

+                }				

+                

+            } else{

+				target.dhcpNotice("pppoe_msg");

+                target.dhcpNoticeText($.i18n.prop("pppoe_msg"));

+                target.staticNotice("pppoe_msg");

+                target.staticNoticeText($.i18n.prop("pppoe_msg"));

+                target.pppoeNotice("pppoe_msg");

+                target.pppoeNoticeText($.i18n.prop("pppoe_msg"));

+                target.autoNotice("pppoe_msg");

+                target.autoNoticeText($.i18n.prop("pppoe_msg"));

+                if(target.currentMode() == "AUTO") {

+                    target.autoNoticeShow(true);

+                }else if(target.currentMode() == "PPPOE") {

+                    target.pppoeNoticeShow(true);

+                }else if(target.currentMode() == "STATIC") {

+                    target.staticNoticeShow(true);

+                }else if(target.currentMode() == "DHCP") {

+                    target.dhcpNoticeShow(true);

+                }

+            }            

+		}

+        // 设置后通过定时检查rj45_state状态,判断断开操作结果.

+         		

+        function checkDisconnectStatus(){

+            if(checkConCounter < 1){

+                checkConCounter++;

+            } else if (pppObj.rj45_state != "working" && pppObj.rj45_state != "connect") {

+                target.dhcpNoticeShow(false);

+                target.staticNoticeShow(false);

+                target.pppoeNoticeShow(false);

+                target.autoNoticeShow(false);

+                window.clearInterval(checkStatusTimer);

+                successOverlay();

+            } else if(checkConCounter > 6){

+                if(timeoutTipShowed == false){

+                    timeoutTipShowed = true;

+                    showAlert("ussd_operation_timeout");

+                }

+                window.clearInterval(checkStatusTimer);

+            } else if(checkConCounter < 7) {

+                checkConCounter++;

+            } else {

+                hideLoading();

+                window.clearInterval(checkStatusTimer);

+            }				

+        }

+        

+		//应用按钮事件.

+		function saveFunc(){

+			target.dhcpNoticeShow(false);

+			target.staticNoticeShow(false);

+			target.pppoeNoticeShow(false);

+			target.autoNoticeShow(false);

+			if(pppObj.rj45_state == "dead"){

+				showAlert("pppoe_msg");

+				return;

+			}

+			var requestParams = {};

+			if($("#pppoe_mode").val() == "PPPOE") {

+				requestParams = $.extend({}, {

+					goformId: "WAN_GATEWAYMODE_PPPOE",

+					pppoe_username: target.user(),

+					pppoe_cc: target.password()

+				});

+			} else if($("#pppoe_mode").val() == "AUTO") {

+				requestParams = $.extend({}, {

+					goformId: "WAN_GATEWAYMODE_AUTO",

+					pppoe_username: target.autoUser(),

+					pppoe_cc: target.autoPassword()

+				});

+			} else if($("#pppoe_mode").val() == "STATIC") {

+				if(target.ipAddress() == target.defaultGateway()){

+					showAlert("ip_gate_not_same");

+					return;

+				}

+				if(isStaticIPValid(target.ipAddress(), pppObj.lan_ipaddr, pppObj.lan_netmask)){

+					showAlert("ip_innergate_not_same");

+					return;

+				}

+				requestParams = $.extend({}, {

+					goformId: "WAN_GATEWAYMODE_STATIC",

+					static_wan_ipaddr: target.ipAddress(),

+					static_wan_netmask: target.subnetMask(),

+					static_wan_gateway: target.defaultGateway(),

+					static_wan_primary_dns: target.primaryDNS(),

+					static_wan_secondary_dns: target.secondaryDNS(),

+					WAN_MODE: "STATIC"

+				});

+			} else {

+				requestParams = $.extend({}, {

+					goformId: "WAN_GATEWAYMODE_DHCP"

+				});

+			}

+			requestParams.action_link = "connect";

+			requestParams.dial_mode = target.pppMode();

+			showLoading("waiting");

+			

+			service.setPppoeDialMode(requestParams, function(data){

+				if(data.result){

+					target.currentMode($("#pppoe_mode").val());

+					pppObj = service.getPppoeParams();

+					checkConCounter = 0;

+					timeoutTipShowed = false;

+					setRj45CheckTimer("connect");					

+					$("#pppoeApply").translate();

+                } else {

+					errorOverlay("pppoe_message_send_fail");

+                }

+			});

+			

+		}

+		

+		//取消连接按钮事件.

+		function cancelConnectFunc(){

+			target.dhcpNoticeShow(false);

+			target.staticNoticeShow(false);

+			target.pppoeNoticeShow(false);

+			target.autoNoticeShow(false);

+			if(pppObj.rj45_state == "dead"){

+				showAlert("pppoe_msg");

+				return;

+			}

+			var requestParams = {

+				dial_mode: target.pppMode(),

+				action_link: "disconnect"

+			};

+			if(pppObj.ethwan_mode == "PPPOE") {

+				requestParams = $.extend(requestParams, {

+					goformId: "WAN_GATEWAYMODE_PPPOE",

+					pppoe_username: pppObj.pppoe_username,

+					pppoe_cc: pppObj.pppoe_cc					

+				});

+			}else if(pppObj.ethwan_mode == "AUTO") {

+				requestParams = $.extend(requestParams, {

+					goformId: "WAN_GATEWAYMODE_AUTO",

+					pppoe_username: pppObj.pppoe_username,

+					pppoe_cc: pppObj.pppoe_cc					

+				});

+			}else if(pppObj.ethwan_mode == "STATIC") {

+				requestParams = $.extend(requestParams, {

+					goformId: "WAN_GATEWAYMODE_STATIC",

+					static_wan_ipaddr: pppObj.static_wan_ipaddr,

+					static_wan_netmask: pppObj.static_wan_netmask,

+					static_wan_gateway: pppObj.static_wan_gateway,

+					static_wan_primary_dns: pppObj.static_wan_primary_dns,

+					static_wan_secondary_dns: pppObj.static_wan_secondary_dns,

+					WAN_MODE: "STATIC"

+				});

+			}else {

+				requestParams = $.extend(requestParams, {

+					goformId: "WAN_GATEWAYMODE_DHCP"

+				});

+			}

+			showLoading("waiting");

+			service.setPppoeDialMode(requestParams, function(data){

+				if(data.result){

+                    checkConCounter = 0;

+					timeoutTipShowed = false;

+					setRj45CheckTimer("disconnect");

+					$("#pppoeApply").translate();

+                } else {

+					errorOverlay("pppoe_message_send_fail");

+                }

+			});

+			

+		}

+		

+		function radioHandlerFunc(){

+			initContronler();

+			return true;

+		}

+		

+		function changeModeDivFunc(){

+			initContronler();

+		}

+        

+    }

+

+	function bindContainer(vm){

+		var container = $('#container');

+		ko.cleanNode(container[0]);

+		ko.applyBindings(vm, container[0]);

+	

+	}

+    // 联网设置初始化.

+     

+	function initialize() {

+		var vm = new PPPoEViewModel();

+		bindContainer(vm);

+		

+		$("#pppoeApply").translate();

+		

+		$('#pppoeForm').validate({

+			submitHandler : function() {

+				vm.save();

+			},

+            rules: {

+                txtPin: "wps_pin_check",

+				txtIpAddress: "dmz_ip_check",

+				txtSubnetMask: {

+					ipv4: true,

+                    subnetmask_check: true

+				},

+				txtDefaultGateway: {

+					ipv4: true,

+					gateway_check: true

+				},

+				txtPrimaryDNS: {

+					ipv4: true,

+					dns_check:true

+				},

+				txtSecondaryDNS: {

+					ipv4: true,

+					dns_check:true

+				}

+            }

+		});

+	}

+	

+	

+//from 4.0

+    // 有效DNS检查.

+     

+function validateDns(dns){

+	if ( "0.0.0.0" == dns || "255.255.255.255" == dns) {

+		return false;

+	}

+	return true;

+}

+    // 联网设置初始化.

+     

+function isStaticIPValid(ip, lanip, lanmask){

+	if(!ip || !lanip || !lanmask){//各参数不能为空

+        return false;

+    }

+	if(ip == lanip){// 与内网IP相等

+		return true;

+	}

+    var  res1 = [], res2 = [], mask = [];

+    addr1 = ip.split(".");

+    addr2 = lanip.split(".");

+    mask  = lanmask.split(".");

+    for(var i = 0; i < addr1.length; i += 1){

+        res1.push(parseInt(addr1[i]) & parseInt(mask[i]));

+        res2.push(parseInt(addr2[i]) & parseInt(mask[i]));

+    }

+    if(res1.join(".") == res2.join(".")){//在同一个网段

+        return true;

+    }else{//不在同一个网段

+        return false;

+    }

+}

+

+// 有效子网掩码验证.

+     

+function isNetmaskIPValid(ip) {

+	if (ip == 255 || ip == 254 || ip == 252 || ip == 248

+		|| ip == 240 || ip == 224 || ip == 192 || ip == 128 || ip == 0)

+	{

+		return true;

+	}

+	else

+	{

+		return false;

+	}

+}

+    // 有效子网掩码检查.

+     

+function validateNetmask(netmask) {

+	var array = new Array();

+	array = netmask.split(".");

+

+	if (array.length != 4) {

+		return false;

+	}

+

+	array[0] = parseInt(array[0]);

+	array[1] = parseInt(array[1]);

+	array[2] = parseInt(array[2]);

+	array[3] = parseInt(array[3]);

+

+	if (array[3] != 0) {

+		if (array[2] != 255 || array[1] != 255 || array[0] != 255) {

+			return false;

+		} else {

+			if (!isNetmaskIPValid(array[3])) {

+				return false;

+			}

+		}

+	}

+

+	if (array[2] != 0) {

+		if (array[1] != 255 || array[0] != 255) {

+			return false;

+		} else {

+			if (!isNetmaskIPValid(array[2])) {

+				return false;

+			}

+		}

+	}

+

+	if (array[1] != 0) {

+		if (array[0] != 255) {

+			return false;

+		} else{

+			if (!isNetmaskIPValid(array[1])) {

+				return false;

+			}

+		}

+	}

+	if(array[0]!=255) {

+		return false;

+	}

+	if ( "0.0.0.0" == netmask || "255.255.255.255" == netmask) {

+		return false;

+	}

+	return true;

+}

+    

+    // subnetmask_check校验规则

+     

+jQuery.validator.addMethod("subnetmask_check", function (value, element, param) {

+	var result = validateNetmask(value);

+    return this.optional(element) || result;

+});

+    // dns_check校验规则

+     

+jQuery.validator.addMethod("dns_check", function (value, element, param) {

+	var result = validateDns(value);

+    return this.optional(element) || result;

+});

+    // 有效网关检查.

+     

+function validateGateway(wanIp, netmaskIp, gatewayIp) {

+	if(myConcat(wanIp,netmaskIp) == myConcat(netmaskIp, gatewayIp)) {

+		return true;

+	} else {

+		return false;

+	}

+}

+    // IP和子网掩码转换成数组形式并相与,返回相与后的IP.

+     

+function myConcat(ip1,ip2){

+	var result = [];

+	var iplArr = ip1.split(".");

+	var ip2Arr = ip2.split(".");

+	for(var i = 0; i < iplArr.length;i++){

+		result[i] = (iplArr[i] & ip2Arr[i]);

+	}

+	return result.join(".");

+}

+    // gateway_check校验规则

+     

+jQuery.validator.addMethod("gateway_check", function (value, element, param) {

+	var result = validateGateway($('#txtIpAddress').val(), $('#txtSubnetMask').val(), $("#txtDefaultGateway").val());

+    return this.optional(element) || result;

+});

+	

+	return {

+		init: initialize

+	};

+});

+//联网设置模块

+define("network_dial_set","underscore jquery knockout set service".split(" "),

+function(_, $, ko, config, service) {

+

+    //联网设置view model

+	function DialVM() {

+		var dialMode = service.getConnectionMode();

+		var target = this;

+

+		target.selectMode = ko.observable(dialMode.connectionMode);

+        target.enableFlag = ko.observable(true);

+        target.isAllowedRoaming = ko.observable(dialMode.isAllowedRoaming);

+        var originalRoaming = dialMode.isAllowedRoaming;

+

+        target.setAllowedRoaming = setAllowedRoamingFunc;

+		

+		var checkboxFlag = $(".checkboxToggle");

+        target.checkEnable = checkEnableFunc;

+		

+        //修改联网模式

+        target.save = saveFunc;

+		

+		function saveFunc() {

+            showLoading();

+            var connMode = target.selectMode();

+            //当选择自动时,下发原先的勾选状态

+            if (connMode == 'auto_dial') {

+                originalRoaming = target.isAllowedRoaming();

+            } else {

+                target.isAllowedRoaming(originalRoaming);

+            }

+            service.setConnectionMode({

+                connectionMode: connMode,

+                isAllowedRoaming: target.isAllowedRoaming()

+            }, function (result) {

+                if (result.result == "success") {

+                    successOverlay();

+                } else {

+                    errorOverlay();

+                }

+            });

+        }

+		

+		function setAllowedRoamingFunc() {

+            if(!$("#roamBtn").hasClass("disable")){

+                var checkbox = $("#isAllowedRoaming:checked");

+                if(checkbox && checkbox.length == 0 ){

+                    target.isAllowedRoaming("on");

+                }else{

+                    target.isAllowedRoaming("off");

+                }

+            }

+        }

+		

+		function checkEnableFunc() {

+            var status = service.getStatusInfo();

+

+            if (status.connectStatus == "ppp_connected" || status.connectStatus == "ppp_connecting") {

+                target.enableFlag(false);

+                disableCheckbox(checkboxFlag);

+            }

+            else {

+                target.enableFlag(true);

+                enableCheckbox(checkboxFlag);

+            }

+        }

+

+	}

+

+    //联网设置初始化.

+	function initialize() {

+		var vm = new DialVM();

+		bindContainer(vm);

+		

+        vm.checkEnable();

+        addInterval( vm.checkEnable, 1000);

+	}

+	

+	function bindContainer(vm){

+		var container = $('#container');

+		ko.cleanNode(container[0]);

+		ko.applyBindings(vm, container[0]);

+	

+	}

+	

+	return {

+		init: initialize

+	};

+});

+// APN Setting 模块

+define("network_apn_set","underscore jquery knockout set service".split(" "),

+    function (_, $, ko, config, service) {

+

+    //获取鉴权方式

+     

+    function getAuthModes() {

+        return _.map(config.APN_AUTH_MODES, function (item) {

+            return new Option(item.name, item.value);

+        });

+    }

+

+    function getApnPdpTypes() {

+        var pdpTypesArray = [new Option('IPv4', 'IP')];

+        if (config.IPV6_SUPPORT) {

+            pdpTypesArray.push(new Option('IPv6', 'IPv6'));

+            if (config.IPV4V6_SUPPORT) {

+                pdpTypesArray.push(new Option('IPv4v6', 'IPv4v6'));

+            }

+            if (config.IPV4_AND_V6_SUPPORT) {

+                pdpTypesArray.push(new Option('IPv4 & IPv6', 'IPv4v6'));

+            }

+        }

+        return pdpTypesArray;

+    }

+

+    //获取apn相关信息

+     

+    function getApnSet() {

+        var apnInfo = service.getApnSettings();

+        apnInfo.ipv6ApnConfigs = getApnConfigs(apnInfo.ipv6APNs, true);

+        apnInfo.apnConfigs = getApnConfigs(apnInfo.APNs, false);

+        apnInfo.autoApnConfigs = getAutoApnsConfig(apnInfo.autoApns, apnInfo.autoApnsV6);

+        return apnInfo;

+    }

+    var apnConfigs = {};

+    var ipv6ApnConfigs = {};

+    var autoApnConfigs = {};

+

+    //解析自动apn信息

+     

+    function getAutoApnsConfig(autoApnV4, autoApnV6) {

+        var autoApnsV4 = [];

+        var autoApnsV6 = [];

+

+        if (autoApnV4 && autoApnV4.length > 5) {

+            var apnArr = autoApnV4.split("||");

+            for (var ki = 0; ki < apnArr.length; ki++) {

+                if (apnArr[ki] != "") {

+                    var apnItem = parseApnItem(apnArr[ki], false);

+                    autoApnsV4.push(apnItem);

+                }

+            }

+        }

+        if (autoApnV6 && autoApnV6.length > 5) {

+            var apnArr = autoApnV6.split("||");

+            for (var ki = 0; ki < apnArr.length; ki++) {

+                if (apnArr[ki] != "") {

+                    var apnItem = parseApnItem(apnArr[ki], false);

+                    autoApnsV6.push(apnItem);

+                }

+            }

+        }

+        return dealAutoApnsV4V6(autoApnsV4, autoApnsV6);

+    }

+    //解析apn信息

+     

+    function getApnConfigs(apnsStr, isIpv6) {

+        var apnCfgs = [];

+        var theApnConfigs = {};

+        if (apnsStr && apnsStr.length > 10) {

+            var apnArr = apnsStr.split("||");

+            for (var ki = 0; ki < apnArr.length; ki++) {

+                if (apnArr[ki] != "") {

+                    var apnItem = parseApnItem(apnArr[ki], isIpv6);

+                    apnCfgs.push(apnItem);

+                    theApnConfigs[apnItem.profileName] = apnItem;

+                }

+            }

+        }

+        if (isIpv6 == false) {

+            apnConfigs = theApnConfigs;

+        } else {

+            ipv6ApnConfigs = theApnConfigs;

+        }

+        return apnCfgs;

+    }

+

+	//解析单条apn信息

+     

+    function parseApnItem(apnStr, isIpv6) {

+        var apnItem = {};

+        var items = apnStr.split("($)");

+        for (var ki = 0; ki < items.length; ki++) {

+            apnItem.profileName = items[0];

+            apnItem.pdpType = items[7];

+            if (isIpv6 == false) {	

+                apnItem.dnsMode = items[10];

+                apnItem.dns1 = items[11];

+                apnItem.dns2 = items[12];

+                apnItem.wanApn = items[1];

+                apnItem.authMode = items[4].toLowerCase();

+                apnItem.username = items[5];

+                apnItem.password = items[6];

+            } else {		

+                apnItem.dnsModeV6 = items[10];

+                apnItem.dns1V6 = items[11];

+                apnItem.dns2V6 = items[12];

+                apnItem.wanApnV6 = items[1];

+                apnItem.authModeV6 = items[4].toLowerCase();

+                apnItem.usernameV6 = items[5];

+                apnItem.passwordV6 = items[6];

+            }

+        }

+        return apnItem;

+    }

+    //合并V4\V6自动apn信息

+     

+    function dealAutoApnsV4V6(v4, v6) {

+        autoApnConfigs = {};

+        var autoApns = [];

+        for (var ki = 0; ki < v4.length; ki++) {

+            var apnElem = v4[ki];

+            var itemsV6 = v6[ki];

+            if (itemsV6 && (itemsV6.pdpType == 'IPv6' || itemsV6.pdpType == 'IPv4v6')) {

+                apnElem.usernameV6 = itemsV6.username;

+                apnElem.passwordV6 = itemsV6.password;

+                apnElem.dns1V6 = itemsV6.dns1;

+                apnElem.dns2V6 = itemsV6.dns2;

+                apnElem.wanApnV6 = itemsV6.wanApn;

+                apnElem.authModeV6 = itemsV6.authMode;

+                apnElem.dnsModeV6 = itemsV6.dnsMode;

+            }

+            autoApns.push(apnElem);

+            autoApnConfigs[apnElem.profileName] = apnElem;

+        }

+        return autoApns;

+    }

+

+    function getProfileOptions(apns) {

+        return _.map(apns, function (item) {

+            return new Option(item.profileName, item.profileName);

+        });

+    }

+

+    //APNViewModel

+     

+    function APNViewModel() {

+        var target = this;

+        var apnSettings = getApnSet();

+        if (apnSettings.apnNumPreset) {

+            config.maxApnNumber = apnSettings.apnNumPreset;

+        }

+

+        target.defApn = ko.observable(apnSettings.profileName); //当前默认APN

+        target.apnMode = ko.observable(apnSettings.apnMode);

+        target.autoProfiles = ko.observableArray(getProfileOptions(apnSettings.autoApnConfigs));

+        target.profiles = ko.observableArray(getProfileOptions(apnSettings.apnConfigs));

+        target.wanDial = ko.observable(apnSettings.wanDial);

+		

+        target.showApnDns = ko.observable(config.SHOW_APN_DNS);

+        target.index = ko.observable(apnSettings.currIndex);

+        target.supportIPv6 = ko.observable(config.IPV6_SUPPORT);

+        target.supportIpv4AndIpv6 = ko.observable(config.IPV4_AND_V6_SUPPORT);

+

+        target.apn = ko.observable(apnSettings.wanApn);

+        target.dnsMode = ko.observable(apnSettings.dnsMode == 'manual' ? 'manual' : 'auto');

+        target.dns1 = ko.observable(apnSettings.dns1);

+        target.dns2 = ko.observable(apnSettings.dns2);

+        target.authModes = ko.observableArray(getAuthModes());

+        target.username = ko.observable(apnSettings.username);

+        target.password = ko.observable(apnSettings.password);

+		

+        target.pdpTypes = ko.observableArray(getApnPdpTypes());

+        target.selectedPdpType = ko.observable(apnSettings.pdpType);

+        target.selectedPdpTypeTmp = ko.observable(apnSettings.pdpType); //the PdpType select's value before chang

+        target.profileName = ko.observable(apnSettings.profileName); //当前编辑框中的

+        target.selectedProfile = ko.observable(apnSettings.profileName); //当前下拉框选择的APN

+

+        target.showPassword = ko.observable(false);

+

+        target.apnV6 = ko.observable(apnSettings.wanApnV6);

+        target.dnsModeV6 = ko.observable(apnSettings.dnsModeV6 == 'manual' ? 'manual' : 'auto');

+        target.dns1V6 = ko.observable(apnSettings.dns1V6);

+        target.dns2V6 = ko.observable(apnSettings.dns2V6);

+        target.authModesV6 = ko.observableArray(getAuthModes());

+        target.usernameV6 = ko.observable(apnSettings.usernameV6);

+        target.passwordV6 = ko.observable(apnSettings.passwordV6);

+        target.pdpTypeNote = ko.observable(true);

+        if (apnSettings.autoApnConfigs && apnSettings.autoApnConfigs.length > 0) {

+            target.selectedAutoProfile = ko.observable(apnSettings.autoApnConfigs[0].profileName);

+        } else {

+            target.selectedAutoProfile = ko.observable();

+        }

+

+        if (config.EMPTY_APN_SUPPORT == false) {

+            $("#apn_ipv4_apn").addClass("required");

+            $("#apn_ipv6_apn").addClass("required");

+        } else {

+            $("#apn_ipv4_apn").removeClass("required");

+            $("#apn_ipv6_apn").removeClass("required");

+        }

+		

+        target.disableProfile = ko.observable(false); //表示处于新增页面

+        target.addApnHide = ko.observable(true);

+        target.defaultCfg = ko.observable(true); //当前选中的是默认APN

+        target.predeterminedCfg = ko.observable(true); //当前选中的是预置的APN

+		

+        target.selectedAuthentication = ko.observable(apnSettings.authMode);

+        target.selectedAuthenticationV6 = ko.observable(apnSettings.authModeV6);

+

+

+        target.transApnV6 = ko.observable('apn');

+        target.transDnsModeV6 = ko.observable('apn_dns_mode');

+        target.transDns1V6 = ko.observable('apn_dns1');

+        target.transDns2V6 = ko.observable('apn_dns2');

+        target.transAuthV6 = ko.observable('apn_authentication');

+        target.transUserNameV6 = ko.observable('apn_user_name');

+        target.transPasswordV6 = ko.observable('apn_password');

+		

+        target.transApn = ko.observable(config.IPV4_AND_V6_SUPPORT ? 'apn_ipv4_apn' : 'apn');

+        target.transDnsMode = ko.observable(config.IPV4_AND_V6_SUPPORT ? 'apn_dns_mode_ipv4' : 'apn_dns_mode');

+        target.transDns1 = ko.observable(config.IPV4_AND_V6_SUPPORT ? 'apn_dns1_ipv4' : 'apn_dns1');

+        target.transDns2 = ko.observable(config.IPV4_AND_V6_SUPPORT ? 'apn_dns2_ipv4' : 'apn_dns2');

+        target.transAuth = ko.observable(config.IPV4_AND_V6_SUPPORT ? 'apn_authentication_ipv4' : 'apn_authentication');

+        target.transUserName = ko.observable(config.IPV4_AND_V6_SUPPORT ? 'apn_user_name_ipv4' : 'apn_user_name');

+        target.transPassword = ko.observable(config.IPV4_AND_V6_SUPPORT ? 'apn_password_ipv4' : 'apn_password');

+

+        target.setDefaultVisible = ko.observable(!isConnectedNetWork());

+

+        target.tmp1 = ko.computed(function () {

+             if (target.selectedPdpType() == "IPv6") {

+                target.transApnV6('apn');

+                target.transDnsModeV6('apn_dns_mode');

+                target.transDns1V6('apn_dns1');

+                target.transDns2V6('apn_dns2');

+                target.transAuthV6('apn_authentication');

+                target.transUserNameV6('apn_user_name');

+                target.transPasswordV6('apn_password');

+            } else if (config.IPV4_AND_V6_SUPPORT && target.selectedPdpType() == 'IPv4v6') {

+                target.transApn('apn_ipv4_apn');

+                target.transDnsMode('apn_dns_mode_ipv4');

+                target.transDns1('apn_dns1_ipv4');

+                target.transDns2('apn_dns2_ipv4');

+                target.transAuth('apn_authentication_ipv4');

+                target.transUserName('apn_user_name_ipv4');

+                target.transPassword('apn_password_ipv4');

+

+                target.transApnV6('apn_ipv6_apn');

+                target.transDnsModeV6('apn_dns_mode_ipv6');

+                target.transDns1V6('apn_dns1_ipv6');

+                target.transDns2V6('apn_dns2_ipv6');

+                target.transAuthV6('apn_authentication_ipv6');

+                target.transUserNameV6('apn_user_name_ipv6');

+                target.transPasswordV6('apn_password_ipv6');

+            } else if (target.selectedPdpType() == "IP" || target.selectedPdpType() == "IPv4") {

+                target.transApn('apn');

+                target.transDnsMode('apn_dns_mode');

+                target.transDns1('apn_dns1');

+                target.transDns2('apn_dns2');

+                target.transAuth('apn_authentication');

+                target.transUserName('apn_user_name');

+                target.transPassword('apn_password');

+            } else { //config.IPV4V6_SUPPORT && target.selectedPdpType() == 'IPv4v6'

+                target.transApn('apn');

+                target.transDnsMode('apn_dns_mode');

+                target.transDns1('apn_dns1');

+                target.transDns2('apn_dns2');

+                target.transAuth('apn_authentication');

+                target.transUserName('apn_user_name');

+                target.transPassword('apn_password');

+            }

+            $("#apn_setting_form").translate();

+        });

+

+        target.autoApnChecked = ko.computed(function () {

+            return target.apnMode() == "auto";

+        });

+		

+        target.hasCapacity = ko.computed(function () {

+            if (target.profiles().length < config.maxApnNumber) {

+                return true;

+            } else {

+                return false;

+            }

+        });

+

+        target.showDnsV6 = ko.computed(function () {

+            return target.dnsModeV6() == "manual";

+        });

+		

+        target.showDns = ko.computed(function () {

+            return target.dnsMode() == "manual";

+        });

+

+

+        checkDefaultProfileStatus();

+        target.checkInputDisable = ko.computed(function () {

+            if (target.apnMode() != "auto"  && (target.predeterminedCfg() == false && target.defaultCfg() == true) && !isConnectedNetWork()) {

+                return false;

+            }

+            if (((target.apnMode() != "auto" && (target.predeterminedCfg() || target.defaultCfg()) && !target.disableProfile())) || target.apnMode() == "auto") {

+                return true;

+            }

+            if ((!target.disableProfile() || !(target.predeterminedCfg() || target.defaultCfg())) && target.apnMode() != "auto") {

+                return false;

+            }

+            return false;

+        });

+

+        var data = service.getDeviceInfo();

+        target.pdpTypeChangeAlert = pdpTypeChangeAlertFunc;

+		

+

+        target.showAutoApnDetail = ko.computed(function () {

+            if (target.apnMode() != "auto") {

+                return true;

+            } else {

+                return target.autoProfiles().length > 0;

+            }

+        });

+		//密码显示事件

+        target.showPasswordHandler = function () {

+            var checkbox = $("#showPassword:checked");

+            if (checkbox && checkbox.length == 0) {

+                target.showPassword(true);

+            } else {

+                target.showPassword(false);

+            }

+        };

+		//auto apn profile change 事件处理

+         

+        target.autoProfileChangeHandler = autoProfileChangeHandlerFunc;

+		

+		

+        //profile change 事件处理

+         

+        target.profileChangeHandler = profileChangeHandlerFunc;

+		

+        

+        //切换profile时重置下面的显示项

+        target.setUIData = setUIDataFunc;

+		

+

+        //设置默认apn状态

+         

+        function checkDefaultProfileStatus() {

+            var index = getApnIndex();

+            //默认apn不允许编辑

+            if (target.apnMode() != "auto") { //当前选中与实际不一致的话

+                if (target.selectedProfile() != target.defApn()) {

+                    target.defaultCfg(false);

+                } else {

+                    target.defaultCfg(true); //默认APN

+                }

+            } else {

+                if (target.selectedAutoProfile() != target.defApn()) {

+                    target.defaultCfg(false);

+                } else {

+                    target.defaultCfg(true); //默认APN

+                }

+            }

+

+            if (index >= config.defaultApnSize) {

+                target.predeterminedCfg(false);

+            } else {

+                target.predeterminedCfg(true); //预置APN

+            }

+        }

+

+

+        //设置为默认apn

+         

+        target.setDefaultAct = setDefaultActFunc;

+		

+

+		

+        //APN mode change 事件处理

+         

+        target.apnModeChangeHandler = apnModeChangeHandlerFunc;

+		

+		

+        function doSetDefaultAct() {

+            var index = 0;

+            if (target.apnMode() != 'auto') {

+                index = getApnIndex();

+                target.selectedProfile($("#profile").val());

+            } else {

+                index = getAutoApnIndex();

+                target.selectedAutoProfile($("#autoProfile").val());

+            }

+            var selectedProfileDetail = target.getSelectedManualProfile();

+            service.setDefaultApn({

+                index: index,

+                apnMode: target.apnMode(),

+                pdpType: selectedProfileDetail.pdpType,

+

+                profileName: selectedProfileDetail.profileName,

+                wanApn: selectedProfileDetail.wanApn,

+                authMode: selectedProfileDetail.authMode,

+                username: selectedProfileDetail.username,

+                password: selectedProfileDetail.password,

+                dnsMode: config.SHOW_APN_DNS ? selectedProfileDetail.dnsMode : 'auto',

+                dns1: config.SHOW_APN_DNS ? selectedProfileDetail.dns1 : '',

+                dns2: config.SHOW_APN_DNS ? selectedProfileDetail.dns2 : ''

+            }, function (data) {

+                if (data.result) {

+                    //showLoading("apn_alert_restart");

+                    //restartDevice(service);

+                    addTimeout(function () {

+                        initialize(true);

+                        target.apnModeChangeHandler();

+                        successOverlay();

+                    }, 500);

+                } else {

+                    errorOverlay();

+                }

+            }, function (data) {

+                errorOverlay();

+            });

+        }

+

+        target.getSelectedManualProfile = getSelectedManualProfileFunc;

+		

+

+        //获取自动apn索引

+         

+        function getAutoApnIndex() {

+            var configs = $("#autoProfile option");

+            for (var ki = 0; ki < configs.length; ki++) {

+                if (configs[ki].value == target.selectedAutoProfile()) {

+                    return ki;

+                }

+            }

+            return configs.length - 1;

+        }

+		

+		//获取apn索引

+         

+        function getApnIndex() {

+            var configs = $("#profile option");

+            if (configs.length == 0) {

+                configs = target.profiles();

+            }

+            var ki = 0;

+            for (; ki < configs.length; ki++) {

+                if (configs[ki].value == target.selectedProfile()) {

+                    break;

+                }

+            }

+            return ki;

+        }

+

+        //保存APN设置信息

+         

+        target.saveAct = saveActFunc;

+		

+		//编辑APN信息

+         

+        function editApnSetting(preAct) { //默认设置按钮触发为TRUE

+            showLoading();

+            var apnIndex = getApnIndex();

+            var sameInfo = false;

+            if (config.IPV4V6_SUPPORT && target.selectedPdpType() == 'IPv4v6') {

+                sameInfo = true;

+            }

+            var needDoDefault = false;

+            if (preAct || (target.predeterminedCfg() || target.defaultCfg())) {

+                needDoDefault = true;

+            }

+            service.addOrEditApn({

+                profileName: target.profileName(),

+                pdpType: target.selectedPdpType(),

+                index: apnIndex,

+

+                wanApn: target.apn(),

+                authMode: target.selectedAuthentication(),

+                username: target.username(),

+                password: target.password(),

+                dnsMode: config.SHOW_APN_DNS ? target.dnsMode() : 'auto',

+                dns1: config.SHOW_APN_DNS ? target.dns1() : '',

+                dns2: config.SHOW_APN_DNS ? target.dns2() : '',

+

+                wanApnV6: sameInfo ? target.apn() : target.apnV6(),

+                authModeV6: sameInfo ? target.selectedAuthentication() : target.selectedAuthenticationV6(),

+                usernameV6: sameInfo ? target.username() : target.usernameV6(),

+                passwordV6: sameInfo ? target.password() : target.passwordV6(),

+                dnsModeV6: config.SHOW_APN_DNS ? (sameInfo ? target.dnsMode() : target.dnsModeV6()) : 'auto',

+                dns1V6: config.SHOW_APN_DNS ? (sameInfo ? target.dns1() : target.dns1V6()) : '',

+                dns2V6: config.SHOW_APN_DNS ? (sameInfo ? target.dns2() : target.dns2V6()) : ''

+            }, function (data) {

+                if (data.result) {

+                    apnSettings = getApnSet();

+                    if (target.profileName() != target.selectedProfile()) {

+                        var newProfileName = target.profileName();

+                        target.profiles(getProfileOptions(apnSettings.apnConfigs));

+                        $('#profile').val(newProfileName).trigger('change');

+                    }

+                    if (needDoDefault == false) {

+                        successOverlay();

+                    } else {

+                        doSetDefaultAct();

+                    }

+                } else {

+                    errorOverlay();

+                }

+            }, function (data) {

+                errorOverlay();

+            });

+        }

+		

+        //新增APN信息

+         

+        function addNewApnSetting() {

+            showLoading("waiting");

+            var optionLen = $("option", "#profile").length;

+            if (optionLen < config.defaultApnSize) {

+                errorOverlay();

+                return;

+            }

+            // 支持IPv4v6,并且选择IPv4v6时,IPv4 与 IPv6下发相同的信息

+            // 支持IPv4 & v6,并且选择IPv4v6时,IPv4 与 IPv6下发各自的信息

+            var sameInfo = false;

+            if (config.IPV4V6_SUPPORT && target.selectedPdpType() == 'IPv4v6') {

+                sameInfo = true;

+            }

+

+            service.addOrEditApn({

+                profileName: target.profileName(),

+                pdpType: target.selectedPdpType(),

+                index: optionLen,

+

+                wanApn: target.apn(),

+                authMode: target.selectedAuthentication(),

+                username: target.username(),

+                password: target.password(),

+                dnsMode: config.SHOW_APN_DNS ? target.dnsMode() : 'auto',

+                dns1: config.SHOW_APN_DNS ? target.dns1() : '',

+                dns2: config.SHOW_APN_DNS ? target.dns2() : '',

+

+                wanApnV6: sameInfo ? target.apn() : target.apnV6(),

+                authModeV6: sameInfo ? target.selectedAuthentication() : target.selectedAuthenticationV6(),

+                usernameV6: sameInfo ? target.username() : target.usernameV6(),

+                passwordV6: sameInfo ? target.password() : target.passwordV6(),

+                dnsModeV6: config.SHOW_APN_DNS ? (sameInfo ? target.dnsMode() : target.dnsModeV6()) : 'auto',

+                dns1V6: config.SHOW_APN_DNS ? (sameInfo ? target.dns1() : target.dns1V6()) : '',

+                dns2V6: config.SHOW_APN_DNS ? (sameInfo ? target.dns2() : target.dns2V6()) : ''

+            }, function (data) {

+                if (data.result) {

+                    apnSettings = getApnSet();

+                    if (target.profileName() != target.selectedProfile()) {

+                        var newProfileName = target.profileName();

+                        target.profiles(getProfileOptions(apnSettings.apnConfigs));

+                        $('#profile').val(newProfileName).trigger('change');

+                    }

+                    doSetDefaultAct();

+                } else {

+                    errorOverlay();

+                }

+            }, function (data) {

+                errorOverlay();

+            });

+        }

+

+        

+

+        var tempApn = {};

+		//删除APN

+         

+        target.deleteAct = deleteActFunc;

+		

+		//取消新增APN

+         

+        target.cancelAddAct = cancelAddActFunc;

+		

+        //进入新增APN页面

+         

+        target.addAct = addActFunc;

+		//进入新增APN页面

+		function addActFunc() {

+            clearValidateMsg('#apn_setting_form');

+            target.pdpTypeNote(true);

+            target.disableProfile(true);

+            target.addApnHide(true);

+            tempApn = {

+                profileName: target.profileName(),

+                selectedPdpType: target.selectedPdpType(),

+

+                wanApnV6: target.apnV6(),

+                dnsModeV6: config.SHOW_APN_DNS ? target.dnsModeV6() : 'auto',

+                dns1V6: config.SHOW_APN_DNS ? target.dns1V6() : '',

+                dns2V6: config.SHOW_APN_DNS ? target.dns2V6() : '',

+                authModeV6: target.selectedAuthenticationV6(),

+                usernameV6: target.usernameV6(),

+                passwordV6: target.passwordV6(),

+				

+                wanApn: target.apn(),

+                dnsMode: config.SHOW_APN_DNS ? target.dnsMode() : 'auto',

+                dns1: config.SHOW_APN_DNS ? target.dns1() : '',

+                dns2: config.SHOW_APN_DNS ? target.dns2() : '',

+                authMode: target.selectedAuthentication(),

+                username: target.username(),

+                password: target.password(),

+

+            };

+            target.profileName("");

+            target.selectedPdpType("IP");

+            target.selectedPdpTypeTmp("IP");

+

+            target.apnV6("");

+            target.dnsModeV6("auto");

+            target.dns1V6("");

+            target.dns2V6("");

+            target.selectedAuthenticationV6("none");

+            target.usernameV6("");

+            target.passwordV6("");

+			

+            target.apn("");

+            target.dnsMode("auto");

+            target.dns1("");

+            target.dns2("");

+            target.selectedAuthentication("none");

+            target.username("");

+            target.password("");

+

+        }

+		

+		//取消新增APN

+		function cancelAddActFunc() {

+            clearValidateMsg('#apn_setting_form');

+            target.pdpTypeNote(false);

+            target.disableProfile(false);

+            target.addApnHide(false);

+            target.profileName(tempApn.profileName);

+            target.selectedPdpType(tempApn.selectedPdpType);

+            target.selectedPdpTypeTmp(tempApn.selectedPdpType);

+

+            target.apnV6(tempApn.wanApnV6);

+            target.dnsModeV6(tempApn.dnsModeV6);

+            target.dns1V6(tempApn.dns1V6);

+            target.dns2V6(tempApn.dns2V6);

+            target.selectedAuthenticationV6(tempApn.authModeV6);

+            target.usernameV6(tempApn.usernameV6);

+            target.passwordV6(tempApn.passwordV6);

+			

+            target.apn(tempApn.wanApn);

+            target.dnsMode(tempApn.dnsMode);

+            target.dns1(tempApn.dns1);

+            target.dns2(tempApn.dns2);

+            target.selectedAuthentication(tempApn.authMode);

+            target.username(tempApn.username);

+            target.password(tempApn.password);

+

+        }

+		

+		//删除APN

+		function deleteActFunc() {

+            if (!target.selectedProfile()) {

+                showAlert("apn_no_select_alert");

+                return false;

+            }

+            if (target.predeterminedCfg()) { //预置的apn不允许删除

+                errorOverlay("apn_delete_cant_delete_default");

+                return false;

+            }

+            if (getApnSet().profileName == target.profileName()) {

+                errorOverlay("apn_cant_delete_current");

+                return false;

+            }

+

+            showConfirm("apn_delete_confirm", function () {

+                showLoading('deleting');

+                service.deleteApn({

+                    index: getApnIndex()

+                }, function (data) {

+                    if (data.result) {

+                        target.profiles(getProfileOptions(getApnSet().apnConfigs));

+                        target.selectedProfile(target.defApn());

+                        target.profileChangeHandler();

+                        successOverlay();

+                    } else {

+                        errorOverlay();

+                    }

+                }, function (data) {

+                    errorOverlay();

+                });

+            });

+        }

+		

+		//保存APN设置信息

+		function saveActFunc() {

+            if (!$('#apn_setting_form').valid()) {

+                return false;

+            }

+            if (!target.selectedProfile() && !target.disableProfile()) { //不是增加时的设置需要判断是否选择了Profile

+                showAlert("apn_no_select_alert");

+                return false;

+            }

+            var exist = false;

+            $.each(target.profiles(), function (i, e) {

+                if (e.value == target.profileName()) {

+                    exist = true;

+                }

+            });

+

+            if (target.disableProfile() == false) {

+                if (exist && target.selectedProfile() != target.profileName()) {

+                    showInfo("apn_save_profile_exist");

+                    return false;

+                }

+                if (target.predeterminedCfg()) { //预置的APN不可以修改

+                    errorOverlay();

+                    return false;

+                }

+                if (target.predeterminedCfg() || target.defaultCfg()) {

+                    //showConfirm("apn_alert", function () {

+                    editApnSetting(false);

+                    //});

+                } else {

+                    editApnSetting(false);

+                }

+            } else {

+				

+                if ($("#profile option").length >= config.maxApnNumber) {

+                    showInfo({

+                        msg: "apn_profile_full",

+                        params: [config.maxApnNumber]

+                    });

+                    return false;

+                }

+                if (exist) {

+                    showInfo("apn_save_profile_exist");

+                    return false;

+                }

+                var info = service.getStatusInfo();

+                if (info.connectStatus != "ppp_connected") {

+                    //showConfirm("apn_alert", function () {

+                    addNewApnSetting();

+                    //});

+                    

+                } else {

+					showConfirm("apn_diconneted_network_confirm", function () {

+                        showLoading('disconnecting');

+                        service.disconnect({}, function (data) {

+                            if (data.result) {

+                                config.connect_flag = true;

+                                addNewApnSetting();

+                            } else {

+                                errorOverlay();

+                            }

+                        });

+                    });

+                }

+            }

+        }

+		

+		function getSelectedManualProfileFunc() {

+            var cfg = {};

+            var profileVal = $("#profile").val();

+            if (typeof target.selectedProfile() == 'undefined') {

+                target.selectedProfile(profileVal);

+            }

+            var cfgV4 = apnConfigs[profileVal];

+            var cfgV6 = ipv6ApnConfigs[profileVal];

+            if (cfgV4 && !cfgV6) {

+                $.extend(cfg, cfgV4);

+            } else if (cfgV4 && cfgV6) {

+                if (!!cfgV4.pdpType) {

+                    $.extend(cfg, cfgV6);

+                    $.extend(cfg, cfgV4);

+                } else {

+                    $.extend(cfg, cfgV4);

+                    $.extend(cfg, cfgV6);

+                }

+            }

+            return cfg;

+        }

+		

+		//APN mode change 事件处理

+		function apnModeChangeHandlerFunc(data, event) {

+            if (target.apnMode() != 'auto') {

+                target.profileChangeHandler();

+            } else {

+                if (target.showAutoApnDetail()) {

+                    target.autoProfileChangeHandler();

+                }

+            }

+            return true;

+        }

+		

+		//设置为默认apn

+		function setDefaultActFunc() {

+            if (!target.selectedProfile()) {

+                showAlert("apn_no_select_alert");

+                return false;

+            }

+            var connectStatus = service.getConnectionInfo().connectStatus;

+             if (connectStatus == "ppp_connecting") {

+                showAlert({

+                    msg: "apn_cant_modify_status",

+                    params: [$.i18n.prop("connecting").toLowerCase()]

+                });

+                return false;

+            } else if (connectStatus == "ppp_disconnecting") {

+                showAlert({

+                    msg: "apn_cant_modify_status",

+                    params: [$.i18n.prop("disconnecting").toLowerCase()]

+                });

+                return false;

+            } else if (connectStatus == "ppp_connected") {

+                showAlert({

+                    msg: "apn_cant_modify_status",

+                    params: [$.i18n.prop("connected").toLowerCase()]

+                });

+                return false;

+            }

+            if (target.apnMode() == 'auto' || target.predeterminedCfg()) {

+                //showConfirm("apn_alert", function () {

+                showLoading("waiting");

+                doSetDefaultAct();

+                //});

+            } else {

+                if ($('#apn_setting_form').valid() == false) {

+                    $(".error:first", "#apn_setting_form").focus();                    

+                } else {

+					var exist = false;

+                    $.each(target.profiles(), function (i, e) {

+                        if (e.value == target.profileName()) {

+                            exist = true;

+                        }

+                    });

+                    if (exist && target.selectedProfile() != target.profileName()) {

+                        showInfo("apn_save_profile_exist");

+                        return false;

+                    }

+                    //showLoading("waiting");

+                    //showConfirm("apn_alert", function () {

+                    editApnSetting(true);

+                    //});

+                }

+            }

+        }

+		

+		//切换profile时重置下面的显示项

+		function setUIDataFunc(data) {

+            clearValidateMsg('#apn_setting_form');

+            if (!data) {

+                return;

+            }

+            target.selectedPdpType(data.pdpType || 'IP');

+            target.selectedPdpTypeTmp(data.pdpType || 'IP');

+            target.profileName(data.profileName);

+

+            target.apn(data.wanApn);

+            target.dnsMode(data.dnsMode != 'manual' ? 'auto' : 'manual');

+            target.dns1(data.dns1);

+            target.dns2(data.dns2);

+            target.username(data.username);

+            target.password(data.password);

+            target.selectedAuthentication(data.authMode || 'none');

+

+            target.apnV6(data.wanApnV6);

+            target.dnsModeV6(data.dnsModeV6 != 'manual' ? 'auto' : 'manual');

+            target.dns1V6(data.dns1V6);

+            target.dns2V6(data.dns2V6);

+            target.usernameV6(data.usernameV6);

+            target.passwordV6(data.passwordV6);

+            target.selectedAuthenticationV6(data.authModeV6 || 'none');

+        }

+		

+		//profile change 事件处理

+		function profileChangeHandlerFunc(data, event) {

+            target.pdpTypeNote(true);

+            if (target.apnMode() != 'manual') {

+                return true;

+            }

+            var cfg = target.getSelectedManualProfile();

+            target.setUIData(cfg);

+            checkDefaultProfileStatus();

+            return true;

+        }

+		

+		//auto apn profile change 事件处理

+		function autoProfileChangeHandlerFunc(data, event) {

+            if (target.apnMode() != 'auto') {

+                return true;

+            }

+            var cfg = autoApnConfigs[target.selectedAutoProfile()];

+            target.setUIData(cfg);

+            checkDefaultProfileStatus();

+            return true;

+        }

+		

+		function pdpTypeChangeAlertFunc() {

+            if (target.pdpTypeNote()) {

+                showAlert({

+                    msg: "apn_pdptype_change_note",

+                    params: [data.lanDomain, data.ipAddress]

+                });

+            }

+            if (target.apnMode() != "auto" && !target.disableProfile()) { //如果是手动非ADD状态,切换PDP类型时,不改变界面显示的各项值

+                if ((config.IPV4_AND_V6_SUPPORT && target.selectedPdpTypeTmp() != 'IPv4v6' && target.selectedPdpType() != 'IPv4v6') || !config.IPV4_AND_V6_SUPPORT) { //

+                    if (target.selectedPdpTypeTmp() == 'IPv6') { //V6 -> V4 / V4V6

+                        target.apn(target.apnV6());

+                        target.dnsMode(target.dnsModeV6());

+                        target.dns1(target.dns1V6());

+                        target.dns2(target.dns2V6());

+                        target.username(target.usernameV6());

+                        target.password(target.passwordV6());

+                        target.selectedAuthentication(target.selectedAuthenticationV6());

+                    } else if (target.selectedPdpType() == 'IPv6') { //V4 / V4V6 -> V6

+                        target.apnV6(target.apn());

+                        target.dnsModeV6(target.dnsMode());

+                        target.dns1V6(target.dns1());

+                        target.dns2V6(target.dns2());

+                        target.usernameV6(target.username());

+                        target.passwordV6(target.password());

+                        target.selectedAuthenticationV6(target.selectedAuthentication());

+                    }

+                }

+            }

+            target.selectedPdpTypeTmp(target.selectedPdpType());

+        }

+       

+

+    }

+

+    //是否已联网

+     

+    function isConnectedNetWork() {

+        var info = service.getConnectionInfo();

+        return info.connectStatus == "ppp_connected";

+    }

+

+    function initVar() {

+        apnConfigs = {};

+        ipv6ApnConfigs = {};

+        autoApnConfigs = {};

+    }

+	function bindContainer(vm){

+		var container = $('#container');

+        ko.cleanNode(container[0]);

+        ko.applyBindings(vm, container[0]);

+	}

+    //初始化ViewModel

+     

+    function initialize(formInit) {

+        initVar();

+        

+        var vm = new APNViewModel();

+		bindContainer(vm);

+

+        if (!formInit) {

+            addInterval(function () {

+                vm.setDefaultVisible(!isConnectedNetWork());

+            }, 1000);

+        }

+        $('#apn_setting_form').validate({

+            submitHandler: function () {

+                vm.saveAct();

+            },

+            rules: {

+                profile_name: 'apn_profile_name_check',

+                apn_ipv4_apn: 'apn_check',

+                apn_dns1_ipv4: "ipv4",

+                apn_dns2_ipv4: "ipv4",

+                apn_ipv6_apn: 'apn_check',

+                apn_dns1_ipv6: "ipv6",

+                apn_dns2_ipv6: "ipv6",

+                apn_user_name_ipv4: 'ppp_username_check',

+                apn_secretcode_ipv4: 'ppp_secretcode_check',

+                apn_user_name_ipv6: 'ppp_username_check',

+                apn_secretcode_ipv6: 'ppp_secretcode_check'

+            }

+        });

+    }

+

+    return {

+        init: initialize

+    };

+});
\ No newline at end of file
diff --git a/lynq/S300/ap/app/zte_webui/js/set.js b/lynq/S300/ap/app/zte_webui/js/set.js
new file mode 100755
index 0000000..f2dc0cc
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/js/set.js
@@ -0,0 +1,959 @@
+define(function () {

+    var config = {

+        WEBUI_TITLE: '4G Hostless Modem', //title配置, 具体参考各设备下的配置

+        ALREADY_NOTICE: false, //是否已经提醒,有在线升级信息

+        ALREADY_OTA_NOTICE: false, //是否OTA升级提醒过

+        dbMsgs: [], //数据库中全部的短消息

+        listMsgs: [], //经解析关联后的所有短消息

+        currentChatObject: null, //当前聊天对象的手机号

+        smsMaxId: 0, //短消息最大编号

+        phonebook: [], //电话本记录

+        smsIsReady: false, //缓存短信初始化状态

+        portForwardMax: 10, //端口转发最大规则数

+        urlFilterMax: 10, //URL filter最大规则数

+        defaultApnSize: 1, //出厂设置默认APN的个数

+        maxApnNumber: 10, //最大APN个数

+        RJ45_SUPPORT: false, //是否支持rj45

+        TSW_SUPPORT: false, // 是否支持定时休眠唤醒

+        WIFI_SLEEP_SUPPORT: true, // 是否支持wifi休眠

+        HAS_BATTERY: true, //是否有电池

+        FAST_BOOT_SUPPORT: true, //是否支持快速开机

+        TURN_OFF_SUPPORT: true, //是否支持关机

+        PRODUCT_TYPE: 'UFI', // 产品类型UFI、CPE

+        IS_TEST: false, //配置是否是模拟数据

+        NATIVE_UPDATE_FILE_SIZE: 64, //支持的本地升级文件大小上限,单位为M

+        DDNS_SUPPORT: false, //DDNS

+        MAX_LOGIN_COUNT: 5, //最大登录次数,密码输入错误次数到了以后会账户冻结一定时间

+        LOGIN_SECURITY_SUPPORT: true, //是否支持登录安全

+        LOGIN_THEN_CHECK_PIN: true, //是否先登录后验证PIN,PUK

+        GUEST_HASH: ['#httpshare_guest'],

+        DEVICE: 'ext', //各个型号机配置文件路径

+        connect_flag: false,

+        defaultRoute: '#entry',

+        IPV4_AND_V6_SUPPORT: false, //是否支持IPv4 & v6。 双PDP双栈

+        IPV4V6_SUPPORT: true, //是否支持ipv4v6。 IPV4V6_SUPPORT和IPV4_AND_V6_SUPPORT不可同时为true.单PDP双栈

+        IPV6_SUPPORT: true, //是否支持ipv6

+        EMPTY_APN_SUPPORT: false, //是否支持空apn

+        SHOW_APN_DNS: false, //APN设置页面是否显示DNS,不显示则dnsMode默认设置为auto

+        TRAFFIC_SUPPORT: true, //是否支持流量功能

+        CLEAR_DATA_SUPPORT: false, //是否支持流量和时间清空功能

+        NETWORK_UNLOCK_SUPPORT: false, //是否支持解锁

+        SHOW_MAC_ADDRESS: false, //是否显示mac地址

+        PASSWORD_ENCODE: true, //登录密码和WIFI密码是否加密

+        AP_STATION_SUPPORT: false, //是否支持AP Station功能

+        AP_STATION_LIST_LENGTH: 10,

+        WIFI_WEP_SUPPORT: false, //是否支持wifi WEP加密

+        WIFI_WAP3_SUPPORT: true, //是否支持wifi WAP3加密

+        WIFI_WPA2_WAP3_SUPPORT: true, //是否支持wifi WPA2/WAP3兼容模式

+        WIFI_HAS_5G: false,

+        WIFI_BAND_SUPPORT: false, //是否支持wifi频段设置

+        WIFI_BANDWIDTH_SUPPORT: false, //是否支持频带宽度

+        WIFI_BANDWIDTH_SUPPORT_40MHZ: false, //频带宽度是否支持40MHZ,reltek芯片支持

+        WIFI_SUPPORT_QR_CODE: true, //是否支持wifi二维码显示

+        WIFI_SUPPORT_QR_SWITCH: false, //是否支持wifi二维码显示控制

+        WIFI_SWITCH_SUPPORT: true, //是否支持wifi开关

+        MAX_STATION_NUMBER: 32, //CPE WIFI最大连接数为32

+        SHOW_WIFI_AP_ISOLATED: false, // 是否显示AP隔离

+        STATION_BLOCK_SUPPORT: false, // 已连接设备是否支持Block功能

+        UPGRADE_TYPE: "FOTA", //取值有"NONE","OTA","FOTA","TWO_PORTION"

+        SMS_UNREAD_NUM_INCLUDE_SIM: false, //未读短息数量是否包含SIM侧

+        SMS_DATABASE_SORT_SUPPORT: true, //短信是否支持DB排序

+        SMS_MATCH_LENGTH: 11, //短信联系人号码匹配位数,11国内项目,8国际项目

+        SHOW_UN_COMPLETE_CONCAT_SMS: true, //级联短信未接收完是否显示相关级联短信

+        SMS_SET_READ_WHEN_COMPLETE: false, //聊天过程中,级联短信只有接受完成后才能自动设置为已读

+        SD_CARD_SUPPORT: false, //是否支持SD卡

+        SD_BASE_PATH: '/mmc2', //SD 卡根目录

+        //modem_main_state的临时状态,一般需要界面轮询等待

+        TEMPORARY_MODEM_MAIN_STATE: ["modem_undetected", "modem_detected", "modem_sim_state", "modem_handover", "modem_imsi_lock", "modem_online", "modem_offline"],

+        ISNOW_NOTICE: false, //FOTA是否正在提示有新版本

+        INCLUDE_MOBILE: true,

+        HAS_USSD: false, // 是否支持USSD功能,

+        HAS_URL: false, // 是否支持URL过滤,

+        HAS_CASCADE_SMS: true, //是否支持级联短信

+        HAS_FOTA: true, //是否支持FOTA

+        HAS_UPDATE_CHECK: true, //是否支持升级检测设置

+        HAS_PHONEBOOK: true, //是否有电话本功能

+        HAS_SMS: true, //是否有短信功能

+        HAS_PARENTAL_CONTROL: false, // 是否支持家长控制功能

+        HAS_MULTI_SSID: false, //多ssid功能

+        HAS_WIFI: true, //是否包含wifi功能

+        HAS_QUICK_SETTING: true, //是否支持快速设置

+        HAS_SNTP: true, //是否支持时间管理

+        HAS_BLACK_AND_WHITE_FILTER: false, //是否支持黑白名单

+        HAS_LOGIN: true, //是否有登录页面

+        HAS_UPNP: true, //是否支持UPNP

+        BAUD_RATES: [{

+                name: '9600',

+                value: '9600'

+            }, {

+                name: '19200',

+                value: '19200'

+            }, {

+                name: '38400',

+                value: '38400'

+            }, {

+                name: '57600',

+                value: '57600'

+            }, {

+                name: '115200',

+                value: '115200'

+            }, {

+                name: '230400',

+                value: '230400'

+            }, {

+                name: '460800',

+                value: '460800'

+            }, {

+                name: '921600',

+                value: '921600'

+            }

+        ],

+        FORWARDING_MODES: [{

+                name: 'Unconditional forwarding',

+                value: '1'

+            }, {

+                name: 'When busy',

+                value: '2'

+            }, {

+                name: 'When no answer',

+                value: '3'

+            }, {

+                name: 'Cancel all forwarding',

+                value: '0'

+            }

+        ],

+        wdsModes: [{

+                name: "Disable",

+                value: "0"

+            }, {

+                name: "RootAP Mode",

+                value: "1"

+            }, {

+                name: "Bridge Mode",

+                value: "2"

+            }, {

+                name: "Repeater Mode",

+                value: "3"

+            }

+        ],

+        daylightSave: [{

+                name: "Disable",

+                value: "0"

+            }, {

+                name: "Enable",

+                value: "1"

+            }

+        ],

+        sntpTimeSetMode: [{

+                name: 'manual',

+                value: 'manual'

+            }, {

+                name: 'auto',

+                value: 'auto'

+            }

+        ],

+        //时区

+        timeZone: [{

+                name: "(GMT-12:00) Dateline West",

+                value: "<-12>12_0"

+            }, {

+                name: "(GMT-11:00) Midway Islands, Samoa",

+                value: "SST11_0"

+            }, {

+                name: "(GMT-10:00) Hawaii",

+                value: "<-10>10_0"

+            }, {

+                name: "(GMT-09:00) Alaska",

+                value: "<-09>9_0"

+            }, {

+                name: "(GMT-08:00) Pacific time (USA and Canada), Tijuana",

+                value: "PST8PDT,M3.2.0,M11.1.0_0"

+            }, {

+                name: "(GMT-07:00) Mountain time (USA and Canada)",

+                value: "<-07>7_0"

+            }, {

+                name: "(GMT-07:00) Arizona",

+                value: "<-07>7_1"

+            }, {

+                name: "(GMT-07:00) Chihuahua, La Paz, Mazza Tran",

+                value: "MST7MDT,M4.1.0,M10.5.0_2"

+            }, {

+                name: "(GMT-06:00) Saskatchewan",

+                value: "<-06>6_0"

+            }, {

+                name: "(GMT-06:00) Central time (USA and Canada)",

+                value: "<-06>6_1"

+            }, {

+                name: "(GMT-06:00) Central America",

+                value: "<-06>6_2"

+            }, {

+                name: "(GMT-06:00) Guadalajara City, Mexico City, Monterey",

+                value: "<-06>6_3"

+            }, {

+                name: "(GMT-05:00) Bogota, Lima, Quito",

+                value: "<-05>5_0"

+            }, {

+                name: "(GMT-05:00) Eastern time (USA and Canada)",

+                value: "<-05>5_1"

+            }, {

+                name: "(GMT-05:00) Indiana (East)",

+                value: "EST5EDT,M3.2.0,M11.1.0_2"

+            }, {

+                name: "(GMT-04:00) Atlantic time (Canada)",

+                value: "AST4ADT,M3.2.0,M11.1.0_0"

+            }, {

+                name: "(GMT-04:00) Caracas, La Paz",

+                value: "<-04>4_1"

+            }, {

+                name: "(GMT-04:00) Santiago",

+                value: "<-04>4<-03>,M8.2.6/24,M5.2.6/24_2"

+            }, {

+                name: "(GMT-03:30) Newfoundland",

+                value: "NST3:30NDT,M3.2.0,M11.1.0_0"

+            }, {

+                name: "(GMT-03:00) Brasilia",

+                value: "<-03>3_0"

+            }, {

+                name: "(GMT-03:00) Buenos Aires, Georgetown",

+                value: "<-03>3_1"

+            }, {

+                name: "(GMT-03:00) Greenland",

+                value: "<-03>3_2"

+            }, {

+                name: "(GMT-02:00) Mid-Atlantic",

+                value: "<-02>2_0"

+            }, {

+                name: "(GMT-01:00) Cape Verde Islands",

+                value: "<-01>1_0"

+            }, {

+                name: "(GMT-01:00) Azores",

+                value: "<-01>1<+00>,M3.5.0/0,M10.5.0/1_1"

+            }, {

+                name: "(GMT) GMT: Dublin, Edinburgh, London, Lisbon",

+                value: "GMT0IST,M3.5.0/1,M10.5.0_0"

+            }, {

+                name: "(GMT) Casablanca, Monrovia",

+                value: "WET0WEST,M3.5.0,M10.5.0/3_1"

+            }, {

+                name: "(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna",

+                value: "CET-1CEST,M3.5.0,M10.5.0/3_0"

+            }, {

+                name: "(GMT+01:00) Belgrad, Bratislava, Budapest, Ljubljana, Prague",

+                value: "CET-1CEST,M3.5.0,M10.5.0/3_1"

+            }, {

+                name: "(GMT+01:00) Brussels, Copenhagen, Madrid, Paris",

+                value: "CET-1CEST,M3.5.0,M10.5.0/3_2"

+            }, {

+                name: "(GMT+01:00) Sarajevo, Skopje,Warsaw, Zagreb",

+                value: "CET-1CEST,M3.5.0,M10.5.0/3_3"

+            }, {

+                name: "(GMT+01:00) Western Central African",

+                value: "<+01>-1_4"

+            }, {

+                name: "(GMT+02:00) Bucharest",

+                value: "EET-2EEST,M3.5.0/3,M10.5.0/4_0"

+            }, {

+                name: "(GMT+02:00) Pretoria, Harare",

+                value: "CAT-2_1"

+            }, {

+                name: "(GMT+02:00) Helsinki, Kiev, Riga, Sofia, Tallinn, Vilnius",

+                value: "EET-2EEST,M3.5.0/3,M10.5.0/4_2"

+            }, {

+                name: "(GMT+02:00) Cairo",

+                value: "EET-2_3"

+            }, {

+                name: "(GMT+02:00) Athens, Beirut, Istanbul, Minsk",

+                value: "EET-2EEST,M3.5.0/3,M10.5.0/4_4"

+            }, {

+                name: "(GMT+02:00) Jerusalem",

+                value: "IST-2IDT,M3.4.5/02:00:00,M10.5.0/02:00:00_5"

+            }, {

+                name: "(GMT+03:00) Baghdad",

+                value: "<+03>-3_0"

+            }, {

+                name: "(GMT+03:00) Riyadh, Kuwait",

+                value: "<+03>-3_1"

+            }, {

+                name: "(GMT+03:00) Moscow, St Petersburg, Volgograd",

+                value: "<+03>-3_2"

+            }, {

+                name: "(GMT+03:00) Nairobi",

+                value: "EAT-3_3"

+            }, {

+                name: "(GMT+03:30) Teheran",

+                value: "<+0330>-3:30<+0430>,J80/0,J264/0_0"

+            }, {

+                name: "(GMT+04:00) Abu Zabi, Muscat",

+                value: "<+04>-4_0"

+            }, {

+                name: "(GMT+04:00) Baku, Tbilisi, Yerevan",

+                value: "<+04>-4_1"

+            }, {

+                name: "(GMT+04:30) Kabul",

+                value: "<+0430>-4:30_0"

+            }, {

+                name: "(GMT+05:00) Yekaterinburg",

+                value: "<+05>-5_0"

+            }, {

+                name: "(GMT+05:00) Islamabad, Karachi, Tashkent",

+                value: "PKT-5_1"

+            }, {

+                name: "(GMT+05:30) Madras, Calcutta, Mumbai, New Delhi",

+                value: "<+0530>-5:30_0"

+            }, {

+                name: "(GMT+05:45) Kathmandu",

+                value: "<+0545>-5:45_0"

+            }, {

+                name: "(GMT+06:00) Ala Mutu, Novosibirsk",

+                value: "<+06>-6_0"

+            }, {

+                name: "(GMT+06:00) Dhaka, Astana",

+                value: "<+06>-6_1"

+            }, {

+                name: "(GMT+06:00) Sri Haya Ed Denny Pla",

+                value: "<+06>-6_2"

+            }, {

+                name: "(GMT+06:30) Yangon",

+                value: "<+0630>-6:30_0"

+            }, {

+                name: "(GMT+07:00) Krasnoyarsk",

+                value: "<+07>-7_0"

+            }, {

+                name: "(GMT+07:00) Bangkok, Hanoi, Jakarta",

+                value: "<+07>-7_1"

+            }, {

+                name: "(GMT+08:00) Beijing, Chongqing, Hongkong Special Administrative Region, Urumqi",

+                value: "CST-8_0"

+            }, {

+                name: "(GMT+08:00) Kuala Lumpur, Singapore",

+                value: "<+08>-8_1"

+            }, {

+                name: "(GMT+08:00) Perth",

+                value: "AWST-8_2"

+            }, {

+                name: "(GMT+08:00) Taipei",

+                value: "CST-8_3"

+            }, {

+                name: "(GMT+08:00) Irkutsk, Ulam Batu",

+                value: "<+08>-8_4"

+            }, {

+                name: "(GMT+09:00) Osaka, Sapporo, Tokyo",

+                value: "JST-9_0"

+            }, {

+                name: "(GMT+09:00) Seoul",

+                value: "KST-9_1"

+            }, {

+                name: "(GMT+09:00) Yakutsk",

+                value: "<+09>-9_2"

+            }, {

+                name: "(GMT+09:30) Adelaide",

+                value: "ACST-9:30ACDT,M10.1.0,M4.1.0/3_0"

+            }, {

+                name: "(GMT+09:30) Darwin",

+                value: "ACST-9:30_1"

+            }, {

+                name: "(GMT+10:00) Brisbane",

+                value: "AEST-10_0"

+            }, {

+                name: "(GMT+10:00) Vladivostok",

+                value: "<+10>-10_1"

+            }, {

+                name: "(GMT+10:00) Guam, Port Moresby",

+                value: "<+10>-10_2"

+            }, {

+                name: "(GMT+10:00) Hobart",

+                value: "AEST-10AEDT,M10.1.0,M4.1.0/3_3"

+            }, {

+                name: "(GMT+10:00) Canberra, Melbourne, Sydney",

+                value: "AEST-10AEDT,M10.1.0,M4.1.0/3_4"

+            }, {

+                name: "(GMT+11:00) Magadan, Solomon islands, New Caledonia",

+                value: "<+11>-11_0"

+            }, {

+                name: "(GMT+12:00) Wellington, Oakland",

+                value: "<+12>-12_0"

+            }, {

+                name: "(GMT+12:00) Fiji, Kamchatka, Marshall Islands",

+                value: "<+12>-12_1"

+            }, {

+                name: "(GMT+13:00) Nukualofa",

+                value: "<+13>-13_0"

+            }

+        ],

+

+        //短信保存时间

+        SMS_VALIDITY: [{

+                name: '12 hours',

+                value: 'twelve_hours'

+            }, {

+                name: 'A day',

+                value: 'one_day'

+            }, {

+                name: 'A week',

+                value: 'one_week'

+            }, {

+                name: 'The longest period',

+                value: 'largest'

+            }

+        ],

+        MAP_PROTOCOL_MODES: [{

+                name: "TCP+UDP",

+                value: "TCP&UDP"

+            }, {

+                name: "TCP",

+                value: "TCP"

+            }, {

+                name: "UDP",

+                value: "UDP"

+            }

+        ],

+        //端口转发协议

+        FORWARD_PROTOCOL_MODES: [{

+                name: "TCP+UDP",

+                value: "TCP&UDP"

+            }, {

+                name: "TCP",

+                value: "TCP"

+            }, {

+                name: "UDP",

+                value: "UDP"

+            }

+        ],

+        FILTER_PROTOCOL_MODES: [{

+                name: "NONE",

+                value: "None"

+            }, {

+                name: "TCP",

+                value: "TCP"

+            }, {

+                name: "UDP",

+                value: "UDP"

+            }, {

+                name: "ICMP",

+                value: "ICMP"

+            }

+        ],

+

+        //HTTPSHARE模式

+        SD_SHARE_ENABLE: [{

+                name: "Enable",

+                value: "1"

+            }, {

+                name: "Disable",

+                value: "0"

+            }

+        ],

+

+        SD_ACCESS_TYPE: [{

+                name: "entire_sd_card",

+                value: "1"

+            }, {

+                name: "custom_setting",

+                value: "0"

+            }

+        ],

+

+        SD_FILE_TO_SHARE: [{

+                name: "entire_sd_card",

+                value: "1"

+            }, {

+                name: "custom_setting",

+                value: "0"

+            }

+        ],

+

+        //国家码所述类型

+        countryCodeType: {

+            world: 3,

+            mkkc: 3,

+            apld: 7,

+            etsic: 3,

+            fcca: 1

+        },

+

+        countries_5g: {

+            NONE: "NONE",

+            AR: "ARGENTIA",

+            AM: "ՀԱՅԱՍՏԱՆ",

+            AU: "AUSTRILIA",

+            AT: "ÖSTERREICH",

+            AZ: "AZƏRBAYCAN",

+            BH: "البحرين",

+            BY: "БЕЛАРУСЬ",

+            BE: "BELGIË",

+            BA: "БОСНА И ХЕРЦЕГОВИНА",

+            BR: "BRASIL",

+            BN: "BRUNEI DARUSSALAM",

+            BG: "БЪЛГАРИЯ",

+            CL: "CHILE",

+            CN: "中国",

+            CR: "COSTA RICA",

+            HR: "HRVATSKA",

+            CY: "ΚΎΠΡΟΣ",

+            CZ: "ČESKÁ REPUBLIKA",

+            DK: "DANMARK",

+            EC: "ECUADOR",

+            EG: "مصر",

+            SV: "EL SALVADOR",

+            EE: "EESTI",

+            FI: "SUOMI",

+            FR: "FRANCE",

+            GE: "საქართველო",

+            DE: "DEUTSCHLAND",

+            GR: "ΕΛΛΆΔΑ",

+            HK: "香港",

+            HU: "MAGYARORSZÁG",

+            IS: "ÍSLAND",

+            IN: "INDIA",

+            ID: "INDONESIA",

+            IR: "ایران",

+            IE: "ÉIRE",

+            IL: "إسرائيل",

+            IT: "ITALIA",

+            JM: "JAMAICA",

+            JO: "الأردن",

+            KP: "조선민주주의인민공화국",

+            KR: "한국 ROK",

+            LV: "LATVIJA",

+            LI: "LIECHTENSTEIN",

+            LT: "LIETUVA",

+            LU: "LUXEMBOURG",

+            MO: "澳門",

+            MY: "MALAYSIA",

+            MT: "MALTA",

+            MC: "MONACO",

+            NL: "NEDERLAND",

+            AN: "Netherlands Antilles",

+            NO: "NORGE",

+            OM: "سلطنة عمان",

+            PE: "PERÚ",

+            PH: "PHILIPPINES",

+            PL: "POLSKA",

+            PT: "PORTUGAL",

+            SA: "السعودية",

+            SG: "SINGAPORE",

+            SK: "SLOVENSKÁ REPUBLIKA",

+            SI: "SLOVENIJA",

+            ZA: "SOUTH AFRICA",

+            ES: "ESPAÑA",

+            LK: "SRILANKA",

+            SE: "SVERIGE",

+            CH: "SCHWEIZ",

+            TT: "TRINIDAD AND TOBAGO",

+            TN: "تونس",

+            TR: "TÜRKİYE",

+            GB: "UNITED KINGDOM",

+            UY: "URUGUAY",

+            JP: "日本",

+            BZ: "BELIZE",

+            BO: "BOLIVIA",

+            NZ: "NEW ZEALAND",

+            VE: "VENEZUELA",

+            CA: "CANADA",

+            CO: "COLOMBIA",

+            DO: "REPÚBLICA DOMINICANA",

+            GT: "GUATEMALA",

+            MX: "MEXICO",

+            PA: "PANAMÁ",

+            PR: "PUERTO RICO",

+            TW: "台灣",

+            US: "UNITED STATES",

+            UZ: "O’zbekiston"

+        },

+

+        //国家码与语言匹配表

+        countries: {

+            NONE: "NONE",

+            AL: "SHQIPERI",

+            DZ: "الجزائر",

+            AR: "ARGENTIA",

+            AM: "ՀԱՅԱՍՏԱՆ",

+            AU: "AUSTRALIA",

+            AT: "ÖSTERREICH",

+            AZ: "AZƏRBAYCAN",

+            BD: "বাংলাদেশ",

+            BH: "البحرين",

+            BY: "БЕЛАРУСЬ",

+            BE: "BELGIË",

+            BA: "БОСНА И ХЕРЦЕГОВИНА",

+            BR: "BRASIL",

+            BN: "BRUNEI DARUSSALAM",

+            BG: "БЪЛГАРИЯ",

+            CL: "CHILE",

+            CN: "中国",

+            CR: "COSTA RICA",

+            HR: "HRVATSKA",

+            CY: "ΚΎΠΡΟΣ",

+            CZ: "ČESKÁ REPUBLIKA",

+            DK: "DANMARK",

+            EC: "ECUADOR",

+            EG: "مصر",

+            SV: "EL SALVADOR",

+            EE: "EESTI",

+            FI: "SUOMI",

+            FR: "FRANCE",

+            GE: "საქართველო",

+            DE: "DEUTSCHLAND",

+            GR: "ΕΛΛΆΔΑ",

+            HN: "HONDURAS",

+            HK: "香港",

+            HU: "MAGYARORSZÁG",

+            IS: "ÍSLAND",

+            IN: "INDIA",

+            ID: "INDONESIA",

+            IR: "ایران، جمهوری اسلامی",

+            IE: "ÉIRE",

+            IL: "إسرائيل",

+            IT: "ITALIA",

+            JM: "JAMAICA",

+            JO: "الأردن",

+            KZ: "КАЗАХСТАН",

+            KE: "KENYA",

+            KP: "조선민주주의인민공화국",

+            KR: "한국 ROK",

+            KW: "الكويت",

+            LV: "LATVIJA",

+            LB: "لبنان",

+            LI: "LIECHTENSTEIN",

+            LT: "LIETUVA",

+            LU: "LUXEMBOURG",

+            MO: "澳門",

+            MK: "МАКЕДОНИЈА",

+            MY: "MALAYSIA",

+            MT: "MALTA",

+            MC: "MONACO",

+            MA: "المغرب",

+            NL: "NEDERLAND",

+            AN: "NETHERLANDS ANTILLES",

+            NO: "NORGE",

+            OM: "سلطنة عمان",

+            PK: "PAKISTAN",

+            PE: "PERÚ",

+            PH: "PHILIPPINES",

+            PL: "POLSKA",

+            PT: "PORTUGAL",

+            QA: "قطر",

+            RO: "ROMÂNIA",

+            RU: "Российская Федерация",

+            SA: "السعودية",

+            SG: "SINGAPORE",

+            SK: "SLOVENSKÁ REPUBLIKA",

+            SI: "SLOVENIJA",

+            ZA: "SOUTH AFRICA",

+            ES: "ESPAÑA",

+            LK: "SRILANKA",

+            SE: "SVERIGE",

+            CH: "SCHWEIZ",

+            SY: "الجمهورية العربية السورية",

+            TH: "ประเทศไทย",

+            TT: "TRINIDAD AND TOBAGO",

+            TN: "تونس",

+            TR: "TÜRKİYE",

+            UA: "Україна",

+            AE: "الإمارات العربية المتحدة",

+            GB: "UNITED KINGDOM",

+            UY: "URUGUAY",

+            VN: "VIỆT NAM",

+            YE: "اليمن",

+            ZW: "ZIMBABWE",

+            JP: "日本",

+            BZ: "BELIZE",

+            BO: "BOLIVIA",

+            NZ: "NEW ZEALAND",

+            VE: "REPÚBLICA BOLIVARIANA DE VENEZUELA",

+            CA: "CANADA",

+            CO: "COLOMBIA",

+            DO: "REPÚBLICA DOMINICANA",

+            GT: "GUATEMALA",

+            MX: "MEXICO",

+            PA: "PANAMÁ",

+            PR: "PUERTO RICO",

+            TW: "台灣",

+            US: "UNITED STATES",

+            UZ: "O’zbekiston"

+        },

+        //国家码与类型匹配表

+        countryCode_5g: {

+            //88 countries of world【36 40 44 48】

+            one: {

+                codes: ["AL", "AI", "AW", "AT", "BY", "BM", "BA", "BW", "IO", "BG",

+                    "CV", "HR", "CY", "CZ", "DK", "EE", "FI", "FR", "GF", "PF",

+                    "TF", "GI", "DE", "GR", "GP", "GG", "HU", "IS", "IE", "IT",

+                    "KE", "LA", "LV", "LS", "LI", "LT", "LU", "MK", "MT", "IM",

+                    "MQ", "MR", "MU", "YT", "MC", "MS", "NL", "AN", "NO",

+                    "OM", "PL", "PT", "RE", "RO", "SM", "SN", "RS", "SK", "SI",

+                    "ZA", "ES", "SE", "CH", "TC", "UG", "GB", "VG", "WF", "ZM",

+                    "AF", "JO", "MA", "EH", "EU", "DZ", "IL", "MX", "PM", "TN",

+                    "TR", "JP"],

+                channels: [36, 40, 44, 48]

+            },

+            //60 countrys of world【36 40 44 48 149 153 157 161 165】

+            two: {

+                codes: ["AS", "AG", "AZ", "BR", "KH", "KY", "CO", "CR", "DM", "DO",

+                    "EC", "GH", "GD", "HK", "KZ", "KI", "FM", "MZ", "NA", "NZ",

+                    "NI", "NE", "PW", "PE", "PH", "PR", "VC", "TH", "TT", "UY",

+                    "ZW", "AU", "BH", "BB", "CA", "CL", "CX", "EG", "SV", "GT",

+                    "HT", "IN", "MY", "NF", "PA", "PG", "SG", "US", "VN"],

+                channels: [36, 40, 44, 48, 149, 153, 157, 161, 165]

+            },

+            //9 countrys of world【149 153 157 161】

+            three: {

+                codes: ["CU", "IR", "KR", "SY", "LB", "MW", "MO", "QA"],

+                channels: [149, 153, 157, 161]

+            },

+            //12 countrys of world【149 153 157 161 165】

+            four: {

+                codes: ["BD", "BF", "CN", "HN", "JM", "PK", "PY", "KN", "AR", "TW", "NG"],

+                channels: [149, 153, 157, 161, 165]

+            },

+            //1 country of world【36 40 44 48 149 153 157 161】

+            five: {

+                codes: ["SA"],

+                channels: [36, 40, 44, 48, 149, 153, 157, 161]

+            }

+        },

+        countryCode: {

+            world: ["AL", "DZ", "AR", "AM", "AU", "AT", "AZ", "BH", "BY",

+                "BE", "BA", "BR", "BN", "BG", "CL", "CN", "CR", "HR", "CY",

+                "CZ", "DK", "EC", "EG", "SV", "EE", "FI", "FR", "GE",

+                "DE", "GR", "HN", "HK", "HU", "IS", "IN", "ID", "IR", "IE",

+                "IL", "IT", "JM", "JO", "KZ", "KE", "KP", "KR", "KW", "LV",

+                "LB", "LI", "LT", "LU", "MO", "MK", "MY", "MT", "MC", "MA",

+                "NL", "AN", "NO", "OM", "PK", "PE", "PH", "PL", "PT", "QA",

+                "RO", "RU", "SA", "SG", "SK", "SI", "ZA", "ES", "LK",

+                "SE", "CH", "SY", "TH", "TT", "TN", "TR", "UA", "AE", "GB",

+                "UY", "VN", "YE", "ZW", "BD"],

+            mkkc: ["JP"],

+            apld: [],

+            etsic: ["BZ", "BO", "NZ", "VE"],

+            fcca: ["CA", "CO", "DO", "GT", "MX", "PA", "PR", "TW", "US", "UZ"]

+        },

+        //休眠时间

+        SLEEP_MODES: [{

+                name: "Always on",

+                value: "-1"

+            }, {

+                name: "5 minutes",

+                value: "5"

+            }, {

+                name: "10 minutes",

+                value: "10"

+            }, {

+                name: "20 minutes",

+                value: "20"

+            }, {

+                name: "30 minutes",

+                value: "30"

+            }, {

+                name: "1 hour",

+                value: "60"

+            }, {

+                name: "2 hours",

+                value: "120"

+            }

+        ],

+        DDNSSetMode: [{

+                name: 'Enable',

+                value: '1'

+            }, {

+                name: 'Disable',

+                value: '0'

+            }

+        ],

+        ddns_Modeselect: [{

+                name: 'manual',

+                value: 'manual'

+            }, {

+                name: 'auto',

+                value: 'auto'

+            }

+        ],

+        DDNSDDP: [{

+                name: 'dyndns.org',

+                value: 'dyndns.org'

+            }, {

+                name: 'freedns.afraid.org',

+                value: 'freedns.afraid.org'

+            }, {

+                name: 'zoneedit.com',

+                value: 'zoneedit.com'

+            }, {

+                name: 'no-ip.com',

+                value: 'no-ip.com'

+            }, {

+                name: 'None',

+                value: 'none'

+            }

+        ],

+        //RJ45连接模式

+        pppoeModes: [{

+                name: "PPPoE",

+                value: "PPPOE"

+            }, {

+                name: "Static",

+                value: "STATIC"

+            }, {

+                name: "DHCP",

+                value: "DHCP"

+            }, {

+                name: "AUTO",

+                value: "AUTO"

+            }

+        ],

+        //联网模式

+        AUTO_MODES: [{

+                name: 'Automatic',

+                value: 'NETWORK_auto'

+            }, {

+                name: '4G Only',

+                value: 'Only_LTE'

+            }, {

+                name: '3G Only',

+                value: 'Only_WCDMA'

+            }, {

+                name: '2G Only',

+                value: 'Only_GSM'

+            }

+        ],

+        //APN鉴权模式

+        APN_AUTH_MODES: [{

+                name: "NONE",

+                value: "none"

+            }, {

+                name: "CHAP",

+                value: "chap"

+            }, {

+                name: "PAP",

+                value: "pap"

+            }

+        ],

+        //语言

+        LANGUAGES: [{

+                name: 'English',

+                value: 'en'

+            }, {

+                name: '中文',

+                value: 'zh-cn'

+            }

+        ],

+        //wifi加密模式

+        AUTH_MODES: [{

+                name: 'NO ENCRYPTION',

+                value: 'OPEN'

+            }, {

+                name: 'WPA2(AES)-PSK',

+                value: 'WPA2PSK'

+            }, {

+                name: 'WPA-PSK/WPA2-PSK',

+                value: 'WPAPSKWPA2PSK'

+            }, {

+                name: 'WPA3-Personal',

+                value: 'WPA3Personal'

+            }, {

+                name: 'WPA2(AES)/WPA3-Personal',

+                value: 'WPA2WPA3'

+            }

+        ],

+        AUTH_MODES_WEP: [{

+                name: 'NO ENCRYPTION',

+                value: 'OPEN'

+            }, {

+                name: 'SHARED',

+                value: 'SHARED'

+            }, {

+                name: 'WPA2(AES)-PSK',

+                value: 'WPA2PSK'

+            }, {

+                name: 'WPA-PSK/WPA2-PSK',

+                value: 'WPAPSKWPA2PSK'

+            }, {

+                name: 'WPA3-Personal',

+                value: 'WPA3Personal'

+            }, {

+                name: 'WPA2(AES)/WPA3-Personal',

+                value: 'WPA2WPA3'

+            }

+        ],

+        AUTH_MODES_ALL: [{

+                name: 'NO ENCRYPTION',

+                value: 'OPEN'

+            }, {

+                name: 'SHARED',

+                value: 'SHARED'

+            }, {

+                name: 'WPA-PSK',

+                value: 'WPAPSK'

+            }, {

+                name: 'WPA2-PSK',

+                value: 'WPA2PSK'

+            }, {

+                name: 'WPA-PSK/WPA2-PSK',

+                value: 'WPAPSKWPA2PSK'

+            }, /*{

+                name: 'WPA3-Personal',

+                value: 'WPA3Personal'

+            }, {

+                name: 'WPA2(AES)/WPA3-Personal',

+                value: 'WPA2WPA3'

+            }, */{

+                name: 'EAP-SIM/AKA',

+                value: 'EAP-SIM/AKA'

+            }

+        ],

+

+        NETWORK_MODES: [{

+                name: '802.11 b/g/n',

+                value: '4'

+            }, {

+                name: '802.11 n only',

+                value: '2'

+            }

+        ],

+        NETWORK_MODES_BAND: [{

+                name: '802.11 a only',

+                value: '5'

+            }, {

+                name: '802.11 n only',

+                value: '2'

+            }, {

+                name: '802.11 a/n',

+                value: '4'

+            }

+        ],

+        resetContentModifyValue: function () {

+            this.CONTENT_MODIFIED.checkChangMethod = function () {

+                return false;

+            };

+            this.CONTENT_MODIFIED.modified = false;

+            this.CONTENT_MODIFIED.message = 'leave_page_info';

+            this.CONTENT_MODIFIED.callback = {

+                ok: $.noop,

+                no: function () {

+                    return true;

+                }

+            }; //如果no返回true,页面则保持原状

+            this.CONTENT_MODIFIED.data = {};

+        },

+        CONTENT_MODIFIED: {

+            modified: false,

+            message: 'leave_page_info',

+            data: {},

+            checkChangMethod: function () {

+                return false;

+            },

+            callback: {

+                ok: $.noop,

+                no: function () {

+                    return true;

+                }

+            } //如果no返回true,页面则保持原状

+        }, //当前页面内容是否已经修改

+

+    };

+

+    require([config.DEVICE + '/set'], function (otherConf) {

+        $.extend(config, otherConf);

+    });

+

+    return config;

+});

diff --git a/lynq/S300/ap/app/zte_webui/js/sim_device.js b/lynq/S300/ap/app/zte_webui/js/sim_device.js
new file mode 100755
index 0000000..633e2e6
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/js/sim_device.js
@@ -0,0 +1,5028 @@
+define("sim_abnormal","jquery knockout service set main opmode".split(" "),

+    function ($, ko, service, config, home, opmode) {

+

+    function init() {

+        var container = $('#container')[0];

+        ko.cleanNode(container);

+        var vm = new simViewMode();

+        ko.applyBindings(vm, container);

+

+        $('#frmPUK').validate({

+            submitHandler: function () {

+                vm.enterPUK();

+            },

+            rules: {

+                txtNewPIN: "pin_check",

+                txtConfirmPIN: {

+                    equalToPin: "#txtNewPIN"

+                },

+                txtPUK: "puk_check"

+            }

+        });

+

+        $('#frmPIN').validate({

+            submitHandler: function () {

+                vm.enterPIN();

+            },

+            rules: {

+                txtPIN: "pin_check"

+            }

+        });

+    }

+

+    function simViewMode() {

+        var target = this;

+        var staInfo = service.getStatusInfo();

+        var curCableMode = "PPPOE" == staInfo.blc_wan_mode || "AUTO_PPPOE" == staInfo.blc_wan_mode;

+        target.hasRj45 = config.RJ45_SUPPORT;

+        target.hasSms = config.HAS_SMS;

+        target.hasPhonebook = config.HAS_PHONEBOOK;

+        target.isSupportSD = config.SD_CARD_SUPPORT;

+        if (config.WIFI_SUPPORT_QR_SWITCH) {

+            var wifiInfo = service.getWifiBasic();

+            target.showQRCode = config.WIFI_SUPPORT_QR_CODE && wifiInfo.show_qrcode_flag;

+        } else {

+            target.showQRCode = config.WIFI_SUPPORT_QR_CODE;

+        }

+        if(config.WIFI_SUPPORT_QR_CODE){

+            target.qrcodeSrc = './pic/qrcode_ssid_wifikey.png?_=' + $.now();

+        } else {

+            target.qrcodeSrc = './pic/res_blacktrans.png';

+        }

+        target.hasParentalControl = ko.observable(config.HAS_PARENTAL_CONTROL && curCableMode);

+        target.pageState = {

+            NO_SIM: 0,

+            WAIT_PIN: 1,

+            WAIT_PUK: 2,

+            PUK_LOCKED: 3,

+            LOADING: 4

+        };

+        target.isHomePage = ko.observable(false);

+        if (window.location.hash == "#main") {

+            target.isHomePage(true);

+        }

+

+        var info = service.getLoginData();

+        target.PIN = ko.observable();

+        target.newPIN = ko.observable();

+        target.confirmPIN = ko.observable();

+        target.PUK = ko.observable();

+        target.pinNumber = ko.observable(info.pinnumber);

+        target.pukNumber = ko.observable(info.puknumber);

+

+        var state = computePageState(info);

+        target.page = ko.observable(state);

+        if (state == target.pageState.LOADING) {

+            addTimeout(refreshPage, 500);

+        }

+        target.showOpModeWindow = function () {

+            showSettingWindow("change_mode", "opmode_popup", "opmode_popup", 400, 300, function () {});

+        };

+        target.isLoggedIn = ko.observable(false);

+        target.enableFlag = ko.observable(false);

+        //更新当前工作模式状态信息

+        target.refreshOpmodeInfo = function () {

+            var staInfo = service.getStatusInfo();

+            target.isLoggedIn(staInfo.isLoggedIn);

+

+            if (!curCableMode && checkCableMode(staInfo.blc_wan_mode)) { //如果有线,则重新加载

+                if (target.page() == target.pageState.NO_SIM || target.page() == target.pageState.WAIT_PIN || target.page() == target.pageState.WAIT_PUK || target.page() == target.pageState.PUK_LOCKED) {

+                    window.location.reload();

+                }

+            }

+

+            curCableMode = checkCableMode(staInfo.blc_wan_mode);

+            target.hasParentalControl(config.HAS_PARENTAL_CONTROL && curCableMode);

+            if (curCableMode && staInfo.ethWanMode.toUpperCase() == "DHCP") {

+                target.enableFlag(true);

+            } else if ((!curCableMode && staInfo.connectStatus != "ppp_disconnected") || (curCableMode && staInfo.rj45ConnectStatus != "idle" && staInfo.rj45ConnectStatus != "dead")) {

+                target.enableFlag(false);

+            } else {

+                target.enableFlag(true);

+            }

+            var mode = (staInfo.blc_wan_mode == "AUTO_PPP" || staInfo.blc_wan_mode == "AUTO_PPPOE") ? "AUTO" : staInfo.blc_wan_mode;

+            var currentOpMode = "";

+            switch (mode) {

+            case "PPP":

+                currentOpMode = "opmode_gateway";

+                break;

+            case "PPPOE":

+                currentOpMode = "opmode_cable";

+                break;

+            case "AUTO":

+                currentOpMode = "opmode_auto";

+                break;

+            default:

+                break;

+            }

+            $("#opmode").attr("data-trans", currentOpMode).text($.i18n.prop(currentOpMode));

+        }

+        //刷新页面状态

+        function refreshPage() {

+            var data = service.getLoginData();

+            var state = computePageState(data);

+            if (state == target.pageState.LOADING) {

+                addTimeout(refreshPage, 500);

+            } else {

+                target.page(state);

+                target.pinNumber(data.pinnumber);

+                target.pukNumber(data.puknumber);

+            }

+        }

+        //输入PUK设置新PIN事件处理

+        target.enterPUK = function () {

+            showLoading();

+            target.page(target.pageState.LOADING);

+            var newPIN = target.newPIN();

+            var confirmPIN = target.confirmPIN();

+            var params = {};

+            params.PinNumber = newPIN;

+            params.PUKNumber = target.PUK();

+            service.enterPUK(params, function (data) {

+                if (!data.result) {

+                    hideLoading();

+                    if (target.pukNumber() == 2) {

+                        showAlert("last_enter_puk", function () {

+                            refreshPage();

+                        });

+                    } else {

+                        showAlert("puk_error", function () {

+                            refreshPage();

+                            if (target.page() == target.pageState.PUK_LOCKED) {

+                                hideLoading();

+                            }

+                        });

+                    }

+                    target.PUK('');

+                    target.newPIN('');

+                    target.confirmPIN('');

+                } else {

+                    refreshPage();

+                    if (target.page() == target.pageState.PUK_LOCKED) {

+                        hideLoading();

+                    }

+                }

+            });

+        };

+        //验证输入PIN事件处理

+        target.enterPIN = function () {

+            showLoading();

+            target.page(target.pageState.LOADING);

+            var pin = target.PIN();

+            service.enterPIN({

+                PinNumber: pin

+            }, function (data) {

+                if (!data.result) {

+                    hideLoading();

+                    if (target.pinNumber() == 2) {

+                        showAlert("last_enter_pin", function () {

+                            refreshPage();

+                        });

+                    } else {

+                        showAlert("pin_error", function () {

+                            refreshPage();

+                        });

+                    }

+                    target.PIN('');

+                }

+                refreshPage();

+                if (target.page() == target.pageState.WAIT_PUK) {

+                    hideLoading();

+                }

+            });

+        };

+

+        if (target.hasRj45) {

+            target.refreshOpmodeInfo();

+            addInterval(function () {

+                target.refreshOpmodeInfo();

+            }, 1000);

+        }

+        //根据登录状态和SIM卡状态设置页面状态

+        function computePageState(data) {

+            var state = data.modem_main_state;

+            if (state == "modem_undetected" || state == "modem_sim_undetected" || state == "modem_sim_destroy") {

+                return target.pageState.NO_SIM;

+            } else if (state == "modem_waitpin") {

+                return target.pageState.WAIT_PIN;

+            } else if ((state == "modem_waitpuk" || data.pinnumber == 0) && (data.puknumber != 0)) {

+                return target.pageState.WAIT_PUK;

+            } else if ((data.puknumber == 0 || state == "modem_sim_destroy") && state != "modem_sim_undetected" && state != "modem_undetected") {

+                return target.pageState.PUK_LOCKED;

+            } else if ($.inArray(state, config.TEMPORARY_MODEM_MAIN_STATE) != -1) {

+                return target.pageState.LOADING;

+            } else {

+                location.reload();

+            }

+        }

+

+    }

+

+    return {

+        init: init

+    };

+});

+

+define("ota_update", "jquery jq_fileinput service knockout set statusBar".split(" "), 

+

+    function ($, fileinput, service, ko, config, status) {

+

+    function FotaUpdateViewModel() {

+        var target    = this;

+        var setting = service.getOTAUpdateSetting();		

+        var upgUrl = service.getManualOTAUpdateSetting();

+

+        target.allowRoamingUpdate = ko.observable(setting.allowRoamingUpdate);		

+		target.hasDdns            = config.DDNS_SUPPORT;

+		target.hasUpdateCheck     = config.HAS_UPDATE_CHECK;	

+		target.hasUssd            = config.HAS_USSD;		

+        target.isDataCard         = config.PRODUCT_TYPE == 'DATACARD';

+        target.lastCheckTime      = ko.observable('');	

+        target.updateIntervalDay  = ko.observable(setting.updateIntervalDay);		

+        target.updateMode         = ko.observable(setting.updateMode);

+		target.updateType         = ko.observable(service.getUpdateType().update_type);

+        target.updateURL          = ko.observable(upgUrl.updateURL);

+

+        // 手动ota升级事件

+        target.ota_upgrade_apply = function () {

+            var otaUpdateURLInfo = {

+                updateURL: target.updateURL()

+            };

+            showLoading();

+            service.setManualOTAUpdateSetting(otaUpdateURLInfo, function (settingInfo) {

+                if (settingInfo && settingInfo.result == "success") {

+                    successOverlay();

+                } else {

+                    errorOverlay();

+                }

+            });

+        };

+

+

+        // 自动检测设置按钮事件

+        target.apply = function () {

+            var updateSettingInfo = {

+                updateMode: target.updateMode(),

+                updateIntervalDay: target.updateIntervalDay(),

+                allowRoamingUpdate: target.allowRoamingUpdate()

+            };

+            showLoading();

+            service.setOTAUpdateSetting(updateSettingInfo, function (settingInfo) {

+                if (settingInfo && settingInfo.result == "success") {

+                    setting.allowRoamingUpdate = target.allowRoamingUpdate();

+                    successOverlay();

+                } else {

+                    errorOverlay();

+                }

+            });

+        };

+

+

+        // 按钮【检测】点击事件处理接口

+        target.checkNewVersion = function () {

+            var newVersionState = service.getNewVersionState();

+			if(newVersionState.fota_package_already_download == "yes"){

+				showAlert("fota_package_already_download");

+				return;

+			}

+

+            if(config.UPGRADE_TYPE=="FOTA"){

+                var checkingState = ["checking"];

+                if ($.inArray(newVersionState.fota_current_upgrade_state, checkingState) != -1) {

+                    showAlert("ota_update_running");

+                    return;

+                }

+            }

+

+			// FOTA开始下载前,判断当前是否已经在下载过程中,防止错误清空fota_new_version_state状态

+            var statusInfo = service.getStatusInfo();

+            if (newVersionState.fota_current_upgrade_state == "prepare_install") {

+                showInfo('ota_download_success');

+                return;

+            }

+

+            var upgradingState = ["downloading", "confirm_dowmload"];

+            if ($.inArray(newVersionState.fota_current_upgrade_state, upgradingState) != -1) {

+                status.showOTAAlert();

+                return;

+            }

+

+            if (statusInfo.roamingStatus) {

+                showConfirm("ota_check_roaming_confirm", function () {

+                    checkNewVersion();

+                });

+            } else {

+                checkNewVersion();

+            }

+            // 检测是否有新版本

+            function checkNewVersion() {

+                showLoading("ota_new_version_checking");

+                function checkNewVersionResult() {

+                    var result = service.getNewVersionState();

+                    if (result.hasNewVersion) {

+						if(result.fota_new_version_state == "already_has_pkg"&&result.fota_current_upgrade_state !="prepare_install"&&result.fota_current_upgrade_state !="low_battery")

+						{

+							addTimeout(checkNewVersionResult, 1000);

+						}

+						else

+						{

+							status.showOTAAlert();

+						}

+                    } else if (result.fota_new_version_state == "no_new_version") {

+                        showAlert("ota_no_new_version");

+                    }else if (result.fota_new_version_state == "check_failed" ) {

+                        errorOverlay("ota_check_fail");

+                    } else if ( result.fota_new_version_state == "bad_network"){

+                     	errorOverlay("ota_connect_server_failed");

+                    }else {

+                        addTimeout(checkNewVersionResult, 1000);

+                    }

+                }

+

+                service.setUpgradeSelectOp({selectOp: 'check'}, function (result) {

+                    if (result.result == "success") {

+                        checkNewVersionResult();

+                    } else {

+                        errorOverlay();

+                    }

+                });

+            }

+        };

+

+

+

+        // 确认按钮状态:可用/灰化

+        target.fixPageEnable = function () {

+            var connectStatusInfo = service.getStatusInfo();

+			var opModeData = service.getOpMode();

+            if (checkConnectedStatus(connectStatusInfo.connectStatus, opModeData.rj45_state, connectStatusInfo.connectWifiStatus)) {

+                enableBtn($("#btnCheckNewVersion"));

+            } else {

+                disableBtn($("#btnCheckNewVersion"));

+            }

+        };

+

+        target.clickAllowRoamingUpdate = function () {

+            var checkedbox = $("#chkUpdateRoamPermission:checked");

+            if (checkedbox && checkedbox.length == 0) {

+                target.allowRoamingUpdate("1");

+            } else {

+                target.allowRoamingUpdate("0");

+            }

+        };

+

+        service.getOTAlastCheckTime({}, function(info){

+            target.lastCheckTime(info.dm_last_check_time);

+        });

+

+	}

+    // 获取升级文件大小

+	function getFileSize(object){

+		var fileLenth = 0;

+		var isIE = /msie/i.test(navigator.userAgent) && !window.opera; 

+		if (isIE) {  //如果是ie

+			var objectValue = object.value;

+			try {  

+				var fso = new ActiveXObject("Scripting.FileSystemObject");  

+				fileLenth = parseInt(fso.GetFile(objectValue).size);

+				} catch (e) {  

+				fileLenth = 1;					

+			} 

+		}else{  //对于非IE获得要上传文件的大小			

+			try{			

+				fileLenth = parseInt(object.files[0].size);

+			}catch (e) {

+				fileLenth = 1;  //获取不到取-1

+			}

+		}

+		return fileLenth/1024/1024;

+	} 

+

+    function init() {

+        var container = $('#container')[0];

+        ko.cleanNode(container);

+        var fwVm = new FotaUpdateViewModel();

+        ko.applyBindings(fwVm, container);		

+

+        if(fwVm.updateType() == "mifi_fota"){

+            fwVm.fixPageEnable();

+            addInterval(function () {            

+                fwVm.fixPageEnable();          

+            }, 1000);

+		}else{			

+	        if ($(".customfile").length == 0) {

+			    $("#fileField").customFileInput();

+		    }

+		}

+

+        $('#frmOTAUpdate').validate({

+            submitHandler: function () {

+                fwVm.apply();

+            }

+        });

+    }

+

+    return {

+        init: init

+    };

+});

+

+// SD卡 模块

+

+define("sd", "jquery set service knockout".split(" ") , function($, config, service, ko) {

+

+	// 基目录。感觉此根目录不显示给用户会更友好

+	var basePath = config.SD_BASE_PATH;

+

+	function SDCardViewModel() {

+		var target = this;

+		var SDConfiguration      = service.getSDConfiguration();

+

+        target.selectedMode        = ko.observable(SDConfiguration.sd_mode);

+        target.orignalMode         = ko.observable(SDConfiguration.sd_mode);

+        target.sdStatus            = ko.observable(SDConfiguration.sd_status);

+		target.orignalSdStatus     = ko.observable(SDConfiguration.sd_status);

+        target.sdStatusInfo        = ko.observable("sd_card_status_info_" + SDConfiguration.sd_status);

+        target.selectedShareEnable = ko.observable(SDConfiguration.share_status);

+        target.selectedFileToShare = ko.observable(SDConfiguration.file_to_share);

+        target.selectedAccessType  = ko.observable(SDConfiguration.share_auth);

+

+		var path = SDConfiguration.share_file.substring(basePath.length);

+

+        target.pathToShare         = ko.observable(path);

+        target.isInvalidPath       = ko.observable(false);

+		target.checkEnable         = ko.observable(true);

+

+

+	    addInterval(function(){

+			target.refreshSimStatus();

+		}, 3000);

+

+        // 检查共享路径是否有效

+        target.checkPathIsValid = ko.computed(function () {

+            if (target.orignalMode() == 0 && target.selectedShareEnable() == '1' && target.selectedFileToShare() == '0'

+                && target.pathToShare() != '' && target.pathToShare() != '/') {

+                service.checkFileExists({

+                    "path": basePath + target.pathToShare()

+                }, function (info) {

+                    if (info.status != "exist") {

+                        target.isInvalidPath(true);

+                    } else {

+                        target.isInvalidPath(false);

+                    }

+                });

+            } else {

+                target.isInvalidPath(false);

+            }

+        });	

+

+

+        target.disableApplyBtn = ko.computed(function(){

+            return target.selectedMode() == target.orignalMode() && target.selectedMode() == '1';

+        });

+

+		// 文件共享方式radio点击事件

+		target.fileToShareClickHandle = function(){

+			if(target.selectedFileToShare() == "1"){

+				target.pathToShare("/");

+			}

+			return true;

+		};		

+

+		// T卡热插拔时状态监控,拔插卡重刷界面

+		target.refreshSimStatus = function(){

+			if(target.checkEnable()){

+				var SDConfiguration = service.getSDConfiguration();

+			    if(SDConfiguration.sd_status && (SDConfiguration.sd_status != target.orignalSdStatus())){

+				    if(SDConfiguration.sd_status != '1'){

+						target.sdStatusInfo("sd_card_status_info_" + SDConfiguration.sd_status);

+						target.sdStatus(SDConfiguration.sd_status);

+		                target.orignalSdStatus(SDConfiguration.sd_status);

+						$("#sd_card_status_info").translate();

+					}else{

+						clearTimer();

+					    clearValidateMsg();

+					    init();

+					}

+			    }

+			}			

+		}

+

+

+

+

+

+		// 表单submit事件处理

+		target.save = function(){

+			showLoading('waiting');

+			target.checkEnable(false);

+			if(target.orignalMode() == target.selectedMode()){

+				showAlert("setting_no_change");

+			} else {

+				service.setSdCardMode({

+					mode : target.selectedMode()

+				}, function(info) {

+					if(info.result){

+                        target.orignalMode(target.selectedMode());

+						if(info.result == "processing"){

+							errorOverlay("sd_usb_forbidden");

+						}else{								

+						    successOverlay();

+						}

+					} else {

+						if (target.selectedMode() == "0") {

+							errorOverlay("sd_not_support");

+						} else {

+						    errorOverlay();

+						}

+					}

+				}, function(error) {

+					if (target.selectedMode() == "0") {

+						errorOverlay("sd_not_support");

+					} else {

+					    errorOverlay();

+					}

+				});

+			}

+			target.checkEnable(true);

+			return true;

+		};

+

+

+

+		// 保存详细配置信息

+        target.saveShareDetailConfig = function() {

+            showLoading('waiting');

+            target.checkEnable(false);			

+            var param = {

+                share_status : target.selectedShareEnable(),

+                share_auth : target.selectedAccessType(),

+                share_file : basePath + target.pathToShare()

+            };

+

+            if (target.selectedShareEnable() == "0") {

+                setSdCardSharing(param);

+            } else {

+                service.checkFileExists({

+                    "path" : param.share_file

+                }, function(info) {

+                    if (info.status != "exist" && info.status != "processing") {

+                        errorOverlay("sd_card_share_setting_" + info.status);

+                    } else {

+                        setSdCardSharing(param);

+                    }

+                }, function(){

+                    errorOverlay();

+                });

+            }

+

+            target.checkEnable(true);

+            return true;

+		}

+

+		// 设置SD卡共享信息

+        function setSdCardSharing(param){

+			service.setSdCardSharing(param, function(result) {

+				if (isErrorObject(result)) {

+					if (result.errorType == "no_sdcard") {

+						errorOverlay("sd_card_share_setting_no_sdcard");

+					} else {

+						errorOverlay();

+					}

+				} else {

+					successOverlay();

+				}

+			});

+		}

+	}

+

+	// 将配置的option项转换成Option数组

+	// {Array} configItem [{name: "name1", value: "val1"},{name: "name2", value: "val2"}]

+	function getOptionArray(configItem) {

+		var arr = [];

+		for ( var i = 0; i < configItem.length; i++) {

+			arr.push(new Option(configItem.name, configItem.value));

+		}

+		return arr;

+	}

+

+	function init() {

+		var container = $('#container')[0];

+		ko.cleanNode(container);

+		var fwVm = new SDCardViewModel();

+		ko.applyBindings(fwVm, container);

+		$("#sd_card_status_info").translate();

+		$('#sdmode_form').validate({

+			submitHandler : function() {

+				fwVm.save();

+			}

+		});

+		$('#httpshare_form').validate({

+			submitHandler : function() {

+				fwVm.saveShareDetailConfig();

+			},

+			rules : {

+				path_to_share : "check_file_path"

+			}

+		});

+	}

+

+	return {

+		init : init

+	};

+});

+

+// SD卡 HttpShare模块

+

+define("sd_httpshare","jquery underscore jq_fileinput set service knockout".split(" ") , 

+

+	function($, _, fileinput, config, service, ko) {

+

+	// 每页记录条数

+	// 不能够设置每页数据个数,默认:10

+	// 默认值不可修改

+	var perPage = 10;

+

+	// 当前页

+	var activePage = 1;

+

+	// 当前目录,默认根目录""

+	var currentPath = "";

+

+	// 基目录。是否需要显示给用户?用户友好度

+	var basePath = config.SD_BASE_PATH;

+

+	// 前置路径,发现有的设备会将sd卡数据显示在web目录

+	// prePath = "/usr/conf/web";

+	var prePath = "";

+

+	// 是否隐藏重命名按钮

+	var readwrite = true;

+

+	// 文件列表模板

+	var sdFileItemTmpl = null;

+

+	// 分页模板

+	var pagerTmpl = null;

+    // 配置信息原始状态

+    var originalStatus = null;

+

+    var zoneOffsetSeconds = new Date().getTimezoneOffset() * 60;

+

+    var shareFilePath = '';

+

+	var sdIsUploading = false;//SD卡是否正在上传文件

+

+	// 生成分页数据数组

+	// @method generatePager

+	// @param {Integer} totalSize 总记录数

+	// @param {Integer} perPageNum 每页记录条数

+	// @param {Integer} currentPage 当前页

+	// @return {Array} 分页数据数组

+	function generatePager(totalSize, perPageNum, currentPage) {

+        if (totalSize == 0) {

+            return [];

+        }

+        var pagersArr = [];

+        var totalPages = getTotalPages(totalSize, perPageNum);

+        pagersArr.push({

+            pageNum: currentPage - 1,

+            isActive: false,

+            isPrev: true,

+            isNext: false,

+            isDot: false

+        });

+        if (currentPage == 6) {

+            pagersArr.push({

+                pageNum: 1,

+                isActive: false,

+                isPrev: false,

+                isNext: false,

+                isDot: false

+            });

+        } else if (currentPage > 5) {

+            pagersArr.push({

+                pageNum: 1,

+                isActive: false,

+                isPrev: false,

+                isNext: false,

+                isDot: false

+            });

+            pagersArr.push({

+                pageNum: 0,

+                isPrev: false,

+                isNext: false,

+                isActive: false,

+                isDot: true

+            });

+        }

+        var i;

+        var startPage = currentPage - 4 > 0 ? currentPage - 4 : 1;

+        var endPage = currentPage + 4;

+        for (i = startPage; i <= endPage && i <= totalPages; i++) {

+            pagersArr.push({

+                pageNum: i,

+                isActive: i == currentPage,

+                isPrev: false,

+                isNext: false,

+                isDot: false

+            });

+        }

+        if (currentPage + 5 == totalPages) {

+            pagersArr.push({

+                pageNum: totalPages,

+                isPrev: false,

+                isNext: false,

+                isActive: false,

+                isDot: false

+            });

+        } else if (currentPage + 3 <= totalPages && i - 1 != totalPages) {

+            pagersArr.push({

+                pageNum: 0,

+                isPrev: false,

+                isNext: false,

+                isActive: false,

+                isDot: true

+            });

+            pagersArr.push({

+                pageNum: totalPages,

+                isPrev: false,

+                isNext: false,

+                isActive: false,

+                isDot: false

+            });

+        }

+        pagersArr.push({

+            pageNum: parseInt(currentPage, 10) + 1,

+            isPrev: false,

+            isNext: true,

+            isActive: false,

+            isDot: false

+        });

+        return pagersArr;

+	}

+

+	function getTotalPages(total, perPage){

+		var totalPages = Math.floor(total / perPage);

+		if (total % perPage != 0) {

+			totalPages++;

+		}

+		return totalPages;

+	}

+

+	// 整理文件列表数据,并用模板显示

+	function showFileSet(files) {

+		var i = 0;

+		var shownFiles = $.map(files, function(n) {

+			var obj = {

+				fileName : HTMLEncode(n.fileName),

+				fileType : n.attribute == 'document' ? 'folder' : getFileType(n.fileName),

+				fileSize : getDisplayVolume(n.size, false),

+				filePath : basePath + getCurrentPath() + "/" + n.fileName,

+                lastUpdateTime : transUnixTime((parseInt(n.lastUpdateTime, 10) + zoneOffsetSeconds) * 1000),

+				trClass : i % 2 == 0 ? "even" : "",

+				readwrite : readwrite

+			};

+			i++;

+			return obj;

+		});

+

+		if(sdFileItemTmpl == null){

+			sdFileItemTmpl = $.template("sdFileItemTmpl", $("#sdFileItemTmpl"));

+		}

+		$("#fileList_container").html($.tmpl("sdFileItemTmpl", {data: shownFiles}));

+	}

+

+	// HttpShareViewModel

+	function HttpShareViewModel() {

+		var isGuest = false;

+		if(window.location.hash == "#httpshare_guest"){

+			isGuest = true;

+		}

+		readwrite = true;

+		activePage = 1;

+        setCurrentPath('');

+		basePath = config.SD_BASE_PATH;

+		showLoading('waiting');

+		service.getSDConfiguration({}, function(data){

+            originalStatus = data;

+            shareFilePath = data.share_file;

+            if(shareFilePath.charAt(shareFilePath.length - 1) == '/'){//如果路径中有/,则去掉

+            	shareFilePath = shareFilePath.substring(0, shareFilePath.length - 1);

+            }

+

+			if(data.sd_status == '1' && data.sd_mode == '0'){ //共享

+				if(isGuest && data.share_status == '1'){// guest and share

+					basePath = shareFilePath;

+					if(data.share_auth == '0'){ // readonly

+						readwrite = false;

+						$("#uploadSection, #delete_file_button, .sd_guest_hide_th", "#httpshare_form").hide();

+					}else{

+                        $("#uploadSection, #delete_file_button, .sd_guest_hide_th", "#httpshare_form").show();

+                    }

+					$("#go_to_login_button").removeClass("hide");

+					$('#sd_menu').hide();

+					$('.form-note').hide();

+					if ($(".customfile").length == 0) {

+						$("#fileField").customFileInput();

+					}

+					pagerItemClickHandler(1);

+				} else if(isGuest && data.share_status == '0'){ // guest not share

+					$(".form-body .content", "#httpshare_form").hide().remove();

+					$(".form-title", "#httpshare_form").attr("data-trans", "httpshare").html($.i18n.prop("httpshare"));

+					$(".form-note", "#httpshare_form").attr("data-trans", "note_http_share_cannot_access").html($.i18n.prop("note_http_share_cannot_access"));

+                    hideLoading();

+				} else {

+					if ($(".customfile").length == 0) {

+						$("#fileField").customFileInput();

+					}

+					pagerItemClickHandler(1);

+				}

+			} else { // usb

+				$(".form-body .content", "#httpshare_form").hide().remove();

+				$(".form-title", "#httpshare_form").attr("data-trans", "httpshare").html($.i18n.prop("httpshare"));

+				$(".form-note", "#httpshare_form").attr("data-trans", "note_http_share_usb_access").html($.i18n.prop("note_http_share_usb_access"));

+                $(".form-note", "#httpshare_form").addClass("margintop10");

+				hideLoading();

+			}

+		}, function(){

+            errorOverlay();

+            $(".form-body .content", "#httpshare_form").hide().remove();

+            $(".form-title", "#httpshare_form").attr("data-trans", "httpshare").html($.i18n.prop("httpshare"));

+            $(".form-note", "#httpshare_form").attr("data-trans", "note_http_share_cannot_access").html($.i18n.prop("note_http_share_cannot_access"));

+        });

+

+		addInterval(function(){

+			!sdIsUploading && self.checkSdStatus();

+		}, 3000);

+

+		// T卡热插拔时状态监控,拔插卡重刷界面

+		self.checkSdStatus = function(){			

+			var data = service.getSDConfiguration();

+			if(data.sd_status && (data.sd_status != originalStatus.sd_status)){

+				if(data.sd_status == '1'){

+					window.location.reload();

+				}else{

+					clearTimer();

+					clearValidateMsg();

+					init();

+				}

+			}			

+		}

+	}

+

+	// 页码点击事件处理

+	pagerItemClickHandler = function(num) {

+		activePage = num;

+		refreshFileList(getCurrentPath(), activePage);

+	};

+

+    function checkConfiguration(){

+        var data = service.getSDConfiguration();

+        if(!_.isEqual(originalStatus, data)){

+            showAlert('sd_config_changed_reload', function(){

+                init();

+            });

+            return false;

+        }

+        return true;

+    }

+

+    //检查操作路径是否为共享路径,如果是共享路径,给用户提示

+    function inSharePath(path, wording) {

+        var tmpShareFilePath = shareFilePath + '/';

+        var tmpPath = path + '/';

+        if (originalStatus.share_status == '1' && shareFilePath != '' && shareFilePath != '/' && tmpShareFilePath.indexOf(tmpPath) != -1) {

+            showAlert(wording);

+            return true;

+        }

+        return false;

+    }

+

+	// 进入文件夹

+	enterFolder = function(name) {

+        if(!checkConfiguration()){

+            return false;

+        }

+		var path;

+		if (name == "") {

+			path = "";

+		} else {

+			path = getCurrentPath() + '/' + name;

+		}

+		refreshFileList(path, 1);

+        return true;

+	};

+

+	// 回到上一级目录

+	backFolder = function() {

+        if(!checkConfiguration()){

+            return false;

+        }

+		var path = getCurrentPath().substring(0, getCurrentPath().lastIndexOf("/"));

+		refreshFileList(path, 1);

+        return true;

+	};

+

+	// 更新按钮状态

+	refreshBtnsStatus = function() {

+		if (getCurrentPath() == "") {

+			$("#rootBtnLi, #backBtnLi").hide();

+		} else {

+			$("#rootBtnLi, #backBtnLi").show();

+		}

+		if (readwrite) {

+            $("#createNewFolderLi").hide();

+            $("#createNewFolderLi").find(".error").hide();

+            $("#newFolderBtnLi").show();

+            $("#newFolderName").val('');

+            $("#createNewFolderErrorLabel").removeAttr('data-trans').text('');

+		} else {

+            $("#newFolderBtnLi, #createNewFolderLi").hide().remove();

+		}

+        checkDeleteBtnStatus();

+	};

+

+

+	// 刷新文件列表

+	refreshFileList = function(path, index, alertShown) {

+		if(!alertShown){

+            showLoading('waiting');

+        }

+		service.getFileList({

+			path : prePath + basePath + path,

+			index : index

+		}, function(data) {

+			if (isErrorObject(data)) {

+				showAlert(data.errorType);

+				return;

+            }

+            setCurrentPath(path);

+			$("#sd_path").val(path);

+			activePage = index;

+			totalSize = data.totalRecord;

+			showFileSet(data.details);

+			pagination(totalSize); //测试分页时可以将此处totalSize调大

+			refreshBtnsStatus();

+			updateSdMemorySizes();

+            if(!alertShown){

+			    hideLoading();

+            }

+		});

+	};

+

+

+	// 显示新建文件夹按钮点击事件

+	openCreateNewFolderClickHandler = function() {

+		$("#newFolderBtnLi").hide();

+		$("#newFolderName").show();

+		$("#createNewFolderLi").show();

+	};

+

+	// 取消显示新建文件夹按钮点击事件

+	cancelCreateNewFolderClickHandler = function() {

+		$("#createNewFolderLi").hide();

+        $("#newFolderName").val('');

+		$("#newFolderBtnLi").show();

+		$("#createNewFolderLi").find(".error").hide();

+	};

+

+	// 新建文件夹按钮点击事件

+	createNewFolderClickHandler = function() {

+        if(!checkConfiguration()){

+            return false;

+        }

+		var newFolderName = $.trim($("#newFolderName").val());

+		var newPath = prePath + basePath + getCurrentPath() + "/" + newFolderName;

+        showLoading('creating');

+		service.checkFileExists({

+			path : newPath

+		}, function(data1) {

+			if (data1.status == "noexist" || data1.status == "processing") {

+				service.createFolder({

+					path : newPath

+				}, function(data) {

+					if (isErrorObject(data)) {

+						showAlert(data.errorType);

+						return false;

+					} else {

+                        successOverlay();

+                        refreshFileList(getCurrentPath(), 1);

+                    }

+				});

+			} else if (data1.status == "no_sdcard") {

+                showAlert("no_sdcard", function(){

+                    window.location.reload();

+                });

+			} else if (data1.status == "exist") {

+				$("#createNewFolderErrorLabel").attr('data-trans', 'sd_card_share_setting_exist').text($.i18n.prop("sd_card_share_setting_exist"));

+				hideLoading();

+			}

+		}, function(){

+            errorOverlay();

+        });

+        return true;

+	};

+

+	// 重命名按钮点击事件

+	renameBtnClickHandler = function(oldName) {

+        var oldPath = prePath + basePath + getCurrentPath() + "/" + oldName;

+        if(inSharePath(oldPath, 'sd_share_path_cant_rename')){

+            return false;

+        }

+		showPrompt("sd_card_folder_name_is_null", function() {

+            renamePromptCallback(oldName);

+        }, 160, oldName, checkPromptInput);

+    };

+

+    function renamePromptCallback(oldName){

+        if(!checkConfiguration()){

+            return false;

+        }

+        var promptInput = $("div#confirm div.promptDiv input#promptInput");

+        var newFolderName = $.trim(promptInput.val());

+        var newPath = prePath + basePath + getCurrentPath() + "/" + newFolderName;

+        service.checkFileExists({

+                path : newPath

+            }, function(data1) {

+				if (data1.status == "noexist" || data1.status == "processing") {

+					hideLoadingButtons();

+					var oldPath = prePath + basePath + getCurrentPath() + "/" + oldName;

+					service.fileRename({

+						oldPath : oldPath,

+						newPath : newPath,

+						path : prePath + basePath + getCurrentPath()

+					}, function(data) {

+						if (isErrorObject(data)) {							

+							showAlert($.i18n.prop(data.errorType));

+							if(data.errorType == "no_exist"){

+								var alertShown = true;

+								refreshFileList(getCurrentPath(), 1, alertShown);

+							} else if(data.errorType == "processing"){

+								//

+							}							

+						} else {

+                            refreshFileList(getCurrentPath(), 1);

+                            successOverlay();

+                        }

+                        showLoadingButtons();

+						return true;

+					});

+				} else if (data1.status == "no_sdcard") {

+					showAlert("no_sdcard", function(){

+                        window.location.reload();

+                    });

+					return false;

+				} else if (data1.status == "exist") {

+					$(".promptErrorLabel").text($.i18n.prop("sd_card_share_setting_exist"));

+					return false;

+				}

+                return true;

+            }, function(){

+                errorOverlay();

+        });

+        return false;

+    }

+

+    // Prompt弹出框INPUT校验函数

+    function checkPromptInput(){

+        var promptInput = $("div#confirm div.promptDiv input#promptInput");

+        var newFileName = $.trim(promptInput.val());

+        var newPath = (prePath + basePath + getCurrentPath() + "/" + newFileName).replace("//", "/");

+        var checkResult = checkFileNameAndPath(newFileName, newPath);

+        if (1 == checkResult) {

+            $(".promptErrorLabel").text($.i18n.prop("sd_upload_rename_null"));//tip filena is null

+            return false;

+        }else if (2 == checkResult) {

+            $(".promptErrorLabel").text($.i18n.prop("sd_card_path_too_long"));

+            return false;

+        }else if (3 == checkResult) {

+            $(".promptErrorLabel").text($.i18n.prop("check_file_path"));

+            return false;

+        }else{

+            $(".promptErrorLabel").text("");

+            return true;

+        }

+        return true;;

+    }

+

+    hideLoadingButtons = function () {

+        $(".buttons", "#confirm").hide();

+    };

+

+    showLoadingButtons = function () {

+        $(".buttons", "#confirm").show();

+    };

+

+	// 删除按钮点击事件

+	deleteBtnClickHandler = function() {

+        if(!checkConfiguration()){

+            return false;

+        }

+		var files = $("input:checkbox:checked", "#fileList_container");

+		var fileNames = "";

+		if (!files || files.length == 0) {

+			return false;

+		}

+        var hasSharePath = false;

+        $.each(files, function (i, n) {

+            var theFile = $(n).val();

+            if (inSharePath(prePath + basePath + getCurrentPath() + "/" + theFile, {msg: 'sd_share_path_cant_delete', params: [theFile]})) {

+                hasSharePath = true;

+                return false;

+            }

+            return true;

+        });

+        if (hasSharePath) {

+            return false;

+        }

+		showConfirm("confirm_data_delete", function(){

+			$.each(files, function(i, n) {

+				fileNames += $(n).val() + "*";

+			});

+			var thePath = prePath + basePath + getCurrentPath();

+			service.deleteFilesAndFolders({

+				path : thePath,

+				names : fileNames

+			}, function(data) {

+				if (data.status == "failure") {

+					showAlert("delete_folder_failure");

+				}

+				else if(data.status == "no_sdcard"){

+					showAlert("no_sdcard");

+				}

+				else if(data.status == "processing"){

+					showAlert("sd_file_processing_cant_delete");

+				}

+				else if(data.status == "success"){

+					successOverlay();

+				}

+				refreshFileList(getCurrentPath(), 1);

+			}, function(){

+                errorOverlay();

+            });

+		});

+        return true;

+	};

+

+    // 文件上传按钮点击事件

+    fileUploadSubmitClickHandler = function(ifReName) {        

+        if(ifReName){

+            var fileName = $.trim($("div#confirm div.promptDiv input#promptInput").val());

+        }else{

+            var fileName = $(".customfile").attr('title');

+        }

+        var newPath = (basePath + getCurrentPath() + "/" + fileName).replace("//", "/");

+        var fileSize = getFileSize($("#fileField")[0]);

+        if(!checkuploadFileNameAndPath(fileName, newPath, fileSize)){

+            return false;

+        }		

+        doCheckAndUpload(fileName, newPath, fileSize);

+    };

+

+    function doCheckAndUpload(fileName, newPath, fileSize){

+        service.getSdMemorySizes({}, function(data) {

+			if (isErrorObject(data)) {

+				showAlert(data.errorType);

+				return false;

+			}

+			if (data.availableMemorySize < fileSize) {

+				showAlert("sd_upload_space_not_enough");

+				return false;

+			}

+			$.modal.close();

+			showLoading('uploading', '<span data-trans="note_uploading_not_refresh">' + $.i18n.prop('note_uploading_not_refresh') + '</span>');

+			service.checkFileExists({

+				path : newPath

+			}, function(data1) {

+				if (data1.status == "noexist") {

+					$("#fileUploadForm").attr("action", "/cgi-bin/httpshare/" + URLEncodeComponent(fileName));

+					var currentTime = new Date().getTime();

+					$("#path_SD_CARD_time").val(transUnixTime(currentTime));

+					$("#path_SD_CARD_time_unix").val(Math.round((currentTime - zoneOffsetSeconds * 1000) / 1e3));

+					if(!iframeLoadBinded){

+						bindIframeLoad();

+					}

+					sdIsUploading = true;

+					$("#fileUploadForm").submit();

+				} else if (data1.status == "no_sdcard") {

+					showAlert("no_sdcard", function(){

+						window.location.reload();

+					});

+				} else if (data1.status == "processing") {

+					showAlert("sd_upload_file_is_downloading");//("system is downloading,try later!");

+				}else if (data1.status == "exist") {

+					showPrompt("sd_upload_rename",function(){

+						fileUploadSubmitClickHandler(true);

+					},160, fileName, checkPromptInput, clearUploadInput);

+				}

+			}, function(){

+				errorOverlay();

+			});

+        		return true;

+		});

+	}

+

+    var iframeLoadBinded = false;

+    function bindIframeLoad(){

+        iframeLoadBinded = true;

+        $('#fileUploadIframe').load(function() {

+			sdIsUploading = false;

+            var txt = $('#fileUploadIframe').contents().find("body").html().toLowerCase();

+            var alertShown = false;

+            if (txt.indexOf('success') != -1) {

+                successOverlay();

+            } else if (txt.indexOf('space_not_enough') != -1) {

+                alertShown = true;

+                showAlert('sd_upload_space_not_enough');

+            } else if (txt.indexOf('data_lost') != -1) {

+                alertShown = true;

+                showAlert('sd_upload_data_lost');

+            } else {

+                errorOverlay();

+            }

+

+            clearUploadInput();

+            refreshFileList(getCurrentPath(), 1, alertShown);

+        });

+    }

+

+	// 更新SD卡容量显示数据

+	updateSdMemorySizes = function() {

+		service.getSdMemorySizes({}, function(data) {

+			if (isErrorObject(data)) {

+				showAlert(data.errorType);

+				return false;

+			}

+			var total = getDisplayVolume(data.totalMemorySize, false);

+			var used = getDisplayVolume(data.totalMemorySize - data.availableMemorySize, false);

+			$("#sd_volumn_used").text(used);

+			$("#sd_volumn_total").text(total);

+            return true;

+		});

+	};

+

+	// 翻页

+	pagination = function(fileTotalSize) {

+		var pagers = generatePager(fileTotalSize, perPage, parseInt(activePage, 10));

+		if(pagerTmpl == null){

+			pagerTmpl = $.template("pagerTmpl", $("#pagerTmpl"));

+		}

+		$(".pager", "#fileListButtonSection").html($.tmpl("pagerTmpl", {data: {pagers : pagers, total : getTotalPages(fileTotalSize, perPage)}}));

+		renderCheckbox();

+		$(".content", "#httpshare_form").translate();

+	};

+

+	// 下载文件是检查文件路径是否包含特殊字符

+	checkFilePathForDownload = function(path){

+        if(!checkConfiguration()){

+            return false;

+        }

+		var idx = path.lastIndexOf('/');

+		var prePath = path.substring(0, idx+1);

+		var name = path.substring(idx+1, path.length);

+		if(checkFileNameChars(prePath, true) && checkFileNameChars(name, false)){

+			return true;

+		}

+		showAlert('sd_card_invalid_chars_cant_download');

+		return false;

+	};

+

+	gotoLogin = function(){

+		window.location.href="#entry";

+	};

+

+	// 事件绑定

+    function bindEvent(){

+		$('#createNewFolderForm').validate({

+			submitHandler : function() {

+				createNewFolderClickHandler();

+			},

+			rules : {

+				newFolderName : {sd_card_path_too_long:true,check_filefold_name: true}

+			}

+		});

+        $("p.checkbox", "#httpshare_form").die().live('click', function () {

+            addTimeout(function () {

+                checkDeleteBtnStatus();

+            }, 100);

+        });

+        $(".icon-download", "#httpshare_form").die().live("click", function () {

+            return checkFilePathForDownload($(this).attr("filelocal"));

+        });

+        $(".folderTd", "#httpshare_form").die().live("click", function () {

+            return enterFolder($(this).attr("filename"));

+        });

+        $(".fileRename", "#httpshare_form").die().live("click", function () {

+            return renameBtnClickHandler($(this).attr("filename"));

+        });

+        iframeLoadBinded = false;

+    }

+

+

+	// 刷新删除按钮状态

+    function checkDeleteBtnStatus(){

+        var checkedItem = $("p.checkbox.checkbox_selected", '#fileListSection');

+        if(checkedItem.length > 0){

+            enableBtn($('#delete_file_button'));

+        } else {

+            disableBtn($('#delete_file_button'));

+        }

+    }

+

+

+    // 文件名和路径检查

+    function checkFileNameAndPath(filename, path) {

+        if (filename == "" || filename.length > 25) {

+            return 1;

+        }

+        if (path.length >= 200) {

+            return 2;

+        }

+        if (!checkFileNameChars(filename, false)) {

+            return 3;

+        }

+    }

+

+	// 文件名特殊字符检查

+	function checkFileNameChars(filename, isIncludePath) {

+		var ASCStringInvalid = '+/:*?<>\"\'\\|#&`~';

+		if(isIncludePath){

+			ASCStringInvalid = '+:*?<>\"\'\\|#&`~';

+		}

+		var flag = false;

+		var dotFlag = false;

+		var reg = /^\.+$/;

+		for ( var filenamelen = 0; filenamelen < filename.length; filenamelen++) {

+			for ( var ACSlen = 0; ACSlen < ASCStringInvalid.length; ACSlen++) {

+				if (filename.charAt(filenamelen) == ASCStringInvalid.charAt(ACSlen)) {

+					flag = true;

+					break;

+				}

+			}

+			if (reg.test(filename)) {

+				dotFlag = true;

+			}

+			if (flag || dotFlag) {

+				return false;

+			}

+		}

+		return true;

+	}

+

+

+    function checkuploadFileNameAndPath(fileName, newPath, fileSize){

+        if(!checkConfiguration()){

+            return false;

+        }

+

+		if (typeof fileName == "undefined" || fileName == '' || fileName == $.i18n.prop("no_file_selected")) {

+            showAlert("sd_no_file_selected");

+			return false;

+		}

+		if (newPath.length >= 200) {

+			showAlert("sd_card_path_too_long");

+			return false;

+		}

+

+		if (fileSize/1024/1024/1024 > 2){  //no more than 2G

+			showAlert("sd_file_size_too_big");

+			return false;

+		}		

+

+		if (fileName.indexOf('*') >= 0){  //no *

+			showAlert("sd_file_name_invalid");

+			return false;

+		}

+		return true;

+	}

+

+

+	//清空上传控件

+    function clearUploadInput(){

+        $("#fileField").closest('.customfile').before('<input id="fileField" name="filename" maxlength="200" type="file" dir="ltr"/>').remove();

+        addTimeout(function(){

+            $("#fileField").customFileInput();

+        }, 0);

+        $("#uploadBtn", "#uploadSection").attr("data-trans", "browse_btn").html($.i18n.prop('browse_btn'));

+        $(".customfile", "#uploadSection").removeAttr("title");

+        $(".customfile span.customfile-feedback", "#uploadSection")

+            .html('<span data-trans="no_file_selected">'+$.i18n.prop('no_file_selected')+'</span>')

+            .attr('class', 'customfile-feedback');

+    }

+

+

+    function getCurrentPath(){

+        return currentPath;

+    }

+

+    function setCurrentPath(path){

+        if(path.lastIndexOf("/") == path.length - 1){

+            currentPath = path.substring(0, path.length - 1);

+        } else {

+            currentPath = path;

+        }

+    }

+

+

+    function getFileSize(object){

+        var isIE = /msie/i.test(navigator.userAgent) && !window.opera; 

+        if (isIE) {  //如果是ie

+            var objValue = object.value;

+            try {  

+                var fileSysObj = new ActiveXObject("Scripting.FileSystemObject");  

+                fileLenth = parseInt(fileSysObj.GetFile(objValue).size);

+                } catch (e) {  //('IE内核取不到长度'); 

+                fileLenth	= 1;					

+            } 

+        }else{  //其他

+            try{//对于非IE获得要上传文件的大小

+                fileLenth = parseInt(object.files[0].size);

+                }catch (e) {

+                fileLenth=1;  //获取不到取-1

+            }

+        }

+        return fileLenth;

+    } 

+

+	function init() {

+		var container = $('#container')[0];

+		ko.cleanNode(container);

+		var fwVm = new HttpShareViewModel();

+		ko.applyBindings(fwVm, container);

+        bindEvent();

+	}

+

+

+    jQuery.validator.addMethod("check_filefold_name", function(value, element, param) {

+        var result = checkFileNameChars(value, false);

+        return this.optional(element) || result;

+    });

+

+    jQuery.validator.addMethod("sd_card_path_too_long", function(value, element, param) {

+        var newFolderName = $.trim($("#newFolderName").val());

+        var newPath = prePath + basePath + getCurrentPath() + "/" + newFolderName;

+        var result = true;

+        if (newPath.length >= 200) {

+            result = false;

+        }

+        return this.optional(element) || result;

+    });

+

+	return {

+		init : init

+	};

+});

+

+define("ussd","set service knockout jquery".split(" "), function (set, fnc, libko, libjq) {

+    var time_interval = 0;

+    var initFlg = true;

+    var numTimeout = 0;

+    var replyFlg = false;

+    var ussd_action = 1;

+

+    function init() {

+        var container = libjq('#container')[0];

+        libko.cleanNode(container);

+        var vm = new vmUSSD();

+        libko.applyBindings(vm, container);

+

+    }

+    var USSDLocation = {

+        SEND: 0,

+        REPLY: 1

+    };

+    function vmUSSD() {

+        var target = this;

+

+        target.hasUpdateCheck = set.HAS_UPDATE_CHECK;

+        target.ussd_action = libko.observable(ussd_action);

+        target.USSDLocation = libko.observable(USSDLocation.SEND);

+        target.USSDReply = libko.observable("");

+        target.USSDSend = libko.observable("");

+        target.hasDdns = set.DDNS_SUPPORT;

+

+        function checkTimeout() {

+            if (replyFlg) {

+                replyFlg = true;

+                window.clearInterval(time_interval);

+                numTimeout = 0;

+            } else {

+                if (numTimeout > 28) {

+                    replyFlg = true;

+                    window.clearInterval(time_interval);

+                    showAlert("ussd_operation_timeout");

+                    target.USSDReply("");

+                    target.USSDSend("");

+                    target.USSDLocation(USSDLocation.SEND);

+                    numTimeout = 0;

+

+                } else {

+                    numTimeout++;

+                }

+

+            }

+        };

+

+        target.sendToNet = function () {

+            numTimeout = 0;

+            window.clearInterval(time_interval);

+            var command = target.USSDSend();

+

+            var idx_t = 0;

+            var indexChar;

+            for (idx_t = 0; idx_t < command.length; ) { //corem0418, delte left blanks and right blanks

+                indexChar = command.charAt(idx_t);

+                if (indexChar == ' ') {

+                    if (command.length > 1) {

+                        command = command.substr(idx_t + 1);

+                    } else {

+                        command = ''; // string is filled with blank

+                        break;

+                    }

+                } else {

+                    break;

+                }

+            }

+

+            for (idx_t = command.length - 1; idx_t >= 0 && command.length > 0; --idx_t) {

+                indexChar = command.charAt(idx_t);

+                if (indexChar == ' ') {

+                    if (command.length > 1) {

+                        command = command.substr(0, idx_t);

+                    } else {

+                        command = ''; // string is filled with blank

+                        break;

+                    }

+                } else {

+                    break;

+                }

+            }

+

+            if (('string' != typeof(command)) || ('' == command)) {

+                showAlert("ussd_error_input");

+                return;

+            }

+

+            showLoading('waiting');

+

+            var tmp = {};

+            tmp.operator = "ussd_send";

+            tmp.strUSSDCommand = command;

+            tmp.sendOrReply = "send";

+

+            fnc.getUSSDResponse(tmp, function (result, content) {

+                hideLoading();

+                if (result) {

+                    USSD_reset();

+                    target.USSDLocation(USSDLocation.REPLY);

+                    target.ussd_action(content.ussd_action);

+                    libjq("#USSD_Content").val(decodeMessage(content.data, true));

+                    replyFlg = false;

+                    numTimeout = 0;

+                } else {

+                    showAlert(content);

+                }

+            });

+        };

+

+        target.replyToNet = function () {

+            numTimeout = 0;

+            window.clearInterval(time_interval);

+            var command = target.USSDReply();

+

+            var idx_t = 0;

+            var indexChar;

+            for (idx_t = 0; idx_t < command.length; ) { //corem0418, delte left blanks and right blanks

+                indexChar = command.charAt(idx_t);

+                if (indexChar == ' ') {

+                    if (command.length > 1) {

+                        command = command.substr(idx_t + 1);

+                    } else {

+                        command = ''; // string is filled with blank

+                        break;

+                    }

+                } else {

+                    break;

+                }

+            }

+

+            for (idx_t = command.length - 1; idx_t >= 0 && command.length > 0; --idx_t) {

+                indexChar = command.charAt(idx_t);

+                if (indexChar == ' ') {

+                    if (command.length > 1) {

+                        command = command.substr(0, idx_t);

+                    } else {

+                        command = ''; // string is filled with blank

+                        break;

+                    }

+                } else {

+                    break;

+                }

+            }

+

+            if (('string' != typeof(command)) || ('' == command)) {

+                showAlert("ussd_error_input");

+                return;

+            }

+

+            showLoading('waiting');

+

+            var tmp = {};

+            tmp.operator = "ussd_reply";

+            tmp.strUSSDCommand = command;

+            tmp.sendOrReply = "reply";

+

+            fnc.getUSSDResponse(tmp, function (result, content) {

+                hideLoading();

+                if (result) {

+                    target.ussd_action(content.ussd_action);

+                    libjq("#USSD_Content").val(decodeMessage(content.data, true));

+                    replyFlg = false;

+                    USSD_reset();

+                    numTimeout = 0;

+                } else {

+                    showAlert(content);

+                }

+            });

+        };

+

+        USSD_reset = function () {

+            target.USSDReply("");

+            target.USSDSend("");

+        };

+        USSD_cancel = function () {

+            fnc.USSDReplyCancel(function (result) {});

+        };

+

+        target.noReplyCancel = function () {

+            numTimeout = 0;

+            replyFlg = true;

+            window.clearInterval(time_interval);

+            fnc.USSDReplyCancel(function (result) {

+                if (result) {

+                    USSD_reset();

+                    target.USSDLocation(USSDLocation.SEND);

+                } else {

+                    showAlert("ussd_fail");

+                }

+            });

+        };

+

+        //如果首次进入USSD菜单,先发送USSD取消命令,进行初始化

+        if (initFlg) {

+            USSD_cancel();

+            initFlg = false;

+        }

+    }

+

+    return {

+        init: init

+    };

+});

+

+

+define("phonebook","underscore jquery knockout set service jq_chosen".split(" "),

+

+    function (_, $, ko, config, service, chosen) {

+

+    var locationValue = {

+        SIM: "0",

+        DEVICE: "1"

+    };

+    var pageState = {

+        LIST: 0,

+        NEW: 1,

+        EDIT: 2,

+        VIEW: 3,

+        SEND_MSM: 4

+    };

+    //存储位置选项

+    var saveLocationOpts = function (hasSIMCard) {

+        var opts = [];

+        opts.push(new Option($.i18n.prop("device_book"), locationValue.DEVICE));

+        if (hasSIMCard) {

+            opts.push(new Option($.i18n.prop("sim_book"), locationValue.SIM));

+        }

+        return opts;

+    };

+

+    function getCurrentGroup() {

+        return $("#selectedFilterGroup").val();

+    }

+    //列表模板对应的Columns

+    var templateColumns = {

+        cardColumns: [{

+                rowText: "index",

+                display: false

+            }, {

+                rowText: "name"

+            }, {

+                rowText: "mobile_phone_number"

+            }, {

+                rowText: "home_phone_number"

+            }

+        ],

+        listColumns: [{

+                columnType: "checkbox",

+                headerTextTrans: "number",

+                rowText: "index",

+                width: "10%"

+            }, {

+                headerTextTrans: "name",

+                rowText: "name",

+                width: "25%",

+                sortable: true

+            }, {

+                columnType: "image",

+                headerTextTrans: "save_location",

+                rowText: "imgLocation",

+                width: "20%",

+                sortable: true

+            }, {

+                headerTextTrans: "mobile_phone_number",

+                rowText: "mobile_phone_number",

+                width: "30%",

+                sortable: true

+            }, {

+                headerTextTrans: "group",

+                rowText: "transGroup",

+                width: "15%",

+                sortable: true,

+                needTrans: true

+            }

+        ]

+    };

+    //分组选项

+    var groupOpts = function () {

+        var opts = [];

+        opts.push(new Option($.i18n.prop("common"), "common"));

+        opts.push(new Option($.i18n.prop("family"), "family"));

+        opts.push(new Option($.i18n.prop("friend"), "friend"));

+        opts.push(new Option($.i18n.prop("colleague"), "colleague"));

+        return opts;

+    };

+

+    var _phoneBookStopSMSSending = false;

+

+    function pbViewMode() {

+        var target = this;

+

+        //property for common

+        target.pageState = ko.observable(pageState.LIST);

+        target.initFail = ko.observable(true);

+        target.hasSms = ko.observable(config.HAS_SMS);

+

+        var smsHasCapability = true;

+        var smsLeftCount = 0;

+

+        //property for list

+        var capacity = {

+            simMaxNameLen: 0,

+            simMaxNumberLen: 0,

+            IsSimCardFull: true,

+            IsDeviceFull: true,

+            Used: 0,

+            Capacity: 0,

+            Ratio: "(0/0)"

+        };

+        target.capacity = ko.observable(capacity);

+        target.phoneBookCapacity = ko.observable(capacity.Ratio);

+        target.books = ko.observableArray();

+        //列表模板创建

+        target.gridTemplate = new ko.simpleGrid.viewModel({

+            tableClass: "table-fixed",

+            data: target.books(),

+            idName: "index",

+            columns: templateColumns.listColumns,

+            defaultSortField: "name",

+            defaultSortDirection: "ASC",

+            pageSize: 10,

+            tmplType: 'list',

+            searchColumns: ["name", "mobile_phone_number"],

+            primaryColumn: "mobile_phone_number",

+            showPager: true,

+            rowClickHandler: function (dataId) {

+                target.editBooks(dataId, 'view');

+            },

+            deleteHandler: function (dataId) {

+                target.deleteOneBook(dataId);

+            },

+            changeTemplateHandler: function () {

+                target.changeTemplate();

+            }

+        });

+

+        //property for edit or new

+        target.locations = ko.observableArray();

+        target.originLocation = "";

+        target.selectedLocation = ko.observable(locationValue.DEVICE);

+        target.locationTrans = ko.observable();

+        target.locationTransText = ko.observable();

+        target.index = ko.observable(-1);

+        target.name = ko.observable("");

+        target.nameMaxLength = ko.computed(function () {

+            var max = getNameMaxLength();

+            var name = target.name().substring(0, max);

+            target.name(name);

+            return getNameMaxLength();

+        });

+        function getNameMaxLength() {

+            var max = 22;

+            if (target.selectedLocation() == locationValue.DEVICE) {

+                var encodeType = getEncodeType(target.name());

+                if ("UNICODE" == encodeType.encodeType || encodeType.extendLen > 0) {

+                    max = 11;

+                } else {

+                    max = 22;

+                }

+                //max = 22;

+            } else {

+                //对"^"需要按照2个字符处理

+                var encodeType = getEncodeType(target.name());

+                if ("UNICODE" == encodeType.encodeType || encodeType.extendLen > 0) {

+                    max = (target.capacity().simMaxNameLen / 2) - 1;

+                } else {

+                    max = target.capacity().simMaxNameLen;

+                }

+            }

+            return max;

+        }

+

+        target.mobile_phone_number = ko.observable("");

+        target.mobileMaxLength = ko.computed(function () {

+            var max = getMobileMaxLength();

+            var mobileNumber = target.mobile_phone_number().substring(0, max);

+            target.mobile_phone_number(mobileNumber);

+            return getMobileMaxLength();

+        });

+        function getMobileMaxLength() {

+            var max = 40;

+            if (target.selectedLocation() == locationValue.DEVICE) {

+                max = 40;

+            } else {

+                max = target.capacity().simMaxNumberLen;

+            }

+            return max;

+        }

+

+        target.home_phone_number = ko.observable("");

+        target.office_phone_number = ko.observable("");

+        target.mail = ko.observable("");

+        target.transEditAreaTitle = ko.dependentObservable(function () {

+            var state = target.pageState();

+            if (state == pageState.EDIT) {

+                return "edit";

+            } else if (state == pageState.NEW) {

+                return "new";

+            } else if (state == pageState.VIEW) {

+                return "view";

+            }

+        });

+        var groups = groupOpts();

+        target.groups = ko.observableArray(groups);

+        target.selectedGroup = ko.observable();

+        target.groupTrans = ko.observable();

+        target.groupTransText = ko.observable();

+

+        target.selectedFilterGroup = ko.observable('all');

+        target.selectedFilterGroupChangeHandler = function () {

+            target.selectedFilterGroup($("#selectedFilterGroup").val());

+            getPhoneBookReady();

+        };

+

+        //property for sendMessage

+        target.showErrorInfo = ko.observable(false);

+        target.messageContent = ko.observable("");

+        target.messageCount = ko.computed(function () {

+            var msgInput = $("#txtSmsContent", "#sendMessage");

+            var msgInputDom = msgInput[0];

+            target.messageContent();

+            var strValue = msgInput.val();

+            var encodeType = getEncodeType(strValue);

+            var maxLength = encodeType.encodeType == 'UNICODE' ? 335 : 765;

+            if (strValue.length + encodeType.extendLen > maxLength) {

+                var scrollTop = msgInputDom.scrollTop;

+                var insertPos = getInsertPos(msgInputDom);

+                var moreLen = strValue.length + encodeType.extendLen - maxLength;

+                var insertPart = strValue.substr(insertPos - moreLen > 0 ? insertPos - moreLen : 0, moreLen);

+                var reversed = insertPart.split('').reverse();

+                var checkMore = 0;

+                var cutNum = 0;

+                for (var i = 0; i < reversed.length; i++) {

+                    if (getEncodeType(reversed[i]).extendLen > 0) {

+                        checkMore += 2;

+                    } else {

+                        checkMore++;

+                    }

+                    if (checkMore >= moreLen) {

+                        cutNum = i + 1;

+                        break;

+                    }

+                }

+                var iInsertToStartLength = insertPos - cutNum;

+

+                target.messageContent(strValue.substr(0, iInsertToStartLength) + strValue.substr(insertPos));

+                if (target.messageContent().length > maxLength) {

+                    target.messageContent(target.messageContent().substr(0, maxLength));

+                }

+                setInsertPos(msgInputDom, iInsertToStartLength);

+                msgInputDom.scrollTop = scrollTop;

+            }

+            pbDraftListener();

+            var newValue = $(msgInputDom).val();

+            var newEncodeType = getEncodeType(newValue);

+            var newMaxLength = newEncodeType.encodeType == 'UNICODE' ? 335 : 765;

+            if (newValue.length + newEncodeType.extendLen >= newMaxLength) {

+                $("#msgCount").addClass("colorRed");

+            } else {

+                $("#msgCount").removeClass("colorRed");

+            }

+            return "(" + (newValue.length + newEncodeType.extendLen) + "/" + newMaxLength + ")" + "(" + getSmsCount(newValue) + "/5)";

+        });

+

+        target.clear = function (isNeedInit) {

+            if (target.pageState() == pageState.SEND_MSM) {

+                smsPageCheckDraft(clearPhonebookForm, isNeedInit);

+            } else {

+                clearPhonebookForm(isNeedInit);

+            }

+            config.resetContentModifyValue();

+        };

+

+        //通过按钮返回列表状态事件处理

+        target.btnClear = function (isNeedInit) {

+            if (target.pageState() == pageState.SEND_MSM) {

+                smsPageCheckDraft(clearPhonebookForm, isNeedInit);

+                config.resetContentModifyValue();

+            } else if ((target.pageState() == pageState.NEW || target.pageState() == pageState.EDIT) && (target.preContent.location != target.selectedLocation()

+                     || target.preContent.name != target.name()

+                     || target.preContent.mobile_phone_number != target.mobile_phone_number()

+                     || target.preContent.home_phone_number != target.home_phone_number()

+                     || target.preContent.office_phone_number != target.office_phone_number()

+                     || target.preContent.mail != target.mail()

+                     || target.preContent.group != target.selectedGroup())) {

+                showConfirm("leave_page_info", {

+                    ok: function () {

+                        clearPhonebookForm(isNeedInit);

+                        config.resetContentModifyValue();

+                    },

+                    no: function () {

+                        return false;

+                    }

+                });

+            } else {

+                clearPhonebookForm(isNeedInit);

+                config.resetContentModifyValue();

+            }

+        };

+

+        function clearPhonebookForm(isNeedInit) {

+            $("#frmPhoneBook").hide();

+            target.pageState(pageState.LIST);

+            target.index(-1);

+            target.name("");

+            target.mobile_phone_number("");

+            target.home_phone_number("");

+            target.office_phone_number("");

+            target.mail("");

+            target.messageContent("");

+            if (true == isNeedInit) {

+                refreshPage();

+            }

+            target.gridTemplate.clearAllChecked();

+            clearValidateMsg();

+            $("#books ").translate();

+            $("#frmPhoneBook").show();

+        }

+

+        //检查SIM卡状态

+        target.checkHasSIMCard = function (showMsg) {

+            var status = service.getStatusInfo();

+            if (status.simStatus != "modem_init_complete") {

+                if (showMsg) {

+                    showAlert("sim_removed", function () {

+                        target.pageState(pageState.LIST);

+                        target.clear(true);

+                    });

+                }

+                return false;

+            }

+            return true;

+        };

+

+        //保存电话本事件

+        target.save = function () {

+            var saveBook = function (index) {

+                var isSaveInSIM = (location == locationValue.SIM);

+                if (isSaveInSIM) {

+                    if (!target.checkHasSIMCard(true)) {

+                        return;

+                    }

+                }

+                if (target.pageState() == pageState.NEW || (target.pageState() == pageState.EDIT && location != target.originLocation)) {

+                    if (isSaveInSIM) {

+                        if (target.capacity().IsSimCardFull) {

+                            showAlert("sim_full");

+                            return;

+                        }

+                    } else {

+                        if (target.capacity().IsDeviceFull) {

+                            showAlert("device_full");

+                            return;

+                        }

+                    }

+                }

+                var name = target.name();

+                var mobile_phone_number = target.mobile_phone_number();

+                if ($.trim(name) == "" || $.trim(mobile_phone_number) == "") {

+                    return;

+                }

+                showLoading('saving');

+                var params = {};

+                params.location = location;

+                params.index = index;

+                params.name = name;

+                params.mobile_phone_number = mobile_phone_number;

+                if (!isSaveInSIM) {

+                    params.home_phone_number = target.home_phone_number();

+                    params.office_phone_number = target.office_phone_number();

+                    params.mail = target.mail();

+                    params.group = target.selectedGroup();

+                }

+                if (target.selectedLocation() != target.originLocation) {

+                    params.delId = target.index();

+                }

+                service.savePhoneBook(params, target.callback);

+            }

+            var location = target.selectedLocation();

+            var editIndex = (location == target.originLocation) ? target.index() : -1;

+            if (location == locationValue.SIM && target.originLocation == locationValue.DEVICE) {

+                showConfirm("change_device_to_sim_confirm", function () {

+                    saveBook(editIndex);

+                });

+            } else {

+                saveBook(editIndex);

+            }

+        };

+        //打开添加电话本记录页面事件

+        target.openNewPage = function () {

+            if (target.pageState() == pageState.SEND_MSM) {

+                pbDraftListener();

+                smsPageCheckDraft(openNewPageAct, false);

+            } else if (target.pageState() == pageState.EDIT && (target.preContent.location != target.selectedLocation()

+                     || target.preContent.name != target.name()

+                     || target.preContent.mobile_phone_number != target.mobile_phone_number()

+                     || target.preContent.home_phone_number != target.home_phone_number()

+                     || target.preContent.office_phone_number != target.office_phone_number()

+                     || target.preContent.mail != target.mail()

+                     || target.preContent.group != target.selectedGroup())) {

+                showConfirm("leave_page_info", {

+                    ok: function () {

+                        openNewPageAct(false);

+                    },

+                    no: function () {

+                        return false;

+                    }

+                });

+            } else {

+                openNewPageAct(false);

+            }

+        };

+        function openNewPageAct(isNeedInit) {

+            target.pageState(pageState.NEW);

+            target.selectedLocation(locationValue.DEVICE);

+            target.originLocation = "";

+            if (target.checkHasSIMCard(false)) {

+                target.locations(saveLocationOpts(true));

+            } else {

+                target.locations(saveLocationOpts(false));

+            }

+            var group = getCurrentGroup();

+            if (group != "all") {

+                target.selectedGroup(group);

+            } else {

+                target.selectedGroup("common");

+            }

+            target.name("");

+            target.mobile_phone_number("");

+            target.home_phone_number("");

+            target.office_phone_number("");

+            target.mail("");

+            target.index(-1);

+            target.dynamicTranslate();

+            preOpenEditPage();

+        }

+        //打开添加电话本记录编辑页面事件

+        target.openPage = function (option) {

+            var index;

+            if (target.pageState() == pageState.LIST) {

+                var result = target.checkSelect(option);

+                if (!result.isCorrectData)

+                    return;

+                index = result.selectedIds[0];

+            } else {

+                index = target.index();

+            }

+            target.editBooks(index, option);

+        };

+        //打开添加电话本记录查看页面事件

+        target.openViewPage = function () {

+            target.openPage("view");

+        };

+        //打开添加电话本记录查看页面事件

+        target.openEditPage = function () {

+            target.openPage("edit");

+            if ($.browser.mozilla) {

+                $("#txtName, #txtMobile").removeAttr('maxlength');

+            }

+            preOpenEditPage();

+        };

+        //编辑电话本事件处理

+        target.editBooks = function (selectedId, option) {

+            if (!selectedId)

+                return;

+

+            if (target.checkHasSIMCard(false)) {

+                target.locations(saveLocationOpts(true));

+            } else {

+                target.locations(saveLocationOpts(false));

+            }

+            var data = target.books();

+            for (var i = 0; i < data.length; i++) {

+                var n = data[i];

+                if (n.index == selectedId) {

+                    target.index(n.index);

+                    target.selectedLocation(n.location);

+                    target.originLocation = n.location;

+                    var trans = (n.location == locationValue.DEVICE) ? "device" : "sim";

+                    target.locationTrans(trans);

+                    var transText = $.i18n.prop("trans");

+                    target.locationTransText(transText);

+                    target.name(n.name);

+                    target.mobile_phone_number(n.mobile_phone_number);

+                    target.home_phone_number(n.home_phone_number);

+                    target.office_phone_number(n.office_phone_number);

+                    target.mail(n.mail);

+                    target.selectedGroup(n.group);

+                    target.groupTrans("group_" + n.group);

+                    target.groupTransText($.i18n.prop(target.groupTrans()));

+                    if (option == "edit") {

+                        target.pageState(pageState.EDIT);

+                    } else {

+                        target.pageState(pageState.VIEW);

+                    }

+                    break;

+                }

+            }

+            target.dynamicTranslate();

+

+            if (target.selectedLocation() == locationValue.SIM) {

+                target.checkHasSIMCard(true)

+            }

+        };

+        //翻译编辑区域

+        target.dynamicTranslate = function () {

+            $("#container").translate();

+        };

+        //删除一条电话本事件处理(card模式使用)

+        target.deleteOneBook = function (index) {

+            showConfirm("confirm_pb_delete", function () {

+                showLoading('deleting');

+                var params = {};

+                params.indexs = [String(index)];

+                service.deletePhoneBooks(params, target.callback);

+            });

+            return false;

+        };

+        //删除一条电话本事件处理

+        target.deleteBook = function () {

+            target.deleteOneBook(target.index());

+        };

+        //删除一条或多条电话本事件处理

+        target.deleteBooks = function () {

+            var result = target.checkSelect("delete");

+            if (!result.isCorrectData)

+                return;

+            showConfirm("confirm_pb_delete", function () {

+                showLoading('deleting');

+                var params = {};

+                params.indexs = result.selectedIds;

+                service.deletePhoneBooks(params, target.callback);

+            });

+        };

+        //判断电话本选中

+        target.checkSelect = function (pState) {

+            var ids;

+            if ("send" == pState) {

+                ids = target.gridTemplate.selectedPrimaryValue();

+            } else {

+                ids = target.gridTemplate.selectedIds();

+            }

+

+            var isCorrectData = true;

+            if (ids.length == 0) {

+                showAlert("no_data_selected");

+                isCorrectData = false;

+            } else if ("edit" == pState || "view" == pState) {

+                if (ids.length > 1) {

+                    showAlert("too_many_data_selected");

+                    isCorrectData = false;

+                }

+            } else if ("send" == pState) {

+                if (ids.length > 5) {

+                    showAlert("max_send_number");

+                    isCorrectData = false;

+                }

+            }

+            return {

+                selectedIds: ids,

+                isCorrectData: isCorrectData

+            };

+        };

+        //全部删除电话本事件处理

+        target.deleteAllBooks = function () {

+            showConfirm("confirm_data_delete", function () {

+                showLoading('deleting');

+                var group = getCurrentGroup();

+                var params = {};

+                if (group == "all") {

+                    params.location = 2;

+                    service.deleteAllPhoneBooks(params, target.callback);

+                } else {

+                    params.location = 3;

+                    params.group = group;

+                    service.deleteAllPhoneBooksByGroup(params, target.callback);

+                }

+            });

+        };

+

+        target.callback = function (data) {

+            if (data && data.result == "success") {

+                target.clear(true);

+                $("#books ").translate();

+                renderCheckbox();

+                successOverlay(null, true);

+            } else {

+                errorOverlay();

+            }

+        };

+        //变换显示方式事件处理

+        target.changeTemplate = function () {

+            if (target.gridTemplate.tmplType == "card") {

+                target.gridTemplate.tmplType = "list";

+                target.gridTemplate.pageSize = 10;

+                target.gridTemplate.columns = templateColumns.listColumns;

+            } else {

+                target.gridTemplate.tmplType = "card";

+                target.gridTemplate.pageSize = 10;

+                target.gridTemplate.columns = templateColumns.cardColumns;

+            }

+            refreshPage();

+            $("#books ").translate();

+        };

+        //显示发送短信页面

+        target.openSendMessagePage = function () {

+            if (pageState.SEND_MSM == target.pageState()) {

+                return;

+            }

+            if ((target.pageState() == pageState.EDIT || pageState.NEW == target.pageState()) && (target.preContent.location != target.selectedLocation()

+                     || target.preContent.name != target.name()

+                     || target.preContent.mobile_phone_number != target.mobile_phone_number()

+                     || target.preContent.home_phone_number != target.home_phone_number()

+                     || target.preContent.office_phone_number != target.office_phone_number()

+                     || target.preContent.mail != target.mail()

+                     || target.preContent.group != target.selectedGroup())) {

+                showConfirm("leave_page_info", {

+                    ok: function () {

+                        openSendMessagePageAct();

+                    },

+                    no: function () {

+                        return false;

+                    }

+                });

+            } else {

+                openSendMessagePageAct();

+            }

+        };

+

+        function openSendMessagePageAct() {

+            if (pageState.NEW == target.pageState()) {

+                target.pageState(pageState.SEND_MSM);

+                showAlert("no_data_selected");

+                target.clear();

+                return;

+            }

+            var selectedNumber = null;

+            if (pageState.LIST == target.pageState()) {

+                var result = target.checkSelect("send");

+                if (!result.isCorrectData)

+                    return;

+                selectedNumber = result.selectedIds;

+            } else {

+                selectedNumber = target.mobile_phone_number();

+            }

+

+            var select = $("#chosenUserList .chosen-select-deselect");

+            select.empty();

+            var options = [];

+            var tmp = [];

+            for (var j = 0; j < config.phonebook.length; j++) {

+                var book = config.phonebook[j];

+                if ($.inArray(book.pbm_number, tmp) == -1) {

+                    options.push(new Option(book.pbm_name + "/" + book.pbm_number, book.pbm_number, false, true));

+                    tmp.push(book.pbm_number);

+                } else {

+                    for (var i = 0; i < options.length; i++) {

+                        if (options[i].value == book.pbm_number) {

+                            options[i].text = book.pbm_name + "/" + book.pbm_number;

+                            break;

+                        }

+                    }

+                }

+            }

+            var opts = "";

+            $.each(options, function (i, e) {

+                opts += "<option value='" + HTMLEncode(e.value) + "'>" + HTMLEncode(e.text) + "</option>";

+            });

+            select.append(opts);

+            select.chosen({

+                max_selected_options: 5,

+                search_contains: true,

+                width: '545px'

+            });

+            $("#chosenUserSelect").val(selectedNumber);

+            $("#chosenUserSelect").trigger("chosen:updated.chosen");

+            config.resetContentModifyValue();

+            pbDraftListener();

+            target.pageState(pageState.SEND_MSM);

+        }

+

+        //发送短信

+        target.sendMessage = function () {

+            service.getSmsCapability({}, function (capability) {

+                var hasCapability = capability.nvUsed < capability.nvTotal;

+                if (!hasCapability) {

+                    showAlert("sms_capacity_is_full_for_send");

+                    return false;

+                }

+                var numbers = syncSelectAndChosen($("select#chosenUserSelect"), $('.search-choice', '#chosenUserSelect_chosen'));

+                if (numbers.length + capability.nvUsed > capability.nvTotal) {

+                    showAlert({

+                        msg: "sms_capacity_will_full_just",

+                        params: [capability.nvTotal - capability.nvUsed]

+                    });

+                    return false;

+                }

+                target.sendMessageAction();

+                return true;

+            });

+        };

+

+        target.sendMessageAction = function () {

+            var numbers = syncSelectAndChosen($("select#chosenUserSelect"), $('.search-choice', '#chosenUserSelect_chosen'));

+

+            if (!numbers || numbers.length == 0) {

+                target.showErrorInfo(true);

+                var timer = addTimeout(function () {

+                    target.showErrorInfo(false);

+                    window.clearTimeout(timer);

+                }, 5000);

+                return;

+            }

+            var content = target.messageContent();

+            var sentCount = 0;

+            var failCount = 0;

+            if (numbers.length > 1) {

+                showLoading("sending", "<button id='btnStopSending' onclick='phoneBookStopSMSSending();' class='btn btn-primary'>"

+                     + $.i18n.prop("sms_stop_sending")

+                     + "</button>");

+            } else {

+                showLoading('sending');

+            }

+            var callback = function (data) {

+                sentCount++;

+                if (sentCount == numbers.length) {

+                    $("#chosenUserSelect").val("");

+                    target.messageContent("");

+                    config.CONTENT_MODIFIED.modified = false;

+                    if (failCount == 0) {

+                        successOverlay();

+                        location.hash = "#msg_list";

+                    } else {

+                        var msg = $.i18n.prop("success_info") + $.i18n.prop("colon") + (sentCount - failCount)

+                             + "<br/>" + $.i18n.prop("error_info") + $.i18n.prop("colon") + (failCount);

+                        showAlert(msg, function () {

+                            location.hash = "#msg_list";

+                        });

+                    }

+

+                } else {

+                    sendSMS();

+                }

+            }

+            _phoneBookStopSMSSending = false;

+            var sendSMS = function () {

+                if (_phoneBookStopSMSSending) {

+                    hideLoading();

+                    return;

+                }

+                if ((sentCount + 1) == numbers.length) {

+                    $("#loading #loading_container").html("");

+                }

+                service.sendSMS({

+                    number: numbers[sentCount],

+                    message: content,

+                    id: -1

+                }, function (data) {

+                    callback(data);

+                }, function (data) {

+                    failCount++;

+                    callback(data);

+                });

+            };

+            sendSMS();

+        };

+        //清除搜索关键字事件

+        target.clearSearchKey = function () {

+            target.gridTemplate.searchInitStatus(true);

+            target.gridTemplate.searchKey($.i18n.prop("search"));

+            $("#ko_grid_search_txt").addClass("ko-grid-search-txt-default").attr("data-trans", "search");

+        };

+        //点击搜索输入框事件

+        target.searchTextClick = function () {

+            var searchText = $("#ko_grid_search_txt");

+            if (searchText.hasClass("ko-grid-search-txt-default")) {

+                target.gridTemplate.searchKey("");

+                target.gridTemplate.searchInitStatus(false);

+                searchText.removeClass("ko-grid-search-txt-default").removeAttr("data-trans");

+            }

+        };

+        //离开搜索输入框事件

+        target.searchTextBlur = function () {

+            var txt = $.trim(target.gridTemplate.searchKey()).toLowerCase();

+            if (txt == "") {

+                target.clearSearchKey();

+            }

+        };

+        //当前表格是否有数据

+        target.hasData = ko.computed(function () {

+            return target.gridTemplate.afterSearchData().length > 0;

+        });

+        //当前表格是否有选中的数据

+        target.hasChecked = ko.computed(function () {

+            return target.gridTemplate.checkedCount() > 0;

+        });

+        //是否可以点击发送按钮

+        target.canSend = ko.computed(function () {

+            var checked = target.gridTemplate.checkedCount();

+            if (!target.checkHasSIMCard(false)) {

+                return false;

+            }

+            return (checked > 0 && checked <= 5);

+        });

+

+        //发送短信时,选择用户变化的监控事件

+        target.draftListenerEvent = function () {

+            pbDraftListener();

+        };

+        //文档内容监听,判断是否修改过

+        function pbDraftListener() {

+            var smsHasCapability = true;

+            if (smsHasCapability) {

+                var content = target.messageContent();

+                var hasContent = false;

+                var numbers = getSelectValFromChosen($('.search-choice', '#chosenUserSelect_chosen'));

+                var noContactSelected = !(numbers && numbers.length > 0);

+                if (typeof content == "undefined" || content == '') {

+                    config.resetContentModifyValue();

+                    return false;

+                } else {

+                    hasContent = true;

+                }

+                if (hasContent && !noContactSelected) {

+                    config.CONTENT_MODIFIED.modified = true;

+                    config.CONTENT_MODIFIED.message = 'sms_to_save_draft';

+                    config.CONTENT_MODIFIED.callback.ok = saveDraftAction;

+                    config.CONTENT_MODIFIED.callback.no = $.noop;

+                    config.CONTENT_MODIFIED.data = {

+                        content: content,

+                        numbers: numbers

+                    };

+                    return false;

+                }

+                if (hasContent && noContactSelected) {

+                    config.CONTENT_MODIFIED.modified = true;

+                    config.CONTENT_MODIFIED.message = 'sms_no_recipient';

+                    config.CONTENT_MODIFIED.callback.ok = $.noop;

+                    config.CONTENT_MODIFIED.callback.no = function () {

+                        // 返回true,页面保持原状

+                        return true;

+                    };

+                    return false;

+                }

+            }

+            /*else { cov_2

+            config.resetContentModifyValue();

+            }*/

+        }

+

+        function saveDraftAction(data) {

+            var datetime = new Date();

+            var params = {

+                index: -1,

+                currentTimeString: getCurrentTimeString(datetime),

+                groupId: data.numbers.length > 1 ? datetime.getTime() : '',

+                message: data.content,

+                numbers: data.numbers

+            };

+            service.saveSMS(params, function () {

+                successOverlay('sms_save_draft_success');

+            }, function () {

+                errorOverlay("sms_save_draft_failed")

+            });

+        }

+        function smsPageCheckDraft(clearCallback, isNeedInit) {

+            if (config.CONTENT_MODIFIED.message != 'sms_to_save_draft') {

+                if (config.CONTENT_MODIFIED.modified) {

+                    showConfirm(config.CONTENT_MODIFIED.message, {

+                        ok: function () {

+                            config.CONTENT_MODIFIED.callback.ok(config.CONTENT_MODIFIED.data);

+                            clearCallback(isNeedInit);

+                        },

+                        no: function () {

+                            if (config.CONTENT_MODIFIED.message == 'sms_to_save_draft') {

+                                clearCallback(isNeedInit);

+                            }

+                            return false;

+                        }

+                    });

+                    return false;

+                } else {

+                    clearCallback(isNeedInit);

+                }

+            } else {

+                config.CONTENT_MODIFIED.callback.ok(config.CONTENT_MODIFIED.data);

+                clearCallback(isNeedInit);

+            }

+        }

+

+        //重新获取页面数据并显示

+        function getPhoneBookReady() {

+            service.getPhoneBookReady({}, function (data) {

+                if (data.pbm_init_flag == "6") {

+                    target.initFail(true);

+                    hideLoading();

+                    showAlert("phonebook_init_fail");

+                } else if (data.pbm_init_flag != "0") {

+                    addTimeout(getPhoneBookReady, 1000);

+                } else {

+                    target.initFail(false);

+                    var capacity = getCapacity();

+                    target.capacity(capacity);

+                    target.phoneBookCapacity(capacity.Ratio);

+                    var phoneBooks = getBooks(capacity.Used);

+                    target.books(phoneBooks);

+                    target.gridTemplate.data(phoneBooks);

+                    $('#books').find('tbody').translate();

+                    hideLoading();

+                }

+            });

+        }

+

+        showLoading('waiting');

+        addTimeout(getPhoneBookReady, 200);

+

+        //重新获取页面数据并显示

+        function refreshPage() {

+            showLoading();

+            var capacity = getCapacity();

+            target.phoneBookCapacity(capacity.Ratio);

+            target.capacity(capacity);

+            var books = getBooks(capacity.Used);

+            target.books(books);

+            target.gridTemplate.data(books);

+            hideLoading();

+        }

+

+        target.preContent = {};

+        //保存编辑前的内容

+        function setPreContent() {

+            target.preContent.location = target.selectedLocation();

+            target.preContent.name = target.name();

+            target.preContent.mobile_phone_number = target.mobile_phone_number();

+            target.preContent.home_phone_number = target.home_phone_number();

+            target.preContent.office_phone_number = target.office_phone_number();

+            target.preContent.mail = target.mail();

+            target.preContent.group = target.selectedGroup();

+        }

+

+        //检测数据是否改变

+        function checkContentChang() {

+            var changed = (target.preContent.location != target.selectedLocation()

+                 || target.preContent.name != target.name()

+                 || target.preContent.mobile_phone_number != target.mobile_phone_number()

+                 || target.preContent.home_phone_number != target.home_phone_number()

+                 || target.preContent.office_phone_number != target.office_phone_number()

+                 || target.preContent.mail != target.mail()

+                 || target.preContent.group != target.selectedGroup());

+            config.CONTENT_MODIFIED.modified = changed;

+        }

+

+        function preOpenEditPage() {

+            config.resetContentModifyValue();

+            setPreContent();

+            config.CONTENT_MODIFIED.checkChangMethod = checkContentChang;

+        }

+    }

+

+    //设置停止发送标志为true

+    phoneBookStopSMSSending = function () {

+        _phoneBookStopSMSSending = true;

+        $("#loading #loading_container").html($.i18n.prop("sms_cancel_sending"));

+    }

+

+    //获取电话本

+    function getBooks(capacity) {

+        var para = {};

+        para.page = 0;

+        para.data_per_page = capacity;

+        para.orderBy = "name";

+        para.isAsc = true;

+        var books = [];

+        var group = getCurrentGroup();

+        if (config.HAS_SMS) {

+            books = service.getPhoneBooks(para);

+            config.phonebook = books.pbm_data;

+            if (group != "all") {

+                books = {

+                    "pbm_data": _.filter(books.pbm_data, function (item) {

+                        return item.pbm_group == group;

+                    })

+                };

+            }

+        } else {

+            if (group != "all") {

+                para.group = group;

+                books = service.getPhoneBooksByGroup(para);

+            } else {

+                books = service.getPhoneBooks(para);

+            }

+        }

+        return translateData(books.pbm_data);

+    }

+

+    //获取电话本容量信息

+    function getCapacity() {

+        var sim = service.getSIMPhoneBookCapacity();

+        var device = service.getDevicePhoneBookCapacity();

+        return {

+            simUsed: sim.simPbmUsedCapacity,

+            deviceUsed: device.pcPbmUsedCapacity,

+            simCapacity: sim.simPbmTotalCapacity,

+            deviceCapacity: device.pcPbmTotalCapacity,

+            simMaxNameLen: sim.maxNameLen,

+            simMaxNumberLen: sim.maxNumberLen,

+            IsSimCardFull: (sim.simPbmUsedCapacity == sim.simPbmTotalCapacity),

+            IsDeviceFull: (device.pcPbmUsedCapacity == device.pcPbmTotalCapacity),

+            Used: sim.simPbmUsedCapacity + device.pcPbmUsedCapacity,

+            Capacity: sim.simPbmTotalCapacity + device.pcPbmTotalCapacity,

+            Ratio: "(" + (sim.simPbmUsedCapacity + device.pcPbmUsedCapacity) + "/" + (sim.simPbmTotalCapacity + device.pcPbmTotalCapacity) + ")"

+        };

+    }

+

+    function translateData(books) {

+        var ret = [];

+        var group = getCurrentGroup();

+        var hasFilter = (group != "all");

+        if (books) {

+            for (var i = 0; i < books.length; i++) {

+                if (hasFilter) {

+                    var currentGroup = books[i].pbm_group;

+                    if (books[i].pbm_location == locationValue.SIM || currentGroup != group) {

+                        continue;

+                    }

+                }

+                var temp = {

+                    index: books[i].pbm_id,

+                    location: books[i].pbm_location,

+                    imgLocation: books[i].pbm_location == locationValue.SIM ? "pic/simcard.png" : "pic/res_device.png",

+                    name: books[i].pbm_name,

+                    mobile_phone_number: books[i].pbm_number,

+                    home_phone_number: books[i].pbm_anr,

+                    office_phone_number: books[i].pbm_anr1,

+                    mail: books[i].pbm_email,

+                    group: books[i].pbm_group,

+                    transGroup: (!books[i].pbm_group) ? "group_null" : "group_" + books[i].pbm_group

+                };

+                ret.push(temp);

+            }

+        }

+        return ret;

+    }

+    //初始化ViewModel并进行绑定

+    function init() {

+        var container = $('#container');

+        ko.cleanNode(container[0]);

+        var vm = new pbViewMode();

+        ko.applyBindings(vm, container[0]);

+        $("#txtSmsContent").die().live("contextmenu", function () {

+            return false;

+        });

+        $('#frmPhoneBook').validate({

+            submitHandler: function () {

+                vm.save();

+            },

+            rules: {

+                txtMail: "email_check",

+                txtName: "name_check",

+                txtMobile: "phonenumber_check",

+                txtHomeNumber: "phonenumber_check",

+                txtOfficeNumber: "phonenumber_check"

+            }

+        });

+

+    }

+

+    return {

+        init: init

+    };

+});

+

+define("sms_list","underscore jquery knockout set service jq_chosen".split(" "),

+    function (_, $, ko, config, service, chosen) {

+

+    var currentPage = 1;

+    //数据是否加载完成

+    var ready = false,

+    //聊天室信息正在加载中

+    chatRoomInLoading = false;

+    //快速添加联系人模板

+    var addPhonebookTmpl = null,

+    //短消息模板

+    smsTableTmpl = null,

+    //接收短消息模板

+    smsOtherTmpl = null,

+    //发送短消息模板

+    smsMeTmpl = null,

+    //群聊草稿

+    groupDrafts = [],

+    //短消息列表显示群聊草稿

+    groupDraftItems = [],

+    //短消息列表显示群聊草稿及其草稿群聊细节

+    groupedDraftsObject = {},

+    //短消息容量信息

+    smsCapability = {},

+    //短消息是否还有存储空间

+    hasCapability = true;

+    //获取全部短消息,并将短信通过回调函数getPhoneBooks,与电话本进行关联

+    function getSMSMessages(callback) {

+        return service.getSMSMessages({

+            page: 0,

+            smsCount: 500,

+            nMessageStoreType: 1,

+            tags: 10,

+            orderBy: "order by id desc"

+        }, function (data) {

+            tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), data.messages.length);

+            config.dbMsgs = data.messages;

+            config.listMsgs = groupSms(config.dbMsgs);

+            callback();

+        }, function () {

+            tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), 0);

+            config.dbMsgs = [];

+            config.listMsgs = [];

+            cleanSmsList();

+        });

+    }

+

+    //清楚短消息列表内容

+    cleanSmsList = function () {

+        $("#smslist-table").empty();

+    };

+

+    //关联后的短消息根据电话号码进行分组

+    function groupSms(messages) {

+        var peoples = {},

+        theSortedPeoples = [];

+        config.listMsgs = [];

+        groupDrafts = [];

+        $.each(messages, function (i, e) {

+            if (e.tag == '4' && e.groupId != '') { // 群聊草稿

+                groupDrafts.push(e);

+                return;

+            }

+            e.target = e.number;

+            if (parseInt(e.id, 10) > config.smsMaxId) {

+                config.smsMaxId = e.id;

+            }

+            var last8 = getLastNumber(e.number, config.SMS_MATCH_LENGTH);

+            if (last8 in peoples) {

+                peoples[last8].push(e);

+            } else {

+                peoples[last8] = [e];

+                theSortedPeoples.push(e);

+            }

+        });

+        theSortedPeoples = _.sortBy(theSortedPeoples, function (ele) {

+            return 0 - parseInt(ele.id + "", 10);

+        });

+        $.each(theSortedPeoples, function (s_i, sp) {

+            var people = getLastNumber(sp.number, config.SMS_MATCH_LENGTH);

+            var newCount = 0;

+            var hasDraft = false;

+            for (var i = 0; i < peoples[people].length; i++) {

+                if (peoples[people][i].isNew) {

+                    newCount++;

+                }

+                if (peoples[people][i].tag == '4' && peoples[people][i].groupId == '') { // 单条草稿

+                    hasDraft = true;

+                }

+            }

+            config.listMsgs.push({

+                id: peoples[people][0].id,

+                name: "",

+                number: peoples[people][0].number,

+                latestId: peoples[people][0].id,

+                totalCount: peoples[people].length,

+                newCount: newCount,

+                latestSms: peoples[people][0].content,

+                latestTime: peoples[people][0].time,

+                checked: false,

+                itemId: getLastNumber(people, config.SMS_MATCH_LENGTH),

+                groupId: peoples[people][0].groupId,

+                hasDraft: hasDraft

+            });

+        });

+        return config.listMsgs;

+    }

+

+    //获取电话本信息,并与短消息关联

+    function getPhoneBooks() {

+        var books = service.getPhoneBooks({

+            page: 0,

+            data_per_page: 2000,

+            orderBy: "name",

+            isAsc: true

+        });

+        if ($.isArray(books.pbm_data) && books.pbm_data.length > 0) {

+            config.phonebook = books.pbm_data;

+        }

+        dealPhoneBooks();

+    }

+

+    //双异步获取设备侧和sim卡侧的短信息,并将其合并

+    function dealPhoneBooks() {

+        var select = $("#chosenUserList .chosen-select-deselect");

+        select.empty();

+        var options = [];

+        var tmp = [];

+        var pbTmp = [];

+        for (var j = 0; j < config.phonebook.length; j++) {

+            var book = config.phonebook[j];

+            var last8Num = getLastNumber(book.pbm_number, config.SMS_MATCH_LENGTH);

+            if (last8Num && $.inArray(last8Num, pbTmp) == -1) {

+                options.push(new Option(book.pbm_name + "/" + book.pbm_number, last8Num, false, true));

+                if ($.inArray(last8Num, tmp) == -1) {

+                    tmp.push(last8Num);

+                }

+                pbTmp.push(last8Num);

+            } else {

+                for (var i = 0; i < options.length; i++) {

+                    if (options[i].value == last8Num) {

+                        options[i].text = book.pbm_name + "/" + book.pbm_number;

+                        break;

+                    }

+                }

+            }

+        }

+        var groupIds = [];

+        for (var k = 0; k < groupDrafts.length; k++) { // 将草稿做对象Map封装,供草稿组点击后的草稿分解

+            if ($.inArray(groupDrafts[k].groupId, groupIds) == -1) {

+                groupIds.push(groupDrafts[k].groupId);

+                var draft = groupDrafts[k];

+                groupedDraftsObject[groupDrafts[k].groupId] = [draft];

+            } else {

+                var draft = groupDrafts[k];

+                groupedDraftsObject[groupDrafts[k].groupId].push(draft);

+            }

+            var itemId = getLastNumber(groupDrafts[k].number, config.SMS_MATCH_LENGTH);

+            if ($.inArray(itemId, tmp) == -1) {

+                options.push(new Option(groupDrafts[k].number, itemId));

+                tmp.push(itemId);

+            }

+        }

+        for (var g in groupedDraftsObject) { // 处理列表显示的草稿信息

+            var drafts = groupedDraftsObject[g];

+            var draftItem = drafts[drafts.length - 1];

+            draftItem.draftShowName = '';

+            draftItem.draftShowNameTitle = '';

+            $.each(drafts, function (i, n) {

+                var showName = getShowNameByNumber(n.number);

+                draftItem.draftShowName += (i == 0 ? '' : ';') + showName;

+                draftItem.draftShowNameTitle += (i == 0 ? '' : ';') + showName;

+            });

+

+            var len = 10;

+            if (getEncodeType(draftItem.draftShowName).encodeType == "UNICODE") {

+                len = 10;

+            }

+            draftItem.draftShowName = draftItem.draftShowName.length > len ? draftItem.draftShowName.substring(0, len) + "..." : draftItem.draftShowName;

+            draftItem.totalCount = drafts.length;

+            draftItem.hasDraft = true;

+            draftItem.latestTime = draftItem.time;

+            groupDraftItems.push(draftItem);

+        }

+        for (var i = 0; i < config.listMsgs.length; i++) {

+            var smsItem = config.listMsgs[i];

+            for (var j = config.phonebook.length; j > 0; j--) {

+                var book = config.phonebook[j - 1];

+                var last8Num = getLastNumber(book.pbm_number, config.SMS_MATCH_LENGTH);

+                if (smsItem.itemId == last8Num) {

+                    smsItem.name = book.pbm_name;

+                    for (var k = 0; k < options.length; k++) {

+                        if (last8Num == options[k].value) {

+                            options[k].value = getLastNumber(smsItem.number, config.SMS_MATCH_LENGTH);

+                            options[k].text = book.pbm_name + '/' + smsItem.number;

+                            break;

+                        }

+                    }

+                    break;

+                }

+            }

+            if ($.inArray(smsItem.itemId, tmp) == -1) {

+                options.push(new Option(smsItem.number, getLastNumber(smsItem.number, config.SMS_MATCH_LENGTH)));

+                tmp.push(smsItem.itemId);

+            }

+        }

+

+        var opts = "";

+        $.each(options, function (i, e) {

+            opts += "<option value='" + HTMLEncode(e.value) + "'>" + HTMLEncode(e.text) + "</option>";

+        });

+        select.append(opts);

+        select.chosen({

+            max_selected_options: 5,

+            search_contains: true,

+            width: '740px'

+        });

+        showSmsListData();

+        showMultiDraftListData();

+        //changeShownMsgs();

+        ready = true;

+    }

+

+    function showSmsListData() {

+        if (smsTableTmpl == null) {

+            smsTableTmpl = $.template("smsTableTmpl", $("#smsTableTmpl"));

+        }

+        cleanSmsList();

+        $.tmpl("smsTableTmpl", {

+            data: config.listMsgs

+        }).translate().appendTo("#smslist-table");

+

+        if (config.HAS_PHONEBOOK) {

+            $(".sms-add-contact-icon").removeClass("hide");

+        } else {

+            $(".sms-add-contact-icon").addClass("hide");

+        }

+    }

+    //群组草稿列表显示

+    function showMultiDraftListData() {

+        if (groupDraftItems.length == 0) {

+            return false;

+        }

+        if (smsTableTmpl == null) {

+            smsTableTmpl = $.template("smsTableTmpl", $("#smsTableTmpl"));

+        }

+        $.tmpl("smsTableTmpl", {

+            data: groupDraftItems

+        }).translate().prependTo("#smslist-table");

+    }

+

+    // 页面发生滚动后,改变页面显示的短消息

+    function changeShownMsgs() {

+        var shownMsgsTmp = [];

+        var range = _.range((currentPage - 1) * 5, currentPage * 5);

+        $.each(range, function (i, e) {

+            if (config.listMsgs[e]) {

+                shownMsgsTmp.push(config.listMsgs[e]);

+            }

+        });

+        //shownMsgsTmp = config.listMsgs;

+        currentPage++;

+

+        if (smsTableTmpl == null) {

+            smsTableTmpl = $.template("smsTableTmpl", $("#smsTableTmpl"));

+        }

+        $.tmpl("smsTableTmpl", {

+            data: shownMsgsTmp

+        }).translate().appendTo("#smslist-table");

+

+        renderCheckbox();

+        if (shownMsgsTmp.length == 0) {

+            disableBtn($("#smslist-delete-all"));

+            tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), 0);

+        } else {

+            enableBtn($("#smslist-delete-all"));

+            tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), 1);

+        }

+        if (currentPage == 2 && window.innerHeight == $("body").height()) {

+            changeShownMsgs();

+        }

+        return shownMsgsTmp;

+    }

+

+    //将被checked的条目添加到self.checkedItem中,用于在滚动还原checkbox

+    checkboxClickHandler = function (id) {

+        checkDeleteBtnStatus();

+    };

+

+    //获取已选择的条目

+    getSelectedItem = function () {

+        var selected = [];

+        var checkedItem = $("#smslist-table input:checkbox:checked");

+        checkedItem.each(function (i, e) {

+            selected.push($(e).val());

+        });

+        return selected;

+    };

+

+    //删除按钮是否禁用

+    checkDeleteBtnStatus = function () {

+        var size = getSelectedItem().length;

+        if (size == 0) {

+            disableBtn($("#smslist-delete"));

+        } else {

+            enableBtn($("#smslist-delete"));

+        }

+    };

+

+    //刷新短消息列表

+    refreshClickHandler = function () {

+        $("#smslist-table").empty();

+        disableBtn($("#smslist-delete"));

+        disableCheckbox($("#smslist-checkAll", "#smsListForm"));

+        init();

+        renderCheckbox();

+    };

+

+    //删除全部短消息

+    deleteAllClickHandler = function () {

+        showConfirm("confirm_data_delete", function () {

+            showLoading('deleting');

+            service.deleteAllMessages({

+                location: "native_inbox"

+            }, function (data) {

+                cleanSmsList();

+                tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), 0);

+                successOverlay();

+            }, function (error) {

+                errorOverlay(error.errorText);

+            });

+        });

+    };

+

+    //删除选中的短消息

+    deleteSelectClickHandler = function () {

+        showConfirm("confirm_sms_delete", function () {

+            showLoading('deleting');

+            var items = getIdsBySelectedIds();

+            service.deleteMessage({

+                ids: items.ids

+            }, function (data) {

+                renderAfterDelete(items);

+                disableBtn($("#smslist-delete"));

+                $("#checkbox-all").removeAttr("checked");

+                renderCheckbox();

+                successOverlay();

+            }, function (error) {

+                errorOverlay(error.errorText);

+            });

+        });

+

+        function renderAfterDelete(items) {

+            var ids = items.ids;

+            var nums = [];

+            $.each(config.dbMsgs, function (i, e) {

+                if ($.inArray(e.id, items.normalIds) != -1) {

+                    nums.push(e.number);

+                }

+            });

+            nums = _.uniq(nums);

+            $.each(nums, function (i, e) {

+                $("#smslist-item-" + getLastNumber(e, config.SMS_MATCH_LENGTH)).hide().remove();

+            });

+            $.each(items.groups, function (i, e) {

+                $("#smslist-item-" + e).hide().remove();

+            });

+            synchSmsList(nums, ids);

+        }

+

+        function getIdsBySelectedIds() {

+            var nums = [];

+            var resultIds = [];

+            var normalIds = [];

+            var groups = [];

+            var selectedItem = getSelectedItem();

+            $.each(selectedItem, function (i, e) {

+                var checkbox = $("#checkbox" + e);

+                if (checkbox.attr("groupid")) {

+                    groups.push(checkbox.attr("groupid"));

+                } else {

+                    nums.push(getLastNumber(checkbox.attr("number"), config.SMS_MATCH_LENGTH));

+                }

+            });

+

+            $.each(config.dbMsgs, function (i, e) {

+                if ($.inArray(getLastNumber(e.number, config.SMS_MATCH_LENGTH), nums) != -1 && (typeof e.groupId == "undefined" || _.isEmpty(e.groupId + ''))) {

+                    resultIds.push(e.id);

+                    normalIds.push(e.id);

+                } else if ($.inArray(e.groupId + '', groups) != -1) { //删除草稿组

+                    resultIds.push(e.id);

+                }

+            });

+            resultIds = _.uniq(resultIds);

+            return {

+                ids: resultIds,

+                groups: groups,

+                normalIds: normalIds

+            };

+        }

+    };

+

+    //新短信按钮点击

+    newMessageClickHandler = function () {

+        $("#chosenUser1", "#smsChatRoom").addClass("hide");

+        $("#chosenUser", "#smsChatRoom").show();

+

+        cleanChatInput();

+        checkSmsCapacityAndAlert();

+        $("select.chosen-select-deselect").val("").trigger("chosen:updated.chosen");

+        switchPage('chat');

+        gotoBottom();

+        clearChatList();

+    };

+

+    //返回聊天室列表

+    chatCancelClickHandler = function () {

+        if (config.CONTENT_MODIFIED.modified) {

+            var confirmMessage = 'sms_to_save_draft';

+            var selectedContact = syncSelectAndChosen($("select#chosenUserSelect"), $('.search-choice', '#chosenUserSelect_chosen'));

+            var noContactSelected = !selectedContact || selectedContact.length == 0;

+            if (noContactSelected) {

+                confirmMessage = 'sms_no_recipient';

+            }

+            if (noContactSelected) {

+                showConfirm(confirmMessage, {

+                    ok: function () {

+                        if (!noContactSelected) {

+                            saveDraftAction({

+                                content: $("#chat-input", "#smsChatRoom").val(),

+                                numbers: selectedContact,

+                                isFromBack: true

+                            });

+                        }

+                        config.resetContentModifyValue();

+                        backToSmsListMainPage();

+                    },

+                    no: function () {

+                        if (noContactSelected) {

+                            return true;

+                        }

+                        config.resetContentModifyValue();

+                        backToSmsListMainPage();

+                    }

+                });

+            } else {

+                saveDraftAction({

+                    content: $("#chat-input", "#smsChatRoom").val(),

+                    numbers: selectedContact,

+                    isFromBack: true

+                });

+                config.resetContentModifyValue();

+                backToSmsListMainPage();

+            }

+            return false;

+        }

+        backToSmsListMainPage();

+    };

+

+    //跳转页面至SIM卡侧、设置界面

+    toOtherClickHandler = function (href) {

+        config.CONTENT_MODIFIED.checkChangMethod();

+        if (config.CONTENT_MODIFIED.modified) {

+            draftListener();

+            if (config.CONTENT_MODIFIED.message == 'sms_to_save_draft') {

+                config.CONTENT_MODIFIED.callback.ok(config.CONTENT_MODIFIED.data);

+                config.resetContentModifyValue();

+                window.location.hash = href;

+            } else {

+                showConfirm(config.CONTENT_MODIFIED.message, {

+                    ok: function () {

+                        config.CONTENT_MODIFIED.callback.ok(config.CONTENT_MODIFIED.data);

+                        config.resetContentModifyValue();

+                        window.location.hash = href;

+                    },

+                    no: function () {

+                        var result = config.CONTENT_MODIFIED.callback.no(config.CONTENT_MODIFIED.data);

+                        if (!result) {

+                            window.location.hash = href;

+                            config.resetContentModifyValue();

+                        }

+                    }

+                });

+            }

+            return false;

+        } else {

+            window.location.hash = href;

+        }

+    };

+

+    function backToSmsListMainPage() {

+        $("select.chosen-select-deselect").val("").trigger("chosen:updated.chosen");

+        config.currentChatObject = null;

+        $(".smslist-btns", "#smslist-main").removeClass('smsListFloatButs');

+        switchPage('list');

+    }

+

+    function switchPage(page) {

+        if (page == 'chat') {

+            $("#smslist-main").hide();

+            $("#smsChatRoom").show();

+        } else {

+            $("#smsChatRoom").hide();

+            $("#smslist-main").show();

+        }

+    }

+

+    var sendSmsErrorTimer = null;

+    //添加发送错误消息

+    addSendSmsError = function (msg) {

+        if (sendSmsErrorTimer) {

+            window.clearTimeout(sendSmsErrorTimer);

+            sendSmsErrorTimer = null;

+        }

+        $("#sendSmsErrorLi").text($.i18n.prop(msg));

+        sendSmsErrorTimer = addTimeout(function () {

+            $("#sendSmsErrorLi").text("");

+        }, 5000);

+    };

+

+    //发送短消息

+    sendSmsClickHandler = function () {

+        if (!hasCapability) {

+            showAlert("sms_capacity_is_full_for_send");

+            return;

+        }

+        var inputVal = $("#chat-input", "#smsChatRoom");

+        var msgContent = inputVal.val();

+        if (msgContent == $.i18n.prop("chat_input_placehoder")) {

+            inputVal.val("");

+            msgContent = "";

+        }

+        var nums = syncSelectAndChosen($("select#chosenUserSelect"), $('.search-choice', '#chosenUserSelect_chosen'));

+        if ($.isArray(nums)) {

+            nums = $.grep(nums, function (n, i) {

+                return !_.isEmpty(n);

+            });

+        }

+        if (!nums || nums.length == 0) {

+            addSendSmsError("sms_contact_required");

+            return;

+        }

+        if (nums.length + smsCapability.nvUsed > smsCapability.nvTotal) {

+            showAlert({

+                msg: "sms_capacity_will_full_just",

+                params: [smsCapability.nvTotal - smsCapability.nvUsed]

+            });

+            return;

+        }

+        if (nums.length == 1) {

+            config.currentChatObject = getLastNumber(nums[0], config.SMS_MATCH_LENGTH);

+            showLoading('sending');

+        } else if (nums.length > 1) {

+            showLoading("sending", "<button id='sms_cancel_sending' onclick='cancelSending()' class='btn btn-primary'>"

+                 + $.i18n.prop("sms_stop_sending")

+                 + "</button>");

+            config.currentChatObject = null;

+        }

+        var i = 0;

+        var leftNum = nums.length;

+        couldSend = true;

+        disableBtn($("#btn-send", "#inputpanel"));

+        sendSms = function () {

+            if (!couldSend) {

+                hideLoading();

+                return;

+            }

+            var newMsg = {

+                id: -1,

+                number: nums[i],

+                content: msgContent,

+                isNew: false

+            };

+

+            if (leftNum == 1) {

+                $("#loading #loading_container").html("");

+            }

+

+            leftNum--;

+            service.sendSMS({

+                number: newMsg.number,

+                message: newMsg.content,

+                id: -1

+            }, function (data) {

+                var latestMsg = getLatestMessage() || {

+                    id: parseInt(config.smsMaxId, 10) + 1,

+                    time: transUnixTime($.now()),

+                    number: newMsg.number

+                };

+                config.smsMaxId = latestMsg.id;

+                newMsg.id = config.smsMaxId;

+                newMsg.time = latestMsg.time;

+                newMsg.tag = 2;

+                newMsg.hasDraft = false;

+                if (nums.length > 1) {

+                    newMsg.targetName = getNameOrNumberByNumber(newMsg.number);

+                }

+                addSendMessage(newMsg, i + 1 != nums.length);

+                updateDBMsg(newMsg);

+                updateMsgList(newMsg);

+                tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), $(".smslist-item", "#smslist-table").length);

+                gotoBottom();

+                if (i + 1 == nums.length) {

+                    updateChatInputWordLength();

+                    enableBtn($("#btn-send", "#inputpanel"));

+                    hideLoading();

+                    return;

+                }

+                i++;

+                sendSms();

+            }, function (error) {

+                var latestMsg = getLatestMessage() || {

+                    id: parseInt(config.smsMaxId, 10) + 1,

+                    time: transUnixTime($.now()),

+                    number: newMsg.number

+                };

+                config.smsMaxId = latestMsg.id;

+                newMsg.id = config.smsMaxId;

+                newMsg.time = latestMsg.time;

+                newMsg.errorText = $.i18n.prop(error.errorText);

+                newMsg.tag = 3;

+                newMsg.target = newMsg.number;

+                newMsg.hasDraft = false;

+                if (nums.length > 1) {

+                    newMsg.targetName = getNameOrNumberByNumber(newMsg.number);

+                }

+                addSendMessage(newMsg, i + 1 != nums.length);

+                updateDBMsg(newMsg);

+                updateMsgList(newMsg);

+                tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), $(".smslist-item", "#smslist-table").length);

+                gotoBottom();

+                if (i + 1 == nums.length) {

+                    updateChatInputWordLength();

+                    enableBtn($("#btn-send", "#inputpanel"));

+                    hideLoading();

+                    return;

+                }

+                i++;

+                sendSms();

+            });

+        };

+        sendSms();

+    };

+

+    var couldSend = true;

+

+    //取消剩余短信发送操作

+    cancelSending = function () {

+        couldSend = false;

+        $("#loading #loading_container").html($.i18n.prop('sms_cancel_sending'));

+    };

+

+    //获取最新的短消息

+    getLatestMessage = function () {

+        var data = service.getSMSMessages({

+            page: 0,

+            smsCount: 5,

+            nMessageStoreType: 1,

+            tags: 10,

+            orderBy: "order by id desc"

+        });

+        if (data.messages.length > 0) {

+            for (var i = 0; i < data.messages.length; i++) {

+                if (data.messages[i].tag == '2' || data.messages[i].tag == '3') {

+                    return data.messages[i];

+                }

+            }

+            return null;

+        } else {

+            return null;

+        }

+    };

+

+    //发送短信后,更新短信数据对象

+    function updateDBMsg(msg) {

+        if (config.dbMsgs.length == 0) {

+            config.dbMsgs = [msg];

+        } else {

+            /* cov_2

+            for(var j = 0; j < config.dbMsgs.length; j++){

+            if(config.dbMsgs[j].id == msg.id){

+            config.dbMsgs[j] = msg;

+            return;

+            } else {

+            var newMsg = [msg];

+            $.merge(newMsg, config.dbMsgs);

+            config.dbMsgs = newMsg;

+            return;

+            }

+            }

+             */

+            if (config.dbMsgs[0].id == msg.id) {

+                config.dbMsgs[0] = msg;

+                return;

+            } else {

+                var newMsg = [msg];

+                $.merge(newMsg, config.dbMsgs);

+                config.dbMsgs = newMsg;

+                return;

+            }

+        }

+    }

+

+    //发送短信后,更新短信列表, number不为空做删除处理,为空做增加处理

+    function updateMsgList(msg, number, counter) {

+        if ((!msg || !msg.number) && !number) {

+            return;

+        }

+        var itemId = '';

+        if (msg && typeof msg.groupId != "undefined" && msg.groupId != '') {

+            itemId = msg.groupId;

+        } else {

+            itemId = getLastNumber((number || msg.number), config.SMS_MATCH_LENGTH);

+        }

+        var item = $("#smslist-item-" + itemId);

+        if (item && item.length > 0) {

+            var totalCountItem = item.find(".smslist-item-total-count");

+            var count = totalCountItem.text();

+            count = Number(count.substring(1, count.length - 1));

+            if (number) {

+                if (count == 1 || msg == null) {

+                    item.hide().remove();

+                    return;

+                } else {

+                    totalCountItem.text("(" + (count - (counter || 1)) + ")");

+                    item.find(".smslist-item-draft-flag").addClass('hide');

+                }

+            } else {

+                totalCountItem.text("(" + (count + 1) + ")");

+                if (msg.tag == '4') {

+                    item.find(".smslist-item-draft-flag").removeClass('hide');

+                }

+            }

+            item.find(".smslist-item-checkbox p.checkbox").attr("id", msg.id);

+            item.find(".smslist-item-checkbox input:checkbox").val(msg.id).attr("id", "checkbox" + msg.id);

+            var contentHtml = msg.content;

+			var msgContent;

+            if (msg.tag == '4') {

+                //contentHtml = '<span class="smslist-item-draft-flag colorRed" data-trans="draft"></span>: ' + contentHtml;

+				msgContent = item.find(".smslist-item-msg").html('<span class="smslist-item-draft-flag colorRed" data-trans="draft"></span>: ' + HTMLEncode(contentHtml)); //.addClass("font-weight-bold");

+            } else {

+				msgContent = item.find(".smslist-item-msg").html(HTMLEncode(contentHtml)); //.addClass("font-weight-bold");

+			}

+            //var msgContent = item.find(".smslist-item-msg").html(HTMLEncode(contentHtml)); //.addClass("font-weight-bold");

+            msgContent.closest('td').prop('title', msg.content);

+            item.find(".smslist-item-repeat span").die().click(function () {

+                forwardClickHandler(msg.id);

+            });

+            item.find("span.clock-time").text(msg.time);

+            var tmpItem = item;

+            item.hide().remove();

+            $("#smslist-table").prepend(tmpItem.show());

+        } else {

+            if (smsTableTmpl == null) {

+                smsTableTmpl = $.template("smsTableTmpl", $("#smsTableTmpl"));

+            }

+            msg.checked = false;

+            msg.newCount = 0;

+            msg.latestId = msg.id;

+            msg.latestSms = msg.content;

+            msg.latestTime = msg.time;

+            if (msg.groupId == '' || typeof msg.groupId == "undefined") {

+                msg.totalCount = 1;

+            }

+            if (!msg.hasDraft) {

+                msg.hasDraft = false;

+            }

+            msg.itemId = itemId;

+            msg.name = getNameByNumber(msg.number);

+            $.tmpl("smsTableTmpl", {

+                data: [msg]

+            }).translate().prependTo("#smslist-table");

+        }

+        if (config.HAS_PHONEBOOK) {

+            $(".sms-add-contact-icon").removeClass("hide");

+        } else {

+            $(".sms-add-contact-icon").addClass("hide");

+        }

+        $("#smslist-table").translate();

+        renderCheckbox();

+    }

+

+    //增加发送内容到聊天室, notCleanChatInput 是否清除输入框内容

+    addSendMessage = function (sms, notCleanChatInput) {

+        if (smsMeTmpl == null) {

+            smsMeTmpl = $.template("smsMeTmpl", $("#smsMeTmpl"));

+        }

+        $.tmpl("smsMeTmpl", sms).appendTo("#chatlist");

+        $("#chatlist").translate();

+        if (!notCleanChatInput) {

+            cleanChatInput();

+        }

+        clearMySmsErrorMessage(sms.id);

+    };

+

+    //清楚错误消息,避免翻译问题

+    clearMySmsErrorMessage = function (id) {

+        addTimeout(function () {

+            $("div.error", "#talk-item-" + id).text("");

+        }, 3000);

+    };

+

+    //快速添加联系人overlay是否打开

+    var isPoped = false;

+

+    //关闭快速添加联系人overlay

+    hidePopup = function () {

+        $(".tagPopup").remove();

+        isPoped = false;

+    };

+

+    //清空聊天室内容

+    clearChatList = function () {

+        $("#chatlist").empty();

+        updateChatInputWordLength();

+    };

+

+    //过滤短消息内容

+    dealContent = function (content) {

+        if (config.HAS_PHONEBOOK) {

+            return HTMLEncode(content).replace(/(\d{3,})/g, function (word) {

+                var r = (new Date().getTime() + '').substring(6) + (getRandomInt(1000) + 1000);

+                return "<a id='aNumber" + r + "' href='javascript:openPhoneBook(\"" + r + "\", \"" + word + "\")'>" + word + "</a>";

+            });

+        } else {

+            return HTMLEncode(content);

+        }

+

+    };

+

+    //打开快速添加联系人overlay

+    openPhoneBook = function (id, num) {

+        var target = null;

+        var outContainer = "";

+        var itemsContainer = null;

+        var isChatRoom = false;

+        if (!id) {

+            target = $("#listNumber" + getLastNumber(num, config.SMS_MATCH_LENGTH));

+            outContainer = ".smslist-item";

+            itemsContainer = $("#addPhonebookContainer");

+        } else {

+            target = $("#aNumber" + id);

+            outContainer = ".msg_container";

+            itemsContainer = $("#chatlist");

+            isChatRoom = true;

+        }

+        if (isPoped) {

+            hidePopup();

+        }

+        isPoped = true;

+        $("#tagPopup").remove();

+

+        if (addPhonebookTmpl == null) {

+            addPhonebookTmpl = $.template("addPhonebookTmpl", $("#addPhonebookTmpl"));

+        }

+        $.tmpl("addPhonebookTmpl", {

+            number: num

+        }).appendTo(itemsContainer);

+        var p = target.position();

+        var msgContainer = target.closest(outContainer);

+        var msgP = msgContainer.position();

+        var _left = 0,

+        _top = 0;

+        if (isChatRoom) {

+            var containerWidth = itemsContainer.width();

+            var containerHeight = itemsContainer.height();

+            var pop = $("#innerTagPopup");

+            _left = msgP.left + p.left;

+            _top = msgP.top + p.top + 20;

+            if (pop.width() + _left > containerWidth) {

+                _left = containerWidth - pop.width() - 20;

+            }

+            if (containerHeight > 100 && pop.height() + _top > containerHeight) {

+                _top = containerHeight - pop.height() - 5;

+            }

+        } else {

+            _left = p.left;

+            _top = p.top;

+        }

+        $("#innerTagPopup").css({

+            top: _top + "px",

+            left: _left + "px"

+        });

+        $('#quickSaveContactForm').translate().validate({

+            submitHandler: function () {

+                quickSaveContact(isChatRoom);

+            },

+            rules: {

+                name: "name_check",

+                number: "phonenumber_check"

+            }

+        });

+    };

+

+    //快速添加联系人

+    quickSaveContact = function () {

+        var name = $(".tagPopup #innerTagPopup #name").val();

+        var number = $(".tagPopup #innerTagPopup #number").val();

+        var newContact = {

+            index: -1,

+            location: 1,

+            name: name,

+            mobile_phone_number: number,

+            home_phone_number: "",

+            office_phone_number: "",

+            mail: ""

+        };

+        var device = service.getDevicePhoneBookCapacity();

+        if (device.pcPbmUsedCapacity >= device.pcPbmTotalCapacity) {

+            showAlert("device_full");

+            return false;

+        }

+        showLoading('waiting');

+        service.savePhoneBook(newContact, function (data) {

+            if (data.result == "success") {

+                config.phonebook.push({

+                    pbm_name: name,

+                    pbm_number: number

+                });

+                updateItemShowName(name, number);

+                hidePopup();

+                successOverlay();

+            } else {

+                errorOverlay();

+            }

+        }, function (data) {

+            errorOverlay();

+        });

+    };

+

+    function updateItemShowName(name, number) {

+        var lastNum = getLastNumber(number, config.SMS_MATCH_LENGTH);

+        $("span.smslist-item-name2", "#smslist-item-" + lastNum).text(name);

+        $("#listNumber" + lastNum).hide();

+    }

+

+    //聊天室删除单条消息

+    deleteSingleItemClickHandler = function (id, resendCallback) {

+        if (resendCallback) {

+            deleteTheSingleItem(id);

+        } else {

+            showConfirm("confirm_sms_delete", function () {

+                showLoading('deleting');

+                deleteTheSingleItem(id);

+            });

+        }

+

+        function deleteTheSingleItem(id) {

+            service.deleteMessage({

+                ids: [id]

+            }, function (data) {

+                var target = $(".smslist-item-delete", "#talk-item-" + id).attr("target");

+                $("#talk-item-" + id).hide().remove();

+

+                synchSmsList(null, [id]);

+                updateMsgList(getPeopleLatestMsg(target), target);

+                if (resendCallback) {

+                    resendCallback();

+                } else {

+                    hideLoading();

+                }

+                tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), $(".smslist-item", "#smslist-table").length);

+            }, function (error) {

+                if (resendCallback) {

+                    resendCallback();

+                } else {

+                    hideLoading();

+                }

+            });

+        }

+    };

+

+    //删除草稿

+    function deleteDraftSms(ids, numbers) {

+        stopNavigation();

+        service.deleteMessage({

+            ids: ids

+        }, function (data) {

+            updateSmsCapabilityStatus(null, function () {

+                draftListener();

+                restoreNavigation();

+            });

+            for (var i = 0; i < numbers.length; i++) {

+                updateMsgList(getPeopleLatestMsg(numbers[i]), numbers[i], ids.length);

+            }

+            synchSmsList(null, ids);

+            tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), $(".smslist-item", "#smslist-table").length);

+        }, function (error) {

+            restoreNavigation();

+            // Do nothing

+        });

+    }

+

+    //删除群聊草稿草稿

+    function deleteMultiDraftSms(ids, groupId) {

+        service.deleteMessage({

+            ids: ids

+        }, function (data) {

+            synchSmsList(null, ids);

+            $("#smslist-item-" + groupId).hide().remove();

+            checkSmsCapacityAndAlert();

+            tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), $(".smslist-item", "#smslist-table").length);

+        }, function (error) {

+            // Do nothing

+        });

+    }

+

+    getCurrentChatObject = function () {

+        var nums = $("select.chosen-select-deselect").val();

+        if (!nums) {

+            config.currentChatObject = null;

+        } else if (nums.length == 1) {

+            config.currentChatObject = getLastNumber(nums, config.SMS_MATCH_LENGTH);

+        } else if (nums.length > 1) {

+            config.currentChatObject = null;

+        }

+        return config.currentChatObject;

+    };

+

+    //获取当前聊天对象最新的短消息

+    getPeopleLatestMsg = function (number) {

+        for (var j = 0; j < config.dbMsgs.length; j++) {

+            if (!config.dbMsgs[j].groupId && getLastNumber(config.dbMsgs[j].number, config.SMS_MATCH_LENGTH) == getLastNumber(number, config.SMS_MATCH_LENGTH)) {

+                return config.dbMsgs[j];

+            }

+        }

+        return null;

+    };

+

+    //重新发送,复制消息到发送框

+    resendClickHandler = function (id) {

+        if (!hasCapability) {

+            showAlert("sms_capacity_is_full_for_send");

+            return;

+        }

+        showLoading('sending');

+        $("div.error", "#talk-item-" + id).text($.i18n.prop("sms_resending"));

+        var targetNumber = $("div.smslist-item-resend", "#talk-item-" + id).attr("target");

+        var content = $("div.J_content", "#talk-item-" + id).text();

+        for (var j = 0; j < config.dbMsgs.length; j++) {

+            if (config.dbMsgs[j].id == id) {

+                content = config.dbMsgs[j].content;

+            }

+        }

+

+        disableBtn($("#btn-send", "#inputpanel"));

+        var newMsg = {

+            id: -1,

+            number: targetNumber,

+            content: content,

+            isNew: false

+        };

+        service.sendSMS({

+            number: newMsg.number,

+            message: newMsg.content,

+            id: -1

+        }, function (data) {

+            var latestMsg = getLatestMessage() || {

+                id: parseInt(config.smsMaxId, 10) + 1,

+                time: transUnixTime($.now()),

+                number: newMsg.number

+            };

+            config.smsMaxId = latestMsg.id;

+            newMsg.id = config.smsMaxId;

+            newMsg.time = latestMsg.time;

+            newMsg.tag = 2;

+            newMsg.target = latestMsg.number;

+            newMsg.targetName = getNameOrNumberByNumber(targetNumber);

+            updateDBMsg(newMsg);

+            updateMsgList(newMsg);

+            deleteSingleItemClickHandler(id, function () {

+                addSendMessage(newMsg, true);

+                updateChatInputWordLength();

+                enableBtn($("#btn-send", "#inputpanel"));

+                hideLoading();

+                gotoBottom();

+            });

+        }, function (error) {

+            var latestMsg = getLatestMessage() || {

+                id: parseInt(config.smsMaxId, 10) + 1,

+                time: transUnixTime($.now()),

+                number: newMsg.number

+            };

+            config.smsMaxId = latestMsg.id;

+            newMsg.id = config.smsMaxId;

+            newMsg.time = latestMsg.time;

+            newMsg.errorText = $.i18n.prop("sms_resend_fail");

+            newMsg.tag = 3;

+            newMsg.target = latestMsg.number;

+            newMsg.targetName = getNameOrNumberByNumber(targetNumber);

+            updateDBMsg(newMsg);

+            updateMsgList(newMsg);

+            deleteSingleItemClickHandler(id, function () {

+                addSendMessage(newMsg, true);

+                updateChatInputWordLength();

+                enableBtn($("#btn-send", "#inputpanel"));

+                hideLoading();

+                gotoBottom();

+            });

+        });

+    };

+

+    //滚动到底部

+    gotoBottom = function () {

+        $("#chatpanel .clear-container").animate({

+            scrollTop: $("#chatlist").height()

+        });

+    };

+

+    //最后一条短消息距离顶部的距离

+    var lastItemOffsetTop = 0;

+    //页面是否处于滚动中

+    var scrolling = false;

+    //初始化页面状态信息

+    function initStatus() {

+        currentPage = 1;

+        ready = false;

+        shownMsgs = [];

+        scrolling = false;

+        lastItemOffsetTop = 0;

+        groupDrafts = groupDraftItems = [];

+        groupedDraftsObject = {};

+		config.dbMsgs = [];

+        config.listMsgs = null;

+        config.smsMaxId = 0;

+        config.phonebook = [];

+    }

+

+    function getReadyStatus() {

+        showLoading('waiting');

+        config.currentChatObject = null;

+        var getSMSReady = function () {

+            service.getSMSReady({}, function (data) {

+                if (data.sms_cmd_status_result == "2") {

+                    $("input:button", "#smsListForm .smslist-btns").attr("disabled", "disabled");

+                    hideLoading();

+                    showAlert("sms_init_fail");

+                } else if (data.sms_cmd_status_result == "1") {

+                    addTimeout(getSMSReady, 1000);

+                } else {

+                    if (config.HAS_PHONEBOOK) {

+                        getPhoneBookReady();

+                    } else {

+                        initSMSList(false);

+                    }

+                }

+            });

+        };

+

+        var getPhoneBookReady = function () {

+            service.getPhoneBookReady({}, function (data) {

+                if (data.pbm_init_flag == "6") {

+                    initSMSList(false);

+                } else if (data.pbm_init_flag != "0") {

+                    addTimeout(getPhoneBookReady, 1000);

+                } else {

+                    initSMSList(true);

+                }

+            });

+        };

+

+        var initSMSList = function (isPbmInitOK) {

+            initStatus();

+            if (isPbmInitOK) {

+                getSMSMessages(function () {

+                    getPhoneBooks();

+                    hideLoading();

+                });

+            } else {

+                getSMSMessages(function () {

+                    config.phonebook = [];

+                    //if(config.HAS_PHONEBOOK){

+                    dealPhoneBooks();

+                    //}

+                    hideLoading();

+                });

+            }

+            bindingEvents();

+            fixScrollTop();

+            window.scrollTo(0, 0);

+            initSmsCapability();

+        };

+

+        getSMSReady();

+    }

+

+    //初始化短信容量状态

+    function initSmsCapability() {

+        var capabilityContainer = $("#smsCapability");

+        updateSmsCapabilityStatus(capabilityContainer);

+        checkSimStatusForSend();

+        addInterval(function () {

+            updateSmsCapabilityStatus(capabilityContainer);

+            checkSimStatusForSend();

+        }, 5000);

+    }

+

+    //SIM卡未准备好时,禁用发送按钮

+    function checkSimStatusForSend() {

+        var data = service.getStatusInfo();

+        if (data.simStatus != 'modem_init_complete') {

+            disableBtn($("#btn-send"));

+            $("#sendSmsErrorLi").html('<span data-trans="no_sim_card_message">' + $.i18n.prop('no_sim_card_message') + '</span>');

+            $("#chatpanel .smslist-item-resend:visible").hide();

+        } else {

+            enableBtn($("#btn-send"));

+            $("#chatpanel .smslist-item-resend:hidden").show();

+        }

+    }

+

+    //更新短信容量状态

+    function updateSmsCapabilityStatus(capabilityContainer, callback) {

+        service.getSmsCapability({}, function (capability) {

+            if (capabilityContainer != null) {

+                capabilityContainer.text("(" + (capability.nvUsed > capability.nvTotal ? capability.nvTotal : capability.nvUsed) + "/" + capability.nvTotal + ")");

+            }

+            hasCapability = capability.nvUsed < capability.nvTotal;

+            smsCapability = capability;

+            if ($.isFunction(callback)) {

+                callback();

+            }

+        });

+    }

+

+    //初始化页面及VM

+    function init() {

+        getReadyStatus();

+    }

+

+    //事件绑定

+    bindingEvents = function () {

+        var $win = $(window);

+        var $smsListBtns = $("#smslist-main .smslist-btns");

+        var offsetTop = $("#mainContainer").offset().top;

+        $win.unbind("scroll").scroll(function () {

+            if ($win.scrollTop() > offsetTop) {

+                $smsListBtns.addClass("smsListFloatButs marginnone");

+            } else {

+                $smsListBtns.removeClass("smsListFloatButs marginnone");

+            }

+            //loadData(); //由于目前数据显示是全显示,不做动态加载,因此暂时注释掉

+        });

+

+        $("#smslist-table p.checkbox").die().live("click", function () {

+            checkboxClickHandler($(this).attr("id"));

+        });

+

+        $("#smslist-checkAll", "#smsListForm").die().live("click", function () {

+            checkDeleteBtnStatus();

+        });

+

+        $("#chat-input", "#smsChatRoom").die().live("drop", function () {

+            $("#inputpanel .chatform").addClass("chatformfocus");

+            var $this = $(this);

+            $this.removeAttr("data-trans");

+            if ($this.val() == $.i18n.prop("chat_input_placehoder")) {

+                $this.val("");

+            }

+            updateChatInputWordLength();

+        }).live("focusin", function () {

+            $("#inputpanel .chatform").addClass("chatformfocus");

+            var $this = $(this);

+            $this.removeAttr("data-trans");

+            if ($this.val() == $.i18n.prop("chat_input_placehoder")) {

+                $this.val("");

+            }

+            updateChatInputWordLength();

+        }).live("focusout", function () {

+            $("#inputpanel .chatform").removeClass("chatformfocus");

+            var $this = $(this);

+            if ($this.val() == "" || $this.val() == $.i18n.prop("chat_input_placehoder")) {

+                $this.val($.i18n.prop("chat_input_placehoder")).attr("data-trans", "chat_input_placehoder");

+            }

+            updateChatInputWordLength();

+        }).live("keyup", function () {

+            updateChatInputWordLength();

+        }).live("paste", function () {

+            window.setTimeout(function () {

+                updateChatInputWordLength();

+            }, 0);

+        }).live("cut", function () {

+            window.setTimeout(function () {

+                updateChatInputWordLength();

+            }, 0);

+        }).live("drop", function () {

+            window.setTimeout(function () {

+                updateChatInputWordLength();

+            }, 0);

+        }).live("contextmenu", function () {

+            return false;

+        });

+

+        $("#name").die().live("drop", function () {

+            updateNameInputWordLength();

+        }).live("focusin", function () {

+            updateNameInputWordLength();

+        }).live("focusout", function () {

+            updateNameInputWordLength();

+        }).live("keyup", function () {

+            updateNameInputWordLength();

+        }).live("paste", function () {

+            updateNameInputWordLength();

+        }).live("cut", function () {

+            updateNameInputWordLength();

+        }).live("dragend", function () {

+            updateNameInputWordLength();

+        }).live("contextmenu", function () {

+            return false;

+        });

+

+        $("select.chosen-select-deselect", "#smsChatRoom").die().live('change', function () {

+            draftListener();

+        });

+        $("#searchInput").die().live('blur', function () {

+            searchTextBlur();

+        }).live('keyup', function () {

+            updateSearchValue($("#searchInput").val());

+        });

+    };

+

+    //更新剩余字数

+    updateNameInputWordLength = function () {

+

+        var msgInput = $("#name", "#quickSaveContactForm");

+        var msgInputDom = msgInput[0];

+        var strValue = msgInput.val();

+        var encodeType = getEncodeType(strValue);

+        var maxLength = encodeType.encodeType == 'UNICODE' ? 11 : 22;

+        while (strValue.length + encodeType.extendLen > maxLength) {

+            strValue = strValue.substring(0, strValue.length - 1);

+            msgInputDom.value = strValue;

+            encodeType = getEncodeType(strValue);

+            maxLength = encodeType.encodeType == 'UNICODE' ? 11 : 22;

+        }

+    };

+

+//获取聊天对象的名字

+    getNameByNumber = function (num) {

+        for (var i = config.phonebook.length; i > 0; i--) {

+            if (getLastNumber(config.phonebook[i - 1].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(num, config.SMS_MATCH_LENGTH)) {

+                return config.phonebook[i - 1].pbm_name;

+            }

+        }

+        return "";

+    };

+    //获取聊天对象的名字和号码

+    getShowNameByNumber = function (num) {

+        for (var i = config.phonebook.length; i > 0; i--) {

+            if (getLastNumber(config.phonebook[i - 1].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(num, config.SMS_MATCH_LENGTH)) {

+                return config.phonebook[i - 1].pbm_name /* + "/" + num*/;

+            }

+        }

+        return num;

+    };

+

+    //获取聊天对象的名字,如果没有名字,则显示号码

+    getNameOrNumberByNumber = function (num) {

+        for (var i = config.phonebook.length; i > 0; i--) {

+            if (config.phonebook[i - 1].pbm_number == num) {

+                return config.phonebook[i - 1].pbm_name;

+            }

+        }

+        for (var i = config.phonebook.length; i > 0; i--) {

+            if (getLastNumber(config.phonebook[i - 1].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(num, config.SMS_MATCH_LENGTH)) {

+                return config.phonebook[i - 1].pbm_name;

+            }

+        }

+        return num;

+    };

+

+    //点击短信列表条目,进入聊天室页面

+    smsItemClickHandler = function (num) {

+        if (chatRoomInLoading) {

+            return false;

+        }

+        chatRoomInLoading = true;

+        if (smsOtherTmpl == null) {

+            smsOtherTmpl = $.template("smsOtherTmpl", $("#smsOtherTmpl"));

+        }

+        if (smsMeTmpl == null) {

+            smsMeTmpl = $.template("smsMeTmpl", $("#smsMeTmpl"));

+        }

+

+        var name = getShowNameByNumber(num);

+        $("#chosenUser", "#smsChatRoom").hide();

+        $("#chosenUser1", "#smsChatRoom").addClass("hide");

+

+        config.currentChatObject = getLastNumber(num, config.SMS_MATCH_LENGTH);

+        setAsRead(num);

+        cleanChatInput();

+        clearChatList();

+        var userSelect = $("select.chosen-select-deselect", "#smsChatRoom");

+        var ops = $("option", userSelect);

+        var numberExist = false;

+        for (var i = 0; i < ops.length; i++) {

+            var n = ops[i];

+            if (getLastNumber(n.value, config.SMS_MATCH_LENGTH) == config.currentChatObject) {

+                num = n.value;

+                numberExist = true;

+                break;

+            }

+        }

+        if (!numberExist) {

+            userSelect.append("<option value='" + HTMLEncode(num) + "' selected='selected'>" + HTMLEncode(num) + "</option>");

+        }

+        $("select.chosen-select-deselect").val(num).trigger("chosen:updated.chosen");

+        switchPage('chat');

+        config.dbMsgs = _.sortBy(config.dbMsgs, function (e) {

+            return 0 - e.id;

+        });

+        var draftIds = [];

+        var dbMsgsTmp = [];

+        var dbMsgsTmpIds = [];

+        var chatHasDraft = false;

+        for (var i = config.dbMsgs.length - 1; i >= 0; i--) {

+            var e = config.dbMsgs[i];

+            if (_.indexOf(dbMsgsTmpIds, e.id) != -1) {

+                continue;

+            }

+            if (getLastNumber(e.number, config.SMS_MATCH_LENGTH) == config.currentChatObject && _.isEmpty(e.groupId)) {

+                e.isNew = false;

+                e.errorText = '';

+                e.targetName = '';

+                if (e.tag == "0" || e.tag == "1") {

+                    $.tmpl("smsOtherTmpl", e).appendTo("#chatlist");

+                    dbMsgsTmpIds.push(e.id);

+                    dbMsgsTmp.push(e);

+                } else if (e.tag == "2" || e.tag == "3") {

+                    $.tmpl("smsMeTmpl", e).appendTo("#chatlist");

+                    dbMsgsTmpIds.push(e.id);

+                    dbMsgsTmp.push(e);

+                } else if (e.tag == "4") {

+                    draftIds.push(e.id);

+                    $("#chat-input", "#smsChatRoom").val(e.content).removeAttr('data-trans');

+                    updateChatInputWordLength();

+                    chatHasDraft = true;

+                }

+            } else {

+                dbMsgsTmpIds.push(e.id);

+                dbMsgsTmp.push(e);

+            }

+        }

+        $("#chatlist").translate();

+        if (chatHasDraft) {

+            $("#chosenUser", "#smsChatRoom").show();

+            $("#chosenUser1", "#smsChatRoom").addClass("hide");

+        } else {

+            $("#chosenUser", "#smsChatRoom").hide();

+            $("#chosenUser1", "#smsChatRoom").removeClass("hide").html(HTMLEncode(name));

+        }

+        config.dbMsgs = dbMsgsTmp.reverse();

+        if (draftIds.length > 0) {

+            deleteDraftSms(draftIds, [num]);

+        } else {

+            checkSmsCapacityAndAlert();

+        }

+

+        checkSimStatusForSend();

+        gotoBottom();

+        chatRoomInLoading = false;

+    };

+

+    function checkSmsCapacityAndAlert() {

+        var capabilityContainer = $("#smsCapability");

+        updateSmsCapabilityStatus(capabilityContainer);

+        addTimeout(function () {

+            if (!hasCapability) {

+                showAlert("sms_capacity_is_full_for_send");

+            }

+        }, 2000);

+    }

+

+    cleanChatInput = function () {

+        $("#chat-input", "#smsChatRoom").val($.i18n.prop("chat_input_placehoder")).attr("data-trans", "chat_input_placehoder");

+    };

+

+    //设置为已读

+    setAsRead = function (num) {

+        var ids = [];

+        $.each(config.dbMsgs, function (i, e) {

+            if (getLastNumber(e.number, config.SMS_MATCH_LENGTH) == getLastNumber(num, config.SMS_MATCH_LENGTH) && e.isNew) {

+                ids.push(e.id);

+                e.isNew = false;

+            }

+        });

+        if (ids.length > 0) {

+            service.setSmsRead({

+                ids: ids

+            }, function (data) {

+                if (data.result) {

+                    $("#smslist-item-" + getLastNumber(num, config.SMS_MATCH_LENGTH) + " .smslist-item-new-count").text("").addClass("hide");

+                    $("#smslist-item-" + getLastNumber(num, config.SMS_MATCH_LENGTH)).removeClass("font-weight-bold");

+                    $("#smslist-item-" + getLastNumber(num, config.SMS_MATCH_LENGTH) + " td:nth-child(2)").removeClass("font-weight-bold");

+                }

+                $.each(config.listMsgs, function (i, e) {

+                    if (e.number == num && e.newCount > 0) {

+                        e.newCount = 0;

+                    }

+                });

+            });

+        }

+    };

+

+    //转发按钮点击事件

+    forwardClickHandler = function (id) {

+        var selectedContact = syncSelectAndChosen($("select#chosenUserSelect"), $('.search-choice', '#chosenUserSelect_chosen'));

+        var content = $("#chat-input", "#smsChatRoom").val();

+        var hasContent = typeof content != "undefined" && content != '' && content != $.i18n.prop('chat_input_placehoder');

+        if (hasContent) {

+            saveDraftAction({

+                content: content,

+                numbers: selectedContact,

+                isFromBack: true,

+                noLoading: true

+            });

+        }

+

+        clearChatList();

+        config.currentChatObject = null;

+

+        $("#chosenUser1", "#smsChatRoom").addClass("hide");

+        $("#chosenUser", "#smsChatRoom").show();

+        for (var j = 0; j < config.dbMsgs.length; j++) {

+            if (config.dbMsgs[j].id == id) {

+                var theChatInput = $("#chat-input", "#smsChatRoom");

+                theChatInput.val(config.dbMsgs[j].content);

+                setInsertPos(theChatInput[0], config.dbMsgs[j].content.length);

+            }

+        }

+        updateChatInputWordLength();

+        $("select.chosen-select-deselect").val("").trigger("chosen:updated.chosen");

+        addTimeout(function () {

+            $("#chosen-search-field-input").focus();

+        }, 300);

+        switchPage('chat');

+        gotoBottom();

+    };

+

+    //更新剩余字数

+    updateChatInputWordLength = function () {

+        var msgInput = $("#chat-input", "#smsChatRoom");

+        var msgInputDom = msgInput[0];

+        var strValue = msgInput.val();

+        var encodeType = getEncodeType(strValue);

+        var maxLength = encodeType.encodeType == 'UNICODE' ? 335 : 765;

+        if (strValue.length + encodeType.extendLen > maxLength) {

+            var scrollTop = msgInputDom.scrollTop;

+            var insertPos = getInsertPos(msgInputDom);

+            var moreLen = strValue.length + encodeType.extendLen - maxLength;

+            var insertPart = strValue.substr(insertPos - moreLen > 0 ? insertPos - moreLen : 0, moreLen);

+            var reversed = insertPart.split('').reverse();

+            var checkMore = 0;

+            var cutNum = 0;

+            for (var i = 0; i < reversed.length; i++) {

+                if (getEncodeType(reversed[i]).extendLen > 0) {

+                    checkMore += 2;

+                } else {

+                    checkMore++;

+                }

+                if (checkMore >= moreLen) {

+                    cutNum = i + 1;

+                    break;

+                }

+            }

+            var iInsertToStartLength = insertPos - cutNum;

+            msgInputDom.value = strValue.substr(0, iInsertToStartLength) + strValue.substr(insertPos);

+            if (msgInputDom.value.length > maxLength) {

+                msgInputDom.value = msgInputDom.value.substr(0, maxLength);

+            }

+            setInsertPos(msgInputDom, iInsertToStartLength);

+            msgInputDom.scrollTop = scrollTop;

+        }

+        var textLength = 0;

+        var newValue = $(msgInputDom).val();

+        var newEncodeType = {

+            encodeType: 'GSM7_default',

+            extendLen: 0

+        };

+        if (newValue != $.i18n.prop('chat_input_placehoder')) {

+            newEncodeType = getEncodeType(newValue);

+        }

+        var newMaxLength = newEncodeType.encodeType == 'UNICODE' ? 335 : 765;

+        var $inputCount = $("#inputcount", "#inputpanel");

+        var $inputItemCount = $("#inputItemCount", "#inputpanel");

+        if (newValue.length + newEncodeType.extendLen >= newMaxLength) {

+            $inputCount.addClass("colorRed");

+            $inputItemCount.addClass("colorRed");

+        } else {

+            $("#inputcount", "#inputpanel").removeClass("colorRed");

+            $("#inputItemCount", "#inputpanel").removeClass("colorRed");

+        }

+        if ("" != newValue && $.i18n.prop('chat_input_placehoder') != newValue) {

+            textLength = newValue.length + newEncodeType.extendLen;

+        }

+        $inputCount.html("(" + textLength + "/" + newMaxLength + ")");

+        $inputItemCount.html("(" + getSmsCount(newValue) + "/5)");

+        draftListener();

+    };

+

+    //文档内容监听,判断是否修改过

+    function draftListener() {

+        var content = $("#chat-input", "#smsChatRoom").val();

+        if (hasCapability) {

+            var selectedContact = getSelectValFromChosen($('.search-choice', '#chosenUserSelect_chosen'));

+            var noContactSelected = !selectedContact || selectedContact.length == 0;

+            var hasContent = typeof content != "undefined" && content != '' && content != $.i18n.prop('chat_input_placehoder');

+

+            if (!hasContent) {

+                config.resetContentModifyValue();

+                return;

+            }

+            if (hasContent && !noContactSelected) {

+                config.CONTENT_MODIFIED.modified = true;

+                config.CONTENT_MODIFIED.message = 'sms_to_save_draft';

+                config.CONTENT_MODIFIED.callback.ok = saveDraftAction;

+                config.CONTENT_MODIFIED.callback.no = $.noop;

+                config.CONTENT_MODIFIED.data = {

+                    content: $("#chat-input", "#smsChatRoom").val(),

+                    numbers: selectedContact

+                };

+                return;

+            }

+            if (hasContent && noContactSelected) {

+                config.CONTENT_MODIFIED.modified = true;

+                config.CONTENT_MODIFIED.message = 'sms_no_recipient';

+                config.CONTENT_MODIFIED.callback.ok = $.noop;

+                config.CONTENT_MODIFIED.callback.no = function () {

+                    // 返回true,页面保持原状

+                    return true;

+                }; //$.noop;

+                return;

+            }

+        } else {

+            config.resetContentModifyValue();

+        }

+    }

+

+    //保存草稿回调动作

+    function saveDraftAction(data) {

+        var datetime = new Date();

+        var params = {

+            index: -1,

+            currentTimeString: getCurrentTimeString(datetime),

+            groupId: data.numbers.length > 1 ? datetime.getTime() : '',

+            message: data.content,

+            numbers: data.numbers

+        };

+        !data.noLoading && showLoading('waiting');

+        service.saveSMS(params, function () {

+            if (data.isFromBack) {

+                getLatestDraftSms(data.numbers);

+                !data.noLoading && successOverlay('sms_save_draft_success');

+                window.location.reload();

+            } else {

+                !data.noLoading && successOverlay('sms_save_draft_success');

+                window.location.reload();

+            }

+        }, function () {

+            !data.noLoading && errorOverlay("sms_save_draft_failed")

+        });

+

+        //获取最新的草稿信息

+        function getLatestDraftSms(numbers) {

+            service.getSMSMessages({

+                page: 0,

+                smsCount: 5,

+                nMessageStoreType: 1,

+                tags: 4,

+                orderBy: "order by id desc"

+            }, function (data) {

+                if (data.messages && data.messages.length > 0) {

+                    var theGroupId = '',

+                    draftShowName = '',

+                    draftShowNameTitle = '',

+                    i = 0,

+                    drafts = [];

+                    for (; i < data.messages.length; i++) {

+                        var msg = data.messages[i];

+                        for (var k = 0; k < numbers.length; k++) {

+                            var num = numbers[k];

+                            if (getLastNumber(num, config.SMS_MATCH_LENGTH) == getLastNumber(msg.number, config.SMS_MATCH_LENGTH)) { //if (num.indexOf(msg.number) == 0) {

+                                msg.number = num;

+                            }

+                        }

+                        if (theGroupId != '' && theGroupId != msg.groupId) {

+                            break;

+                        }

+                        updateDBMsg(msg);

+                        if (msg.groupId == '') { // 单条草稿

+                            break;

+                        } else { // 多条草稿

+                            theGroupId = msg.groupId;

+                            var showName = getShowNameByNumber(msg.number);

+                            draftShowName += (i == 0 ? '' : ';') + showName;

+                            draftShowNameTitle += (i == 0 ? '' : ';') + showName;

+                        }

+                        drafts.push(msg);

+                    }

+                    if (theGroupId == '') { // 单条草稿

+                        var msg = data.messages[0];

+                        msg.hasDraft = true;

+                        updateMsgList(msg);

+                    } else { // 多条草稿

+                        var msg = data.messages[0];

+                        var len = 10;

+                        if (getEncodeType(draftShowName).encodeType == "UNICODE") {

+                            len = 10;

+                        }

+                        msg.draftShowNameTitle = draftShowNameTitle;

+                        msg.draftShowName = draftShowName.length > len ? draftShowName.substring(0, len) + "..." : draftShowName;

+                        msg.hasDraft = true;

+                        msg.totalCount = i;

+                        groupedDraftsObject[theGroupId] = drafts;

+                        updateMsgList(msg);

+                    }

+                    tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), $(".smslist-item", "#smslist-table").length);

+                }

+            }, function () {

+                // do nothing

+            });

+        }

+    }

+

+    //点击群聊草稿进入草稿发送页面 在进入的过程中会先删掉草稿

+    draftSmsItemClickHandler = function (groupId) {

+        if (chatRoomInLoading) {

+            return false;

+        }

+        chatRoomInLoading = true;

+        var msgs = groupedDraftsObject[groupId];

+        var numbers = [];

+        var ids = [];

+        for (var i = 0; msgs && i < msgs.length; i++) {

+            numbers.push(getLastNumber(msgs[i].number, config.SMS_MATCH_LENGTH));

+            ids.push(msgs[i].id + '');

+        }

+        $("#chosenUser", "#smsChatRoom").show();

+        $("#chosenUser1", "#smsChatRoom").addClass("hide").html('');

+        $("select.chosen-select-deselect").val(numbers).trigger("chosen:updated.chosen");

+        $("#chat-input", "#smsChatRoom").val(msgs[0].content);

+        updateChatInputWordLength();

+        clearChatList();

+        switchPage('chat');

+        draftListener();

+        gotoBottom();

+        chatRoomInLoading = false;

+        deleteMultiDraftSms(ids, groupId);

+    };

+

+    //按列表条目删除短消息

+    deletePhoneMessageClickHandler = function (num) {

+        showConfirm("confirm_sms_delete", function () {

+            showLoading('deleting');

+            var ids = [];

+            $.each(config.dbMsgs, function (i, e) {

+                if (e.number == num) {

+                    ids.push(e.id);

+                }

+            });

+            service.deleteMessage({

+                ids: ids

+            }, function (data) {

+                $("#smslist-item-" + getLastNumber(num, config.SMS_MATCH_LENGTH)).hide().remove();

+                synchSmsList([num], ids);

+                successOverlay();

+                tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), $(".smslist-item", "#smslist-table").length);

+            }, function (error) {

+                errorOverlay(error.errorText);

+            });

+        });

+    };

+

+    //同步短信列表数据

+    synchSmsList = function (nums, ids) {

+        if (nums && nums.length > 0) {

+            config.listMsgs = $.grep(config.listMsgs, function (n, i) {

+                return $.inArray(n.number, nums) == -1;

+            });

+        }

+        if (ids && ids.length > 0) {

+            var dbMsgsTmp = [];

+            $.each(config.dbMsgs, function (i, e) {

+                if ($.inArray(e.id, ids) == -1) {

+                    dbMsgsTmp.push(e);

+                }

+            });

+            config.dbMsgs = dbMsgsTmp;

+        }

+    };

+

+    //确定最后一条短消息距离顶部的距离

+    function fixScrollTop() {

+        var items = $(".smslist-item");

+        var lastOne;

+        if (items.length > 0) {

+            lastOne = items[items.length - 1];

+        } else {

+            lastOne = items[0];

+        }

+        lastItemOffsetTop = lastOne ? lastOne.offsetTop : 600;

+    }

+

+    function loadData() {

+        if (ready && !scrolling && lastItemOffsetTop < ($(window).scrollTop() + $(window).height())

+             && $(".smslist-item").length != config.listMsgs.length) {

+            scrolling = true;

+            addTimeout(function () {

+                removeChecked("smslist-checkAll");

+                changeShownMsgs();

+                fixScrollTop();

+                scrolling = false;

+            }, 100);

+        }

+    }

+

+    function stopNavigation() {

+        disableBtn($('#btn-back'));

+        $('a', '#left').bind("click", function () {

+            return false;

+        });

+        $('a', '#list-nav').bind("click", function () {

+            return false;

+        });

+    }

+

+    function restoreNavigation() {

+        enableBtn($('#btn-back'));

+        $('a', '#left').unbind("click");

+        $('a', '#list-nav').unbind("click");

+    }

+

+    function searchTable(key) {

+        key = $.trim(key);

+        var $trs = $('tr', '#smslist-table'),

+        trLength = $trs.length;

+        if (key == '') {

+            $trs.show();

+            return false;

+        }

+        $trs.hide();

+        while (trLength) {

+            var $tr = $($trs[trLength - 1]),

+            $tds = $('td', $tr),

+            tdLength = $tds.length;

+            while (tdLength - 1) {

+                var $td = $($tds[tdLength - 1]);

+                if ($td.text().toLowerCase().indexOf(key.toLowerCase()) != -1) {

+                    $tr.show();

+                    break;

+                }

+                tdLength--;

+            }

+            trLength--;

+        }

+

+        addTimeout(function () {

+            $(":checkbox:checked", "#addPhonebookContainer").removeAttr('checked');

+            vm.selectedItemIds([]);

+            vm.freshStatus($.now());

+            renderCheckbox();

+        }, 300);

+        return true;

+    }

+	updateSearchValue = function (key) {

+        if (key == "" || key == $.i18n.prop("search")) {

+            return true;

+        }

+        searchTable(key);

+    };

+	//清除搜索关键字事件

+    clearSearchKey = function () {

+        updateSearchValue($.i18n.prop("search"));

+        $("#searchInput").addClass("ko-grid-search-txt-default").attr("data-trans", "search");

+    };

+    //点击搜索输入框事件

+    searchTextClick = function () {

+        var searchText = $("#searchInput");

+        if (searchText.hasClass("ko-grid-search-txt-default")) {

+            updateSearchValue("");

+            searchText.val("");

+            searchText.removeClass("ko-grid-search-txt-default").removeAttr("data-trans");

+        }

+    };

+    //离开搜索输入框事件

+    searchTextBlur = function () {

+        var txt = $.trim($("#searchInput").val()).toLowerCase();

+        if (txt == "") {

+            clearSearchKey();

+        }

+    };

+

+    window.smsUtil = {

+        changeLocationHandler: function (ele) {

+            if ($(ele).val() == 'sim') {

+                window.location.hash = '#msg_sim';

+            } else {

+                window.location.hash = '#msg_main';

+            }

+        }

+    };

+

+    return {

+        init: init

+    };

+});

+

+define("sms_set","underscore jquery knockout set service".split(" "),

+    function (_, $, ko, config, service) {

+

+    var validityModes = _.map(config.SMS_VALIDITY, function (item) {

+        return new Option(item.name, item.value);

+    });

+

+    function SmsSetViewMode() {

+        var target = this;

+        var setting = getSmsSetting();

+        target.modes = ko.observableArray(validityModes);

+        target.selectedMode = ko.observable(setting.validity);

+        target.centerNumber = ko.observable(setting.centerNumber);

+        target.deliveryReport = ko.observable(setting.deliveryReport);

+

+        target.clear = function () {

+            init();

+            clearValidateMsg();

+        };

+

+        target.save = function () {

+            showLoading('waiting');

+            var params = {};

+            params.validity = target.selectedMode();

+            params.centerNumber = target.centerNumber();

+            params.deliveryReport = target.deliveryReport();

+            service.setSmsSetting(params, function (result) {

+                if (result.result == "success") {

+                    successOverlay();

+                } else {

+                    errorOverlay();

+                }

+            });

+        };

+    }

+

+    //获取短信设置参数

+

+    function getSmsSetting() {

+        return service.getSmsSetting();

+    }

+

+    function init() {

+        var container = $('#container');

+        ko.cleanNode(container[0]);

+        var vm = new SmsSetViewMode();

+        ko.applyBindings(vm, container[0]);

+        $('#smsSettingForm').validate({

+            submitHandler: function () {

+                vm.save();

+            },

+            rules: {

+                txtCenterNumber: "sms_service_center_check"

+            }

+        });

+    }

+

+    return {

+        init: init

+    };

+});

+

+define("sms_sim_messages","jquery knockout set service".split(" "),

+    function ($, ko, config, service) {

+    var simMsgListTmpl = null;

+    //每页记录条数

+    var perPage = 200;

+

+    //获取短信分页记录

+    function getSMSMessages() {

+        return service.getSMSMessages({

+            page: 0,

+            smsCount: perPage,

+            nMessageStoreType: 0,

+            tags: 10,

+            orderBy: "order by id desc"

+        }, function (data) {

+            tryToDisableCheckAll($("#simMsgList-checkAll"), data.messages.length);

+            dealPhoneBooks(data.messages);

+        }, function (data) {

+            dealPhoneBooks([]);

+        });

+    }

+

+    //短信显示联系人名字,并将结果显示在UI

+    function dealPhoneBooks(messages) {

+        $.each(messages, function (j, n) {

+            n.itemId = getLastNumber(n.number, config.SMS_MATCH_LENGTH);

+            for (var i = 0; i < config.phonebook.length; i++) {

+                var person = config.phonebook[i];

+                if (n.itemId == getLastNumber(person.pbm_number, config.SMS_MATCH_LENGTH)) {

+                    n.name = person.pbm_name;

+                    break;

+                }

+            }

+        });

+        renderSimMessageList(messages);

+    }

+

+    //清楚短信列表内容

+    cleanSimSmsList = function () {

+        $("#simMsgList_container").empty();

+    };

+

+    //将短信显示结果显示在UI

+    function renderSimMessageList(messages) {

+        if (simMsgListTmpl == null) {

+            simMsgListTmpl = $.template("simMsgListTmpl", $("#simMsgListTmpl"));

+        }

+        cleanSimSmsList();

+        $("#simMsgList_container").html($.tmpl("simMsgListTmpl", {

+                data: messages

+            }));

+        hideLoading();

+    }

+

+    //初始化电话本信息

+    function initPhoneBooks(cb) {

+        service.getPhoneBooks({

+            page: 0,

+            data_per_page: 2000,

+            orderBy: "name",

+            isAsc: true

+        }, function (books) {

+            if ($.isArray(books.pbm_data) && books.pbm_data.length > 0) {

+                config.phonebook = books.pbm_data;

+            } else {

+                config.phonebook = [];

+            }

+            cb();

+        }, function () {

+            errorOverlay();

+        });

+    }

+

+    function simSmsViewMode() {

+        var self = this;

+        start();

+    }

+

+    //短信删除事件处理

+    deleteSelectedSimMsgClickHandler = function () {

+        var checkbox = $("input[name=msgId]:checked", "#simMsgList_container");

+        var msgIds = [];

+        for (var i = 0; i < checkbox.length; i++) {

+            msgIds.push($(checkbox[i]).val());

+        }

+        if (msgIds.length == 0) {

+            return false;

+        }

+        showConfirm("confirm_sms_delete", function () {

+            showLoading('deleting');

+            service.deleteMessage({

+                ids: msgIds

+            }, function (data) {

+                removeChecked("simMsgList-checkAll");

+                disableBtn($("#simMsgList-delete"));

+                var idsForDelete = "";

+                checkbox.each(function (i, n) {

+                    idsForDelete += ".simMsgList-item-class-" + $(n).val() + ",";

+                });

+                if (idsForDelete.length > 0) {

+                    $(idsForDelete.substring(0, idsForDelete.length - 1)).hide().remove();

+                }

+                tryToDisableCheckAll($("#simMsgList-checkAll"), $(".smslist-item", "#simMsgList_container").length);

+                successOverlay();

+            }, function (error) {

+                errorOverlay(error.errorText);

+            });

+            //删除短信后需要刷新列表

+            updateSimSmsCapabilityStatus($("#simSmsCapability"));

+        });

+    };

+    //将被checked的条目添加到self.checkedItem中,用于在滚动还原checkbox

+    function checkboxClickHandler() {

+        if (getSelectedItemSize() == 0) {

+            disableBtn($("#simMsgList-delete"));

+        } else {

+            enableBtn($("#simMsgList-delete"));

+        }

+    }

+

+    //获取已选择的条目

+    function getSelectedItemSize() {

+        return $("input:checkbox:checked", '#simMsgList_container').length;

+    }

+

+    //模块开始,检查电话本及短信状态并加装页码数据

+    function start() {

+        showLoading('waiting');

+        var getSMSReady = function () {

+            service.getSMSReady({}, function (data) {

+                if (data.sms_cmd_status_result == "2") {

+                    hideLoading();

+                    showAlert("sms_init_fail");

+                } else if (data.sms_cmd_status_result == "1") {

+                    addTimeout(function () {

+                        getSMSReady();

+                    }, 1000);

+                } else {

+                    if (!config.HAS_PHONEBOOK) {

+                        initSMSList(config.HAS_PHONEBOOK);

+                    } else {

+                        getPhoneBookReady();

+                    }

+                }

+            });

+        };

+

+        var getPhoneBookReady = function () {

+            service.getPhoneBookReady({}, function (data) {

+                if (data.pbm_init_flag == "6") {

+                    initSMSList(false);

+                } else if (data.pbm_init_flag != "0") {

+                    addTimeout(function () {

+                        getPhoneBookReady();

+                    }, 1000);

+                } else {

+                    initSMSList(config.HAS_PHONEBOOK);

+                }

+            });

+        };

+

+        var initSMSList = function (isPbmInitOK) {

+            if (isPbmInitOK) {

+                initPhoneBooks(function () {

+                    getSMSMessages();

+                });

+            } else {

+                config.phonebook = [];

+                getSMSMessages();

+            }

+        };

+        getSMSReady();

+        initSimSmsCapability();

+    }

+

+    //初始化短信容量状态

+    function initSimSmsCapability() {

+        var capabilityContainer = $("#simSmsCapability");

+        updateSimSmsCapabilityStatus(capabilityContainer);

+        addInterval(function () {

+            updateSimSmsCapabilityStatus(capabilityContainer);

+        }, 5000);

+    }

+

+    //更新短信容量状态

+    function updateSimSmsCapabilityStatus(capabilityContainer) {

+        service.getSmsCapability({}, function (capability) {

+            if (capabilityContainer != null) {

+                capabilityContainer.text("(" + capability.simUsed + "/" + capability.simTotal + ")");

+            }

+        });

+    }

+

+    //清除搜索关键字事件

+    clearSearchKey = function () {

+        updateSearchValue($.i18n.prop("search"));

+        $("#searchInput").addClass("ko-grid-search-txt-default").attr("data-trans", "search");

+    };

+    //点击搜索输入框事件

+    searchTextClick = function () {

+        var searchText = $("#searchInput");

+        if (searchText.hasClass("ko-grid-search-txt-default")) {

+            updateSearchValue("");

+            searchText.val("");

+            searchText.removeClass("ko-grid-search-txt-default").removeAttr("data-trans");

+        }

+    };

+    //离开搜索输入框事件

+    searchTextBlur = function () {

+        var txt = $.trim($("#searchInput").val()).toLowerCase();

+        if (txt == "") {

+            clearSearchKey();

+        }

+    };

+

+    updateSearchValue = function (key) {

+        if (key == "" || key == $.i18n.prop("search")) {

+            return true;

+        }

+        searchTable(key);

+    }

+

+    function searchTable(key) {

+        key = $.trim(key);

+        var $trs = $('tr', '#smslist-table'),

+        trLength = $trs.length;

+        if (key == '') {

+            $trs.show();

+            return false;

+        }

+        $trs.hide();

+        while (trLength) {

+            var $tr = $($trs[trLength - 1]),

+            $tds = $('td', $tr),

+            tdLength = $tds.length;

+            while (tdLength - 1) {

+                var $td = $($tds[tdLength - 1]);

+                if ($td.text().toLowerCase().indexOf(key.toLowerCase()) != -1) {

+                    $tr.show();

+                    break;

+                }

+                tdLength--;

+            }

+            trLength--;

+        }

+

+        addTimeout(function () {

+            $(":checkbox:checked", "#addPhonebookContainer").removeAttr('checked');

+            vm.selectedItemIds([]);

+            vm.freshStatus($.now());

+            renderCheckbox();

+        }, 300);

+        return true;

+    }

+

+    //点击短信列表条目

+    simsmsItemClickHandler = function (tag, id, num) {

+        if (tag == "1") {

+            var ids = [];

+            ids.push(id);

+            service.setSmsRead({

+                ids: ids

+            }, function (data) {

+                if (data.result) {

+                    $(".simMsgList-item-class-" + id, "#simMsgTableContainer").removeClass('font-weight-bold');

+                }

+            });

+        }

+    }

+

+    //页面事件绑定

+    function initEventBind() {

+        $(".smslist-item-msg", "#simMsgTableContainer").die().live("click", function () {

+            var $this = $(this).addClass('showFullHeight');

+            $('.smslist-item-msg.showFullHeight', '#simMsgTableContainer').not($this).removeClass('showFullHeight');

+        });

+        $("#simMsgList_container p.checkbox, #simMsgListForm #simMsgList-checkAll").die().live("click", function () {

+            checkboxClickHandler();

+        });

+        $("#searchInput").die().live('blur', function () {

+            searchTextBlur();

+        }).live('keyup', function () {

+            updateSearchValue($("#searchInput").val());

+        });

+    }

+

+    //模块初始化开始

+    function init() {

+        var container = $('#container');

+        ko.cleanNode(container[0]);

+        var vm = new simSmsViewMode();

+        ko.applyBindings(vm, container[0]);

+        initEventBind();

+    }

+

+    window.smsUtil = {

+        changeLocationHandler: function (ele) {

+            if ($(ele).val() == 'sim') {

+                window.location.hash = '#msg_sim';

+            } else {

+                window.location.hash = '#msg_main';

+            }

+        }

+    };

+

+    return {

+        init: init

+    };

+});

diff --git a/lynq/S300/ap/app/zte_webui/js/wifi.js b/lynq/S300/ap/app/zte_webui/js/wifi.js
new file mode 100755
index 0000000..eceb2a9
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/js/wifi.js
@@ -0,0 +1,3757 @@
+define("wifi_advance","underscore jquery knockout set service jqui".split(" "),

+    function (_, $, ko, config, service, jqui) {

+    var $sliderRange = null;

+    //当前是否WiFi连接

+    var viaWifi = false;

+

+    function paintRateOption(data) {

+        var opts = [];

+        for (var i = 0; i < data.length; i++) {

+            var rate = data[i].rate == 0 ? "Auto" : data[i].rate + " Mbps";

+            opts.push(new Option(rate, data[i].index));

+        }

+        return opts;

+    }

+

+    //wifi传输速率

+    var transpeed = [0, 1, 2, 5.5, 6, 6.5, 9, 11, 12, 13, 18, 19.5, 24, 26, 36, 39, 48, 52, 54, 58.5, 65];

+

+    function rateSort(a, b) {

+        return a.rate - b.rate;

+    }

+    //删除重复速率值

+    function unionRate(rateTable) {

+        var rates = [],

+        result = [];

+        for (var i = 0; i < rateTable.length; i++) {

+            for (var j = 0; j < rateTable[i].length; j++) {

+                if (ko.utils.arrayIndexOf(rates, rateTable[i][j]) == -1) {

+                    rates.push(rateTable[i][j]);

+                    result.push({

+                        index: rateTable[i][j],

+                        rate: transpeed[rateTable[i][j]]

+                    });

+                }

+            }

+        }

+        result.sort(rateSort);

+        return result;

+    }

+

+    //根据模式生成速率选项

+    function modeRateOption(wifimode) {

+        var wifimodeN = [0, 5, 9, 11, 13, 15, 17, 19, 20];

+        var wifimodeG = [0, 4, 6, 8, 10, 12, 14, 16, 18];

+        var wifimodeB = [0, 1, 2, 3, 7];

+        var rate = [];

+

+        switch (wifimode) {

+            //--wifimode

+        case '5':

+            rate.push(wifimodeN);

+            rate.push(wifimodeG);

+            rate.push(wifimodeB);

+            break;

+        case '4':

+            rate.push(wifimodeN);

+            rate.push(wifimodeG);

+            rate.push(wifimodeB);

+            break;

+        case '3':

+            rate.push(wifimodeG);

+            rate.push(wifimodeB);

+            break;

+        case '2':

+            rate.push(wifimodeN);

+            break;

+        case '1':

+            rate.push(wifimodeG);

+            break;

+        case '0':

+            rate.push(wifimodeB);

+            break;

+

+        default:

+            rate.push(wifimodeN);

+            break;

+        }

+        var union = unionRate(rate);

+        return paintRateOption(union);

+    }

+

+    function getCountryCode(country) {

+        var countryCodeArr = config.countryCode;

+        var type = '';

+        for (key in countryCodeArr) {

+            var codes = countryCodeArr[key];

+            if ($.inArray(country, codes) != -1) {

+                type = key;

+                break;

+            }

+        }

+        var typeCode = config.countryCodeType[type];

+        return typeCode ? typeCode : "0";

+    }

+

+    function channelOption(country) {

+        var showOption = [new Option('Auto', '0')];

+        var type = getCountryCode(country) + '';

+        switch (type) {

+            //--type

+        case '9':

+            generateChannelOption(showOption, 2307, 13);

+            break;

+        case '7':

+            generateChannelOption(showOption, 2307, 13);

+            generateChannelOption(showOption, 2407, 11);

+            generateChannelOption(showOption, 2462, 2);

+            break;

+        case '3':

+            generateChannelOption(showOption, 2407, 11);

+            generateChannelOption(showOption, 2462, 2);

+            break;

+            //--type

+        case '2':

+            generateChannelOption(showOption, 2307, 13);

+            generateChannelOption(showOption, 2407, 11);

+            break;

+        case '1':

+            generateChannelOption(showOption, 2407, 11);

+            break;

+        default:

+            generateChannelOption(showOption, 2407, 11);

+        }

+        return showOption;

+    }

+    function generateChannelOption(showOption, start, count) {

+        for (var i = 1; i <= count; i++) {

+            var txt = start + i * 5 + "MHz (Channel " + showOption.length + ")";

+            showOption.push(new Option(txt, showOption.length + "_" + (start + i * 5)));

+        }

+    }

+

+    function channelOption5g(country) {

+        for (key in config.countryCode_5g) {

+            var item = config.countryCode_5g[key];

+            if ($.inArray(country, item.codes) != -1) {

+                return generate5gChannelOption(item.channels);

+            }

+        }

+        return [new Option('Auto', '0')];

+    }

+    function generate5gChannelOption(channels) {

+        var showOption = [new Option('Auto', '0')];

+        for (var i = 0; i < channels.length; i++) {

+            var channel = channels[i];

+            var mhz = channel * 5 + 5000;

+            var txt = mhz + "MHz (Channel " + channel + ")";

+            showOption.push(new Option(txt, channel + "_" + (mhz)));

+        }

+        return showOption;

+    }

+

+    function getBandOptions() {

+        var showOption = [];

+        if (!config.WIFI_HAS_5G) {

+            showOption.push(new Option('2.4GHz', 'b'));

+        } else {

+            showOption.push(new Option('5GHz', 'a'));

+            showOption.push(new Option('2.4GHz', 'b'));

+        }

+        return showOption;

+    }

+

+    function getChannelBandwidthsOptions(isSupport40) {

+        var showOption = [];

+        if (isSupport40) {

+            showOption.push(new Option('20MHz', '0'));

+            showOption.push(new Option('20MHz/40MHz', '1'));

+        } else {

+            showOption.push(new Option('20MHz', '0'));

+        }

+        return showOption;

+    }

+

+    function countryCodeOption(is5G) {

+        var countries = is5G ? config.countries_5g : config.countries;

+        var showOption = [];

+        for (key in countries) {

+            showOption.push(new Option(countries[key], key));

+        }

+        showOption = _.sortBy(showOption, function (opt) {

+            return opt.text;

+        });

+        return showOption;

+    }

+

+    function getWifiAdvance() {

+        return service.getWifiAdvance();

+    }

+

+    function getWpsState() {

+        return service.getWpsInfo();

+    }

+

+    function getModeOption(wifiBand) {

+        var modes = wifiBand == 'a' ? config.NETWORK_MODES_BAND : config.NETWORK_MODES;

+        if (wifiBand == 'a') {

+            $("#mode").hide();

+            $("#modeFor5HZ").show();

+            $("#modeLabel").attr('for', 'modeFor5HZ');

+        } else if (modes.length == 1) {

+            $("#mode").hide();

+            $("#modeFor5HZ").hide();

+        } else {

+            $("#mode").show();

+            $("#modeFor5HZ").hide();

+        }

+        var modeOptions = [];

+        for (var i = 0; i < modes.length; i++) {

+            modeOptions.push(new Option(modes[i].name, modes[i].value));

+        }

+        return modeOptions;

+    }

+

+    function getSelectedRateV(rate, rates) {

+        for (var i = 0; i < rates.length; i++) {

+            var opt = rates[i];

+            if (opt.text == rate + " Mbps") {

+                return opt.value;

+            }

+        }

+        return '0';

+    }

+    //获取所选的信道对应的value值

+    function getSelectedChannelV(channel, channels) {

+        for (var i = 0; i < channels.length; i++) {

+            var opt = $(channels[i]);

+            if (opt.val().split("_")[0] == channel) {

+                return opt.val();

+            }

+        }

+        return '0';

+    }

+

+    function WifiAdvanceViewModel() {

+        // Data

+        var target = this;

+

+        var wifiInfo = service.getWifiAdvance();

+        target.origin_ap_station_enable = wifiInfo.ap_station_enable;

+        target.modes = ko.observableArray(getModeOption(wifiInfo.wifiBand));

+        target.bands = ko.observableArray(getBandOptions());

+

+        var countryOpts = countryCodeOption(wifiInfo.wifiBand == 'a');

+        target.countries = ko.observableArray(countryOpts);

+        target.channels = ko.observableArray(wifiInfo.wifiBand == 'a' ? channelOption5g(wifiInfo.countryCode) : channelOption(wifiInfo.countryCode));

+        target.rates = ko.observableArray(modeRateOption(wifiInfo.mode));

+

+        target.hasAPStation = config.AP_STATION_SUPPORT;

+        target.hasWifiSwitch = config.WIFI_SWITCH_SUPPORT;

+        target.hasMultiSSID = config.HAS_MULTI_SSID;

+        target.hasWlanMacfilter = config.HAS_BLACK_AND_WHITE_FILTER;

+        target.hasWifiBand = ko.observable(config.WIFI_BAND_SUPPORT);

+        target.hasBandwidth = ko.observable(config.WIFI_BANDWIDTH_SUPPORT);

+

+        target.selectedMode = ko.observable(wifiInfo.mode);

+        target.selectedChannel = ko.observable(getSelectedChannelV(wifiInfo.channel, target.channels()));

+        target.selectedChannelBandwidth = ko.observable(wifiInfo.bandwidth); //5:a, 2.5:b

+        target.selectedCountry = ko.observable(wifiInfo.countryCode.toUpperCase());

+        target.selectedBand = ko.observable(wifiInfo.wifiBand); //5:a, 2.5:b

+        target.selectedRate = ko.observable(getSelectedRateV(wifiInfo.rate, target.rates()));

+

+        var baseInfo = service.getWifiBasic();

+        target.wifi_enable = ko.observable(baseInfo.wifi_enable);

+        if (config.HAS_MULTI_SSID && ((baseInfo.m_AuthMode == "OPEN" && baseInfo.m_encryptType == "WEP") || (baseInfo.m_AuthMode == "SHARED" && baseInfo.m_encryptType == "WEP") || baseInfo.m_encryptType == "TKIP")) {

+            target.isF = ko.observable(true);

+        } else if ((baseInfo.AuthMode == "OPEN" && baseInfo.encryptType == "WEP") || (baseInfo.AuthMode == "SHARED" && baseInfo.encryptType == "WEP") || baseInfo.encryptType == "TKIP") {

+            target.isF = ko.observable(true);

+        } else {

+            target.isF = ko.observable(false);

+        }

+        target.isShowSSIDInfoDiv = ko.observable(false);

+        if (config.WIFI_SWITCH_SUPPORT) {

+            if (baseInfo.wifi_enable == "1") {

+                target.isShowSSIDInfoDiv(true);

+            } else {

+                target.isShowSSIDInfoDiv(false);

+            }

+        } else {

+            target.isShowSSIDInfoDiv(true);

+        }

+        target.multi_ssid_enable = ko.observable(baseInfo.multi_ssid_enable);

+        target.origin_multi_ssid_enable = baseInfo.multi_ssid_enable;

+        target.maxStationNumber = ko.observable(wifiInfo.MAX_Station_num);

+        target.selectedStation = ko.observable(wifiInfo.MAX_Access_num);

+        target.selectedStationM = ko.observable(wifiInfo.m_MAX_Access_num);

+

+        target.oneBandTrans = ko.observable(wifiInfo.wifiBand == 'a' ? '5G' : '2.4G');

+        target.oneModeTrans = ko.observable((wifiInfo.wifiBand == 'a' ? 'network_modes_band_select_' : 'network_mode_select_') + wifiInfo.mode);

+

+        target.channelBandwidths = ko.computed(function () {

+            if (config.WIFI_BANDWIDTH_SUPPORT_40MHZ) {

+                return getChannelBandwidthsOptions(true);

+            } else {

+                return getChannelBandwidthsOptions(false);

+            }

+        });

+

+        wifiInfo = $.extend(wifiInfo, target);

+

+        //Event Handler 频段切换时更新对应的国家/地区码、信道和网络模式选项

+        target.bandChangeHandler = function () {

+            if (target.selectedBand() == 'a') { //5g

+                //802.11a only   802.11n only   802.11a/n

+                target.modes(getModeOption(target.selectedBand()));

+                target.countries(countryCodeOption(true));

+            } else { // 2.4g

+                //802.11 n only   802.11 b/g/n

+                target.modes(getModeOption(target.selectedBand()));

+                target.countries(countryCodeOption(false));

+            }

+            target.selectedCountry('0');

+            target.channels(target.generateChannelOption());

+            target.selectedChannel('0');

+        };

+

+        target.countryChangeHandler = function (data, event) {

+            var opts = target.generateChannelOption();

+            target.channels(opts);

+            target.selectedChannel('0');

+        };

+

+        target.modeChangeHandler = function (data, event) {

+            var opts = modeRateOption(target.selectedMode());

+            target.rates(opts);

+            target.selectedRate('0');

+        };

+

+        target.generateChannelOption = function () {

+            if (target.selectedBand() == 'a') {

+                return channelOption5g(target.selectedCountry());

+            } else {

+                return channelOption(target.selectedCountry());

+            }

+        };

+

+        target.save = function () {

+            var status = getWpsState();

+            if (status.wpsFlag == '1') {

+                showAlert('wps_on_info', function() {

+                    window.location.reload();

+                });

+                return;

+            }

+            var selectedRateTxt = $("#rate option:selected").text();

+            var rateVal = null;

+            if (selectedRateTxt != $.i18n.prop('rate_0')) {

+                rateVal = $.trim(selectedRateTxt.replace('Mbps', ''));

+            } else {

+                rateVal = 0;

+            }

+            var wifiParam = {};

+            wifiParam.countryCode = target.selectedCountry();

+            wifiParam.mode = target.selectedMode();

+            var selectedChannel = target.selectedChannel();

+            wifiParam.channel = selectedChannel == '0' ? '0' : selectedChannel.split("_")[0];

+            wifiParam.rate = rateVal;

+            wifiParam.wifiBand = target.selectedBand();

+            if (config.WIFI_BANDWIDTH_SUPPORT) {

+                wifiParam.bandwidth = target.selectedChannelBandwidth();

+            }

+            wifiParam.station = target.selectedStation();

+            wifiParam.m_station = target.selectedStationM();

+            showConfirm('wifi_disconnect_confirm', function () {

+                showLoading('waiting');

+                service.setWifiAdvance(wifiParam, function (result) {

+                    if (result.result == "success") {

+                        if (viaWifi) {

+                            setTimeout(advanceReloadVarWifi, 15000);

+                        } else {

+                            addInterval(advanceReload, 1000);

+                        }

+                    } else {

+                        errorOverlay();

+                    }

+                });

+            });

+        };

+

+        target.checkSettings = function (ssid) {

+            var status = getWpsState();

+            if (status.wpsFlag == '1') {

+                showAlert('wps_on_info', function() {

+                    window.location.reload();

+                });

+                return true;

+            }

+            if (config.HAS_MULTI_SSID && baseInfo.multi_ssid_enable == "1") {

+                if ((ssid == "ssid1" && parseInt(target.selectedStation()) + parseInt(baseInfo.m_MAX_Access_num) > baseInfo.MAX_Station_num)

+                     || (ssid == "ssid2" && parseInt(target.m_selectedStation()) + parseInt(baseInfo.MAX_Access_num) > baseInfo.MAX_Station_num)) {

+                    showAlert({

+                        msg: 'multi_ssid_max_access_number_alert',

+                        wifiParam: baseInfo.MAX_Station_num

+                    });

+                    return true;

+                }

+            }

+

+            return false;

+        };

+

+        target.setMultiSSIDSwitch = function () {

+            if (target.checkSettings("switch")) {

+                return;

+            }

+

+            var setSwitch = function () {

+                showLoading('waiting');

+                var wifiParam = {};

+                wifiParam.m_ssid_enable = target.multi_ssid_enable();

+                if (config.WIFI_SWITCH_SUPPORT) {

+                    wifiParam.wifiEnabled = target.wifi_enable();

+                }

+                service.setWifiBasicMultiSSIDSwitch(wifiParam, function (result) {

+                    if (result.result == "success") {

+                        if (viaWifi) {

+                            setTimeout(hasApReloadVarWifi, 15000);

+                        } else {

+                            addInterval(hasApReload, 1000);

+                        }

+                    } else {

+                        errorOverlay();

+                    }

+                });

+            };

+

+            var baseInfo = service.getStatusInfo();

+            if (config.HAS_MULTI_SSID && target.wifi_enable() == "1") {

+                if (target.multi_ssid_enable() == "1" && config.AP_STATION_SUPPORT && target.origin_ap_station_enable == "1") {

+                    if (!baseInfo.wifiStatus) {

+                        showConfirm("multi_ssid_enable_confirm", function () {

+                            setSwitch();

+                        });

+                    } else {

+                        showConfirm("multi_ssid_enable_confirm2", function () {

+                            setSwitch();

+                        });

+                    }

+                } else {

+                    if (!baseInfo.wifiStatus) {

+                        setSwitch();

+                    } else {

+                        showConfirm("wifi_disconnect_confirm2", function () {

+                            setSwitch();

+                        });

+                    }

+                }

+            } else {

+                setSwitch();

+            }

+

+            function hasApReloadVarWifi() {

+                successOverlay();

+                setTimeout(function () {

+                    window.location.reload();

+                }, 1000);

+                clearTimer();

+                clearValidateMsg();

+                service.refreshAPStationStatus();

+                initialize();

+            }

+            function hasApReload() {

+                var baseInfo = service.getWifiBasic();

+                if (baseInfo.wifi_enable == target.wifi_enable()) {

+                    successOverlay();

+                    clearTimer();

+                    clearValidateMsg();

+                    service.refreshAPStationStatus();

+                    initialize();

+                }

+            }

+

+        };

+

+    }

+

+    function checkAccessMode() {

+        service.getParams({

+            nv: 'user_ip_addr'

+        }, function (dataIp) {

+            service.getParams({

+                nv: 'station_list'

+            }, function (dataList) {

+                viaWifi = isWifiConnected(dataIp.user_ip_addr, dataList.station_list);

+            });

+        });

+    }

+

+    function advanceReloadVarWifi() {

+        successOverlay();

+        setTimeout(function () {

+            window.location.reload();

+        }, 1000);

+    }

+

+    function advanceReload() {

+        var baseInfo = service.getWifiBasic();

+        if (baseInfo.wifi_enable == "1") {

+            successOverlay();

+            clearTimer();

+            clearValidateMsg();

+            initialize();

+        }

+    }

+

+    function initialize() {

+        var container = $('#container');

+        ko.cleanNode(container[0]);

+        var vm = new WifiAdvanceViewModel();

+        ko.applyBindings(vm, container[0]);

+        addTimeout(function () {

+            checkAccessMode();

+        }, 600);

+

+        if (config.WDS_SUPPORT) {

+            checkWifiStatusUseWDS();

+        } else if (config.AP_STATION_SUPPORT) {

+            checkWifiStatus();

+        }

+

+        $('#wifi_advance_form').validate({

+            submitHandler: function () {

+                vm.save();

+            }

+        });

+

+        $('#frmWifiSwitch').validate({

+            submitHandler: function () {

+                vm.setMultiSSIDSwitch();

+            }

+        });

+    }

+

+    function checkWifiStatusUseWDS() {

+        var baseInfo = service.getWdsInfo();

+        if (baseInfo.currentMode == "0") {

+            $(':input', '#frmWifiSwitch,#wifi_advance_form').each(function () {

+                $(this).prop("disabled", false);

+            });

+        } else {

+            $(':input', '#frmWifiSwitch,#wifi_advance_form').each(function () {

+                $(this).prop("disabled", true);

+            });

+        }

+    }

+

+    function checkWifiStatus() {

+        var baseInfo = service.getAPStationBasic();

+        if (baseInfo.ap_station_enable != "1") {

+            $(':input', '#wifi_advance_form').each(function () {

+                $(this).prop("disabled", false);

+            });

+        } else {

+            $(':input', '#wifi_advance_form').each(function () {

+                $(this).prop("disabled", true);

+            });

+        }

+    }

+

+    return {

+        init: initialize

+    };

+});

+

+define("wifi_ap_station","underscore jquery knockout set service".split(" "),

+    function (_, $, ko, config, service) {

+    var viaWifi = false;

+    function checkAccessMode() {

+        service.getParams({

+            nv: 'user_ip_addr'

+        }, function (dataIp) {

+            service.getParams({

+                nv: 'station_list'

+            }, function (dataList) {

+                viaWifi = isWifiConnected(dataIp.user_ip_addr, dataList.station_list);

+            });

+        });

+    }

+

+    function apStationViewMode() {

+        var target = this;

+        var ssid_ex = "";

+        target.hasMultiSSID = config.HAS_MULTI_SSID;

+        target.hasAPStation = config.AP_STATION_SUPPORT;

+        target.hasWifiSwitch = config.WIFI_SWITCH_SUPPORT;

+        target.hasWlanMacfilter = config.HAS_BLACK_AND_WHITE_FILTER;

+

+        var securityModes = _.map(config.AUTH_MODES_ALL, function (item) {

+            return new Option(item.name, item.value);

+        });

+        //当前页面标识  list列表页 add添加页面  edit编辑页面

+        target.page = {

+            list: 1,

+            add: 2,

+            edit: 3

+        };

+        //WiFi热点列表列的配置项

+        var gridColumn = [{

+                columnType: "radio",

+                headerTextTrans: "option",

+                rowText: "profileName",

+                width: "10%"

+            }, {

+                headerTextTrans: "ssid_title",

+                rowText: "ssid",

+                width: "30%"

+            }, {

+                columnType: "image",

+                headerTextTrans: "signal",

+                rowText: "imgSignal",

+                width: "30%"

+            }, {

+                headerTextTrans: "security_mode",

+                rowText: "authMode_show",

+                width: "30%"

+            }

+        ];

+        //搜索到的WiFi热点列表列的配置项

+        var searchGridColumn = [{

+                columnType: "radio",

+                rowText: "index",

+                width: "10%"

+            }, {

+                headerTextTrans: "ssid_title",

+                rowText: "ssid",

+                width: "30%"

+            }, {

+                columnType: "image",

+                headerTextTrans: "signal",

+                rowText: "imgSignal",

+                width: "30%"

+            }, {

+                headerTextTrans: "security_mode",

+                rowText: "authMode_show",

+                width: "30%"

+            }

+        ];

+

+        target.pageState = ko.observable(target.page.list);

+

+        var info = service.getAPStationBasic();

+

+        target.origin_ap_station_enable = info.ap_station_enable;

+        target.ap_station_enable = ko.observable(info.ap_station_enable);

+        target.apList = ko.observable([]);

+        if (target.origin_ap_station_enable == "1") {

+            var apList = service.getHotspotList();

+            target.apList(fixHotspotList(apList.hotspotList));

+        }

+

+        target.apSearchList = ko.observable([]);

+

+        target.connectButtonStatus = ko.observable("disable");

+        target.hasSelectFromUser = ko.observable();

+        target.showPassword = ko.observable(false);

+

+        target.isCableMode = ko.observable();

+

+        var infoBasic = service.getWifiBasic();

+        target.wifi_enable = ko.observable(infoBasic.wifi_enable);

+

+        target.isShowSSIDInfoDiv = ko.observable(false);

+        if (config.WIFI_SWITCH_SUPPORT) {

+            if (infoBasic.wifi_enable == "1") {

+                target.isShowSSIDInfoDiv(true);

+            } else {

+                target.isShowSSIDInfoDiv(false);

+            }

+        } else {

+            target.isShowSSIDInfoDiv(true);

+        }

+        target.multi_ssid_enable = ko.observable(infoBasic.multi_ssid_enable);

+

+        //密码显示事件

+        target.showPasswordHandler = function () {

+            $("#codeWPAKey").parent().find(".error").hide();

+            $("#pwdWepKey").parent().find(".error").hide();

+            var checkbox = $("#showPassword:checked");

+            if (checkbox && checkbox.length == 0) {

+                target.showPassword(true);

+            } else {

+                target.showPassword(false);

+            }

+        };

+

+        target.showWPAPasswordHandler = function () {

+            $("#codeWPAKey").parent().find(".error").hide();

+            $("#pwdWepKey").parent().find(".error").hide();

+            if ($("#showWPAPassword").is(":checked")) {

+                target.showPassword(true);

+            } else {

+                target.showPassword(false);

+            }

+        };

+

+        //列表模板创建

+        target.apGrid = new ko.simpleGrid.viewModel({

+            idName: "profileName",

+            data: target.apList(),

+            tmplType: 'list',

+            pageSize: 100,

+            columns: gridColumn,

+            primaryColumn: "fromProvider",

+            radioClickHandler: function () {

+                computeButtonState();

+            }

+        });

+        //热点搜索结果列表模板创建

+        target.apSearchGrid = new ko.simpleGrid.viewModel({

+            data: target.apSearchList(),

+            idName: "index",

+            tmplType: 'list',

+            pageSize: 100,

+            columns: searchGridColumn,

+            radioClickHandler: function () {

+                var index = target.apSearchGrid.radioSelectValue();

+                var aplist = target.apSearchList();

+                for (var i = 0; i < aplist.length; i++) {

+                    var list_item = aplist[i];

+                    if (list_item.index == index) {

+                        target.profileName("");

+                        target.ssid(list_item.ssid);

+                        ssid_ex = list_item.ssid;

+                        target.signal(list_item.signal);

+                        target.authMode(list_item.authMode);

+                        target.password(list_item.password);

+                        target.mac(list_item.mac);

+                        if (list_item.authMode == "WPAPSKWPA2PSK" || list_item.authMode == "WPA2PSK" || list_item.authMode == "WPAPSK" || list_item.authMode == "WPA3Personal" || list_item.authMode == "WPA2WPA3") {

+                            target.encryptType_WPA(list_item.encryptType);

+                        } else {

+                            target.encryptType(list_item.encryptType);

+                        }

+                        target.keyID(list_item.keyID);

+                        renderCustomElement($("#cipherGroup"));

+                        break;

+                    }

+                }

+            }

+        });

+

+        //计算并设置当前连接和按钮的状态

+        target.computeConnectStatus = function () {

+            computeButtonState();

+

+            var networkStatus = target.connectStatus();

+            if (networkStatus == "ppp_connected") {

+                target.current_status_trans("ap_station_wan_connected");

+                target.current_status_text($.i18n.prop("ap_station_wan_connected"));

+                return;

+            }

+

+            var ssid = target.connectWifiSSID();

+            var wifiStatus = target.connectWifiStatus();

+            if (ssid && wifiStatus == "connect") {

+                target.current_status_trans("ap_station_wlan_connected");

+                target.current_status_text($.i18n.prop("ap_station_wlan_connected"));

+                return;

+            }

+

+            target.current_status_trans("ap_station_no_connection");

+            target.current_status_text($.i18n.prop("ap_station_no_connection"));

+        };

+        //计算并设置按钮的状态

+        function computeButtonState() {

+            var profileName = target.apGrid.radioSelectValue();

+            if (!profileName) {

+                target.hasSelectFromUser(false);

+                target.connectButtonStatus("disable");

+                return;

+            }

+

+            var status = "";

+            var fromProvider = "";

+            for (var i = 0; i < target.apList().length; i++) {

+                var list_item = target.apList()[i];

+                if (list_item.profileName == profileName) {

+                    status = list_item.connectStatus;

+                    fromProvider = list_item.fromProvider;

+                    break;

+                }

+            }

+

+            if (status == "1") {

+                target.connectButtonStatus("hide");

+                target.hasSelectFromUser(false);

+            } else {

+                target.connectButtonStatus("show");

+                target.hasSelectFromUser(fromProvider == "0");

+            }

+        }

+        var statusInfo = service.getStatusInfo();

+        target.networkType = ko.observable(statusInfo.networkType);

+        target.networkOperator = ko.observable(statusInfo.networkOperator);

+        target.connectStatus = ko.observable(statusInfo.connectStatus);

+        target.connectWifiStatus = ko.observable(statusInfo.connectWifiStatus);

+        target.connectWifiProfile = ko.observable(statusInfo.connectWifiProfile);

+        target.connectWifiSSID = ko.observable(statusInfo.connectWifiSSID);

+

+        target.current_status_trans = ko.observable("");

+        target.current_status_text = ko.observable("");

+        target.current_status = ko.computed(function () {

+            target.computeConnectStatus()

+        });

+

+        target.modes = securityModes;

+        target.profileName = ko.observable("");

+        target.ssid = ko.observable();

+        target.signal = ko.observable("0");

+        target.authMode = ko.observable();

+        target.password = ko.observable();

+        target.encryptType = ko.observable();

+        target.encryptType_WPA = ko.observable("TKIPCCMP");

+        target.keyID = ko.observable("0");

+        target.mac = ko.observable();

+

+        target.openAddPage = function () {

+            if (wifiIsClosed()) {

+                return;

+            }

+            if (wpsIsOn()) {

+                return;

+            }

+            target.clear();

+            getSearchHotspot();

+        };

+

+        //打开基本设置页面

+        target.openListPage = function () {

+            if (wifiIsClosed()) {

+                return;

+            }

+            if (wpsIsOn()) {

+                return;

+            }

+            target.clear();

+            target.pageState(target.page.list);

+            target.apGrid.data(target.apList());

+            v.computeConnectStatus();

+        };

+

+        target.addHotspot = function () {

+            if (wifiIsClosed()) {

+                return;

+            }

+            if (wpsIsOn()) {

+                return;

+            }

+            if (target.pageState() == target.page.add && target.apList().length >= config.AP_STATION_LIST_LENGTH) {

+                showAlert({

+                    msg: "ap_station_exceed_list_max",

+                    params: config.AP_STATION_LIST_LENGTH

+                });

+                return;

+            }

+            showLoading('waiting');

+            var wifi_para = {};

+            var profileName = target.apGrid.radioSelectValue();

+            wifi_para.profileName = target.profileName();

+            wifi_para.ssid = target.ssid();

+            wifi_para.signal = target.signal();

+            wifi_para.authMode = target.authMode();

+            wifi_para.password = target.password();

+            if (wifi_para.authMode == "SHARED") {

+                wifi_para.encryptType = "WEP";

+            } else if (wifi_para.authMode == "WPAPSKWPA2PSK" || wifi_para.authMode == "WPA2PSK" || wifi_para.authMode == "WPAPSK" || wifi_para.authMode == "WPA3Personal" || wifi_para.authMode == "WPA2WPA3") {

+                wifi_para.encryptType = target.encryptType_WPA();

+            } else {

+                wifi_para.encryptType = target.encryptType();

+            }

+            wifi_para.keyID = target.keyID();

+            wifi_para.mac = (target.mac() == "" || target.ssid() != ssid_ex) ? "0F:00:00:00:00:00" : target.mac();

+            wifi_para.apList = target.apList();

+            service.saveHotspot(wifi_para, function (data) {

+                target.callback(data, true);

+            });

+        };

+

+        target.deleteHotspot = function () {

+            if (wifiIsClosed()) {

+                return;

+            }

+            if (wpsIsOn()) {

+                return;

+            }

+            showConfirm("confirm_data_delete", function () {

+                var wifi_para = {};

+                wifi_para.profileName = target.apGrid.radioSelectValue();

+                wifi_para.apList = target.apList();

+                showLoading('waiting');

+                service.deleteHotspot(wifi_para, function (data) {

+                    target.callback(data, true);

+                });

+            });

+        };

+

+        target.openEditPage = function () {

+            if (wifiIsClosed()) {

+                return;

+            }

+            if (wpsIsOn()) {

+                return;

+            }

+            var profileName = target.apGrid.radioSelectValue();

+            var aplist = target.apList();

+            for (var i = 0; i < aplist.length; i++) {

+                var list_item = aplist[i];

+                if (list_item.profileName == profileName) {

+                    target.profileName(profileName);

+                    target.ssid(list_item.ssid);

+                    target.signal(list_item.signal);

+                    target.authMode(list_item.authMode);

+                    target.password(list_item.password);

+                    target.mac(list_item.mac);

+                    if (list_item.authMode == "WPAPSKWPA2PSK" || list_item.authMode == "WPA2PSK" || list_item.authMode == "WPAPSK" || list_item.authMode == "WPA3Personal" || list_item.authMode == "WPA2WPA3") {

+                        target.encryptType_WPA(list_item.encryptType);

+                    } else {

+                        target.encryptType(list_item.encryptType);

+                    }

+                    target.keyID(list_item.keyID);

+                }

+            }

+            target.pageState(target.page.edit);

+        };

+

+        target.connectHotspot = function () {

+            if (wifiIsClosed()) {

+                return;

+            }

+            if (wpsIsOn()) {

+                return;

+            }

+            var profileName = target.apGrid.radioSelectValue();

+            var apList = target.apList();

+

+            function connect() {

+                showLoading("connecting");

+                var wifi_para = {};

+                var connectIndex = -1;

+                var ssid = "";

+                for (var i = 0; i < apList.length; i++) {

+                    if (apList[i].profileName == profileName) {

+

+                        wifi_para.EX_SSID1 = apList[i].ssid;

+                        wifi_para.EX_AuthMode = apList[i].authMode;

+                        wifi_para.EX_EncrypType = apList[i].encryptType;

+                        wifi_para.EX_DefaultKeyID = apList[i].keyID;

+                        wifi_para.EX_WEPKEY = apList[i].password;

+                        wifi_para.EX_WPAPSK1 = apList[i].password;

+                        wifi_para.EX_wifi_profile = apList[i].profileName;

+                        wifi_para.EX_mac = apList[i].mac;

+                        connectIndex = i;

+                        ssid = apList[i].ssid;

+                        break;

+                    }

+                }

+

+                target.connectWifiSSID(ssid);

+                target.connectWifiStatus("connecting");

+                target.apGrid.setRadioSelect(profileName);

+                target.connectButtonStatus("disable");

+

+                service.connectHotspot(wifi_para, function (data) {

+                    if (data && data.result == "success") {

+                        target.connectButtonStatus("disable");

+                        //延迟检测 确保取得的状态是最新的

+                        addTimeout(checkWifiStatus, 3000);

+                    } else if (data && data.result == "processing") {

+                        showAlert("ap_station_processing");

+                    } else {

+                        var apList = target.apList(); // cov_2

+                        apList[connectIndex].connectStatus = "0";

+                        target.connectWifiStatus("disconnect");

+                        target.connectButtonStatus("show");

+                        hideLoading();

+                        errorOverlay();

+                    }

+                    var apList = service.getHotspotList();

+                    target.apList(fixHotspotList(apList.hotspotList));

+                    target.connectWifiProfile(profileName);

+                    target.connectWifiSSID(ssid);

+                    target.apGrid.data([]);

+                    target.apGrid.data(target.apList());

+                    target.apGrid.setRadioSelect(profileName);

+                });

+            }

+

+            //将用户选中的profile排在运营商定制profile后的第一位

+            function refreshApList(profile, aplist) {

+                var apListLeft = [];

+                var apListPre = [];

+                for (var i = 0; i < aplist.length; i++) {

+                    if (aplist[i].fromProvider != "1") {

+                        if (aplist[i].profileName == profile) {

+                            apListPre.push(apList[i]);

+                        } else {

+                            apListLeft.push(apList[i]);

+                        }

+                    } else {

+                        apListPre.push(apList[i]);

+                    }

+                }

+                var apListNew = apListPre.concat(apListLeft);

+                service.saveHotspot({

+                    apList: apListNew

+                }, function (data) {

+                    if (data && data.result == "success") {

+                        apList = apListNew;

+                        target.apList(fixHotspotList(apList));

+                    }

+                });

+            }

+

+            var check_count = 0;

+            var connectStatus = false;

+

+            var status = service.getStatusInfo();

+            if (status.connectStatus == "ppp_connected" || status.connectStatus == "ppp_connecting") {

+                showConfirm("ap_station_connect_change_alert", function () {

+                    showLoading();

+                    connect();

+                });

+            } else {

+                connect();

+            }

+

+            function checkWifiStatus() {

+                check_count = check_count + 1;

+                if (check_count > 60) {

+                    hideLoading();

+                    errorOverlay();

+                    return;

+                }

+                if (!connectStatus) {

+                    var status = service.getStatusInfo();

+                    if (status.connectWifiStatus != "connect") {

+                        addTimeout(checkWifiStatus, 1000);

+                    } else {

+                        connectStatus = true;

+                    }

+                }

+                if (connectStatus) {

+                    //继续判断profile中连接状态是否为1

+                    service.getHotspotList({}, function (data) {

+                        for (var i = 0, len = data.hotspotList.length; i < len; i++) {

+                            var list_item = data.hotspotList[i];

+                            if (list_item.profileName == profileName) {

+                                if (list_item.connectStatus == "1") {

+                                    hideLoading();

+                                    return;

+                                } else {

+                                    var errorMsg = {

+                                        msg: 'ap_connect_error',

+                                        params: [list_item.ssid]

+                                    };

+                                    showAlert(errorMsg);

+                                    return;

+                                }

+                                break;

+                            }

+                        }

+                        addTimeout(checkWifiStatus, 1000);

+                    });

+                }

+            }

+

+        };

+

+        target.disconnectHotspot = function () {

+            if (wpsIsOn()) {

+                return;

+            }

+            showLoading('disconnecting');

+            service.disconnectHotspot({}, function (data) {

+                target.callback(data, true);

+            })

+        };

+

+        function getSearchHotspot() {

+            var check_count = 0;

+

+            function search() {

+                var result = service.getSearchHotspotList();

+                if (result.scan_finish == "0") {

+                    if (check_count <= 60) {

+                        check_count = check_count + 1;

+                        addTimeout(search, 1000);

+                    } else {

+                        hideLoading();

+                        showAlert("ap_station_search_hotspot_fail");

+                    }

+                } else {

+                    if ("2" == result.scan_finish) {

+                        hideLoading();

+                        showAlert("ap_station_processing");

+                    } else {

+                        target.apSearchList(fixHotspotList(result.hotspotList));

+                        target.apSearchGrid.data(target.apSearchList());

+                        hideLoading();

+                    }

+                }

+            }

+

+            showLoading('scanning');

+            service.searchHotspot({}, function (data) {

+                if (data && data.result == "processing") {

+                    hideLoading();

+                    showAlert("ap_station_processing");

+                } else if (data && data.result == "success") {

+                    if (target.pageState() != target.page.add) {

+                        target.pageState(target.page.add);

+                    }

+                    search();

+                } else {

+                    if (target.pageState() != target.page.add) {

+                        target.pageState(target.page.add);

+                    }

+                    hideLoading();

+                    showAlert("ap_station_search_hotspot_fail");

+                }

+            });

+        }

+

+        //清除编辑页面的信息

+        target.clear = function () {

+            target.apSearchGrid.clearRadioSelect();

+            target.profileName("");

+            target.ssid("");

+            target.signal("0");

+            target.authMode("OPEN");

+            target.password("");

+            target.encryptType("NONE");

+            target.encryptType_WPA("TKIPCCMP");

+            target.keyID("0");

+            target.mac("");

+        };

+

+        target.apply = function () {

+            if (wifiIsClosed()) {

+                return;

+            }

+            if (wpsIsOn()) {

+                return;

+            }

+

+            function setBasic() {

+                showLoading('waiting');

+                var wifi_para = {};

+                wifi_para.ap_station_enable = target.ap_station_enable();

+                service.setAPStationBasic(wifi_para, function (data) {

+                    if (target.origin_ap_station_enable == target.ap_station_enable()) {

+                        target.callback(data, true);

+                    } else {

+                        target.callback2(data, true);

+                    }

+                });

+                service.refreshAPStationStatus();

+            }

+            if (!config.HAS_MULTI_SSID) {

+                setBasic();

+            } else {

+                var infoBasic = service.getWifiBasic();

+                if (target.ap_station_enable() == "1" && infoBasic.multi_ssid_enable == "1") {

+                    showConfirm("ap_station_enable_confirm", setBasic);

+                } else {

+                    setBasic();

+                }

+            }

+        };

+        //刷新搜到的热点列表

+        target.searchHotspot = function () {

+            if (wifiIsClosed()) {

+                return;

+            }

+            if (wpsIsOn()) {

+                return;

+            }

+            getSearchHotspot();

+        };

+        //和webserver交互时的回调,wifi不重启的情况

+        target.callback = function (data, isInitPage) {

+            if (data) {

+                if (isInitPage) {

+                    initialize();

+                    $("#apList").translate();

+                }

+                if (data.result == "processing") {

+                    showAlert("ap_station_processing");

+                } else if (data.result == "spot_connected" || data.result == "spot_connecting") {

+                    showAlert("ap_station_update_fail");

+                } else if (data.result == "success") {

+                    successOverlay();

+                } else if (data.result == "exist") {

+                    showAlert("ap_station_exist");

+                } else {

+                    errorOverlay();

+                }

+            } else {

+                errorOverlay();

+            }

+        }

+

+        //和webserver交互时的回调,wifi会重启的情况

+        target.callback2 = function (data, isInitPage) {

+            if (data) {

+                if (!viaWifi) { //通过wifi登录webui

+                    addInterval(function () {

+                        var info = service.getWifiBasic();

+                        if (info.wifi_enable == "1") {

+                            clearTimer();

+                            clearValidateMsg();

+                            initialize();

+                            $("#apList").translate();

+                            if (data.result == "spot_connected" || data.result == "spot_connecting") {

+                                showAlert("ap_station_update_fail");

+                            } else if (data.result == "success") {

+                                successOverlay();

+                            } else {

+                                errorOverlay();

+                            }

+                        }

+                    }, 1000);

+                } else {

+                    setTimeout(function () {

+                        if (data.result == "processing") {

+                            showAlert("ap_station_processing");

+                        } else if (data.result == "spot_connecting" || data.result == "spot_connected") {

+                            showAlert("ap_station_update_fail");

+                        } else if (data.result == "success") {

+                            successOverlay();

+                            setTimeout(function () {

+                                window.location.reload();

+                            }, 1000);

+                            clearTimer();

+                            clearValidateMsg();

+                            initialize();

+                        } else {

+                            errorOverlay();

+                        }

+                    }, 15000);

+                }

+            } else {

+                errorOverlay();

+            }

+        };

+

+        target.checkSettings = function (ssid) {

+            var status = service.getWpsInfo();

+            if (status.wpsFlag == '1') {

+                showAlert('wps_on_info', function() {

+                    window.location.reload();

+                });

+                return true;

+            }

+            if (config.HAS_MULTI_SSID && info.multi_ssid_enable == "1") {

+                if ((ssid == "ssid1" && parseInt(target.selectedStation()) + parseInt(info.m_MAX_Access_num) > info.MAX_Station_num)

+                     || (ssid == "ssid2" && parseInt(target.m_selectedStation()) + parseInt(info.MAX_Access_num) > info.MAX_Station_num)) {

+                    showAlert({

+                        msg: 'multi_ssid_max_access_number_alert',

+                        params: info.MAX_Station_num

+                    });

+                    return true;

+                }

+            }

+

+            return false;

+        };

+

+        target.setMultiSSIDSwitch = function () {

+            if (target.checkSettings("switch")) {

+                return;

+            }

+

+            var setSwitch = function () {

+                showLoading('waiting');

+                var params = {};

+                params.m_ssid_enable = target.multi_ssid_enable();

+                if (config.WIFI_SWITCH_SUPPORT) {

+                    params.wifiEnabled = target.wifi_enable();

+                }

+                service.setWifiBasicMultiSSIDSwitch(params, function (result) {

+                    if (result.result == "success") {

+                        if (!viaWifi) {

+                            addInterval(function () {

+                                var info = service.getWifiBasic();

+                                if (info.wifi_enable == target.wifi_enable()) {

+                                    successOverlay();

+                                    clearTimer();

+                                    clearValidateMsg();

+                                    service.refreshAPStationStatus();

+                                    initialize();

+                                }

+                            }, 1000);

+                        } else {

+                            setTimeout(function () {

+                                successOverlay();

+                                setTimeout(function () {

+                                    window.location.reload();

+                                }, 1000);

+                                clearTimer();

+                                clearValidateMsg();

+                                service.refreshAPStationStatus();

+                                initialize();

+                            }, 15000);

+                        }

+                    } else {

+                        errorOverlay();

+                    }

+                });

+            };

+

+            var info = service.getStatusInfo();

+            if (config.HAS_MULTI_SSID && target.wifi_enable() == "1") {

+                if (target.multi_ssid_enable() == "1" && config.AP_STATION_SUPPORT && target.origin_ap_station_enable == "1") {

+                    if (!info.wifiStatus) {

+                        showConfirm("multi_ssid_enable_confirm", function () {

+                            setSwitch();

+                        });

+                    } else {

+                        showConfirm("multi_ssid_enable_confirm2", function () {

+                            setSwitch();

+                        });

+                    }

+                } else {

+                    if (!info.wifiStatus) {

+                        setSwitch();

+                    } else {

+                        showConfirm("wifi_disconnect_confirm2", function () {

+                            setSwitch();

+                        });

+                    }

+                }

+            } else {

+                setSwitch();

+            }

+        };

+

+    }

+

+    function wpsIsOn() {

+        var wifi_info = service.getWpsInfo();

+        if (wifi_info.wpsFlag == '1') {

+            showAlert('wps_on_info', function() {

+                window.location.reload();

+            });

+            return true;

+        }

+    }

+

+    //处理热点列表内容,以便在表格显示

+    function fixHotspotList(list) {

+        var fixedList = [];

+        for (var ii = 0; ii < list.length; ii++) {

+            list[ii].index = ii;

+            var url_image = "";

+            if (list[ii].connectStatus != "1") {

+                if (list[ii].encryptType.toLowerCase() == "none" && list[ii].authMode.toLowerCase() == "open") {

+                    url_image = "pic/wlan_signal_" + list[ii].signal + ".png";

+                } else {

+                    url_image = "pic/wlan_lock_signal_" + list[ii].signal + ".png";

+                }

+            } else {

+                if (list[ii].encryptType.toLowerCase() == "none" && list[ii].authMode.toLowerCase() == "open") {

+                    url_image = "pic/wlan_connected.png";

+                } else {

+                    url_image = "pic/wlan_lock_connected.png";

+                }

+            }

+            list[ii].imgSignal = url_image;

+            list[ii].authMode_show = $.i18n.prop("ap_station_security_mode_" + list[ii].authMode);

+        }

+        return list;

+    }

+

+    function wifiIsClosed() {

+        var wifi_info = service.getWpsInfo();

+        if (wifi_info.radioFlag == "0") {

+            showAlert('wps_wifi_off');

+            return true;

+        }

+    }

+

+    function event_bind(aps_vm) {

+        $("#showWPAPassword").change(function () {

+            aps_vm.showWPAPasswordHandler();

+        });

+        $("#showPassword").change(function () {

+            aps_vm.showPasswordHandler();

+        });

+    }

+

+    function initialize() {

+        var aps_vm = new apStationViewMode();

+        var container = $('#container')[0];

+        ko.cleanNode(container);

+        ko.applyBindings(aps_vm, container);

+        event_bind(aps_vm);

+

+        aps_refresh(true);

+        clearTimer();

+        addInterval(function () {

+            aps_refresh(false);

+            checkAccessMode();

+        }, 1000);

+

+        $('#frmWifiSwitch').validate({

+            submitHandler: function () {

+                aps_vm.setMultiSSIDSwitch();

+            }

+        });

+

+        $("#frmAPStation").validate({

+            submitHandler: function () {

+                aps_vm.addHotspot();

+            },

+            rules: {

+                txtSSID: "ssid_ap"

+            },

+            errorPlacement: function (error, element) {

+                var id = element.attr("id");

+                if (id == "txtWPAKey" || id == "codeWPAKey") {

+                    error.insertAfter("#lblshowWPAPassword");

+                } else if (id == "txtWepKey" || id == "pwdWepKey") {

+                    error.insertAfter("#lblShowPassword");

+                } else {

+                    error.insertAfter(element);

+                }

+            }

+        });

+

+        function aps_refresh(initPage) {

+            var info = service.getStatusInfo();

+            if (info.multi_ssid_enable != "1") {

+                aps_vm.isCableMode(checkCableMode(info.blc_wan_mode));

+                aps_vm.connectWifiProfile(info.connectWifiProfile);

+                aps_vm.connectWifiSSID(info.connectWifiSSID);

+                aps_vm.connectWifiStatus(info.connectWifiStatus);

+                aps_vm.networkType(info.networkType);

+                aps_vm.connectStatus(info.connectStatus);

+                aps_vm.computeConnectStatus();

+

+                service.getHotspotList({}, function (data) {

+                    var list = fixHotspotList(data.hotspotList);

+                    aps_vm.apList(list);

+                    var gripList = aps_vm.apGrid.data();

+                    if (list.length > 0 && list[0].profileName != gripList[0].profileName && list[0].connectStatus == "1") {

+                        aps_vm.apGrid.data([]);

+                        aps_vm.apGrid.data(aps_vm.apList());

+                        aps_vm.apGrid.setRadioSelect(list[0].profileName);

+                    }

+                    renderCustomElement($("#apList"));

+                    var radios = $("input[type='radio']", "#apList").each(function () {

+                        for (var i = 0, len = list.length; i < len; i++) {

+                            if (list[i].profileName == $(this).val()) {

+                                var img = $(this).parent().parent().find("img")[0];

+                                img.src = list[i].imgSignal;

+                                if (initPage) {

+                                    if (list[i].connectStatus == "1") {

+                                        aps_vm.hasSelectFromUser(false);

+                                        aps_vm.connectButtonStatus("disable");

+                                    }

+                                }

+                            }

+                        }

+                    });

+                });

+            } else {

+                //to do

+            }

+        }

+

+    }

+

+    return {

+        init: initialize

+    }

+});

+

+define("wifi_guest","underscore jquery knockout set service CryptoJS".split(" "),

+

+    function (_, $, ko, config, service, CryptoJS) {

+

+    var viaWifi = false;

+    function checkAccessMode() {

+        service.getParams({

+            nv: 'user_ip_addr'

+        }, function (dataIp) {

+            service.getParams({

+                nv: 'station_list'

+            }, function (dataList) {

+                viaWifi = isWifiConnected(dataIp.user_ip_addr, dataList.station_list);

+            });

+        });

+    }

+

+    var securityModes = _.map(config.WIFI_WEP_SUPPORT ? config.AUTH_MODES_WEP : config.AUTH_MODES, function (item) {

+        return new Option(item.name, item.value);

+    });

+

+    function maxStationAccess(max) {

+        var showOption = [];

+        for (var i = 1; i <= max; i++) {

+            showOption.push(new Option(i, i));

+        }

+        return showOption;

+    }

+

+    function wifiGuestVM() {

+        var target = this;

+        var info = service.getWifiBasic();

+

+        target.hasWifiSwitch = config.WIFI_SWITCH_SUPPORT;

+        target.hasMultiSSID = config.HAS_MULTI_SSID;

+        target.showIsolated = config.SHOW_WIFI_AP_ISOLATED;

+        target.hasAPStation = config.AP_STATION_SUPPORT;

+        target.hasWlanMacfilter = config.HAS_BLACK_AND_WHITE_FILTER;

+        target.hasWifiWep = config.WIFI_WEP_SUPPORT;

+        target.hasWifiWpa3 = config.WIFI_WAP3_SUPPORT;

+        target.hasWifiWpa23 = config.WIFI_WPA2_WAP3_SUPPORT;

+

+        var advanceInfo = service.getWifiAdvance();

+        target.adBand = ko.observable(advanceInfo.wifiBand);

+        target.adMode = ko.observable(advanceInfo.mode);

+

+        target.showQRSwitch = config.WIFI_SUPPORT_QR_CODE && config.WIFI_SUPPORT_QR_SWITCH;

+        target.showQR = ko.observable(info.m_show_qrcode_flag);

+        if (config.WIFI_SUPPORT_QR_SWITCH) {

+            target.showQRCode = ko.observable(config.WIFI_SUPPORT_QR_CODE && target.showQR());

+        } else {

+            target.showQRCode = ko.observable(config.WIFI_SUPPORT_QR_CODE);

+        }

+        if(config.WIFI_SUPPORT_QR_CODE){

+            target.qrcodeSrc = './pic/qrcode_multi_ssid_wifikey.png?_=' + $.now();

+        } else {

+            target.qrcodeSrc = './pic/res_blacktrans.png';

+        }

+        target.origin_ap_station_enable = info.ap_station_enable;

+        target.wifi_enable = ko.observable(info.wifi_enable);

+        target.isShowSSIDInfoDiv = ko.observable(false);

+        if (config.WIFI_SWITCH_SUPPORT) {

+            if (info.wifi_enable == "1") {

+                target.isShowSSIDInfoDiv(true);

+            } else {

+                target.isShowSSIDInfoDiv(false);

+            }

+        } else {

+            target.isShowSSIDInfoDiv(true);

+        }

+

+        target.multi_ssid_enable = ko.observable(info.multi_ssid_enable);

+        target.origin_multi_ssid_enable = info.multi_ssid_enable;

+

+        target.maxStationNumber = ko.computed(function () {

+            return config.MAX_STATION_NUMBER;

+        });

+

+        target.modes = ko.observableArray(securityModes);

+        target.selectedMode = ko.observable(info.AuthMode);

+        target.passPhrase = ko.observable(info.passPhrase);

+        target.showPassword = ko.observable(false);

+        target.ssid = ko.observable(info.SSID);

+        target.broadcast = ko.observable(info.broadcast == '1' ? '1' : '0');

+        target.apIsolation = ko.observable(info.apIsolation == '1' ? '1' : '0');

+        target.cipher = info.cipher;

+        target.selectedStation = ko.observable(info.MAX_Access_num);

+        target.maxStations = ko.observableArray(maxStationAccess(info.MAX_Station_num));

+

+        target.m_modes = ko.observableArray(securityModes);

+        target.m_selectedMode = ko.observable(info.m_AuthMode);

+        target.m_passPhrase = ko.observable(info.m_passPhrase);

+        target.m_showPassword = ko.observable(false);

+        target.m_ssid = ko.observable(info.m_SSID);

+        target.m_broadcast = ko.observable(info.m_broadcast == '1' ? '1' : '0');

+        target.m_apIsolation = ko.observable(info.m_apIsolation == '1' ? '1' : '0');

+        target.m_cipher = info.m_cipher;

+        target.m_selectedStation = ko.observable(info.m_MAX_Access_num);

+        target.m_maxStations = ko.observableArray(maxStationAccess(info.MAX_Station_num));

+        target.m_encryptType = ko.observable(info.m_encryptType);

+        target.m_keyID = ko.observable(info.m_keyID);

+        target.m_wepPassword = ko.observable("");

+

+        //刷新界面状态值显示

+        target.clear = function (option) {

+            if (option == "switch") {

+                target.multi_ssid_enable(info.multi_ssid_enable);

+                target.wifi_enable(info.wifi_enable);

+            } else if (option == "ssid1") {

+                target.selectedMode(info.AuthMode);

+                target.passPhrase(info.passPhrase);

+                target.ssid(info.SSID);

+                target.broadcast(info.broadcast == '1' ? '1' : '0');

+                target.cipher = info.cipher;

+                target.selectedStation(info.MAX_Access_num);

+                target.apIsolation(info.apIsolation == '1' ? '1' : '0');

+            } else if (option == "ssid2") {

+                target.m_selectedMode(info.m_AuthMode);

+                target.m_passPhrase(info.m_passPhrase);

+                target.m_ssid(info.m_SSID);

+                target.m_broadcast(info.m_broadcast == '1' ? '1' : '0');

+                target.m_cipher = info.m_cipher;

+                target.m_selectedStation(info.m_MAX_Access_num);

+                target.m_apIsolation(info.m_apIsolation == '1' ? '1' : '0');

+                if (config.WIFI_WEP_SUPPORT) {

+                    target.m_encryptType(info.m_encryptType);

+                    target.m_keyID(info.m_keyID);

+                    target.m_wepPassword(target.getWepPassword());

+                }

+            } else {

+                clearTimer();

+                clearValidateMsg();

+                initialize();

+                service.refreshAPStationStatus();

+            }

+        };

+

+        target.getWepPassword = function () {

+            return target.m_keyID() == '3' ? info.m_Key4Str1 : (target.m_keyID() == '2' ? info.m_Key3Str1 : target.m_keyID() == '1' ? info.m_Key2Str1 : info.m_Key1Str1);

+        }

+        target.m_wepPassword(target.getWepPassword());

+        //WEP加密模式下网络秘钥切换事件

+        target.profileChangeHandler = function (data, event) {

+            $("#pwdWepKey").parent().find("label[class='error']").hide();

+            target.m_wepPassword(target.getWepPassword());

+            return true;

+        };

+

+        target.saveSSID1 = function () {

+            if (target.checkSettings("ssid1")) {

+                return;

+            }

+            showConfirm('wifi_disconnect_confirm', function () {

+                target.saveSSID1Action();

+            });

+        };

+        target.saveSSID1Action = function () {

+            showLoading('waiting');

+            target.broadcast($("#broadcastCheckbox:checked").length > 0 ? '0' : '1');

+            target.apIsolation($("#apisolatedCheckbox:checked").length);

+            var params = {};

+            params.AuthMode = target.selectedMode();

+            params.passPhrase = target.passPhrase();

+            params.SSID = target.ssid();

+            params.broadcast = target.broadcast();

+            params.station = target.selectedStation();

+            params.cipher = target.selectedMode() == "WPA2PSK" ? 1 : 2;

+            if (params.AuthMode == "WPA3Personal" || params.AuthMode == "WPA2WPA3") {

+                params.cipher = 1;

+            }

+            params.NoForwarding = target.apIsolation();

+            params.show_qrcode_flag = target.showQR() == true ? 1 : 0;

+            service.setWifiBasic(params, function (result) {

+                if (result.result == "success") {

+                    if (viaWifi) {

+                        setTimeout(guestReloadVarWifi, 15000);

+                    } else {

+                        addInterval(guestReload, 1000);

+                    }

+                } else {

+                    errorOverlay();

+                }

+            });

+        };

+

+        target.saveSSID2 = function () {

+            if (target.checkSettings("ssid2")) {

+                return;

+            }

+            if (!config.PASSWORD_ENCODE) {

+                var pwdRegex = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{8,32}');

+                if (!pwdRegex.test(target.m_passPhrase())) {

+                        showConfirm("password_note_too_low", function () {

+                            showConfirm('wifi_disconnect_confirm', function () {

+                            target.saveSSID2Action();

+                            return;

+                        });

+                        return;

+                    });

+                    return;

+                }

+            }

+            showConfirm('wifi_disconnect_confirm', function () {

+                target.saveSSID2Action();

+            });

+        };

+        target.saveSSID2Action = function () {

+            showLoading('waiting');

+            target.m_broadcast($("#mBroadcastCheckbox:checked").length > 0 ? '0' : '1');

+            target.m_apIsolation($("#mApIsolatedCheckbox:checked").length);

+            var ciphertext = "";

+            if (config.PASSWORD_ENCODE) {

+	        ciphertext = target.m_passPhrase();

+	    } else {

+                var kparam = service.getDeviceInfoLow();

+                var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);

+		var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);

+                ciphertext = CryptoJS.AES.encrypt(target.m_passPhrase(), tkey, {

+                    iv: tiv,

+                    mode: CryptoJS.mode.CBC,

+                    padding: CryptoJS.pad.ZeroPadding

+                    }).toString();

+	    }

+            var params = {};

+            params.m_AuthMode = target.m_selectedMode();

+            params.m_passPhrase = ciphertext;

+            params.m_SSID = target.m_ssid();

+            params.m_broadcast = target.m_broadcast();

+            params.m_station = target.m_selectedStation();

+            params.m_cipher = target.m_selectedMode() == "WPA2PSK" ? 1 : 2;

+            if (params.m_AuthMode == "WPA3Personal" || params.m_AuthMode == "WPA2WPA3") {

+                params.m_cipher = 1;

+            }

+            params.m_NoForwarding = target.m_apIsolation();

+            params.m_show_qrcode_flag = target.showQR() == true ? 1 : 0;

+

+            if (config.WIFI_WEP_SUPPORT) {

+                if (params.m_AuthMode == "SHARED") {

+                    params.m_encryptType = "WEP";

+                } else if (params.m_AuthMode == "WPAPSKWPA2PSK" || params.m_AuthMode == "WPA2PSK" || params.m_AuthMode == "WPAPSK" || params.m_AuthMode == "WPA3Personal" || params.m_AuthMode == "WPA2WPA3") {

+                    //params.m_encryptType = target.m_encryptType_WPA();

+                } else {

+                    params.m_encryptType = target.m_encryptType();

+                }

+                params.m_wep_default_key = target.m_keyID();

+                params.m_wep_key_4 = info.m_Key4Str1;

+                params.m_wep_key_3 = info.m_Key3Str1;

+                params.m_wep_key_2 = info.m_Key2Str1;

+                params.m_wep_key_1 = info.m_Key1Str1;

+                var mWEPSelect = '0';

+                if (target.m_wepPassword().length == '13' || target.m_wepPassword().length == '5') {

+                    mWEPSelect = '1';

+                } else {

+                    mWEPSelect = '0';

+                }

+                if (target.m_keyID() == '3') {

+                    params.m_wep_key_4 = target.m_wepPassword();

+                    params.m_WEP4Select = mWEPSelect;

+                } else if (target.m_keyID() == '2') {

+                    params.m_wep_key_3 = target.m_wepPassword();

+                    params.m_WEP3Select = mWEPSelect;

+                } else if (target.m_keyID() == '1') {

+                    params.m_wep_key_2 = target.m_wepPassword();

+                    params.m_WEP2Select = mWEPSelect;

+                } else {

+                    params.m_wep_key_1 = target.m_wepPassword();

+                    params.m_WEP1Select = mWEPSelect;

+                }

+            }

+

+            service.setWifiBasic4SSID2(params, function (result) {

+                if (result.result == "success") {

+                    if (viaWifi) {

+                        setTimeout(ssid2ReloadVarWifi, 15000);

+                    } else {

+                        addInterval(ssid2Reload, 1000);

+                    }

+                } else {

+                    errorOverlay();

+                }

+            });

+        };

+

+        function guestReloadVarWifi() {

+            successOverlay();

+            setTimeout(function () {

+                window.location.reload();

+            }, 1000);

+            target.clear();

+        }

+        function guestReload() {

+            var info = getWifiMain();

+            if (info.wifi_enable == "1") {

+                successOverlay();

+                target.clear();

+            }

+        }

+        function ssid2ReloadVarWifi() {

+            successOverlay();

+            setTimeout(function () {

+                window.location.reload();

+            }, 1000);

+            target.clear();

+        }

+        function ssid2Reload() {

+            var info = getWifiMain();

+            if (info.wifi_enable == "1") {

+                successOverlay();

+                target.clear();

+            }

+        }

+

+        target.checkSettings = function (ssid) {

+            var status = getWpsState();

+

+            if (config.HAS_MULTI_SSID) {

+                if (ssid == "ssid1" || ssid == "ssid2") {

+                    if (ssid == "ssid2") {

+                        var accessDevice = service.getStatusInfo().ssid2AttachedNum;

+                        if (parseInt(target.m_selectedStation()) < accessDevice) {

+                            showAlert('Extend_accessDevice');

+                            return true;

+                        }

+                    } else {

+                        var accessDevice = service.getStatusInfo().ssid1AttachedNum;

+                        if (parseInt(target.selectedStation()) < accessDevice) {

+                            showAlert('Extend_accessDevice');

+                            return true;

+                        }

+                    }

+                }

+            }

+

+            if (status.wpsFlag == '1') {

+                showAlert('wps_on_info', function() {

+                    window.location.reload();

+                });

+                return true;

+            }

+            if (config.HAS_MULTI_SSID && info.multi_ssid_enable == "1") {

+                if ((ssid == "ssid1" && parseInt(target.selectedStation()) + parseInt(info.m_MAX_Access_num) > info.MAX_Station_num)

+                     || (ssid == "ssid2" && parseInt(target.m_selectedStation()) + parseInt(info.MAX_Access_num) > info.MAX_Station_num)) {

+                    showAlert({

+                        msg: 'multi_ssid_max_access_number_alert',

+                        params: info.MAX_Station_num

+                    });

+                    return true;

+                }

+            }

+

+            return false;

+        };

+

+        target.setMultiSSIDSwitch = function () {

+            if (target.checkSettings("switch")) {

+                return;

+            }

+

+            var setSwitch = function () {

+                showLoading('waiting');

+                var params = {};

+                params.m_ssid_enable = target.multi_ssid_enable();

+                if (config.WIFI_SWITCH_SUPPORT) {

+                    params.wifiEnabled = target.wifi_enable();

+                }

+                service.setWifiBasicMultiSSIDSwitch(params, function (result) {

+                    if (result.result == "success") {

+                        if (viaWifi) {

+                            setTimeout(multiReloadViaWifi, 15000);

+                        } else {

+                            addInterval(multiReload, 1000);

+                        }

+                    } else {

+                        errorOverlay();

+                    }

+                });

+            };

+            function multiReloadViaWifi() {

+                successOverlay();

+                setTimeout(function () {

+                    window.location.reload();

+                }, 1000);

+                target.clear();

+            }

+            function multiReload() {

+                var info = getWifiMain();

+                if (info.wifi_enable == target.wifi_enable()) {

+                    successOverlay();

+                    target.clear();

+                }

+            }

+            var info = service.getStatusInfo();

+            if (config.HAS_MULTI_SSID && target.wifi_enable() == "1") {

+                if (config.AP_STATION_SUPPORT && target.multi_ssid_enable() == "1" && target.origin_ap_station_enable == "1") {

+                    if (!info.wifiStatus) {

+                        showConfirm("multi_ssid_enable_confirm", function () {

+                            setSwitch();

+                        });

+                    } else {

+                        showConfirm("multi_ssid_enable_confirm2", function () {

+                            setSwitch();

+                        });

+                    }

+                } else {

+                    if (!info.wifiStatus) {

+                        setSwitch();

+                    } else {

+                        showConfirm("wifi_disconnect_confirm2", function () {

+                            setSwitch();

+                        });

+                    }

+                }

+            } else {

+                setSwitch();

+            }

+        };

+        target.showQRHandler = function () {

+            var checkbox = $("#showQR:checked");

+            if (checkbox && checkbox.length == 0) {

+                target.showQR(true);

+            } else {

+                target.showQR(false);

+            }

+            target.showQRCode(config.WIFI_SUPPORT_QR_CODE && target.showQR());

+        };

+

+        target.showPasswordHandler = guestShowPassword;

+

+        target.m_showPasswordHandler = m_guestShowPassword;

+

+        function guestShowPassword() {

+            $("#passShow").parent().find(".error").hide();

+            var checkbox = $("#showPassword:checked");

+            if (checkbox && checkbox.length == 0) {

+                target.showPassword(true);

+            } else {

+                target.showPassword(false);

+            }

+        }

+        function m_guestShowPassword() {

+            $("#m_passShow").parent().find(".error").hide();

+            $("#m_pwdWepKey").parent().find(".error").hide();

+            var checkbox = $("#m_showPassword:checked");

+            if (checkbox && checkbox.length == 0) {

+                target.m_showPassword(true);

+            } else {

+                target.m_showPassword(false);

+            }

+        }

+

+    }

+

+    function getWifiMain() {

+        return service.getWifiBasic();

+    }

+

+    function initialize() {

+        var container = $('#container');

+        ko.cleanNode(container[0]);

+        var vm = new wifiGuestVM();

+        ko.applyBindings(vm, container[0]);

+        addTimeout(function () {

+            checkAccessMode();

+        }, 600);

+

+        function checkWifiStatus() {

+            var info = service.getAPStationBasic();

+            if (info.ap_station_enable != "1") {

+                $('#frmMultiSSID :input').each(function () {

+                    $(this).attr("disabled", false);

+                });

+            } else {

+                $('#frmMultiSSID :input').each(function () {

+                    $(this).attr("disabled", true);

+                });

+            }

+        }

+

+        function checkWifiStatusAccordingToWDS() {

+            var info = service.getWdsInfo();

+            if (info.currentMode == "0") {

+                $('#frmWifiSwitch :input').each(function () {

+                    $(this).attr("disabled", false);

+                });

+                $('#frmSSID2 :input').each(function () {

+                    $(this).attr("disabled", false);

+                });

+                $('#frmSSID1 :input').each(function () {

+                    $(this).attr("disabled", false);

+                });

+            } else {

+                $('#frmWifiSwitch :input').each(function () {

+                    $(this).attr("disabled", true);

+                });

+                $('#frmSSID2 :input').each(function () {

+                    $(this).attr("disabled", true);

+                });

+                $('#frmSSID1 :input').each(function () {

+                    $(this).attr("disabled", true);

+                });

+            }

+        }

+

+        if (config.WDS_SUPPORT) {

+            checkWifiStatusAccordingToWDS();

+        } else if (config.AP_STATION_SUPPORT) {

+            checkWifiStatus();

+        }

+

+        $('#frmMultiSSID').validate({

+            submitHandler: function () {

+                vm.setMultiSSIDSwitch();

+            }

+        });

+        $('#frmWifiSwitch').validate({

+            submitHandler: function () {

+                vm.setMultiSSIDSwitch();

+            }

+        });

+        $('#frmSSID2').validate({

+            submitHandler: function () {

+                vm.saveSSID2();

+            },

+            rules: {

+                m_ssid: 'ssid',

+                m_pwdWepKey: {

+                    wifi_wep_password_check: true,

+                    wifi_password_check: true

+                },

+                m_txtWepKey: {

+                    wifi_wep_password_check: true,

+                    wifi_password_check: true

+                },

+                m_pass: 'wifi_password_check',

+                m_passShow: 'wifi_password_check'

+            },

+            errorPlacement: function (error, element) {

+                var id = element.attr("id");

+                if (id == "m_passShow" || id == "m_pass") {

+                    error.insertAfter("#m_lblShowPassword");

+                } else if (id == "m_txtWepKey" || id == "m_pwdWepKey") {

+                    error.insertAfter("#m_lblShowWepPassword");

+                } else {

+                    error.insertAfter(element);

+                }

+            }

+        });

+        $('#frmSSID1').validate({

+            submitHandler: function () {

+                vm.saveSSID1();

+            },

+            rules: {

+                pass: 'wifi_password_check',

+                ssid: 'ssid',

+                passShow: 'wifi_password_check'

+            },

+            errorPlacement: function (error, element) {

+                var id = element.attr("id");

+                if (id == "passShow" || id == "pass") {

+                    error.insertAfter("#lblShowPassword");

+                } else {

+                    error.insertAfter(element);

+                }

+            }

+        });

+

+    }

+

+    function getWpsState() {

+        return service.getWpsInfo();

+    }

+

+    return {

+        init: initialize

+    };

+});

+

+define("wifi_mac_filter","underscore jquery knockout set service".split(" "),

+    function (_, $, ko, config, service) {

+

+    var viaWifi = false;

+    function checkAccessMode() {

+        service.getParams({

+            nv: 'user_ip_addr'

+        }, function (dataIp) {

+            service.getParams({

+                nv: 'station_list'

+            }, function (dataList) {

+                viaWifi = isWifiConnected(dataIp.user_ip_addr, dataList.station_list);

+            });

+        });

+    }

+

+    function macFilterViewModel() {

+        var target = this;

+        target.hasAPStation = config.AP_STATION_SUPPORT;

+        target.hasWifiSwitch = config.WIFI_SWITCH_SUPPORT;

+        target.hasMultiSSID = config.HAS_MULTI_SSID;

+        target.showIsolated = config.SHOW_WIFI_AP_ISOLATED;

+

+        var info = service.getMacFilterInfo();

+        var wifiBaseInfo = service.getWifiBasic();

+        target.multi_ssid_enable = ko.observable(wifiBaseInfo.multi_ssid_enable);

+        target.origin_ap_station_enable = wifiBaseInfo.ap_station_enable;

+        target.wifi_enable = ko.observable(wifiBaseInfo.wifi_enable);

+

+        target.isShowSSIDInfoDiv = ko.observable(false);

+        if (config.WIFI_SWITCH_SUPPORT) {

+            if (wifiBaseInfo.wifi_enable == "1") {

+                target.isShowSSIDInfoDiv(true);

+            } else {

+                target.isShowSSIDInfoDiv(false);

+            }

+        } else {

+            target.isShowSSIDInfoDiv(true);

+        }

+

+        target.selectedAction = ko.observable(info.ACL_mode);

+        target.mac1 = ko.observable("");

+        target.mac2 = ko.observable("");

+        target.mac3 = ko.observable("");

+        target.mac4 = ko.observable("");

+        target.mac5 = ko.observable("");

+        target.mac6 = ko.observable("");

+        target.mac7 = ko.observable("");

+        target.mac8 = ko.observable("");

+        target.mac9 = ko.observable("");

+        target.mac10 = ko.observable("");

+        if (info.ACL_mode == "1") {

+            macInfoWhite = info.wifi_mac_white_list.split(";");

+            target.mac1 = ko.observable(macInfoWhite[0]);

+            target.mac2 = ko.observable(macInfoWhite[1]);

+            target.mac3 = ko.observable(macInfoWhite[2]);

+            target.mac4 = ko.observable(macInfoWhite[3]);

+            target.mac5 = ko.observable(macInfoWhite[4]);

+            target.mac6 = ko.observable(macInfoWhite[5]);

+            target.mac7 = ko.observable(macInfoWhite[6]);

+            target.mac8 = ko.observable(macInfoWhite[7]);

+            target.mac9 = ko.observable(macInfoWhite[8]);

+            target.mac10 = ko.observable(macInfoWhite[9]);

+        } else if (info.ACL_mode == "2") {

+            macInfoBlack = info.wifi_mac_black_list.split(";");

+            target.mac1 = ko.observable(macInfoBlack[0]);

+            target.mac2 = ko.observable(macInfoBlack[1]);

+            target.mac3 = ko.observable(macInfoBlack[2]);

+            target.mac4 = ko.observable(macInfoBlack[3]);

+            target.mac5 = ko.observable(macInfoBlack[4]);

+            target.mac6 = ko.observable(macInfoBlack[5]);

+            target.mac7 = ko.observable(macInfoBlack[6]);

+            target.mac8 = ko.observable(macInfoBlack[7]);

+            target.mac9 = ko.observable(macInfoBlack[8]);

+            target.mac10 = ko.observable(macInfoBlack[9]);

+        }

+

+        target.save = filter_save;

+        //切换MAC过滤规则事件

+        target.ChangeHandler = function () {

+            $("#mac_filter_form").find(".error").hide();

+            $("#mac_filter_form").find("input[type=text]").show();

+            var info = service.getMacFilterInfo();

+            if (target.selectedAction() == "1") {

+                macInfoWhite = info.wifi_mac_white_list.split(";");

+                target.mac1(macInfoWhite[0]);

+                target.mac2(macInfoWhite[1]);

+                target.mac3(macInfoWhite[2]);

+                target.mac4(macInfoWhite[3]);

+                target.mac5(macInfoWhite[4]);

+                target.mac6(macInfoWhite[5]);

+                target.mac7(macInfoWhite[6]);

+                target.mac8(macInfoWhite[7]);

+                target.mac9(macInfoWhite[8]);

+                target.mac10(macInfoWhite[9]);

+            } else if (target.selectedAction() == "2") {

+                macInfoBlack = info.wifi_mac_black_list.split(";");

+                target.mac1(macInfoBlack[0]);

+                target.mac2(macInfoBlack[1]);

+                target.mac3(macInfoBlack[2]);

+                target.mac4(macInfoBlack[3]);

+                target.mac5(macInfoBlack[4]);

+                target.mac6(macInfoBlack[5]);

+                target.mac7(macInfoBlack[6]);

+                target.mac8(macInfoBlack[7]);

+                target.mac9(macInfoBlack[8]);

+                target.mac10(macInfoBlack[9]);

+            } else {

+                target.mac1("");

+                target.mac2("");

+                target.mac3("");

+                target.mac4("");

+                target.mac5("");

+                target.mac6("");

+                target.mac7("");

+                target.mac8("");

+                target.mac9("");

+                target.mac10("");

+            }

+        }

+        //检查WPS状态

+        target.checkSettings = function (ssid) {

+            var wifi_status = service.getWpsInfo();

+            if (wifi_status.wpsFlag == '1') {

+                showAlert('wps_on_info', function() {

+                    window.location.reload();

+                });

+                return true;

+            }

+            return false;

+        };

+

+        //设置多SSID开关

+        target.setMultiSSIDSwitch = function () {

+            if (target.checkSettings("switch")) {

+                return;

+            }

+

+            var setSwitch = setFilterSwitch;

+

+            var info = service.getStatusInfo();

+            if (config.HAS_MULTI_SSID && target.wifi_enable() == "1") {

+                if (target.multi_ssid_enable() == "1" && config.AP_STATION_SUPPORT && target.origin_ap_station_enable == "1") {

+                    if (!info.wifiStatus) {

+                        showConfirm("multi_ssid_enable_confirm", function () {

+                            setSwitch();

+                        });

+                    } else {

+                        showConfirm("multi_ssid_enable_confirm2", function () {

+                            setSwitch();

+                        });

+                    }

+                } else {

+                    if (!info.wifiStatus) {

+                        setSwitch();

+                    } else {

+                        showConfirm("wifi_disconnect_confirm2", function () {

+                            setSwitch();

+                        });

+                    }

+                }

+            } else {

+                setSwitch();

+            }

+

+			function setFilterSwitch() {

+                showLoading('waiting');

+                var filter_param = {};

+                filter_param.m_ssid_enable = target.multi_ssid_enable();

+                if (config.WIFI_SWITCH_SUPPORT) {

+                    filter_param.wifiEnabled = target.wifi_enable();

+                }

+                service.setWifiBasicMultiSSIDSwitch(filter_param, function (result) {

+                    if (result.result == "success") {

+                        if (!viaWifi) {

+                            addInterval(function () {

+                                var info = service.getWifiBasic();

+                                service.refreshAPStationStatus();

+                                if (info.wifi_enable == target.wifi_enable()) {

+                                    successOverlay();

+                                    clearTimer();

+                                    clearValidateMsg();

+                                    service.refreshAPStationStatus();

+                                    initialize();

+                                }

+                            }, 1000);

+                        } else {

+                            setTimeout(function () {

+                                successOverlay();

+                                setTimeout(function () {

+                                    window.location.reload();

+                                }, 1000);

+                                clearTimer();

+                                clearValidateMsg();

+                                service.refreshAPStationStatus();

+                                initialize();

+                            }, 15000);

+                        }

+                    } else {

+                        errorOverlay();

+                    }

+                });

+            }

+        };

+

+		function filter_save() {

+            var wifi_status = service.getWpsInfo();

+            if (wifi_status.wpsFlag == '1') {

+                showAlert('wps_on_info', function() {

+                    window.location.reload();

+                });

+                return true;

+            }

+

+            if (target.mac1() == undefined || target.mac1().indexOf(" ") >= 0) {

+                target.mac1("")

+            }

+            if (target.mac2() == undefined || target.mac2().indexOf(" ") >= 0) {

+                target.mac2("")

+            }

+            if (target.mac3() == undefined || target.mac3().indexOf(" ") >= 0) {

+                target.mac3("")

+            }

+            if (target.mac4() == undefined || target.mac4().indexOf(" ") >= 0) {

+                target.mac4("")

+            }

+            if (target.mac5() == undefined || target.mac5().indexOf(" ") >= 0) {

+                target.mac5("")

+            }

+            if (target.mac6() == undefined || target.mac6().indexOf(" ") >= 0) {

+                target.mac6("")

+            }

+            if (target.mac7() == undefined || target.mac7().indexOf(" ") >= 0) {

+                target.mac7("")

+            }

+            if (target.mac8() == undefined || target.mac8().indexOf(" ") >= 0) {

+                target.mac8("")

+            }

+            if (target.mac9() == undefined || target.mac9().indexOf(" ") >= 0) {

+                target.mac9("")

+            }

+            if (target.mac10() == undefined || target.mac10().indexOf(" ") >= 0) {

+                target.mac10("")

+            }

+

+            var mac_list = new Array(target.mac1(), target.mac2(), target.mac3(), target.mac4(), target.mac5(),

+                    target.mac6(), target.mac7(), target.mac8(), target.mac9(), target.mac10());

+            if (target.selectedAction() == "2" && info.client_mac_address != "" && $.inArray(info.client_mac_address, mac_list) != -1) {

+                showAlert('black_yourself_tip');

+                return false;

+            }

+            var list_sort = mac_list.sort(); //排序

+            for (var i = 0; i < list_sort.length - 1; i++) {

+                if (list_sort[i] != "" && list_sort[i] == list_sort[i + 1]) {

+                    showAlert('mac_repeat_tip');

+                    return false;

+                }

+            }

+            var string_maclist = "";

+            for (var i = 0; i < 10; i++) {

+                if (string_maclist == "") {

+                    string_maclist = mac_list[i];

+                } else {

+                    if (mac_list[i]) {

+                        string_maclist = string_maclist + ";" + mac_list[i];

+                    }

+                }

+            }

+            var filter_param = {};

+            filter_param.ACL_mode = target.selectedAction();

+            if (target.selectedAction() == "2") {

+                filter_param.wifi_mac_black_list = string_maclist;

+            } else if (target.selectedAction() == "1") {

+                filter_param.wifi_mac_white_list = string_maclist;

+            }

+            showLoading('waiting');

+            service.setMacFilter(filter_param, function (result) {

+                if (result.result == "success") {

+                    successOverlay();

+                } else {

+                    errorOverlay();

+                }

+            });

+        }

+    }

+

+    function bindContainer(filter_vm) {

+        var container = $('#container');

+        ko.cleanNode(container[0]);

+        ko.applyBindings(filter_vm, container[0]);

+

+        $('#frmWifiSwitch').validate({

+            submitHandler: function () {

+                filter_vm.setMultiSSIDSwitch();

+            }

+        });

+        $('#mac_filter_form').validate({

+            submitHandler: function () {

+                filter_vm.save();

+            },

+            rules: {

+                mac_1: 'mac_check',

+                mac_2: 'mac_check',

+                mac_3: 'mac_check',

+                mac_4: 'mac_check',

+                mac_5: 'mac_check',

+                mac_6: 'mac_check',

+                mac_7: 'mac_check',

+                mac_8: 'mac_check',

+                mac_9: 'mac_check',

+                mac_10: 'mac_check'

+            }

+        });

+    }

+    function initialize() {

+        var filter_vm = new macFilterViewModel();

+        bindContainer(filter_vm);

+

+        addTimeout(function () {

+            checkAccessMode();

+        }, 600);

+    }

+

+    return {

+        init: initialize

+    };

+});

+

+define("wifi_main","underscore jquery knockout set service CryptoJS".split(" "),

+    function (_, $, ko, config, service, CryptoJS) {

+

+    var securityModes = _.map(config.WIFI_WEP_SUPPORT ? config.AUTH_MODES_WEP : config.AUTH_MODES, function (item) {

+        return new Option(item.name, item.value);

+    });

+

+    function maxStationAccess(max) {

+        var showOption = [];

+        for (var i = 1; i <= max; i++) {

+            showOption.push(new Option(i, i));

+        }

+        return showOption;

+    }

+    //是否通过wifi接入

+    var viaWifi = false;

+    function checkAccessMode() {

+        service.getParams({

+            nv: 'user_ip_addr'

+        }, function (dataIp) {

+            service.getParams({

+                nv: 'station_list'

+            }, function (dataList) {

+                viaWifi = isWifiConnected(dataIp.user_ip_addr, dataList.station_list);

+            });

+        });

+    }

+

+    function WifiMainVM() {

+        var target = this;

+        var info = getWifiMain();

+

+        target.hasWifiSwitch = config.WIFI_SWITCH_SUPPORT;

+        target.hasMultiSSID = config.HAS_MULTI_SSID;

+        target.showIsolated = config.SHOW_WIFI_AP_ISOLATED;

+        target.hasAPStation = config.AP_STATION_SUPPORT;

+        target.hasWlanMacfilter = config.HAS_BLACK_AND_WHITE_FILTER;

+        target.hasWifiWep = config.WIFI_WEP_SUPPORT;

+        target.hasWifiWpa3 = config.WIFI_WAP3_SUPPORT;

+        target.hasWifiWpa23 = config.WIFI_WPA2_WAP3_SUPPORT;

+

+        var advanceInfo = service.getWifiAdvance();

+        target.adBand = ko.observable(advanceInfo.wifiBand);

+        target.adMode = ko.observable(advanceInfo.mode);

+        target.showQRSwitch = config.WIFI_SUPPORT_QR_CODE && config.WIFI_SUPPORT_QR_SWITCH;

+        target.showQR = ko.observable(info.show_qrcode_flag);

+        if (config.WIFI_SUPPORT_QR_SWITCH) {

+            target.showQRCode = ko.observable(config.WIFI_SUPPORT_QR_CODE && target.showQR());

+        } else {

+            target.showQRCode = ko.observable(config.WIFI_SUPPORT_QR_CODE);

+        }

+        if(config.WIFI_SUPPORT_QR_CODE){

+            target.qrcodeSrc = './pic/qrcode_ssid_wifikey.png?_=' + $.now();

+        } else {

+            target.qrcodeSrc = './pic/res_blacktrans.png';

+        }

+        target.origin_ap_station_enable = info.ap_station_enable;

+        target.wifi_enable = ko.observable(info.wifi_enable);

+

+        target.isShowSSIDInfoDiv = ko.observable(false);

+        if (config.WIFI_SWITCH_SUPPORT) {

+            if (info.wifi_enable == "1") {

+                target.isShowSSIDInfoDiv(true);

+            } else {

+                target.isShowSSIDInfoDiv(false);

+            }

+        } else {

+            target.isShowSSIDInfoDiv(true);

+        }

+

+        target.multi_ssid_enable = ko.observable(info.multi_ssid_enable);

+        target.origin_multi_ssid_enable = info.multi_ssid_enable;

+

+        target.maxStationNumber = ko.computed(function () {

+            return config.MAX_STATION_NUMBER;

+        });

+

+        target.modes = ko.observableArray(securityModes);

+        target.selectedMode = ko.observable(info.AuthMode);

+        target.passPhrase = ko.observable(info.passPhrase);

+        target.showPassword = ko.observable(false);

+        target.ssid = ko.observable(info.SSID);

+        target.broadcast = ko.observable(info.broadcast == '1' ? '1' : '0');

+        target.apIsolation = ko.observable(info.apIsolation == '1' ? '1' : '0');

+        target.cipher = info.cipher;

+        target.selectedStation = ko.observable(info.MAX_Access_num);

+        target.maxStations = ko.observableArray(maxStationAccess(info.MAX_Station_num));

+        target.encryptType = ko.observable(info.encryptType);

+        target.keyID = ko.observable(info.keyID);

+        target.wepPassword = ko.observable("");

+

+        target.m_modes = ko.observableArray(securityModes);

+        target.m_selectedMode = ko.observable(info.m_AuthMode);

+        target.m_passPhrase = ko.observable(info.m_passPhrase);

+        target.m_showPassword = ko.observable(false);

+        target.m_ssid = ko.observable(info.m_SSID);

+        target.m_broadcast = ko.observable(info.m_broadcast == '1' ? '1' : '0');

+        target.m_apIsolation = ko.observable(info.m_apIsolation == '1' ? '1' : '0');

+        target.m_cipher = info.m_cipher;

+        target.m_selectedStation = ko.observable(info.m_MAX_Access_num);

+        target.m_maxStations = ko.observableArray(maxStationAccess(info.MAX_Station_num));

+

+        target.getWepPassword = function () {

+            return target.keyID() == '3' ? info.Key4Str1 : (target.keyID() == '2' ? info.Key3Str1 : target.keyID() == '1' ? info.Key2Str1 : info.Key1Str1);

+        }

+        target.wepPassword(target.getWepPassword());

+        target.profileChangeHandler = function (data, event) {

+            $("#pwdWepKey").parent().find("label[class='error']").hide();

+            target.wepPassword(target.getWepPassword());

+            return true;

+        };

+

+        target.clear = function (option) {

+            if (option == "switch") {

+                target.multi_ssid_enable(info.multi_ssid_enable);

+                target.wifi_enable(info.wifi_enable);

+            } else if (option == "ssid2") {

+                target.m_selectedMode(info.m_AuthMode);

+                target.m_passPhrase(info.m_passPhrase);

+                target.m_ssid(info.m_SSID);

+                target.m_broadcast(info.m_broadcast == '1' ? '1' : '0');

+                target.m_cipher = info.m_cipher;

+                target.m_selectedStation(info.m_MAX_Access_num);

+                target.m_apIsolation(info.m_apIsolation == '1' ? '1' : '0');

+            } else if (option == "ssid1") {

+                target.selectedMode(info.AuthMode);

+                target.passPhrase(info.passPhrase);

+                target.ssid(info.SSID);

+                target.broadcast(info.broadcast == '1' ? '1' : '0');

+                target.cipher = info.cipher;

+                target.selectedStation(info.MAX_Access_num);

+                target.apIsolation(info.apIsolation == '1' ? '1' : '0');

+                if (config.WIFI_WEP_SUPPORT) {

+                    target.encryptType(info.encryptType);

+                    target.keyID(info.keyID);

+                    target.wepPassword(target.getWepPassword());

+                }

+            } else {

+                clearTimer();

+                clearValidateMsg();

+                initialize();

+            }

+        };

+

+        target.saveSSID1 = function () {

+            if (target.checkSettings("ssid1")) {

+                return;

+            }

+            if (!config.PASSWORD_ENCODE) {

+                var pwdRegex = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{8,32}');

+                if (!pwdRegex.test(target.passPhrase())) {

+                        showConfirm("password_note_too_low", function () {

+                            showConfirm('wifi_disconnect_confirm', function () {

+                            target.saveSSID1Action();

+                            return;

+                        });

+                        return;

+                    });

+                    return;

+                }

+            }

+            showConfirm('wifi_disconnect_confirm', function () {

+                target.saveSSID1Action();

+            });

+        };

+

+        target.saveSSID1Action = getSSID1Action;

+

+        target.saveSSID2 = function () {

+            if (target.checkSettings("ssid2")) {

+                return;

+            }

+            showConfirm('wifi_disconnect_confirm', function () {

+                target.saveSSID2Action();

+            });

+        };

+

+        target.saveSSID2Action = getSSID2Action;

+

+        //检测wps\最大接入数

+        target.checkSettings = function (ssid) {

+            var status = getWpsState();

+            if (ssid == "ssid1" || ssid == "ssid2") {

+                if (ssid == "ssid2") {

+                    var accessDevice = service.getStatusInfo().ssid2AttachedNum;

+                    if (parseInt(target.m_selectedStation()) < accessDevice) {

+                        showAlert('Extend_accessDevice');

+                        return true;

+                    }

+                } else {

+                    var accessDevice = service.getStatusInfo().ssid1AttachedNum;

+                    if (parseInt(target.selectedStation()) < accessDevice) {

+                        showAlert('Extend_accessDevice');

+                        return true;

+                    }

+                }

+            }

+

+            if (status.wpsFlag == '1') {

+                showAlert('wps_on_info', function() {

+                    window.location.reload();

+                });

+                return true;

+            }

+

+            if (info.multi_ssid_enable == "1" && config.HAS_MULTI_SSID) {

+                if ((ssid == "ssid2" && parseInt(target.m_selectedStation()) + parseInt(info.MAX_Access_num) > info.MAX_Station_num)

+                     || (ssid == "ssid1" && parseInt(target.selectedStation()) + parseInt(info.m_MAX_Access_num) > info.MAX_Station_num)) {

+                    showAlert({

+                        msg: 'multi_ssid_max_access_number_alert',

+                        params: info.MAX_Station_num

+                    });

+                    return true;

+                }

+            }

+

+            return false;

+        };

+

+        target.setMultiSSIDSwitch = function () {

+            if (target.checkSettings("switch")) {

+                return;

+            }

+

+            var setSwitch = function () {

+                showLoading('waiting');

+                var params = {};

+                params.m_ssid_enable = target.multi_ssid_enable();

+                if (config.WIFI_SWITCH_SUPPORT) {

+                    params.wifiEnabled = target.wifi_enable();

+                }

+                service.setWifiBasicMultiSSIDSwitch(params, function (result) {

+                    if (result.result == "success") {

+                        if (viaWifi) {

+                            setTimeout(hasApReloadVarWifi, 15000);

+                        } else {

+                            addInterval(hasApReload, 1000);

+                        }

+                    } else {

+                        errorOverlay();

+                    }

+                });

+            };

+

+            function hasApReloadVarWifi() {

+                successOverlay();

+                setTimeout(function () {

+                    window.location.reload();

+                }, 1000);

+                service.refreshAPStationStatus();

+                target.clear();

+            }

+            function hasApReload() {

+                var info = getWifiMain();

+                service.refreshAPStationStatus();

+                if (info.wifi_enable == target.wifi_enable()) {

+                    successOverlay();

+                    target.clear();

+                }

+            }

+

+            var info = service.getStatusInfo();

+            if (config.HAS_MULTI_SSID && target.wifi_enable() == "1") {

+                if (target.multi_ssid_enable() == "1" && config.AP_STATION_SUPPORT && target.origin_ap_station_enable == "1") {

+                    if (!info.wifiStatus) {

+                        showConfirm("multi_ssid_enable_confirm", function () {

+                            setSwitch();

+                        });

+                    } else {

+                        showConfirm("multi_ssid_enable_confirm2", function () {

+                            setSwitch();

+                        });

+                    }

+                } else {

+                    if (!info.wifiStatus) {

+                        setSwitch();

+                    } else {

+                        showConfirm("wifi_disconnect_confirm2", function () {

+                            setSwitch();

+                        });

+                    }

+                }

+            } else {

+                setSwitch();

+            }

+        };

+

+        //二维码显示事件

+        target.showQRHandler = function () {

+            var checkbox = $("#showQR:checked");

+            if (checkbox && checkbox.length == 0) {

+                target.showQR(true);

+            } else {

+                target.showQR(false);

+            }

+            target.showQRCode(config.WIFI_SUPPORT_QR_CODE && target.showQR());

+        };

+

+        //SSID2

+        target.m_showPasswordHandler = function () {

+            $("#m_passShow").parent().find(".error").hide();

+            var checkbox = $("#m_showPassword:checked");

+            if (checkbox && checkbox.length == 0) {

+                target.m_showPassword(true);

+            } else {

+                target.m_showPassword(false);

+            }

+        };

+        target.showPasswordHandler = function () {

+            $("#codeWPAKey").parent().find(".error").hide();

+            $("#pwdWepKey").parent().find(".error").hide();

+            var checkbox = $("#showPassword:checked");

+            if (checkbox && checkbox.length == 0) {

+                target.showPassword(true);

+            } else {

+                target.showPassword(false);

+            }

+        };

+

+        function getSSID2Action() {

+            showLoading('waiting');

+            var params = {};

+            params.m_AuthMode = target.m_selectedMode();

+            params.m_passPhrase = target.m_passPhrase();

+            params.m_SSID = target.m_ssid();

+            params.m_broadcast = target.m_broadcast();

+            params.m_station = target.m_selectedStation();

+            params.m_cipher = target.m_selectedMode() == "WPA2PSK" ? 1 : 2;

+            if (params.m_AuthMode == "WPA3Personal" || params.m_AuthMode == "WPA2WPA3") {

+                params.m_cipher = 1;

+            }

+            params.m_NoForwarding = target.m_apIsolation();

+            params.m_show_qrcode_flag = target.showQR() == true ? 1 : 0;

+            service.setWifiBasic4SSID2(params, function (result) {

+                if (result.result == "success") {

+                    if (viaWifi) {

+                        setTimeout(ssid2ReloadVarWifi, 15000);

+                    } else {

+                        addInterval(ssid2Reload, 1000);

+                    }

+                } else {

+                    errorOverlay();

+                }

+            });

+        }

+        function ssid2ReloadVarWifi() {

+            successOverlay();

+            setTimeout(function () {

+                window.location.reload();

+            }, 1000);

+            target.clear();

+        }

+        function ssid2Reload() {

+            var info = getWifiMain();

+            if (info.wifi_enable == "1") {

+                successOverlay();

+                target.clear();

+            }

+        }

+

+        function getSSID1Action() {

+

+            showLoading('waiting');

+            target.broadcast($("#broadcastCheckbox:checked").length > 0 ? '0' : '1');

+            target.apIsolation($("#apisolatedCheckbox:checked").length);

+            var ciphertext = "";

+            if (config.PASSWORD_ENCODE) {

+	        ciphertext = target.passPhrase();

+	    } else {

+                var kparam = service.getDeviceInfoLow();

+                var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);

+		var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);

+                ciphertext = CryptoJS.AES.encrypt(target.passPhrase(), tkey, {

+                    iv: tiv,

+                    mode: CryptoJS.mode.CBC,

+                    padding: CryptoJS.pad.ZeroPadding

+                    }).toString();

+	    }

+            var params = {};

+            params.AuthMode = target.selectedMode();

+            params.passPhrase = ciphertext;

+            params.SSID = target.ssid();

+            params.broadcast = target.broadcast();

+            params.station = target.selectedStation();

+            params.cipher = target.selectedMode() == "WPA2PSK" ? 1 : 2;

+            if (params.AuthMode == "WPA3Personal" || params.AuthMode == "WPA2WPA3") {

+                params.cipher = 1;

+            }

+            params.NoForwarding = target.apIsolation();

+            params.show_qrcode_flag = target.showQR() == true ? 1 : 0;

+            if (config.WIFI_WEP_SUPPORT) {

+                if (params.AuthMode == "WPAPSK" || params.AuthMode == "WPA2PSK" || params.AuthMode == "WPAPSKWPA2PSK" || params.AuthMode == "WPA3Personal" || params.AuthMode == "WPA2WPA3") {}

+                else if (params.AuthMode == "SHARED") {

+                    params.encryptType = "WEP";

+                } else {

+                    params.encryptType = target.encryptType();

+                }

+                params.wep_default_key = target.keyID();

+                params.wep_key_1 = info.Key1Str1;

+                params.wep_key_2 = info.Key2Str1;

+                params.wep_key_3 = info.Key3Str1;

+                params.wep_key_4 = info.Key4Str1;

+                var WEPSelect = '0';

+                if (target.wepPassword().length == '5' || target.wepPassword().length == '13') {

+                    WEPSelect = '1';

+                } else {

+                    WEPSelect = '0';

+                }

+                if (target.keyID() == '3') {

+                    params.wep_key_4 = target.wepPassword();

+                    params.WEP4Select = WEPSelect;

+                } else if (target.keyID() == '2') {

+                    params.wep_key_3 = target.wepPassword();

+                    params.WEP3Select = WEPSelect;

+                } else if (target.keyID() == '1') {

+                    params.wep_key_2 = target.wepPassword();

+                    params.WEP2Select = WEPSelect;

+                } else {

+                    params.wep_key_1 = target.wepPassword();

+                    params.WEP1Select = WEPSelect;

+                }

+            }

+

+            service.setWifiBasic(params, function (result) {

+                if (result.result == "success") {

+                    if (viaWifi) {

+                        setTimeout(ssid1ReloadVarWifi, 15000);

+                    } else {

+                        addInterval(ssid1Reload, 1000);

+                    }

+                } else {

+                    errorOverlay();

+                }

+            });

+        }

+        function ssid1ReloadVarWifi() {

+            successOverlay();

+            setTimeout(function () {

+                window.location.reload();

+            }, 1000);

+            target.clear();

+        }

+        function ssid1Reload() {

+            var info = getWifiMain();

+            if (info.wifi_enable == "1") {

+                successOverlay();

+                target.clear();

+            }

+        }

+

+    }

+

+    function getWpsState() {

+        return service.getWpsInfo();

+    }

+

+    function getWifiMain() {

+        return service.getWifiBasic();

+    }

+

+    function initialize() {

+        var container = $('#container');

+        ko.cleanNode(container[0]);

+        var vm = new WifiMainVM();

+        ko.applyBindings(vm, container[0]);

+        addTimeout(function () {

+            checkAccessMode();

+        }, 600);

+

+        if (config.WDS_SUPPORT) {

+            checkWifiStatusAccordingToWDS();

+        } else if (config.AP_STATION_SUPPORT) {

+            checkWifiStatus();

+        }

+

+        $('#frmSSID1').validate({

+            submitHandler: function () {

+                vm.saveSSID1();

+            },

+            rules: {

+                ssid: 'ssid',

+                pwdWepKey: {

+                    wifi_wep_password_check: true,

+                    wifi_password_check: true

+                },

+                txtWepKey: {

+                    wifi_wep_password_check: true,

+                    wifi_password_check: true

+                },

+                codeWPAKey: 'wifi_password_check',

+                txtWPAKey: 'wifi_password_check'

+            },

+            errorPlacement: function (error, element) {

+                var id = element.attr("id");

+                if (id == "codeWPAKey" || id == "txtWPAKey") {

+                    error.insertAfter("#lblshowWPAPassword");

+                } else if (id == "pwdWepKey" || id == "txtWepKey") {

+                    error.insertAfter("#lblShowWepPassword");

+                } else {

+                    error.insertAfter(element);

+                }

+            }

+        });

+        $('#frmSSID2').validate({

+            submitHandler: function () {

+                vm.saveSSID2();

+            },

+            rules: {

+                m_ssid: 'ssid',

+                m_pass: 'wifi_password_check',

+                m_passShow: 'wifi_password_check'

+            },

+            errorPlacement: function (error, element) {

+                var id = element.attr("id");

+                if (id == "m_pass" || id == "m_passShow") {

+                    error.insertAfter("#m_lblShowPassword");

+                } else if (id == "pass" || id == "passShow") {

+                    error.insertAfter("#lblShowPassword");

+                } else {

+                    error.insertAfter(element);

+                }

+            }

+        });

+        //表单提交函数、校验规则配置

+        $('#frmWifiSwitch').validate({

+            submitHandler: function () {

+                vm.setMultiSSIDSwitch();

+            }

+        });

+

+        $('#frmMultiSSID').validate({

+            submitHandler: function () {

+                vm.setMultiSSIDSwitch();

+            }

+        });

+

+    }

+

+    function checkWifiStatusAccordingToWDS() {

+        var info = service.getWdsInfo();

+        if (info.currentMode == "0") {

+            $('#frmWifiSwitch :input').each(function () {

+                $(this).prop("disabled", false);

+            });

+            $('#frmSSID1 :input').each(function () {

+                $(this).prop("disabled", false);

+            });

+            $('#frmSSID2 :input').each(function () {

+                $(this).prop("disabled", false);

+            });

+        } else {

+            $('#frmWifiSwitch :input').each(function () {

+                $(this).prop("disabled", true);

+            });

+            $('#frmSSID1 :input').each(function () {

+                $(this).prop("disabled", true);

+            });

+            $('#frmSSID2 :input').each(function () {

+                $(this).prop("disabled", true);

+            });

+        }

+    }

+    function checkWifiStatus() {

+        var info = service.getAPStationBasic();

+        if (info.ap_station_enable == "1") {

+            $('#frmMultiSSID :input').each(function () {

+                $(this).prop("disabled", true);

+            });

+        } else {

+            $('#frmMultiSSID :input').each(function () {

+                $(this).prop("disabled", false);

+            });

+        }

+    }

+

+    return {

+        init: initialize

+    };

+});

+

+define("wifi_sleep_mode","underscore jquery knockout set service".split(" "),

+    function (_, $, ko, config, service) {

+

+    //休眠方式

+    function getSleepMode() {

+        return service.getSleepMode();

+    }

+

+    //覆盖范围

+    function getWifiRange() {

+        return service.getWifiRange();

+    }

+

+    var sleepTime = _.map(config.SLEEP_MODES, function (item) {

+        return new Option(item.name, item.value);

+    });

+

+    function SleepModeViewMode() {

+        var target = this;

+

+        target.isCPE = config.PRODUCT_TYPE == 'CPE';

+        target.showTSWDiv = config.TSW_SUPPORT;

+        target.showSleepDiv = config.WIFI_SLEEP_SUPPORT;

+        target.hasUssd = config.HAS_USSD;

+        target.hasUpdateCheck = config.HAS_UPDATE_CHECK;

+        target.hasDdns = config.DDNS_SUPPORT;

+

+        target.modes = ko.observableArray(sleepTime);

+

+        var smInfo = getSleepMode();

+        target.selectedMode = ko.observable(smInfo.sleepMode);

+

+        var wifiRangeInfo = getWifiRange();

+        target.wifiRangeMode = ko.observable(wifiRangeInfo.wifiRangeMode);

+

+        target.setWifiRange = smSetWifiRange;

+

+        target.setWifiRangeAct = smSetWifiRangeAct;

+

+        target.setSleepMode = smSetSleepMode;

+

+        target.setSleepModeAct = smSetSleepModeAct;

+

+        var tsw = service.getTsw();

+        target.openEnable = ko.observable(tsw.openEnable == "" ? '0' : tsw.openEnable);

+        target.openH = ko.observable(tsw.openH);

+        target.openM = ko.observable(tsw.openM);

+        target.closeH = ko.observable(tsw.closeH);

+        target.closeM = ko.observable(tsw.closeM);

+        //定时休眠唤醒

+        target.saveTsw = smSaveTsw;

+

+        function smSetWifiRange() {

+            service.getWpsInfo({}, function (smInfo) {

+                if (smInfo.wpsFlag == '1') {

+                    showAlert('wps_on_info', function() {

+                        window.location.reload();

+                    });

+                } else if (smInfo.radioFlag == '0') {

+                    showAlert('wps_wifi_off');

+                } else {

+                    showConfirm('wifi_sleep_confirm', function () {

+                        showLoading('waiting');

+                        target.setWifiRangeAct();

+                    });

+

+                }

+            });

+        }

+        function smSetSleepModeAct() {

+            var params = {};

+            params.sleepMode = target.selectedMode();

+            service.setSleepMode(params, function (result) {

+                if (result.result != "success") {

+                    errorOverlay();

+                } else {

+                    successOverlay();

+                }

+            });

+        }

+

+        function smSetWifiRangeAct() {

+            var params = {};

+            params.wifiRangeMode = target.wifiRangeMode();

+            service.setWifiRange(params, function (result) {

+                if (result.result != "success") {

+                    errorOverlay();

+                } else {

+                    successOverlay();

+                }

+            });

+        }

+

+        function smSetSleepMode() {

+            showLoading('waiting');

+            service.getWpsInfo({}, function (info) {

+                if (info.wpsFlag == '1') {

+                    showAlert('wps_on_info', function() {

+                        window.location.reload();

+                    });

+                } else if (info.radioFlag == '0') {

+                    showAlert('wps_wifi_off');

+                } else {

+                    target.setSleepModeAct();

+                }

+            });

+        }

+        function smSaveTsw() {

+            if (target.openEnable() == '1') {

+                if (Math.abs((target.openH() * 60 + parseInt(target.openM(), 10)) - (target.closeH() * 60 + parseInt(target.closeM(), 10))) < 10) {

+                    showAlert('tsw_time_interval_alert');

+                    return false;

+                }

+                showLoading('waiting');

+                service.saveTsw({

+                    openEnable: target.openEnable(),

+                    closeEnable: target.openEnable(),

+                    openTime: leftInsert(target.openH(), 2, '0') + ':' + leftInsert(target.openM(), 2, '0'),

+                    closeTime: leftInsert(target.closeH(), 2, '0') + ':' + leftInsert(target.closeM(), 2, '0')

+                }, smShowRes, $.noop);

+            } else {

+                showLoading('waiting');

+                service.saveTsw({

+                    openEnable: target.openEnable(),

+                    closeEnable: target.openEnable()

+                }, smShowRes, $.noop);

+            }

+

+        }

+

+    }

+    function bindContainer(smVm) {

+        var container = $('#container');

+        ko.cleanNode(container[0]);

+        ko.applyBindings(smVm, container[0]);

+

+        $('#frmTsw').validate({

+            submitHandler: function () {

+                smVm.saveTsw();

+            },

+            errorPlacement: function (error, element) {

+                if (element.attr("name") == "closeM" || element.attr("name") == "closeH") {

+                    $("#closeErrorDiv").html(error);

+                } else if (element.attr("name") == "openM" || element.attr("name") == "openH") {

+                    $("#openErrorDiv").html(error);

+                } else {

+                    error.insertAfter(element);

+                }

+            }

+        });

+

+        $('#sleepModeForm').validate({

+            submitHandler: function () {

+                smVm.setSleepMode();

+            }

+        });

+

+        $('#wifiRangeForm').validate({

+            submitHandler: function () {

+                smVm.setWifiRange();

+            }

+        });

+

+    }

+    function initialize() {

+        var smVm = new SleepModeViewMode();

+        bindContainer(smVm);

+    }

+    function smShowRes(data) {

+        if (data && data.result == "success") {

+            successOverlay();

+        } else {

+            errorOverlay();

+        }

+    }

+

+    return {

+        init: initialize

+    };

+});

+

+define("wifi_station_info","underscore jquery knockout set service menu".split(" "),

+    function (_, $, ko, config, service, menu) {

+

+    var stationUtil = {

+        dealElement: function (showEdit, idx) {

+            if (idx != "all") {

+                if (!showEdit) {

+                    $("#edit_btn_" + idx + ",#hostname_txt_" + idx).show();

+                    $("#save_btn_" + idx + ",#cancel_btn_" + idx + ",#hostname_input_" + idx).hide();

+                } else {

+                    $("#edit_btn_" + idx + ",#hostname_txt_" + idx).hide();

+                    $("#save_btn_" + idx + ",#cancel_btn_" + idx + ",#hostname_input_" + idx).show();

+                }

+            } else {

+                $("input[id^='hostname_txt_'],a[id^='edit_btn_']").show();

+                $("input[id^='hostname_input_'],a[id^='cancel_btn_'],a[id^='save_btn_']").hide();

+            }

+        },

+        //根据MAC匹配主机名

+        getHostName: function (hostName, mac, hostNameList) {

+            var element_data = _.find(hostNameList, function (element_data) {

+                return element_data.mac == mac;

+            });

+            return element_data ? element_data.hostname : hostName;

+        },

+        //匹配黑名单列表和主机名

+        parseBlackString: function (macStr, hostnameStr) {

+            if (macStr == "") {

+                return [];

+            }

+            var tempMac = macStr.split(';');

+            var tempHostName = hostnameStr.split(';');

+            var result = [];

+            for (var i = 0; i < tempMac.length; i++) {

+                //var obj = {};

+                //obj.hostName = tempHostName[i];

+                //obj.macAddress = tempMac[i];

+                result.push({

+                    hostName: tempHostName[i],

+                    macAddress: tempMac[i]

+                });

+            }

+            return result;

+        }

+    };

+

+    function staInfoViewMode() {

+        var target = this;

+        var originalData = {

+            user_ip: '',

+            macList: '',

+            ACL_mode: 2, //黑白名单

+            hostnameList: ''

+        };

+        target.showCableDiv = config.PRODUCT_TYPE == 'CPE' && config.RJ45_SUPPORT;

+        target.supportBlock = config.STATION_BLOCK_SUPPORT;

+        var pcMenu = menu.findMenu('#parental_control');

+        target.showPCLink = pcMenu && pcMenu.length > 0 && config.HAS_PARENTAL_CONTROL;

+

+        target.deviceInfo = ko.observableArray([]);

+        target.cableDeviceInfo = ko.observableArray([]);

+        target.blackDevices = ko.observableArray([]);

+        target.blackDevicesMac = ko.computed(function () {

+            return _.map(target.blackDevices(), function (element_data) {

+                return element_data.macAddress;

+            });

+        });

+        target.showBlackDiv = ko.observable(config.HAS_BLACK_AND_WHITE_FILTER ? (originalData.ACL_mode == '2' ? true : false) : config.STATION_BLOCK_SUPPORT);

+

+        ko.computed(function () {

+            target.deviceInfo();

+            target.cableDeviceInfo();

+            target.blackDevices();

+            $("#station_info_div").translate();

+        }).extend({

+            notify: 'always',

+            throttle: 300

+        });

+

+        var hostNameList = service.getHostNameList({}).devices;

+        //获取WiFi已连接设备

+        target.fetchAttachedDevices = function (cb) {

+            service.getCurrentlyAttachedDevicesInfo({}, function (data) {

+                if (editingHostname) {

+                    return false;

+                }

+                target.deviceInfo(_.map(data.attachedDevices, function (element_data, idx) {

+                        element_data.idx = _.uniqueId('wireless_');

+                        element_data.type = 1;

+                        element_data.inBlackGroup = config.HAS_BLACK_AND_WHITE_FILTER && originalData.ACL_mode != '2' ? false : _.contains(target.blackDevicesMac(), element_data.macAddress);

+                        element_data.hostName = stationUtil.getHostName(element_data.hostName, element_data.macAddress, hostNameList);

+                        element_data.disableFlag = (config.HAS_BLACK_AND_WHITE_FILTER && originalData.ACL_mode != '2') || element_data.inBlackGroup || editingHostname;

+                        return element_data;

+                    }));

+                if (_.isFunction(cb)) {

+                    cb.apply(this);

+                }

+            });

+        };

+        //获取RJ45已连接设备

+        target.fetchAttachedCableDevices = function (cb) {

+            service.getAttachedCableDevices({}, function (data) {

+                if (editingHostname) {

+                    return false;

+                }

+                target.cableDeviceInfo(_.map(data.attachedDevices, function (element_data, idx) {

+                        element_data.idx = _.uniqueId('cable_');

+                        element_data.hostName = stationUtil.getHostName(element_data.hostName, element_data.macAddress, hostNameList);

+                        element_data.type = 2;

+                        return element_data;

+                    }));

+                if (_.isFunction(cb)) {

+                    cb.apply(this);

+                }

+            });

+        };

+

+        target.fetchBlacklist = function (cb) {

+            service.getMacFilterInfo({}, function (data) {

+                originalData.ACL_mode = data.ACL_mode;

+                originalData.user_ip = data.user_ip_addr;

+                originalData.hostnameList = data.wifi_hostname_black_list;

+                originalData.macList = data.wifi_mac_black_list;

+                target.showBlackDiv(config.HAS_BLACK_AND_WHITE_FILTER ? (originalData.ACL_mode == '2' ? true : false) : config.STATION_BLOCK_SUPPORT);

+                var blackDevices = stationUtil.parseBlackString(data.wifi_mac_black_list, data.wifi_hostname_black_list);

+                target.blackDevices(_.map(blackDevices, function (element_data, idx) {

+                        element_data.idx = _.uniqueId('black_');

+                        element_data.type = 3;

+                        element_data.hostName = stationUtil.getHostName(element_data.hostName, element_data.macAddress, hostNameList);

+                        return element_data;

+                    }));

+                if (_.isFunction(cb)) {

+                    cb.apply(this);

+                }

+            }, $.noop);

+        };

+        target.fetchBlacklist();

+        target.fetchAttachedDevices();

+        if (target.showCableDiv) {

+            target.fetchAttachedCableDevices();

+        }

+

+        var editingHostname = 0;

+        addInterval(function () {

+            if (editingHostname == 0) {

+                target.fetchAttachedDevices();

+            }

+        }, 3000);

+

+        if (target.showCableDiv) {

+            addInterval(function () {

+                if (editingHostname == 0) {

+                    target.fetchAttachedCableDevices();

+                }

+            }, 5000);

+        }

+        //WiFi已连接设备列表中屏蔽按钮事件 入黑名单

+        target.wirelessBlockHandler = stationBlockEvent;

+        //保存主机名事件

+        target.saveHostNameHandler = saveHostNameEvent;

+        //主机名修改按钮点击事件

+        target.editHostNameHandler = function (element_data) {

+            editingHostname++;

+            $("#hostname_input_" + element_data.idx).val(element_data.hostName);

+            stationUtil.dealElement(true, element_data.idx);

+            return false;

+        };

+        //取消编辑主机名事件

+        target.cancelEditHostNameHandler = function (element_data) {

+            stationUtil.dealElement(false, element_data.idx);

+            editingHostname--;

+        };

+        target.cancelAllEditHostNameHandler = function () {

+            stationUtil.dealElement(false, "all");

+            editingHostname = 0;

+        };

+        //从黑名单列表中移除

+        target.blacklistRemoveHandler = function (element_data) {

+            if (originalData.macList.indexOf(element_data.macAddress) == -1) {

+                return false;

+            }

+            if (editingHostname) {

+                target.cancelAllEditHostNameHandler();

+            }

+            showLoading('waiting');

+            var macArr = [];

+            var hostnameArr = [];

+            $.each(target.blackDevices(), function (i, n) {

+                if (n.macAddress != element_data.macAddress) {

+                    macArr.push(n.macAddress);

+                    hostnameArr.push(n.hostName);

+                }

+            });

+            var params = {

+                ACL_mode: '2', //originalData.ACL_mode

+                macFilteringMode: '2', //originalData.ACL_mode

+                wifi_hostname_black_list: hostnameArr.join(';'),

+                wifi_mac_black_list: macArr.join(';')

+            };

+            target.updateMacFilterList(params);

+        };

+        target.updateMacFilterList = function (params) {

+            service.setMacFilter(params, function (data) {

+                if (data.result == "success") {

+                    target.blackDevices([]);

+                    target.fetchBlacklist(function () {

+                        target.fetchAttachedDevices(function () {

+                            successOverlay();

+                        });

+                    });

+                }

+            }, function () {

+                errorOverlay();

+            });

+        };

+

+        function saveHostNameEvent(element_data) {

+            var $input = $("#hostname_input_" + element_data.idx);

+            var newHostname = $input.val();

+            if (newHostname.indexOf(" ") == 0 || newHostname.lastIndexOf(" ") == (newHostname.length - 1) || /[\*\$\[&:,;<>'"\\`\]¥]{1,32}/.test(newHostname)) {

+                showAlert('device_rename');

+                return false;

+            } else if (newHostname == '') {

+                $(".promptErrorLabel", "#confirm-message-container").text($.i18n.prop("required"));

+                var $closestTD = $input.closest('td').addClass('has-error');

+                addTimeout(function () {

+                    $closestTD.removeClass('has-error');

+                }, 5000);

+                showAlert('required');

+                return false;

+            }

+            showLoading('waiting');

+            element_data.hostName = newHostname;

+            service.editHostName({

+                hostname: element_data.hostName,

+                mac: element_data.macAddress

+            }, function () {

+                editingHostname = 0;

+                service.getHostNameList({}, function (data) {

+                    hostNameList = data.devices;

+                    if (element_data.type == 3) {

+                        target.fetchBlacklist(function () {

+                            hideLoading();

+                            successOverlay();

+                        });

+                    } else if (element_data.type == 2) {

+                        target.fetchAttachedCableDevices(function () {

+                            hideLoading();

+                            successOverlay();

+                        });

+                    } else if (element_data.type == 1) {

+                        target.fetchAttachedDevices(function () {

+                            hideLoading();

+                            successOverlay();

+                        });

+                    }

+                });

+            }, function () {

+                errorOverlay();

+            });

+        }

+

+        function stationBlockEvent(element_data) {

+            if (config.HAS_BLACK_AND_WHITE_FILTER && originalData.ACL_mode != '2') {

+                return false;

+            }

+            if (originalData.macList.split(';').length == 10) {

+                showAlert('black_list_max');

+                return false;

+            }

+            if (originalData.macList.indexOf(element_data.macAddress) != -1) {

+                return false;

+            }

+            if (element_data.ipAddress == originalData.user_ip) {

+                showAlert('black_yourself_tip');

+                return false;

+            }

+            if (editingHostname) {

+                target.cancelAllEditHostNameHandler();

+            }

+            showLoading('waiting');

+            var newHostnameList = originalData.hostnameList == '' ? element_data.hostName : element_data.hostName + ';' + originalData.hostnameList;

+            var newMacList = originalData.macList == '' ? element_data.macAddress : element_data.macAddress + ';' + originalData.macList;

+            var params = {

+                ACL_mode: '2',

+                wifi_hostname_black_list: newHostnameList,

+                wifi_mac_black_list: newMacList

+            };

+            target.updateMacFilterList(params);

+        }

+

+    }

+

+    function bindContainer(ws_vm) {

+        var container = $('#container')[0];

+        ko.cleanNode(container);

+        ko.applyBindings(ws_vm, container);

+    }

+    function initialize() {

+        var ws_vm = new staInfoViewMode();

+        bindContainer(ws_vm);

+    }

+

+    return {

+        init: initialize

+    };

+});

+

+define("wifi_wps","underscore jquery knockout set service".split(" "),

+    function (_, $, ko, config, service) {

+

+    var viaWifi = false;

+

+    function WpsViewMode() {

+        var target = this;

+        target.hasMultiSSID = config.HAS_MULTI_SSID;

+        target.hasAPStation = config.AP_STATION_SUPPORT;

+        target.hasWifiSwitch = config.WIFI_SWITCH_SUPPORT;

+        target.hasWlanMacfilter = config.HAS_BLACK_AND_WHITE_FILTER;

+

+        target.wpsType = ko.observable('');

+        target.wpsPin = ko.observable('');

+

+        var state = getWpsState();

+        target.origin_ap_station_enable = state.ap_station_enable;

+

+        target.wpsFlag = ko.observable(state.wpsFlag);

+        target.authMode = ko.observable(state.authMode);

+

+        target.radioFlag = ko.observable(state.radioFlag);

+        target.encrypType = ko.observable(state.encrypType);

+

+        target.mulOption = ko.observable(paintSSIDOption(state));

+        target.wpsSSID = ko.observable(getSSIDCurrWps(state));

+

+        var infoBasic = service.getWifiBasic();

+        target.wifi_enable = ko.observable(infoBasic.wifi_enable);

+

+        target.isShowSSIDInfoDiv = ko.observable(false);

+        if (config.WIFI_SWITCH_SUPPORT) { //软开关

+            if (infoBasic.wifi_enable == "1") {

+                target.isShowSSIDInfoDiv(true);

+            } else {

+                target.isShowSSIDInfoDiv(false);

+            }

+        } else {

+            target.isShowSSIDInfoDiv(true);

+        }

+        target.multi_ssid_enable = ko.observable(infoBasic.multi_ssid_enable);

+        target.origin_multi_ssid_enable = infoBasic.multi_ssid_enable;

+

+        target.save = wpa_save;

+

+        // if (state.wpsFlag != '0') {

+        //     target.wpsType(state.wpsType == 'PIN' ? 'PIN' : 'PBC');

+        // } else {

+        //     target.wpsType('');

+        // }

+            target.wpsType(state.wpsType == 'PIN' ? 'PIN' : 'PBC');

+

+        target.setMultiSSIDSwitch = function () {

+            if (target.checkSettings("switch")) {

+                return;

+            }

+

+            function wpsSetSwitch() {

+                showLoading('waiting');

+                var wps_param = {};

+                wps_param.m_ssid_enable = target.multi_ssid_enable();

+                if (config.WIFI_SWITCH_SUPPORT) {

+                    wps_param.wifiEnabled = target.wifi_enable();

+                }

+                service.setWifiBasicMultiSSIDSwitch(wps_param, function (result) {

+                    if (result.result == "success") {

+                        if (!viaWifi) {

+                            addInterval(wpsReload, 1000);

+                        } else {

+                            setTimeout(wpsReloadViaWifi, 15000);

+                        }

+                    } else {

+                        errorOverlay();

+                    }

+                });

+            }

+

+            var setSwitch = wpsSetSwitch;

+            var state = service.getStatusInfo();

+            if (target.wifi_enable() == "1" && config.HAS_MULTI_SSID) {

+                if (target.multi_ssid_enable() == "1" && config.AP_STATION_SUPPORT && target.origin_ap_station_enable == "1") {

+                    if (!state.wifiStatus) {

+                        showConfirm("multi_ssid_enable_confirm", function () {

+                            setSwitch();

+                        });

+                    } else {

+                        showConfirm("multi_ssid_enable_confirm2", function () {

+                            setSwitch();

+                        });

+                    }

+                } else {

+                    if (!state.wifiStatus) {

+                        setSwitch();

+                    } else {

+                        showConfirm("wifi_disconnect_confirm2", function () {

+                            setSwitch();

+                        });

+                    }

+                }

+            } else {

+                setSwitch();

+            }

+

+            function wpsReload() {

+                var state = service.getWifiBasic();

+                if (state.wifi_enable == target.wifi_enable()) {

+                    successOverlay();

+                    clearTimer();

+                    clearValidateMsg();

+                    service.refreshAPStationStatus();

+                    initialize();

+                }

+            }

+            function wpsReloadViaWifi() {

+                successOverlay();

+                setTimeout(function () {

+                    window.location.reload();

+                }, 1000);

+                clearTimer();

+                clearValidateMsg();

+                service.refreshAPStationStatus();

+                initialize();

+            }

+

+        };

+

+        target.checkSettings = function (ssid) {

+            var state = getWpsState();

+            if (state.wpsFlag == '1') {

+                showAlert('wps_on_info', function() {

+                    window.location.reload();

+                });

+                return true;

+            }

+            return false;

+        };

+

+        function wpa_save() {

+            var state = getWpsState();

+

+            if (state.radioFlag == '0') {

+                showAlert('wps_wifi_off');

+                return;

+            }

+

+            if (state.wpsFlag == '1') {

+                showAlert('wps_on_info', function() {

+                    window.location.reload();

+                });

+                return true;

+            }

+

+            if (target.wpsSSID() == "SSID1") {

+                var res = (state.AuthMode == "OPEN" && state.encrypType == "WEP")

+                 || (state.AuthMode == "SHARED" && state.encrypType == "WEP")

+                 || (state.AuthMode == "WPAPSK" && state.encrypType == "TKIP")

+                 || (state.AuthMode == "WPAPSK" && state.encrypType == "TKIPCCMP")

+                 || (state.AuthMode == "WPAPSK" && state.encrypType == "AES")

+                 || (state.AuthMode == "WPA2PSK" && state.encrypType == "TKIP")

+                 || (state.AuthMode == "WPAPSKWPA2PSK" && state.encrypType == "TKIP")

+                 || (state.AuthMode == "WPA3Personal")

+                 || (state.AuthMode == "WPA2WPA3");

+                if (res) {

+                    showAlert('wps_auth_open');

+                    return;

+                }

+            } else {

+                var resm = (state.m_AuthMode == "OPEN" && state.m_encrypType == "WEP")

+                 || (state.m_AuthMode == "SHARED" && state.m_encrypType == "WEP")

+                 || (state.m_AuthMode == "WPAPSK" && state.m_encrypType == "TKIP")

+                 || (state.m_AuthMode == "WPAPSK" && state.m_encrypType == "TKIPCCMP")

+                 || (state.m_AuthMode == "WPAPSK" && state.m_encrypType == "AES")

+                 || (state.m_AuthMode == "WPA2PSK" && state.m_encrypType == "TKIP")

+                 || (state.m_AuthMode == "WPAPSKWPA2PSK" && state.m_encrypType == "TKIP")

+                 || (state.m_AuthMode == "WPA3Personal")

+                 || (state.m_AuthMode == "WPA2WPA3");

+                if (resm) {

+                    showAlert('wps_auth_open');

+                    return;

+                }

+            }

+

+            var wpsSSID;

+            var wpsIndex;

+            if (target.wpsSSID() != "SSID1") {

+                wpsSSID = state.multiSSID;

+                wpsIndex = 2;

+            } else {

+                wpsSSID = state.ssid;

+                wpsIndex = 1;

+            }

+

+            var basic = service.getWifiBasic();

+            if (wpsSSID == basic.m_SSID && wpsIndex == 2) {

+                if (basic.m_broadcast == '1') {

+                    showAlert('wps_ssid_broadcast_disable');

+                    return;

+                }

+            } else if (wpsSSID == basic.SSID && wpsIndex == 1) {

+                if (basic.broadcast == '1') {

+                    showAlert('wps_ssid_broadcast_disable');

+                    return;

+                }

+            }

+

+            showLoading('waiting');

+            var wps_param = {};

+            wps_param.wpsType = target.wpsType();

+            wps_param.wpsSSID = wpsSSID;

+            wps_param.wpsIndex = wpsIndex;

+            wps_param.wpsPin = getWpsPin(target.wpsPin());

+

+            service.openWps(wps_param, function (result) {

+                if (result.result != "success") {

+                    errorOverlay();

+                } else {

+                    target.wpsPin('');

+                    clearValidateMsg();

+                    successOverlay();

+                }

+            });

+        }

+

+    }

+

+    function getWpsPin(value) {

+        if (value.length != 9) {

+            return value;

+        } else {

+            return value.substring(0, 4) + value.substring(5);

+        }

+    }

+

+    function getWpsState() {

+        return service.getWpsInfo();

+    }

+

+    function paintSSIDOption(info) {

+        var show_opt = [];

+        show_opt.push(new Option(info.ssid, "SSID1"));

+        if (info.ssidEnable == "1") {

+            show_opt.push(new Option(info.multiSSID, "SSID2"));

+        }

+        return show_opt;

+    }

+

+    //检查当前是否通过wifi登录webui

+    function checkAccessMode() {

+        service.getParams({

+            nv: 'user_ip_addr'

+        }, function (dataIp) {

+            service.getParams({

+                nv: 'station_list'

+            }, function (dataList) {

+                viaWifi = isWifiConnected(dataIp.user_ip_addr, dataList.station_list);

+            });

+        });

+    }

+    function bindContainer(wpsVm) {

+        var container = $('#container');

+        ko.cleanNode(container[0]);

+        ko.applyBindings(wpsVm, container[0]);

+

+        addTimeout(function () {

+            checkAccessMode();

+        }, 600);

+

+        $('#wpsForm').validate({

+            submitHandler: function () {

+                wpsVm.save();

+            },

+            rules: {

+                txtPin: {

+                    "wps_pin_validator": true

+                }

+            }

+        });

+

+        $('#frmWifiSwitch').validate({

+            submitHandler: function () {

+                wpsVm.setMultiSSIDSwitch();

+            }

+        });

+    }

+    function getSSIDCurrWps(info) {

+        if (info.ssid != info.multiSSID) {

+            return info.wpsSSID == info.multiSSID ? "SSID2" : "SSID1";

+        } else {

+            if (info.wifi_wps_index == '2') {

+                return "SSID2";

+            } else {

+                return "SSID1";

+            }

+        }

+    }

+    //视图初始化

+    function initialize() {

+        var wpsVm = new WpsViewMode();

+        bindContainer(wpsVm);

+    }

+

+    return {

+        init: initialize

+    };

+});

+

diff --git a/lynq/S300/ap/app/zte_webui/makefile b/lynq/S300/ap/app/zte_webui/makefile
new file mode 100755
index 0000000..8a78c71
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/makefile
@@ -0,0 +1,65 @@
+include $(zte_app_mak)

+

+all:

+	echo "zte_webui compile do nothing"

+

+clean:

+	echo "zte_webui clean do nothing"

+

+romfs:

+	@mkdir -p $(ROOTFS_DIR)/etc_ro/web

+	@cp -afvp $(APP_DIR)/zte_webui/*   $(ROOTFS_DIR)/etc_ro/web

+	find . -type f -name '*.js' | xargs -n1 -I {} java -jar $(YUICOMPRESSOR)  {} -o  $(ROOTFS_DIR)/etc_ro/web/{}

+	find . -type f -name '*.css' | xargs -n1 -I {} java -jar $(YUICOMPRESSOR)  {} -o  $(ROOTFS_DIR)/etc_ro/web/{}

+	find . -type f -name '*.html' | xargs -n1 -I {} sed -i 's/^[ \t]*//g' $(ROOTFS_DIR)/etc_ro/web/{}

+	find . -type f -name '*.html' | xargs -n1 -I {} sed -i 's/[ \t]*$$//g' $(ROOTFS_DIR)/etc_ro/web/{}

+	find . -type f -name '*.html' | xargs -n1 -I {} sed -i ":a;N;s/\r//g;ta" $(ROOTFS_DIR)/etc_ro/web/{}

+	find . -type f -name '*.html' | xargs -n1 -I {} sed -i ":a;N;s/\n//g;ta" $(ROOTFS_DIR)/etc_ro/web/{}

+ifeq ($(CONFIG_WEBUI_TYPE),CPE)

+	-rm -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set.js

+	-cp -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_cpe.js $(ROOTFS_DIR)/etc_ro/web/js/ext/set.js

+endif

+ifeq ($(CONFIG_WEBUI_TYPE),CPE_SW)	

+	-rm -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set.js

+	-cp -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_cpe_sw.js $(ROOTFS_DIR)/etc_ro/web/js/ext/set.js

+endif

+

+

+

+ifeq ($(PRJ_IS_MIN), yes)

+	-cp -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_min.js $(ROOTFS_DIR)/etc_ro/web/js/ext/set.js

+ifeq ($(CONFIG_WIFI_MODULE), xr819)

+	-cp -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_xr819.js $(ROOTFS_DIR)/etc_ro/web/js/ext/set.js

+endif

+ifeq ($(CONFIG_WIFI_MODULE), ssv6x5x)

+	-cp -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_ssv6x5x.js $(ROOTFS_DIR)/etc_ro/web/js/ext/set.js

+endif

+endif

+ifeq ($(CONFIG_WIFI_MODULE), aic8800)

+	-rm -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set.js

+	-cp -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_aic8800.js $(ROOTFS_DIR)/etc_ro/web/js/ext/set.js

+endif

+ifeq ($(CONFIG_WIFI_MODULE), realtek)

+	-rm -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set.js

+	-cp -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_realtek.js $(ROOTFS_DIR)/etc_ro/web/js/ext/set.js

+endif

+

+ifneq ($(CONFIG_USE_WEBUI_SECURITY),yes)

+	-rm -v $(ROOTFS_DIR)/etc_ro/web/js/3rd/crypto-js.js

+	-cp -v $(ROOTFS_DIR)/etc_ro/web/js/ext/crypto-js-null.js $(ROOTFS_DIR)/etc_ro/web/js/3rd/crypto-js.js

+	-sed -i 's/PASSWORD_ENCODE:false,//' $(ROOTFS_DIR)/etc_ro/web/js/ext/set.js

+endif

+	-rm -v $(ROOTFS_DIR)/etc_ro/web/js/ext/crypto-js-null.js

+	-rm -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_min.js

+	-rm -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_xr819.js

+	-rm -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_ssv6x5x.js

+	-rm -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_aic8800.js

+	-rm -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_cpe.js

+	-rm -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_cpe_sw.js

+	-rm -v $(ROOTFS_DIR)/etc_ro/web/makefile

+ifeq ($(CONFIG_USE_WEBUI_ZIP),yes)

+	(cd $(ROOTFS_DIR)/etc_ro && zip -r web.zip web)

+	(cd $(ROOTFS_DIR)/etc_ro && rm -rfv web)

+endif

+

+	

diff --git a/lynq/S300/ap/app/zte_webui/pic/res_logo_web.png b/lynq/S300/ap/app/zte_webui/pic/res_logo_web.png
new file mode 100755
index 0000000..659b3d5
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/pic/res_logo_web.png
Binary files differ
diff --git a/lynq/S300/ap/app/zte_webui/subpg/adm_lan.html b/lynq/S300/ap/app/zte_webui/subpg/adm_lan.html
new file mode 100755
index 0000000..43fdc65
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/subpg/adm_lan.html
@@ -0,0 +1,107 @@
+<div id="innerContainer">

+    <div class="row header-row">

+        <div class="col-xs-1">

+            <a href="#main">

+                <img alt="" src="pic/direct-back.png">

+            </a>

+        </div>

+        <div class="col-xs-11">

+            <div class="form-title">

+                <h1 data-trans='advanced_settings'></h1>

+            </div>

+        </div>

+    </div>

+<div class="row">

+<div class="col-xs-2">

+    <div class="nav_right">

+		<ul>

+			<li><a href="#wlan_sleep" data-trans="sleep_mode"></a></li>

+			<li class="active"><a href="#route_set" data-trans="router_setting"></a></li>

+			<li><a href="#filter_main" data-trans="firewall"></a></li>

+			<li data-bind="visible:hasUpdateCheck"><a href="#fota" data-trans="update_settings"></a></li>

+			<li data-bind="visible:hasUssd"><a href="#usat" data-trans="USSD"></a></li>

+			<li data-bind="visible:hasDdns"><a href="#dynamic_dns" data-trans="DDNS"></a></li>

+			<li><a href="#more" data-trans="others"></a></li>

+            <li><a data-trans="tr069" href="#tr069"></a></li>

+		</ul>

+	</div>

+</div>

+

+<div class="col-xs-10">

+<form id="frmLan" role="form">

+    <h3 class="form-title" data-trans="router_setting"></h3>

+    <div class="form-body margin-top-20">

+        <div class="content">

+            <div class="row form-group">

+                <label data-trans="ip_address" for="txtIpAddress" class="col-xs-4 side-right"></label>

+                <div class="col-xs-3">

+                    <input id="txtIpAddress" name="txtIpAddress" data-bind="value: ipAddress" maxlength="15" type="text" class="required form-control"/>

+                </div>

+            </div>

+            <div class="row form-group">

+                <label data-trans="subnet_mask" for="txtSubnetMask" class="col-xs-4 side-right"></label>

+                <div class="col-xs-3">

+                <input id="txtSubnetMask" name="txtSubnetMask" data-bind="value: subnetMask" maxlength="15"  type="text" class="required form-control"/>

+                </div>

+            </div>

+            <div class="row form-group" data-bind="visible: showMacAddress() && hasWifi()">

+                <label data-trans="mac_address" class="col-xs-4 side-right"></label>

+                <div class="col-xs-3">

+                <label id="txtMacAddress" data-bind="text: macAddress" class="label-content"></label>

+                </div>

+            </div>

+            <div class="row form-group">

+                <label class="col-xs-4 side-right" data-trans="dhcp_server"></label>

+                <div class="col-xs-8">

+                    <div class="row">

+                        <div class="col-xs-3">

+                            <input id="dhcpEnable" name="dhcpServer" data-bind="checked: dhcpServer,click: dhcpServerHandler" type="radio" value="1"/>

+                            <label data-trans="enable" for="dhcpEnable"></label>

+                        </div>

+                        <div class="col-xs-3">

+                            <input id="dhcpDisable" name="dhcpServer" data-bind="checked: dhcpServer,click: dhcpServerHandler" type="radio" value="0"/>

+                            <label data-trans="disable" for="dhcpDisable"></label>

+                        </div>

+                    </div>

+                </div>

+            </div>

+            <div data-bind='visible: dhcpServer() == "1"'>

+                <div class="row form-group">

+                    <label data-trans='dhcp_ip_pool' for="txtDhcpIpPoolStart" class="col-xs-4 side-right"></label>

+                    <div class="col-xs-8 form-inline">

+                        <input id='txtDhcpIpPoolStart' name="txtDhcpIpPoolStart" data-bind="value: dhcpStart" maxlength="15" type="text" class="required rangeInput form-control"/>

+                        -

+                        <input id='txtDhcpIpPoolEnd' name="txtDhcpIpPoolEnd" data-bind="value: dhcpEnd" maxlength="15" type="text" class="required rangeInput form-control"/>

+                    </div>

+                </div>

+                <div class="row form-group">

+                    <label for="txtDhcpLease" data-trans="dhcp_lease" class="col-xs-4 side-right"></label>

+                    <div class="col-xs-3">

+                        <div class="input-group">

+                            <input id="txtDhcpLease" name="txtDhcpLease" data-bind="value: dhcpLease" maxlength="5"  type="text" class="required form-control"/>

+                            <div data-trans="hours" id="leaseLabel" class="input-group-addon"></div>

+

+                        </div>

+                        <div id="errorHolder"></div>

+                    </div>

+                </div>

+            </div>

+        </div>

+        <div class="form-buttons">

+            <input type="submit" formmethod="post" data-trans="apply" class="btn btn-primary"/>

+        </div>

+        <div class="form-note">

+            <div class="notes-title">&nbsp;</div>

+            <ul class="notes-content">

+                <li data-trans="lan_note_ip_address"></li>

+                <li data-trans="lan_note_subnet_mask"></li>

+                <li data-trans="lan_note_dhcp_server_enable"></li>

+                <li data-trans="lan_note_dhcp_server_disable"></li>

+                <li data-trans="lan_note_dhcp_ip_pool"></li>

+                <li data-trans="lan_note_dhcp_lease_time"></li>

+            </ul></div>

+    </div>

+</form>

+    </div>

+    </div>

+</div>

diff --git a/lynq/S300/ap/app/zte_webui/subpg/adm_others.html b/lynq/S300/ap/app/zte_webui/subpg/adm_others.html
new file mode 100755
index 0000000..ba2cfcc
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/subpg/adm_others.html
@@ -0,0 +1,217 @@
+<div id="innerContainer">

+    <div class="row header-row">

+        <div class="col-xs-1">

+            <a href="#main">

+                <img alt="" src="pic/direct-back.png">

+            </a>

+        </div>

+        <div class="col-xs-11">

+            <div class="form-title">

+                <h1 data-trans='advanced_settings'></h1>

+            </div>

+        </div>

+    </div>

+    <div class="row">

+        <div class="col-xs-2">

+		    <div class="nav_right">

+		    <ul>

+				<li><a href="#wlan_sleep" data-trans="sleep_mode"></a></li>

+				<li><a href="#route_set" data-trans="router_setting"></a></li>

+				<li><a href="#filter_main" data-trans="firewall"></a></li>

+				<li data-bind="visible:hasUpdateCheck"><a href="#fota" data-trans="update_settings"></a></li>

+				<li data-bind="visible:hasUssd"><a href="#usat" data-trans="USSD"></a></li>

+				<li data-bind="visible:hasDdns"><a href="#dynamic_dns" data-trans="DDNS"></a></li>      

+				<li class="active"><a href="#more" data-trans="others"></a></li>

+				<li><a data-trans="tr069" href="#tr069"></a></li>

+			</ul>

+			</div>

+		</div>

+        <div class="col-xs-10">

+        <form id="frmRestoreReset">

+            <div class="form-body">

+                <h3 data-trans="others_restart_reset" class="form-title"></h3>

+				<div class="row form-group">

+                    <div data-trans="others_note_info" class="col-xs-12"></div>

+                </div>

+                <div class="row form-group">				    

+                    <div class="col-xs-12 align-right">

+                        <input data-trans="restart_button" data-bind="click: restart" type="button" class="btn btn-primary margin-right-20"/>

+                        <input data-trans="restore_button" data-bind="visible: currentUserInChildGroup() == false, click: restore" type="button" class="btn btn-primary margin-right-20"/>

+                    </div>

+                </div>

+            </div>

+        </form>

+

+		<!-- add by qumengjia for schedule restart start -->

+		<form id="frmScheduleRestart">

+			<div class="form-body">

+				<h3 data-trans="restart_schedule" class="form-title"></h3>

+				<div class="row form-group">

+					<label data-trans="enable_reboot_switch" class="col-xs-4 side-right"></label>

+					<div class="col-xs-8">

+						<div class="row">

+							<div class="col-xs-3">

+								<input id="restartEnable" data-bind="checked: scheduleSetting" type="radio" value="1"/>

+								<label data-trans="enable" for="restartEnable"></label>

+							</div>

+							<div class="col-xs-3">

+								<input id="restartDidable" data-bind="checked: scheduleSetting" type="radio" value="0"/>

+								<label data-trans="disable" for="restartDidable"></label>

+							</div>

+						</div>

+					</div>

+				</div>

+				<div data-bind='visible: scheduleSetting() == "1"' class="row form-group">

+					<label class="col-xs-4 side-right" data-trans='restart_schedule_time'></label>

+					<div class="col-xs-8">

+						<!-- <label data-trans="eyeryday" style="display:inline-block; width:auto; padding-right:0"></label> -->

+						<select id="restartHour" data-bind="options: scr_hours, value: scheduleHour, optionsText: 'text', optionsValue: 'value'" style="display:inline-block; width:auto; padding-right:5px; padding-left:5px" class="form-control"></select> 

+						<label data-trans="hour" for="restartHour" style="display:inline-block; width:auto; padding-right:0"></label>

+						<select id="restartMinute" data-bind="options: scr_minutes, value: scheduleMinute, optionsText: 'text', optionsValue: 'value'" style="display:inline-block; width:auto; padding-right:5px; padding-left:5px" class="form-control"></select> 

+						<label data-trans="minute" for="restartMinute" style="display:inline-block; width:auto; padding-right:0"></label>

+					</div>

+				</div>

+				<div class="form-buttons">

+					<input data-bind="click:scheduleRestart" data-trans="apply" type="submit" formmethod="post" class="btn btn-primary margin-right-20"/>

+				</div>

+			</div>

+		</form>

+		<!-- add by qumengjia for schedule restart end -->

+

+        <form id="frmtrunOffDevice" data-bind="visible: turnOffSupport">

+            <div class="form-body">

+                <h3 data-trans="others_turn_off" class="form-title"></h3>

+                <div class="row form-group">

+                    <div class="col-xs-12 align-right">

+                        <input data-bind="click: turnoff" data-trans="turnoff_button" type="button" class="btn btn-primary margin-right-20"/>

+                    </div>

+                </div>

+            </div>

+        </form>

+

+        <form data-bind="visible: fastbootSupport">

+            <div class="form-body">

+                <h3 class="form-title" data-trans="fastboot_setting"></h3>

+                <div class="row form-group">

+                    <label data-trans="fastboot_setting" class="col-xs-4 side-right"></label>

+                    <div class="col-xs-8">

+                        <div class="row">

+                            <div class="col-xs-3">

+                                <input id="fastEnable" name="fastboot" data-bind="checked: fastbootSetting, enable: fastbootEnableFlag" type="radio" value="1"/>

+                                <label data-trans="enable" for="fastEnable"></label>

+                            </div>

+                            <div class="col-xs-3">

+                                <input id="fastDisable" name="fastboot" data-bind="checked: fastbootSetting, enable: fastbootEnableFlag" type="radio" value="0"/>

+                                <label data-trans="disable" for="fastDisable"></label>

+                            </div>

+                        </div>

+                    </div>

+                </div>

+                <div class="row form-group">

+                    <div class="col-xs-12" data-trans="fastboot_note"></div>

+                </div>

+                <div class="row form-group">

+                    <div class="col-xs-12 align-right">

+                        <input data-bind="click: saveFastBoot, enable: fastbootEnableFlag" data-trans="apply" type="button" class="btn btn-primary margin-right-20"/>

+                    </div>

+                </div>

+            </div>

+        </form>

+

+

+		<form id="sntpForm" data-bind="visible: SNTPSupport">

+			<div class="form-body">

+				<h3 class="form-title">SNTP</h3>

+				<div class="content">

+					<div class="row form-group">

+						<label class="col-xs-4 side-right" data-trans='local_current_time'></label>

+						<div class="col-xs-8">

+							<span class="span3" data-bind="text: localTime"></span>

+							<span>&nbsp;</span>

+							<span id="weekday" data-bind="text: day"></span>

+						</div>

+					</div>

+					<div class="row form-group">

+						<label class="col-xs-4 side-right" data-trans='time_set_mode' for="sntpSetTimeMode"></label>

+						<div class="col-xs-4">

+							<select id="sntpSetTimeMode" class="form-control" data-transid="time_set_time" data-bind="options: timeSetModes, value: currentMode, optionsText: transOption('time_set_time'), optionsValue: 'value', event:{change: changeSetTimeMode}"></select>

+						</div>					

+					</div>

+					<div id="manualSetTime" data-bind="visible: isManualSetTime">

+						<div class="row form-group">

+							<label class="col-xs-4 side-right" data-trans='time_set_time_manual'></label>							

+

+							<div class="col-xs-8">

+									<select id="manualYear" data-bind="options: years, value: currentYear, optionsText: 'text', optionsValue: 'value', event:{change: initDateList}" style="display:inline-block; width:auto; padding-right:5px; padding-left:5px"  class="form-control"></select> 

+								    <label data-trans="year" for="manualYear" style="display:inline-block; width:auto; padding-right:0"></label>

+

+								    <select id="manualMonth" data-bind="options: months, value: currentMonth, optionsText: 'text', optionsValue: 'value', event: {change: initDateList}" style="display:inline-block; width:auto; padding-right:5px; padding-left:5px" class="form-control"></select> 

+								    <label data-trans="month" for="manualMonth" style="display:inline-block; width:auto; padding-right:0"></label>

+

+									<select id="manualDate" data-bind="options: dates, value: currentDate, optionsText: 'text', optionsValue: 'value'" style="display:inline-block; width:auto; padding-right:5px; padding-left:5px" class="form-control"></select> 

+								    <label data-trans="date" for="manualDate" style="display:inline-block; width:auto; padding-right:0"></label>

+

+									<select id="manualHour" data-bind="options: hours, value: currentHour, optionsText: 'text', optionsValue: 'value'" style="display:inline-block; width:auto; padding-right:5px; padding-left:5px" class="form-control"></select> 

+								    <label data-trans="hour" for="manualHour" style="display:inline-block; width:auto; padding-right:0"></label>

+

+									<select id="manualMinute" data-bind="options: minutes, value: currentMinute, optionsText: 'text', optionsValue: 'value'" style="display:inline-block; width:auto; padding-right:5px; padding-left:5px" class="form-control"></select> 

+									<label data-trans="minute" for="manualMinute" style="display:inline-block; width:auto; padding-right:0"></label>

+							</div>

+                        </div>						

+					</div>

+					<div id="autoSntpTime" data-bind="visible: isAutoSntpTime">

+						<div id="sntp_server0" class="row form-group">

+							<label data-trans='stnp_server1' for="sntp_server1_select" class="col-xs-4 side-right"></label>

+							<div class="col-xs-4">

+								<select id="sntp_server1_select" data-bind="options: serverList, value: currentServer0, optionsText: 'text', optionsValue: 'value', event: {change: changeServerSelect}" class="form-control"></select>

+							</div>

+							<div class="col-xs-4">

+							    <input id="sntp_other_server0" name="sntp_other_server0" data-bind="value:customServer0, visible:isOther0" type="text" class="required form-control"/>

+							</div>

+						</div>

+						<div id="sntp_server1" class="row form-group">

+							<label class="col-xs-4 side-right" data-trans='stnp_server2' for="stnp_server2_select"></label>

+							<div class="col-xs-4">

+								<select id="stnp_server2_select" data-bind="options: serverList, value: currentServer1, optionsText: 'text', optionsValue: 'value', event: {change: changeServerSelect}" class="form-control"></select>

+	                        </div>

+							<div class="col-xs-4">						

+    							<input id="sntp_other_server1" name="sntp_other_server1"  data-bind="value:customServer1, visible:isOther1" type="text" class="required form-control"/>

+							</div>

+						</div>

+						<div id="sntp_server2" class="row form-group">

+							<label data-trans='stnp_server3' for="stnp_server3_select" class="col-xs-4 side-right"></label>

+							<div class="col-xs-4">

+								<select id="stnp_server3_select" class="form-control" data-bind="options: serverList, value: currentServer2, optionsText: 'text', optionsValue: 'value', event: {change: changeServerSelect}"></select>

+							</div>

+							<div class="col-xs-4">

+								<input id="sntp_other_server2" name="sntp_other_server2" data-bind="value:customServer2, visible:isOther2" type="text" class="required form-control"/>

+							</div>

+						</div>

+						<div class="row form-group">

+							<label data-trans='time_zone' for="time_zone_select" class="col-xs-4 side-right"></label>

+							<div class="col-xs-4">

+								<select id="time_zone_select" data-bind="options: timeZones, value: currentTimeZone, optionsText: transOption('time_zone'), optionsValue: 'value'" data-transid="time_zone" class="form-control"></select>

+							</div>

+						</div>

+

+					</div>		

+				</div>

+				<div class="form-buttons">

+					<input data-bind="" data-trans="apply" type="submit" formmethod="post" class="btn btn-primary margin-right-20"/>

+				</div>

+			</div>

+		</form>

+

+        <div class="form-body">

+            <div class="content margin-top-20 line-height-30">

+                <div class="row">

+                    <a href="#pin_mode">

+                        <div data-trans="pin_management" class="col-xs-3 arrow-right">

+                        </div>

+                    </a>

+                </div>

+            </div>

+        </div>

+    </div>

+</div>

+</div>

diff --git a/lynq/S300/ap/app/zte_webui/subpg/firewall.html b/lynq/S300/ap/app/zte_webui/subpg/firewall.html
new file mode 100755
index 0000000..c11cf58
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/subpg/firewall.html
@@ -0,0 +1,70 @@
+<div id="innerContainer">

+    <div class="row header-row">

+        <div class="col-xs-1">

+            <a href="#main">

+                <img alt="" src="pic/direct-back.png">

+            </a>

+        </div>

+        <div class="col-xs-11">

+            <div class="form-title">

+                <h1 data-trans='advanced_settings'></h1>

+            </div>

+        </div>

+    </div>

+    <div class="row">

+        <div class="col-xs-2">

+			<div class="nav_right">

+				<ul>

+					<li><a data-trans="sleep_mode" href="#wlan_sleep"></a></li>

+					<li><a data-trans="router_setting" href="#route_set"></a></li>

+					<li class="active"><a data-trans="firewall" href="#filter_main"></a></li>

+					<li data-bind="visible:hasUpdateCheck"><a data-trans="update_settings" href="#fota"></a></li>

+					<li data-bind="visible:hasUssd"><a data-trans="USSD" href="#usat"></a></li>

+					<li data-bind="visible:hasDdns"><a data-trans="DDNS" href="#dynamic_dns"></a></li>

+					<li><a data-trans="others" href="#more"></a></li>

+                    <li><a data-trans="tr069" href="#tr069"></a></li>

+				</ul>

+			</div>

+		</div>

+

+    <div class="col-xs-10">

+        <div class="form-body">

+            <div class="content margin-top-20">

+                <div class="col-xs-4">

+                    <div class="row">

+                        <a href="#filter_port">

+                            <div data-trans="port_filter" class="line-height-40 arrow-right cursorhand"></div>

+                        </a>

+                    </div>

+                    <div class="row">

+                        <a href="#map_port">

+                            <div data-trans="port_map" class="line-height-40 arrow-right cursorhand"></div>

+                        </a>

+                    </div>

+                    <div class="row">

+                        <a href="#foward_port">

+                            <div data-trans="port_forward" class="line-height-40 arrow-right cursorhand"></div>

+                        </a>

+                    </div>

+                    <div data-bind="visible: hasUrlFilter" class="row">

+                        <a href="#filter_url">

+                            <div data-trans="url_filter" class="line-height-40 arrow-right cursorhand"></div>

+                        </a>

+                    </div>

+                    <div class="row">

+                        <a href="#universal_plug_and_play">

+                            <div data-trans="upnp" class="line-height-40 arrow-right cursorhand"></div>

+                        </a>

+                    </div>

+                    <div class="row">

+                        <a href="#demilitarized_zone">

+                            <div data-trans="dmz" class="line-height-40 arrow-right cursorhand"></div>

+                        </a>

+                    </div>

+                </div>

+            </div>

+        </div>

+    </div>

+    </div>

+</div>

+

diff --git a/lynq/S300/ap/app/zte_webui/subpg/ota_update.html b/lynq/S300/ap/app/zte_webui/subpg/ota_update.html
new file mode 100755
index 0000000..5217129
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/subpg/ota_update.html
@@ -0,0 +1,161 @@
+<div id="innerContainer">

+    <div class="row header-row">

+        <div class="col-xs-1">

+            <a href="#main">

+                <img alt="" src="pic/direct-back.png">

+            </a>

+        </div>

+        <div class="col-xs-11">

+            <div class="form-title">

+                <h1 data-trans='advanced_settings'></h1>

+            </div>

+        </div>

+    </div>

+    <div class="row">

+        <div class="col-xs-2">

+			<div class="nav_right">

+				<ul>

+					<li data-bind="visible: isDataCard"><a href="#demilitarized_zone" data-trans="dmz_setting"></a></li>

+					<li data-bind="visible: isDataCard"><a href="#pin_mode" data-trans="pin_management"></a></li>

+					<li data-bind="visible: !isDataCard"><a href="#wlan_sleep" data-trans="sleep_mode"></a></li>

+					<li data-bind="visible: !isDataCard"><a href="#route_set" data-trans="router_setting"></a></li>

+					<li data-bind="visible: !isDataCard"><a href="#filter_main" data-trans="firewall"></a></li>

+					<li data-bind="visible:hasUpdateCheck" class="active"><a href="#fota" data-trans="update_settings"></a></li>

+					<li data-bind="visible:hasUssd"><a href="#usat" data-trans="USSD"></a></li>

+					<li data-bind="visible:hasDdns"><a href="#dynamic_dns" data-trans="DDNS"></a></li>

+					<li data-bind="visible: !isDataCard"><a href="#more" data-trans="others"></a></li>

+                    <li><a data-trans="tr069" href="#tr069"></a></li>

+				</ul>

+			</div>

+		</div>

+

+<div class="col-xs-10">

+<form id="frmOTAUpdate" role="form" data-bind="visible: updateType() == 'mifi_fota'">

+     <!-- <h3 data-trans="ota_update_manual" class="form-title"></h3 --> 

+    <div class="form-body margin-top-20">

+        <!--div class="content">

+            <div class="row">

+                <div class="col-xs-6">

+                    <span data-trans="ota_last_update_check"></span>

+                    <span data-bind="text: lastCheckTime"></span>

+                </div>

+                <div class="col-xs-6 align-right">

+                    <input id="btnCheckNewVersion" data-bind="click:checkNewVersion" data-trans="ota_check_new_version" type="button" class="btn btn-primary margin-right-20"/>

+                </div>

+            </div>

+			<div class="form-note">

+                <div class="notes-title">&nbsp;</div>

+                <ul class="notes-content">

+                    <li data-trans="ota_check_new_version_desc"></li>

+                </ul>

+		    </div>

+        </div-->

+

+        <!--div class="form-title" data-trans='ota_update_manual'></div>

+        <div class="content">

+            <span class="paddingleft25" data-trans="ota_check_new_version_desc"></span>

+        </div>

+        <div class="form-buttons">

+            <input id="btnCheckNewVersion" type="button" class="btn btn-primary" data-trans="ota_check_new_version"

+                   data-bind="click:checkNewVersion"/>

+        </div>

+        <div class="form-title" data-trans='ota_update_setting'></div-->

+        <div class="content">

+			<!--

+            <h3 data-trans="ota_update_setting" class="form-title"></h3>

+            <div class="row">

+                <label data-trans="ota_auto_update_switch" class="col-xs-4 side-right"></label>

+                <div class="col-xs-8">

+                    <div class="row form-group">

+                        <div class="col-xs-3">

+                            <input id="auto_update_enable" name="updateMode" data-bind="checked: updateMode" type="radio" value="1"/>

+                            <label data-trans="enable" for="auto_update_enable"></label>

+                        </div>

+                        <div class="col-xs-3">

+                            <input id="auto_update_disable" name="updateMode" data-bind="checked: updateMode" type="radio" value="0"/>

+                            <label data-trans="disable" for="auto_update_disable"></label>

+                        </div>

+                    </div>

+                </div>

+            </div>

+            <div class="row form-group" data-bind="visible: false">

+                <label data-trans="ota_update_interval_day" for="selInterValDay" class="col-xs-4 side-right"></label>

+

+                <div class="col-xs-3">

+                    <select id="selInterValDay" name="selInterValDay" data-bind="value: updateIntervalDay" class="form-control">

+                        <option data-trans="ota_update_every_day" value="1"></option>

+                        <option data-trans="ota_update_15_day" value="15"></option>

+                        <option data-trans="ota_update_30_day" value="30"></option>

+                    </select>

+                </div>

+            </div>

+            <div class="row form-group" data-bind="visible: updateMode()=='1'">

+                <div class="col-xs-12 padding-top-10">

+                    <p class="checkbox" data-bind="css:{'checkbox_selected': allowRoamingUpdate()=='1'}, click: clickAllowRoamingUpdate"

+                       manualControl="true">

+                        <input id="chkUpdateRoamPermission" name="chkUpdateRoamPermission" data-bind="checked:allowRoamingUpdate()=='1'" type="checkbox" value="1"/>

+                    </p>

+                    <label data-trans="ota_update_roaming_remind" class="update_inline floatleft"></label>

+                </div>

+            </div>

+

+            <div class="form-buttons">

+                <input id="btnApply" data-trans="apply" type="submit" formmethod="post" class="btn btn-primary"/>

+            </div-->

+

+            <div class="row form-group">

+                <label data-trans="ota_manual_upgrade_url" class="col-xs-4 side-right"></label>

+                    <div class="col-xs-3">

+                        <input id="upgrade_url" type="text" size="128" data-bind="value:updateURL" class="required form-control">

+                    </div>

+            </div>

+            <div class="form-buttons">

+                <input id="btnOtaUpgApply" data-bind="click:ota_upgrade_apply" data-trans="download" type="submit" formmethod="post" class="btn btn-primary"/>

+            </div>

+

+            <!--div class="form-note">

+                <div class="notes-title">&nbsp;</div>

+                <ul class="notes-content">

+                    <li data-trans="fota_note1"></li>

+                </ul>

+		    </div-->

+		</div>

+

+	</div>

+</form>

+<!--form id="frmNativeUpdate" data-bind="visible: updateType() == 'mifi_local'" method="post" name="UploadFile" id="UploadFile" action="../../cgi-bin/upload.cgi" enctype="multipart/form-data" target="ifr"> 

+	<div class="form-body">

+		<h3 class="form-title" data-trans="software_upload"></h3>

+		<table style="width:100%">  

+			<input type="text" id="upfile" size="20" style="height:35px; width:200px; display:inline-block;" readonly />

+			<input type="button" class="btn btn-primary" data-trans='browse_btn' style="height:34px; width:81px;" />

+			<input id="fileName" class="form-control" type="file" name="fileName" style="margin-left: 15px;background-color:#E3E3E3;opacity:0;filter:alpha(opacity=0);position:absolute;left:0px; width:280px; display:inline-block;" /> 

+			<input class="btn btn-primary" id="fileuploadsubmit" type="submit" formmethod="post" data-trans="ota_title" style="float:right; margin-top:8px; margin-right: 20px;" /> 

+		</table>  

+		<iframe name="ifr" id="ifr" style="display:none;"></iframe>

+	</div>

+</form-->

+    <div id="uploadSection" data-bind="visible: updateType() == 'mifi_local'">

+        <h3 class="form-title" data-trans="software_upload"></h3>

+        <iframe id="fileUploadIframe" name="fileUploadIframe" frameborder="0" height="0" scrolling="no" style="height:0px;width:0px;" width="0"></iframe>

+        <form id="fileUploadForm" name="fileUploadForm" action="../../cgi-bin/upload/upload.cgi" enctype="multipart/form-data" method="post" target="fileUploadIframe">

+            <input id="fileField" name="filename" dir="ltr" maxlength="200" type="file"/>

+            <div class="fileUploadDiv">

+                <input id="fileUploadApplyBtn" name="fileUploadApplyBtn" data-trans="ota_title" type="button" onclick="fileUploadSubmitClickHandler();" class="btn btn-primary margin-left-5 margin-top-2"/>

+            </div>

+            <div class="clear"></div>

+        </form>

+    </div>

+	<form data-bind="visible: updateType() == 'mifi_local'">

+	    <div class="form-body">

+	    <div class="form-note">

+            <div class="notes-title">&nbsp;</div>

+            <ul class="notes-content">

+                <li data-trans="local_note"></li>

+            </ul>

+		</div>

+		</div>

+	</form>

+</div>

+</div>

+</div>

diff --git a/lynq/S300/ap/app/zte_webui/subpg/sms_set.html b/lynq/S300/ap/app/zte_webui/subpg/sms_set.html
new file mode 100755
index 0000000..3796934
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/subpg/sms_set.html
@@ -0,0 +1,75 @@
+<div id="innerContainer">

+    <div class="row header-row">

+        <div class="col-xs-1">

+            <a href="#main">

+                <img alt="" src="pic/direct-back.png">

+            </a>

+        </div>

+        <div class="col-xs-11">

+            <div class="form-title">

+                <h1 data-trans='sms_setting'></h1>

+            </div>

+        </div>

+    </div>

+    <div class="row">

+        <div class="col-xs-2">

+			<div class="nav_right">

+				<ul>

+					<li><a data-trans="device" href="#msg_main"></a></li>

+					<li><a data-trans="sim" href="#msg_sim"></a></li>

+					<li class="active"><a data-trans="setting" href="#msg_set"></a></li>

+				</ul>

+			</div>

+		</div>

+		<div class="col-xs-10">

+

+

+<form id='smsSettingForm'>

+    <div class="form-body">

+        <div class="content">

+		    <h3 data-trans="sms_setting" class="form-title"></h3>

+            <div class="row form-group">

+                <label data-trans='sms_validity' for='txtValidity' class="col-xs-3 side-right"></label>

+                <div class="col-xs-5">

+                    <select id="txtValidity" data-transid='sms_validity' data-bind="options: modes, value: selectedMode, optionsText: transOption('sms_validity'), optionsValue: 'value'" class="form-control"></select>

+                </div>

+            </div>

+            <div class="row form-group">

+                <label data-trans='center_number' for='txtCenterNumber' class="col-xs-3 side-right"></label>

+                <div class="col-xs-5">

+                    <input id='txtCenterNumber' data-bind="value: centerNumber" maxlength='18' name="txtCenterNumber" type="text" class="required form-control"/>

+                </div>

+            </div>

+            <div class="row form-group">

+                <label data-trans='delivery_report' class="col-xs-3 side-right"></label>

+                <div class="col-xs-5">

+                    <div class="row">

+                        <div class="col-xs-4">

+                            <input id="reportOn" data-bind="checked: deliveryReport" name="deliveryReport" type="radio" value="1"/>

+                            <label data-trans="enable" for="reportOn"></label>

+                        </div>

+                        <div class="col-xs-4">

+                            <input id="reportOff" data-bind="checked: deliveryReport" name="deliveryReport" type="radio" value="0"/>

+                            <label data-trans="disable" for="reportOff"></label>

+                        </div>

+                    </div>

+                </div>

+            </div>

+        </div>

+        <div class="form-buttons">

+            <input data-trans='apply' type="submit" formmethod="post" class="btn btn-primary"/>

+            <!--input type="button" class="btn" data-bind='click: clear' data-trans='cancel'/-->

+        </div>

+        <div class="form-note">

+            <div class="notes-title">&nbsp;</div>

+            <ul class="notes-content">

+                <li data-trans="sms_setting_note_validity"></li>

+                <li data-trans="sms_setting_note_center_number"></li>

+                <li data-trans="sms_setting_note_delivery_report"></li>

+            </ul>

+        </div>

+    </div>

+</form> 

+    </div>

+</div>

+</div>
\ No newline at end of file
diff --git a/lynq/S300/ap/app/zte_webui/subpg/tr069.html b/lynq/S300/ap/app/zte_webui/subpg/tr069.html
new file mode 100755
index 0000000..88310de
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/subpg/tr069.html
@@ -0,0 +1,119 @@
+<div id="innerContainer"></div>

+    <div class="row header-row">

+        <div class="col-xs-1"><a href="#main"><img alt="" src="pic/direct-back.png"></a></div>

+        <div class="col-xs-11">

+            <div class="form-title">

+                <h1 data-trans='advanced_settings'></h1>

+            </div>

+        </div>

+    </div><!-- 代表跳转不到当前页面的导航栏 -->

+    <div class="row">

+        <div class="col-xs-2">

+            <div class="nav_right">

+                <ul>

+                    <li><a data-trans="sleep_mode" href="#wlan_sleep"></a></li>

+                    <li><a data-trans="router_setting" href="#route_set"></a></li>

+                    <li><a data-trans="firewall" href="#filter_main"></a></li>

+                    <li data-bind="visible:hasUpdateCheck"><a data-trans="update_settings" href="#fota"></a></li>

+                    <li data-bind="visible:hasUssd"><a data-trans="USSD" href="#usat"></a></li>

+                    <li data-bind="visible:hasDdns"><a data-trans="DDNS" href="#dynamic_dns"></a></li>

+                    <li><a data-trans="others" href="#more"></a></li>

+                    <li class="active"><a data-trans="tr069" href="#tr069"></a></li>

+                </ul>

+            </div>

+        </div>

+        <div class="col-xs-10">

+            <div class="form-body margin-top-20">

+                <form id='frmTr069'>

+                    <h3 data-trans="tr069" class="form-title"></h3>

+                    <div class="content">

+                        <div class="row form-group">

+                            <label data-trans="cwmp_enaled" class="col-xs-4 side-right"></label>

+                            <div class="col-xs-8">

+                                <div class="row">

+                                    <div class="col-xs-3">

+                                        <input id="tr069Enable" data-bind="checked: cwmp_active" type="radio" value="1"/>

+                                        <label data-trans="enable" for="tr069Enable"></label>

+                                    </div>

+                                    <div class="col-xs-3">

+                                        <input id="tr069Didable" data-bind="checked: cwmp_active" type="radio" value="0"/>

+                                        <label data-trans="disable" for="tr069Didable"></label>

+                                    </div>

+                                </div>

+                            </div>

+                        </div>

+                        <div data-bind="visible:cwmp_active()==='1'">

+                            <div class="row form-group"><label data-trans="server_url" for="cwmp_acs_server_url" class="col-xs-4 side-right"></label>

+                                <div class="col-xs-3"><input id="cwmp_acs_server_url" name="cwmp_acs_server_url" data-bind="value: cwmp_acs_server_url" maxlength="255" type="text" class="required form-control" /></div>

+                            </div>

+                            <div class="row form-group"><label data-trans="server_username" class="col-xs-4 side-right" for='cwmp_acs_username'></label>

+                                <div class="col-xs-3"><input id="cwmp_acs_username" data-bind="value: cwmp_acs_username" name="cwmp_acs_username" maxlength="255" type="text" class="required form-control" /></div>

+                            </div>

+                            <div class="row form-group"><label data-trans="server_password" class="col-xs-4 side-right" for="cwmp_acs_password"></label>

+                                <div class="col-xs-3"><input name='cwmp_acs_password' id="cwmp_acs_password" maxlength="255" class="required form-control" data-bind="value: cwmp_acs_password" type="password" /></div>

+                            </div>

+                            <div class="row form-group"><label class="col-xs-4 side-right" data-trans="enable_cycle_reporting"></label>

+                                <div class="col-xs-8">

+                                    <div class="row">

+                                        <div class="col-xs-3"><input id="reportingEnable" name="reporting" data-bind="checked: cwmp_periodic_inform_active" type="radio" value="1" /><label data-trans="enable" for="reportingEnable"></label></div>

+                                        <div class="col-xs-3"><input id="reportingDisable" name="reporting" data-bind="checked: cwmp_periodic_inform_active" type="radio" value="0" /><label data-trans="disable" for="reportingDisable"></label></div>

+                                    </div>

+                                </div>

+                            </div>

+                            <div class="row form-group"><label data-trans="periodi_reporting_interval" class="col-xs-4 side-right" for="cwmp_periodic_inform_interval"></label>

+                                <div class="col-xs-3"><input name='cwmp_periodic_inform_interval' class="required form-control" min=20 max=86400 type="text" data-bind="value: cwmp_periodic_inform_interval,attr:{'disabled': cwmp_periodic_inform_active()==='1' ? false : true}" /></div>

+                            </div>

+                            <div class="row form-group"><label data-trans="cpe_username" class="col-xs-4 side-right"></label>

+                                <div class="col-xs-3"><input class="form-control" id="cwmp_conn_request_username" maxlength="255" name="cwmp_conn_request_username" type="text" data-bind="value: cwmp_conn_request_username" /></div>

+                            </div>

+                            <div class="row form-group"><label data-trans="cpe_password" class="col-xs-4 side-right"></label>

+                                <div class="col-xs-3"><input class="form-control" id='cwmp_conn_request_password' maxlength="255" name="cwmp_conn_request_password" data-bind="value: cwmp_conn_request_password" type="password" /></div>

+                            </div>

+                        </div>

+                        <div class="form-buttons"><input data-trans="apply" type="submit" formmethod="post" class="btn btn-primary" /></div>

+                    </div>

+                </form>

+                <!-- <form id='frmTrtun' id="frmTrtun" data-bind="visible:cwmp_active()==='1'" style="display:none">

+                    <h3 class="form-title">STUN</h3>

+                    <div class="content">

+                        <div class="row form-group"><label data-trans="stun_enable" class="col-xs-4 side-right"></label>

+                            <div class="col-xs-3"><label for="stumSwitchs" id="stumBtn">

+                                    <div class="stumBtn"></div>

+                                </label><input type="checkbox" id="stumSwitchs" class="inputCheck" data-bind="click:btn('stumBtn','stumSwitchs','cwmp_stun_active')"></div>

+                        </div>

+                        <div data-bind="visible:cwmp_stun_active()==='1'">

+                            <div class="row form-group"><label data-trans="stun_server_address" class="col-xs-4 side-right"></label>

+                                <div class="col-xs-3"><input id="cwmp_stun_server_addr" name="cwmp_stun_server_addr" data-bind="value: cwmp_stun_server_addr" maxlength="128" type="text" class="required form-control" /></div>

+                            </div>

+                            <div class="row form-group"><label data-trans="stun_server_port" class="col-xs-4 side-right" for="cwmp_stun_server_port"></label>

+                                <div class="col-xs-3"><input id="cwmp_stun_server_port" data-bind="value: cwmp_stun_server_port" max="65535" min="0" type="text" class="required form-control" name="cwmp_stun_server_port" /></div>

+                            </div>

+                            <div class="row form-group"><label data-trans="stun_username" class="col-xs-4 side-right"></label>

+                                <div class="col-xs-3"><input name='cwmp_stun_username' maxlength="255" class="form-control" name="cwmp_stun_username" data-bind="value: cwmp_stun_username" type="text" /></div>

+                            </div>

+                            <div class="row form-group"><label data-trans="stun_password" class="col-xs-4 side-right"></label>

+                                <div class="col-xs-3"><input name='cwmp_stun_password' maxlength="255" class="form-control" data-bind="value: cwmp_stun_password" type="password" /></div>

+                            </div>

+                            <div class="row form-group"><label data-trans="stun_min_keepalive_period" class="col-xs-4 side-right" for="cwmp_stun_min_keep_alive_interval"></label>

+                                <div class="col-xs-3"><input class="required form-control" id="cwmp_stun_min_keep_alive_interval" min=10 max=86400 name="cwmp_stun_min_keep_alive_interval" type="text" data-bind="value: cwmp_stun_min_keep_alive_interval" /></div>

+                            </div>

+                            <div class="row form-group"><label data-trans="stun_max_keepalive_period" class="col-xs-4 side-right" for="stperiod"></label>

+                                <div class="col-xs-3"><input class="required form-control" id="stperiod" min=10 max=86400 name="cwmp_stun_max_keep_alive_interval" type="text" data-bind="value: cwmp_stun_max_keep_alive_interval" /></div>

+                            </div>

+                            <div class="row form-group"><label for="cwmp_udp_notify_limit_num" data-trans="stun_udp_notfication_limit" class="col-xs-4 side-right"></label>

+                                <div class="col-xs-3"><input class="required form-control" id="cwmp_udp_notify_limit_num" min=5 max=86400 name="cwmp_udp_notify_limit_num" type="text" data-bind="value: cwmp_udp_notify_limit_num" /></div>

+                            </div>

+                            <div class="row form-group"><label data-trans="stun_udp_connection_request_address" class="col-xs-4 side-right"></label>

+                                <div class="col-xs-8"><span id="cwmp_udp_conn_req_addr" name="cwmp_udp_conn_req_addr" data-bind="text: cwmp_udp_conn_req_addr"></span></div>

+                            </div>

+                            <div class="row form-group"><label data-trans="stun_nat_detected" class="col-xs-4 side-right"></label>

+                                <div class="col-xs-8"><span id="cwmp_nat_detected_mark" name="cwmp_nat_detected_mark" data-bind="text: cwmp_nat_detected_mark"></span></div>

+                            </div>

+                            <div class="form-buttons"><input data-trans="apply" type="submit" formmethod="post" class="btn btn-primary" /></div>

+                        </div>

+                    </div>

+                </form> -->

+            </div>

+        </div>

+    </div>

+</div>
\ No newline at end of file
diff --git a/lynq/S300/ap/app/zte_webui/subpg/ussd.html b/lynq/S300/ap/app/zte_webui/subpg/ussd.html
new file mode 100755
index 0000000..b58f7d3
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/subpg/ussd.html
@@ -0,0 +1,84 @@
+<div id="innerContainer">

+    <div class="row header-row">

+        <div class="col-xs-1">

+            <a href="#main">

+                <img alt="" src="pic/direct-back.png">

+            </a>

+        </div>

+        <div class="col-xs-11">

+            <div class="form-title">

+                <h1 data-trans='advanced_settings'></h1>

+            </div>

+        </div>

+    </div>

+<div class="row">

+    <div class="col-xs-2">

+		<div class="nav_right">

+			<ul>

+			    <li><a data-trans="sleep_mode" href="#wlan_sleep"></a></li>

+				<li><a data-trans="router_setting" href="#route_set"></a></li>

+				<li><a data-trans="firewall" href="#filter_main"></a></li>

+				<li data-bind="visible:hasUpdateCheck"><a data-trans="update_settings" href="#fota"></a></li>

+				<li class="active"><a data-trans="USSD" href="#usat"></a></li>

+				<li data-bind="visible:hasDdns"><a data-trans="DDNS" href="#dynamic_dns"></a></li>

+				<li><a data-trans="others" href="#more"></a></li>

+                <li><a data-trans="tr069" href="#tr069"></a></li>

+			</ul>

+		</div>

+	</div>

+

+	<div class="col-xs-10">

+

+    <form id="frmUSSD">

+	<div class="form-body">

+	    <h3 data-trans="USSD" class="form-title"></h3>

+        <div id="USSD_send_div"  data-bind="visible: USSDLocation()==0" class="form-body margin-top-20">

+            <div class="content">

+                <div class="row form-group">

+                    <label data-trans="ussd_send_to" class="col-xs-4 side-right"></label>

+                    <div class="col-xs-3">

+                        <input id="USSD_send" type="text" size="20" data-bind="value:USSDSend,valueUpdate:'afterkeydown'" class="required form-control">

+                    </div>

+                </div>

+                <div class="form-buttons">

+                    <input id="sendToNet" type="button" data-trans='ussd_send' data-bind="disable:USSDSend().length<=0,css:{disabled:USSDSend().length<=0},click:sendToNet" class="btn btn-primary marginright10" />

+                    <!--input type="reset"  data-trans='ussd_cancel' data-bind="disable:USSDSend().length<=0,css:{disabled:USSDSend().length<=0},click:resetUSSD" id="cancelToNet" class="btn btn-primary"/-->

+                </div>

+            </div>

+        </div>

+        <div id="USSD_reply_div"  data-bind="visible: USSDLocation()==1" class="form-body margin-top-20">

+            <!--<div class="form-title" data-trans='ussd_contents'></div>!-->

+            <div class="content">

+                <div class="row form-group">

+                    <label data-trans="ussd_contents" class="col-xs-4 side-right"></label>

+                    <div class="col-xs-3">

+                        <textarea id="USSD_Content" rows="8" cols="50" readonly="readonly" name="USSD_Content"></textarea>

+                    </div>

+                </div>

+                <div class="form-buttons">

+                    <input type="button" data-trans='ussd_cancel' data-bind="click:noReplyCancel" class="btn btn-primary marginright10"/>

+                </div>

+                <div id="ussd_action" data-bind="visible: ussd_action()!=0">

+                    <div class="row form-group">

+                        <label class="col-xs-4 side-right" data-trans="ussd_reply_to"></label>

+                        <div class="col-xs-3">

+                            <input id="USSD_reply" type="text" name="USSD_reply" size="20" data-bind="value:USSDReply"  class="required form-control">

+                        </div>

+                    </div>

+                    <div class="form-buttons">

+                        <input type="button" data-trans='ussd_reply' data-bind="click:replyToNet" class="btn btn-primary marginright10"/>

+                    </div>

+                </div>

+            </div>

+        </div>

+        <div class="form-note">

+            <div class="notes-title">&nbsp;</div>

+            <ul class="notes-content">

+                <li data-trans="ussd_note1"></li>

+            </ul>

+        </div>

+	</div>

+	</form>

+    </div>

+    </div>

+</div>

diff --git a/lynq/S300/ap/app/zte_webui/subpg/wifi_sleep_mode.html b/lynq/S300/ap/app/zte_webui/subpg/wifi_sleep_mode.html
new file mode 100755
index 0000000..4706288
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/subpg/wifi_sleep_mode.html
@@ -0,0 +1,160 @@
+<div id="innerContainer">

+<div class="row header-row">

+    <div class="col-xs-1">

+        <a href="#main">

+            <img alt="" src="pic/direct-back.png">

+        </a>

+    </div>

+    <div class="col-xs-11">

+        <div class="form-title">

+            <h1 data-trans='advanced_settings'></h1>

+        </div>

+    </div>

+</div>

+<div class="row">

+    <div class="col-xs-2">

+		<div class="nav_right">

+		    <ul>

+            <li class="active"><a data-trans="sleep_mode" href="#wlan_sleep"></a></li>

+            <li><a data-trans="router_setting" href="#route_set"></a></li>

+            <li><a data-trans="firewall" href="#filter_main"></a></li>

+            <li data-bind="visible:hasUpdateCheck"><a data-trans="update_settings" href="#fota"></a></li>

+            <li data-bind="visible:hasUssd"><a data-trans="USSD" href="#usat"></a></li>

+			<li data-bind="visible:hasDdns"><a data-trans="DDNS" href="#dynamic_dns"></a></li>

+            <li><a data-trans="others" href="#more"></a></li>

+            <li><a data-trans="tr069" href="#tr069"></a></li>

+        </ul>

+	    </div>

+	</div>

+    <div class="col-xs-10">

+

+

+<div class="form-body margin-top-20">

+    <!--hide wifi range settings until sw implements it-->

+    <form id='wifiRangeForm'>

+        <h3 data-trans="wifi_range_settings" class="form-title"></h3>

+        <div class="content">

+            <div class="row">

+                <label data-trans='wifi_range' class="col-xs-3"></label>

+                <div class="col-xs-8">

+                    <input id='short_mode' data-bind="checked: wifiRangeMode" name="rangeGroup" type="radio" value="short_mode"/>

+                    <label data-bind="visible: !isCPE" data-trans='wifi_short_mode' for='short_mode'></label>

+                    <label data-bind="visible: isCPE" data-trans='wifi_des_short_mode' for='short_mode'></label>

+                </div>

+            </div>

+            <div class="row">

+                <label class="col-xs-3"></label>

+                <div class="col-xs-8">

+                    <input id='medium_mode' data-bind="checked: wifiRangeMode" name="rangeGroup" type="radio" value="medium_mode"/>

+                    <label data-trans='wifi_medium_mode' for='medium_mode'></label>

+                </div>

+            </div>

+            <div class="row">

+                <label class="col-xs-3"></label>

+                <div class="col-xs-8">

+                    <input id='long_mode' data-bind="checked: wifiRangeMode" name="rangeGroup" type="radio" value="long_mode"/>

+                    <label data-trans='wifi_long_mode' for='long_mode'></label>

+                </div>

+            </div>

+        </div>

+        <div class="form-buttons">

+            <input data-trans='apply' type="submit" formmethod="post" class="btn btn-primary"/>

+        </div>

+        <div class="form-note">

+            <div class="notes-title">&nbsp;</div>

+            <ul class="notes-content">

+                <li data-trans="wifi_range_note_range"></li>

+                <li class="no-style">

+                    <ul data-bind="visible: !isCPE">

+                        <li data-trans="wifi_range_note_short"></li>

+                        <li data-trans="wifi_range_note_medium"></li>

+                        <li data-trans="wifi_range_note_long"></li>

+                    </ul>

+                    <ul data-bind="visible: isCPE">

+                        <li data-trans="wifi_range_note_short_cpe"></li>

+                        <li data-trans="wifi_range_note_medium_cpe"></li>

+                        <li data-trans="wifi_range_note_long_cpe"></li>

+                    </ul>

+                </li>

+            </ul>

+        </div>

+    </form>

+    <form id="frmTsw" data-bind="visible: showTSWDiv">

+        <div class="form-body">

+            <h3 data-trans="time_sleep_wake_up" class="form-title"></h3>

+            <div class="content">

+                <div class="row form-group">

+                    <label data-trans="tsw_settings" class="col-xs-3 side-right"></label>

+                    <div class="col-xs-6">

+                        <div class="row">

+                            <div class="col-xs-4">

+                                <input id="tswEnable" data-bind="checked: openEnable" name="tswGrp" type="radio" value="1"/>

+                                <label data-trans="enable" for="tswEnable"></label>

+                            </div>

+                            <div class="col-xs-4">

+                                <input id="tswDisable" data-bind="checked: openEnable" name="tswGrp" type="radio" value="0"/>

+                                <label for="tswDisable" data-trans="disable"></label>

+                            </div>

+                        </div>

+                    </div>

+                </div>

+                <div data-bind="visible: openEnable() == '1'" class="row form-group">

+                    <div class="col-xs-3">

+                        <span data-trans="tsw_timer_on"></span>

+                    </div>

+                    <div class="col-xs-9">

+                        <div>

+                            <input id="openH" data-bind="value: openH" min="0" max="23" maxlength="2" name="openH" style="width: 27px;display:inline-block;padding: 5px 4px;" type="text" class="required form-control"> :

+                            <input id="openM" data-bind="value: openM" min="0" max="59" maxlength="2" name="openM" style="width: 27px;display:inline-block;padding: 5px 4px;" type="text" class="required form-control">

+                        </div>

+                    </div>

+                    <div id="openErrorDiv" class="col-xs-9 col-md-offset-3"></div>

+                </div>

+                <div data-bind="visible: openEnable() == '1'" class="row form-group">

+                    <div class="col-xs-3">

+                        <span data-trans="tsw_timer_off"></span>

+                    </div>

+                    <div class="col-xs-9">

+                        <input id="closeH" data-bind="value: closeH" min="0" max="23" maxlength="2" name="closeH" style="width: 27px;display:inline-block;padding: 5px 4px;" type="text" class="required form-control"> :

+                        <input id="closeM" data-bind="value: closeM" min="0" max="59" maxlength="2" name="closeM" style="width: 27px;display:inline-block;padding: 5px 4px;" type="text" class="required form-control">

+                    </div>

+                    <div id="closeErrorDiv" class="col-xs-9 col-md-offset-3"></div>

+                </div>

+            </div>

+            <div class="form-buttons">

+                <input data-trans="apply" type="submit" formmethod="post" class="btn btn-primary"/>

+            </div>

+            <div class="form-note">

+                <div class="notes-title">&nbsp;</div>

+                <ul class="notes-content">

+                    <li data-trans="tsw_note"></li>

+                    <li data-trans="tsw_note_on"></li>

+                    <li data-trans="tsw_note_off"></li>

+                </ul>

+            </div>

+        </div>

+    </form>

+    <form id='sleepModeForm' data-bind="visible: showSleepDiv">

+        <h3 data-trans='wifi_sleep' class="form-title"></h3>

+        <div class="content">

+            <div class="row">

+                <label data-trans='sleep_time' class="col-xs-3" for='mode'></label>

+                <div class="col-xs-4">

+                <select id="mode" data-bind="options: modes, value: selectedMode, optionsText: transOption('sleep_mode'), optionsValue: 'value'" data-transid='sleep_mode' class="form-control"></select>

+                </div>

+            </div>

+        </div>

+        <div class="form-buttons">

+            <input data-trans='apply' type="submit" formmethod="post" class="btn btn-primary"/>

+        </div>

+        <div class="form-note">

+            <div class="notes-title">&nbsp;</div>

+            <ul class="notes-content">

+                <li data-trans="wifi_sleep_note_info"></li>

+            </ul>

+        </div>

+    </form>

+</div>

+    </div>

+</div>

+</div>

diff --git a/lynq/S300/ap/app/zte_webui/subpg/wifi_wps.html b/lynq/S300/ap/app/zte_webui/subpg/wifi_wps.html
new file mode 100755
index 0000000..0a96aa6
--- /dev/null
+++ b/lynq/S300/ap/app/zte_webui/subpg/wifi_wps.html
@@ -0,0 +1,123 @@
+<div id="innerContainer">

+    <div class="row header-row">

+        <div class="col-xs-1">

+            <a href="#main">

+                <img alt="" src="pic/direct-back.png">

+            </a>

+        </div>

+        <div class="col-xs-11">

+            <div class="form-title form-title-multi">

+                <h1 data-trans='wifi_wireless_settings'></h1>

+                <p data-trans="wifi_main_sub_title"></p>

+            </div>

+        </div>

+    </div>

+    <div class="row">

+        <div class="col-xs-2">

+		    <div class="nav_right">

+				<ul data-bind="visible: isShowSSIDInfoDiv">

+					<li><a data-trans="multi_ssid_1" data-bind="attr:{'data-trans': hasMultiSSID ? 'multi_ssid_1':'ssid_title'}" href="#wlan_main"></a></li>

+					<li data-bind="visible: hasMultiSSID"><a data-trans="multi_ssid_2" href="#wlan_guset"></a></li>

+					<li class="active"><a data-trans="wps" href="#wlan_wps"></a></li>

+					<li data-bind="visible: hasAPStation"><a data-trans="ap_station" href="#wlan_station"></a></li>

+					<li><a data-trans="wifi_advance" href="#wlan_adv"></a></li>

+					<li data-bind="visible: hasWlanMacfilter"><a data-trans="mac_filter" href="#filter_mac"></a></li>

+				</ul>

+			</div>

+		</div>

+        <div class="col-xs-10">

+

+<div class="form-body">

+    <form id="frmWifiSwitch" role="form">

+        <div class="content margin-top-20">

+            <div data-bind="visible: hasWifiSwitch" class="row form-group">

+                <label data-trans="wifi_switch" class="col-xs-4 side-right"></label>

+                <div class="col-xs-6">

+                    <div class="row">

+                        <div class="col-xs-4">

+                            <input id="wifi_switch_enable"

+                                   data-bind="checked: wifi_enable" name="wifi_switch" type="radio" value="1"/>

+                            <label data-trans="enable" for="wifi_switch_enable"></label>

+                        </div>

+                        <div class="col-xs-4">

+                            <input id="wifi_switch_disable"

+                                   data-bind="checked: wifi_enable" name="wifi_switch" type="radio" value="0"/>

+                            <label data-trans="disable" for="wifi_switch_disable"></label>

+                        </div>

+                    </div>

+                </div>

+            </div>

+            <div data-bind="visible: wifi_enable() == '1' && hasMultiSSID" class="row form-group">

+                <label data-trans="multi_ssid_enable" class="col-xs-4 side-right"></label>

+                <div class="col-xs-6">

+                    <div class="row">

+                        <div class="col-xs-4">

+                            <input id="multi_ssid_switch_enable"

+                                   data-bind="checked: multi_ssid_enable" name="multi_ssid_switch" type="radio" value="1"/>

+                            <label data-trans="enable" for="multi_ssid_switch_enable"></label>

+                        </div>

+                        <div class="col-xs-4">

+                            <input id="multi_ssid_switch_disable"

+                                   data-bind="checked: multi_ssid_enable" name="multi_ssid_switch" type="radio" value="0"/>

+                            <label data-trans="disable" for="multi_ssid_switch_disable"></label>

+                        </div>

+                    </div>

+                </div>

+            </div>

+            <div data-bind="visible: hasWifiSwitch || (wifi_enable() == '1' && hasMultiSSID)" class="form-buttons">

+                <input id="wifi_switch_apply" data-trans='apply' type="submit" formmethod="post" class="btn btn-primary"/>

+                <!--input id="wifi_switch_cancel" type="button" class="btn-1 " data-bind='click: function(){clear("switch");}' data-trans='cancel'/-->

+            </div>

+        </div>

+    </form>

+

+    <div data-bind="visible: isShowSSIDInfoDiv" class="content">

+        <form id='wpsForm' role="form">

+	    <h3 data-bind="attr:{'data-trans': 'wps'}" class="form-title"></h3>

+        <div data-bind="visible: hasMultiSSID" class="row form-group">

+            <label data-trans='ssid_title' for="multiSSID" class="col-xs-4 side-right"></label>

+            <div class="col-xs-4">

+                <select id="multiSSID" data-bind="options: mulOption, value: wpsSSID, optionsValue: 'value', optionsText: 'text'" class="valid form-control">

+				</select>

+            </div>

+        </div>

+		<!-- <div class="row form-group">

+            <label data-trans="wps" class="col-xs-4 side-right"></label>

+            <div class="col-xs-6">

+                <div class="row">

+                    <div class="col-xs-4">

+                        <input id="pinMode" data-bind="checked: wpsType" name="wpsMode" type="radio" value="PIN"/>

+                        <label data-trans="wps_pin" for="pinMode"></label>

+                    </div>

+                    <div class="col-xs-6">

+                        <input id="txtPin" data-bind="value: wpsPin, enable: wpsType() == 'PIN', valueUpdate: 'keypress'" maxlength="9" name="txtPin" type="text" class="required margin-left-5  form-control"/>

+                    </div>

+                </div>

+            </div>

+        </div> -->

+        <div class="row form-group">

+            <label data-trans="wps" class="col-xs-4 side-right"></label>

+            <label class="col-xs-4 side-right"></label>

+            <div class="col-xs-6">

+                <input id="pbcMode" data-bind="checked: wpsType" name="wpsMode" type="radio" value="PBC"/>

+                <label data-trans="wps_pbc" for="pbcMode"></label>

+            </div>

+        </div>

+        <div class="form-buttons">

+            <input data-bind="enable: wpsType() != '', css:{disabled: wpsType() == ''}" class="btn btn-primary" data-trans='apply' type="submit" formmethod="post"/>

+        </div>

+        <div class="form-note">

+            <div class="notes-title">&nbsp;</div>

+            <ul class="notes-content">

+                <li data-trans="wps_note_all"></li>

+                <!-- <li data-trans="wps_note_pin"></li> -->

+                <li data-trans="wps_note_pbc"></li>

+                <li data-trans="wps_note_wait"></li>

+            </ul>

+        </div>

+        </form>

+    </div>

+</div>

+    </div>

+</div>

+</div>

diff --git a/lynq/S300/ap/lib/libsoftap/netapi.c b/lynq/S300/ap/lib/libsoftap/netapi.c
new file mode 100755
index 0000000..fc3a67d
--- /dev/null
+++ b/lynq/S300/ap/lib/libsoftap/netapi.c
@@ -0,0 +1,607 @@
+/**
+ * @file Netapi.c
+ * @brief Implementation of Sanechips
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author linxu Gebin
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <syslog.h>
+#include <sys/klog.h>
+#include <sys/msg.h>
+#include <sys/socket.h>
+#include <linux/sockios.h>
+#include <sys/un.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include "softap_api.h"
+#include <net/if.h>
+
+/************************ ÍøÂç½Ó¿Ú ************************/
+
+
+
+//¸ù¾ÝÍøÂçÉ豸Ãû»ñÈ¡¶ÔÓ¦µÄÉ豸ID,°´ÕÕÓÅÏȼ¶ÓëNVÖеÄÉ豸Ãû½øÐÐÆ¥Å䣬ʧ°Ü·µ»Ø-1
+int getDevId_byname(char *dev_name)
+{
+	char ps_wan[NETIF_NAME_LEN] = {0};
+	char psext_wan1[NETIF_NAME_LEN] = {0};
+	char psext_wan2[NETIF_NAME_LEN] = {0};
+	char psext_wan3[NETIF_NAME_LEN] = {0};
+	char psext_wan4[NETIF_NAME_LEN] = {0};
+	char psext_wan5[NETIF_NAME_LEN] = {0};
+	char psext_wan6[NETIF_NAME_LEN] = {0};
+	char psext_wan7[NETIF_NAME_LEN] = {0};
+	char psext_wan8[NETIF_NAME_LEN] = {0};
+	char swwanstr[NETIF_NAME_LEN] = {0};
+	char swlanstr[NETIF_NAME_LEN] = {0};
+	char eth_wan[NETIF_NAME_LEN] = {0};
+	char wifi_wan[NETIF_NAME_LEN] = {0};
+	char eth_lan[NETIF_NAME_LEN] = {0};
+	char wifi_lan[NETIF_NAME_LEN] = {0};
+	char usb_lan[NETIF_NAME_LEN] = {0};
+	char sw_name[NV_NAME_LEN] = {0};
+	char lan_enable[NV_NAME_LEN] = {0};
+	printf("netapi:getDevId_byname start!dev_name=%s\n", dev_name);
+
+	//ȱʡÍâÍø¿ÚΪ¿ÕʱºòÒ²¸øÖ÷¿Ø·¢ÏûÏ¢£¬add by zpm 20160628 begin
+	if (strlen(dev_name) == 0) {
+		return NO_DEV;
+	}
+	//ȱʡÍâÍø¿ÚΪ¿ÕʱºòÒ²¸øÖ÷¿Ø·¢ÏûÏ¢£¬add by zpm 20160628 end
+
+	cfg_get_item("pswan", ps_wan, sizeof(ps_wan));
+	cfg_get_item("ps_ext1", psext_wan1, sizeof(psext_wan1));
+	cfg_get_item("ps_ext2", psext_wan2, sizeof(psext_wan2));
+	cfg_get_item("ps_ext3", psext_wan3, sizeof(psext_wan3));
+	cfg_get_item("ps_ext4", psext_wan4, sizeof(psext_wan4));
+	cfg_get_item("ps_ext5", psext_wan5, sizeof(psext_wan1));
+	cfg_get_item("ps_ext6", psext_wan6, sizeof(psext_wan2));
+	cfg_get_item("ps_ext7", psext_wan7, sizeof(psext_wan3));
+	cfg_get_item("ps_ext8", psext_wan8, sizeof(psext_wan4));
+	cfg_get_item("wifiwan", wifi_wan, sizeof(wifi_wan));
+	cfg_get_item("swwanstr", swwanstr, sizeof(swwanstr));
+	cfg_get_item("swlanstr", swlanstr, sizeof(swlanstr));
+	cfg_get_item("ethwan", eth_wan, sizeof(eth_wan));
+	cfg_get_item("ethlan", eth_lan, sizeof(eth_lan));
+	cfg_get_item("wifilan", wifi_lan, sizeof(wifi_lan));
+	cfg_get_item("usblan", usb_lan, sizeof(usb_lan));
+	cfg_get_item("sw", sw_name, sizeof(sw_name));
+	cfg_get_item("LanEnable", lan_enable, sizeof(lan_enable));
+
+	if (!strncmp(dev_name, ps_wan, strlen(dev_name)))
+		return PS_NET_DEV;
+	if ((0 != strcmp(lan_enable, "0")) && !strncmp(dev_name, usb_lan, strlen(dev_name)))
+		return USB_LAN_DEV;
+	if (!strncmp(dev_name, psext_wan1, strlen(dev_name)))
+		return PS_EXT_DEV1;
+	if (!strncmp(dev_name, psext_wan2, strlen(dev_name)))
+		return PS_EXT_DEV2;
+	if (!strncmp(dev_name, psext_wan3, strlen(dev_name)))
+		return PS_EXT_DEV3;
+	if (!strncmp(dev_name, psext_wan4, strlen(dev_name)))
+		return PS_EXT_DEV4;
+	if (!strncmp(dev_name, psext_wan5, strlen(dev_name)))
+		return PS_EXT_DEV5;
+	if (!strncmp(dev_name, psext_wan6, strlen(dev_name)))
+		return PS_EXT_DEV6;
+	if (!strncmp(dev_name, psext_wan7, strlen(dev_name)))
+		return PS_EXT_DEV7;
+	if (!strncmp(dev_name, psext_wan8, strlen(dev_name)))
+		return PS_EXT_DEV8;
+	//µ±½öÒ»¸öRJ45Íø¿Úʱ£¬Ê¼ÖÕµ±ÍâÍø¿ÚÓã¬ÔÙ¼ÓÉÏeth_type£¬¿ÉÒÔʵÏÖÄÚÍø¹¦ÄÜ
+	if (!strncmp(dev_name, eth_wan, strlen(dev_name)) || !strncmp(dev_name, swwanstr, strlen(dev_name)))
+		return RJ45_WAN_DEV;
+	//µ±´æÔÚÁ½¸öRJ45Íø¿Úʱ£¬ÔÚ´ËÉèÖÃÒ»¸ö¹Ì¶¨µÄÄÚÍøRJ45Íø¿Ú
+	if (!strncmp(dev_name, eth_lan, strlen(dev_name)) || !strncmp(dev_name, swlanstr, strlen(dev_name)))
+		return RJ45_LAN_DEV;
+	if (!strncmp(dev_name, wifi_wan, strlen(dev_name)))
+		return WIFI_WAN_DEV;
+	if (!strncmp(dev_name, wifi_lan, strlen(dev_name)))
+		return WIFI_LAN_DEV;
+
+	return -1;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º set_pswanstate
+* ¹¦ÄÜÃèÊö£º ÉèÖÃpsÍøÂçÉ豸IPv6״̬NVÖµ
+* ²ÎÊý˵Ã÷£º c_id(IN) :PDP¼¤»îµÄc_id
+*            state(IN):ÍøÂçÉ豸״̬
+* ·µ »Ø Öµ£º
+* ÆäËü˵Ã÷£º
+**************************************************************************/
+
+static void set_pswan_v6state(int c_id, int state)
+{
+	char ps_wan[NV_NAME_LEN] = {0};
+	char pswan_state[NETIF_NAME_LEN] = {0};
+
+	cfg_get_item("pswan", ps_wan, sizeof(ps_wan));
+
+	snprintf(pswan_state, sizeof(pswan_state), "%s%d_ipv6_state", ps_wan, c_id);
+
+	if (state == DEV_STATE_WORKING) {
+		cfg_set(pswan_state, "working");
+		return;
+	}
+
+	if (state == DEV_STATE_CONNECT) {
+		cfg_set(pswan_state, "connect");
+		return;
+	}
+	if (state == DEV_STATE_DEAD) {
+		cfg_set(pswan_state, "dead");
+		return;
+	}
+}
+
+static int pdp_state_check(struct pdp_active_info *actinfo)
+{
+	char pdp_act_state[NV_NAME_LEN] = {0};
+	char nv_pdp_state[NV_NAME_LEN] = {0};
+	sprintf(nv_pdp_state, "pdp_act_state_%d", actinfo->c_id);
+	cfg_get_item(nv_pdp_state, pdp_act_state, sizeof(pdp_act_state));
+	if (0 != strcmp(pdp_act_state, "act")) {
+		cfg_set(nv_pdp_state, "acting");
+		return 0;
+	}
+	return 1;
+}
+
+static void plugin_state_set(unsigned char netdev_id)
+{
+	int plugstate;
+	char rj45_pluginstate[NV_NAME_LEN] = {0};
+	char temp[NV_NAME_LEN] = {0};
+	cfg_get_item("rj45_pluginstate", rj45_pluginstate, sizeof(rj45_pluginstate));
+
+	plugstate = atoi(rj45_pluginstate);
+	if (netdev_id == RJ45_WAN_DEV || netdev_id == SW_WAN_DEV) {
+		plugstate |= RJ45_WAN_IN;
+		sprintf(temp, "%d", plugstate);
+		cfg_set("rj45_pluginstate", temp);
+	} else if (netdev_id == RJ45_LAN_DEV || netdev_id == SW_LAN_DEV) {
+		plugstate |= RJ45_LAN_IN;
+		sprintf(temp, "%d", plugstate);
+		cfg_set("rj45_pluginstate", temp);
+	} else if (netdev_id == USB_LAN_DEV) {
+		plugstate = USB_LAN_IN;
+		sprintf(temp, "%d", plugstate);
+		cfg_set("usb_pluginstate", temp);
+	} else if (netdev_id >= PS_EXT_DEV1 && netdev_id <= PS_EXT_DEV8) {
+		sprintf(temp, "psext%d_pluginstate", netdev_id);
+		cfg_set(temp, "1");
+	}
+}
+
+static void plugout_state_set(unsigned char netdev_id)
+{
+	int plugstate;
+	char rj45_pluginstate[NV_NAME_LEN] = {0};
+	char temp[NV_NAME_LEN] = {0};
+
+	cfg_get_item("rj45_pluginstate", rj45_pluginstate, sizeof(rj45_pluginstate));
+	plugstate = atoi(rj45_pluginstate);
+
+	if (netdev_id == RJ45_WAN_DEV || netdev_id == SW_WAN_DEV) {
+		plugstate &= ~RJ45_WAN_IN;
+		sprintf(temp, "%d", plugstate);
+		cfg_set("rj45_pluginstate", temp);
+	} else if (netdev_id == RJ45_LAN_DEV || netdev_id == SW_LAN_DEV) {
+		plugstate &= ~RJ45_LAN_IN;
+		sprintf(temp, "%d", plugstate);
+		cfg_set("rj45_pluginstate", temp);
+	} else if (netdev_id == USB_LAN_DEV) {
+		plugstate = USB_LAN_OUT;
+		sprintf(temp, "%d", plugstate);
+		cfg_set("usb_pluginstate", temp);
+	} else if (netdev_id >= PS_EXT_DEV1 && netdev_id <= PS_EXT_DEV8) {
+		sprintf(temp, "psext%d_pluginstate", netdev_id);
+		cfg_set(temp, "0");
+	}
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º pdp_act_proc
+* ¹¦ÄÜÃèÊö£º PSÍøÂçÉ豸¼¤»î½Ó¿Ú
+* ²ÎÊý˵Ã÷£º pdp_active_info(IN):PDP¼¤»îÐÅÏ¢
+* ·µ »Ø Öµ£º ²Ù×÷³É¹¦·µ»Ø1.
+* ÆäËü˵Ã÷£º atÏà¹ØÓ¦Óýø³Ìµ÷Óã¬Èçatserver¡¢pcserver¡¢VoLTE¡¢²ÊÐŵÈÓ¦Óýø³Ì£»
+* ½Ó¿ÚÄÚ²¿ÊµÏÖ¶ÔÓÚµÄPSÉ豸µÄ¼¤»î¼°ÏàÓ¦µÄÍøÂçÅäÖÃ
+**************************************************************************/
+int ppp_act_proc(char *ttyname)
+{
+	char cmd[200] = {0};
+	char path_sh[50] = {0};
+
+	slog(NET_PRINT, SLOG_ERR, "netapi:calling ppp_act_proc, %s\n", ttyname);
+	cfg_set("ppp_pdpstate", "");
+	cfg_get_item("path_sh", path_sh, sizeof(path_sh));
+	if (!ttyname)
+		return -1;
+	sprintf(cmd, "%s/pppd_up.sh %s", path_sh, ttyname);
+	slog(NET_PRINT, SLOG_ERR, "cmd is %s\n", cmd);
+	soft_system(cmd);
+	return 0;
+}
+
+int pdp_act_proc(struct pdp_active_info *actinfo, int src_id)
+{
+	int ret = 0;
+	//klocwork
+	//int c_id = actinfo->c_id;
+	//unsigned char ip46flag = actinfo->act_info.ip46flag;
+
+	system("cat /proc/uptime 1>dev/console 2>&1");
+
+	if (!actinfo || actinfo->act_info.ip46flag == V4V6_INVALID) {
+		slog(NET_PRINT, SLOG_ERR, "pdp_act_proc, src_id = %d, actinfo->act_info.ip46flag == V4V6_INVALID\n", src_id);
+
+		softap_assert("ip46flag error"); //klocwork
+		return -1;
+	}
+	slog(NET_PRINT, SLOG_ERR, "netapi:pdp_act_proc: src_id=0x%x, cid=%d pdp_type=%u ip46flag=%u\n", src_id, actinfo->c_id, actinfo->pdp_type, actinfo->act_info.ip46flag);
+
+#if 1  // cov M  actinfo->pdp_type is unsigned, could not compare with 0
+    if (PDP_PPP < actinfo->pdp_type) {
+#else
+	if (PDP_PPP < actinfo->pdp_type || PDP_LOCAL > actinfo->pdp_type) {
+#endif        
+
+		slog(NET_PRINT, SLOG_ERR, "pdp_act_proc, src_id = %d, pdp_type is error: cid=%d pdp_type=%u ip46flag=%u\n", src_id, actinfo->c_id, actinfo->pdp_type, actinfo->act_info.ip46flag);
+		softap_assert("pdp_type=%u error", actinfo->pdp_type);
+		return -1;
+	}
+
+	if (1 == pdp_state_check(actinfo)) {
+
+		slog(NET_PRINT, SLOG_ERR, "pdp_act_init: already act c_id = %d, src_id = %d\n", actinfo->c_id, src_id);
+		//softap_assert("already act");
+		return -1;
+	}
+
+	if (actinfo->act_info.ip46flag == V6_VALID || actinfo->act_info.ip46flag == V46_VALID) {
+		set_pswan_v6state(actinfo->c_id, DEV_STATE_CONNECT);
+	}
+
+	ret = ipc_send_message(src_id, MODULE_ID_MAIN_CTRL, MSG_CMD_NET_PDP_ACT, sizeof(struct pdp_active_info), (UCHAR *)actinfo, 0);  /*lint !e26 !e55*/
+	if (0 != ret) {
+		softap_assert("send msg to zte_router error");
+		return -1;
+	}
+
+	slog(NET_PRINT, SLOG_ERR, "pdp_act_proc: success!\n");
+	return 0;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º pdp_deact_proc
+* ¹¦ÄÜÃèÊö£º PSÍøÂçÉ豸ȥ»î½Ó¿Ú
+* ²ÎÊý˵Ã÷£º c_id(IN):PDP¼¤»îc_id.
+* ·µ »Ø Öµ£º ²Ù×÷³É¹¦·µ»Ø1.
+* ÆäËü˵Ã÷£º atÏà¹ØÓ¦Óýø³Ìµ÷Óã¬Èçatserver¡¢pcserver¡¢VoLTE¡¢²ÊÐŵÈÓ¦Óýø³Ì£»
+½Ó¿ÚÄÚ²¿ÊµÏÖ¶ÔÓÚµÄPSÉ豸ȥ»î£»Ö§³Ö46µ¥Õ»È¥»î£¬ËùÒÔÈë²ÎÐèҪָʾ46Çé¿ö
+**************************************************************************/
+int pdp_deact_proc(int c_id, unsigned char ip46flag, int src_id)
+{
+	int ret = 0;
+	struct pdp_deactive_info temp;
+	char nv_pdp_state[NV_NAME_LEN] = {0};
+
+	slog(NET_PRINT, SLOG_ERR, "netapi:pdp_deact_proc: src_id=%d, cid=%d ip46flag=%u\n", src_id, c_id, ip46flag);
+
+	sprintf(nv_pdp_state, "pdp_act_state_%d", c_id);
+
+	temp.c_id = c_id;
+	temp.ip46flag = ip46flag;
+
+	if (ip46flag == V4V6_INVALID) {
+		slog(NET_PRINT, SLOG_ERR, "pdp_deact_proc,src_id = %d, ip46flag is error: cid=%d ip46flag=%u\n", src_id, c_id, ip46flag);
+		softap_assert("ip46flag=%u error", ip46flag);
+		return -1;
+	}
+
+	cfg_set(nv_pdp_state, "deacting");
+	ret = ipc_send_message(src_id, MODULE_ID_MAIN_CTRL, MSG_CMD_NET_PDP_DEACT, sizeof(struct pdp_deactive_info), (UCHAR *)&temp, 0); /*lint !e26 !e55*/
+	if (0 != ret) {
+		softap_assert("send msg to zte_router error");
+		return -1;
+	}
+	slog(NET_PRINT, SLOG_ERR, "pdp_deact_proc: success!\n");
+	return 0;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º netdev_connect_internet
+* ¹¦ÄÜÃèÊö£º webui·¢Ë͵ÄÁ¬½ÓÇëÇó,½Ó¿ÚÄÚ²¿½øÐÐifconfig up£¬²¢Æô¶¯ÏàÓ¦µÄµØÖ··ÖÅä½ø³Ì
+* ²ÎÊý˵Ã÷£º netdev_id£ºÍøÂçÉ豸¶ÔÓ¦µÄºêÃû£¬²Î¼ûUSB_NET_DEVµÈºêÖµ
+* ·µ »Ø Öµ£º ²Ù×÷³É¹¦·µ»Ø1.
+* ÆäËü˵Ã÷£º É豸Ö÷¿ØÄ£¿éµ÷Óô˽ӿÚǰ£¬ÐèÒª¼ì²âµ±Ç°É豸ÎïÀíͨ·ÒÑͨ£¬·ñÔò²»Ó¦¸Ãµ÷Óô˽ӿڣ»
+* Ö÷¿ØÄ£¿éÐèÒªÑÏ¿ØÖظ´µÄµ÷Óøýӿڣ¬ÒòΪÿµ÷ÓÃÒ»´Î¸Ã½Ó¿Ú£¬ÄÚ²¿½Ô»áÖØÐÂÖ´ÐÐÒ»´ÎÍêÕûµÄµØÖ··ÖÅäÁ÷³Ì£»
+**************************************************************************/
+int netdev_connect_internet(unsigned char netdev_id, int src_id)
+{
+	int ret = 0;
+
+	slog(NET_PRINT, SLOG_ERR, "netapi:netdev_connect_internet: netdev_id=%u\n", netdev_id);
+
+	if (netdev_id != RJ45_WAN_DEV && netdev_id != WIFI_WAN_DEV && netdev_id != RJ45_LAN_DEV && netdev_id != WIFI_LAN_DEV) {
+		slog(NET_PRINT, SLOG_ERR, "connect_internet:%u don't support connect op!\n", netdev_id);
+		softap_assert("netdev_id=%d error", netdev_id);
+		return 0;
+	}
+
+	ret = ipc_send_message(src_id, MODULE_ID_MAIN_CTRL, MSG_CMD_NET_CONNECT, sizeof(unsigned char), (UCHAR *)&netdev_id, 0); /*lint !e26 !e55*/
+	if (0 != ret) {
+		softap_assert("send msg to zte_router error");
+		return 0;
+	}
+	return 1;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º netdev_disconnect_internet
+* ¹¦ÄÜÃèÊö£º webui·¢Ë͵ĶϿªÁ¬½ÓÇëÇó,½Ó¿ÚÄÚ²¿½øÐÐifconfig down£¬²¢É±µôÏàÓ¦µÄµØÖ··ÖÅä½ø³Ì
+* ²ÎÊý˵Ã÷£º netdev_id£ºÍøÂçÉ豸¶ÔÓ¦µÄºêÃû£¬²Î¼ûUSB_NET_DEVµÈºêÖµ
+* ·µ »Ø Öµ£º ²Ù×÷³É¹¦·µ»Ø1.
+* ÆäËü˵Ã÷£º É豸Ö÷¿ØÄ£¿éµ÷Óô˽ӿÚ
+**************************************************************************/
+int netdev_disconnect_internet(unsigned char netdev_id, int src_id)
+{
+	int ret = 0;
+
+	printf("netapi:netdev_disconnect_internet start!netdev_id=%u\n", netdev_id);
+	slog(NET_PRINT, SLOG_ERR, "netapi:netdev_disconnect_internet: netdev_id=%u\n", netdev_id);
+
+	if (netdev_id != RJ45_WAN_DEV && netdev_id != WIFI_WAN_DEV && netdev_id != RJ45_LAN_DEV && netdev_id != WIFI_LAN_DEV) {
+		slog(NET_PRINT, SLOG_ERR, "disconnect_internet:%u don't support disconnect op!\n", netdev_id);
+		softap_assert("netdev_id=%d error", netdev_id);
+
+		return 0;
+	}
+
+	ret = ipc_send_message(src_id, MODULE_ID_MAIN_CTRL, MSG_CMD_NET_DISCON, sizeof(unsigned char), (UCHAR *)&netdev_id, 0); /*lint !e26 !e55*/
+	if (0 != ret) {
+		softap_assert("send msg to zte_router error");
+		return 0;
+	}
+	return 1;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º netdev_plugin_proc_byname
+* ¹¦ÄÜÃèÊö£º ÈȲå°ÎÉ豸²åÈë,½Ó¿ÚÄÚ²¿¼ì²âÊÇ·ñÐèÒª½øÐÐ×Ô¶¯²¦ºÅ£¬ÈçÐèÒª£¬Ö´ÐеØÖ··ÖÅä¡¢×éÍøµÈÁ÷³Ì
+* ²ÎÊý˵Ã÷£º netdev_name£ºÍøÂçÉ豸Ãû£¬source_id plug¼ì²âÄ£¿éID
+* ·µ »Ø Öµ£º ²Ù×÷³É¹¦·µ»Ø1.
+* ÆäËü˵Ã÷£º É豸Ö÷¿Øµ÷Óô˽ӿÚʱ£¬±íÃ÷¸ÃÍøÂçÉ豸ÎïÀíͨ·ÒÑͨ£¬¿ÉÒÔ½øÐÐIPÊý¾Ý°üµÄÊÕ·¢ÁË
+**************************************************************************/
+int netdev_plugin_proc_byname(char *netdev_name, int src_id)
+{
+	int netdev_id = 0;
+	slog(NET_PRINT, SLOG_ERR, "netdev_plugin_byname, netdev %s is plugin, src_id = %d\n", netdev_name, src_id);
+	netdev_id = getDevId_byname(netdev_name);
+
+	if (netdev_id == -1) {
+		slog(NET_PRINT, SLOG_ERR, "netdev_plugin_proc_byname,netdev_name is error,please connect main control");
+		return -1;
+	} else {
+		return netdev_plugin_proc(netdev_id, src_id);
+	}
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º netdev_plugout_proc
+* ¹¦ÄÜÃèÊö£º ÈȲå°ÎÉ豸°Î³ö,½Ó¿ÚÄÚ²¿½øÐÐifconfig down£¬²¢É±µôÏàÓ¦µÄµØÖ··ÖÅä½ø³Ì
+* ²ÎÊý˵Ã÷£º netdev_name£ºÍøÂçÉ豸Ãû£¬source_id plug¼ì²âÄ£¿éID
+* ·µ »Ø Öµ£º ²Ù×÷³É¹¦·µ»Ø1.
+* ÆäËü˵Ã÷£º É豸Ö÷¿Øµ÷Óô˽ӿÚʱ£¬±íÃ÷¸ÃÍøÂçÉ豸ÎïÀíͨ·ÒѶϣ¬²»ÒªÔÙ½øÐÐIPÊý¾Ý°üÊÕ·¢
+**************************************************************************/
+int netdev_plugout_proc_byname(char *netdev_name, int src_id)
+{
+	int netdev_id = 0;
+	slog(NET_PRINT, SLOG_ERR, "netdev_plugout_byname, netdev %s is plugout, src_id = %d\n", netdev_name, src_id);
+	netdev_id = getDevId_byname(netdev_name);
+
+	if (netdev_id == -1) {
+		slog(NET_PRINT, SLOG_ERR, "netdev_plugout_proc_byname,netdev_name is error,please connect main control");
+		return -1;
+	} else {
+		return netdev_plugout_proc(netdev_id, src_id);
+	}
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º netdev_plugin_proc
+* ¹¦ÄÜÃèÊö£º ÈȲå°ÎÉ豸²åÈë,½Ó¿ÚÄÚ²¿¼ì²âÊÇ·ñÐèÒª½øÐÐ×Ô¶¯²¦ºÅ£¬ÈçÐèÒª£¬Ö´ÐеØÖ··ÖÅä¡¢×éÍøµÈÁ÷³Ì
+* ²ÎÊý˵Ã÷£º netdev_id£ºÍøÂçÉ豸¶ÔÓ¦µÄºêÃû£¬²Î¼ûUSB_NET_DEVµÈºêÖµ
+* ·µ »Ø Öµ£º ²Ù×÷³É¹¦·µ»Ø1.
+* ÆäËü˵Ã÷£º É豸Ö÷¿Øµ÷Óô˽ӿÚʱ£¬±íÃ÷¸ÃÍøÂçÉ豸ÎïÀíͨ·ÒÑͨ£¬¿ÉÒÔ½øÐÐIPÊý¾Ý°üµÄÊÕ·¢ÁË
+**************************************************************************/
+int netdev_plugin_proc(unsigned char netdev_id, int src_id)
+{
+	int ret = 0;
+
+	printf("netapi:netdev_plugin_proc start!netdev_id=%u\n", netdev_id);
+	slog(NET_PRINT, SLOG_ERR, "netapi:netdev_plugin_proc: netdev_id=%u\n", netdev_id);
+	plugin_state_set(netdev_id);
+	/*if (netdev_id == RJ45_WAN_DEV || netdev_id == SW_WAN_DEV || netdev_id == RJ45_LAN_DEV || netdev_id == SW_LAN_DEV)
+	{
+		ret = ipc_send_message(MODULE_ID_CALL_CTRL, MODULE_ID_MMI, MSG_CMD_RJ45_STATUS_INFO, 0, NULL, 0);
+		if (0 != ret) {
+			softap_assert("send msg to mmi error");
+		}
+	}*/
+	ret = ipc_send_message2(src_id, MODULE_ID_MAIN_CTRL, MSG_CMD_NET_PLUGIN, sizeof(unsigned char), (UCHAR *)&netdev_id, 0); /*lint !e26 !e55*/
+
+	if (0 != ret) {
+		softap_assert("send msg to zte_router error");
+		return 0;
+	}
+#ifdef _USE_MBIM	
+	slog(NET_PRINT, SLOG_ERR, "netapi:netdev_plugin_proc: send MSG_CMD_NET_PLUGIN to MBIM\n");
+	ipc_send_message2(src_id, MODULE_ID_MBIM, MSG_CMD_NET_PLUGIN, sizeof(unsigned char), (UCHAR *)&netdev_id, 0); 
+#endif
+	return 1;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º netdev_plugout_proc
+* ¹¦ÄÜÃèÊö£º ÈȲå°ÎÉ豸°Î³ö,½Ó¿ÚÄÚ²¿½øÐÐifconfig down£¬²¢É±µôÏàÓ¦µÄµØÖ··ÖÅä½ø³Ì
+* ²ÎÊý˵Ã÷£º netdev_id£ºÍøÂçÉ豸¶ÔÓ¦µÄºêÃû£¬²Î¼ûUSB_NET_DEVµÈºêÖµ
+* ·µ »Ø Öµ£º ²Ù×÷³É¹¦·µ»Ø1.
+* ÆäËü˵Ã÷£º É豸Ö÷¿Øµ÷Óô˽ӿÚʱ£¬±íÃ÷¸ÃÍøÂçÉ豸ÎïÀíͨ·ÒѶϣ¬²»ÒªÔÙ½øÐÐIPÊý¾Ý°üÊÕ·¢
+**************************************************************************/
+int netdev_plugout_proc(unsigned char netdev_id, int src_id)
+{
+	int ret = 0;
+
+	printf("netapi:netdev_plugout_proc start!netdev_id=%u\n", netdev_id);
+	slog(NET_PRINT, SLOG_ERR, "netapi:netdev_plugout_proc: netdev_id=%u\n", netdev_id);
+	plugout_state_set(netdev_id);
+	slog(NET_PRINT, SLOG_ERR, "netdev_plugout_proc: netdev_id=%u\n", netdev_id);
+	/*if (netdev_id == RJ45_WAN_DEV || netdev_id == SW_WAN_DEV || netdev_id == RJ45_LAN_DEV || netdev_id == SW_LAN_DEV)
+	{
+		ret = ipc_send_message(MODULE_ID_CALL_CTRL, MODULE_ID_MMI, MSG_CMD_RJ45_STATUS_INFO, 0, NULL, 0);
+		if (0 != ret) {
+			softap_assert("send msg to mmi error");
+		}
+	}*/
+	ret = ipc_send_message2(src_id, MODULE_ID_MAIN_CTRL, MSG_CMD_NET_PLUGOUT, sizeof(unsigned char), (UCHAR *)&netdev_id, 0); /*lint !e26 !e55*/
+
+	if (0 != ret) {
+		softap_assert("send msg to zte_router error");
+		return 0;
+	}
+#ifdef _USE_MBIM
+	ipc_send_message2(src_id, MODULE_ID_MBIM, MSG_CMD_NET_PLUGOUT, sizeof(unsigned char), (UCHAR *)&netdev_id, 0);
+#endif
+	return 1;
+}
+/********************************************************************
+* º¯ÊýÃû³Æ£º tcpip_reset_configure
+* ¹¦ÄÜÃèÊö£º »Ö¸´³ö³§ÉèÖÃʱÓÉååzte_blc½ø³Ìµ÷Óã¬É¾³ý³ÌÐòÔËÐÐÖÐÉú³ÉµÄÎļþ
+* ²ÎÊý˵Ã÷£º ÎÞ
+* ·µ »Ø Öµ£º ÎÞ
+* ÆäËü˵Ã÷£º
+**********************************************************************/
+void tcpip_reset_configure()
+{
+	char cmd[200] = {0};
+	char path_script[50] = {0};
+	char path_conf[50] = {0};
+	char path_file[200] = {0};
+	printf("netapi:tcpip_reset_configure start!\n");
+	cfg_get_item("path_conf", path_conf, sizeof(path_conf));
+	sprintf(path_file, "%s/hostname_mac_file", path_conf);
+
+
+	//»Ö¸´³ö³§ÉèÖÃʱɾ³ýhostname_mac_fileÎļþ
+	sprintf(cmd, "/bin/rm -rf %s", path_file);
+	zxic_system(cmd);
+	//»Ö¸´³ö³§ÉèÖÃʱɾ³ýstatic_macip_file  Îļþ
+	memset(path_file, 0, sizeof(path_file));
+	sprintf(path_file, "%s/static_macip_file", path_conf);
+	memset(cmd, 0, sizeof(cmd));
+	sprintf(cmd, "/bin/rm -rf %s", path_file);
+	zxic_system(cmd);
+
+	memset(path_file, 0, sizeof(path_file));
+	sprintf(path_file, "%s/children_device_file", path_conf);
+	memset(cmd, 0, sizeof(cmd));
+	sprintf(cmd, "/bin/rm -rf %s", path_file);
+	zxic_system(cmd);
+
+	memset(path_file, 0, sizeof(path_file));
+	sprintf(path_file, "%s/white_site_file", path_conf);
+	memset(cmd, 0, sizeof(cmd));
+	sprintf(cmd, "/bin/rm -rf %s", path_file);
+	zxic_system(cmd);
+
+	/*reset DDNS status file*/
+	memset(path_file, 0, sizeof(path_file));
+	sprintf(path_file, "%s/inadyn.status", path_conf);
+	memset(cmd, 0, sizeof(cmd));
+	sprintf(cmd, "/bin/rm -rf %s", path_file);
+	zxic_system(cmd);
+
+	//»Ö¸´³ö³§ÉèÖÃʱ½«MAC-IP°ó¶¨¹æÔòÇå¿Õ
+	cfg_get_item("path_sh", path_script, sizeof(path_script));
+	memset(cmd, 0, sizeof(cmd));
+	sprintf(cmd, "%s/config-udhcpd.sh \"lan\" -S", path_script);
+	soft_system(cmd);
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º tc_control
+* ¹¦ÄÜÃèÊö£º Á÷Á¿¿ØÖÆ
+* ²ÎÊý˵Ã÷£º ÐèÒªÁ÷Á¿¼à¿ØµÄÉÏÏÂÐÐÁ¿£¬Êý¾Ý¿¨ÐèÒªÓÐcid£¬ufiģʽ²»ÐèÒª
+*            0±íʾ²»ÐèÒªÁ÷¿Ø£¬µ¥Î»:bit£¬Òòlinux±ê×¼ÃüÁîÊǶÔ×Ö½Ú´¦Àí£¬ËùÒÔ×îÖÕÅäÖÃÖµ»áÕû³ý8
+* ·µ »Ø Öµ£º ²Ù×÷³É¹¦·µ»Ø1.
+* ÆäËü˵Ã÷£º ¸øÐèÒªÁ÷Á¿¿ØÖƵÄÓ¦Óõ÷Óã¬ÈçÉÏÐÐÐèÒªÁ÷¿Ø£¬ÇëµÈÄÜÉÏÍâÍøºóÔÙµ÷Ó㬷ñÔòÎÞ·¨»ñÈ¡ÍâÍø¿Ú½øÐÐÁ÷¿Ø
+*                 Õý³£¹Ø»úÖØÐ¿ª»ú£¬Ö®Ç°ÉèÖõÄÁ÷¿ØÒÀÈ»ÓÐЧ
+**************************************************************************/
+int tc_control(struct tc_control_info *tcinfo, int src_id)
+{
+	int ret = 0;
+
+	printf("netapi:tc_control start! c_id:%d, down:%u, up:%u\n, src:%d \n", tcinfo->c_id, tcinfo->tc_downlink, tcinfo->tc_uplink, src_id);
+
+	ret = ipc_send_message(src_id, MODULE_ID_MAIN_CTRL, MSG_CMD_NET_TC_CTRL, sizeof(struct tc_control_info), (UCHAR *)tcinfo, 0);
+	if (0 != ret) {
+		softap_assert("send msg to zte_router error");
+		return 0;
+	}
+	return 1;
+}
+
+#define SIOCDEVPRIVATE 0X89F0
+#define SIOCVLAN		SIOCDEVPRIVATE+0x0	
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º set_ethwan_mode
+* ¹¦ÄÜÃèÊö£º ÉèÖÃswitchÉ豸eth0.200Íø¿Ú¶ÔÓ¦µÄport3Ϊwan¿Ú»¹ÊÇlan¿Ú
+* ²ÎÊý˵Ã÷£º mode:1 => wan¿Ú£¬0 => lan¿Ú
+* ·µ »Ø Öµ£º ÎÞ.
+* ÆäËü˵Ã÷£º 
+**************************************************************************/
+void set_ethwan_port_mode(int mode)
+{
+	struct ifreq ifr;
+	int fd;
+	char eth_name[IFNAMSIZ] = {'e','t','h','0'};
+
+	if(mode != 0 && mode != 1)
+	{
+		return;
+	}
+	slog(NET_PRINT, SLOG_ERR, "set_ethwan_port_mode() mode=%d\n", mode);	
+	if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+		slog(NET_PRINT, SLOG_ERR, "set_eth200_mode() socket(AF_INET,SOCK_STREAM) fail");
+		return;
+	}
+	memset(&ifr, 0, sizeof(ifr));
+	memcpy((void*)ifr.ifr_name, (void*)eth_name, strlen("eth0"));//gmacÍø¿ÚÃû³Æeth0£¬ºóÐø¿¼ÂÇÊÇ·ñͨ¹ýÐÂÔönvÏî»ñÈ¡
+	ifr.ifr_data = (void*)&mode;
+
+	if (ioctl(fd, SIOCVLAN, &ifr) < 0 && errno != EINVAL) {
+		slog(NET_PRINT, SLOG_ERR, "set_eth200_mode() ioctl fail");		
+		close(fd);
+		return;
+	}
+
+	close(fd);
+
+}
+
+
diff --git a/lynq/S300/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/board-zx297520v3.c b/lynq/S300/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/board-zx297520v3.c
new file mode 100755
index 0000000..280a14b
--- /dev/null
+++ b/lynq/S300/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/board-zx297520v3.c
@@ -0,0 +1,680 @@
+/*
+ * linux/arch/arm/mach-zx297510/board-zx297520v2.c
+ *
+ *  Copyright (C) 2015 ZTE-TSP
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/spi/spi.h>
+#include <linux/mtd/physmap.h>
+#include <linux/syscalls.h>
+
+#include <asm/setup.h>
+#include <asm/mach-types.h>
+#include <asm/irq.h>
+#include <asm/uaccess.h>
+
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+#include <asm/mach/irq.h>
+#include <asm/hardware/cache-l2x0.h>
+
+#include <mach/board.h>
+#include <mach/gpio.h>
+#include <mach/iomap.h>
+#include <mach/irqs.h>
+#include <mach/debug.h>
+#include <mach/spinlock.h>
+#include <mach/pcu.h>
+#include <linux/gpio.h>
+
+//++
+#include <mach/gpio_cfg.h>
+//++
+
+#include <linux/delay.h>
+#include <linux/dev_info.h>
+#include <mach/pwr_ctrl.h>
+
+
+/* LCM manufacturer ID */
+#define LCM_ID_LEAD         0x7C
+#define LCM_ID_ST7789V		0x85
+
+extern struct sys_timer zx29_timer;
+#if (defined CONFIG_SPI_ZX29) || (defined CONFIG_SPI_GPIO)
+extern void __init spi_add_devices(void);
+#endif
+void zx_write_bits(void __iomem *reg_addr, unsigned char offset, unsigned char width, unsigned long value)
+{
+	unsigned int temp, mask;
+
+	mask = (1 << width) - 1;
+	temp = ioread32(reg_addr);
+	temp &= ~(mask << offset);
+	temp |= (value << offset);
+	iowrite32(temp, reg_addr);
+}
+
+int lcd_get_info(struct lcd_info *info)
+{
+    if(info == NULL)
+        return -EINVAL;
+
+#ifdef CONFIG_FB_LEADT15DS26
+	sprintf(info->manu, "lead");
+    sprintf(info->ic, "T15DDS26");
+    sprintf(info->resolution, "128*128");
+#else
+	sprintf(info->manu, "unknown");
+    sprintf(info->ic, "unknown");
+    sprintf(info->resolution, "unknown");
+#endif
+
+    return 0;
+}
+
+int wifi_get_info(struct wifi_info *info)
+{
+    if(info == NULL)
+        return -EINVAL;
+	
+#ifdef CONFIG_RTL8192CD
+	sprintf(info->manu, "RealTek");
+    sprintf(info->ic, "RTL81XX");
+#else
+    sprintf(info->manu, "unknown");
+    sprintf(info->ic, "unknown");
+#endif
+
+    return 0;
+}
+
+extern char g_maf_id;
+extern char g_dev_id;
+int flash_get_info(struct flash_ddr_info *info)
+{
+	char manuf = g_maf_id;
+	char dev   = g_dev_id;
+
+	if( NULL==info )
+		return 1;
+	
+ 	if(manuf == 0x2C) {
+		sprintf( info->manu, "MICRON" );
+		sprintf( info->model, "MT29F2G08U0B");
+	}
+	else if((manuf == 0xAD)&&(dev == 0xAC)) {
+		sprintf( info->manu, "HYNIX" );
+		sprintf( info->model, "H9TA4GG2GDMCPR");
+	}
+	else if((manuf == 0xAD)&&(dev == 0xAA)) {
+		sprintf( info->manu, "JSC" );
+		sprintf( info->model, "JSFBAB3YHABB");
+	}
+	else if(manuf == 0x01) {
+		if(dev == 0xAC) {
+			sprintf( info->manu, "JSC" );
+			sprintf( info->model, "JSFCBB3Y75BBD");
+		}
+		else if(dev == 0xA1) {
+			sprintf( info->manu, "JSC" );
+			sprintf( info->model, "JSFAA3Y7ABB");
+		}
+	}
+	else if(manuf == 0xC8) {
+		if(dev == 0xAC) {
+			sprintf( info->manu, "ESMT" );
+			sprintf( info->model, "FM6BD4G2GA");
+		}
+		else if(dev == 0xAA) {
+			sprintf( info->manu, "ESMT" );
+			sprintf( info->model, "FM6BD2G1GA");
+		}
+		else if(dev == 0xC1) {
+			sprintf( info->manu, "GD" );
+			sprintf( info->model, "GD5F1GQ4R");
+		}
+		else if(dev == 0x41) {
+			sprintf( info->manu, "GD" );
+			sprintf( info->model, "GD5F1GQ5R");
+		}
+		else if(dev == 0xC2) {
+			sprintf( info->manu, "GD" );
+			sprintf( info->model, "GD5F2GQ4R");
+		}
+		else if(dev == 0xC4) {
+			sprintf( info->manu, "GD" );
+			sprintf( info->model, "GD5F4GQ4R");
+		}
+		else if(dev == 0xE1) {
+			sprintf( info->manu, "GD" );
+			sprintf( info->model, "GD5F1GQ4R");
+		}
+		else if(dev == 0xE2) {
+			sprintf( info->manu, "GD" );
+			sprintf( info->model, "GD5F2GQ4R");
+		}
+		else if(dev == 0xE4) {
+			sprintf( info->manu, "GD" );
+			sprintf( info->model, "GD5F4GQ4R");
+		}
+	}
+	else if(manuf == 0xA1) {
+		if(dev == 0xC1) {
+			sprintf( info->manu, "PAROGON" );
+			sprintf( info->model, "PN26Q01A");
+		}
+		else if(dev == 0xC2) {
+			sprintf( info->manu, "PAROGON" );
+			sprintf( info->model, "PN26Q02A");
+		}
+	}
+	else if(manuf == 0xEF) {
+		if(dev == 0xBA) {
+			sprintf( info->manu, "WINBOND" );
+			sprintf( info->model, "W25N01G");
+		}
+		else if(dev == 0xBB) {
+			sprintf( info->manu, "WINBOND" );
+			sprintf( info->model, "W25N02G");
+		}
+	}
+	else if (manuf == 0x98) {
+		if(dev == 0xB2) {
+			sprintf( info->manu, "TOSHIBA" );
+			sprintf( info->model, "TC58CYG0S3HRAIG");
+		}
+		else if(dev == 0xBB) {
+			sprintf( info->manu, "TOSHIBA" );
+			sprintf( info->model, "TC58CYG1S3HRAIG");
+		}
+	}
+	else {
+		sprintf( info->manu, "unknown" );
+		sprintf( info->model, "unknown");
+	}	
+
+	if(dev == 0xAA||dev==0xC2||dev==0xE2||dev==0xBB)
+		sprintf( info->size, "256MiB" );
+	else if(dev == 0xAC||dev==0xC4||dev==0xE4)
+		sprintf( info->size, "512MiB" );
+	else if(dev == 0xA1||dev==0xC1||dev==0xE1||dev==0xBA)
+		sprintf( info->size, "128MiB" );
+	else
+		sprintf( info->size, "unknown" );
+
+	return 0;
+}  
+
+unsigned long ddr_freq_get(void)
+{
+	unsigned long rdata =readl(ZX_MATRIX_CRM_BASE + 0x50) & 0x3;
+	unsigned long ddrfreq=0;
+		
+	switch(rdata)
+	{
+		case 0:
+		{
+			ddrfreq =312000000;
+			break;
+		}	
+		 case 1:
+	        {
+			ddrfreq =400000000;
+			break;
+	        }
+		 case 2:
+	        {
+			ddrfreq =208000000;
+			break;
+	        }		 
+		default:
+		{
+			ddrfreq =156000000;	
+			break;
+		}
+	}
+	
+	return ddrfreq;
+}
+	
+unsigned long ddr_read_mr(unsigned long mr)
+{
+	unsigned long rdata;
+	unsigned long rautoen;
+	unsigned long raxigateen;
+
+	rautoen=readl(ZX_DDR_CTRL_BASE + 0x030);
+	raxigateen=readl(ZX_MATRIX_CRM_BASE + 0x100);
+	
+	zx_write_bits(ZX_MATRIX_CRM_BASE + 0x100,0,4,0);
+	zx_write_bits(ZX_DDR_CTRL_BASE     + 0x030,0,2,0);
+	rdata = readl(ZX_SOC_SYS_BASE + 0x40) >> 16;/*bit16 valid*/
+
+	writel( (mr << 8),ZX_DDR_CTRL_BASE + 0x14);
+	writel( ((1 << 31) | (1 << 4) | 1),ZX_DDR_CTRL_BASE + 0x10);
+
+	while((readl(ZX_SOC_SYS_BASE + 0x40) >> 16) == rdata);
+
+	rdata = readl(ZX_SOC_SYS_BASE + 0x40) & 0xff;
+
+	writel( rautoen,ZX_DDR_CTRL_BASE + 0x030);
+	writel( raxigateen,ZX_MATRIX_CRM_BASE + 0x100);	
+
+	return rdata;
+}
+
+int ddr_get_info(struct flash_ddr_info *info)
+{
+	unsigned long ddr_id;
+	unsigned long ddr_freq;
+
+	if( NULL==info )
+		return 1;
+
+	ddr_id = ddr_read_mr(5);	/*read mr5*/
+	ddr_freq= ddr_freq_get();	
+	
+	if(ddr_id == 0x05) {
+		sprintf( info->manu, "NANYA" );/*ÄÏÑÇ*/
+		sprintf( info->size, "256MiB" );
+		sprintf( info->model, "LPDDR2" );
+		sprintf( info->freq, "%dHz", ddr_freq );	
+	}
+	else if (ddr_id == 0xf8) {
+		sprintf( info->manu, "DOSILICON" );/*¶«Ð¾*/
+		sprintf( info->size, "256MiB" );
+		sprintf( info->model, "LPDDR2" );
+		sprintf( info->freq, "%dHz", ddr_freq );
+	}
+	else {
+		sprintf( info->manu, "unknown" );
+		sprintf( info->size, "unknown" );
+		sprintf( info->model, "unknown" );
+		sprintf( info->freq, "unknown" );	
+	}
+	return 0;
+}
+
+
+int cpu_get_info(struct cpu_info *info)
+{
+	if( NULL==info )
+		return 1;
+
+	sprintf(info->manu, "SANECHIPS");
+	sprintf(info->model, "ZX297520V3");
+	
+	return 0;
+}
+SYSCALL_DEFINE3(get_lcdinfo, char __user *, manu, char __user *, ic, char __user *, resolution)
+{
+	int err = 0;
+	struct lcd_info 		lcd;
+
+	err = lcd_get_info(&lcd);
+
+	if(err)
+		return -EINVAL;
+
+	if (manu)
+		err |= copy_to_user(manu, &lcd.manu, sizeof(lcd.manu));
+	if (ic)
+		err |= copy_to_user(ic, &lcd.ic, sizeof(lcd.ic));
+	if (resolution)
+		err |= copy_to_user(resolution, &lcd.resolution, sizeof(lcd.resolution));
+	
+	return err ? -EFAULT : 0;
+
+}
+SYSCALL_DEFINE2(get_wifiinfo, char __user *, manu, char __user *, ic)
+{
+	int err = 0;
+	struct wifi_info 		wifi;
+
+	err = wifi_get_info(&wifi);
+
+	if(err)
+		return -EINVAL;
+
+	if (manu)
+		err |= copy_to_user(manu, &wifi.manu, sizeof(wifi.manu));
+	if (ic)
+		err |= copy_to_user(ic, &wifi.ic, sizeof(wifi.ic));
+	
+	return err ? -EFAULT : 0;
+
+}
+SYSCALL_DEFINE3(get_flashinfo, char __user *, manu, char __user *, model, char __user *, sizes)
+{
+	int err = 0;
+	struct flash_ddr_info 		flash;
+
+	err = flash_get_info(&flash);
+
+	if(err)
+		return -EINVAL;
+
+	if (manu)
+		err |= copy_to_user(manu, &flash.manu, sizeof(flash.manu));
+	if (model)
+		err |= copy_to_user(model, &flash.model, sizeof(flash.model));
+	if (sizes)
+		err |= copy_to_user(sizes, &flash.size, sizeof(flash.size));
+	
+	return err ? -EFAULT : 0;
+
+}
+SYSCALL_DEFINE4(get_ddrinfo, char __user *, manu, char __user *, model, char __user *, sizes, char __user *, freq)
+{
+	int err = 0;
+	struct flash_ddr_info 		ddr;
+
+	err = ddr_get_info(&ddr);
+
+	if(err)
+		return -EINVAL;
+
+	if (manu)
+		err |= copy_to_user(manu, &ddr.manu, sizeof(ddr.manu));
+	if (model)
+		err |= copy_to_user(model, &ddr.model, sizeof(ddr.model));
+	if (sizes)
+		err |= copy_to_user(sizes, &ddr.size, sizeof(ddr.size));
+	if (freq)
+		err |= copy_to_user(freq, &ddr.freq, sizeof(ddr.freq));	
+	
+	return err ? -EFAULT : 0;
+
+}
+SYSCALL_DEFINE2(get_cpuinfo, char __user *, manu, char __user *, model)
+{
+	int err = 0;
+	struct cpu_info 		cpu;
+
+	err = cpu_get_info(&cpu);
+
+	if(err)
+		return -EINVAL;
+
+	if (manu)
+		err |= copy_to_user(manu, &cpu.manu, sizeof(cpu.manu));
+	if (model)
+		err |= copy_to_user(model, &cpu.model, sizeof(cpu.model));
+
+	return err ? -EFAULT : 0;
+}
+unsigned char cid_reserved = 0;
+SYSCALL_DEFINE1(set_cidstate, unsigned char, cid)
+{
+	cid_reserved = cid;
+	return 0;
+}
+extern int zAti_CidIsUsed(unsigned char bCid);
+SYSCALL_DEFINE1(get_cidstate, unsigned char, cid)
+{
+#ifndef CONFIG_SYSTEM_RECOVERY
+#ifndef CONFIG_SYSTEM_CAP
+#ifndef _USE_TestHarness
+#ifdef USE_CPPS_KO
+	if(cpps_callbacks.zAti_CidIsUsed(cid))
+#else
+	if(zAti_CidIsUsed(cid))
+#endif
+		return 1;
+	if((cid_reserved & (1<<(cid-1))) && cid_reserved != 255)//15±íÊ¾ÌØÊâ²úÆ·ÐÎ̬£¬cid¼ÈÔ¤Áô¸øÍⲿ£¬Ò²²ÎÓ붯̬·ÖÅä
+		return 1;
+#endif
+#endif
+#endif		
+	return 0;
+}
+int get_cid_state(unsigned char cid)
+{
+	return sys_get_cidstate(cid);
+}
+EXPORT_SYMBOL(get_cid_state);
+typedef void (*set_pdp_state_CB)(unsigned char cid, unsigned int state);
+typedef int (*get_ipv6_prefix_CB)(unsigned char cid, int len, unsigned char *prefix, unsigned char *prefix_len);
+set_pdp_state_CB g_psnet_set_RA_state = NULL;
+get_ipv6_prefix_CB g_psnet_get_prefix = NULL;
+SYSCALL_DEFINE2(set_pdp_state, unsigned char, cid, unsigned int, state)
+{
+	if(g_psnet_set_RA_state != NULL){
+		g_psnet_set_RA_state(cid, state);
+	}
+	return 0;
+}
+
+SYSCALL_DEFINE2(get_ipv6_prefix, unsigned char, cid, char __user *, prefix)
+{
+	if(g_psnet_get_prefix != NULL){
+		int ret = 0;
+		unsigned char prefix_str[64] = {0};
+		unsigned char prefix_len = 0;
+		ret = g_psnet_get_prefix(cid, sizeof(prefix_str), prefix_str, &prefix_len);
+		if(ret > 0 && prefix_len > 0 && copy_to_user(prefix, prefix_str, ret) == 0)
+			return prefix_len;
+	}
+	return 0;
+}
+
+typedef int (*set_xlat_CB)(unsigned char *ip_info, unsigned char *dev_name);
+set_xlat_CB g_set_xlat_cb = NULL;
+SYSCALL_DEFINE2(set_xlat, char __user *, ip_info, char __user *, dev_name)
+{
+	unsigned char info[40] = {0};
+	unsigned char dev[16] = {0};
+	if(g_set_xlat_cb != NULL){
+		if(copy_from_user(&info, ip_info, sizeof(info)) == 0 
+			&& copy_from_user(&dev, dev_name, sizeof(dev)) == 0 ){
+			return g_set_xlat_cb(&info, &dev);
+		}
+	}
+	return 0;
+}
+
+#if 0
+SYSCALL_DEFINE5(get_devinfo, struct lcd_info __user *, lcd_dev, 
+						struct wifi_info __user *, wifi_dev, 
+						struct flash_ddr_info __user *, flash_dev, 
+						struct flash_ddr_info __user *, ddr_dev, 
+						struct cpu_info __user *, cpu_dev)
+{
+	int err = 0;
+	struct lcd_info 		lcd;
+	struct wifi_info 		wifi;
+	struct flash_ddr_info 	flash;
+	struct flash_ddr_info 	ddr;
+	struct cpu_info 		cpu;
+
+	err = lcd_get_info(&lcd);
+	err += wifi_get_info(&wifi);
+	err += flash_get_info(&flash);
+	err += ddr_get_info(&ddr);
+	err += cpu_get_info(&cpu);
+
+	if(err)
+		return -EINVAL;
+
+	if (lcd_dev)
+		err |= copy_to_user(lcd_dev, lcd, sizeof(struct lcd_info));
+	if (wifi_dev)
+		err |= copy_to_user(wifi_dev, wifi, sizeof(struct wifi_info));
+	if (flash_dev)
+		err |= copy_to_user(flash_dev, flash, sizeof(struct flash_ddr_info));
+	if (ddr_dev)
+		err |= copy_to_user(ddr_dev, ddr, sizeof(struct flash_ddr_info));
+	if (cpu_dev)
+		err |= copy_to_user(cpu_dev, cpu, sizeof(struct cpu_info));
+	
+	return err ? -EFAULT : 0;
+
+}
+#endif
+
+/*
+ *do someting you like to do early
+ *it is invoked between mmu initialize finish and irq initialize start
+ */
+static void __init board_init_early(void)
+{
+	softspinlock_init();
+
+	zx29_clock_init();
+
+	pcu_init();
+}
+
+/*
+ *initiate board based on zx297520v2
+ */
+static void __init board_init(void)
+{
+#ifdef CONFIG_CACHE_L2X0
+	/* set RAM latencies */
+	/* 0-1cycle 1-2cycles ...
+	 * bit10..8  : write
+	 * bit6..4   : read
+	 * bit2..0   : setup
+	 */
+	//iowrite32(0x111, ZX_L2CACHE_CONFIG_BASE + L2X0_TAG_LATENCY_CTRL);
+	//iowrite32(0x911, ZX_L2CACHE_CONFIG_BASE + L2X0_DATA_LATENCY_CTRL);
+
+	/**  bit16  	: 0-8way  1-16way
+	  *  bit19..17  : 1-16KB  2-32KB ...
+	  *  bit21      : 1-enable parity(ÆæÅ¼)
+	  *  bit22      : 1-ignore internal shared attribute
+	  *  bit25      : ?
+	  *  bit28		: 1-data prefetch
+	  *  bit29		: 1-instruction prefetch
+	  *  bit30		: 1-enable early BRESP(write response)
+	  *
+	  */
+	l2x0_init(ZX_L2CACHE_CONFIG_BASE, 0x72320000, 0x800f0fff);
+#endif
+#if defined (CONFIG_RDAWFMAC) ||defined (CONFIG_RDAWFMAC_MODULE)
+	extern void rda_wifi_enable(int bval);
+	extern int rda_wifi_init(void);
+	extern void rda_wifi_deinit(void);
+	int ret;
+    ret = rda_wifi_init();
+	if(ret < 0)
+	{
+        printk("%s,rda_wifi_init failed\n",__func__);        
+    }
+	else
+	{
+		rda_wifi_enable(0);
+		rda_wifi_deinit();
+		//mdelay(200);
+		//rda_wifi_enable(1);
+		//mdelay(200);
+	}
+#endif
+#if defined (CONFIG_ESP8089) ||defined (CONFIG_ESP8089_MODULE)
+	extern void esp_wifi_enable(int bval);
+	extern int esp_wifi_init(void);
+	extern void esp_wifi_deinit(void);
+	int ret;
+    ret = esp_wifi_init();
+	if(ret < 0)
+	{
+        printk("%s,rda_wifi_init failed\n",__func__);        
+    }
+	else
+	{
+		esp_wifi_enable(0);
+		esp_wifi_deinit();
+		//mdelay(200);
+		//rda_wifi_enable(1);
+		//mdelay(200);
+	}
+#endif
+
+#if( (defined CONFIG_SLIC_TW) || (defined CONFIG_SLIC))
+	pwr_buck3v3_on(POWER_SLIC);
+	printk("buck3v3 on, slic power up.\n");
+
+#endif
+
+#if  (defined CONFIG_RTL8192CD) || (defined CONFIG_NET_ZX29_GMAC)
+	pwr_buck3v3_on(POWER_WIFI);
+	printk("buck3v3 on, wifi power up.\n");
+#endif
+	check_led_ver(); // add by you.chen for hardware compatible 
+	platform_add_devices(zx29_device_table, zx29_device_table_num);
+
+#if (defined CONFIG_SPI_ZX29) || (defined CONFIG_SPI_GPIO)
+	spi_add_devices();
+#endif
+    i2c_add_devices();
+#if  (defined CONFIG_RTL8192CD) || (defined CONFIG_SSV6X5X)
+    //int RTL_8192CHIP_ENABLE = 71;
+    int ret;
+    ret = gpio_request(PIN_WIFI_CHIP_ENABLE, "wifi_chip_enable");
+    if(ret<0)
+    {
+        printk("request wifi enable gpio failed\n");
+        gpio_free(PIN_WIFI_CHIP_ENABLE);
+    }
+    else
+    {
+        //zx29_gpio_config(RTL_8192CHIP_ENABLE, GPIO71_GPIO71);
+        zx29_gpio_config(PIN_WIFI_CHIP_ENABLE, PIN_WIFI_CHIP_ENABLE_SEL);
+#ifdef CONFIG_MIFI_WIFI
+	   gpio_direction_output(PIN_WIFI_CHIP_ENABLE, 0);
+	   printk("wifi enable gpio success low%d\n",PIN_WIFI_CHIP_ENABLE);
+#else
+		gpio_direction_output(PIN_WIFI_CHIP_ENABLE, 1);
+		printk("wifi enable gpio success high%d\n",PIN_WIFI_CHIP_ENABLE);
+#endif
+    }
+#endif
+
+#ifdef CONFIG_IP175L_PHY
+    int val;
+    val = gpio_request(ZX29_GPIO_124, "switch_lan_enable");
+    if(val < 0)
+    {
+        printk("request switch lan enable gpio failed\n");
+        gpio_free(ZX29_GPIO_124);
+    }
+    else
+    {
+        zx29_gpio_config(ZX29_GPIO_124, GPIO124_GPIO124);
+		gpio_direction_output(ZX29_GPIO_124, 1);
+    }
+#endif
+}
+
+MACHINE_START(ZX297520V3, "TSP ZX297520V3")
+	.atag_offset  	= 0x100,
+#if NEW_LINUX_FRAME
+	.init_time	  	= zx29_timer_init,
+#else
+	.timer		  	= &zx29_timer,
+#endif
+	.map_io		  	= zx29_map_io,
+	.init_early	  	= board_init_early,
+	.init_irq  	  	= zx29_init_irq,
+	.init_machine 	= board_init,
+	.restart 		= zx29_restart,
+MACHINE_END
diff --git a/lynq/S300/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/include/mach/board.h b/lynq/S300/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/include/mach/board.h
new file mode 100755
index 0000000..79c225f
--- /dev/null
+++ b/lynq/S300/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/include/mach/board.h
@@ -0,0 +1,85 @@
+/*
+ * arch/arm/mach-zx297520v2/include/mach/board.h
+ *
+ *  Copyright (C) 2013 ZTE-TSP
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+
+
+#ifndef __ASM_ARCH_BOARD_H
+#define __ASM_ARCH_BOARD_H
+
+#include <linux/version.h>
+#include <linux/init.h>
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
+#define	NEW_LINUX_FRAME		1
+#else
+#define	NEW_LINUX_FRAME		0
+#endif
+
+struct zx29_reg_conf
+{
+	void __iomem *	reg_addr;
+    unsigned char 	reg_bit_offset;
+    unsigned char 	reg_bit_size;
+};
+
+extern struct kobject *zx_test_kobj;
+
+/*********************************************************************
+ **           io operation interface                                **
+ *********************************************************************
+ */
+#define zx_reg_sync_write(v, a) \
+        do {    \
+            iowrite32(v, a);    \
+        } while (0)
+
+#define zx_read_reg(addr) \
+    ioread32(addr)
+
+#define zx_write_reg(addr, val)   \
+	zx_reg_sync_write(val, addr)
+
+#define zx_set_reg(addr, val) \
+    zx_reg_sync_write(zx_read_reg(addr) | (val), addr)
+
+#define zx_clr_reg(addr, val) \
+    zx_reg_sync_write(zx_read_reg(addr) & ~(val), addr)
+
+#define zx_reg_sync_write_16(v, a) \
+        do {    \
+            iowrite16(v, a);    \
+        } while (0)
+
+#define zx_read_reg_16(addr) \
+    ioread16(addr)
+
+#define zx_write_reg_16(addr, val)   \
+	zx_reg_sync_write_16(val, addr)
+
+void zx_write_bits(void __iomem *reg_addr, unsigned char offset, unsigned char width, unsigned long value);
+#define zx_wrie_bit(addr, offset, val)      	\
+	zx_write_bits(addr, offset, 1, val)
+
+extern void check_led_ver(void);
+extern struct platform_device *zx29_device_table[];
+extern unsigned int zx29_device_table_num;
+
+void __init zx29_map_io(void);
+void __init zx29_clock_init(void);
+void __init zx29_timer_init(void);
+void zx29_restart(char str, const char *cmd);
+void __init i2c_add_devices(void);
+#endif
diff --git a/lynq/S300/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/include/mach/gpio_cfg.h b/lynq/S300/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/include/mach/gpio_cfg.h
new file mode 100755
index 0000000..127c5ec
--- /dev/null
+++ b/lynq/S300/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/include/mach/gpio_cfg.h
@@ -0,0 +1,425 @@
+/*******************************************************************************

+ * Copyright (C) 2016, ZXIC Corporation.

+ *

+ * File Name: gpio_cfg.h

+ * File Mark:

+ * Description:define gpio config for EVB

+

+ * Author:        ZXIC

+ * Date:          2016-07-19

+ *

+ * History 1:

+  ********************************************************************************/

+

+#ifndef _GPIO_CFG_H

+#define _GPIO_CFG_H

+

+/****************************************************************************

+* 	                                           Include files

+****************************************************************************/

+#include <mach/gpio.h>

+

+

+/****************************************************************************

+* 	                                           Local Macros

+****************************************************************************/

+/*

+modules:

+#define  PIN_MODULE_FUNC	      ZX29_GPIO_XX

+*/

+

+

+/******************* Peripherals********************/

+

+#if 0      /*For  Examples*/

+/* Keypad */

+#define	PIN_KEYPAD_KPD_POWER			    ZX29_GPIO_52

+#define	PIN_KEYPAD_KPD_WPS				    ZX29_GPIO_75

+#define	PIN_KEYPAD_KPD_RESET				ZX29_GPIO_76

+#endif

+

+/************************Platform********************/

+

+/**************pmu******************/

+#define PIN_PMU_INT			ZX29_GPIO_47

+#define PIN_PMU_PSHOLD		ZX29_GPIO_24

+

+#define PMU_INT_FUNC_SEL	GPIO47_EXT_INT0

+#define PMU_PSHOLD_FUNC_SEL	GPIO24_GPIO24

+

+/**************charge***************/

+#ifdef CONFIG_ARCH_ZX297520V3_MIFI

+#define PIN_CHARGE_INT							ZX29_GPIO_48

+#define PIN_CHARGE_BOOST_GPIO1				ZX29_GPIO_35

+#define PIN_CHARGE_BOOST_GPIO2				ZX29_GPIO_36

+#define PIN_CHARGE_BOOST_GPIO3				ZX29_GPIO_37

+#define PIN_CHARGE_BOOST_LOADSWITCH			ZX29_GPIO_38

+

+#define CHARGE_INT_FUNC_SEL					GPIO48_EXT_INT1

+#define CHARGE_BOOST_GPIO1_FUNC_SEL			GPIO35_GPIO35

+#define CHARGE_BOOST_GPIO2_FUNC_SEL			GPIO36_GPIO36

+#define CHARGE_BOOST_GPIO3_FUNC_SEL			GPIO37_GPIO37

+#define CHARGE_BOOST_LOADSWITCH_FUNC_SEL	GPIO38_GPIO38

+#elif defined CONFIG_ARCH_ZX297520V3_UFI

+#define PIN_CHARGE_INT							ZX29_GPIO_48

+#define PIN_CHARGE_BOOST_GPIO1				ZX29_GPIO_35

+#define PIN_CHARGE_BOOST_GPIO2				ZX29_GPIO_36

+#define PIN_CHARGE_BOOST_GPIO3				ZX29_GPIO_37

+#define PIN_CHARGE_BOOST_LOADSWITCH			ZX29_GPIO_38

+

+#define CHARGE_INT_FUNC_SEL					GPIO48_EXT_INT1

+#define CHARGE_BOOST_GPIO1_FUNC_SEL			GPIO35_GPIO35

+#define CHARGE_BOOST_GPIO2_FUNC_SEL			GPIO36_GPIO36

+#define CHARGE_BOOST_GPIO3_FUNC_SEL			GPIO37_GPIO37

+#define CHARGE_BOOST_LOADSWITCH_FUNC_SEL	GPIO38_GPIO38

+#elif defined CONFIG_ARCH_ZX297520V3_FWP

+#define PIN_CHARGE_EN_GPIO				ZX29_GPIO_40

+#define PIN_CHARGE_STATE_GPIO			ZX29_GPIO_52

+#define PIN_CHARGE_CTRL_GPIO			ZX29_GPIO_NULL

+#define PIN_CHARGE_CHGIN_GPIO			ZX29_GPIO_49

+

+#define CHARGE_EN_GPIO_SEL				GPIO40_GPIO40

+#define CHARGE_STATE_GPIO_SEL			GPIO52_GPIO52

+#define CHARGE_CTRL_GPIO_SEL			0xff//undefine

+#define CHARGE_CHGIN_GPIO_SEL			GPIO49_GPIO49

+

+#define CHARGE_STATE_FUNC_SEL			GPIO52_EXT_INT5

+#define CHARGE_CHGIN_FUNC_SEL			GPIO49_EXT_INT2

+

+#else

+#define PIN_CHARGE_EN_GPIO				ZX29_GPIO_131

+#define PIN_CHARGE_STATE_GPIO		ZX29_GPIO_54

+#define PIN_CHARGE_CTRL_GPIO			ZX29_GPIO_130

+#define PIN_CHARGE_CHGIN_GPIO		ZX29_GPIO_48

+

+#define CHARGE_EN_GPIO_SEL				GPIO131_GPIO131

+#define CHARGE_STATE_GPIO_SEL			GPIO54_GPIO54

+#define CHARGE_CTRL_GPIO_SEL			GPIO130_GPIO130

+#define CHARGE_CHGIN_GPIO_SEL			GPIO48_GPIO48

+

+#define CHARGE_STATE_FUNC_SEL			GPIO54_EXT_INT7

+#define CHARGE_CHGIN_FUNC_SEL			GPIO48_EXT_INT1

+#endif

+/***************lcd*****************/

+#ifdef CONFIG_ARCH_ZX297520V3_FWP

+#define PIN_LCD_BLG         ZX29_GPIO_53

+#define LCD_BLG_FUNC_SEL	GPIO53_GPIO53

+#define PIN_LCD_RST 		ZX29_GPIO_125

+#define LCD_RST_FUNC_SEL	GPIO125_GPIO125

+#else

+#define PIN_LCD_BLG 		ZX29_GPIO_119

+#define LCD_BLG_FUNC_SEL	GPIO119_GPIO119

+#define PIN_LCD_RST 		ZX29_GPIO_120

+#define LCD_RST_FUNC_SEL	GPIO120_GPIO120

+#endif

+

+#define PIN_SPI_DCX 		ZX29_GPIO_27

+#define SPI_DCX_FUNC_SEL	GPIO27_GPIO27

+

+#define PIN_SPI_CS			ZX29_GPIO_25

+#define PIN_SPI_CLK			ZX29_GPIO_26

+#define PIN_SPI_TXD			ZX29_GPIO_28

+

+#define LCD_CS_SPI_FUNC_SEL		GPIO25_SSP0_CS

+#define LCD_CLK_SPI_FUNC_SEL		GPIO26_SSP0_CLK

+#define LCD_TXD_SPI_FUNC_SEL		GPIO28_SSP0_TXD

+

+#define LCD_CS_GPIO_FUNC_SEL		GPIO25_GPIO25

+#define LCD_CLK_GPIO_FUNC_SEL		GPIO26_GPIO26

+#define LCD_TXD_GPIO_FUNC_SEL		GPIO28_GPIO28

+

+#ifdef  CONFIG_FB_LCD_TE_ON

+#define PIN_LCD_TE 		ZX29_GPIO_49

+#define GPIO_TE_FUNC_SEL GPIO49_EXT_INT2

+#define LCD_TE_INT   EX2_INT

+#define LCD_TE_INT_LEVEL   INT_NEGEDGE

+#endif

+

+/***************led*****************/

+#if defined(CONFIG_ARCH_ZX297520V3_CPE_SWITCH)

+#define PIN_LED_POWER 			ZX29_GPIO_21

+#define PIN_LED_LTE_RED			ZX29_GPIO_45

+#define PIN_LED_LTE_BLUE		ZX29_GPIO_46

+#define PIN_LED_WIFI 		 	ZX29_GPIO_86

+#define PIN_LED_WPS 		 	ZX29_GPIO_72

+#define PIN_LED_RJ11 			ZX29_GPIO_22

+#define PIN_LED_4G_1 			ZX29_GPIO_29

+#define PIN_LED_4G_2 			ZX29_GPIO_30

+#define PIN_LED_4G_3 			ZX29_GPIO_73

+#define PIN_LED_4G_4 			ZX29_GPIO_74

+#define PIN_LED_4G_5 			ZX29_GPIO_75

+

+

+#define LED_POWER_FUNC_SEL 		GPIO21_GPIO21

+#define LED_LTE_RED_FUNC_SEL 	GPIO45_GPIO45

+#define LED_LTE_BLUE_FUNC_SEL 	GPIO46_GPIO46

+#define LED_WIFI_FUNC_SEL 		GPIO86_GPIO86

+#define LED_WPS_FUNC_SEL		GPIO72_GPIO72

+#define LED_RJ11_FUNC_SEL		GPIO22_GPIO22

+#define LED_4G_1_FUNC_SEL		GPIO29_GPIO29

+#define LED_4G_2_FUNC_SEL		GPIO30_GPIO30

+#define LED_4G_3_FUNC_SEL		GPIO73_GPIO73

+#define LED_4G_4_FUNC_SEL		GPIO74_GPIO74

+#define LED_4G_5_FUNC_SEL		GPIO75_GPIO75

+

+#elif defined(CONFIG_ARCH_ZX297520V3_MIFI)

+#ifdef CONFIG_MIN_VERSION

+#define PIN_LED_MODEM_RED 		ZX29_GPIO_75

+#define PIN_LED_MODEM_GREEN 	ZX29_GPIO_73

+#define PIN_LED_MODEM_BLUE 		ZX29_GPIO_74

+//#define PIN_LED_SMS 			ZX29_GPIO_40

+#define PIN_LED_WIFI 		 	ZX29_GPIO_76

+#define PIN_LED_ETH 		 	ZX29_GPIO_77

+#define PIN_LED_BATTARY_RED 	ZX29_GPIO_46

+#define PIN_LED_BATTARY_GREEN 	ZX29_GPIO_72

+

+#define LED_MODEM_RED_FUNC_SEL 		GPIO75_GPIO75

+#define LED_MODEM_GREEN_FUNC_SEL 	GPIO73_GPIO73

+#define LED_MODEM_BLUE_FUNC_SEL 	GPIO74_GPIO74

+//#define LED_SMS_FUNC_SEL 			GPIO40_GPIO40

+#define LED_WIFI_FUNC_SEL 			GPIO76_GPIO76

+#define LED_ETH_FUNC_SEL 			GPIO77_GPIO77

+#define LED_BATTARY_RED_FUNC_SEL 	GPIO46_GPIO46

+#define LED_BATTARY_GREEN_SEL 		GPIO72_GPIO72

+#else

+#define PIN_LED_MODEM_RED 		ZX29_GPIO_124

+//#define PIN_LED_MODEM_GREEN 	ZX29_GPIO_44

+#define PIN_LED_MODEM_BLUE 		ZX29_GPIO_123

+#define PIN_LED_SMS 			ZX29_GPIO_40

+#define PIN_LED_WIFI 		 	ZX29_GPIO_39

+#define PIN_LED_BATTARY_RED 	ZX29_GPIO_42/*red and green changed*/

+#define PIN_LED_BATTARY_GREEN 	ZX29_GPIO_41

+

+#define LED_MODEM_RED_FUNC_SEL 		GPIO124_GPIO124

+//#define LED_MODEM_GREEN_FUNC_SEL 	GPIO44_GPIO44

+#define LED_MODEM_BLUE_FUNC_SEL 	GPIO123_GPIO123

+#define LED_SMS_FUNC_SEL 			GPIO40_GPIO40

+#define LED_WIFI_FUNC_SEL 			GPIO39_GPIO39

+#define LED_BATTARY_RED_FUNC_SEL 	GPIO42_GPIO42

+#define LED_BATTARY_GREEN_SEL 		GPIO41_GPIO41

+#endif/*CONFIG_MIN_VERSION*/

+

+#elif defined(CONFIG_ARCH_ZX297520V3_UFI)

+#ifdef CONFIG_MIN_VERSION

+#define PIN_LED_MODEM_RED 		ZX29_GPIO_124

+#define PIN_LED_MODEM_GREEN 	ZX29_GPIO_125

+//#define PIN_LED_MODEM_BLUE 		ZX29_GPIO_123

+#define PIN_LED_SMS 			ZX29_GPIO_40

+#define PIN_LED_WIFI 		 	ZX29_GPIO_39

+#define PIN_LED_BATTARY_RED 	ZX29_GPIO_41

+#define PIN_LED_BATTARY_GREEN 	ZX29_GPIO_42

+

+#define LED_MODEM_RED_FUNC_SEL 		GPIO124_GPIO124

+#define LED_MODEM_GREEN_FUNC_SEL 	GPIO125_GPIO125

+//#define LED_MODEM_BLUE_FUNC_SEL 	GPIO123_GPIO123

+#define LED_SMS_FUNC_SEL 			GPIO40_GPIO40

+#define LED_WIFI_FUNC_SEL 			GPIO39_GPIO39

+#define LED_BATTARY_RED_FUNC_SEL 	GPIO41_GPIO41

+#define LED_BATTARY_GREEN_SEL 		GPIO42_GPIO42

+#else

+#define PIN_LED_MODEM_RED 		ZX29_GPIO_124

+//#define PIN_LED_MODEM_GREEN 	ZX29_GPIO_44

+#define PIN_LED_MODEM_BLUE 		ZX29_GPIO_123

+#define PIN_LED_SMS 			ZX29_GPIO_40

+#define PIN_LED_WIFI 		 	ZX29_GPIO_39

+#define PIN_LED_BATTARY_RED 	ZX29_GPIO_42/*red and green changed*/

+#define PIN_LED_BATTARY_GREEN 	ZX29_GPIO_41

+

+#define LED_MODEM_RED_FUNC_SEL 		GPIO124_GPIO124

+//#define LED_MODEM_GREEN_FUNC_SEL 	GPIO44_GPIO44

+#define LED_MODEM_BLUE_FUNC_SEL 	GPIO123_GPIO123

+#define LED_SMS_FUNC_SEL 			GPIO40_GPIO40

+#define LED_WIFI_FUNC_SEL 			GPIO39_GPIO39

+#define LED_BATTARY_RED_FUNC_SEL 	GPIO42_GPIO42

+#define LED_BATTARY_GREEN_SEL 		GPIO41_GPIO41

+#endif/*CONFIG_MIN_VERSION*/

+

+#else

+#ifdef _V3PHONE_TYPE_C31F_

+

+#define PIN_LED_FLASHLIGHT			ZX29_GPIO_121

+#define PIN_LED_MOTOR				ZX29_GPIO_125

+#define LED_FLASHLIGHT_FUNC_SEL	GPIO121_GPIO121

+#define LED_MOTOR_FUNC_SEL		GPIO125_GPIO125

+#else

+//#define PIN_LED_FLASHLIGHT			ZX29_GPIO_45

+#define PIN_LED_MOTOR				ZX29_GPIO_120

+

+//#define LED_FLASHLIGHT_FUNC_SEL	GPIO45_GPIO45

+#define LED_MOTOR_FUNC_SEL		GPIO120_GPIO120

+#endif

+#endif

+/***************TP********************/

+#define PIN_TP_IRQ			ZX29_GPIO_51

+#define PIN_TP_RST			ZX29_GPIO_121

+#define TP_IRQ_FUN_SEL		GPIO51_EXT_INT4

+#define TP_RST_GPIO_SEL		GPIO121_GPIO121

+

+/***************kpd*****************/

+/*Keypad (power_on, ufi, ufi_reset) for ufi*/

+#if defined(CONFIG_ARCH_ZX297520V3_CPE_SWITCH)

+#define PIN_KPD_WIFI 		ZX29_GPIO_130

+#define PIN_KPD_WPS 		ZX29_GPIO_131

+#define PIN_KPD_RST 		ZX29_GPIO_49

+

+#define KPD_WIFI_FUNC_GPIO  GPIO130_GPIO130

+#define KPD_WPS_FUNC_GPIO 	GPIO131_GPIO131

+#define KPD_RST_FUNC_GPIO 	GPIO49_GPIO49

+

+#define KPD_WIFI_FUNC_INT	GPIO130_EXT_INT11

+#define KPD_WPS_FUNC_INT 	GPIO131_EXT_INT12

+#define KPD_RST_FUNC_INT	GPIO49_EXT_INT2

+#else

+#define PIN_KPD_WPS 		ZX29_GPIO_131

+#define PIN_KPD_RST 		ZX29_GPIO_126

+/* #define KPD_POWER_FUNC_GPIO GPIO52_GPIO52 */

+#define KPD_WPS_FUNC_GPIO 	GPIO131_GPIO131

+#define KPD_RST_FUNC_GPIO 	GPIO126_GPIO126

+

+/* #define KPD_POWER_FUNC_INT	GPIO52_EXT_INT2 */

+#define KPD_WPS_FUNC_INT 	GPIO131_EXT_INT12

+#define KPD_RST_FUNC_INT	GPIO126_EXT_INT15

+

+#endif

+

+/********************High-speed transaction***********/

+/* SD */

+#define PIN_MMC_TF_CARD_DET ZX29_GPIO_51

+#define PIN_MMC_TF_CARD_DET_FUNC GPIO51_EXT_INT4

+#define PIN_MMC_TF_CARD_DET_GPIO_FUNC GPIO51_GPIO51

+

+/*WIFI*/

+/*-----------------------------------------------------------------------

+                      BUCK_GPIO     |    PWR_CTL     |     CHIP_ENABLE   |    WAKEUP

+-------------------------------------------------------------------------

+ CPE            ZX29_GPIO_77      ZX29_GPIO_42      ZX29_GPIO_71     ZX29_GPIO_57

+-------------------------------------------------------------------------

+ EVB                     --                ZX29_GPIO_27      ZX29_GPIO_71     ZX29_GPIO_57

+-------------------------------------------------------------------------

+ MDL            ZX29_GPIO_77      ZX29_GPIO_42      ZX29_GPIO_71     ZX29_GPIO_57

+-------------------------------------------------------------------------

+ MIFI                    --                ZX29_GPIO_27      ZX29_GPIO_71     ZX29_GPIO_57

+------------------------------------------------------------------------*/

+//SOC bug, GPIO77 must be configed GPIO function before buck3v3 power on..

+#define PIN_WIFI_PWR_BUCK_GPIO			ZX29_GPIO_77

+#define PIN_WIFI_PWR_BUCK_GPIO_SEL		GPIO77_GPIO77

+

+//WIFI power control pin, EVB is 27.

+#define PIN_WIFI_PWR_CTL					ZX29_GPIO_91

+#define PIN_WIFI_PWR_CTL_SEL				GPIO91_GPIO91

+

+//WIFI chip enable pin.

+#ifdef CONFIG_ARCH_ZX297520V3_MIFI

+#define PIN_WIFI_CHIP_ENABLE				ZX29_GPIO_132

+#define PIN_WIFI_CHIP_ENABLE_SEL			GPIO132_GPIO132

+#elif defined (CONFIG_ARCH_ZX297520V3_UFI)

+#define PIN_WIFI_CHIP_ENABLE				ZX29_GPIO_85

+#define PIN_WIFI_CHIP_ENABLE_SEL			GPIO85_GPIO85

+#elif defined (CONFIG_ARCH_ZX297520V3_CPE)

+#define PIN_WIFI_CHIP_ENABLE				ZX29_GPIO_120

+#define PIN_WIFI_CHIP_ENABLE_SEL			GPIO120_GPIO120

+#elif defined (CONFIG_ARCH_ZX297520V3_CPE_SWITCH)

+#define PIN_WIFI_CHIP_ENABLE				ZX29_GPIO_123

+#define PIN_WIFI_CHIP_ENABLE_SEL			GPIO123_GPIO123

+#else

+#define PIN_WIFI_CHIP_ENABLE				ZX29_GPIO_31

+#define PIN_WIFI_CHIP_ENABLE_SEL			GPIO31_GPIO31

+#endif

+

+//WIFI wakeup pin

+#define PIN_WIFI_WAKEUP					ZX29_GPIO_120

+#define PIN_WIFI_WAKEUP_SEL				GPIO120_EXT_INT9

+

+//interrupte of wakeup pin.

+#define INT_WIFI_WAKEUP					PCU_EX9_INT

+

+

+/********************Low-speed transaction***********/

+

+/* UART */

+#define PIN_UART0_RXD     ZX29_GPIO_29	/*GPIO 29 / 30*/

+#define FNC_UART0_RXD	  GPIO29_UART0_RXD

+#define PIN_UART0_TXD     ZX29_GPIO_30	/*GPIO 30 / 29*/

+#define FNC_UART0_TXD	  GPIO30_UART0_TXD

+#define PIN_UART0_CTS     ZX29_GPIO_31	/*GPIO 31 / 120*/

+#define FNC_UART0_CTS     GPIO31_UART0_CTS

+#define PIN_UART0_RTS     ZX29_GPIO_32	/*GPIO 32 / 119*/

+#define FNC_UART0_RTS     GPIO32_UART0_RTS

+

+#define PIN_UART1_RXD     ZX29_GPIO_33   /*GPIO 33 / 32*/

+#define FNC_UART1_RXD	  GPIO33_UART1_RXD

+#define PIN_UART1_TXD     ZX29_GPIO_34   /*GPIO 34 / 31*/

+#define FNC_UART1_TXD	  GPIO34_UART1_TXD

+#define PIN_UART1_CTS     ZX29_GPIO_126  /*GPIO 126*/

+#define FNC_UART1_CTS	  GPIO126_UART1_CTS

+#define PIN_UART1_RTS     ZX29_GPIO_125   /*GPIO 125*/

+#define FNC_UART1_RTS	  GPIO125_UART1_RTS

+

+#define PIN_UART2_RXD     ZX29_GPIO_121  /*GPIO 121 / 33 /34*/

+#define FNC_UART2_RXD	  GPIO121_UART2_RXD

+#define PIN_UART2_TXD     ZX29_GPIO_122  /*GPIO 122 / 34 /33*/

+#define FNC_UART2_TXD	  GPIO122_UART2_TXD

+#define PIN_UART2_CTS     ZX29_GPIO_124  /*GPIO 124*/

+#define FNC_UART2_CTS	  GPIO124_UART2_CTS

+#define PIN_UART2_RTS     ZX29_GPIO_123  /*GPIO 123*/

+#define FNC_UART2_RTS	  GPIO123_UART2_RTS

+

+/************* I2S ***************/

+#define PIN_I2S0_WS		  	ZX29_GPIO_35

+#define PIN_I2S0_CLK		ZX29_GPIO_36

+#define PIN_I2S0_DIN		ZX29_GPIO_37

+#define PIN_I2S0_DOUT		ZX29_GPIO_38

+

+#define PIN_I2S1_WS		  	ZX29_GPIO_39

+#define PIN_I2S1_CLK		ZX29_GPIO_40

+#define PIN_I2S1_DIN		ZX29_GPIO_41

+#define PIN_I2S1_DOUT		ZX29_GPIO_42

+

+#define FUN_I2S0_WS			GPIO35_I2S0_WS

+#define FUN_I2S0_CLK		GPIO36_I2S0_CLK

+#define FUN_I2S0_DIN		GPIO37_I2S0_DIN

+#define FUN_I2S0_DOUT		GPIO38_I2S0_DOUT

+

+#define FUN_I2S1_WS		    GPIO39_I2S1_WS

+#define FUN_I2S1_CLK		GPIO40_I2S1_CLK

+#define FUN_I2S1_DIN		GPIO41_I2S1_DIN

+#define FUN_I2S1_DOUT		GPIO42_I2S1_DOUT

+

+/************* TDM ***************/

+#ifdef CONFIG_ARCH_ZX297520V3_CPE_SWITCH

+

+#define PIN_TDM_FS		  	ZX29_GPIO_39

+#define PIN_TDM_CLK			ZX29_GPIO_40

+#define PIN_TDM_DIN			ZX29_GPIO_41

+#define PIN_TDM_DOUT		ZX29_GPIO_42

+

+#define FUN_TDM_FS			GPIO39_TDM_FS

+#define FUN_TDM_CLK			GPIO40_TDM_CLK

+#define FUN_TDM_DIN			GPIO41_TDM_DATA_IN

+#define FUN_TDM_DOUT		GPIO42_TDM_DATA_OUT

+

+#else

+#define PIN_TDM_FS		  	ZX29_GPIO_35

+#define PIN_TDM_CLK			ZX29_GPIO_36

+#define PIN_TDM_DIN			ZX29_GPIO_37

+#define PIN_TDM_DOUT		ZX29_GPIO_38

+

+#define FUN_TDM_FS			GPIO35_TDM_FS

+#define FUN_TDM_CLK			GPIO36_TDM_CLK

+#define FUN_TDM_DIN			GPIO37_TDM_DATA_IN

+#define FUN_TDM_DOUT		GPIO38_TDM_DATA_OUT

+#endif

+

+/************* CODEC ***************/

+#define CODEC_EN            ZX29_GPIO_123

+#define CODEC_REFCLK        ZX29_GPIO_15

+#define CODEC_RESET         ZX29_GPIO_122

+#define PIN_EARP_INT        ZX29_GPIO_53

+#define EARP_INT_FUNC_SEL   GPIO53_EXT_INT6

+

+/************* SLIC ***************/

+#ifdef CONFIG_ARCH_ZX297520V3_CPE_SWITCH

+#define SLIC_PWR_CTRL       ZX29_GPIO_132

+#endif

+

+#endif

diff --git a/lynq/S300/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/zx297520v3-mifi-devices.c b/lynq/S300/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/zx297520v3-mifi-devices.c
new file mode 100755
index 0000000..f568f29
--- /dev/null
+++ b/lynq/S300/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/zx297520v3-mifi-devices.c
@@ -0,0 +1,1473 @@
+/*
+ * arch/arm/mach-zx297520v3/zx297520v3_devices.c
+ *
+ *  Copyright (C) 2015 ZTE-TSP
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+
+#include <linux/dma-mapping.h>
+#include <linux/platform_device.h>
+#include <linux/soc/zte/rpm/rpmsg.h>
+#include <linux/i2c.h>
+
+#include <mach/dma.h>
+#include <mach/board.h>
+#include <mach/iomap.h>
+#include <mach/irqs.h>
+#include <mach/i2c.h>
+#include <mach/gpio.h>
+#include <mach/zx29_mmc.h>
+#include <mach/zx29_uart_def.h>
+#include <linux/soc/zte/tsc/tsc.h>
+
+#if (defined CONFIG_SPI_ZX29) || (defined CONFIG_SPI_GPIO)
+#include <linux/spi/spi.h>
+#include <linux/spi/spi_gpio.h>
+#include <mach/spi.h>
+#include <linux/video/zx29_lcd.h>
+#endif
+
+#ifdef CONFIG_CHARGER_ZX234502
+#include <linux/power/zx234502_charger.h>
+#endif
+#ifdef CONFIG_CHARGER_AW3215
+#include <linux/power/aw3215_charger.h>
+#endif
+#ifdef CONFIG_LEDS_GPIO
+#include <linux/leds.h>
+#include <mach/gpio.h>
+#include <linux/gpio.h>
+#endif
+#ifdef CONFIG_MMC_ZX29
+#include <linux/mmc/host.h>
+#endif
+#ifdef CONFIG_KEYBOARD_ZX_INT
+#include <linux/input.h>
+#include <linux/gpio_keys.h>
+#endif
+#ifdef CONFIG_KEYBOARD_ZX_5x6
+#include <linux/input.h>
+#include <linux/input/zx29_keypad_5x6.h>
+#endif
+#ifdef CONFIG_ZX29_GMAC
+#include <linux/gmac/gmac.h>
+#endif
+#ifdef CONFIG_MFD_ZX234290_I2C
+#include <linux/mfd/zx234290.h>
+#endif
+
+#if (defined CONFIG_SND_SOC_ZX297520V3) || (defined CONFIG_SND_SOC_ZX297520V3_MODULE)
+#include <sound/zx29_snd_platform.h>
+#endif
+#include <mach/gpio_cfg.h>
+
+
+struct zx29_uart_platdata  zx29_uart0_platdata= {
+		.uart_use = 1,
+		.uart_rxd.gpioname = "uart0_rxd",
+		.uart_rxd.gpionum = PIN_UART0_RXD,
+		.uart_rxd.gpiofnc = FNC_UART0_RXD,
+		.uart_txd.gpioname = "uart0_txd",
+		.uart_txd.gpionum = PIN_UART0_TXD,
+		.uart_txd.gpiofnc = FNC_UART0_TXD,
+		.uart_ctsrtsuse = 0,
+		.uart_cts.gpioname = "uart0_cts",
+		.uart_cts.gpionum= PIN_UART0_CTS ,
+		.uart_cts.gpiofnc = FNC_UART0_CTS ,
+		.uart_rts.gpioname = "uart0_rts",
+		.uart_rts.gpionum =PIN_UART0_RTS,
+		.uart_rts.gpiofnc = FNC_UART0_RTS,
+		.uart_abauduse = 0,
+		.uart_input_enable = 0,
+};
+struct zx29_uart_platdata  zx29_uart1_platdata= {
+		.uart_use = 1,
+		.uart_rxd.gpioname = "uart1_rxd",
+		.uart_rxd.gpionum = PIN_UART1_RXD,
+		.uart_rxd.gpiofnc = FNC_UART1_RXD,
+		.uart_txd.gpioname = "uart1_txd",
+		.uart_txd.gpionum = PIN_UART1_TXD,
+		.uart_txd.gpiofnc = FNC_UART1_TXD,
+		.uart_ctsrtsuse = 0,
+		.uart_cts.gpioname = "uart1_cts",
+		.uart_cts.gpionum= PIN_UART1_CTS ,
+		.uart_cts.gpiofnc = FNC_UART1_CTS ,
+		.uart_rts.gpioname = "uart1_rts",
+		.uart_rts.gpionum = PIN_UART1_RTS,
+		.uart_rts.gpiofnc = FNC_UART1_RTS,
+		.uart_abauduse = 0,
+		.uart_input_enable = 0,
+};
+struct zx29_uart_platdata  zx29_uart2_platdata= {
+		.uart_use = 0,
+		.uart_rxd.gpioname = "uart2_rxd",
+		.uart_rxd.gpionum = PIN_UART2_RXD,
+		.uart_rxd.gpiofnc = FNC_UART2_RXD,
+		.uart_txd.gpioname = "uart2_txd",
+		.uart_txd.gpionum = PIN_UART2_TXD,
+		.uart_txd.gpiofnc = FNC_UART2_TXD,
+		.uart_ctsrtsuse = 0,
+		.uart_cts.gpioname = "uart2_cts",
+		.uart_cts.gpionum= PIN_UART2_CTS ,
+		.uart_cts.gpiofnc = FNC_UART2_CTS ,
+		.uart_rts.gpioname = "uart2_rts",
+		.uart_rts.gpionum = PIN_UART2_RTS,
+		.uart_rts.gpiofnc = FNC_UART2_RTS,
+		.uart_abauduse = 0,
+		.uart_input_enable = 0,
+};
+/* --------------------------------------------------------------------
+ *  UART
+ * -------------------------------------------------------------------- */
+#ifdef CONFIG_SERIAL_ZX29_UART
+/* UART0*/
+static struct resource zx29_uart0_resources[] = {
+	[0] = {
+		.start	= ZX29_UART0_PHYS,
+		.end	= ZX29_UART0_PHYS + SZ_4K - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= UART0_MIX_INT,
+		.end	= UART0_MIX_INT,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device zx29_uart0_device = {
+	.name		= "zx29_uart",
+	.id		= 0,
+	.resource	= zx29_uart0_resources,
+	.num_resources	= ARRAY_SIZE(zx29_uart0_resources),
+	.dev = {
+		.platform_data = &zx29_uart0_platdata,
+	}
+};
+/* UART2*/
+static struct resource zx29_uart1_resources[] = {
+	[0] = {
+		.start	= ZX29_UART1_PHYS,
+		.end	= ZX29_UART1_PHYS + SZ_4K - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= UART1_MIX_INT,
+		.end	= UART1_MIX_INT,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device zx29_uart1_device = {
+	.name		= "zx29_uart",
+	.id		= 1,
+	.resource	= zx29_uart1_resources,
+	.num_resources	= ARRAY_SIZE(zx29_uart1_resources),
+	.dev = {
+		.platform_data = &zx29_uart1_platdata,
+	}
+};
+
+/* UART2*/
+static struct resource zx29_uart2_resources[] = {
+	[0] = {
+		.start	= ZX29_UART2_PHYS,
+		.end	= ZX29_UART2_PHYS + SZ_4K - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= UART2_MIX_INT,
+		.end	= UART2_MIX_INT,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device zx29_uart2_device = {
+	.name		= "zx29_uart",
+	.id		= 2,
+	.resource	= zx29_uart2_resources,
+	.num_resources	= ARRAY_SIZE(zx29_uart2_resources),
+	.dev = {
+		.platform_data = & zx29_uart2_platdata,
+	}
+};
+#endif
+
+/* --------------------------------------------------------------------
+ *	DMA -- Direct Memory Access
+* -------------------------------------------------------------------- */
+#ifdef CONFIG_ZX29_DMA
+static struct resource zx29_dma_res[] = {
+	[0] = {
+		.start	= (u32)ZX_DMA_PS_BASE,
+		.end	= (u32)ZX_DMA_PS_BASE + SZ_4K - 1,
+		.flags  = IORESOURCE_MEM,
+	},
+	[1] = {
+		.start = PS_DMA_INT,
+		.end   = PS_DMA_INT,
+		.flags = IORESOURCE_IRQ,
+	},
+};
+static struct platform_device zx29_dma_device = {
+	.name = "zx29_dma",
+	.id = 0,
+	.resource = zx29_dma_res,
+	.num_resources	= ARRAY_SIZE(zx29_dma_res),
+};
+#endif
+
+#if (defined CONFIG_SND_SOC_ZX297520V3) || (defined CONFIG_SND_SOC_ZX297520V3_MODULE)
+
+static struct platform_device zx29_audio = {
+	.name		= SND_MACHINE_PDEV_NAME,
+	.id		= -1,
+	.dev		= {
+		.platform_data	= ZX29_SND_MACH_PDATA, //&snd_machine_pdata,
+	},
+};
+#endif
+
+#if (defined CONFIG_SND_SOC_ZX_PCM) || (defined CONFIG_SND_SOC_ZX_PCM_MODULE)
+/* ASOC DMA */
+static unsigned long long zx29_device_dma_mask = DMA_BIT_MASK(32);
+
+struct platform_device zx29_asoc_dma = {
+	.name		= "zx29-pcm-audio",
+	.id		= -1,
+	.dev		= {
+		.dma_mask		= &zx29_device_dma_mask,
+		.coherent_dma_mask	= DMA_BIT_MASK(32),
+	}
+};
+#endif
+
+/* --------------------------------------------------------------------
+ *	I2S
+* -------------------------------------------------------------------- */
+//#ifdef CONFIG_SND_SOC_ZX_I2S
+#if (defined CONFIG_SND_SOC_ZX_I2S) || (defined CONFIG_SND_SOC_ZX_I2S_MODULE)
+#define zx29_I2S0	1
+//#define zx29_I2S1	1
+
+#ifdef zx29_I2S0
+/* I2S0 */
+static struct resource i2s0_res[] = {
+	[0] = {
+		.start	= (u32)ZX_I2S0_BASE,
+		.end	= (u32)ZX_I2S0_BASE + SZ_4K - 1,
+		.flags  = IORESOURCE_MEM,
+	},
+	[1] = {
+		.start = DMA_CH_I2S0_TX,
+		.end   = DMA_CH_I2S0_TX,
+		.flags = IORESOURCE_DMA,
+	},
+	[2] = {
+		.start = DMA_CH_I2S0_RX0,
+		.end   = DMA_CH_I2S0_RX0,
+		.flags = IORESOURCE_DMA,
+	},
+};
+static struct platform_device zx29_i2s0_device = {
+	.name = "zx29_i2s",
+	.id = 0,
+	.resource = i2s0_res,
+	.num_resources	= ARRAY_SIZE(i2s0_res),
+};
+#endif
+
+#ifdef zx29_I2S1
+static struct resource i2s1_res[] = {
+	[0] = {
+		.start	= (u32)ZX_I2S1_BASE,
+		.end	= (u32)ZX_I2S1_BASE + SZ_4K - 1,
+		.flags  = IORESOURCE_MEM,
+	},
+	[1] = {
+		.start = DMA_CH_I2S1_TX,
+		.end   = DMA_CH_I2S1_TX,
+		.flags = IORESOURCE_DMA,
+	},
+	[2] = {
+		.start = DMA_CH_I2S1_RX0,
+		.end   = DMA_CH_I2S1_RX0,
+		.flags = IORESOURCE_DMA,
+	},
+};
+static struct platform_device zx29_i2s1_device = {
+	.name = "zx29_i2s",
+	.id = 1,
+	.resource = i2s1_res,
+	.num_resources	= ARRAY_SIZE(i2s1_res),
+};
+#endif
+#endif
+
+#if (defined CONFIG_SND_SOC_ZX_VOICE) || (defined CONFIG_SND_SOC_ZX_VOICE_MODULE)
+static struct platform_device voice_asoc_device = {
+	.name = "voice_audio",
+	.id = -1,
+};
+#endif
+/* --------------------------------------------------------------------
+ *  MMC / SD
+ * -------------------------------------------------------------------- */
+#ifdef CONFIG_MMC_ZX29
+static struct resource zx29_sdmmc0_resources[] = {
+	[0] = {
+		.start	= ZX_SD0_BASE,
+		.end	= ZX_SD0_BASE + SZ_4K - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= SD0_INT,
+		.end	= SD0_INT,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+struct dw_mci_board zx29_sdmmc0_platdata = {
+	.num_slots	= 1,
+#if 1//def CONFIG_RTL8192CD
+	.quirks = DW_MCI_QUIRK_BROKEN_CARD_DETECTION | DW_MCI_QUIRK_SDIO \
+	| DW_MCI_QUIRK_UNALIGN_DMA_SZ | DW_MCI_QUIRK_UNALIGN_DMA_START |DW_MCI_QUIRK_CLK_PHASE_TURN ,
+	.caps	= (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |MMC_CAP_UHS_SDR50 | MMC_CAP_SDIO_IRQ |MMC_CAP_NONREMOVABLE),
+#else
+	.quirks = DW_MCI_QUIRK_BROKEN_CARD_DETECTION | DW_MCI_QUIRK_SDIO,
+	.caps	= (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |MMC_CAP_UHS_SDR50),
+#endif
+
+#ifdef CONFIG_SSV6X5X
+	.bus_hz = 50*1000*1000,
+#else
+	.bus_hz = 100*1000*1000,
+#ifdef CONFIG_AIC8800
+	.bus_hz = 100*1000*1000,
+#endif
+#endif
+	.pm_caps = MMC_PM_KEEP_POWER | MMC_PM_IGNORE_PM_NOTIFY,
+	.data1_irq = SD0_DATA1_INT,
+};
+static struct platform_device zx29_sdmmc0_device = {
+	.name		= "zx29_sd",
+	.id		= 0,
+	.resource	= zx29_sdmmc0_resources,
+	.num_resources	= ARRAY_SIZE(zx29_sdmmc0_resources),
+	.dev		= {
+		.coherent_dma_mask	= 0xffffffffUL,
+		.platform_data		= &zx29_sdmmc0_platdata,
+	},
+};
+static struct resource zx29_sdmmc1_resources[] = {
+	[0] = {
+		.start	= ZX_SD1_BASE,
+		.end	= ZX_SD1_BASE + SZ_4K - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= SD1_INT,
+		.end	= SD1_INT,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+struct dw_mci_board zx29_sdmmc1_platdata = {
+	.num_slots	= 1,
+#ifdef CONFIG_XR_WLAN
+	.quirks = DW_MCI_QUIRK_BROKEN_CARD_DETECTION | DW_MCI_QUIRK_SDIO \
+	| DW_MCI_QUIRK_UNALIGN_DMA_SZ | DW_MCI_QUIRK_UNALIGN_DMA_START,
+	.bus_hz = 100*1000*1000,
+	.caps	= (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |MMC_CAP_UHS_SDR50 | MMC_CAP_SDIO_IRQ|MMC_CAP_NONREMOVABLE),
+	.pm_caps = MMC_PM_KEEP_POWER | MMC_PM_IGNORE_PM_NOTIFY,
+	.data1_irq = SD1_DATA1_INT,
+#else
+     .bus_hz = 50*1000*1000,
+	 .caps	= (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
+     .detect_delay_ms = 500,
+#endif
+	//.init = sdmmc_init,
+	//.setpower = sdmmc_set_power,
+
+	//.detect_delay_ms = 500,
+};
+
+
+static struct platform_device zx29_sdmmc1_device = {
+	.name		= "zx29_sd",
+	.id		= 1,
+	.resource	= zx29_sdmmc1_resources,
+	.num_resources	= ARRAY_SIZE(zx29_sdmmc1_resources),
+	.dev		= {
+		.coherent_dma_mask	= 0xffffffffUL,
+		.platform_data		= &zx29_sdmmc1_platdata,
+	},
+};
+#endif
+
+/* --------------------------------------------------------------------
+ *  NAND
+ * -------------------------------------------------------------------- */
+#ifdef CONFIG_MTD_ZXIC_SPIFC
+ static struct resource spi_nand_resource[] = {
+	  [0] = {
+		  .start  = ZX_SPIFC0_BASE,
+		  .end	  = ZX_SPIFC0_BASE + SZ_4K - 1,
+		  .flags  = IORESOURCE_MEM,
+		  .name   = "spifc_reg",
+	  },
+	  [2] = {
+		  .start  = SPI_FC0_INT,
+		  .end	  = SPI_FC0_INT,
+		  .flags  = IORESOURCE_IRQ,
+
+	  },
+  };
+#endif
+#ifdef CONFIG_MTD_NAND_DENALI
+static struct resource denali_nand_resource[] = {
+	[0] = {
+		.start	= ZX_NAND_REG_BASE,
+		.end	= ZX_NAND_REG_BASE + SZ_4K - 1,
+		.flags	= IORESOURCE_MEM,
+		.name   = "denali_reg",
+	},
+	[1] = {
+		.start	= ZX_NAND_DATA_BASE,
+		.end	= ZX_NAND_DATA_BASE + SZ_4K - 1,
+		.flags	= IORESOURCE_MEM,
+		.name   = "nand_data",
+	},
+    [2] = {
+		.start	= NAND_INT,
+		.end	= NAND_INT,
+		.flags	= IORESOURCE_IRQ,
+
+	},
+};
+struct denali_nand_data {
+	struct mtd_partition *parts;
+	int (*dev_ready)(struct mtd_info *mtd);
+	u32 nr_parts;
+	u8 ale;		/* address line number connected to ALE */
+	u8 cle;		/* address line number connected to CLE */
+	u8 width;	/* buswidth */
+	u8 chip_delay;
+};
+static struct denali_nand_data zx29_nand_data = {
+	.cle		= 0,
+	.ale		= 1,
+	.width		= 8,
+};
+struct platform_device zx29_device_nand = {
+	.name		= "denali-nand-dt",
+	.id		= -1,
+	.dev		= {
+		.platform_data	= &zx29_nand_data,
+	},
+	.num_resources	= ARRAY_SIZE(denali_nand_resource),
+	.resource	= denali_nand_resource,
+};
+#endif
+
+#ifdef CONFIG_MTD_ZXIC_SPIFC
+struct platform_device zx29_device_spi_nand = {
+	.name		= "spi-nand-dt",
+	.id		= -1,
+	.num_resources	= ARRAY_SIZE(spi_nand_resource),
+	.resource	= spi_nand_resource,
+};
+#endif
+
+/*
+ *--------------------------------------------------------------------
+ *  						NOR
+ * --------------------------------------------------------------------
+ */
+
+#ifdef CONFIG_SPI_ZXIC_NOR
+ static struct resource spi_nor_resource[] = {
+	  [0] = {
+		  .start  = ZX_SPIFC0_BASE,
+		  .end	  = ZX_SPIFC0_BASE + SZ_4K - 1,
+		  .flags  = IORESOURCE_MEM,
+		  .name   = "spi_nor_reg",
+	  },
+	  [2] = {
+		  .start  = SPI_FC0_INT,
+		  .end	  = SPI_FC0_INT,
+		  .flags  = IORESOURCE_IRQ,
+
+	  },
+  };
+
+struct platform_device zx29_device_spi_nor = {
+	.name		= "spi-nor-dt",
+	.id		= -1,
+	.num_resources	= ARRAY_SIZE(spi_nor_resource),
+	.resource	= spi_nor_resource,
+};
+#endif
+
+
+
+/* --------------------------------------------------------------------
+ *  I2C
+ * -------------------------------------------------------------------- */
+#ifdef CONFIG_I2C_ZX29
+
+#define zx29_pmic_i2c	1
+#define zx29_I2C0		1
+
+
+#ifdef zx29_pmic_i2c
+static struct zx29_i2c_platform_data zx29_pmic_i2c_platform_data = {
+	.bus_clk_rate   = 300000,
+};
+
+static struct resource pmic_i2c_resources[] = {
+	[0] = {
+		.start	= (u32)ZX_PMIC_I2C_BASE,
+		.end	= (u32)ZX_PMIC_I2C_BASE + SZ_4K - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= I2C0_INT,
+		.end	= I2C0_INT,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device zx29_pmic_i2c_device = {
+	.name		= "zx29_i2c",
+	.id 	    = 0,
+	.resource	= pmic_i2c_resources,
+	.num_resources	= ARRAY_SIZE(pmic_i2c_resources),
+	.dev = {
+		.platform_data = &zx29_pmic_i2c_platform_data,
+	},
+};
+#endif
+
+#ifdef zx29_I2C0
+static struct zx29_i2c_platform_data zx29_i2c0_platform_data = {
+	.bus_clk_rate	 = 300000,
+};
+
+static struct resource i2c0_resources[] = {
+	[0] = {
+		.start	= (u32)ZX_I2C1_BASE,
+		.end	= (u32)ZX_I2C1_BASE + SZ_4K - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= I2C1_INT,
+		.end	= I2C1_INT,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device zx29_i2c0_device = {
+	.name		= "zx29_i2c",
+	.id 	    = 1,
+	.resource	= i2c0_resources,
+	.num_resources	= ARRAY_SIZE(i2c0_resources),
+	.dev = {
+		.platform_data = &zx29_i2c0_platform_data,
+	},
+};
+#endif
+
+
+#endif //end CONFIG_I2C_ZX29
+
+/* --------------------------------------------------------------------
+ *  SPI
+ * -------------------------------------------------------------------- */
+#ifdef CONFIG_SPI_ZX29
+static struct resource spi0_resources[] = {
+	[0]={
+		.start	= ZX_SSP0_BASE,
+		.end	= ZX_SSP0_BASE + SZ_32 - 1,
+		.name	= "registers",
+		.flags	= IORESOURCE_MEM,
+	},
+	[1]={
+		.start	= SSP0_INT,
+		.end	= SSP0_INT,
+		.name	= "interrupt",
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct zx29_spi_controller spi0_data ={
+	.bus_id = 0,
+	.num_chipselect = 1,
+	.enable_dma = 1,
+	.autosuspend_delay=0,
+	.dma_tx_param = (void*) DMA_CH_SSP0_TX,
+	.dma_rx_param = (void*) DMA_CH_SSP0_RX,
+};
+
+static struct platform_device zx29_ssp0_device = {
+	.name		= "zx29_ssp",
+	.id 	= 0,
+	.dev	={
+			.platform_data = &spi0_data,
+		},
+	.resource	= spi0_resources,
+	.num_resources	= ARRAY_SIZE(spi0_resources),
+};
+#endif
+
+/* --------------------------------------------------------------------
+ *  USB
+ * -------------------------------------------------------------------- */
+#ifdef CONFIG_DWC_OTG_USB
+/* USB 20*/
+static struct resource zx29_usb0_resources[] = {
+	[0] = {
+		.start	= ZX29_USB_PHYS,
+		.end	= ZX29_USB_PHYS + SZ_256K - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.name   = "usb_int",
+		.start	= USB_INT,
+		.end	= USB_INT,
+		.flags	= IORESOURCE_IRQ,
+	},
+	[2] = {
+	 	 .name   = "usb_powerdown_up",
+		 .start  = USB_POWERDWN_UP_INT,
+		 .end	 = USB_POWERDWN_UP_INT,
+		 .flags  = IORESOURCE_IRQ,
+	},
+	[3] = {
+	 	 .name   = "usb_powerdown_down",
+		 .start  = USB_POWERDWN_DOWN_INT,
+		 .end	 = USB_POWERDWN_DOWN_INT,
+		 .flags  = IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device zx29_usb0_device = {
+	.name		= "zx29_hsotg",
+	.id		= 0,
+	.resource	= zx29_usb0_resources,
+	.num_resources	= ARRAY_SIZE(zx29_usb0_resources),
+};
+#endif
+
+#ifdef CONFIG_USB_DWC_OTG_HCD
+ /* HSIC*/
+static struct resource zx29_usb1_resources[] = {
+ [0] = {
+	 .start  = ZX29_HSIC_PHYS,
+	 .end	 = ZX29_HSIC_PHYS + SZ_256K - 1,
+	 .flags  = IORESOURCE_MEM,
+ },
+ [1] = {
+ 	 .name   = "hsic_int",
+	 .start  = HSIC_INT,
+	 .end	 = HSIC_INT,
+	 .flags  = IORESOURCE_IRQ,
+ },
+ [2] = {
+ 	 .name   = "hsic_powerdown_up",
+	 .start  = HSIC_POWERDWN_UP_INT,
+	 .end	 = HSIC_POWERDWN_UP_INT,
+	 .flags  = IORESOURCE_IRQ,
+ },
+ [3] = {
+ 	 .name   = "hsic_powerdown_down",
+	 .start  = HSIC_POWERDWN_DOWN_INT,
+	 .end	 = HSIC_POWERDWN_DOWN_INT,
+	 .flags  = IORESOURCE_IRQ,
+ },
+};
+
+static struct platform_device zx29_usb1_device = {
+ .name		 = "zx29_hsic",
+ .id	 = 1,
+ .resource	 = zx29_usb1_resources,
+ .num_resources  = ARRAY_SIZE(zx29_usb1_resources),
+};
+#endif
+
+/* --------------------------------------------------------------------
+ * ICP
+ * -------------------------------------------------------------------- */
+#ifdef CONFIG_RPM_ZX29
+ /*ICP_M0/ICP_ARM0*/
+static struct zx29_rpmsg_platform_data rpmsg_m0_platform_data = {
+	.iram_send_base	= (u32)ICP_IRAM_APM0_BASEADDR,
+	.iram_send_size	= ICP_IRAM_APM0_SIZE,
+  	.iram_recv_base	= (u32)ICP_IRAM_M0AP_BASEADDR,
+	.iram_recv_size	= ICP_IRAM_M0AP_SIZE,
+  	.ddr_send_base	= (u32)ICP_DDR_APM0_BASEADDR,
+  	.ddr_send_size	= ICP_DDR_APM0_SIZE,
+  	.ddr_recv_base	= (u32)ICP_DDR_M0AP_BASEADDR,
+  	.ddr_recv_size	= ICP_DDR_M0AP_SIZE,
+  	.max_channel_cnt= CHANNEL_AP2M0_MAXID,
+};
+
+static struct resource icp_m0_resources[] = {
+	[0] = {
+		.start	= ICP_M02PS_INT,
+		.end	= ICP_M02PS_INT,
+		.flags	= IORESOURCE_IRQ,
+	},
+	[1] = {
+		.start	= (u32)ZX29_ICP_APM0_REG,
+		.end	= (u32)ZX29_ICP_APM0_REG + 0x30,
+		.flags	= IORESOURCE_MEM,
+		.name 	= "icp",
+	},
+
+};
+
+static struct zx29_rpmsg_platform_data rpmsg_ps_platform_data = {
+	.iram_send_base	= (u32)ICP_IRAM_APPS_BASEADDR,
+	.iram_send_size	= ICP_IRAM_APPS_SIZE,
+  	.iram_recv_base	= (u32)ICP_IRAM_PSAP_BASEADDR,
+	.iram_recv_size	= ICP_IRAM_PSAP_SIZE,
+  	.ddr_send_base	= (u32)ICP_DDR_APPS_BASEADDR,
+  	.ddr_send_size	= ICP_DDR_APPS_SIZE,
+  	.ddr_recv_base	= (u32)ICP_DDR_PSAP_BASEADDR,
+  	.ddr_recv_size	= ICP_DDR_PSAP_SIZE,
+  	.max_channel_cnt= CHANNEL_AP2PS_MAXID,
+};
+
+static struct resource icp_ps_resources[] = {
+	[0] = {
+		.start	= ICP_AP2PS_INT,
+		.end	= ICP_AP2PS_INT,
+		.flags	= IORESOURCE_IRQ,
+	},
+	[1] = {
+		.start	= (u32)ZX29_ICP_APPS_REG,
+		.end	= (u32)ZX29_ICP_APPS_REG + 0x30,
+		.flags	= IORESOURCE_MEM,
+		.name 	= "icp",
+	},
+};
+
+/* AP <--> m0 */
+static struct platform_device zx29_icp_m0_device = {
+	.name		= "icp",
+	.id			= 0,
+	.resource	= icp_m0_resources,
+	.num_resources	= ARRAY_SIZE(icp_m0_resources),
+	.dev = {
+		.platform_data = &rpmsg_m0_platform_data,
+	},
+};
+
+/* AP <--> ps */
+static struct platform_device zx29_icp_ps_device = {
+	.name		= "icp",
+	.id			= 1,
+	.resource	= icp_ps_resources,
+	.num_resources	= ARRAY_SIZE(icp_ps_resources),
+	.dev = {
+		.platform_data = &rpmsg_ps_platform_data,
+	},
+};
+#endif
+
+/* --------------------------------------------------------------------
+ *	WDT -- ap watchdog timer
+* -------------------------------------------------------------------- */
+#ifdef CONFIG_ZX29_WATCHDOG
+static struct resource wdt_res[] = {
+	[0] = {
+		.start	= (u32)ZX_AP_WDT_BASE,
+		.end	= (u32)ZX_AP_WDT_BASE + SZ_4K - 1,
+		.flags  = IORESOURCE_MEM,
+	},
+	[1] = {
+		.start = WDT_INT,
+		.end   = WDT_INT,
+		.flags = IORESOURCE_IRQ,
+	},
+};
+static struct platform_device zx29_wdt_device = {
+	.name = "zx29_ap_wdt",
+	.id = 0,
+	.resource = wdt_res,
+	.num_resources	= ARRAY_SIZE(wdt_res),
+};
+#endif
+
+#ifdef CONFIG_LEDS_GPIO
+
+struct gpio_led leds[]={
+	{
+		.name = "modem_r_led",
+		.pin_select = 0,/*gpio*/
+		.gpio = PIN_LED_MODEM_RED,
+		.func = LED_MODEM_RED_FUNC_SEL,
+		.active_low = 0,
+	},
+	#ifdef CONFIG_MIN_VERSION
+	{
+		.name = "modem_g_led",	
+			.pin_select = 0,/*gpio*/
+		.gpio = PIN_LED_MODEM_GREEN,
+		.func = LED_MODEM_GREEN_FUNC_SEL,
+		.active_low = 0,
+	},
+	{
+		.name = "modem_b_led",
+		.pin_select = 0,/*gpio*/
+		.gpio = PIN_LED_MODEM_BLUE,
+		.func = LED_MODEM_BLUE_FUNC_SEL,
+		.active_low = 0,
+	},
+	#endif
+	{
+		.name = "eth_led",
+		.pin_select = 0,/*gpio*/
+		.gpio = PIN_LED_ETH,
+		.func = LED_ETH_FUNC_SEL,
+		.active_low = 0,
+	},
+	{
+		.name = "wifi_led",	
+		.pin_select = 0,/*gpio*/
+		.gpio = PIN_LED_WIFI,
+		.func = LED_WIFI_FUNC_SEL,
+		.active_low = 0,
+	},
+	{
+		.name = "battery_r_led",			
+		.pin_select = 0,/*gpio*/
+		.gpio = PIN_LED_BATTARY_RED,
+		.func = LED_BATTARY_RED_FUNC_SEL,
+		.active_low = 0,
+		.default_state=LEDS_GPIO_DEFSTATE_ON,
+	},
+	{
+		.name = "battery_g_led",
+		.pin_select = 0,/*gpio*/
+		.gpio = PIN_LED_BATTARY_GREEN,
+		.func = LED_BATTARY_GREEN_SEL,
+		.active_low = 0,
+		//.hw_timer = 1,
+		//.retain_state_suspended = 1,
+	}/*,
+	{
+		.name = "sink1",
+		.pin_select = 1,
+		//.gpio = PIN_LED_BATTARY_GREEN,
+		//.func = LED_BATTARY_GREEN_SEL,
+		.active_low = 0,
+		//.hw_timer = 1,
+		//.retain_state_suspended = 1,
+	}*/
+	
+};
+
+struct gpio_led new_ver_leds[]={
+	{
+		.name = "modem_r_led",
+		.pin_select = 0,/*gpio*/
+		.gpio = ZX29_GPIO_123,
+		.func = GPIO123_GPIO123,
+		.active_low = 0,
+	},
+	#ifdef CONFIG_MIN_VERSION
+	{
+		.name = "modem_g_led",	
+			.pin_select = 0,/*gpio*/
+		.gpio = ZX29_GPIO_46,
+		.func = GPIO46_GPIO46,
+		.active_low = 0,
+	},
+	{
+		.name = "modem_b_led",
+		.pin_select = 0,/*gpio*/
+		.gpio = ZX29_GPIO_122,
+		.func = GPIO122_GPIO122,
+		.active_low = 0,
+	},
+	#endif
+	{
+		.name = "eth_led",
+		.pin_select = 0,/*gpio*/
+		.gpio = ZX29_GPIO_121,
+		.func = GPIO121_GPIO121,
+		.active_low = 0,
+	},
+	{
+		.name = "wifi_led",	
+		.pin_select = 0,/*gpio*/
+		.gpio = ZX29_GPIO_124,
+		.func = GPIO124_GPIO124,
+		.active_low = 0,
+	},
+	{
+		.name = "battery_r_led",			
+		.pin_select = 0,/*gpio*/
+		.gpio = ZX29_GPIO_73,
+		.func = GPIO73_GPIO73,
+		.active_low = 0,
+		.default_state=LEDS_GPIO_DEFSTATE_ON,
+	},
+	{
+		.name = "battery_g_led",
+		.pin_select = 0,/*gpio*/
+		.gpio = PIN_LED_BATTARY_GREEN,
+		.func = LED_BATTARY_GREEN_SEL,
+		.active_low = 0,
+		//.hw_timer = 1,
+		//.retain_state_suspended = 1,
+	}/*,
+	{
+		.name = "sink1",
+		.pin_select = 1,
+		//.gpio = PIN_LED_BATTARY_GREEN,
+		//.func = LED_BATTARY_GREEN_SEL,
+		.active_low = 0,
+		//.hw_timer = 1,
+		//.retain_state_suspended = 1,
+	}*/
+	
+};
+
+extern  int  platform_gpio_blink_set(unsigned pin_sel,unsigned gpio, int state,
+			unsigned long *delay_on, unsigned long *delay_off);
+
+static struct gpio_led_platform_data leds_data =
+{
+	.num_leds =sizeof(leds)/sizeof(leds[0]) ,
+	.leds = leds,
+	.gpio_blink_set=platform_gpio_blink_set,
+
+};
+
+static struct platform_device leds_device =
+{
+	.name		= "leds-gpio",
+	.id		= 1,
+	.dev		= {
+		.platform_data	= &leds_data,
+	},
+};
+
+void check_led_ver(void) {
+	int ret;
+	ret = gpio_request(ZX29_GPIO_74, "led_ver_gpio");
+	if (ret < 0)
+		printk("led ver gpio request fail\n");
+	ret = gpio_direction_input(ZX29_GPIO_74);
+	ret = gpio_get_value(ZX29_GPIO_74);
+	//ret = 0; // fix as new hardware version
+	if (ret == 0) {
+		printk("new hardware version\n");
+		leds_data.leds = new_ver_leds;
+	}
+	else{
+		printk("old hardware version\n");
+	}
+	gpio_free(ZX29_GPIO_74);
+}
+#endif
+
+
+#ifdef CONFIG_KEYBOARD_ZX_INT
+/* --------------------------------------------------------------------
+ *  Keypad (power_on, ufi, ufi_reset) for ufi
+ * -------------------------------------------------------------------- */
+static struct gpio_keys_button zx29_keypad_int[] = {
+	#if 1
+	{
+		.active_low	= 1,				/*ÊÇ·ñµÍµçƽÓÐЧ¡£1: °´ÏÂΪµÍµçƽ  0: °´ÏÂΪ¸ßµçƽ*/
+		.desc       = "kpd_power",
+		.code       = KEY_POWER         /* power: 116 */,
+		.use_pmu_pwron = 1,             /*true: use pmu pwron interrupt fase: use zx297520v2 ext int*/
+		/*
+		// unnecessary for the situation of (.use_pmu_pwron = 1)
+		.gpio		= PIN_KPD_POWER,
+		.gpio_sel_gpio = KPD_POWER_FUNC_GPIO,
+		.gpio_sel_int = KPD_POWER_FUNC_INT,
+		*/
+    },
+	#endif
+
+	#if 1
+	{
+		.gpio		= ZX29_GPIO_48,
+		.active_low	= 1,
+		.desc       = "kpd_wps",
+		.code       = KEY_KPEQUAL,       /* wps: 117 */
+		.gpio_sel_gpio = GPIO48_GPIO48,
+		.gpio_sel_int = GPIO48_EXT_INT1,
+    },
+	#endif
+
+    #if 1
+	{
+		.gpio		= ZX29_GPIO_53,
+		.active_low	= 1,
+		.desc       = "kpd_reset",
+		.code       = KEY_KPPLUSMINUS,   /* reset: 118 */
+		.gpio_sel_gpio = GPIO53_GPIO53,
+		.gpio_sel_int = GPIO53_EXT_INT6,
+    },
+	#endif
+};
+
+static struct gpio_keys_platform_data zx29_keypad_int_data = {
+	.buttons	= zx29_keypad_int,
+	.nbuttons	= ARRAY_SIZE(zx29_keypad_int),
+};
+
+static struct platform_device zx29_keypad_int_device ={
+	.name 	= 	"zx29_keypad_int",
+	.id 	=	-1,
+	.dev	= 	{
+		.platform_data = &zx29_keypad_int_data,
+	}
+};
+#endif
+
+#ifdef CONFIG_KEYBOARD_ZX_5x6
+static struct zx29_5x6_keypad_platform_data zx29_5x6_keypad_data = {
+	.key_map = {
+		{11,  12,  13,  14,  15,  16},
+		{21,  22,  23,  24,  25,  26},
+		{31,  32,  33,  34,  35,  36},
+		{41,  42,  43,  44,  45,  46},
+		{51,  52,  53,  54,  55,  56}
+	},
+	.pin_col_row = {83, 84, 85, 86},
+};
+
+static struct resource kpd5x6_resources[] = {
+	{
+		.start	= KEYPAD_INT,
+		.end	= KEYPAD_INT,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device zx29_5x6_keypad_device ={
+	.name 	= 	"zx29_keypad",
+	.id 	=	0,
+	.resource		= kpd5x6_resources,
+	.num_resources	= ARRAY_SIZE(kpd5x6_resources),
+	.dev	= {
+        .platform_data = &zx29_5x6_keypad_data,
+    }
+};
+#endif
+
+#ifdef CONFIG_ZX29_GMAC
+/* gmac*/
+#if 0
+static struct resource gmac_resources[] = {
+	[0] = {
+		.start	= ZX_GMAC_BASE,
+		.end	= ZX_GMAC_BASE + SZ_8K - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= GMAC_INT,
+		.end	= GMAC_INT,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+#endif
+#if 1
+static struct resource zx29_gmac_resources[] = {
+	[0] = {
+		.start	= ZX_GMAC_BASE,
+		.end	= ZX_GMAC_BASE + SZ_8K - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+#if 0
+	[1] = {
+		.name   = "gmac_int",
+		.start	= GMAC_INT,
+		.end	= GMAC_INT,
+		.flags	= IORESOURCE_IRQ,
+	},
+	[2] = {
+		.name   = "phy_int",
+		.start	= GMACPHY_INT,
+		.end	= GMACPHY_INT,
+		.flags	= IORESOURCE_IRQ,
+	},
+#endif
+};
+#endif
+static struct gmac_platform_data zx29_gmac_data = {
+#if defined(CONFIG_RTK8306E_PHY)
+	.nports		= 7,
+	.rmii_port	= 6,
+#endif
+#if defined(CONFIG_IP175L_PHY)
+	.nports 	= 6,
+	.rmii_port	= 4,
+#endif
+#if defined(CONFIG_ARCH_ZX297520V3_MIFI)
+	.nports 	= 1,
+	.rmii_port	= 1,
+#endif
+	.port_mask  = 0xFFFFFF00,
+};
+
+static struct platform_device zx29_gmac_device = {
+	.name		= "zx29_gmac",
+	.id		= 0,
+	.resource	= zx29_gmac_resources,
+	.num_resources	= ARRAY_SIZE(zx29_gmac_resources),
+	.dev	 = {
+			.platform_data = &zx29_gmac_data,
+		    }
+};
+#endif
+
+#ifdef CONFIG_CHARGER_AW3215
+static struct  aw3215_platform_data aw3215_charger_platform = {
+    .gpio_chgen = ZX29_GPIO_126,
+    .gpio_chgen_gpio_sel = GPIO126_GPIO126,
+    .gpio_chgin = ZX29_GPIO_51,
+    .gpio_chgin_fun_sel = GPIO51_EXT_INT4,
+    .gpio_chgin_gpio_sel =GPIO51_GPIO51 ,
+    .gpio_chgctrl = ZX29_GPIO_130,/*not used*/
+    .gpio_chgctrl_gpio_sel = GPIO130_GPIO130,/*not used*/
+    .gpio_chgstate = ZX29_GPIO_54,
+    .gpio_chgstate_fun_sel = GPIO54_EXT_INT7,
+    .gpio_chgstate_gpio_sel = GPIO54_GPIO54,
+};
+
+static struct platform_device zx29_charger_device = {
+	.name		= "aw3215-charger",
+	.id		= 0,
+	.dev	 = {
+			.platform_data = &aw3215_charger_platform,
+		    }
+};
+
+
+#endif
+
+/* --------------------------------------------------------------------
+ *	----------  for  solution integration department ---------   end
+* -------------------------------------------------------------------- */
+
+
+/*
+ *  device tab used by board_init()
+ */
+struct platform_device *zx29_device_table[] __initdata={
+/* --------------------------------------------------------------------
+ *	----------  for  solution integration department ---------   start
+* -------------------------------------------------------------------- */
+#ifdef CONFIG_SERIAL_ZX29_UART
+	//&zx29_uart0_device,
+	&zx29_uart1_device,
+	//&zx29_uart2_device,
+#endif
+#ifdef CONFIG_MTD_NAND_DENALI
+	&zx29_device_nand,
+#endif
+#ifdef CONFIG_DWC_OTG_USB
+	&zx29_usb0_device,
+#endif
+#ifdef CONFIG_USB_DWC_OTG_HCD
+	&zx29_usb1_device,
+#endif
+#ifdef CONFIG_MTD_ZXIC_SPIFC
+	&zx29_device_spi_nand,
+#endif
+
+#ifdef CONFIG_SPI_ZXIC_NOR
+	&zx29_device_spi_nor,
+#endif
+
+
+#ifdef CONFIG_ZX29_DMA
+	&zx29_dma_device,
+#endif
+
+#ifdef CONFIG_MMC_ZX29
+#ifdef CONFIG_XR_WLAN
+    //&zx29_sdmmc1_device,
+#else
+    &zx29_sdmmc0_device,
+    //&zx29_sdmmc1_device,
+#endif
+#endif
+
+#ifdef CONFIG_I2C_ZX29
+
+#ifdef zx29_pmic_i2c
+	&zx29_pmic_i2c_device,
+#endif
+
+#ifdef zx29_I2C0
+	//&zx29_i2c0_device,
+#endif
+
+#endif
+
+#ifdef CONFIG_SPI_ZX29
+	&zx29_ssp0_device,
+#endif
+
+#ifdef CONFIG_RPM_ZX29
+	&zx29_icp_m0_device,
+	&zx29_icp_ps_device,
+#endif
+
+#ifdef CONFIG_ZX29_WATCHDOG
+	&zx29_wdt_device,
+#endif
+
+#ifdef CONFIG_KEYBOARD_ZX_5x6
+	&zx29_5x6_keypad_device,
+#endif
+
+#ifdef CONFIG_KEYBOARD_ZX_INT
+    &zx29_keypad_int_device,
+#endif
+
+#ifdef CONFIG_CHARGER_AW3215
+       &zx29_charger_device,
+#endif
+
+#ifdef CONFIG_LEDS_GPIO
+       &leds_device,
+#endif
+
+#ifdef CONFIG_ZX29_GMAC
+ 	&zx29_gmac_device,
+#endif
+
+#if (defined CONFIG_SND_SOC_ZX_I2S) || (defined CONFIG_SND_SOC_ZX_I2S_MODULE)
+#ifdef zx29_I2S0
+	&zx29_i2s0_device,
+#endif
+#ifdef zx29_I2S1
+	&zx29_i2s1_device,
+#endif
+#endif
+
+#if (defined CONFIG_SND_SOC_ZX_VOICE) || (defined CONFIG_SND_SOC_ZX_VOICE_MODULE)
+	&voice_asoc_device,
+#endif
+
+#if (defined CONFIG_SND_SOC_ZX_PCM) || (defined CONFIG_SND_SOC_ZX_PCM_MODULE)
+	&zx29_asoc_dma,
+#endif
+#if (defined CONFIG_SND_SOC_ZX297520V3) || (defined CONFIG_SND_SOC_ZX297520V3_MODULE)
+	&zx29_audio,
+#endif
+};
+
+unsigned int zx29_device_table_num=ARRAY_SIZE(zx29_device_table);
+
+#if (defined CONFIG_SPI_ZX29) || (defined CONFIG_SPI_GPIO)
+struct zx29_lcd_platform_data lead_lcd_platform = {
+	.spi_dcx_gpio = PIN_SPI_DCX,
+	.spi_dcx_gpio_fun_sel = SPI_DCX_FUNC_SEL,
+	.lcd_blg_gpio = PIN_LCD_BLG,
+	.lcd_blg_gpio_fun_sel = LCD_BLG_FUNC_SEL,
+	.lcd_rst_gpio = PIN_LCD_RST,
+	.lcd_rst_gpio_fun_sel =LCD_RST_FUNC_SEL,
+};
+
+static const struct spi_config_chip lead_lcd_chip_info = {
+	.com_mode = DMA_TRANSFER,
+	.iface = SPI_INTERFACE_MOTOROLA_SPI,
+	.hierarchy = SPI_MASTER,
+	.slave_tx_disable = 1,//DO_NOT_DRIVE_TX
+	.rx_lev_trig = SPI_RX_4_OR_MORE_ELEM,
+	.tx_lev_trig = SPI_TX_4_OR_MORE_EMPTY_LOC,
+//	.ctrl_len = SSP_BITS_8,
+//	.wait_state = SSP_MWIRE_WAIT_ZERO,
+//	.duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX,
+//	.cs_control = null_cs_control,
+};
+static struct spi_board_info zx29_spi_devices[] = {
+#ifdef CONFIG_FB_LEADT15DS26
+    {
+        .modalias 	    = "lead_t15ds26",
+        .bus_num 	    = 0,
+        .chip_select 	= 0,
+        .max_speed_hz	= 13000000,
+        .mode		    = SPI_MODE_3,
+        .platform_data 	= &lead_lcd_platform,
+        .controller_data = &lead_lcd_chip_info,
+    },
+#endif
+};
+void __init spi_add_devices(void)
+{
+	unsigned  devices_num = ARRAY_SIZE(zx29_spi_devices);
+    int ret = 0;
+	printk("spi_register_board_info success,devices_num=%d\n",devices_num);
+	if (devices_num){
+		ret = spi_register_board_info(zx29_spi_devices, devices_num);
+		printk("spi_register_board_info success,ret=%d\n",ret);
+		if(ret)
+			BUG();
+	}
+}
+#endif
+
+#ifdef CONFIG_CHARGER_ZX234502
+
+#define ZX234502_BAT_VOLTAGE_LEN  21
+
+struct zx234502_bat_calibration zx234502_bat_volage_charge[]=
+{
+	{4100,100}, {4090,95}, {4080,90}, {4070,85}, {4060,80}, {4050,75},
+	{4012,70}, {3973,65}, {3935,60}, {3896,55}, {3860,50}, {3817,45},
+	{3775,40}, {3733,35}, {3692,30}, {3650,25}, {3610,20}, {3570,15},
+	{3530,12}, {3590,10}, {3450,5}
+};
+
+struct zx234502_bat_calibration zx234502_bat_volage_discharge[]=
+{
+	{4100,100}, {4090,95}, {4080,90}, {4070,85}, {4060,80}, {4050,75},
+	{4012,70}, {3973,65}, {3935,60}, {3896,55}, {3860,50}, {3817,45},
+	{3775,40}, {3733,35}, {3692,30}, {3650,25}, {3610,20}, {3570,15},
+	{3530,12}, {3590,10}, {3450,5}
+};
+
+static struct  zx234502_platform_data zx234502_charger_platform = {
+	.gpio_int		=	PIN_CHARGE_INT,  //gpio55
+	.gpio_int_fun_sel = CHARGE_INT_FUNC_SEL,
+	.charging         =  &zx234502_bat_volage_charge,
+	.charging_size = ZX234502_BAT_VOLTAGE_LEN,
+	.discharging      =  &zx234502_bat_volage_discharge,
+	.discharging_size = ZX234502_BAT_VOLTAGE_LEN,
+	.ts_flag = TRUE,
+	.boost_flag = FALSE,
+	.boost_cur_gpio1 = PIN_CHARGE_BOOST_GPIO1,/*GPIO39*/
+	.boost_gpio1_fun_sel = CHARGE_BOOST_GPIO1_FUNC_SEL,
+	.boost_cur_gpio2 = PIN_CHARGE_BOOST_GPIO2,/*GPIO40*/
+	.boost_gpio2_fun_sel = CHARGE_BOOST_GPIO2_FUNC_SEL,
+	.boost_cur_gpio3 = PIN_CHARGE_BOOST_GPIO3,/*GPIO41*/
+	.boost_gpio3_fun_sel = CHARGE_BOOST_GPIO3_FUNC_SEL,
+	.boost_loadswitch_gpio = PIN_CHARGE_BOOST_LOADSWITCH,/*GPIO38*/
+	.boost_loadswitch_fun_sel = CHARGE_BOOST_LOADSWITCH_FUNC_SEL,
+};
+
+#endif
+#ifdef CONFIG_TSC_ZX29
+u32 ts_temp_value_table[TS_ADC_TEMP_NUMBER][TS_ADC_TEMP_VOLTAGE_NUMBER]={
+{30,31,32,33,34,35,36,37,38,39,
+ 40,41,42,43,44,45,46,47,48,49,
+ 50,51,52,53,54,55,56,57,58,59,
+ 60,61,62,63,64,65,66,67,68,69,
+ 70,71,72,73,74,75,76,77,78,79,
+ 80,81,82,83,84,85,86,87,88,89,
+ 90,91,92,93,94,95,96,97,98,99,
+ 100,101,102,103,104,105,106,107,108,109,
+ 110,111,112,113,114,115,116,117,118,119,
+ 120,121,122,123,124,125},
+
+{
+ 1422,1408,1395,1381,1367,1353,1338,1323,1308,1293,
+ 1278,1262,1247,1231,1215,1199,1183,1166,1149,1133,
+ 1116,1100,1083,1066,1049,1032,1015,998,981,965,
+ 948,931,915,898,882,865,849,833,816,801,
+ 785,769,754,739,723,708,694,679,665,650,
+ 636,623,610,596,583,570,558,545,532,521,
+ 509,498,486,475,464,454,443,432,423,412,
+ 402,394,384,375,367,358,350,341,333,326,
+ 317,310,302,295,289,282,275,268,262,256,
+ 250,242,239,233,227,222 }
+};
+volatile u32 ts_adc_flag=2;// 2:adc2,others:adc1
+#endif
+#if 1
+/*
+ *  I2C  device tab used by board_init()
+ */
+#ifdef CONFIG_MFD_ZX234290_I2C
+static struct  zx234290_board zx234290_platform = {
+	.irq_gpio_num	    =	PIN_PMU_INT, //EX0_INT,
+    .irq_gpio_func      =   PMU_INT_FUNC_SEL,
+	.pshold_gpio_num    =   PIN_PMU_PSHOLD,
+	.pshold_gpio_func   =   PMU_PSHOLD_FUNC_SEL,
+	.irq_base	= 	ENT_ZX234290_IRQ_BASE,
+};
+#endif
+
+static struct i2c_board_info zx29_i2c0_devices[] = {
+#ifdef CONFIG_MFD_ZX234290_I2C
+	[0]={
+		I2C_BOARD_INFO("zx234290", 0x12),
+		.irq		= EX0_INT,
+		.platform_data 	= &zx234290_platform,
+	},
+#endif
+
+};
+
+static struct i2c_board_info zx29_i2c1_devices[] = {
+#ifdef CONFIG_CHARGER_ZX234502
+		{
+			I2C_BOARD_INFO("zx234502-charger", 0x13),
+			//.irq		= EX5_INT,
+			.platform_data	= &zx234502_charger_platform,
+		},
+#endif
+#if (defined CONFIG_SND_SOC_ZX297520V3) || (defined CONFIG_SND_SOC_ZX297520V3_MODULE)
+		{
+			I2C_BOARD_INFO(CODEC_NAME, CODEC_ADDR),
+			.platform_data 	= ZX29_SND_CODEC_PDATA, //&snd_codec_pdata,
+		},
+#endif
+#ifdef CONFIG_CAMERA_DRV
+		{
+			I2C_BOARD_INFO("gc6133-sensor", 0x40),
+		},
+#endif
+#ifdef CONFIG_INPUT_TOUCHSCREEN
+		{
+			I2C_BOARD_INFO("touchscreen", 0x38),
+		},
+#endif
+
+};
+
+void __init i2c_add_devices(void)
+{
+	unsigned  devices_num = 0;
+    int ret = 0;
+
+	/*
+	  *i2c devices on bus 0
+	  */
+	devices_num = ARRAY_SIZE(zx29_i2c0_devices);
+	if (devices_num){
+		ret = i2c_register_board_info(0,zx29_i2c0_devices, devices_num);
+		if(ret)
+			BUG();
+	}
+
+	/*
+	  *i2c devices on bus 1
+	  */
+	devices_num = ARRAY_SIZE(zx29_i2c1_devices);
+	if (devices_num){
+		ret = i2c_register_board_info(1,zx29_i2c1_devices, devices_num);
+		if(ret)
+			BUG();
+	}
+}
+#endif
diff --git a/lynq/S300/ap/os/linux/linux-3.4.x/drivers/input/keyboard/zx29-keypad-int.c b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/input/keyboard/zx29-keypad-int.c
new file mode 100755
index 0000000..a17dc3f
--- /dev/null
+++ b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/input/keyboard/zx29-keypad-int.c
@@ -0,0 +1,537 @@
+/***********************************************************************
+* Copyright (C) 2016, Sanechips Corporation.
+*
+* File Name:  zx29-keypad-int.c
+* File Mark:
+* Description:
+* Others:
+* Version:  v1.0
+* Author:   qihongfang yuxiang lvfei ZhouTianbao
+* Date:     2017-2-28
+*
+* History 1:
+*     Date:
+*     Version:
+*     Author:
+*     Modification:
+**********************************************************************/
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/interrupt.h>
+#include <linux/input.h>
+#include <linux/errno.h>
+#include <linux/io.h>
+#include <linux/pm_runtime.h>
+#include <linux/slab.h>
+#include <asm/irq.h>
+#include <linux/workqueue.h>
+
+#include <linux/gpio.h>
+#include <mach/gpio.h>
+#include <mach/pcu.h>
+#include <linux/irq.h>
+#include <linux/gpio_keys.h>
+#include <linux/delay.h>
+#include <linux/wakelock.h>
+
+#include <mach/irqs.h>
+#include <linux/mfd/zx234290.h>
+#include <linux/kthread.h>
+#include <linux/soc/zte/pm/drv_idle.h>
+
+/**********************************************************************/
+//#define ERROR_REGISTER_IRQ        -100
+
+#define KEY_STATUS_UP               0
+#define KEY_STATUS_DOWN             1   /*input��ϵͳ��valueΪ1�ǰ���*/
+
+#define KEY_DELAY_TIME              30  /* ms */
+#define KEY_NUM					    30
+
+static struct input_dev *button_dev = NULL;
+
+typedef struct _zx234290_keypad
+{
+    struct zx234290 *zx234290;
+}zx234290_keypad_data;
+
+static zx234290_keypad_data zx234290_keypad;
+
+static spinlock_t kpd_lock;
+static volatile unsigned int key_active_count = 0;
+static struct wake_lock keypad_wake_lock;
+static struct semaphore kpd_sem;
+
+//#ifdef KPD_DEBUG
+struct key_info
+{
+    unsigned int index;
+	unsigned int code;
+	int value;
+};
+struct key_info key_info_tab[KEY_NUM]=
+{
+    {0},
+};
+static unsigned int key_info_idx = 0;
+static unsigned int key_info_counter = 0;
+//#endif
+
+static int zx29_kpd_queue(unsigned int code, int value)
+{
+    key_info_tab[key_info_idx].code = code;
+    key_info_tab[key_info_idx].value= value;
+    key_info_tab[key_info_idx].index = key_info_counter;
+    key_info_idx++;
+    key_info_counter++;
+    if(key_info_idx >= KEY_NUM)
+    {
+        key_info_idx = 0;
+    }
+    return 0;
+}
+
+static void zx29_key_set_active(void)
+{
+	spin_lock(&kpd_lock);
+
+    if(key_active_count == 0)
+    {
+		zx_cpuidle_set_busy(IDLE_FLAG_KPD);
+		wake_lock(&keypad_wake_lock);
+    }
+    key_active_count++;
+
+	spin_unlock(&kpd_lock);
+}
+
+static void zx29_key_set_idle(void)
+{
+	spin_lock(&kpd_lock);
+
+    key_active_count--;
+    if(key_active_count == 0)
+    {
+    	wake_unlock(&keypad_wake_lock);
+		zx_cpuidle_set_free(IDLE_FLAG_KPD);
+    }
+
+	spin_unlock(&kpd_lock);
+}
+
+/*******************************************************************************
+* Function: zx29_kpd_get_keystate
+* Description:    Test key state
+* Parameters:
+*          Input:
+*       Output:
+* Returns:  0: key down �͵�ƽ(press)    1: key up �ߵ�ƽ(release)
+* Others:
+*   zx29_gpio_config(unsigned int gpio, unsigned int value)  ���ø���
+*   value:  0:GPIO    1:FUNCTION
+********************************************************************************/
+
+static int zx29_kpd_get_keystate(int gpioNum,unsigned int gpio_sel_gpio,unsigned int gpio_sel_int)
+{
+    unsigned int gpio_state = GPIO_HIGH;
+    int irq;
+
+    zx29_gpio_config(gpioNum, gpio_sel_gpio);
+    irq = gpio_to_irq(gpioNum);
+    //pcu_clr_irq_pending(irq);
+    zx29_gpio_set_direction(gpioNum, GPIO_IN);
+    msleep(KEY_DELAY_TIME);
+    gpio_state = gpio_get_value(gpioNum);
+    /* msleep(30); */
+    zx29_gpio_config(gpioNum, gpio_sel_int);/******qhf***int****/
+    //pcu_clr_irq_pending(irq);
+
+    //printk(KERN_INFO "gpio state=%d.\n",gpio_state);
+
+    return gpio_state;  /* 0: �͵�ƽ(press), 1:�ߵ�ƽ(release) */
+
+}
+
+static irqreturn_t zx29_kpd_pwron_inform(int irq, void *dev_id)
+{
+	up(&kpd_sem);
+	return IRQ_HANDLED;
+}
+
+/*******************************************************************************
+* Function: zx29_kpd_pwron_thread
+* Description:
+* Parameters:
+*          Input:
+*       Output:
+* Returns:
+* Others:
+********************************************************************************/
+#define USE_EXT_DEV
+#ifdef USE_EXT_DEV
+//extern struct input_dev *button5x6_dev;
+extern struct input_dev *input_dev_table[32];
+#endif
+int zx29_kpd_pwron_thread(void *dev_id)
+{
+	struct gpio_keys_button *buttons = (struct gpio_keys_button *)dev_id;
+	int ret = 0;
+	unsigned char status = 0;
+
+	struct sched_param param;
+	param.sched_priority = 33;
+	sched_setscheduler(current, SCHED_FIFO, &param);
+
+	while (!kthread_should_stop()) {
+		down(&kpd_sem);
+
+		zx29_key_set_active();
+
+		msleep(10);
+		ret = zx234290_i2c_read_simple(ZX234290_REG_ADDR_STSA, &status);
+		if(ret)
+		{
+			printk(KERN_INFO "kpd read reg return=%d.\n", ret);
+		}
+		else if((status >> ZX234290_STATUSA_POWERON_LSH) & 0x1)
+		{
+#ifdef USE_EXT_DEV
+			if (input_dev_table[1]) {
+				set_bit(buttons->code, input_dev_table[1]->keybit);
+				input_report_key(input_dev_table[1], buttons->code, KEY_STATUS_DOWN);
+				input_sync(input_dev_table[1]);
+			}
+#endif
+			input_report_key(button_dev, buttons->code, KEY_STATUS_DOWN);
+			input_sync(button_dev);
+
+			zx29_kpd_queue(buttons->code, KEY_STATUS_DOWN);
+			printk(KERN_INFO "kpd down code=%d .\n",buttons->code);
+
+			while(1)
+			{
+				msleep(60);
+
+				ret = zx234290_i2c_read_simple(ZX234290_REG_ADDR_STSA, &status);
+				if(ret)
+				{
+					printk(KERN_INFO "kpd read reg return=%d.\n", ret);
+					break;
+				}
+				//printk(KERN_INFO "kpd reg status=%d.\n", status);
+
+				if(((status>>ZX234290_STATUSA_POWERON_LSH)&0x1) == 0x0)
+				{
+#ifdef USE_EXT_DEV
+					if (input_dev_table[1]) {
+						input_report_key(input_dev_table[1], buttons->code, KEY_STATUS_UP);
+						input_sync(input_dev_table[1]);
+					}
+#endif
+					input_report_key(button_dev, buttons->code, KEY_STATUS_UP);
+					input_sync(button_dev);
+
+					zx29_kpd_queue(buttons->code, KEY_STATUS_UP);
+					printk(KERN_INFO "kpd up code=%d.\n",buttons->code);
+					break;
+				}
+			}
+		}
+		else
+		{
+			printk(KERN_INFO "kpd power key noise.\n");
+		}
+
+		zx29_key_set_idle();
+	}
+
+	return 0;
+}
+
+static irqreturn_t zx29_kpd_irq_thread(int irq, void *dev_id)
+{
+    struct gpio_keys_button *buttons = (struct gpio_keys_button *)dev_id;
+    int gpio_val = 0;
+	int state;
+
+    zx29_key_set_active();
+
+    //printk(KERN_INFO "handle irq=%d.\n",irq);
+    gpio_val = zx29_kpd_get_keystate(buttons->gpio,buttons->gpio_sel_gpio,buttons->gpio_sel_int);
+	state = !!gpio_val ^ !!buttons->active_low;
+
+    zx29_gpio_set_inttype(buttons->gpio,
+						  (gpio_val ? IRQ_TYPE_LEVEL_LOW : IRQ_TYPE_LEVEL_HIGH));
+    //pcu_int_clear(irq);
+    //pcu_clr_irq_pending(irq);
+
+#ifdef USE_EXT_DEV
+	if (input_dev_table[1]) {
+		set_bit(buttons->code, input_dev_table[1]->keybit);
+		input_report_key(input_dev_table[1], buttons->code, state);
+		input_sync(input_dev_table[1]);
+	}
+#endif
+
+    input_report_key(button_dev, buttons->code, state);  //�ϱ�key ��ֵ
+    //key_info_tab[key_num].lastStatus = state;
+    input_sync(button_dev);
+    zx29_kpd_queue(buttons->code, state);
+    printk(KERN_INFO "kpd %s code=%d, irq=%d.\n",
+			(state ? "down" : "up"),
+			buttons->code,
+			irq);
+
+    //enable_irq(irq);    //���ж�
+
+    zx29_key_set_idle();
+    return IRQ_HANDLED;
+}
+
+/*******************************************************************************
+* Function: zx29_kpd_irq_handler
+* Description: clear irq , wake thread irq
+* Parameters:
+*          Input:
+*       Output:
+********************************************************************************/
+static irqreturn_t zx29_kpd_irq_handler(int irq, void *dev_id)
+{
+    //disable_irq_nosync(irq);
+    //pcu_int_clear(irq);
+    pcu_clr_irq_pending(irq);
+
+    //printk(KERN_INFO "kpd handler irq=%d.\n", irq);
+
+    return IRQ_WAKE_THREAD;
+}
+
+/*******************************************************************************
+* Function: zx29_kpd_request_irqs
+* Description:
+* Parameters:
+*          Input:
+*       Output:
+********************************************************************************/
+static int zx29_kpd_request_irqs(struct gpio_keys_platform_data *pdata )
+{
+    int ret = -1;
+    struct gpio_keys_button *buttons = pdata->buttons;
+    int keypad_num = pdata->nbuttons;
+    int irq_num = 0;
+
+    for(keypad_num = 0; keypad_num < pdata->nbuttons; keypad_num++)
+    {
+        if(buttons[keypad_num].use_pmu_pwron == 0)
+        {
+			ret = gpio_request(buttons[keypad_num].gpio, buttons[keypad_num].desc);
+			if (ret < 0) {
+				printk(KERN_ERR "kpd request gpio%d failed.\n", buttons[keypad_num].gpio);
+				break;
+			}
+            zx29_gpio_config(buttons[keypad_num].gpio,buttons[keypad_num].gpio_sel_int);
+			/* some switch may be active before booting. use level irq to avoid lack of falling edge. */
+            zx29_gpio_set_inttype(buttons[keypad_num].gpio,
+					(buttons[keypad_num].active_low ? IRQ_TYPE_LEVEL_LOW : IRQ_TYPE_LEVEL_HIGH));
+            if(buttons[keypad_num].code == KEY_KPEQUAL || buttons[keypad_num].code == KEY_KPPLUSMINUS)
+                zx29_gpio_pd_pu_set(buttons[keypad_num].gpio, IO_CFG_PULL_UP);
+            else
+                zx29_gpio_pd_pu_set(buttons[keypad_num].gpio, 0);
+
+            msleep(1); /* wait for stable input */
+
+            irq_num = gpio_to_irq(buttons[keypad_num].gpio);
+            /*
+            if(irq_num > 0){
+                printk(KERN_INFO "zx29_kpd_request_irqs error irq_num=%d.\n",irq_num);
+            }
+            */
+
+            /* pcu_clr_irq_pending(irq_num); */
+            ret = request_threaded_irq(irq_num, NULL, zx29_kpd_irq_thread, IRQF_ONESHOT/*IRQF_TRIGGER_HIGH | IRQF_NO_THREAD*/,
+                buttons[keypad_num].desc, &buttons[keypad_num]);
+			irq_set_irq_wake(irq_num, 1);
+        }
+        else
+        {
+			sema_init(&kpd_sem, 0);
+			kthread_run(zx29_kpd_pwron_thread, &buttons[keypad_num], "kpd_pwron_thread");
+
+			irq_num = ENT_ZX234290_IRQ_BASE + ZX234290_INT_PWRON;
+			ret = request_threaded_irq(irq_num, NULL, zx29_kpd_pwron_inform, 0,
+							buttons[keypad_num].desc, &buttons[keypad_num]);
+        }
+        if(ret)
+        {
+            return ret;
+        }
+        printk(KERN_INFO "kpd request_irq irq_num=%d.\n", irq_num);
+    }
+
+    return ret;
+}
+
+/*******************************************************************************
+* Function: zx29_kpd_probe
+* Description:
+* Parameters:
+*          Input:
+*        Output:
+* Returns:
+********************************************************************************/
+static int zx29_kpd_probe(struct platform_device *pdev)
+{
+    int error = -1;
+    static int i = 0;
+	struct input_handle *handle;
+    struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
+    struct gpio_keys_button *buttons = pdata->buttons;
+    zx234290_keypad.zx234290 = dev_get_drvdata(pdev->dev.parent);
+
+    button_dev = input_allocate_device();
+    if(!button_dev)
+    {
+        printk("allocate_device error.\n");
+        return error;
+    }
+    button_dev->name = pdev->name;
+    button_dev->evbit[0] = BIT_MASK(EV_KEY)|BIT_MASK(EV_REP);
+
+    for(i=0; i < pdata->nbuttons; i++)
+    {
+        set_bit(buttons[i].code,button_dev->keybit);
+    }
+
+    error = input_register_device(button_dev);
+    if(error)
+    {
+        printk("register device error\n");
+        goto err_free_dev;
+    }
+	handle = container_of(button_dev->h_list.next, struct input_handle, d_node);
+	/* printk(KERN_INFO "%s registered evdev %s/%p.\n", __FUNCTION__, handle->name, handle->private); */
+
+    platform_set_drvdata(pdev, button_dev);
+
+	spin_lock_init(&kpd_lock);
+	wake_lock_init(&keypad_wake_lock, WAKE_LOCK_SUSPEND, "keypad");
+    zx29_kpd_request_irqs(pdata);
+
+    return 0;
+
+err_free_dev:
+    input_free_device(button_dev);
+    return error;
+}
+
+
+/*******************************************************************************
+* Function: zx29_kpd_remove
+* Description:
+* Parameters:
+*          Input:
+*        Output:
+* Returns:
+********************************************************************************/
+static int zx29_kpd_remove(struct platform_device *pdev)
+{
+    struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
+    struct gpio_keys_button *buttons = pdata->buttons;
+    static struct input_dev *button_dev = NULL;
+    int i = 0;
+    int irq_num;
+
+    for(i = 0; i < pdata->nbuttons; i++){
+        irq_num = gpio_to_irq(buttons[i].gpio);
+        if(irq_num < 0){
+            printk(KERN_INFO "%s error keypad_num=%d.\n", __FUNCTION__, i);
+        }
+
+    	free_irq(irq_num,NULL);
+		gpio_free(buttons[i].gpio);
+    }
+    button_dev = (struct input_dev *)platform_get_drvdata(pdev);
+    input_free_device(button_dev);
+    button_dev = NULL;
+
+    zx234290_keypad.zx234290 = NULL;
+
+    wake_lock_destroy(&keypad_wake_lock);
+
+    return 0;
+}
+
+static int zx29_kpd_resume(struct platform_device *pdev)
+{
+    struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
+    struct gpio_keys_button *buttons = pdata->buttons;
+    int i = 0;
+    int irq_num = 0;
+
+    for(i = 0; i < pdata->nbuttons; i++){
+
+        irq_num = gpio_to_irq(buttons[i].gpio);
+        if(irq_num < 0){
+            printk(KERN_INFO "%s error keypad_num=%d.\n", __FUNCTION__, i);
+        }
+        if(irq_num != 0){
+            enable_irq(irq_num);
+        }
+
+    }
+    printk(KERN_INFO "%s\n", __FUNCTION__);
+    return 0;
+}
+
+static int zx29_kpd_suspend(struct platform_device *pdev, pm_message_t state)
+{
+    struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
+    struct gpio_keys_button *buttons = pdata->buttons;
+    int i = 0;
+    int irq_num = 0;
+
+    for(i = 0; i < pdata->nbuttons; i++){
+        irq_num = gpio_to_irq(buttons[i].gpio);
+        if(irq_num < 0){
+            printk(KERN_INFO "%s error keypad_num=%d.\n", __FUNCTION__, i);
+        }
+        if(irq_num != 0){
+            disable_irq(irq_num);
+        }
+
+    }
+    printk(KERN_INFO "%s\n", __FUNCTION__);
+    return 0;
+}
+
+static struct platform_driver zx29_kpd_driver =
+{
+    .probe  = zx29_kpd_probe,
+    .remove = zx29_kpd_remove,
+    .driver =
+    {
+        .name   =   "zx29_keypad_int",
+        .owner  =   THIS_MODULE,
+    },
+    //.resume = zx29_kpd_resume,
+    //.suspend    = zx29_kpd_suspend,
+};
+
+static int __init zx29_kpd_init(void)
+{
+    return platform_driver_register(&zx29_kpd_driver);
+}
+
+static void __exit zx29_kpd_exit(void)
+{
+    platform_driver_unregister(&zx29_kpd_driver);
+}
+
+module_init(zx29_kpd_init);
+module_exit(zx29_kpd_exit);
+
+MODULE_AUTHOR("Sanechips");
+MODULE_DESCRIPTION("Sanechips Keypad Driver");
+MODULE_LICENSE("GPL");
+
diff --git a/lynq/S300/ap/os/linux/linux-3.4.x/drivers/mfd/zx234290-regulator-wrapper.c b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/mfd/zx234290-regulator-wrapper.c
new file mode 100644
index 0000000..12c1ef8
--- /dev/null
+++ b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/mfd/zx234290-regulator-wrapper.c
@@ -0,0 +1,1309 @@
+/*

+ * zx234290-regulator-wrapper.c  --  regulator for ZX234290 PMICs

+ *

+ * Copyright 2016 ZTE Inc.

+ *

+ * Author: yuxiang<yu.xiang5@zte.com.cn>

+ *

+ *  This program is free software; you can redistribute  it and/or modify it

+ *  under  the terms of  the GNU General  Public License as published by the

+ *  Free Software Foundation;  either version 2 of the  License, or (at your

+ *  option) any later version.

+ *

+ */

+#include <linux/init.h>        /* For init/exit macros */

+#include <linux/module.h>      /* For MODULE_ marcros  */

+#include <linux/interrupt.h>

+#include <linux/spinlock.h>

+#include <linux/platform_device.h>

+

+#include <linux/device.h>

+#include <linux/delay.h>

+#include <linux/mutex.h>

+#include <linux/mfd/zx234290.h>

+

+static int zDrvZx234290_DischargerConfig(void)

+{

+    int nRet = 0;

+    int index = 0 ;

+

+    /*enable all discharger*/

+    for(index = DISCHARGER_LDO_9; index < DISCHARGER_MAX; index++)

+    {

+        if(index == DISCHARGER_BUCK_X || index == DISCHARGER_LDO_X)

+            continue;

+        nRet = zx234290_SetDischarger(index, DISCHARGER_ENABLE);

+    	if (0 != nRet)

+    	{

+    		return -EIO;

+    	}

+    }

+    /*config, buck0 discharger disable*/

+    /*

+    nRet = Zx234290_SetDischarger(DISCHARGER_BUCK_0, DISCHARGER_DISBALE);

+    if (DRV_SUCCESS != nRet)

+    {

+    	return DRV_ERROR;

+    }*/

+

+    return 0;

+}

+#if 1

+extern int pmu_chip_ver;

+

+int zDrvZx234290_NormalSleepConfig(void)

+{

+	int nRet = 0;

+

+	/* if chg_pwron, this bucks will be closed, we open them again when system reset... */

+    //zx234290_set_buck3_onoff(LDO_ENABLE_ON);        /*RF 1V6*/

+    zx234290_set_buck4_onoff(LDO_ENABLE_ON);        /*PA 3V6*/

+    //zx234290_set_ldo8_onoff(LDO_ENABLE_ON);         /*ZSP JTAG/SD 2V85*/

+	//zx234290_set_ldo6_onoff(LDO_ENABLE_ON);         /*SIM1 1V8ÕâÀï²»Óÿª£¬SIM¿¨×Ô¼º¿ª£¬·ñÔòÓ°ÏìʱÐò*/

+	if (pmu_chip_ver != 297)

+	zx234290_set_ldo10_onoff(LDO_ENABLE_ON);        /*adc0.9v/dac0.9v/avdd_pll0.9v/avdd_abb0.9v*/

+    zx234290_set_ldo1_onoff(LDO_ENABLE_ON);         /*USB 0V9*/

+    zx234290_set_ldo5_onoff(LDO_ENABLE_ON);         /*USB 3V3*/

+	

+	//nRet = Zx234290_SetBUCK1SleepMode(BUCK1_SLP_AUTO_ECO_SLP);

+	nRet = zx234290_set_buck1_sleep_mode(BUCK1_SLP_SHUTDOWN);

+	if (0 != nRet)

+	{

+		return -EIO;

+	}

+

+    nRet = zx234290_set_buck2_sleep_mode(BUCK234_SLP_ECO_WITH_ECO);

+	if (0 != nRet)

+	{

+		return -EIO;

+	}

+	//nRet = Zx234290_SetBUCK3SleepMode(BUCK234_SLP_ECO_WITH_ECO);

+	nRet = zx234290_set_buck3_sleep_mode(BUCK234_SLP_SHUTDOWN);

+	if (0 != nRet)

+	{

+		return -EIO;

+	}

+

+	nRet = zx234290_set_buck4_sleep_mode(BUCK234_SLP_SHUTDOWN);

+	if (0 != nRet)

+	{

+		return -EIO;

+	}

+	nRet = zx234290_set_ldo2_sleep_mode(LDOA_SLP_ECO_VOLT);

+	if (0 != nRet)

+	{

+		return -EIO;

+	}

+	nRet = zx234290_set_ldo3_sleep_mode(LDOA_SLP_ECO_VOLT);

+	if (0 != nRet)

+	{

+		return -EIO;

+	}

+

+	nRet = zx234290_set_ldo4_sleep_mode(LDOB_SLP_SHUTDOWN);

+	if (0 != nRet)

+	{

+		return -EIO;

+	}

+

+	nRet = zx234290_set_ldo6_sleep_mode(LDOB_SLP_ECO_VOLT);

+	if (0 != nRet)

+	{

+		return -EIO;

+	}

+

+	nRet = zx234290_set_ldo7_sleep_mode(LDOA_SLP_ECO_VOLT);

+	if (0 != nRet)

+	{

+		return -EIO;

+	}

+

+	nRet = zx234290_set_ldo8_sleep_mode(LDOA_SLP_ECO_VOLT);//×¢ÒâÐͺŻú²»ÄܹØ

+	if (0 != nRet)

+	{

+		return -EIO;

+	}

+

+	nRet = zx234290_set_ldo9_sleep_mode(LDOA_SLP_ECO_VOLT);

+	if (0 != nRet)

+	{

+		return -EIO;

+	}

+

+    nRet = zx234290_set_ldo10_sleep_mode(LDOA_SLP_ECO_VOLT);

+	if (0 != nRet)

+	{

+		return -EIO;

+	}

+

+	return 0;

+}

+/* for chaging power on */

+int zDrvZx234290_ChgOnSleepConfig(void)

+{

+    //zx234290_set_buck3_onoff(LDO_ENABLE_OFF);        /*RF 1V6*/

+    zx234290_set_buck4_onoff(LDO_ENABLE_OFF);        /*PA 3V6*/

+    //zx234290_set_ldo1_onoff(LDO_ENABLE_OFF);         /*USB 0V9*/

+    //zx234290_set_ldo5_onoff(LDO_ENABLE_OFF);         /*USB 3V3*/

+    zx234290_set_ldo6_onoff(LDO_ENABLE_OFF);         /*SIM1 1V8*/

+    //zx234290_set_ldo7_onoff(LDO_ENABLE_OFF);       /*RF 2V85*/

+    //zx234290_set_ldo8_onoff(LDO_ENABLE_ON);         /*ZSP JTAG/SD 2V85 ÐͺŻú²»ÄܹØ*/

+    //zx234290_set_ldo9_onoff(LDO_ENABLE_OFF);         /*PLL 0V9*/

+    zx234290_set_ldo10_onoff(LDO_ENABLE_OFF);        /*ABB DIG*/

+

+	zx234290_set_buck1_sleep_mode(BUCK1_SLP_SHUTDOWN);  /*vdcore*/

+    zx234290_set_buck2_sleep_mode(BUCK234_SLP_ECO_WITH_ECO);/*ddr1.2v/mcp1.2v/hsic1.2v*/

+    zx234290_set_buck3_sleep_mode(BUCK234_SLP_SHUTDOWN);   /*RF 1V6*/

+    //zx234290_set_buck4_sleep_mode(BUCK234_SLP_SHUTDOWN);   /*PA 3V6*/

+    //zx234290_set_ldo1_sleep_mode(LDOA_SLP_SHUTDOWN);       /*USB 0V9*/

+    //zx234290_set_ldo5_sleep_mode(LDOA_SLP_SHUTDOWN);       /*USB 3V3*/

+	zx234290_set_ldo2_sleep_mode(LDOA_SLP_ECO_VOLT);    /*io1.8v/mcp1.8v/sd01.8v*/

+	zx234290_set_ldo3_sleep_mode(LDOA_SLP_ECO_VOLT);	/*vp111.8v/vddr_pll1.8v/*/

+	zx234290_set_ldo4_sleep_mode(LDOA_SLP_SHUTDOWN);		/*vcxo*/

+    //zx234290_set_ldo6_sleep_mode(LDOA_SLP_SHUTDOWN);       /*SIM1 1V8*/

+    zx234290_set_ldo7_sleep_mode(LDOA_SLP_ECO_VOLT);  /*RF  -- 26M */

+    zx234290_set_ldo8_sleep_mode(LDOA_SLP_ECO_VOLT);       /*ZSP JTAG/SD 2V85/LCD*/

+    zx234290_set_ldo9_sleep_mode(LDOA_SLP_ECO_VOLT);       /*PLL 0V9*/

+    //zx234290_set_ldo10_sleep_mode(LDOA_SLP_SHUTDOWN);      /*ABB DIG*/

+

+	return 0;

+}

+

+

+#endif

+#ifdef CONFIG_PMU_GM

+extern int zx234296h_support_parameter(void);

+#endif

+int zDrvZx234290_LdoInit(void)

+{

+    int ret = 0;

+	

+#ifdef CONFIG_PMU_GM

+	zx234296h_support_parameter();

+#endif

+	//zDrvZx234290_Config();

+	ret = zDrvZx234290_LdoRstErr();

+    

+	ret += zx234290_set_buck1_active_mode(BUCK_NRM_FORCE_PWM);

+	

+	ret += zx234290_set_buck2_active_mode(BUCK_NRM_FORCE_PWM);

+	

+	ret += zx234290_set_buck3_active_mode(BUCK_NRM_FORCE_PWM);

+	

+	ret += zx234290_set_buck4_active_mode(BUCK_NRM_FORCE_PWM);

+

+    

+	ret += zDrvZx234290_DischargerConfig();

+

+	//zDrvZx234290_SleepConfig();

+

+    ret += zx234290_SetLlpEnable(LLP_ENABLE);

+	
+	ret += zx234290_SetTllpToDo(LLP_RESTART);
+	ret += zx234290_SetLlpTime(LLP_TIME_6S);
+   // ret += zx234290_SetRestartDly(LLP_DLY_500MS);  //LLP_DLY_250MS 

+    if(ret != 0)

+	{

+		printk("zx234290 zDrvZx234290_LdoInit err\n");

+		return -1;

+	}

+

+	return 0;

+}

+#if 1	/* vdd_CORE0 -- 0.9V -- BUCK1 */

+/*******************************************************************************

+ * Function:

+ * Description:

+ * Parameters:

+ *	 Input:

+ *

+ *	 Output:

+ *

+ * Returns:

+ *

+ *

+ * Others:

+ ********************************************************************************/

+int zx234290_setcore_onoff(T_ZDrvPmic_Enable status)

+{

+	int ret = 0;

+

+	ret = zx234290_set_buck1_onoff((T_ZDrvZx234290_LDO_ENABLE)status);

+

+	return ret;

+}

+

+T_ZDrvPmic_Enable zx234290_getcore_onoff(void)

+{

+	int status;

+

+	status	= zx234290_get_buck1_onoff();

+

+	return (T_ZDrvPmic_Enable)status;

+}

+int zx234290_setcore_voltage(int vol)

+{

+	int ret = 0;

+	switch (vol)

+	{

+		case 900:

+		{

+			ret = zx234290_set_buck1_voltage(VBUCKA_0_900);

+			break;

+		}

+

+		case 1100:

+		{

+			ret = zx234290_set_buck1_voltage(VBUCKA_1_100);

+			break;

+		}

+		default:

+		{

+			ret = -EINVAL;

+		}

+	}

+

+	return ret;

+}

+

+int zx234290_getcore_voltage(void)

+{

+	int	vget;

+	T_ZDrvZx234290_VbuckA vol;

+

+	vol = zx234290_get_buck1_voltage();

+	switch (vol)

+	{

+		case VBUCKA_0_900:

+		{

+			vget = 900;

+			break;

+		}

+

+		case VBUCKA_1_100:

+		{

+			vget = 1100;

+			break;

+		}

+

+		default:

+		{

+			return -EINVAL;

+		}

+	}

+

+	return vget;

+}

+

+int zx234290_setcore_sleepmode(T_ZDrvPmic_SlpMode mode)

+{

+	int ret = 0;

+

+    switch (mode)

+	{

+		case PM_SLPMODE_AUTO_NORMAL:

+		case PM_SLPMODE_ECO_NRMV:

+		case PM_SLPMODE_ECO_SLPV:

+        case PM_SLPMODE_OFF:

+		{

+			ret = zx234290_set_buck1_sleep_mode((T_ZDrvZx234290_BUCK1_SLPMODE)mode);

+			break;

+		}

+		default:

+		{

+			ret = -EINVAL;

+		}

+	}

+

+	return ret;

+}

+

+T_ZDrvPmic_SlpMode zx234290_getcore_sleepmode(void)

+{

+	T_ZDrvPmic_SlpMode	getMode;

+	T_ZDrvZx234290_BUCK1_SLPMODE	mode;

+

+	mode = zx234290_get_buck1_sleep_mode();

+	switch (mode)

+	{

+		case BUCK1_SLP_AUTO_WITHOUT_ECO:

+		{

+			getMode = PM_SLPMODE_AUTO_NORMAL;

+			break;			

+		}

+		case BUCK1_SLP_AUTO_ECO:	

+		{

+			getMode = PM_SLPMODE_ECO_NRMV;

+			break;			

+		}

+		case BUCK1_SLP_AUTO_ECO_SLP:

+		{

+			getMode = PM_SLPMODE_ECO_SLPV;

+			break;			

+		}

+

+		case BUCK1_SLP_SHUTDOWN:

+		{

+			getMode = PM_SLPMODE_OFF;

+			break;

+		}

+		default:

+		{

+			return PM_SLPMODE_NOT_SUPPORT;

+		}

+	}

+

+	return getMode;

+}

+

+int zx234290_setcore_sleepvoltage(int vol) 	 /* buck1 sleep vol */

+{

+	int ret = 0;

+	switch (vol)

+	{

+        case 800:

+		{

+			ret = zx234290_set_buck1_sleep_voltage(VBUCKA_0_800);

+			break;

+		}

+		case 900:

+		{

+			ret = zx234290_set_buck1_sleep_voltage(VBUCKA_0_900);

+			break;

+		}

+

+		case 1100:

+		{

+			ret = zx234290_set_buck1_sleep_voltage(VBUCKA_1_100);

+			break;

+		}

+		default:

+		{

+			ret = -EINVAL;

+		}

+	}

+

+	return ret;

+}

+#endif

+

+

+#if 1	/*	USB 0.9V-- LDO1 */

+/*******************************************************************************

+ * Function:

+ * Description:

+ * Parameters:

+ *	 Input:

+ *

+ *	 Output:

+ *

+ * Returns:

+ *

+ *

+ * Others:

+ ********************************************************************************/

+int zx234290_setusb_v0v9_onoff(T_ZDrvPmic_Enable status)

+{

+	int ret = 0;

+

+	ret = zx234290_set_ldo1_onoff((T_ZDrvZx234290_LDO_ENABLE)status);

+

+	return ret;

+}

+

+int zx234290_setusb_v0v9_onoff_PSM(T_ZDrvPmic_Enable status)

+{

+	int ret = 0;

+

+	ret = zx234290_set_ldo1_onoff_PSM((T_ZDrvZx234290_LDO_ENABLE)status);

+

+	return ret;

+}

+

+T_ZDrvPmic_Enable zx234290_getusb_v0v9_onoff(void)

+{

+	int status;

+

+	status	= zx234290_get_ldo1_onoff();

+

+	return (T_ZDrvPmic_Enable)status;

+}

+

+int zx234290_setusb_v0v9_voltage(int vol)

+{

+	int ret = 0;

+	switch (vol)

+	{

+		case 900:

+		{

+			ret = zx234290_set_ldo1_voltage(VLDOA_0_900);

+			break;

+		}

+		default:

+		{

+			ret = -EINVAL;

+		}

+	}

+	return ret;

+}

+

+int zx234290_getusb_v0v9_voltage(void)

+{

+	int  vget;

+	T_ZDrvZx234290_VldoA   vol;

+

+	vol = zx234290_get_ldo1_voltage();

+	switch (vol)

+	{

+		case VLDOA_0_900:

+		{

+			vget = 900;

+			break;

+		}

+		default:

+		{

+			return -EINVAL;

+		}

+	}

+

+	return vget;

+}

+

+int zx234290_setusb_v0v9_sleepmode(T_ZDrvPmic_SlpMode mode)

+{

+	int ret = 0;

+

+    switch (mode)

+	{

+		case PM_SLPMODE_AUTO_NORMAL:

+		case PM_SLPMODE_ECO_NRMV:

+		case PM_SLPMODE_ECO_SLPV:

+        case PM_SLPMODE_OFF:

+		{

+			ret = zx234290_set_ldo1_sleep_mode((T_ZDrvZx234290_LDOA_SLPMODE)mode);

+			break;

+		}

+		default:

+		{

+			ret = -EINVAL;

+		}

+	}

+	return ret;

+

+}

+

+T_ZDrvPmic_SlpMode zx234290_getusb_v0v9_sleepmode(void)

+{

+	T_ZDrvPmic_SlpMode	getMode;

+	T_ZDrvZx234290_LDOA_SLPMODE	 mode;

+

+	mode = zx234290_get_ldo1_sleep_mode();

+	switch (mode)

+	{

+		case LDOA_SLP_NRM_MODE:

+		{

+			getMode = PM_SLPMODE_AUTO_NORMAL;

+			break;

+		}

+		case LDOA_SLP_ECO_VOLT:

+		{

+			getMode = PM_SLPMODE_ECO_NRMV;

+			break;

+		}

+        case LDOA_SLP_ECO_VOLT_SLP:

+		{

+			getMode = PM_SLPMODE_ECO_SLPV;

+			break;

+		}

+		case LDOA_SLP_SHUTDOWN:

+		{

+			getMode = PM_SLPMODE_OFF;

+			break;

+		}

+		default:

+		{

+			return PM_SLPMODE_NOT_SUPPORT;

+		}

+	}

+	return getMode;

+}

+

+#endif

+

+#if 1	/*	USB 3.3V-- LDO1 */

+/*******************************************************************************

+ * Function:

+ * Description:

+ * Parameters:

+ *	 Input:

+ *

+ *	 Output:

+ *

+ * Returns:

+ *

+ *

+ * Others:

+ ********************************************************************************/

+int zx234290_setusb_v3v3_onoff(T_ZDrvPmic_Enable status)

+{

+	int ret = 0;

+

+	ret = zx234290_set_ldo5_onoff((T_ZDrvZx234290_LDO_ENABLE)status);

+

+	return ret;

+}

+

+int zx234290_setusb_v3v3_onoff_PSM(T_ZDrvPmic_Enable status)

+{

+	int ret = 0;

+

+	ret = zx234290_set_ldo5_onoff_PSM((T_ZDrvZx234290_LDO_ENABLE)status);

+

+	return ret;

+}

+

+

+T_ZDrvPmic_Enable zx234290_getusb_v3v3_onoff(void)

+{

+	int status;

+

+	status	= zx234290_get_ldo5_onoff();

+

+	return (T_ZDrvPmic_Enable)status;

+}

+

+int zx234290_setusb_v3v3_voltage(int vol)

+{

+	int ret = 0;

+	switch (vol)

+	{

+		case 3300:

+		{

+			ret = zx234290_set_ldo5_voltage(VLDOC_3_300);

+			break;

+		}

+		default:

+		{

+			ret = -EINVAL;

+		}

+	}

+	return ret;

+}

+

+int zx234290_getusb_v3v3_voltage(void)

+{

+	int vget;

+	T_ZDrvZx234290_VldoB	vol;

+

+	vol = zx234290_get_ldo5_voltage();

+	switch (vol)

+	{

+		case VLDOC_3_300:

+		{

+			vget = 3300;

+			break;

+		}

+		default:

+		{

+			return -EINVAL;

+		}

+	}

+

+	return vget;

+}

+

+int zx234290_setusb_v3v3_sleepmode(T_ZDrvPmic_SlpMode mode)

+{

+	int ret = 0;

+

+    switch (mode)

+	{

+		case PM_SLPMODE_AUTO_NORMAL:

+		case PM_SLPMODE_ECO_NRMV:

+		case PM_SLPMODE_ECO_SLPV:

+        case PM_SLPMODE_OFF:

+		{

+			ret = zx234290_set_ldo5_sleep_mode((T_ZDrvZx234290_LDOB_SLPMODE)mode);

+			break;

+		}

+		default:

+		{

+			ret = -EINVAL;

+		}

+	}

+	return ret;

+

+}

+

+T_ZDrvPmic_SlpMode zx234290_getusb_v3v3_sleepmode(void)

+{

+	T_ZDrvPmic_SlpMode	getMode;

+	T_ZDrvZx234290_LDOB_SLPMODE	 mode;

+

+	mode = zx234290_get_ldo5_sleep_mode();

+	switch (mode)

+	{

+		case LDOA_SLP_NRM_MODE:

+		{

+			getMode = PM_SLPMODE_AUTO_NORMAL;

+			break;

+		}

+		case LDOA_SLP_ECO_VOLT:

+		{

+			getMode = PM_SLPMODE_ECO_NRMV;

+			break;

+		}

+        case LDOA_SLP_ECO_VOLT_SLP:

+		{

+			getMode = PM_SLPMODE_ECO_SLPV;

+			break;

+		}

+		case LDOA_SLP_SHUTDOWN:

+		{

+			getMode = PM_SLPMODE_OFF;

+			break;

+		}

+		default:

+		{

+			return PM_SLPMODE_NOT_SUPPORT;

+		}

+	}

+	return getMode;

+}

+#endif

+

+#if 1	/* SIM1 1.8V/3.0V -- LDO6 */

+/*******************************************************************************

+ * Function:

+ * Description:

+ * Parameters:

+ *	 Input:

+ *

+ *	 Output:

+ *

+ * Returns:

+ *

+ *

+ * Others:

+ ********************************************************************************/

+int zx234290_setsim1_onoff(T_ZDrvPmic_Enable status)

+{

+	int ret = 0;

+

+	ret = zx234290_set_ldo6_onoff((T_ZDrvZx234290_LDO_ENABLE)status);

+

+	return ret;

+}

+

+

+T_ZDrvPmic_Enable zx234290_getsim1_onoff(void)

+{

+	int status;

+

+	status	= zx234290_get_ldo6_onoff();

+

+	return (T_ZDrvPmic_Enable)status;

+}

+int zx234290_setsim1_voltage(int vol)

+{

+	int ret = 0;

+	switch (vol)

+	{

+		case 1800:

+		{

+			ret = zx234290_set_ldo6_voltage(VLDOD_1_800);

+			break;

+		}

+

+		case 3000:

+		{

+			ret = zx234290_set_ldo6_voltage(VLDOD_3_000);

+			break;

+		}

+

+		default:

+		{

+			ret = -EINVAL;

+		}

+	}

+

+	return ret;

+}

+int zx234290_getsim1_voltage(void)

+{

+	int vget;

+	T_ZDrvZx234290_VldoD vol;

+

+	vol = zx234290_get_ldo6_voltage();

+	switch (vol)

+	{

+		case VLDOD_1_800:

+		{

+			vget = 1800;

+			break;

+		}

+

+		case VLDOD_3_000:

+		{

+			vget = 3000;

+			break;

+		}

+

+		default:

+		{

+			return -EINVAL;

+		}

+	}

+

+	return vget;

+}

+

+int zx234290_setsim1_sleepmode(T_ZDrvPmic_SlpMode mode)

+{

+	int ret = 0;

+

+    switch (mode)

+	{

+		case PM_SLPMODE_AUTO_NORMAL:

+		case PM_SLPMODE_ECO_NRMV:

+        case PM_SLPMODE_OFF:

+		{

+			ret = zx234290_set_ldo6_sleep_mode((T_ZDrvZx234290_LDOB_SLPMODE)mode);

+			break;

+		}

+		default:

+		{

+			ret = -EINVAL;

+		}

+	}

+

+	return ret;

+}

+

+T_ZDrvPmic_SlpMode zx234290_getsim1_sleepmode(void)

+{

+	T_ZDrvPmic_SlpMode	getMode;

+	T_ZDrvZx234290_LDOB_SLPMODE	 mode;

+

+	mode = zx234290_get_ldo6_sleep_mode();

+	switch (mode)

+	{

+		case LDOB_SLP_NRM_MODE:

+		{

+			getMode = PM_SLPMODE_AUTO_NORMAL;

+			break;			

+		}

+		case LDOB_SLP_ECO_VOLT:

+		{

+			getMode = PM_SLPMODE_ECO_NRMV;

+			break;			

+		}

+		case LDOB_SLP_SHUTDOWN:

+		{

+			getMode = PM_SLPMODE_OFF;

+			break;			

+		}

+		default:

+		{

+			return PM_SLPMODE_NOT_SUPPORT;

+		}

+	}

+

+	return getMode;

+}

+#endif

+

+#if 1	/* SIM2 1.8V/3.0V -- LDO6 */

+/*******************************************************************************

+ * Function:

+ * Description:

+ * Parameters:

+ *	 Input:

+ *

+ *	 Output:

+ *

+ * Returns:

+ *

+ *

+ * Others:

+ ********************************************************************************/

+int zx234290_setsim2_onoff(T_ZDrvPmic_Enable status)

+{

+	int ret = 0;

+

+	ret = zx234290_set_ldo10_onoff((T_ZDrvZx234290_LDO_ENABLE)status);

+

+	return ret;

+}

+

+

+T_ZDrvPmic_Enable zx234290_getsim2_onoff(void)

+{

+	T_ZDrvZx234290_LDO_ENABLE status;

+

+	status	= zx234290_get_ldo10_onoff();

+

+	return (T_ZDrvPmic_Enable)status;

+}

+

+int zx234290_setsim2_voltage(int vol)

+{

+	int ret = 0;

+	switch (vol)

+	{

+		case 1800:

+		{

+			ret = zx234297_set_ldo10_voltageF(VLDOF_1_800);

+			break;

+		}

+

+		case 3000:

+		{

+			ret = zx234297_set_ldo10_voltageF(VLDOF_3_000);

+			break;

+		}

+

+		default:

+		{

+			ret = -EINVAL;

+		}

+	}

+

+	return ret;

+}

+int zx234290_getsim2_voltage(void)

+{

+	int vget;

+	T_ZDrvZx234297_VldoF vol;

+

+	vol = zx234290_get_ldo10_voltageF();

+	switch (vol)

+	{

+		case VLDOF_1_800:

+		{

+			vget = 1800;

+			break;

+		}

+

+		case VLDOF_3_000:

+		{

+			vget = 3000;

+			break;

+		}

+

+		default:

+		{

+			return -EINVAL;

+		}

+	}

+

+	return vget;

+}

+

+int zx234290_setsim2_sleepmode(T_ZDrvPmic_SlpMode mode)

+{

+	int ret = 0;

+

+    switch (mode)

+	{

+		case PM_SLPMODE_AUTO_NORMAL:

+		case PM_SLPMODE_ECO_NRMV:

+        case PM_SLPMODE_OFF:

+		{

+			ret = zx234290_set_ldo10_sleep_mode((T_ZDrvZx234290_LDOA_SLPMODE)mode);

+			break;

+		}

+		default:

+		{

+			ret = -EINVAL;

+		}

+	}

+

+	return ret;

+}

+

+T_ZDrvPmic_SlpMode zx234290_getsim2_sleepmode(void)

+{

+	T_ZDrvPmic_SlpMode	getMode;

+	T_ZDrvZx234290_LDOA_SLPMODE	 mode;

+

+	mode = zx234290_get_ldo10_sleep_mode();

+	switch (mode)

+	{

+		case LDOA_SLP_NRM_MODE:

+		{

+			getMode = PM_SLPMODE_AUTO_NORMAL;

+			break;			

+		}

+		case LDOA_SLP_ECO_VOLT:

+		{

+			getMode = PM_SLPMODE_ECO_NRMV;

+			break;			

+		}

+		case LDOA_SLP_ECO_VOLT_SLP:

+		{

+			getMode = PM_SLPMODE_ECO_SLPV;

+			break;			

+		}	

+		case LDOA_SLP_SHUTDOWN:

+		{

+			getMode = PM_SLPMODE_OFF;

+			break;			

+		}

+		default:

+		{

+			return PM_SLPMODE_NOT_SUPPORT;

+		}

+	}

+

+	return getMode;

+}

+#endif

+

+

+#if 1	/* SD1- 1.8V/2.8V --LDO8 */

+/*******************************************************************************

+ * Function:

+ * Description:

+ * Parameters:

+ *	 Input:

+ *

+ *	 Output:

+ *

+ * Returns:

+ *

+ *

+ * Others:

+ ********************************************************************************/

+int zx234290_setsd1_onoff(T_ZDrvPmic_Enable status)

+{

+	int ret = 0;

+

+	ret = zx234290_set_ldo8_onoff((T_ZDrvZx234290_LDO_ENABLE)status);

+

+	return ret;

+}

+

+T_ZDrvPmic_Enable zx234290_getsd1_onoff(void)

+{

+	int status;

+

+	status = zx234290_get_ldo8_onoff();

+

+	return (T_ZDrvPmic_Enable)status;

+}

+int zx234290_setsd1_voltage(int vol)

+{

+	int ret = 0;

+

+    switch (vol)

+	{

+        case 1800:

+		{

+			ret = zx234290_set_ldo8_voltage(VLDOD_1_800);

+			break;

+		}

+		case 2800:

+		{

+			ret = zx234290_set_ldo8_voltage(VLDOD_2_800);

+			break;

+		}

+		default:

+		{

+			ret = -EINVAL;

+		}

+	}

+

+	return ret;

+}

+

+int zx234290_getsd1_voltage(void)

+{

+	int vget;

+	T_ZDrvZx234290_VldoD vol;

+

+	vol = zx234290_get_ldo8_voltage();

+

+	switch (vol)

+	{

+        case VLDOD_1_800:

+		{

+			vget = 1800;

+			break;

+		}

+

+		case VLDOD_2_800:

+		{

+			vget = 2800;

+			break;

+		}

+

+		default:

+		{

+			return -EINVAL;

+		}

+	}

+

+	return vget;

+}

+

+int zx234290_setsd1_sleepmode(T_ZDrvPmic_SlpMode mode)

+{

+	int ret = 0;

+

+    switch (mode)

+	{

+		case PM_SLPMODE_AUTO_NORMAL:

+		case PM_SLPMODE_ECO_NRMV:

+        case PM_SLPMODE_ECO_SLPV:

+        case PM_SLPMODE_OFF:

+		{

+			ret = zx234290_set_ldo8_sleep_mode((T_ZDrvZx234290_LDOA_SLPMODE)mode);

+			break;

+		}

+		default:

+		{

+			ret = -EINVAL;

+		}

+	}

+

+	return ret;

+}

+

+T_ZDrvPmic_SlpMode zx234290_getsd1_sleepmode(void)

+{

+	T_ZDrvPmic_SlpMode	getMode;

+	T_ZDrvZx234290_LDOA_SLPMODE	 mode;

+

+    mode = zx234290_get_ldo8_sleep_mode();

+

+	switch (mode)

+	{

+		case LDOA_SLP_NRM_MODE:

+		{		

+			getMode = PM_SLPMODE_AUTO_NORMAL;

+			break;

+		}

+		case LDOA_SLP_ECO_VOLT:	

+		{		

+			getMode = PM_SLPMODE_ECO_NRMV;

+			break;

+		}

+        case LDOA_SLP_ECO_VOLT_SLP:	

+		{		

+			getMode = PM_SLPMODE_ECO_SLPV;

+			break;

+		}

+		case LDOA_SLP_SHUTDOWN:

+		{

+			getMode = PM_SLPMODE_OFF;

+			break;

+		}

+		default:

+		{

+			return PM_SLPMODE_NOT_SUPPORT;

+		}

+	}

+

+	return getMode;

+}

+

+#endif

+

+#if 1

+int zDrvPmic_SetNormal_Onoff(T_ZDrvPmic_Regulator regulator, T_ZDrvPmic_Enable enable)
+{
+    int ret = 0;
+
+    switch (regulator)
+    {
+        case VSD1:

+            ret = zx234290_setsd1_onoff(enable);
+            break;
+
+        case VSIM1:

+            ret = zx234290_setsim1_onoff(enable);
+            break;
+			
+        case VSIM2:

+            ret = zx234290_setsim2_onoff(enable);

+            break;

+			

+        case VUSB_0V9:
+            ret = zx234290_setusb_v0v9_onoff(enable);
+            break;
+
+        case VUSB_3V3:
+            ret = zx234290_setusb_v3v3_onoff(enable);
+            break;
+
+		default:
+			return -EINVAL;
+    }
+
+    return ret;
+}
+EXPORT_SYMBOL(zDrvPmic_SetNormal_Onoff);

+

+

+int zDrvPmic_SetNormal_Onoff_PSM(T_ZDrvPmic_Regulator regulator, T_ZDrvPmic_Enable enable)

+{

+    int ret = 0;

+

+    switch (regulator)

+    {

+        case VSD1:

+            ret = zx234290_setsd1_onoff(enable);

+            break;

+

+        case VSIM1:

+            ret = zx234290_setsim1_onoff(enable);

+            break;

+

+        case VUSB_0V9:

+            ret = zx234290_setusb_v0v9_onoff_PSM(enable);

+            break;

+

+        case VUSB_3V3:

+            ret = zx234290_setusb_v3v3_onoff_PSM(enable);

+            break;

+

+		default:

+			return -EINVAL;

+    }

+

+    return ret;

+}

+EXPORT_SYMBOL(zDrvPmic_SetNormal_Onoff_PSM);
+
+
+
+int zDrvPmic_SetNormal_Voltage(T_ZDrvPmic_Regulator regulator, int voltage)
+{
+    int ret = 0;
+
+    switch (regulator)
+    {
+        case VSD1:

+            ret = zx234290_setsd1_voltage(voltage);
+            break;
+
+        case VSIM1:

+            ret = zx234290_setsim1_voltage(voltage);
+            break;
+        case VSIM2:

+            ret = zx234290_setsim2_voltage(voltage);

+            break;
+        case VUSB_0V9:
+            ret = zx234290_setusb_v0v9_voltage(voltage);
+            break;
+
+        case VUSB_3V3:
+            ret = zx234290_setusb_v0v9_voltage(voltage);
+            break;
+
+		default:
+			return -EINVAL;
+    }
+
+    return ret;
+}
+EXPORT_SYMBOL(zDrvPmic_SetNormal_Voltage);
+
+
+
+int zDrvPmic_SetSleep_Voltage(T_ZDrvPmic_Regulator regulator, int voltage)
+{
+    int ret = 0;
+
+    switch (regulator)
+    {
+        case VCORE0:
+            break;
+
+        case VCORE1:
+            {
+            ret = zx234290_setcore_voltage(voltage);
+            if (ret != 0)
+            {
+                return ret;
+            }
+            break;
+        }
+
+		default:
+			return -EINVAL;
+    }
+
+    return ret;
+}
+
+EXPORT_SYMBOL(zDrvPmic_SetSleep_Voltage);
+
+
+int zDrvPmic_GetNormal_Onoff(T_ZDrvPmic_Regulator regulator, T_ZDrvPmic_Enable* enable)
+{
+    int ret = 0;
+
+    switch (regulator)
+    {
+

+        case VSD1:
+            *enable = zx234290_getsd1_onoff();
+            break;
+
+        case VSIM1:

+            *enable = zx234290_getsim1_onoff();
+            break;
+
+        case VUSB_0V9:
+            *enable = zx234290_getusb_v0v9_onoff();
+            break;
+
+        case VUSB_3V3:
+            *enable = zx234290_getusb_v3v3_onoff();
+            break;
+
+		default:
+			return -EINVAL;
+    }
+
+    return ret;
+}
+
+EXPORT_SYMBOL(zDrvPmic_GetNormal_Onoff);
+
+
+int zDrvPmic_GetNormal_Voltage(T_ZDrvPmic_Regulator regulator, int* voltage)
+{
+    int ret = 0;
+
+    switch (regulator)
+    {
+

+        case VSD1:
+            *voltage = zx234290_getsd1_voltage();
+            break;

+
+        case VSIM1:

+            *voltage = zx234290_getsim1_voltage();
+            break;
+
+        case VUSB_0V9:
+            *voltage = zx234290_getusb_v0v9_voltage();
+            break;
+
+        case VUSB_3V3:
+            *voltage = zx234290_getusb_v3v3_voltage();
+            break;
+
+		default:
+			return -EINVAL;
+    }
+
+    return ret;
+}
+
+EXPORT_SYMBOL(zDrvPmic_GetNormal_Voltage);

+#endif

+

diff --git a/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/ethernet/zte/zx29_gmac.c b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/ethernet/zte/zx29_gmac.c
new file mode 100755
index 0000000..9702de5
--- /dev/null
+++ b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/ethernet/zte/zx29_gmac.c
@@ -0,0 +1,1356 @@
+/*

+ * Ethernet driver for zte zx2975xx gmac on chip network device

+ * (c)2008 http://www.zte.com.cn

+ * Authors:	zhang dongdong <zhang.dongdong16@zte.com.cn>

+ *

+ * This program is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU General Public License

+ * as published by the Free Software Foundation; either version

+ * 2 of the License, or (at your option) any later version.

+ */

+#include <linux/kernel.h>

+#include <linux/module.h>

+#include <linux/interrupt.h>

+#include <linux/types.h>

+#include <linux/delay.h>

+#include <linux/init.h>

+#include <linux/spinlock.h>

+#include <linux/netdevice.h>

+#include <linux/etherdevice.h>

+#include <linux/phy.h>

+#include <linux/platform_device.h>

+#include <linux/gmac/gmac.h>

+#include <linux/gpio.h>

+#include "zx29_gmac.h"

+

+#define gmac_printk(_format, _args...)		do{printk(KERN_INFO"gmac," _format "\n",##_args);}while(0)

+

+struct tasklet_struct	*g_gmac_tasklet = NULL;

+

+static void gmac_hw_deinit(struct net_device *dev);

+

+struct zx29_gmac_dev	*g_gmac_dev = NULL;

+

+static u8 zx29_gmac_addr[MAC_ADDR_LENTH] = {0xec,0x1d,0x7f,0xb0,0x2f,0x32};

+

+// È¡µÃµ±Ç°µÄ½ÓÊÕÃèÊö·û

+static struct bd_rx *get_rx_bd(struct net_device *dev)

+{

+    struct zx29_gmac_dev* prv 	= (struct zx29_gmac_dev*)netdev_priv(dev);

+    int   n						= prv->rx_bd_offset;

+    struct bd_rx *d				= (struct bd_rx*)prv->dma_rx_vir;

+

+    if(d[n].RDES0 & DMA_OWNER) 

+    {

+        return 0;

+    }

+    else	

+    {

+        return &d[n];

+    }

+}

+

+static inline int mod_sub(int left, int right, int mod)

+{

+    return (mod - right + left) % mod;

+}

+

+// È¡µÃµ±Ç°µÄ·¢ËÍÃèÊö·û

+static inline struct bd_tx *get_tx_bd(struct net_device *dev)

+{

+    struct zx29_gmac_dev* prv 	= (struct zx29_gmac_dev*)netdev_priv(dev);

+    int   n						= prv->tx_bd_offset;

+    struct bd_tx *d				= (struct bd_tx*)prv->dma_tx_vir;

+	

+    if( mod_sub(prv->tx_bd_offset, prv->txed_bd, GMAC_TX_BD_NUM) > GMAC_TX_BD_NUM - 2 )  

+	{

+		return 0;

+	}

+		

+    if(d[n].TDES0 & DMA_OWNER) 	

+    {

+        return 0;

+    }

+    else

+    {

+        return &d[n];

+    }

+}

+

+// È¡µÃÒÑ·¢ËÍÃèÊö·û

+static struct bd_tx *get_txed_bd(struct net_device *dev)

+{

+    struct bd_tx *d;

+    struct zx29_gmac_dev* prv 	= (struct zx29_gmac_dev*)netdev_priv(dev);

+    int n						= prv->txed_bd;

+

+    d	= (struct bd_tx*)prv->dma_tx_vir;

+

+	if(n == prv->tx_bd_offset) return 0;

+	

+    if(d[n].TDES0 & DMA_OWNER)	return 0;

+	

+	if(d[n].skb == NULL) return 0; 

+

+    prv->txed_bd++;

+    prv->txed_bd %= GMAC_TX_BD_NUM;

+

+    return &d[n];

+}

+

+static void mac_init(struct net_device *dev)

+{

+    volatile unsigned *gmac = (unsigned*)dev->base_addr;

+    unsigned int i=0, j=0, mac_rst=0;

+

+    mac_provide_clock();

+#ifdef __DEAD_LOOP_POLL__                       //////¿ÉÄÜ»áÔì³ÉËÀÑ­»·ÎÞ·¨Í˳ö£¬Äں˳õʼ»¯ÎÞ·¨¼ÌÐø/////////

+    mac_reset();  								// ¿ØÖÆÆ÷¸´Î»

+    mac_set_gmii_mode();						// MII½Ó¿Ú

+    mac_wait_reset_finished();

+#else                                           /////ÒÔÏÂÐ޸ĴúÂëÐèÒª½øÐÐÑϸñ²âÊÔ////////

+    //LOG_INFO("wait for gmac reseting");

+    for(i=0; i<MAC_RESET_NUM; i++)              /////Èí¸´Î»³¢ÊÔ´ÎÊý/////

+    {

+        mac_reset();

+        mac_set_mii_mode();                 //ÉèÖÃΪmiiģʽ£¬10m»òÕß100m

+        for(j=0; j<MAC_WAIT_TIME; j++)          /////²éѯ¸´Î»×´Ì¬³¬Ê±¼ÆÊýÑ­»·1´ÎÊÇ0.1ms////////

+        {

+            printk(".");

+            if(!((MAC(0x1000)) & 1))

+            {

+                printk("ok\n");

+                mac_rst = 1;

+                goto mac_reset_option;

+            } 

+            udelay(100);                        ////µÈ´ý 0.1ms

+        }

+    }

+mac_reset_option:

+    if(!mac_rst)                                ////gmacÍø¿¨macоƬûÓи´Î»³É¹¦//////

+    {

+        printk("gmac reset failed!\n");

+    }

+#endif

+    while(mac_mii_is_busy());

+}

+

+static int gmac_init_rx_bd(struct net_device *dev, struct zx29_gmac_dev* prv)

+{

+    struct sk_buff	*skb = NULL;

+    struct bd_rx *rx  = (struct bd_rx *)prv->dma_rx_vir;

+    int 			i = 0;	

+

+    prv->rx_bd_offset		= 0;

+

+	for(i = 0; i < GMAC_RX_BD_NUM; i++)

+	{

+		// ½ÓÊÕÃèÊö·û³õʼ»¯

+		// ½ÓÊÕÃèÊö·ûµÄÊý¾Ý»º³åÇøÎª SKBµÄdata¶Î£¬¹ÊÏÈ·ÖÅäÏàÓ¦ÊýÁ¿µÄskb£¬

+		// ¹ÒÔÚ½ÓÊÕÃèÊö·û»·»ØÁ´±íÉÏ£¬µ±GMACÓ²¼þ½«Êý¾Ý±£´æºó£¬½«¸Ãskbȡϣ¬Ë͸øÐ­ÒéÉϲã

+		// Í¬Ê±ÒªÖØÐ·ÖÅäÒ»¸öSKB£¬ÔÙ¹Òµ½½ÓÊÕÃèÊö·û»·»ØÁ´±íÉÏ

+

+		skb = netdev_alloc_skb(dev, GMAC_FRAME_LEN + NET_IP_ALIGN);

+

+		if(unlikely(!skb))

+		{

+		   // LOG_ERR("kmalloc memory failed\n");

+			gmac_hw_deinit(dev);

+			return -1;

+		}

+

+		skb_reserve(skb, NET_IP_ALIGN);

+

+		rx[i].RDES0 	   |= DMA_OWNER;

+		rx[i].RDES1  = 0;

+		rx[i].RDES1 	   = GMAC_FRAME_LEN | 1 << 14;

+		rx[i].dma_buf		= virtaddr_to_phys((unsigned)skb->data);

+		rx[i].next			= prv->dma_rx_phy + ((i + 1) << 5);

+		rx[i].skb			= skb;

+#if 0

+		if(i%4 != 0)

+		{

+	       rx[i].RDES1  |= 0x80000000;

+		}

+#endif

+		dma_sync_single_for_device(&dev->dev, rx[i].dma_buf, GMAC_FRAME_LEN, DMA_TO_DEVICE);

+

+	}

+

+	// Ï´ÎÊǶÔÁ´±í½øÐл·»Ø´¦Àí

+	rx[GMAC_RX_BD_NUM-1].next			= prv->dma_rx_phy;

+	rx[GMAC_RX_BD_NUM-1].RDES1 			= GMAC_FRAME_LEN	  | 1 << 14 | 1 << 15;

+

+	return 0;

+}

+

+static void gmac_init_tx_bd(struct zx29_gmac_dev* prv)

+{

+    struct bd_tx *tx  = (struct bd_tx *)prv->dma_tx_vir;

+

+    int 			i = 0;

+

+    prv->tx_bd_offset		= 0;

+    prv->txed_bd			= 0;

+

+    for(i = 0; i < GMAC_TX_BD_NUM; i++)

+    {

+        // ·¢ËÍÃèÊö·û³õʼ»¯

+        // ·¢ËÍÃèÊö·ûµÄÊý¾Ý»º³åÇøÎª SKBµÄdata¶Î£¬¹Ê²»ÐèÒªÊý¾Ý»º³åÇø£¬

+        // ·¢ËÍʱ½«¸ÃSKBµÄÊý¾ÝÇø¹ÒÔÚ·¢ËÍÃèÊö·û»·»ØÁ´±íÉÏ£¬µ±GMACÓ²¼þ½«Êý¾ÝÊý¾Ý·¢Ëͺó£¬Ôݲ»´¦Àí£¬µÈ»·»ØÁ´±íÖØÐÂÈÆ»ØÊ±ÔÙ´¦Àí

+

+        tx[i].TDES0       	= (1 << 20 | 1 << 30);

+        tx[i].TDES1       	= GMAC_FRAME_LEN;

+        tx[i].next			= prv->dma_tx_phy + ((i + 1) << 5);

+    }

+

+    // Ï´ÎÊǶÔÁ´±í½øÐл·»Ø´¦Àí

+    tx[GMAC_TX_BD_NUM-1].next		    	= prv->dma_tx_phy;

+    tx[GMAC_TX_BD_NUM-1].TDES0            	= 1 << 20 | 1 << 21 | 1 << 30;	

+}

+

+static void gmac_stop(void* io)

+{

+	volatile unsigned *gmac = (unsigned*)io;

+

+    dma_disable();

+    mac_disable();

+    mac_int_disable();

+

+    // Çå¿Õ·¢ËÍFIFO

+    dma_clear_tx_fifo();

+    dma_wait_tx_fifo_cleared();

+}

+

+static void gmac_start(void* io)

+{

+	volatile unsigned *gmac = (unsigned*)io;

+

+    mac_int_enable();

+    dma_enable();

+    mac_enable();

+}

+

+static void gmac_trig_transmit(void* io)

+{

+    volatile unsigned *gmac 	= (unsigned*)io;

+    register unsigned status	= (MAC(0x1014) >> 20) & 0x07;

+    switch(status)

+    {

+        case 0:		// ´«ÊäÍ£Ö¹£»¸´Î»»òÕßÍ£Ö¹ÃüÁî·¢ËÍ

+            dma_enable();

+            break;

+        case 6:		// ¹ÒÆð£»´«ÊäÃèÊö·û²»¿ÉÓûòÕß´«Ê仺´æÏÂÒç¡£

+            dma_continue_tx();

+            break;

+        case 1:		// ÕýÔÚ½øÐУ»»ñÈ¡´«ÊäÃèÊö·û

+        case 2:		// ÕýÔÚ½øÐУ»µÈ´ý´«Êä״̬

+        case 3:		// ÕýÔÚ½øÐУ»´Ó·¢ËÍ»º´æ¶ÁÈ¡Êý¾Ý²¢·¢Ë͵½´«Êä FIFO(TxFIFO)

+        case 4:		// дÈëʱ¼ä´Á״̬

+        case 5:		// ±£Áô

+        case 7:		// ÔËÐУ»¹Ø±Õ´«ÊäÃèÊö·û¡£

+        default:

+            break;

+    }

+}

+

+static void gmac_trig_receive(void* io)

+{

+    volatile unsigned *gmac 	= (unsigned*)io;

+    register unsigned status	= (MAC(0x1014) >> 17) & 0x07;;

+    switch(status)

+    {

+        case 0:		// ֹͣ

+            dma_enable();

+            break;

+        case 4:		// ¹ÒÆð

+            dma_continue_rx();

+            break;

+        default:

+            break;

+    }

+}

+

+// ÉèÖÃÓ²¼þMACµØÖ·

+static inline void gmac_update_mac(struct net_device *dev)

+{

+    volatile unsigned *gmac = (unsigned*)dev->base_addr;

+    unsigned char *mac		= (unsigned char *)(dev->dev_addr);

+

+    MAC(0x0044)	= mac[0] | mac[1] << 8 | mac[2] << 16 | mac[3] << 24;

+    MAC(0x0040) = mac[4] | mac[5] << 8;

+

+    //LOG_INFO("MAC: %02X-%02X-%02X-%02X-%02X-%02X\n", mac[5], mac[4], mac[3], mac[2], mac[1], mac[0]);

+}

+

+static void gmac_hw_deinit(struct net_device *dev)

+{

+    int 				i;

+    struct bd_rx 		*rx_bd;

+	struct bd_tx 		*tx_bd;

+    volatile unsigned 	*gmac	= (unsigned*)dev->base_addr;

+    struct zx29_gmac_dev *prv	= (struct zx29_gmac_dev*)netdev_priv(dev);

+

+    gmac_stop((void*)dev->base_addr);

+

+    // ×¢Òârx tx Ò»ÆðÏú»Ù

+    if(prv->dma_rx_phy) {

+        rx_bd   = (struct bd_rx*)prv->dma_rx_vir;

+

+        for(i = 0; i < GMAC_RX_BD_NUM; i++) {

+        	if(rx_bd[i].skb != NULL)      

+ 	           dev_kfree_skb_any(rx_bd[i].skb);

+        }

+

+		tx_bd   = (struct bd_tx*)prv->dma_tx_vir;

+		

+        for(i = 0; i < GMAC_TX_BD_NUM; i++) {

+        	if(tx_bd[i].skb != NULL)

+            	dev_kfree_skb_any(tx_bd[i].skb);

+        }

+

+       // dma_free_coherent(NULL, GMAC_BUF_LEN, prv->dma_rx_vir, prv->dma_rx_phy);   //ÊÍ·Ådma»º³åÇø

+    }

+

+    dma_set_tx_buffer(0);   //ÉèÖÃÊ׸öBDµÄ»º³åÇøÎª0£»

+    dma_set_rx_buffer(0);

+

+    prv->rx_bd_offset	= 0;

+    prv->tx_bd_offset	= 0;

+    prv->txed_bd		= 0;

+    prv->dma_rx_phy		= 0;

+    prv->dma_rx_vir		= 0;

+    prv->dma_tx_phy		= 0;

+    prv->dma_tx_vir		= 0;

+}

+

+void gmac_set_speed_duplex(struct net_device *dev, int speed, int duplex)

+{

+    unsigned			val;

+    struct zx_net_dev* 	prv 	= (struct zx_net_dev*)netdev_priv(dev);

+    volatile unsigned 	*gmac 	= (unsigned*)dev->base_addr;

+

+    val = MAC(0x0000) | 1<<11 | 1<<14;  // ĬÈÏΪ100Mȫ˫¹¤

+    if(SPEED_10 == speed)

+    {

+        val &= ~(1 << 14);                  // 10M

+    }

+    if(DUPLEX_HALF == duplex)

+    {

+        val &= (~(1 << 11));                    // °ëË«¹¤

+        val |= (1 << 16);

+    }

+    MAC(0x0000) = val;

+}

+

+static int gmac_hw_init(struct net_device *dev)

+{

+	int ret = -1;

+    unsigned 		val;

+

+    volatile unsigned *gmac	= (unsigned*)dev->base_addr;   //WL  ÍøÂçÉ豸µÄIO»ùµØÖ·

+    struct zx29_gmac_dev* prv 	= (struct zx29_gmac_dev*)netdev_priv(dev);

+

+	printk("cy: gmac_hw_init \n");

+    if(prv->dma_rx_phy) {

+		printk("cy: gmac_hw_init gmac_hw_deinit\n");

+        gmac_hw_deinit(dev);

+	}

+

+    prv->dma_rx_vir = prv->dma_rx_vir_init;

+	prv->dma_rx_phy = prv->dma_rx_phy_init;

+    prv->dma_tx_vir	= prv->dma_rx_vir + GMAC_RX_BUF_LEN;

+    prv->dma_tx_phy	= prv->dma_rx_phy + GMAC_RX_BUF_LEN;

+

+    // ¶ÔÃèÊö·ûÊý¾ÝÇøÇåÁã

+    memset(prv->dma_rx_vir, 0, GMAC_BUF_LEN);

+

+	//ec616000600086,should check init_rx result

+    ret = gmac_init_rx_bd(dev, prv);

+	if(ret < 0)

+	{

+		printk("hw_net_init,init_rx_bd fail\n");

+		return ret;

+	}

+    gmac_init_tx_bd(prv);

+

+    mac_init(dev);

+

+    /*¹Ø±ÕGMACËùÓй¦ÄÜ*/

+    dma_disable();

+    mac_disable();

+    mac_int_disable();

+

+    /*ÉèÖÃÍ»·¢´«Ê䳤¶È*/

+    val		 	= MAC(0x1000);

+    val			&= ~(0x3F << 8);

+    val			|=  (0x10 << 8);    //burst 16

+    MAC(0x1000)	 = val;

+

+    /*  ÉèÖýÓÊÕÓë·¢ËÍÃèÊö·û*/

+    dma_set_rx_buffer(prv->dma_rx_phy);

+    dma_set_tx_buffer(prv->dma_tx_phy);

+

+    mac_int_clear(0x0001FFFF);								// ÖжÏÇå³ý

+    while(mac_mii_is_busy());

+	

+	//set speed and duplex mode

+	gmac_set_speed_duplex(dev, prv->phydev->speed, prv->phydev->duplex);

+	

+    mac_rece_all_data();									// ½ÓÊÕËùÓÐÊý¾Ý

+    //gmac_set_filter(dev);                                 //²âÊÔʱ¿ÉÒÔ²»Óôò¿ª

+

+	gmac_start((void*)dev->base_addr);

+    return 0;

+}

+

+static int zx29mii_read(struct mii_bus *bus, int phy_addr, int regnum)

+{

+	unsigned long flags;

+	struct zx29_gmac_dev *prv = (struct zx29_gmac_dev*)bus->priv;

+	volatile unsigned 	*gmac	= (unsigned*)prv->base_addr;

+

+	unsigned val	= ( 1 << 0 					|		// busy λ

+					    0 << 1 					|		// R/W²Ù×÷ָʾλ

+					    PHY_CLOCK << 2)			|		// ʱÖÓλ

+					    (regnum & 0x1F) << 6	|		// ¼Ä´æÆ÷

+					    (phy_addr & 0x1F) << 11;		// ÎïÀíоƬ

+

+	spin_lock_irqsave(&prv->lock,flags);

+	while(mac_mii_is_busy());

+	MAC(0x0010) 	= val;

+	spin_unlock_irqrestore(&prv->lock,flags);

+

+	while(mac_mii_is_busy());

+

+	return (MAC(0x0014) & 0xFFFF);

+}

+

+static int zx29mii_write(struct mii_bus *bus, int phy_addr, int regnum, u16 value)

+{

+	struct zx29_gmac_dev *prv = (struct zx29_gmac_dev*)bus->priv;

+	volatile unsigned 	*gmac	= (unsigned*)prv->base_addr;

+

+	unsigned data	= ( 1 << 0 					|		// busy λ

+					    1 << 1 					|		// R/W²Ù×÷ָʾλ

+					    PHY_CLOCK << 2)			|		// ʱÖÓλ

+					    (regnum & 0x1F) << 6	|		// ¼Ä´æÆ÷

+					    (phy_addr & 0x1F) << 11;		// ÎïÀíоƬ

+

+	spin_lock_irq(&prv->lock);

+

+	while(mac_mii_is_busy());

+	MAC(0x0014)		= value;

+	MAC(0x0010)		= data;

+

+	spin_unlock_irq(&prv->lock);

+

+	while(mac_mii_is_busy());

+

+	return 0;

+}

+static int zx29mii_reset(struct mii_bus *bus)

+{

+	struct zx29_gmac_dev *priv = bus->priv;

+	volatile unsigned *gmac = (unsigned*)priv->base_addr;

+	gmac_start(priv->base_addr);

+	while(mac_mii_is_busy());

+	return 0;

+}

+

+static inline void zx29_gmac_set_macaddr(struct net_device* ndev)

+{

+    // È¡µÃMAC µØÖ·: 

+    // ²éÕÒMAC¼Ä´æÆ÷ÖеĵØÖ·£¬Èç¹ûÓÐЧ£¬Ê¹ÓøÃMAC£¬

+    // ÎÞЧÔòËæ»úÉú³É//zx297520v2   Ö±½ÓËæ»úÁËmac µØÖ·

+ 

+   int i =0;

+

+#if  MAC_ADDR_SET

+    for(i = 0;i<MAC_ADDR_LENTH;i++)

+    {

+     ndev->dev_addr[i]   = zx29_gmac_addr[i];

+    }

+

+    if(!is_valid_ether_addr(ndev->dev_addr))

+    {

+	    random_ether_addr(ndev->dev_addr);

+    }

+#else

+    random_ether_addr(ndev->dev_addr);

+#endif

+}

+

+

+static inline void zx29_gmac_linkisup(struct net_device *dev, int isup)

+{

+	struct zx29_gmac_dev *priv = netdev_priv(dev);

+	struct phy_device *phydev = priv->phydev;

+

+	priv->link.duplex = phydev->duplex;

+	priv->link.giga = (phydev->speed == 100);

+	if (priv->link.speed != phydev->speed) {

+		priv->link.speed = phydev->speed;

+		//zx29_gmac_set_rgmii_txclock(priv);

+	}

+	priv->link.isup = isup;

+	if (isup)

+		netif_carrier_on(dev);

+	phy_print_status(phydev);

+}

+

+static void zx29_gmac_stats_printk(struct net_device *dev)

+{

+	printk("dev->stats.rx_errors = %d.\n", dev->stats.rx_errors);

+	printk("dev->stats.rx_dropped = %d.\n", dev->stats.rx_dropped);

+	printk("dev->stats.rx_packets = %d.\n", dev->stats.rx_packets);

+	printk("dev->stats.tx_packets = %d.\n", dev->stats.tx_packets);

+}

+#if 0

+static void zx29_gmac_dump_reg(struct net_device *dev)

+{

+	volatile unsigned 	*gmac 	= (unsigned*)dev->base_addr;

+	u32 i;

+

+	printk("MAC:");

+	for(i=0;i<11;i++){

+		if(!(i%4)){printk("\n");}

+		printk("[%04x]:%04x",(0x1000+i*4),);

+	}

+	

+}

+#endif

+static void zx29_gmac_adjust_link(struct net_device *dev)

+{

+	struct zx29_gmac_dev *priv = netdev_priv(dev);

+	struct phy_device *phydev = priv->phydev;

+	volatile unsigned 	*gmac 	= (unsigned*)dev->base_addr;

+

+	//printk("@@@@@@@@@@zx29_gmac_adjust_link.\n");

+	//zx29_gmac_stats_printk(dev);

+	

+	if (priv->link.isup &&

+			(!phydev->link ||

+			(priv->link.speed != phydev->speed) ||

+			(priv->link.duplex != phydev->duplex))) {

+		priv->link.isup = 0;

+		netif_tx_disable(dev);

+		if (!phydev->link) {

+			netif_carrier_off(dev);

+			phy_print_status(phydev);

+			//gmac_event_notify(GMAC_ETH_PLUGOUT, NULL);

+		}

+	}

+

+	if (!priv->link.isup && phydev->link) {

+		if (priv->link.duplex != phydev->duplex) {

+			if (phydev->duplex)

+				mac_set_full_duplex_mode();

+			else

+				mac_set_half_duplex_mode();

+		}

+

+		if (priv->link.giga != (phydev->speed == 100)) {

+			if (phydev->speed == 100) 

+				mac_set_speed_100m_mode();

+			else 

+				mac_set_speed_10m_mode();

+		}

+

+		zx29_gmac_linkisup(dev, 1);

+		//gmac_event_notify(GMAC_ETH_PLUGIN, NULL);

+	}

+}

+

+static inline int zx29_gmac_phy_start(struct net_device *dev)

+{

+	struct zx29_gmac_dev *priv = netdev_priv(dev);

+	int i = 0;

+	struct phy_device *p = NULL;

+	int ret= 0;

+

+	if(priv->nports == 1) {

+		p = phy_find_first(priv->mii.bus);

+ 	} else {

+ 		if(priv->rmii_port < PHY_MAX_ADDR)

+			p = priv->mii.bus->phy_map[priv->rmii_port];

+	}

+

+	if(!p) {

+		printk("%s: no PHY found\n", dev->name);

+		return -ENODEV;

+	}

+

+	ret = phy_connect_direct(dev, p, &zx29_gmac_adjust_link, 0,

+			PHY_INTERFACE_MODE_RMII);

+

+	if (ret) {

+		printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
+		return ret;

+	}

+	p->supported &= PHY_BASIC_FEATURES;

+	p->advertising = p->supported;

+	priv->phydev = p;

+	return 0;

+}

+

+static int zx29_gmac_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)

+{

+    struct zx29_gmac_dev* prv = (struct zx29_gmac_dev*)netdev_priv(dev);

+    int ret = 0;

+

+    spin_lock_irq(&prv->lock);

+    cmd->advertising = prv->set_duplex_mode;

+    cmd->autoneg = prv->autoneg;

+    spin_unlock_irq(&prv->lock);

+

+    return ret;

+}

+

+static int zx29_gmac_do_settings(struct net_device *dev, struct ethtool_cmd *cmd)

+{

+	u32 speed = ethtool_cmd_speed(cmd);

+	struct zx29_gmac_dev* prv = (struct zx29_gmac_dev*)netdev_priv(dev);

+

+	spin_lock_irq(&prv->lock);

+	if(cmd->advertising == prv->set_duplex_mode)

+	{

+		spin_unlock_irq(&prv->lock);

+		return 0;

+	}

+	spin_unlock_irq(&prv->lock);

+

+	//verify the setting we care about

+	if(cmd->autoneg == AUTONEG_DISABLE &&

+	((speed != SPEED_100 &&

+	speed != SPEED_10) ||

+	(cmd->duplex != DUPLEX_HALF &&

+	cmd->duplex != DUPLEX_FULL)))

+	return -EINVAL;

+

+	prv->set_duplex_mode = cmd->advertising;

+	prv->autoneg = prv->phydev->autoneg = cmd->autoneg;

+	prv->phydev->speed = speed;

+	prv->phydev->duplex = cmd->duplex;

+	return genphy_config_aneg(prv->phydev);

+}

+

+

+static u32 zx29_gmac_get_link(struct net_device *dev)

+{

+	struct zx29_gmac_dev* prv = (struct zx29_gmac_dev*)netdev_priv(dev);

+

+	return prv->link.isup;

+}

+

+// ½ÓÊÕº¯Êý

+static int zx29_gmac_rx(struct net_device *dev)

+{

+	struct bd_rx 	*rx;

+	struct sk_buff	*skb;

+	struct sk_buff	*skb_new;

+	unsigned		len;

+	int   exhausted = 0;

+

+	struct zx29_gmac_dev* prv = (struct zx29_gmac_dev*)netdev_priv(dev);

+

+    rx  = get_rx_bd(dev);

+

+    if(unlikely(!rx))	goto rcv_done;

+

+    while(rx)

+    {

+        if((rx->RDES0 & ERR_RX_ES) || (rx->RDES0 & ERR_RX_LE))

+        {

+            dev->stats.rx_errors++;

+            if(rx->RDES0 & ERR_RX_LE)	dev->stats.rx_length_errors++;

+            if(rx->RDES0 & ERR_RX_OE)	dev->stats.rx_over_errors++;

+            if(rx->RDES0 & ERR_RX_IPC)	dev->stats.rx_frame_errors++;

+            if(rx->RDES0 & ERR_RX_LC)	dev->stats.rx_fifo_errors++;

+            if(rx->RDES0 & ERR_RX_CE)	dev->stats.rx_crc_errors++;

+        }

+        else

+        {

+            // ¶Ô½ÓÊÕÊý¾Ý½øÐд¦Àí

+            // ½«»·»ØÁ´±íÖеÄskbÈ¡³ö£¬²¢½«Ð·ÖÅäÐÂskb¹ÒÉÏ£¬ÓÃÓÚ½ÓÊÕÊý¾Ý

+            // ´ËʱËùÓÐÊý¾ÝÒѾ­±£´æÔÚskb->dataÖÐÁË£¬µ«ÊÇÊý¾Ý³¤¶Èskb»¹²»ÖªµÀ£¬²¢ÇÒÊý¾Ý»¹Ã»ÓÐCACHEͬ²½

+            // ¶Ôskb½øÐÐÊý¾Ý³¤¶È¡¢Êý¾Ýͬ²½´¦Àí

+            // È»ºóÉϱ¨¸øÐ­ÒéÉϲã

+

+            len = ((rx->RDES0 >> 16) & 0x3FFF) - 4;

+            if(len  > (ETH_FRAME_LEN+8))  

+            {

+            //LOG_INFO("rx data length more than %d\n", ETH_FRAME_LEN);

+                dev->stats.rx_dropped++;

+                goto rx_bd_reset;

+            }

+

+            skb_new = netdev_alloc_skb(dev, GMAC_FRAME_LEN + NET_IP_ALIGN);

+            if(unlikely(!skb_new))

+            {

+                //LOG_DBG(3, "memory squeeze, dropping packet\n");

+                dev->stats.rx_dropped++;

+				exhausted++;

+            }

+            else

+            {	

+            	exhausted = 0;

+            	dev->stats.rx_packets++;

+				dev->stats.rx_bytes += len;

+				// Êý¾Ý¶Áȡͬ²½DMA buffer ¸üиøcpu

+				dma_sync_single_for_cpu(&dev->dev, rx->dma_buf, GMAC_FRAME_LEN, DMA_FROM_DEVICE);

+                skb				= rx->skb;

+                skb_put(skb, len);

+                skb->protocol 		= eth_type_trans(skb, dev);

+                netif_rx(skb);		

+				

+                skb_reserve(skb_new, NET_IP_ALIGN);

+                //rx->dma_buf    		= __virt_to_phys((unsigned)skb_new->data);

+                rx->dma_buf    		= virtaddr_to_phys((unsigned)skb_new->data);

+                rx->skb			= skb_new;

+				wmb();

+                // Êý¾Ý¶Áȡͬ²½¸øÉ豸

+				dma_sync_single_for_device(&dev->dev, rx->dma_buf, GMAC_FRAME_LEN, DMA_TO_DEVICE); //TODO

+            }

+        }

+        rx_bd_reset:

+        rx->RDES0 = rx->RDES0 | DMA_OWNER;

+        prv->rx_bd_offset++;

+        prv->rx_bd_offset %= GMAC_RX_BD_NUM;

+		wmb();

+		

+		if(exhausted >= 10)

+			break;

+	

+        gmac_trig_receive((void*)dev->base_addr);     //´¥·¢½ÓÊÕ£¬»ñÈ¡½ÓÊÕ´«ÊäÃèÊö·û

+        rx	= get_rx_bd(dev);

+    }

+

+    rcv_done:

+    gmac_trig_receive((void*)dev->base_addr);

+	

+	return (exhausted >= 10);

+}

+

+

+// ·¢ËÍÖжϴ¦Àíº¯Êý

+static void zx29_gmac_tx(struct net_device *dev)

+{

+    register unsigned status;

+    struct net_device_stats	s	= dev->stats;

+    struct bd_tx *tx 			= get_txed_bd(dev);

+

+    while(tx)

+    {

+        status	= tx->TDES0;

+

+        if(tx->TDES0 & ERR_TX_ES)

+        {

+            s.tx_errors++;

+            if(status & ERR_TX_LC)		s.tx_carrier_errors++;

+            if(status & ERR_TX_NC)		s.tx_carrier_errors++;

+            if(status & ERR_TX_EC)		s.tx_window_errors++;

+            if(status & ERR_TX_LATECOL)	s.tx_window_errors++;

+            if(status & ERR_TX_UF)		s.tx_aborted_errors++;

+            if(status & ERR_TX_ED)		s.tx_aborted_errors++;

+            if(status & ERR_TX_JT)		s.tx_fifo_errors++;

+            if(status & ERR_TX_FF)		s.tx_fifo_errors++;

+

+			printk("%s, status=0x%x, err_cnt=%ld\n", __FUNCTION__,status, s.tx_errors);

+            //LOG_DBG(3, "%s %ld\n", __FUNCTION__, s.tx_errors);

+        }

+	dev_kfree_skb_any( tx->skb);  //wl

+	tx->skb = NULL;

+	tx = get_txed_bd(dev);      

+    }

+

+   if(netif_queue_stopped(dev))

+  // if (netif_carrier_ok(dev))

+    {

+        netif_wake_queue(dev);    //ʹµÃÉϲãЭ¶¨¿ªÊ¼´«ËÍеÄ×ÊÁÏÏÂÀ´

+    }

+}

+

+#ifndef GMAC_NO_INT

+static irqreturn_t zx29_gmac_interrupt(int irq, void *dev_id)

+{

+	struct net_device* dev 		= (struct net_device*)dev_id;

+	struct zx29_gmac_dev* prv 	= (struct zx29_gmac_dev*)netdev_priv(dev);

+	volatile unsigned *gmac 	= (unsigned*)dev->base_addr;

+

+	prv->int_event				= MAC(0x1014);									// ¶ÁÈ¡ÖжÏÐÅÏ¢

+	MAC(0x1014)					= prv->int_event;								// Çå³ýÖжÏ

+

+	// ÏȽ«GMACÖÐ¶ÏÆÁ±Î£¬È»ºó½«Ö÷Òª´¦ÀíÁ÷³Ì·ÅÔÚÈíÖжÏÖÐÍê³É

+	// ÈíÖжÏÍê³Éºó£¬ÔÙ´ò¿ªGAMCÖжÏ

+

+	mac_int_disable();

+	tasklet_schedule(&prv->tasklet);

+

+	return IRQ_HANDLED;

+}

+void zx29_gmac_tasklet(unsigned long dev_id)

+{

+    struct net_device* dev 		= (struct net_device*)dev_id;

+    struct zx29_gmac_dev* prv 	= (struct zx29_gmac_dev*)netdev_priv(dev);

+    volatile unsigned *gmac 	= (unsigned*)dev->base_addr;

+

+    unsigned events				= prv->int_event;								// ¶ÁÈ¡ÖжÏÖб£´æµÄÖжϱê¼Ç

+

+    // ¶ÔGMACÖжϽøÐÐÊÂÎñ´¦Àí£¬Ö±µ½Ã»ÓÐÖжÏ(ÊÂÎñ)ÐèÒª´¦Àí

+    do

+    {

+        if(events & INT_ST_TX)

+        {

+            zx29_gmac_tx(dev); 

+        }                                                     

+        if(events & INT_ST_RX)	    

+        {

+            zx29_gmac_rx(dev);

+        }

+

+        events			= MAC(0x1014);

+        MAC(0x1014)		= events;

+

+    } while( events & (INT_ST_TX | INT_ST_RX));

+

+    // ´ËʱGMACµÄÖжÏÊǹرյģ¬ÐèÒªÔٴδò¿ª

+    mac_int_enable();															// ÔÊÐíGMACÔٴβúÉúÖжÏ

+}

+

+#else

+

+void zx29_gmac_tasklet(unsigned long dev_id)

+{

+    struct net_device* dev 		= (struct net_device*)dev_id;

+    struct zx29_gmac_dev* prv 	= (struct zx29_gmac_dev*)netdev_priv(dev);

+    volatile unsigned *gmac 	= (unsigned*)dev->base_addr;

+	int rx_result = 0;

+    unsigned events				= prv->int_event;								// ¶ÁÈ¡ÖжÏÖб£´æµÄÖжϱê¼Ç

+

+    // ¶ÔGMACÖжϽøÐÐÊÂÎñ´¦Àí£¬Ö±µ½Ã»ÓÐÖжÏ(ÊÂÎñ)ÐèÒª´¦Àí

+    do

+    {

+        if(events & INT_ST_TX)

+        {

+            zx29_gmac_tx(dev); 

+        }                                                     

+        if(events & INT_ST_RX)	    

+        {

+           rx_result = zx29_gmac_rx(dev);

+			if(rx_result)//this means skb is exhausted,so break task

+				break;

+        }

+

+        events			= MAC(0x1014);

+        MAC(0x1014)		= events;

+

+    } while( events & (INT_ST_TX | INT_ST_RX));

+

+    // ´ËʱGMACµÄÖжÏÊǹرյģ¬ÐèÒªÔٴδò¿ª

+   // mac_int_enable();															// ÔÊÐíGMACÔٴβúÉúÖжÏ

+}

+

+enum hrtimer_restart gmac_timer_callback(struct hrtimer *timer)

+{

+	unsigned long delay_in_us = GTIMER_INTERVAL;

+	ktime_t gmac_schdule_time;

+	

+	gmac_schdule_time = ktime_set(0, delay_in_us * 1000);

+	hrtimer_forward_now(timer, gmac_schdule_time);

+

+	//gmac_kick_thread();

+    tasklet_schedule(g_gmac_tasklet);

+    //gmac_kick_plug_thread();

+    //tasklet_schedule(&gmac_net_dev_prv->tasklet);

+	return HRTIMER_RESTART;

+}

+

+#endif

+

+static int zx29_gmac_start_xmit(struct sk_buff *skb, struct net_device *dev)

+{

+	unsigned long		flags;

+	unsigned			len;

+	struct sk_buff		*skb_old;

+	struct bd_tx		*tx;

+	struct zx29_gmac_dev*	prv = (struct zx29_gmac_dev*)netdev_priv(dev);

+	

+	if(0 == prv->link.isup)

+	{

+		/*for 616000599226,phy not link ,so free skb 

+			*/

+		dev_kfree_skb_any(skb);

+		//netif_stop_queue(dev);

+		printk("TSP zx29 gmac xmit  phy not link\n");	 

+		return NETDEV_TX_OK;

+	}

+	

+	// ÔÚÈ¡µÃÃèÊö·ûʱÐèÒª»¥³â²Ù×÷

+	spin_lock_irqsave(&prv->lock, flags);

+

+	if(prv->stopped)

+	{

+		spin_unlock_irqrestore(&prv->lock,flags);

+		dev_kfree_skb_any(skb);

+		

+		printk("zx_net_start_xmit when stopped\n");

+		

+		return NETDEV_TX_OK;

+	}

+

+	tx	= get_tx_bd(dev);

+

+	if(!tx)

+	{

+		spin_unlock_irqrestore(&prv->lock,flags);

+		dev_kfree_skb_any(skb);

+		return NETDEV_TX_OK;

+	}

+	prv->tx_bd_offset++;

+	prv->tx_bd_offset %= GMAC_TX_BD_NUM;

+	spin_unlock_irqrestore(&prv->lock, flags);

+

+	if(skb->len > ETH_FRAME_LEN + 4)	//LOG_INFO("tx length too big\n");

+	printk("TSP zx29 gmac start xmit len too long\n");

+

+	// È¡µÃÃèÊö·ûÉϹÒ×ŵÄSKB£¬È»ºó½«¸ÃSKBÏú»Ù(¸ÃSKBµÄÊý¾ÝÒÑ·¢ËÍ)

+	// ÔÙ½«ÐµÄSKB¹ÒÉÏÈ¥(°üÀ¨SKBµØÖ·£¬ÒÔ¼°skb->data¶ÎµÄÎïÀíµØÖ·£¬ÓÃÓÚGMAC·¢ËÍÊý¾ÝÖ®ÓÃ)

+	// ×¢ÒâÔÚ½«skb->data¶ÎµÄÊý¾Ý·¢ËÍËùÓÐȨ½»¸øGMAC֮ǰ£¬ÐèÒª¶Ôdata¶ÎµÄÊý¾Ý½øÐÐCACHEͬ²½´¦Àí

+	// ÒòΪskb->dataµÄÊý¾ÝÊÇcachedµÄ

+

+	//wl skb_old		 = tx->skb;

+	//flush_skbuf(skb);

+

+	skb= flush_skbuf(skb);

+	if(NULL == skb)

+		BUG_ON(1);	 

+	len 				= MIN(skb->len, GMAC_FRAME_LEN - NET_IP_ALIGN);

+	tx->TDES0		  |= (0x07 << 28);					// ÉèÖÃ״̬±ê¼ÇΪ֡µÄµÚÒ»¸öÊý¾Ý°ü£¬×îºóÒ»¸öÊý°ü£¬Íê³ÉºóÖжÏ(Ò»Ö¡Ò»¸öÊý¾Ý°ü)

+	//tx->dma_buf	 = __virt_to_phys((unsigned)skb->data);

+	tx->dma_buf  = virtaddr_to_phys((unsigned)skb->data);

+	tx->skb 	 = skb;

+

+	// Êý¾ÝдÈëͬ²½

+	// dma_sync_single_for_device(&dev->dev, tx->dma_buf, len, DMA_TO_DEVICE);

+	//wl dev_kfree_skb_any(skb_old);

+	  

+	tx->TDES1	 = len;

+	tx->TDES0	|= DMA_OWNER;

+

+	//prv->tx_bd_offset++;

+	//prv->tx_bd_offset %= GMAC_TX_BD_NUM;

+	wmb();

+	dev->stats.tx_bytes 		+= len;

+	dev->stats.tx_packets++;

+	dev->trans_start			= jiffies;

+

+	gmac_trig_transmit((void*)dev->base_addr);

+	

+	return NETDEV_TX_OK;

+}

+

+

+static void zx29_gmac_tx_timeout(struct net_device *dev)

+{

+	struct zx29_gmac_dev* prv	= (struct zx29_gmac_dev*)netdev_priv(dev);

+

+	genphy_update_link(prv->phydev);

+	prv->link.isup= prv->phydev->link;

+	

+	if(0 == prv->link.isup) {	

+		printk("TSP zx29 gmac net timeout phy not link\n");						// PHY δÁ¬½Ó

+		netif_stop_queue(dev);

+		netif_carrier_off(dev);

+	} else {

+		printk("TSP zx29 gmac net timeout phy linked\n"); 

+		gmac_trig_transmit(dev);

+		gmac_trig_receive(dev);

+

+		netif_carrier_on(dev);

+		netif_wake_queue(dev);

+		dev->trans_start		= jiffies;

+		dev->stats.tx_errors++;

+		dev->stats.tx_dropped++;

+	}

+}

+

+int zx29_gmac_open(struct net_device *dev)

+{

+	struct zx29_gmac_dev *prv = netdev_priv(dev);

+	unsigned long flags;

+	int ret;

+	int err = 0;

+#ifdef GMAC_NO_INT

+	unsigned long delay_in_us = GTIMER_INTERVAL;

+	ktime_t gmac_schdule_time;

+#endif

+

+	err = phy_read_status(prv->phydev);

+    if (err < 0)

+	    return err;

+		

+	spin_lock_irqsave(&prv->lock, flags);

+	prv->link.speed = 0;

+

+	zx29_gmac_linkisup(dev, prv->phydev->link);

+

+	ret	= gmac_hw_init(dev);

+

+	if(ret) {

+		spin_unlock_irqrestore(&prv->lock, flags);

+		return ret;

+	}

+	

+    netif_carrier_on(dev);

+	spin_unlock_irqrestore(&prv->lock, flags);

+	phy_start(prv->phydev);

+	netif_start_queue(dev);

+

+#ifdef GMAC_NO_INT

+	gmac_schdule_time = ktime_set(0, delay_in_us * 1000);

+	if(prv->timer)

+		hrtimer_start(prv->timer, gmac_schdule_time, HRTIMER_MODE_REL );

+#endif

+

+	prv->stopped = 0;

+

+	printk("TSP zx29 gmac net open\n");

+

+	return 0;

+}

+

+static int zx29_gmac_stop(struct net_device *dev)

+{

+	unsigned long flags = 0;

+	int ret = 0;

+	struct zx29_gmac_dev* prv = (struct zx29_gmac_dev*)netdev_priv(dev);

+	

+	spin_lock_irqsave(&prv->lock, flags);

+	

+#ifdef GMAC_NO_INT

+	ret = hrtimer_cancel(prv->timer);

+	if(ret < 0) {

+		BUG_ON(1);

+		spin_unlock_irqrestore(&prv->lock,flags);

+		return ret;

+	}

+#endif

+

+	prv->stopped = 1;

+	

+	netif_stop_queue(dev);

+	netif_carrier_off(dev);

+	phy_stop(prv->phydev);

+

+	gmac_hw_deinit(dev);

+

+	memset(&dev->stats, 0, sizeof(struct net_device_stats));

+	

+	spin_unlock_irqrestore(&prv->lock,flags);

+	printk("TSP zx29 gmac net stop\n");

+

+	return 0;

+}

+

+static int zx29_gmac_set_mac_address(struct net_device *dev, void *p)

+{

+    int ret = eth_mac_addr(dev, p);

+	

+    if(!ret) {

+		gmac_update_mac(dev);

+		printk(" zx29 gmac set mac addr ok\n");

+    }

+

+    return ret;

+}

+/*

+static struct net_device_stats *zx29_gmac_stats(struct net_device *dev)

+{

+

+}

+*/

+static int zx29_gmac_suspend(struct device *dev)

+{

+    struct platform_device *pdev	= to_platform_device(dev);

+    struct net_device 	*ndev		= platform_get_drvdata(pdev);

+

+    if(ndev) {

+    	if(netif_running(ndev)) {

+    		netif_device_detach(ndev);

+    		gmac_stop((void*)ndev->base_addr);

+    	}

+    }

+    return 0;

+}

+

+static int zx29_gmac_resume(struct device *dev)

+{

+    struct platform_device *pdev	= to_platform_device(dev);

+    struct net_device *ndev 		= platform_get_drvdata(pdev);

+

+    if(ndev) {

+    	if(netif_running(ndev)) {

+        	gmac_start((void*)ndev->base_addr);

+        	netif_device_attach(ndev);

+    	}

+    }

+    return 0;

+}

+

+static int zx29_gmac_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)

+{

+	struct zx29_gmac_dev *priv = netdev_priv(dev);

+	if (!(netif_running(dev)))

+		return -EINVAL;

+	if (!priv->phydev)

+		return -EINVAL;

+	return phy_mii_ioctl(priv->phydev, ifr, cmd);

+}

+

+static const struct ethtool_ops zx29_gmac_ethtool_ops = 

+{

+    .get_settings	= zx29_gmac_get_settings,

+    .set_settings	= zx29_gmac_do_settings,

+    .get_link		= zx29_gmac_get_link,

+};

+

+static const struct net_device_ops zx29_gmac_netdev_ops =

+{

+    .ndo_open               = zx29_gmac_open,

+    .ndo_stop               = zx29_gmac_stop,

+    .ndo_start_xmit         = zx29_gmac_start_xmit,

+    .ndo_tx_timeout         = zx29_gmac_tx_timeout,

+    .ndo_do_ioctl             =  zx29_gmac_ioctl,

+   // .ndo_set_multicast_list =  zx_set_multicast,

+    .ndo_change_mtu         = eth_change_mtu,

+    .ndo_validate_addr      = eth_validate_addr,

+    .ndo_set_mac_address    = zx29_gmac_set_mac_address,

+};

+

+static int __devinit zx29_gmac_probe(struct platform_device *pdev)

+{

+	struct zx29_gmac_dev *prv = NULL;

+	struct net_device* ndev = alloc_etherdev(sizeof(struct zx29_gmac_dev));

+	volatile unsigned	*gmac = NULL;

+	struct gmac_platform_data *pdata = dev_get_platdata(&pdev->dev);

+	int ret;

+	unsigned long i;

+	struct mii_bus *mb;

+    struct resource *iomem;

+

+	printk("#########zx29_gmac_probe begin.\n");

+

+	if (!ndev)

+		return -ENOMEM;

+	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);

+	if(!iomem)

+		return -ENXIO;

+

+	ret = gpio_request(63, "phy_rst"); /* gpio 63 */

+	gpio_direction_output(63, 1);

+	mdelay(1);

+	ret = gpio_request(127, "gmac_power"); /* gpio 83/124 */

+	gpio_direction_output(127, 1);

+	mdelay(15);

+	gpio_direction_output(63, 0);

+	mdelay(10);

+	gpio_direction_output(63, 1);

+	mdelay(15);

+	ndev->base_addr = iomem->start;

+	if(!ndev->base_addr)

+		return -ENXIO;		

+#ifndef GMAC_NO_INT

+	ndev->irq = platform_get_irq(pdev, 0);

+#endif

+	ndev->netdev_ops = &zx29_gmac_netdev_ops;

+	ndev->ethtool_ops = &zx29_gmac_ethtool_ops;

+

+	gmac 	= (unsigned*)ndev->base_addr;

+

+    /*¹Ø±ÕGMACËùÓй¦ÄÜ*/

+    dma_disable();

+    mac_disable();

+    mac_int_disable();

+

+	prv = netdev_priv(ndev);

+	memset(prv, 0, sizeof(*prv));

+	spin_lock_init(&prv->lock);

+

+	wake_lock_init(&prv->wake_lock, WAKE_LOCK_SUSPEND, "gmac_pm");

+    wake_lock(&prv->wake_lock);

+

+	zx29_gmac_set_macaddr(ndev);

+

+#ifndef GMAC_NO_INT

+	ret = request_irq(ndev->irq, zx29_gmac_interrupt, 0, ndev->name, ndev);

+	if (ret) {

+		printk(KERN_ERR "irq request failed: %d\n", ndev->irq);

+		goto errirq;
+	}

+#endif

+

+	ret = register_netdev(ndev);

+	if (ret) {

+		printk(KERN_ERR "error registering device %s\n",

+			ndev->name);

+		goto errdev;
+	}

+

+	prv->nports = pdata->nports;

+	prv->rmii_port = pdata->rmii_port;

+	prv->base_addr = ndev->base_addr;

+

+	prv->netdev = ndev;

+

+	mb = mdiobus_alloc();

+	if (!mb) {
+		printk(KERN_ERR "error allocating mii bus\n");

+		goto errmii;
+	}
+	mb->name = "zx29_gmac_mii";

+	mb->read = zx29mii_read;

+	mb->write = zx29mii_write;

+	mb->reset = zx29mii_reset;

+	mb->priv = prv;

+	snprintf(mb->id, MII_BUS_ID_SIZE, "%s-%x", pdev->name, pdev->id);
+	mb->phy_mask = pdata->port_mask;

+	mb->irq = &prv->mii.irq[0];

+	for (i = 0; i < PHY_MAX_ADDR; i++) {
+		int n = platform_get_irq(pdev, i + 1);
+		if (n < 0)
+			n = PHY_POLL;
+		prv->mii.irq[i] = n;

+	}

+	gmac_set_clk();

+	gmac_phy_release();

+	mdelay(500);/*Îñ±ØÒªdelay£¬·ñÔò»á³öÏÖ¶ÁÈ¡PHY¼Ä´æÆ÷ʧ°ÜµÄÇé¿ö*/

+	

+	mdiobus_register(mb);/*ÀïÃæÓжÁÈ¡PHY IDµÄ²Ù×÷£¬ËùÒÔ֮ǰÐèÒªÊÍ·ÅPHYµÄ¸´Î»*/

+	prv->mii.bus = mb;

+	ret = zx29_gmac_phy_start(ndev);

+	if (ret) {

+		//BUG_ON(1);

+		goto errphystart;

+	}

+	

+	platform_set_drvdata(pdev, ndev);

+

+	tasklet_init(&prv->tasklet, zx29_gmac_tasklet, (unsigned long)ndev);

+	g_gmac_tasklet = &prv->tasklet;

+

+	prv->dma_rx_vir	= dma_alloc_coherent(NULL,

+						GMAC_BUF_LEN,

+						&prv->dma_rx_phy,

+						GFP_KERNEL);

+	if(prv->dma_rx_vir == NULL) {

+		BUG_ON(1);

+		goto errphystart;

+	}

+	prv->dma_rx_phy_init = prv->dma_rx_phy;

+	prv->dma_rx_vir_init = prv->dma_rx_vir;

+    prv->dma_tx_vir	= prv->dma_rx_vir + GMAC_RX_BUF_LEN;

+    prv->dma_tx_phy	= prv->dma_rx_phy + GMAC_RX_BUF_LEN;

+

+#ifdef GMAC_NO_INT

+	sema_init(&prv->sem, 0);

+

+	prv->timer = kzalloc(sizeof(struct hrtimer),GFP_KERNEL);

+	if(prv->timer == NULL){

+		BUG_ON(1);

+		goto errmalloc;

+	}

+    hrtimer_init(prv->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL );

+

+    prv->timer->function = gmac_timer_callback;

+#endif

+

+	gmac_event_init();

+

+	g_gmac_dev = prv;

+

+	printk("#########zx29_gmac_probe end.\n");

+

+	return 0;

+errmalloc:

+	dma_free_coherent(NULL, GMAC_BUF_LEN, prv->dma_rx_vir, prv->dma_rx_phy);

+errphystart:

+	mdiobus_unregister(prv->mii.bus);

+	mdiobus_free(prv->mii.bus);

+errmii:
+	unregister_netdev(ndev);

+errdev:

+#ifndef GMAC_NO_INT

+	free_irq(ndev->irq, ndev);

+#endif

+errirq:
+	free_netdev(ndev);

+

+	printk("#########zx29_gmac_probe fail.\n");

+	return ret;

+}

+

+static int __devexit zx29_gmac_remove(struct platform_device *pdev)

+{

+	struct net_device* ndev = platform_get_drvdata(pdev);

+	volatile unsigned	*gmac = NULL;

+	if(ndev) {

+		struct zx29_gmac_dev *prv = netdev_priv(ndev);

+		gmac_hw_deinit(ndev);

+		mdiobus_unregister(prv->mii.bus);

+#ifndef GMAC_NO_INT

+		free_irq(ndev->irq, ndev);

+#endif

+

+		tasklet_disable(&prv->tasklet);

+    	tasklet_kill(&prv->tasklet);

+

+		if(prv->dma_rx_vir)

+			dma_free_coherent(NULL, GMAC_BUF_LEN, prv->dma_rx_vir, prv->dma_rx_phy);   //ÊÍ·Ådma»º³åÇø

+

+		wake_unlock(&prv->wake_lock);

+		wake_lock_destroy(&prv->wake_lock);

+

+		unregister_netdev(ndev);

+		free_netdev(ndev);

+		platform_set_drvdata(pdev, NULL);

+	}

+	return 0;

+}

+

+static struct dev_pm_ops zx29_gmac_pm_ops =

+{

+	.suspend    = zx29_gmac_suspend,

+	.resume     = zx29_gmac_resume,

+};

+

+static struct platform_driver zx29_gmac_driver = {

+	.probe     = zx29_gmac_probe,

+	.remove    = __devexit_p(zx29_gmac_remove),

+	.driver    = {

+		.name     = "zx29_gmac",

+		.owner    = THIS_MODULE,

+		.pm       = &zx29_gmac_pm_ops,

+	},

+};

+

+static int __init zx29_gmac_init(void)

+{

+	printk(KERN_INFO "ZX29 GMAC ethernet driver\n");

+	return platform_driver_register(&zx29_gmac_driver);

+}

+

+

+static void __exit zx29_gmac_exit(void)

+{

+	platform_driver_unregister(&zx29_gmac_driver);

+}

+

+module_init(zx29_gmac_init);

+module_exit(zx29_gmac_exit);

+

+MODULE_LICENSE("GPL");

+MODULE_DESCRIPTION("ZX29 on chip Ethernet driver");

+MODULE_AUTHOR("zhang dongdong <zhang.dongdong16@zte.com.cn>");

+

+

diff --git a/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/phy/Kconfig b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/phy/Kconfig
new file mode 100755
index 0000000..dc72c51
--- /dev/null
+++ b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/phy/Kconfig
@@ -0,0 +1,152 @@
+#
+# PHY Layer Configuration
+#
+
+menuconfig PHYLIB
+	tristate "PHY Device support and infrastructure"
+	depends on !S390
+	depends on NETDEVICES
+	help
+	  Ethernet controllers are usually attached to PHY
+	  devices.  This option provides infrastructure for
+	  managing PHY devices.
+
+if PHYLIB
+
+comment "MII PHY device drivers"
+
+config AMD_PHY
+	tristate "Drivers for the AMD PHYs"
+	---help---
+	  Currently supports the am79c874
+
+config MARVELL_PHY
+	tristate "Drivers for Marvell PHYs"
+	---help---
+	  Currently has a driver for the 88E1011S
+	
+config DAVICOM_PHY
+	tristate "Drivers for Davicom PHYs"
+	---help---
+	  Currently supports dm9161e and dm9131
+
+config QSEMI_PHY
+	tristate "Drivers for Quality Semiconductor PHYs"
+	---help---
+	  Currently supports the qs6612
+
+config LXT_PHY
+	tristate "Drivers for the Intel LXT PHYs"
+	---help---
+	  Currently supports the lxt970, lxt971
+
+config CICADA_PHY
+	tristate "Drivers for the Cicada PHYs"
+	---help---
+	  Currently supports the cis8204
+
+config VITESSE_PHY
+        tristate "Drivers for the Vitesse PHYs"
+        ---help---
+          Currently supports the vsc8244
+
+config SMSC_PHY
+	tristate "Drivers for SMSC PHYs"
+	---help---
+	  Currently supports the LAN83C185, LAN8187 and LAN8700 PHYs
+
+config BROADCOM_PHY
+	tristate "Drivers for Broadcom PHYs"
+	---help---
+	  Currently supports the BCM5411, BCM5421, BCM5461, BCM5464, BCM5481
+	  and BCM5482 PHYs.
+
+config BCM63XX_PHY
+	tristate "Drivers for Broadcom 63xx SOCs internal PHY"
+	depends on BCM63XX
+	---help---
+	  Currently supports the 6348 and 6358 PHYs.
+
+config ICPLUS_PHY
+	tristate "Drivers for ICPlus PHYs"
+	---help---
+	  Currently supports the IP175C and IP1001 PHYs.
+
+config REALTEK_PHY
+	tristate "Drivers for Realtek PHYs"
+	---help---
+	  Supports the Realtek 821x PHY.
+
+config NATIONAL_PHY
+	tristate "Drivers for National Semiconductor PHYs"
+	---help---
+	  Currently supports the DP83865 PHY.
+
+config STE10XP
+	tristate "Driver for STMicroelectronics STe10Xp PHYs"
+	---help---
+	  This is the driver for the STe100p and STe101p PHYs.
+
+config LSI_ET1011C_PHY
+	tristate "Driver for LSI ET1011C PHY"
+	---help---
+	  Supports the LSI ET1011C PHY.
+
+config MICREL_PHY
+	tristate "Driver for Micrel PHYs"
+	---help---
+	  Supports the KSZ9021, VSC8201, KS8001 PHYs.
+
+config FIXED_PHY
+	bool "Driver for MDIO Bus/PHY emulation with fixed speed/link PHYs"
+	depends on PHYLIB=y
+	---help---
+	  Adds the platform "fixed" MDIO Bus to cover the boards that use
+	  PHYs that are not connected to the real MDIO bus.
+
+	  Currently tested with mpc866ads and mpc8349e-mitx.
+
+config JLSEMI_PHY
+	bool "Driver forJLSEMI PHYs"
+	depends on PHYLIB=y
+	---help---
+	  Adds JLSEMI
+
+config MDIO_BITBANG
+	tristate "Support for bitbanged MDIO buses"
+	help
+	  This module implements the MDIO bus protocol in software,
+	  for use by low level drivers that export the ability to
+	  drive the relevant pins.
+
+	  If in doubt, say N.
+
+config MDIO_GPIO
+	tristate "Support for GPIO lib-based bitbanged MDIO buses"
+	depends on MDIO_BITBANG && GENERIC_GPIO
+	---help---
+	  Supports GPIO lib-based MDIO busses.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called mdio-gpio.
+
+config MDIO_OCTEON
+	tristate "Support for MDIO buses on Octeon SOCs"
+	depends on  CPU_CAVIUM_OCTEON
+	default y
+	help
+
+	  This module provides a driver for the Octeon MDIO busses.
+	  It is required by the Octeon Ethernet device drivers.
+
+	  If in doubt, say Y.
+
+endif # PHYLIB
+
+config MICREL_KS8995MA
+	tristate "Micrel KS8995MA 5-ports 10/100 managed Ethernet switch"
+	depends on SPI
+
+source "drivers/net/phy/icplus/Kconfig"
+source "drivers/net/phy/realtek/Kconfig"
+
diff --git a/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/phy/Makefile b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/phy/Makefile
new file mode 100755
index 0000000..fa3391b
--- /dev/null
+++ b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/phy/Makefile
@@ -0,0 +1,30 @@
+# Makefile for Linux PHY drivers
+
+libphy-objs			:= phy.o phy_device.o mdio_bus.o
+
+obj-$(CONFIG_PHYLIB)		+= libphy.o
+obj-$(CONFIG_MARVELL_PHY)	+= marvell.o
+obj-$(CONFIG_DAVICOM_PHY)	+= davicom.o
+obj-$(CONFIG_CICADA_PHY)	+= cicada.o
+obj-$(CONFIG_LXT_PHY)		+= lxt.o
+obj-$(CONFIG_QSEMI_PHY)		+= qsemi.o
+obj-$(CONFIG_SMSC_PHY)		+= smsc.o
+obj-$(CONFIG_VITESSE_PHY)	+= vitesse.o
+obj-$(CONFIG_BROADCOM_PHY)	+= broadcom.o
+obj-$(CONFIG_BCM63XX_PHY)	+= bcm63xx.o
+obj-$(CONFIG_ICPLUS_PHY)	+= icplus/
+obj-$(CONFIG_REALTEK_PHY)	+= realtek/
+obj-$(CONFIG_LSI_ET1011C_PHY)	+= et1011c.o
+obj-$(CONFIG_FIXED_PHY)		+= fixed.o
+obj-$(CONFIG_MDIO_BITBANG)	+= mdio-bitbang.o
+obj-$(CONFIG_MDIO_GPIO)		+= mdio-gpio.o
+obj-$(CONFIG_NATIONAL_PHY)	+= national.o
+obj-$(CONFIG_DP83640_PHY)	+= dp83640.o
+obj-$(CONFIG_STE10XP)		+= ste10Xp.o
+obj-$(CONFIG_MICREL_PHY)	+= micrel.o
+obj-$(CONFIG_MDIO_OCTEON)	+= mdio-octeon.o
+obj-$(CONFIG_MICREL_KS8995MA)	+= spi_ks8995.o
+obj-$(CONFIG_AMD_PHY)		+= amd.o
+
+jlsemiphy-objs := jlsemi.o jlsemi-core.o
+obj-$(CONFIG_JLSEMI_PHY) += jlsemiphy.o
\ No newline at end of file
diff --git a/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/phy/jlsemi-core.c b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/phy/jlsemi-core.c
new file mode 100755
index 0000000..51283db
--- /dev/null
+++ b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/phy/jlsemi-core.c
@@ -0,0 +1,2949 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2021 JLSemi Corporation
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+#include "jlsemi-core.h"
+#include <linux/phy.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/netdevice.h>
+
+#define JL1XXX_PAGE24		24
+#define JL1XXX_LED_BLINK_REG	25
+
+#define JL1XXX_PAGE128		128
+#define JL1XXX_LED_GPIO_REG	29
+#define JL1XXX_WOL_CTRL_REG	28
+
+#define JL2XXX_PAGE3332		3332
+#define JL2XXX_LED_CTRL_REG	16
+#define JL2XXX_PAGE4096		4096
+#define JL2XXX_LED_BLINK_REG	20
+#define JL2XXX_LED_POLARITY_REG	19
+
+#define JL2XXX_PAGE128		128
+#define JL2XXX_FLD_CTRL_REG	28
+#define JL2XXX_FLD_EN		BIT(13)
+#define JL2XXX_FLD_MASK		0x1800
+#define JL2XXX_FLD_MASK_HEAD	11
+#define JL2XXX_FLD_DELAY_00MS	0
+#define JL2XXX_FLD_DELAY_10MS	1
+#define JL2XXX_FLD_DELAY_20MS	2
+#define JL2XXX_FLD_DELAY_40MS	3
+
+#define JL2XXX_SPEED10		0
+#define JL2XXX_SPEED100		1
+#define JL2XXX_SPEED1000	2
+
+#define JL2XXX_PHY_MODE_REG	30
+#define JL2XXX_FIBER_1000	BIT(12)
+#define JL2XXX_FIBER_100	BIT(11)
+#define JL2XXX_PHY_FIBER_MODE_MASK	0x1800
+#define JL2XXX_BMCR_DUPLEX	BIT(8)
+#define JL2XXX_LPA_FIBER_1000HALF	0x40
+#define JL2XXX_LPA_FIBER_1000FULL	0x20
+#define JL2XXX_BMCR_SPEED_LSB	BIT(13)
+#define JL2XXX_BMCR_SPEED_MSB	BIT(6)
+#define JL2XXX_BMCR_AN_RESTART	BIT(9)
+
+
+
+#define JL2XXX_SUPP_LED_MODE	(JL2XXX_LED0_LINK10 | \
+				 JL2XXX_LED0_LINK100 | \
+				 JL2XXX_LED0_LINK1000 | \
+				 JL2XXX_LED0_ACTIVITY | \
+				 JL2XXX_LED1_LINK10 | \
+				 JL2XXX_LED1_LINK100 | \
+				 JL2XXX_LED1_LINK1000 | \
+				 JL2XXX_LED1_ACTIVITY | \
+				 JL2XXX_LED2_LINK10 | \
+				 JL2XXX_LED2_LINK100 | \
+				 JL2XXX_LED2_LINK1000 | \
+				 JL2XXX_LED2_ACTIVITY)
+
+#define JL1XXX_SUPP_GPIO	(JL1XXX_GPIO_LED0_EN | \
+				 JL1XXX_GPIO_LED0_OUT | \
+				 JL1XXX_GPIO_LED1_EN | \
+				 JL1XXX_GPIO_LED1_OUT)
+
+#define JL1XXX_SUPP_LED_MODE	(JL1XXX_LED0_EEE | \
+				 JL1XXX_LED0_100_ACTIVITY | \
+				 JL1XXX_LED0_10_ACTIVITY | \
+				 JL1XXX_LED0_100_LINK | \
+				 JL1XXX_LED0_10_LINK | \
+				 JL1XXX_LED1_EEE | \
+				 JL1XXX_LED1_100_ACTIVITY | \
+				 JL1XXX_LED1_10_ACTIVITY | \
+				 JL1XXX_LED1_100_LINK | \
+				 JL1XXX_LED1_10_LINK)
+
+/************************* Configuration section *************************/
+
+
+/************************* JLSemi iteration code *************************/
+static int jl1xxx_led_static_op_set(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+	int err;
+
+	/* Enable LED operation */
+	jlsemi_set_bits(phydev, JL1XXX_PAGE7,
+			JL1XXX_LED_REG, JL1XXX_LED_EN);
+
+	/* Set led mode */
+	if (priv->led.enable & JL1XXX_LED_MODE_EN) {
+		err = jlsemi_modify_paged_reg(phydev, JL1XXX_PAGE129,
+					      JL1XXX_LED_MODE_REG,
+					      JL1XXX_SUPP_LED_MODE,
+					      priv->led.mode);
+		if (err < 0)
+			return err;
+	}
+	/* Set led period */
+	if (priv->led.enable & JL1XXX_LED_GLOABL_PERIOD_EN) {
+		err = jlsemi_modify_paged_reg(phydev, JL1XXX_PAGE24,
+					      JL1XXX_LED_BLINK_REG,
+					      LED_PERIOD_MASK,
+					      LEDPERIOD(
+					      priv->led.global_period));
+		if (err < 0)
+			return err;
+	}
+	/* Set led on time */
+	if (priv->led.enable & JL1XXX_LED_GLOBAL_ON_EN) {
+		err = jlsemi_modify_paged_reg(phydev, JL1XXX_PAGE24,
+					      JL1XXX_LED_BLINK_REG,
+					      LED_ON_MASK,
+					      LEDON(priv->led.global_on));
+		if (err < 0)
+			return err;
+	}
+	/*Set led gpio output */
+	if (priv->led.enable & JL1XXX_LED_GPIO_OUT_EN) {
+		err = jlsemi_modify_paged_reg(phydev, JL1XXX_PAGE128,
+					      JL1XXX_LED_GPIO_REG,
+					      JL1XXX_SUPP_GPIO,
+					      priv->led.gpio_output);
+		if (err < 0)
+			return err;
+	}
+
+	return 0;
+}
+
+static int jl2xxx_led_static_op_set(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	int err;
+
+	/* Set led mode */
+	if (priv->led.enable & JL2XXX_LED_MODE_EN) {
+		err = jlsemi_modify_paged_reg(phydev, JL2XXX_PAGE3332,
+					      JL2XXX_LED_CTRL_REG,
+					      JL2XXX_SUPP_LED_MODE,
+					      priv->led.mode);
+		if (err < 0)
+			return err;
+	}
+	/* Set led period */
+	if (priv->led.enable & JL2XXX_LED_GLOABL_PERIOD_EN) {
+		err = jlsemi_modify_paged_reg(phydev, JL2XXX_PAGE4096,
+					      JL2XXX_LED_BLINK_REG,
+					      LED_PERIOD_MASK,
+					      LEDPERIOD(
+					      priv->led.global_period));
+		if (err < 0)
+			return err;
+	}
+	/* Set led on time */
+	if (priv->led.enable & JL2XXX_LED_GLOBAL_ON_EN) {
+		err = jlsemi_modify_paged_reg(phydev, JL2XXX_PAGE4096,
+					      JL2XXX_LED_BLINK_REG,
+					      LED_ON_MASK,
+					      LEDON(priv->led.global_on));
+		if (err < 0)
+			return err;
+	}
+	/* Set led polarity */
+	if (priv->led.enable & JL2XXX_LED_POLARITY_EN) {
+		err = jlsemi_set_bits(phydev, JL2XXX_PAGE4096,
+				      JL2XXX_LED_POLARITY_REG,
+				      priv->led.polarity);
+		if (err < 0)
+			return err;
+	}
+
+	return 0;
+}
+
+struct device *jlsemi_get_mdio(struct phy_device *phydev)
+{
+#if JLSEMI_DEV_COMPATIBLE
+	struct device *dev = &phydev->dev;
+#else
+	struct device *dev = &phydev->mdio.dev;
+#endif
+	return dev;
+}
+
+static struct device_node *get_device_node(struct phy_device *phydev)
+{
+	struct device *dev = jlsemi_get_mdio(phydev);
+
+	return dev->of_node;
+}
+
+static int jl1xxx_dts_led_cfg_get(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+	struct device_node *of_node = get_device_node(phydev);
+
+	of_property_read_u32(of_node, "jl1xxx,led-enable",
+			     &priv->led.enable);
+	of_property_read_u32(of_node, "jl1xxx,led-mode",
+			     &priv->led.mode);
+	of_property_read_u32(of_node, "jl1xxx,led-period",
+			     &priv->led.global_period);
+	of_property_read_u32(of_node, "jl1xxx,led-on",
+			     &priv->led.global_on);
+	of_property_read_u32(of_node, "jl1xxx,led-gpio",
+			     &priv->led.gpio_output);
+
+	return 0;
+}
+
+static int jl1xxx_dts_wol_cfg_get(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+	struct device_node *of_node = get_device_node(phydev);
+
+	of_property_read_u32(of_node, "jl1xxx,wol-enable",
+			     &priv->wol.enable);
+
+	return 0;
+}
+
+static int jl1xxx_dts_intr_cfg_get(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+	struct device_node *of_node = get_device_node(phydev);
+
+	of_property_read_u32(of_node, "jl1xxx,interrupt-enable",
+			     &priv->intr.enable);
+
+	return 0;
+}
+
+static int jl1xxx_dts_mdi_cfg_get(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+	struct device_node *of_node = get_device_node(phydev);
+
+	of_property_read_u32(of_node, "jl1xxx,mdi-enable",
+			     &priv->mdi.enable);
+	of_property_read_u32(of_node, "jl1xxx,mdi-rate",
+			     &priv->mdi.rate);
+	of_property_read_u32(of_node, "jl1xxx,mdi-amplitude",
+			     &priv->mdi.amplitude);
+
+	return 0;
+}
+
+static int jl1xxx_dts_rmii_cfg_get(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+	struct device_node *of_node = get_device_node(phydev);
+
+	of_property_read_u32(of_node, "jl1xxx,rmii-enable",
+			     &priv->rmii.enable);
+	of_property_read_u32(of_node, "jl1xxx,rmii-rx_timing",
+			     &priv->rmii.rx_timing);
+	of_property_read_u32(of_node, "jl1xxx,rmii-tx_timing",
+			     &priv->rmii.tx_timing);
+
+	return 0;
+}
+
+
+static int jl2xxx_dts_led_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct device_node *of_node = get_device_node(phydev);
+
+	of_property_read_u32(of_node, "jl2xxx,led-enable",
+			     &priv->led.enable);
+	of_property_read_u32(of_node, "jl2xxx,led-mode",
+			     &priv->led.mode);
+	of_property_read_u32(of_node, "jl2xxx,led-period",
+			     &priv->led.global_period);
+	of_property_read_u32(of_node, "jl2xxx,led-on",
+			     &priv->led.global_on);
+	of_property_read_u32(of_node, "jl2xxx,led-polarity",
+			     &priv->led.polarity);
+
+	return 0;
+}
+
+static int jl1xxx_c_macro_led_cfg_get(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+
+	/* Config LED */
+	struct jl_led_ctrl led_cfg = {
+		.enable		= JL1XXX_LED_CTRL_EN,
+		.mode		= JL1XXX_CFG_LED_MODE,
+		.global_period	= JL1XXX_GLOBAL_PERIOD_MS,
+		.global_on	= JL1XXX_GLOBAL_ON_MS,
+		.gpio_output	= JL1XXX_CFG_GPIO,
+	};
+
+	priv->led = led_cfg;
+
+	return 0;
+}
+
+static int jl1xxx_c_macro_wol_cfg_get(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+
+	struct jl_wol_ctrl wol_cfg = {
+		.enable		= JL1XXX_WOL_CTRL_EN,
+	};
+
+	priv->wol = wol_cfg;
+
+	return 0;
+}
+
+static int jl1xxx_c_macro_intr_cfg_get(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+
+	struct jl_intr_ctrl intr_cfg = {
+		.enable		= JL1XXX_INTR_CTRL_EN,
+	};
+
+	priv->intr = intr_cfg;
+
+	return 0;
+}
+
+static int jl1xxx_c_macro_mdi_cfg_get(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+
+	struct jl_mdi_ctrl mdi_cfg = {
+		.enable		= JL1XXX_MDI_CTRL_EN,
+		.rate		= JL1XXX_MDI_RATE,
+		.amplitude	= JL1XXX_MDI_AMPLITUDE,
+	};
+
+	priv->mdi = mdi_cfg;
+
+	return 0;
+}
+
+static int jl1xxx_c_macro_rmii_cfg_get(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+
+	struct jl_rmii_ctrl rmii_cfg = {
+		.enable		= JL1XXX_RMII_CTRL_EN,
+		.tx_timing	= JL1XXX_RMII_TX_TIMING,
+		.rx_timing	= JL1XXX_RMII_RX_TIMING,
+	};
+
+	priv->rmii = rmii_cfg;
+
+	return 0;
+}
+
+static int jl2xxx_c_macro_led_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+
+	struct jl_led_ctrl led_cfg = {
+		.enable		= JL2XXX_LED_CTRL_EN,
+		.mode		= JL2XXX_CFG_LED_MODE,
+		.global_period	= JL2XXX_GLOBAL_PERIOD_MS,
+		.global_on	= JL2XXX_GLOBAL_ON_MS,
+		.polarity	= JL2XXX_LED_POLARITY,
+	};
+
+	priv->led = led_cfg;
+
+	return 0;
+}
+
+static int jl1xxx_wol_operation_args(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+	struct jl_wol_ctrl *wol = &priv->wol;
+
+	if (JLSEMI_KERNEL_DEVICE_TREE_USE)
+		jl1xxx_dts_wol_cfg_get(phydev);
+	else
+		jl1xxx_c_macro_wol_cfg_get(phydev);
+
+	/* Supported by default */
+	wol->ethtool = false;
+
+	return 0;
+}
+
+static int jl1xxx_intr_operation_args(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+	struct jl_intr_ctrl *intr = &priv->intr;
+
+	if (JLSEMI_KERNEL_DEVICE_TREE_USE)
+		jl1xxx_dts_intr_cfg_get(phydev);
+	else
+		jl1xxx_c_macro_intr_cfg_get(phydev);
+
+	/* Not supported by default */
+	intr->ethtool = false;
+
+	return 0;
+}
+
+static int jl1xxx_mdi_operation_args(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+	struct jl_mdi_ctrl *mdi = &priv->mdi;
+
+	if (JLSEMI_KERNEL_DEVICE_TREE_USE)
+		jl1xxx_dts_mdi_cfg_get(phydev);
+	else
+		jl1xxx_c_macro_mdi_cfg_get(phydev);
+
+	/* Not supported by default */
+	mdi->ethtool = false;
+
+	return 0;
+}
+
+static int jl1xxx_rmii_operation_args(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+	struct jl_rmii_ctrl *rmii = &priv->rmii;
+
+	if (JLSEMI_KERNEL_DEVICE_TREE_USE)
+		jl1xxx_dts_rmii_cfg_get(phydev);
+	else
+		jl1xxx_c_macro_rmii_cfg_get(phydev);
+
+	/* Not supported by default */
+	rmii->ethtool = false;
+
+	return 0;
+}
+
+static int jl1xxx_led_operation_args(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+	struct jl_led_ctrl *led = &priv->led;
+
+	if (JLSEMI_KERNEL_DEVICE_TREE_USE)
+		jl1xxx_dts_led_cfg_get(phydev);
+	else
+		jl1xxx_c_macro_led_cfg_get(phydev);
+
+	/* Not supported by default */
+	led->ethtool = false;
+
+	return 0;
+}
+
+static int jl2xxx_led_operation_args(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct jl_led_ctrl *led = &priv->led;
+
+	if (JLSEMI_KERNEL_DEVICE_TREE_USE)
+		jl2xxx_dts_led_cfg_get(phydev);
+	else
+		jl2xxx_c_macro_led_cfg_get(phydev);
+
+	/* Not supported by default */
+	led->ethtool = false;
+
+	return 0;
+}
+
+
+static int jl2xxx_dts_fld_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct device_node *of_node = get_device_node(phydev);
+
+	of_property_read_u32(of_node, "jl2xxx,fld-enable",
+			     &priv->fld.enable);
+	of_property_read_u32(of_node, "jl2xxx,fld-delay",
+			     &priv->fld.delay);
+
+	return 0;
+}
+
+static int jl2xxx_dts_wol_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct device_node *of_node = get_device_node(phydev);
+
+	of_property_read_u32(of_node, "jl2xxx,wol-enable",
+			     &priv->wol.enable);
+
+	return 0;
+}
+
+static int jl2xxx_dts_intr_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct device_node *of_node = get_device_node(phydev);
+
+	of_property_read_u32(of_node, "jl2xxx,interrupt-enable",
+			     &priv->intr.enable);
+
+	return 0;
+}
+
+static int jl2xxx_dts_downshift_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct device_node *of_node = get_device_node(phydev);
+
+	of_property_read_u32(of_node, "jl2xxx,downshift-enable",
+			     &priv->downshift.enable);
+	of_property_read_u32(of_node, "jl2xxx,downshift-count",
+			     &priv->downshift.count);
+
+	return 0;
+}
+
+static int jl2xxx_dts_rgmii_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct device_node *of_node = get_device_node(phydev);
+
+	of_property_read_u32(of_node, "jl2xxx,rgmii-enable",
+			     &priv->rgmii.enable);
+	of_property_read_u32(of_node, "jl2xxx,rgmii-tx-delay",
+			     &priv->rgmii.tx_delay);
+	of_property_read_u32(of_node, "jl2xxx,rgmii-rx-delay",
+			     &priv->rgmii.rx_delay);
+
+	return 0;
+}
+
+static int jl2xxx_dts_patch_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct device_node *of_node = get_device_node(phydev);
+
+	of_property_read_u32(of_node, "jl2xxx,patch-enable",
+			     &priv->patch.enable);
+
+	return 0;
+}
+
+static int jl2xxx_dts_clk_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct device_node *of_node = get_device_node(phydev);
+
+	of_property_read_u32(of_node, "jl2xxx,clk-enable",
+			     &priv->clk.enable);
+
+	return 0;
+}
+
+static int jl2xxx_dts_work_mode_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct device_node *of_node = get_device_node(phydev);
+
+	of_property_read_u32(of_node, "jl2xxx,work_mode-enable",
+			     &priv->work_mode.enable);
+	of_property_read_u32(of_node, "jl2xxx,work_mode-mode",
+			     &priv->work_mode.mode);
+
+	return 0;
+}
+
+static int jl2xxx_dts_lpbk_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct device_node *of_node = get_device_node(phydev);
+
+	of_property_read_u32(of_node, "jl2xxx,lpbk-enable",
+			     &priv->lpbk.enable);
+	of_property_read_u32(of_node, "jl2xxx,lpbk-mode",
+			     &priv->lpbk.mode);
+
+	return 0;
+}
+
+static int jl2xxx_dts_slew_rate_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct device_node *of_node = get_device_node(phydev);
+
+	of_property_read_u32(of_node, "jl2xxx,slew_rate-enable",
+			     &priv->slew_rate.enable);
+
+	return 0;
+}
+
+static int jl2xxx_dts_rxc_out_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct device_node *of_node = get_device_node(phydev);
+
+	of_property_read_u32(of_node, "jl2xxx,rxc_out-enable",
+			     &priv->rxc_out.enable);
+
+	return 0;
+}
+
+static int jl2xxx_c_macro_fld_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+
+	struct jl_fld_ctrl fld_cfg = {
+		.enable		= JL2XXX_FLD_CTRL_EN,
+		.delay		= JL2XXX_FLD_DELAY,
+	};
+
+	priv->fld = fld_cfg;
+
+	return 0;
+}
+
+static int jl2xxx_c_macro_wol_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+
+	struct jl_wol_ctrl wol_cfg = {
+		.enable		= JL2XXX_WOL_CTRL_EN,
+	};
+
+	priv->wol = wol_cfg;
+
+	return 0;
+}
+
+static int jl2xxx_c_macro_intr_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+
+	struct jl_intr_ctrl intr_cfg = {
+		.enable		= JL2XXX_INTR_CTRL_EN,
+	};
+
+	priv->intr = intr_cfg;
+
+	return 0;
+}
+
+static int jl2xxx_c_macro_downshift_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+
+	struct jl_downshift_ctrl downshift_cfg = {
+		.enable		= JL2XXX_DSFT_CTRL_EN,
+		.count		= JL2XXX_DSFT_AN_CNT,
+	};
+
+	priv->downshift = downshift_cfg;
+
+	return 0;
+}
+
+static int jl2xxx_c_macro_rgmii_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+
+	struct jl_rgmii_ctrl rgmii_cfg = {
+		.enable		= JL2XXX_RGMII_CTRL_EN,
+		.rx_delay	= JL2XXX_RGMII_RX_DLY_2NS,
+		.tx_delay	= JL2XXX_RGMII_TX_DLY_2NS,
+	};
+
+	priv->rgmii = rgmii_cfg;
+
+	return 0;
+}
+
+static int jl2xxx_c_macro_patch_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+
+	struct jl_patch_ctrl patch_cfg = {
+		.enable		= JL2XXX_PATCH_CTRL_EN,
+	};
+
+	priv->patch = patch_cfg;
+
+	return 0;
+}
+
+static int jl2xxx_c_macro_clk_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+
+	struct jl_clk_ctrl clk_cfg = {
+		.enable		= JL2XXX_CLK_CTRL_EN,
+	};
+
+	priv->clk = clk_cfg;
+
+	return 0;
+}
+
+static int jl2xxx_c_macro_work_mode_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+
+	struct jl_work_mode_ctrl work_mode_cfg = {
+		.enable		= JL2XXX_WORK_MODE_CTRL_EN,
+		.mode		= JL2XXX_WORK_MODE_MODE,
+	};
+
+	priv->work_mode = work_mode_cfg;
+
+	return 0;
+}
+
+static int jl2xxx_c_macro_lpbk_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+
+	struct jl_loopback_ctrl lpbk_cfg = {
+		.enable		= JL2XXX_LPBK_CTRL_EN,
+		.mode		= JL2XXX_LPBK_MODE,
+	};
+
+	priv->lpbk = lpbk_cfg;
+
+	return 0;
+}
+
+static int jl2xxx_c_macro_slew_rate_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+
+	struct jl_slew_rate_ctrl slew_rate_cfg = {
+		.enable		= JL2XXX_SLEW_RATE_CTRL_EN,
+	};
+
+	priv->slew_rate = slew_rate_cfg;
+
+	return 0;
+}
+
+static int jl2xxx_c_macro_rxc_out_cfg_get(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+
+	struct jl_rxc_out_ctrl rxc_out_cfg = {
+		.enable		= JL2XXX_RXC_OUT_CTRL_EN,
+	};
+
+	priv->rxc_out = rxc_out_cfg;
+
+	return 0;
+}
+
+static int jl2xxx_fld_operation_args(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct jl_fld_ctrl *fld = &priv->fld;
+
+	if (JLSEMI_KERNEL_DEVICE_TREE_USE)
+		jl2xxx_dts_fld_cfg_get(phydev);
+	else
+		jl2xxx_c_macro_fld_cfg_get(phydev);
+
+	/* Supported by default */
+	fld->ethtool = false;
+
+	return 0;
+}
+
+static int jl2xxx_wol_operation_args(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct jl_wol_ctrl *wol = &priv->wol;
+
+	if (JLSEMI_KERNEL_DEVICE_TREE_USE)
+		jl2xxx_dts_wol_cfg_get(phydev);
+	else
+		jl2xxx_c_macro_wol_cfg_get(phydev);
+
+	/* Supported by default */
+	wol->ethtool = false;
+
+	return 0;
+}
+
+static int jl2xxx_intr_operation_args(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct jl_intr_ctrl *intr = &priv->intr;
+
+	if (JLSEMI_KERNEL_DEVICE_TREE_USE)
+		jl2xxx_dts_intr_cfg_get(phydev);
+	else
+		jl2xxx_c_macro_intr_cfg_get(phydev);
+
+	/* Not supported by default */
+	intr->ethtool = false;
+
+	return 0;
+}
+
+static int jl2xxx_downshift_operation_args(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct jl_downshift_ctrl *downshift = &priv->downshift;
+
+	if (JLSEMI_KERNEL_DEVICE_TREE_USE)
+		jl2xxx_dts_downshift_cfg_get(phydev);
+	else
+		jl2xxx_c_macro_downshift_cfg_get(phydev);
+
+	/* Supported by default */
+	downshift->ethtool = false;
+
+	return 0;
+}
+
+static int jl2xxx_rgmii_operation_args(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct jl_rgmii_ctrl *rgmii = &priv->rgmii;
+
+	if (JLSEMI_KERNEL_DEVICE_TREE_USE)
+		jl2xxx_dts_rgmii_cfg_get(phydev);
+	else
+		jl2xxx_c_macro_rgmii_cfg_get(phydev);
+
+	/* Not supported by default */
+	rgmii->ethtool = false;
+
+	return 0;
+}
+
+static int jl2xxx_patch_operation_args(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct jl_patch_ctrl *patch = &priv->patch;
+
+	if (JLSEMI_KERNEL_DEVICE_TREE_USE)
+		jl2xxx_dts_patch_cfg_get(phydev);
+	else
+		jl2xxx_c_macro_patch_cfg_get(phydev);
+
+	/* Not supported by default */
+	patch->ethtool = false;
+
+	return 0;
+}
+
+static int jl2xxx_clk_operation_args(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct jl_clk_ctrl *clk = &priv->clk;
+
+	if (JLSEMI_KERNEL_DEVICE_TREE_USE)
+		jl2xxx_dts_clk_cfg_get(phydev);
+	else
+		jl2xxx_c_macro_clk_cfg_get(phydev);
+
+	/* Not supported by default */
+	clk->ethtool = false;
+
+	return 0;
+}
+
+static int jl2xxx_work_mode_operation_args(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct jl_work_mode_ctrl *work_mode = &priv->work_mode;
+
+	if (JLSEMI_KERNEL_DEVICE_TREE_USE)
+		jl2xxx_dts_work_mode_cfg_get(phydev);
+	else
+		jl2xxx_c_macro_work_mode_cfg_get(phydev);
+
+	/* Not supported by default */
+	work_mode->ethtool = false;
+
+	return 0;
+}
+
+static int jl2xxx_lpbk_operation_args(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct jl_loopback_ctrl *lpbk = &priv->lpbk;
+
+	if (JLSEMI_KERNEL_DEVICE_TREE_USE)
+		jl2xxx_dts_lpbk_cfg_get(phydev);
+	else
+		jl2xxx_c_macro_lpbk_cfg_get(phydev);
+
+	/* Not supported by default */
+	lpbk->ethtool = false;
+
+	return 0;
+}
+
+static int jl2xxx_slew_rate_operation_args(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct jl_slew_rate_ctrl *slew_rate = &priv->slew_rate;
+
+	if (JLSEMI_KERNEL_DEVICE_TREE_USE)
+		jl2xxx_dts_slew_rate_cfg_get(phydev);
+	else
+		jl2xxx_c_macro_slew_rate_cfg_get(phydev);
+
+	/* Not supported by default */
+	slew_rate->ethtool = false;
+
+	return 0;
+}
+
+static int jl2xxx_rxc_out_operation_args(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	struct jl_rxc_out_ctrl *rxc_out = &priv->rxc_out;
+
+	if (JLSEMI_KERNEL_DEVICE_TREE_USE)
+		jl2xxx_dts_rxc_out_cfg_get(phydev);
+	else
+		jl2xxx_c_macro_rxc_out_cfg_get(phydev);
+
+	/* Not supported by default */
+	rxc_out->ethtool = false;
+
+	return 0;
+}
+
+static int jl2xxx_fld_static_op_set(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	int err;
+	u8 val;
+
+	val = priv->fld.delay & 0xff;
+	err = jl2xxx_fld_dynamic_op_set(phydev, &val);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+static int jl1xxx_wol_cfg_rmii(struct phy_device *phydev)
+{
+	int err;
+	/* WOL Function should be in RMII Mode, the rmii
+	 * clock direction should be output
+	 */
+	err = jlsemi_modify_paged_reg(phydev, JL1XXX_PAGE7,
+				      JL1XXX_RMII_CTRL_REG,
+				      JL1XXX_RMII_OUT,
+				      JL1XXX_RMII_MODE);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+static int jl1xxx_wol_clear(struct phy_device *phydev)
+{
+	jlsemi_set_bits(phydev, JL1XXX_PAGE129,
+			JL1XXX_WOL_CTRL_REG, JL1XXX_WOL_CLEAR);
+
+	jlsemi_clear_bits(phydev, JL1XXX_PAGE129,
+			  JL1XXX_WOL_CTRL_REG, JL1XXX_WOL_CLEAR);
+
+	return 0;
+}
+
+static bool jl1xxx_wol_receive_check(struct phy_device *phydev)
+{
+	if (jlsemi_fetch_bit(phydev, JL1XXX_PAGE129,
+			     JL1XXX_WOL_CTRL_REG, JL1xxx_WOL_RECEIVE))
+		return true;
+	else
+		return false;
+
+}
+
+static int jl1xxx_wol_enable(struct phy_device *phydev, bool enable)
+{
+	if (enable)
+		jlsemi_clear_bits(phydev, JL1XXX_PAGE129,
+				  JL1XXX_WOL_CTRL_REG, JL1XXX_WOL_DIS);
+	else
+		jlsemi_set_bits(phydev, JL1XXX_PAGE129,
+				JL1XXX_WOL_CTRL_REG, JL1XXX_WOL_DIS);
+
+	return 0;
+}
+static int jl1xxx_wol_store_mac_addr(struct phy_device *phydev)
+{
+	int err;
+
+	jlsemi_write_page(phydev, JL1XXX_PAGE129);
+
+	/* Store the device address for the magic packet */
+	err = phy_write(phydev, JL1XXX_MAC_ADDR2_REG,
+			((ADDR8_HIGH_TO_LOW(
+			  phydev->attached_dev->dev_addr[0]) << 8) |
+			  ADDR8_HIGH_TO_LOW(
+			  phydev->attached_dev->dev_addr[1])));
+	if (err < 0)
+		return err;
+	err = phy_write(phydev, JL1XXX_MAC_ADDR1_REG,
+			((ADDR8_HIGH_TO_LOW(
+			  phydev->attached_dev->dev_addr[2]) << 8) |
+			  ADDR8_HIGH_TO_LOW(
+			  phydev->attached_dev->dev_addr[3])));
+	if (err < 0)
+		return err;
+	err = phy_write(phydev, JL1XXX_MAC_ADDR0_REG,
+			((ADDR8_HIGH_TO_LOW(
+			  phydev->attached_dev->dev_addr[4]) << 8) |
+			  ADDR8_HIGH_TO_LOW(
+			  phydev->attached_dev->dev_addr[5])));
+	if (err < 0)
+		return err;
+
+	/* change page to 0 */
+	jlsemi_write_page(phydev, JL1XXX_PAGE0);
+
+	return 0;
+}
+
+static int jl2xxx_wol_enable(struct phy_device *phydev, bool enable)
+{
+	if (enable) {
+		jlsemi_set_bits(phydev, JL2XXX_WOL_CTRL_PAGE,
+				JL2XXX_WOL_CTRL_REG, JL2XXX_WOL_GLB_EN);
+		jlsemi_clear_bits(phydev, JL2XXX_WOL_STAS_PAGE,
+				  JL2XXX_WOL_STAS_REG, JL2XXX_WOL_EN);
+	} else {
+		jlsemi_clear_bits(phydev, JL2XXX_WOL_CTRL_PAGE,
+				  JL2XXX_WOL_CTRL_REG, JL2XXX_WOL_GLB_EN);
+		jlsemi_set_bits(phydev, JL2XXX_WOL_STAS_PAGE,
+				JL2XXX_WOL_STAS_REG, JL2XXX_WOL_EN);
+	}
+	jlsemi_soft_reset(phydev);
+
+	return 0;
+}
+
+static int jl2xxx_wol_active_low_polarity(struct phy_device *phydev, bool low)
+{
+	if (low)
+		jlsemi_set_bits(phydev, JL2XXX_WOL_STAS_PAGE,
+				JL2XXX_WOL_STAS_REG, JL2XXX_WOL_POLARITY);
+	else
+		jlsemi_clear_bits(phydev, JL2XXX_WOL_STAS_PAGE,
+				  JL2XXX_WOL_STAS_REG, JL2XXX_WOL_POLARITY);
+
+	return 0;
+}
+
+static int jl2xxx_wol_clear(struct phy_device *phydev)
+{
+	jlsemi_set_bits(phydev, JL2XXX_WOL_STAS_PAGE,
+			JL2XXX_WOL_STAS_REG, JL2XXX_WOL_EVENT);
+	jlsemi_clear_bits(phydev, JL2XXX_WOL_STAS_PAGE,
+			  JL2XXX_WOL_STAS_REG, JL2XXX_WOL_EVENT);
+
+	return 0;
+}
+
+static int jl2xxx_store_mac_addr(struct phy_device *phydev)
+{
+	int err;
+
+	jlsemi_write_page(phydev, JL2XXX_WOL_STAS_PAGE);
+
+	/* Store the device address for the magic packet */
+	err = phy_write(phydev, JL2XXX_MAC_ADDR2_REG,
+			((phydev->attached_dev->dev_addr[0] << 8) |
+			  phydev->attached_dev->dev_addr[1]));
+	if (err < 0)
+		return err;
+	err = phy_write(phydev, JL2XXX_MAC_ADDR1_REG,
+			((phydev->attached_dev->dev_addr[2] << 8) |
+			  phydev->attached_dev->dev_addr[3]));
+	if (err < 0)
+		return err;
+	err = phy_write(phydev, JL2XXX_MAC_ADDR0_REG,
+			((phydev->attached_dev->dev_addr[4] << 8) |
+			  phydev->attached_dev->dev_addr[5]));
+	if (err < 0)
+		return err;
+
+	/* change page to 0 */
+	jlsemi_write_page(phydev, JL2XXX_PAGE0);
+
+	return 0;
+}
+
+/* Get fast link down for jl2xxx */
+#if (JL2XXX_PHY_TUNABLE)
+int jl2xxx_fld_dynamic_op_get(struct phy_device *phydev, u8 *msecs)
+{
+	int ret;
+	u16 val;
+
+	ret = jlsemi_read_paged(phydev, JL2XXX_PAGE128,
+				JL2XXX_FLD_CTRL_REG);
+
+	if (ret < 0)
+		return ret;
+
+	if (ret & JL2XXX_FLD_EN) {
+		*msecs = ETHTOOL_PHY_FAST_LINK_DOWN_OFF;
+		return 0;
+	}
+
+	val = (ret & JL2XXX_FLD_MASK) >> JL2XXX_FLD_MASK_HEAD;
+
+	switch (val) {
+	case JL2XXX_FLD_DELAY_00MS:
+		*msecs = 0;
+		break;
+	case JL2XXX_FLD_DELAY_10MS:
+		*msecs = 10;
+		break;
+	case JL2XXX_FLD_DELAY_20MS:
+		*msecs = 20;
+		break;
+	case JL2XXX_FLD_DELAY_40MS:
+		*msecs = 40;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+#endif
+/* Set fast link down for jl2xxx */
+int jl2xxx_fld_dynamic_op_set(struct phy_device *phydev, const u8 *msecs)
+{
+	u16 val;
+	int ret;
+
+#if (JL2XXX_PHY_TUNABLE)
+	if (*msecs == ETHTOOL_PHY_FAST_LINK_DOWN_OFF)
+		return jlsemi_clear_bits(phydev, JL2XXX_PAGE128,
+					 JL2XXX_FLD_CTRL_REG,
+					 JL2XXX_FLD_EN);
+#endif
+	if (*msecs <= 5)
+		val = JL2XXX_FLD_DELAY_00MS;
+	else if (*msecs <= 15)
+		val = JL2XXX_FLD_DELAY_10MS;
+	else if (*msecs <= 30)
+		val = JL2XXX_FLD_DELAY_20MS;
+	else
+		val = JL2XXX_FLD_DELAY_40MS;
+
+	val = val << JL2XXX_FLD_MASK_HEAD;
+
+	ret = jlsemi_modify_paged_reg(phydev, JL2XXX_PAGE128,
+				      JL2XXX_FLD_CTRL_REG,
+				      JL2XXX_FLD_MASK, val);
+	if (ret < 0)
+		return ret;
+
+	ret = jlsemi_set_bits(phydev, JL2XXX_PAGE128,
+			      JL2XXX_FLD_CTRL_REG,
+			      JL2XXX_FLD_EN);
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
+
+int jl2xxx_downshift_dynamic_op_get(struct phy_device *phydev, u8 *data)
+{
+	int val, cnt, enable;
+
+	val = jlsemi_read_paged(phydev, JL2XXX_PAGE0,
+				JL2XXX_DSFT_CTRL_REG);
+
+	if (val < 0)
+		return val;
+
+	enable = val & JL2XXX_DSFT_EN;
+	cnt = (val & JL2XXX_DSFT_AN_MASK) + 1;
+
+#if (JL2XXX_PHY_TUNABLE)
+	*data = enable ? cnt : DOWNSHIFT_DEV_DISABLE;
+#else
+	*data = enable ? cnt : 0;
+#endif
+	return 0;
+}
+
+int jl2xxx_downshift_dynamic_op_set(struct phy_device *phydev, u8 cnt)
+{
+	int val, err;
+
+	if (cnt > JL2XXX_DSFT_CNT_MAX)
+		return -E2BIG;
+
+	if (!cnt) {
+		err = jlsemi_clear_bits(phydev, JL2XXX_PAGE0,
+					JL2XXX_DSFT_CTRL_REG,
+					JL2XXX_DSFT_EN);
+	} else {
+		val = ((cnt - 1) & JL2XXX_DSFT_AN_MASK) | JL2XXX_DSFT_EN |
+			JL2XXX_DSFT_SMART_EN | JL2XXX_DSFT_AN_ERR_EN |
+			JL2XXX_DSFT_STL_CNT(18);
+		err = jlsemi_modify_paged_reg(phydev, JL2XXX_PAGE0,
+					      JL2XXX_DSFT_CTRL_REG,
+					      JL2XXX_DSFT_AN_MASK, val);
+	}
+
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+int jl2xxx_downshift_static_op_set(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	int err;
+
+	err = jl2xxx_downshift_dynamic_op_set(phydev,
+					      priv->downshift.count);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+int jl2xxx_rgmii_static_op_set(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	int err;
+
+	if (priv->rgmii.enable & JL2XXX_RGMII_TX_DLY_EN) {
+		err = jlsemi_set_bits(phydev, JL2XXX_PAGE3336,
+				      JL2XXX_RGMII_CTRL_REG,
+				      priv->rgmii.tx_delay);
+		if (err < 0)
+			return err;
+
+	} else {
+		err = jlsemi_clear_bits(phydev, JL2XXX_PAGE3336,
+					JL2XXX_RGMII_CTRL_REG,
+					priv->rgmii.tx_delay);
+		if (err < 0)
+			return err;
+	}
+
+	if (priv->rgmii.enable & JL2XXX_RGMII_RX_DLY_EN) {
+		err = jlsemi_set_bits(phydev, JL2XXX_PAGE3336,
+				      JL2XXX_RGMII_CTRL_REG,
+				      priv->rgmii.rx_delay);
+		if (err < 0)
+			return err;
+	} else {
+		err = jlsemi_clear_bits(phydev, JL2XXX_PAGE3336,
+				      JL2XXX_RGMII_CTRL_REG,
+				      priv->rgmii.rx_delay);
+		if (err < 0)
+			return err;
+	}
+
+	err = jlsemi_soft_reset(phydev);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+int jl2xxx_clk_static_op_set(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	int err;
+
+	if (priv->clk.enable & JL2XXX_125M_CLK_OUT_EN) {
+		err = jlsemi_modify_paged_reg(phydev, JL2XXX_PAGE2627,
+					      JL2XXX_CLK_CTRL_REG,
+					      JL2XXX_CLK_SSC_EN,
+					      JL2XXX_CLK_OUT_PIN |
+					      JL2XXX_CLK_125M_OUT |
+					      JL2XXXX_CLK_SRC);
+		if (err < 0)
+			return err;
+	} else if (priv->clk.enable & JL2XXX_25M_CLK_OUT_EN) {
+		err = jlsemi_modify_paged_reg(phydev, JL2XXX_PAGE2627,
+					      JL2XXX_CLK_CTRL_REG,
+					      JL2XXX_CLK_SSC_EN |
+					      JL2XXX_CLK_125M_OUT,
+					      JL2XXX_CLK_OUT_PIN |
+					      JL2XXXX_CLK_SRC);
+		if (err < 0)
+			return err;
+	} else if (priv->clk.enable & JL2XXX_CLK_OUT_DIS) {
+		err = jlsemi_clear_bits(phydev, JL2XXX_PAGE2627,
+					JL2XXX_CLK_CTRL_REG,
+					JL2XXX_CLK_OUT_PIN);
+		if (err < 0)
+			return err;
+	}
+
+	err = jlsemi_soft_reset(phydev);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+int jl2xxx_slew_rate_static_op_set(struct phy_device *phydev)
+{
+	int err;
+
+	err = jlsemi_set_bits(phydev, JL2XXX_PAGE258,
+			      JL2XXX_SLEW_RATE_CTRL_REG,
+			      JL2XXX_SLEW_RATE_EN | JL2XXX_SLEW_RATE_REF_CLK |
+			      JL2XXX_SLEW_RATE_SEL_CLK);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+int jl2xxx_rxc_out_static_op_set(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	int mode;
+	int err;
+
+	/* fake power down */
+	err = jlsemi_set_bits(phydev, JL2XXX_PAGE18,
+			      JL2XXX_RXC_OUT_REG, JL2XXX_RXC_OUT);
+	if (err < 0)
+		return err;
+
+	mode = jlsemi_read_paged(phydev, JL2XXX_PAGE18, JL2XXX_WORK_MODE_REG);
+	/* Description: Some SOC Ethernet initialization requires PHY to
+	 * provide rx clock for MAC to pass initialization, otherwise DMA
+	 * initialization errors will be reported. However, when PHY is
+	 * set (MAC) sgmii<-->rgmii (PHY) mode, rx clock does not have a
+	 * clock.
+	 * Workaround: Configure PHY to utp<-->rgmii mode before Ethernet
+	 * initialization, and then configure it to sgmii<-->rgmii mode
+	 * after initialization is completed. The adverse effect is that
+	 * it will cause the link up time to become longer
+	 */
+	if (((priv->work_mode.enable & JL2XXX_WORK_MODE_STATIC_OP_EN) &&
+	   (priv->work_mode.mode == JL2XXX_MAC_SGMII_RGMII_MODE)) ||
+	   ((mode & JL2XXX_WORK_MODE_MASK) == JL2XXX_MAC_SGMII_RGMII_MODE)) {
+		err = jlsemi_modify_paged_reg(phydev, JL2XXX_PAGE18,
+					      JL2XXX_WORK_MODE_REG,
+					      JL2XXX_WORK_MODE_MASK,
+					      JL2XXX_UTP_RGMII_MODE);
+		if (err < 0)
+			return err;
+		/* Record the previous value */
+		priv->work_mode.mode = JL2XXX_MAC_SGMII_RGMII_MODE;
+		priv->rxc_out.inited = false;
+	}
+
+	err = jlsemi_soft_reset(phydev);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+int jl2xxx_work_mode_static_op_set(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	int err;
+
+	jlsemi_modify_paged_reg(phydev, JL2XXX_PAGE18,
+				JL2XXX_WORK_MODE_REG,
+				JL2XXX_WORK_MODE_MASK,
+				priv->work_mode.mode);
+
+	err = jlsemi_soft_reset(phydev);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+static inline int __genphy_setup_forced(struct phy_device *phydev)
+{
+	int err;
+	int ctl = 0;
+
+	phydev->pause = phydev->asym_pause = 0;
+
+	if (phydev->speed == SPEED_1000)
+		ctl |= BMCR_SPEED1000;
+	else if (phydev->speed == SPEED_100)
+		ctl |= BMCR_SPEED100;
+
+	if (phydev->duplex == DUPLEX_FULL)
+		ctl |= BMCR_FULLDPLX;
+
+	err = phy_write(phydev, MII_BMCR, ctl);
+
+	return err;
+}
+
+int jl2xxx_config_aneg_fiber(struct phy_device *phydev)
+{
+	if (phydev->autoneg != AUTONEG_ENABLE)
+		return __genphy_setup_forced(phydev);
+
+	/* Dou to fiber auto mode only support 1000M,
+	 * we set 1000M speed to reg0
+	 * NOTE: Do need restart AN otherwise will link down
+	 */
+	jlsemi_modify_paged_reg(phydev, JL2XXX_PAGE0,
+				JL2XXX_BMCR_REG,
+				JL2XXX_BMCR_SPEED_LSB,
+				JL2XXX_BMCR_SPEED_MSB | BMCR_ANENABLE);
+	return 0;
+}
+
+static int jl2xxx_fiber_autoneg_config(struct phy_device *phydev)
+{
+	int speed;
+	int duplex;
+
+	speed = jlsemi_read_paged(phydev, JL2XXX_PAGE0, JL2XXX_PHY_MODE_REG);
+	if (speed < 0)
+		return speed;
+
+	duplex = jlsemi_fetch_bit(phydev, JL2XXX_PAGE0,
+				  MII_BMCR, JL2XXX_BMCR_DUPLEX);
+	if (duplex < 0)
+		return duplex;
+
+	if (duplex)
+		phydev->duplex = DUPLEX_FULL;
+	else
+		phydev->duplex = DUPLEX_HALF;
+
+	speed &= JL2XXX_PHY_FIBER_MODE_MASK;
+	switch (speed) {
+	case JL2XXX_FIBER_1000:
+		phydev->speed = SPEED_1000;
+		break;
+	case JL2XXX_FIBER_100:
+		phydev->speed = SPEED_100;
+		break;
+	default:
+		break;
+	}
+
+	return 0;
+}
+
+static int jl2xxx_update_fiber_status(struct phy_device *phydev)
+{
+	int status;
+	int link;
+
+	status = jlsemi_read_paged(phydev, JL2XXX_PAGE0, JL2XXX_PHY_MODE_REG);
+	if (status < 0)
+		return status;
+
+	link = status & JL2XXX_PHY_FIBER_MODE_MASK;
+
+	if (link)
+		phydev->link = 1;
+	else
+		phydev->link = 0;
+
+	if (phydev->autoneg == AUTONEG_ENABLE)
+		jl2xxx_fiber_autoneg_config(phydev);
+
+	return 0;
+}
+
+bool jl2xxx_read_fiber_status(struct phy_device *phydev)
+{
+	bool fiber_ok = false;
+	u16 phy_mode;
+	int val;
+
+	val = jlsemi_read_paged(phydev, JL2XXX_PAGE18, JL2XXX_WORK_MODE_REG);
+	phy_mode = val & JL2XXX_WORK_MODE_MASK;
+
+	if ((phydev->interface != PHY_INTERFACE_MODE_SGMII) &&
+	   ((phy_mode == JL2XXX_FIBER_RGMII_MODE) ||
+	    (phy_mode == JL2XXX_UTP_FIBER_RGMII_MODE))) {
+		jl2xxx_update_fiber_status(phydev);
+		if (phydev->link)
+			fiber_ok = true;
+	}
+
+	return fiber_ok;
+}
+
+static int jl2xxx_force_speed(struct phy_device *phydev, u16 speed)
+{
+	int err;
+
+	if (speed == JL2XXX_SPEED1000)
+		jlsemi_modify_paged_reg(phydev, JL2XXX_PAGE0, MII_BMCR,
+					BMCR_SPEED100, BMCR_SPEED1000);
+	else if (speed == JL2XXX_SPEED100)
+		jlsemi_modify_paged_reg(phydev, JL2XXX_PAGE0, MII_BMCR,
+					BMCR_SPEED1000, BMCR_SPEED100);
+	else if (speed == JL2XXX_SPEED10)
+		jlsemi_clear_bits(phydev, JL2XXX_PAGE0, MII_BMCR,
+				  BMCR_SPEED1000 | BMCR_SPEED100);
+
+	err = jlsemi_clear_bits(phydev, JL2XXX_PAGE0, MII_BMCR,
+				BMCR_ANENABLE);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+static int jl2xxx_lpbk_force_speed(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+
+	if (priv->lpbk.mode == JL2XXX_LPBK_PCS_1000M)
+		jl2xxx_force_speed(phydev, JL2XXX_SPEED1000);
+	else if (priv->lpbk.mode == JL2XXX_LPBK_PCS_100M)
+		jl2xxx_force_speed(phydev, JL2XXX_SPEED100);
+	else if (priv->lpbk.mode == JL2XXX_LPBK_PCS_10M)
+		jl2xxx_force_speed(phydev, JL2XXX_SPEED10);
+
+	return 0;
+}
+
+int jl2xxx_lpbk_static_op_set(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	int err;
+
+	if ((priv->lpbk.mode == JL2XXX_LPBK_PCS_10M) ||
+	    (priv->lpbk.mode == JL2XXX_LPBK_PCS_100M) ||
+	    (priv->lpbk.mode == JL2XXX_LPBK_PCS_1000M)) {
+		err = jlsemi_modify_paged_reg(phydev, JL2XXX_PAGE0,
+					      MII_BMCR, BMCR_LOOPBACK,
+					      BMCR_LOOPBACK);
+		if (err < 0)
+			return err;
+		err = jl2xxx_lpbk_force_speed(phydev);
+		if (err < 0)
+			return err;
+	} else if (priv->lpbk.mode == JL2XXX_LPBK_PMD_1000M) {
+		err = jlsemi_clear_bits(phydev, JL2XXX_PAGE160,
+					JL2XXX_REG25, JL2XXX_CPU_RESET);
+		if (err < 0)
+			return err;
+
+		jlsemi_write_page(phydev, JL2XXX_PAGE173);
+		phy_write(phydev, JL2XXX_REG16, JL2XXX_LOAD_GO);
+		phy_write(phydev, JL2XXX_REG17, JL2XXX_LOAD_DATA0);
+		jlsemi_write_page(phydev, JL2XXX_PAGE0);
+
+		err = jlsemi_set_bits(phydev, JL2XXX_PAGE160,
+				      JL2XXX_REG25, JL2XXX_CPU_RESET);
+		if (err < 0)
+			return err;
+
+		err = jlsemi_modify_paged_reg(phydev, JL2XXX_PAGE0,
+					      JL2XXX_REG20,
+					      JL2XXX_LPBK_MODE_MASK,
+					      JL2XXX_LPBK_PMD_MODE);
+		if (err < 0)
+			return err;
+
+		err = jlsemi_set_bits(phydev, JL2XXX_PAGE18, JL2XXX_REG21,
+				      JL2XXX_SPEED1000_NO_AN);
+		if (err < 0)
+			return err;
+
+		err = jlsemi_soft_reset(phydev);
+		if (err < 0)
+			return err;
+
+	} else if (priv->lpbk.mode == JL2XXX_LPBK_EXT_STUB_1000M) {
+		err = jlsemi_clear_bits(phydev, JL2XXX_PAGE160,
+					JL2XXX_REG25, JL2XXX_CPU_RESET);
+		if (err < 0)
+			return err;
+		jlsemi_write_page(phydev, JL2XXX_PAGE173);
+		phy_write(phydev, JL2XXX_REG16, JL2XXX_LOAD_GO);
+		phy_write(phydev, JL2XXX_REG17, JL2XXX_LOAD_DATA0);
+		jlsemi_write_page(phydev, JL2XXX_PAGE0);
+
+		err = jlsemi_set_bits(phydev, JL2XXX_PAGE160,
+				      JL2XXX_REG25, JL2XXX_CPU_RESET);
+		if (err < 0)
+			return err;
+
+		err = jlsemi_modify_paged_reg(phydev, JL2XXX_PAGE0,
+					      JL2XXX_REG20,
+					      JL2XXX_LPBK_MODE_MASK,
+					      JL2XXX_LPBK_EXT_MODE);
+		if (err < 0)
+			return err;
+
+		err = jlsemi_set_bits(phydev, JL2XXX_PAGE18, JL2XXX_REG21,
+				      JL2XXX_SPEED1000_NO_AN);
+		if (err < 0)
+			return err;
+
+		err = jlsemi_soft_reset(phydev);
+		if (err < 0)
+			return err;
+	}
+
+	return 0;
+}
+
+int jl1xxx_mdi_static_op_set(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+	int err;
+
+	if (priv->mdi.enable & JL1XXX_MDI_RATE_EN) {
+		err = jlsemi_set_bits(phydev, JL1XXX_PAGE24,
+				      JL1XXX_REG24, priv->mdi.rate);
+		if (err < 0)
+			return err;
+	}
+
+	if (priv->mdi.enable & JL1XXX_MDI_AMPLITUDE_EN) {
+		err = jlsemi_modify_paged_reg(phydev, JL1XXX_PAGE24,
+					      JL1XXX_REG24,
+					      JL1XXX_MDI_TX_BM_MASK,
+					      JL1XXX_MDI_TX_BM(
+					      priv->mdi.amplitude));
+		if (err < 0)
+			return err;
+	}
+
+	return 0;
+}
+
+int jl1xxx_rmii_static_op_set(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+	int err;
+
+	if (priv->rmii.enable & JL1XXX_RMII_MODE_EN) {
+		err = jlsemi_set_bits(phydev, JL1XXX_PAGE7,
+				      JL1XXX_REG16, JL1XXX_RMII_MODE);
+		if (err < 0)
+			return err;
+	} else {
+		err = jlsemi_clear_bits(phydev, JL1XXX_PAGE7,
+					JL1XXX_REG16, JL1XXX_RMII_MODE);
+		if (err < 0)
+			return err;
+		return 0;
+	}
+
+	if (priv->rmii.enable & JL1XXX_RMII_CLK_50M_INPUT_EN) {
+		err = jlsemi_set_bits(phydev, JL1XXX_PAGE7,
+				      JL1XXX_REG16,
+				      JL1XXX_RMII_CLK_50M_INPUT);
+		if (err < 0)
+			return err;
+	} else {
+		err = jlsemi_clear_bits(phydev, JL1XXX_PAGE7,
+					JL1XXX_REG16,
+					JL1XXX_RMII_CLK_50M_INPUT);
+		if (err < 0)
+			return err;
+	}
+
+	if (priv->rmii.enable & JL1XXX_RMII_CRS_DV_EN) {
+		err = jlsemi_set_bits(phydev, JL1XXX_PAGE7,
+				      JL1XXX_REG16,
+				      JL1XXX_RMII_CRS_DV);
+		if (err < 0)
+			return err;
+	} else {
+		err = jlsemi_clear_bits(phydev, JL1XXX_PAGE7,
+					JL1XXX_REG16,
+					JL1XXX_RMII_CRS_DV);
+		if (err < 0)
+			return err;
+	}
+
+	if (priv->rmii.enable & JL1XXX_RMII_TX_SKEW_EN) {
+		err = jlsemi_modify_paged_reg(phydev, JL1XXX_PAGE7,
+					      JL1XXX_REG16,
+					      JL1XXX_RMII_TX_SKEW_MASK,
+					      JL1XXX_RMII_TX_SKEW(
+					      priv->rmii.tx_timing));
+		if (err < 0)
+			return err;
+	}
+
+	if (priv->rmii.enable & JL1XXX_RMII_RX_SKEW_EN) {
+		err = jlsemi_modify_paged_reg(phydev, JL1XXX_PAGE7,
+					      JL1XXX_REG16,
+					      JL1XXX_RMII_RX_SKEW_MASK,
+					      JL1XXX_RMII_RX_SKEW(
+					      priv->rmii.rx_timing));
+		if (err < 0)
+			return err;
+	}
+
+	return 0;
+}
+
+static const u16 patch_fw_versions0[] = {0x9101, 0x9107};
+static const u16 patch_fw_versions1[] = {0x1101};
+static const u16 patch_fw_versions2[] = {0x930a};
+static const u16 patch_fw_versions3[] = {0x2208};
+
+#define patch_version0 0xdef2
+static const u32 init_data0[] = {
+	0x1f00a0, 0x1903f3, 0x1f0012, 0x150100, 0x1f00ad, 0x100000,
+	0x11e0c6, 0x1f00a0, 0x1903fb, 0x1903fb, 0x1903fb, 0x1903fb,
+	0x1903fb, 0x1903fb, 0x1903fb, 0x1903fb, 0x1f00ad, 0x110000,
+	0x120400, 0x130093, 0x140000, 0x150193, 0x160000, 0x170213,
+	0x180000, 0x12040c, 0x130293, 0x140000, 0x150313, 0x160000,
+	0x170393, 0x180000, 0x120418, 0x130413, 0x140000, 0x150493,
+	0x160000, 0x170513, 0x180000, 0x120424, 0x130593, 0x140000,
+	0x150613, 0x160000, 0x170693, 0x180000, 0x120430, 0x130713,
+	0x140000, 0x150793, 0x160000, 0x171137, 0x180000, 0x12043c,
+	0x13006f, 0x140060, 0x15a001, 0x160113, 0x17fd41, 0x18d026,
+	0x120448, 0x13d406, 0x14d222, 0x1517b7, 0x160800, 0x17aa23,
+	0x189407, 0x120454, 0x130713, 0x1430f0, 0x1567b7, 0x160800,
+	0x17a423, 0x1846e7, 0x120460, 0x13a703, 0x14a587, 0x156685,
+	0x168f55, 0x17ac23, 0x18a4e7, 0x12046c, 0x1367b9, 0x145737,
+	0x150800, 0x168793, 0x17ef27, 0x182023, 0x120478, 0x1374f7,
+	0x1407b7, 0x150800, 0x165bfc, 0x17d493, 0x180037, 0x120484,
+	0x13f493, 0x141f04, 0x15f793, 0x1607f7, 0x178fc5, 0x18c03e,
+	0x120490, 0x134702, 0x140793, 0x150210, 0x160763, 0x1700f7,
+	0x180793, 0x12049c, 0x130270, 0x140c63, 0x1530f7, 0x16a001,
+	0x1707b7, 0x180002, 0x1204a8, 0x138793, 0x146967, 0x15c83e,
+	0x1617b7, 0x170002, 0x188793, 0x1204b4, 0x13e567, 0x14c43e,
+	0x1537b7, 0x160002, 0x178793, 0x186867, 0x1204c0, 0x13c23e,
+	0x1447b7, 0x150002, 0x168793, 0x17e9a7, 0x1866b7, 0x1204cc,
+	0x130800, 0x14ca3e, 0x15a783, 0x166d86, 0x1775c1, 0x188713,
+	0x1204d8, 0x130ff5, 0x148ff9, 0x156735, 0x160713, 0x178007,
+	0x188fd9, 0x1204e4, 0x13ac23, 0x146cf6, 0x15a783, 0x1665c6,
+	0x175737, 0x180800, 0x1204f0, 0x136611, 0x14f793, 0x15f0f7,
+	0x16e793, 0x170807, 0x18ae23, 0x1204fc, 0x1364f6, 0x142783,
+	0x155c47, 0x169bf5, 0x172223, 0x185cf7, 0x120508, 0x13a703,
+	0x14f5c6, 0x158f51, 0x16ae23, 0x17f4e6, 0x180737, 0x120514,
+	0x130809, 0x14433c, 0x158fd1, 0x16c33c, 0x170637, 0x180800,
+	0x120520, 0x134a74, 0x14679d, 0x158793, 0x160e07, 0x179ae1,
+	0x18e693, 0x12052c, 0x130036, 0x14ca74, 0x154678, 0x1676e1,
+	0x178693, 0x185006, 0x120538, 0x138ff9, 0x148fd5, 0x1507c2,
+	0x168f6d, 0x1783c1, 0x188fd9, 0x120544, 0x13c67c, 0x140713,
+	0x151000, 0x160793, 0x170000, 0x189c23, 0x120550, 0x1324e7,
+	0x140713, 0x151010, 0x169123, 0x1726e7, 0x18470d, 0x12055c,
+	0x13c63a, 0x144702, 0x158d23, 0x162407, 0x17a223, 0x182607,
+	0x120568, 0x130793, 0x140270, 0x150413, 0x160000, 0x171463,
+	0x1800f7, 0x120574, 0x134789, 0x14c63e, 0x154709, 0x16cc3a,
+	0x174702, 0x180793, 0x120580, 0x130270, 0x141463, 0x1500f7,
+	0x16478d, 0x17cc3e, 0x180513, 0x12058c, 0x130000, 0x144792,
+	0x154581, 0x164485, 0x179782, 0x184018, 0x120598, 0x131775,
+	0x14e563, 0x1502e4, 0x162703, 0x170a04, 0x181163, 0x1205a4,
+	0x130297, 0x144818, 0x150563, 0x160097, 0x1747a2, 0x18c804,
+	0x1205b0, 0x139782, 0x1466b7, 0x150800, 0x16a703, 0x174c46,
+	0x189b71, 0x1205bc, 0x136713, 0x140027, 0x15a223, 0x164ce6,
+	0x174783, 0x180fd4, 0x1205c8, 0x13c7b9, 0x142683, 0x151004,
+	0x164745, 0x179763, 0x1820e6, 0x1205d4, 0x133737, 0x140822,
+	0x152683, 0x163007, 0x177645, 0x18167d, 0x1205e0, 0x138ef1,
+	0x142023, 0x1530d7, 0x162683, 0x172807, 0x18e693, 0x1205ec,
+	0x131006, 0x142023, 0x1528d7, 0x162683, 0x173807, 0x18e693,
+	0x1205f8, 0x131006, 0x142023, 0x1538d7, 0x162683, 0x174007,
+	0x18e693, 0x120604, 0x131006, 0x142023, 0x1540d7, 0x162683,
+	0x174807, 0x18e693, 0x120610, 0x131006, 0x142023, 0x1548d7,
+	0x1656b7, 0x170800, 0x18a703, 0x12061c, 0x133486, 0x14830d,
+	0x158b05, 0x16cf01, 0x17a703, 0x185c46, 0x120628, 0x137671,
+	0x14167d, 0x158f71, 0x166611, 0x17a223, 0x185ce6, 0x120634,
+	0x138f51, 0x14a223, 0x155ce6, 0x162703, 0x171084, 0x1846b2,
+	0x120640, 0x131c63, 0x1402d7, 0x153737, 0x160822, 0x172683,
+	0x182807, 0x12064c, 0x13e693, 0x140016, 0x152023, 0x1628d7,
+	0x172683, 0x183807, 0x120658, 0x13e693, 0x140016, 0x152023,
+	0x1638d7, 0x172683, 0x184007, 0x120664, 0x13e693, 0x140016,
+	0x152023, 0x1640d7, 0x172683, 0x184807, 0x120670, 0x13e693,
+	0x140016, 0x152023, 0x1648d7, 0x172703, 0x181004, 0x12067c,
+	0x1346b2, 0x149c63, 0x151ae6, 0x160737, 0x170800, 0x184b78,
+	0x120688, 0x130693, 0x140ff0, 0x15463d, 0x168b1d, 0x17ce3a,
+	0x1852b7, 0x120694, 0x130800, 0x144701, 0x154389, 0x16408d,
+	0x174311, 0x180537, 0x1206a0, 0x130820, 0x141593, 0x150077,
+	0x1695aa, 0x17418c, 0x184572, 0x1206ac, 0x1305c2, 0x1481c1,
+	0x1581a9, 0x167763, 0x1700b5, 0x189533, 0x1206b8, 0x1300e4,
+	0x144513, 0x15fff5, 0x168e69, 0x170537, 0x180800, 0x1206c4,
+	0x134568, 0x148121, 0x15893d, 0x167463, 0x1702b5, 0x18a583,
+	0x1206d0, 0x1306c2, 0x140763, 0x151277, 0x160a63, 0x171217,
+	0x1805c2, 0x1206dc, 0x1381c1, 0x14818d, 0x150d63, 0x161097,
+	0x178985, 0x180586, 0x1206e8, 0x1395b3, 0x1400b4, 0x15c593,
+	0x16fff5, 0x178eed, 0x180705, 0x1206f4, 0x1315e3, 0x14fa67,
+	0x1535b7, 0x160822, 0x17a703, 0x183005, 0x120700, 0x13757d,
+	0x148a3d, 0x150513, 0x160ff5, 0x178f69, 0x180622, 0x12070c,
+	0x138e59, 0x14a023, 0x1530c5, 0x168637, 0x170800, 0x185a38,
+	0x120718, 0x1375c1, 0x14f693, 0x150ff6, 0x168593, 0x170ff5,
+	0x188f6d, 0x120724, 0x1306a2, 0x148ed9, 0x15da34, 0x164682,
+	0x170713, 0x180210, 0x120730, 0x139163, 0x140ee6, 0x154711,
+	0x16e391, 0x17471d, 0x182023, 0x12073c, 0x1310e4, 0x142683,
+	0x150a04, 0x16471d, 0x179e63, 0x1800e6, 0x120748, 0x136737,
+	0x140800, 0x152703, 0x164cc7, 0x170693, 0x184000, 0x120754,
+	0x137713, 0x144807, 0x151463, 0x1600d7, 0x172223, 0x180e04,
+	0x120760, 0x134018, 0x141163, 0x150497, 0x165703, 0x1700c4,
+	0x181793, 0x12076c, 0x130117, 0x14db63, 0x150207, 0x168737,
+	0x170800, 0x184778, 0x120778, 0x137713, 0x140807, 0x15e705,
+	0x160513, 0x170000, 0x184792, 0x120784, 0x134581, 0x149782,
+	0x1547a2, 0x164711, 0x17c818, 0x18c004, 0x120790, 0x130d23,
+	0x140094, 0x150ca3, 0x160004, 0x179782, 0x1856b7, 0x12079c,
+	0x130800, 0x1442b8, 0x159b71, 0x16c2b8, 0x170513, 0x180000,
+	0x1207a8, 0x1347d2, 0x149782, 0x154703, 0x162684, 0x1703e3,
+	0x18de07, 0x1207b4, 0x13bbd9, 0x1407b7, 0x150002, 0x168793,
+	0x1765c7, 0x18c83e, 0x1207c0, 0x1327b7, 0x140002, 0x158793,
+	0x16dae7, 0x17c43e, 0x1847b7, 0x1207cc, 0x130002, 0x148793,
+	0x151427, 0x16c23e, 0x1757b7, 0x180002, 0x1207d8, 0x138793,
+	0x149867, 0x15b1fd, 0x162683, 0x171504, 0x184709, 0x1207e4,
+	0x1399e3, 0x14e2e6, 0x1536b7, 0x160822, 0x17a703, 0x183006,
+	0x1207f0, 0x13663d, 0x148f51, 0x15a023, 0x1630e6, 0x17bd39,
+	0x18c593, 0x1207fc, 0x130015, 0x14b5dd, 0x158991, 0x1635b3,
+	0x1700b0, 0x180589, 0x120808, 0x13bdf9, 0x148991, 0x15b593,
+	0x160015, 0x17bfdd, 0x180737, 0x120814, 0x130800, 0x144f28,
+	0x15cf89, 0x1647c2, 0x17893d, 0x189782, 0x120820, 0x1347e2,
+	0x140713, 0x151000, 0x162223, 0x1710e4, 0x182423, 0x12082c,
+	0x1310f4, 0x14474d, 0x15b729, 0x168111, 0x17b7dd, 0x1814e3,
+	0x120838, 0x13f097, 0x140737, 0x150800, 0x164770, 0x171713,
+	0x180106, 0x120844, 0x135d63, 0x140607, 0x1585b7, 0x160800,
+	0x17a683, 0x180d05, 0x120850, 0x1372c5, 0x147313, 0x1500f6,
+	0x1612fd, 0x17a703, 0x180d45, 0x12085c, 0x131513, 0x1400c3,
+	0x15f6b3, 0x160056, 0x178ec9, 0x18757d, 0x120868, 0x130393,
+	0x140ff5, 0x151293, 0x160083, 0x17f6b3, 0x180076, 0x120874,
+	0x139b41, 0x148211, 0x15e2b3, 0x160056, 0x171093, 0x180043,
+	0x120880, 0x137693, 0x140016, 0x156333, 0x160067, 0x170613,
+	0x187ff5, 0x12088c, 0x139713, 0x1400b6, 0x157633, 0x1600c3,
+	0x178e59, 0x189513, 0x120898, 0x1300a6, 0x147613, 0x159ff6,
+	0x169713, 0x170096, 0x188e49, 0x1208a4, 0x13f293, 0x14f0f2,
+	0x158e59, 0x16e2b3, 0x170012, 0x1806a2, 0x1208b0, 0x137613,
+	0x14eff6, 0x158e55, 0x16a823, 0x170c55, 0x18aa23, 0x1208bc,
+	0x130cc5, 0x1480e3, 0x15e807, 0x1646b7, 0x170822, 0x18a703,
+	0x1208c8, 0x13f006, 0x149b61, 0x156713, 0x160027, 0x17a023,
+	0x18f0e6, 0x1208d4, 0x13b5ad, 0x140000, 0x150000, 0x160000,
+	0x170000, 0x180000, 0x110000, 0x120400, 0x104000, 0x1f0000,
+};
+
+#define patch_version1 0x9f73
+static const u32 init_data1[] = {
+	0x1f00a0, 0x1903f3, 0x1f0012, 0x150100, 0x1f00ad, 0x100000,
+	0x11e0c6, 0x1f00a0, 0x1903fb, 0x1903fb, 0x1903fb, 0x1903fb,
+	0x1903fb, 0x1903fb, 0x1903fb, 0x1903fb, 0x1f00ad, 0x110000,
+	0x120400, 0x130093, 0x140000, 0x150193, 0x160000, 0x170213,
+	0x180000, 0x12040c, 0x130293, 0x140000, 0x150313, 0x160000,
+	0x170393, 0x180000, 0x120418, 0x130413, 0x140000, 0x150493,
+	0x160000, 0x170513, 0x180000, 0x120424, 0x130593, 0x140000,
+	0x150613, 0x160000, 0x170693, 0x180000, 0x120430, 0x130713,
+	0x140000, 0x150793, 0x160000, 0x171137, 0x180000, 0x12043c,
+	0x13006f, 0x140060, 0x15a001, 0x161111, 0x17cc06, 0x18ca22,
+	0x120448, 0x13c826, 0x1417b7, 0x150800, 0x16aa23, 0x179407,
+	0x180713, 0x120454, 0x1330f0, 0x1467b7, 0x150800, 0x16a423,
+	0x1746e7, 0x18a703, 0x120460, 0x13a587, 0x146685, 0x158f55,
+	0x16ac23, 0x17a4e7, 0x1867a9, 0x12046c, 0x135737, 0x140800,
+	0x158793, 0x16f737, 0x172023, 0x1874f7, 0x120478, 0x1307b7,
+	0x140800, 0x155bf8, 0x165793, 0x170037, 0x18f793, 0x120484,
+	0x131f07, 0x147713, 0x1507f7, 0x168fd9, 0x170713, 0x180210,
+	0x120490, 0x138763, 0x1400e7, 0x150713, 0x160270, 0x178263,
+	0x181ce7, 0x12049c, 0x13a001, 0x141437, 0x150002, 0x160793,
+	0x17e564, 0x18c43e, 0x1204a8, 0x1337b7, 0x140002, 0x158793,
+	0x166867, 0x17c23e, 0x1847b7, 0x1204b4, 0x130002, 0x148793,
+	0x15e9a7, 0x16c63e, 0x1767b7, 0x180800, 0x1204c0, 0x13a703,
+	0x146d87, 0x1576c1, 0x168693, 0x170ff6, 0x188f75, 0x1204cc,
+	0x1366b5, 0x148693, 0x158006, 0x168f55, 0x17ac23, 0x186ce7,
+	0x1204d8, 0x13a703, 0x1465c7, 0x1556b7, 0x160800, 0x177713,
+	0x18f0f7, 0x1204e4, 0x136713, 0x140807, 0x15ae23, 0x1664e7,
+	0x17a703, 0x185c46, 0x1204f0, 0x130413, 0x140000, 0x159b75,
+	0x16a223, 0x175ce6, 0x18a703, 0x1204fc, 0x13f5c7, 0x146691,
+	0x158f55, 0x16ae23, 0x17f4e7, 0x180737, 0x120508, 0x130809,
+	0x14433c, 0x158fd5, 0x16c33c, 0x170793, 0x180000, 0x120514,
+	0x130713, 0x141000, 0x159c23, 0x1624e7, 0x170713, 0x181010,
+	0x120520, 0x138d23, 0x142407, 0x159123, 0x1626e7, 0x17a223,
+	0x182607, 0x12052c, 0x13c026, 0x144782, 0x154581, 0x164485,
+	0x170513, 0x180000, 0x120538, 0x134792, 0x149782, 0x154018,
+	0x161775, 0x17e563, 0x1802e4, 0x120544, 0x132703, 0x140a04,
+	0x151163, 0x160297, 0x174818, 0x180563, 0x120550, 0x130097,
+	0x1447a2, 0x15c804, 0x169782, 0x176637, 0x180800, 0x12055c,
+	0x132703, 0x144c46, 0x159b71, 0x166713, 0x170027, 0x182223,
+	0x120568, 0x134ce6, 0x144703, 0x150fd4, 0x16c739, 0x172603,
+	0x181004, 0x120574, 0x134745, 0x141263, 0x1510e6, 0x163737,
+	0x170822, 0x182603, 0x120580, 0x133007, 0x1475c5, 0x1515fd,
+	0x168e6d, 0x172023, 0x1830c7, 0x12058c, 0x132603, 0x142807,
+	0x156613, 0x161006, 0x172023, 0x1828c7, 0x120598, 0x132603,
+	0x143807, 0x156613, 0x161006, 0x172023, 0x1838c7, 0x1205a4,
+	0x132603, 0x144007, 0x156613, 0x161006, 0x172023, 0x1840c7,
+	0x1205b0, 0x132603, 0x144807, 0x156613, 0x161006, 0x172023,
+	0x1848c7, 0x1205bc, 0x135637, 0x140800, 0x152703, 0x163486,
+	0x17830d, 0x188b05, 0x1205c8, 0x13cf01, 0x142703, 0x155c46,
+	0x1675f1, 0x1715fd, 0x188f6d, 0x1205d4, 0x136591, 0x142223,
+	0x155ce6, 0x168f4d, 0x172223, 0x185ce6, 0x1205e0, 0x132603,
+	0x140a04, 0x15471d, 0x161e63, 0x1700e6, 0x186737, 0x1205ec,
+	0x130800, 0x142703, 0x154cc7, 0x160613, 0x174000, 0x187713,
+	0x1205f8, 0x134807, 0x141463, 0x1500c7, 0x162223, 0x170e04,
+	0x184018, 0x120604, 0x131263, 0x140497, 0x155703, 0x1600c4,
+	0x171793, 0x180117, 0x120610, 0x13dc63, 0x140207, 0x158737,
+	0x160800, 0x174778, 0x187713, 0x12061c, 0x130807, 0x14e70d,
+	0x154782, 0x164581, 0x170513, 0x180000, 0x120628, 0x134792,
+	0x149782, 0x1547a2, 0x164711, 0x17c818, 0x18c004, 0x120634,
+	0x130d23, 0x140094, 0x150ca3, 0x160004, 0x179782, 0x185637,
+	0x120640, 0x130800, 0x144238, 0x159b71, 0x16c238, 0x174782,
+	0x180513, 0x12064c, 0x130000, 0x1447b2, 0x159782, 0x164703,
+	0x172684, 0x1803e3, 0x120658, 0x13ee07, 0x14bdd1, 0x152437,
+	0x160002, 0x170793, 0x18dae4, 0x120664, 0x13c43e, 0x1447b7,
+	0x150002, 0x168793, 0x171427, 0x18c23e, 0x120670, 0x1357b7,
+	0x140002, 0x158793, 0x169867, 0x17b589, 0x182603, 0x12067c,
+	0x131504, 0x144709, 0x151ee3, 0x16f2e6, 0x173637, 0x180822,
+	0x120688, 0x132703, 0x143006, 0x1565bd, 0x168f4d, 0x172023,
+	0x1830e6, 0x120694, 0x13b725, 0x140000, 0x150000, 0x160000,
+	0x170000, 0x180000, 0x110000, 0x120400, 0x104000, 0x1f0000,
+};
+
+#define patch_version2 0x2e9c
+static const u32 init_data2[] = {
+	0x1f00a0, 0x1903f3, 0x1f0012, 0x150100, 0x1f00ad, 0x100000,
+	0x11e0c6, 0x1f0102, 0x199000, 0x1f00a0, 0x1903fb, 0x1903fb,
+	0x1903fb, 0x1903fb, 0x1903fb, 0x1903fb, 0x1903fb, 0x1903fb,
+	0x1f00ad, 0x110000, 0x121000, 0x13937c, 0x140120, 0x15675e,
+	0x16fca8, 0x1706b7, 0x180800, 0x12100c, 0x135af8, 0x145793,
+	0x150037, 0x16f793, 0x171f07, 0x187713, 0x121018, 0x1307f7,
+	0x148fd9, 0x150713, 0x1606a0, 0x179b63, 0x1808e7, 0x121024,
+	0x13cd19, 0x141121, 0x15c822, 0x16ca06, 0x17c626, 0x184789,
+	0x121030, 0x13842e, 0x140963, 0x152cf5, 0x1640d2, 0x174442,
+	0x1844b2, 0x12103c, 0x134501, 0x140161, 0x158082, 0x1617b7,
+	0x170800, 0x18aa23, 0x121048, 0x139407, 0x1467b7, 0x150800,
+	0x16a703, 0x17a587, 0x186605, 0x121054, 0x138f51, 0x14ac23,
+	0x15a4e7, 0x16670d, 0x170713, 0x18e9c7, 0x121060, 0x135637,
+	0x140800, 0x152023, 0x1674e6, 0x174ab8, 0x186713, 0x12106c,
+	0x130407, 0x14cab8, 0x15a703, 0x164d47, 0x1776fd, 0x188693,
+	0x121078, 0x1303f6, 0x148f75, 0x156713, 0x162807, 0x17aa23,
+	0x184ce7, 0x121084, 0x13a703, 0x147587, 0x157713, 0x16e1f7,
+	0x176713, 0x180607, 0x121090, 0x13ac23, 0x1474e7, 0x15a703,
+	0x164f47, 0x177713, 0x18f0f7, 0x12109c, 0x136713, 0x140107,
+	0x15aa23, 0x164ee7, 0x17a703, 0x18fc07, 0x1210a8, 0x139b5d,
+	0x14a023, 0x15fce7, 0x160713, 0x170300, 0x18a223, 0x1210b4,
+	0x13a6e7, 0x144501, 0x158082, 0x166489, 0x179023, 0x180004,
+	0x1210c0, 0x134505, 0x142ebd, 0x1557fd, 0x16c49c, 0x17c4dc,
+	0x184783, 0x1210cc, 0x130ec4, 0x149363, 0x152407, 0x16b795,
+	0x1787b7, 0x180800, 0x1210d8, 0x13a583, 0x140dc7, 0x15a783,
+	0x160e07, 0x178b91, 0x188063, 0x1210e4, 0x131807, 0x14d793,
+	0x150085, 0x1681b9, 0x178bbd, 0x188985, 0x1210f0, 0x1386b7,
+	0x140800, 0x15a703, 0x160d06, 0x17833e, 0x189513, 0x1210fc,
+	0x1300c7, 0x1477c5, 0x1517fd, 0x168f7d, 0x178f49, 0x18757d,
+	0x121108, 0x130293, 0x140ff5, 0x15a603, 0x160d46, 0x171793,
+	0x180083, 0x121114, 0x137733, 0x140057, 0x158f5d, 0x167713,
+	0x17f0f7, 0x181793, 0x121120, 0x130043, 0x148f5d, 0x157793,
+	0x16ff06, 0x170513, 0x187ff5, 0x12112c, 0x13e7b3, 0x140067,
+	0x159613, 0x1600b5, 0x178fe9, 0x188fd1, 0x121138, 0x139513,
+	0x1400a5, 0x15f793, 0x169ff7, 0x179613, 0x180095, 0x121144,
+	0x138fc9, 0x148fd1, 0x1505a2, 0x16f793, 0x17eff7, 0x188fcd,
+	0x121150, 0x13a823, 0x140ce6, 0x15aa23, 0x160cf6, 0x172783,
+	0x180f04, 0x12115c, 0x134719, 0x148563, 0x1500e7, 0x16472d,
+	0x179263, 0x1810e7, 0x121168, 0x130493, 0x141104, 0x154701,
+	0x164781, 0x17d683, 0x180104, 0x121174, 0x13e2b5, 0x1446a1,
+	0x154701, 0x16853e, 0x17c436, 0x18c23a, 0x121180, 0x13c03e,
+	0x142ca9, 0x1546a2, 0x164712, 0x174782, 0x1816fd, 0x12118c,
+	0x13972a, 0x14f6f5, 0x150637, 0x160820, 0x175693, 0x184037,
+	0x121198, 0x139713, 0x140077, 0x159732, 0x164310, 0x17d703,
+	0x180004, 0x1211a4, 0x139963, 0x1422e6, 0x159593, 0x160017,
+	0x176709, 0x18972e, 0x1211b0, 0x135703, 0x140087, 0x157e63,
+	0x1600e6, 0x17d703, 0x180184, 0x1211bc, 0x139023, 0x1400d4,
+	0x159693, 0x160017, 0x179423, 0x1800e4, 0x1211c8, 0x136709,
+	0x149736, 0x151423, 0x1600c7, 0x17d703, 0x180184, 0x1211d4,
+	0x133713, 0x140017, 0x150785, 0x164691, 0x170489, 0x1899e3,
+	0x1211e0, 0x13f8d7, 0x1447b5, 0x151f63, 0x161807, 0x176785,
+	0x1897a2, 0x1211ec, 0x13a703, 0x14a687, 0x154791, 0x160b63,
+	0x1718f7, 0x186489, 0x1211f8, 0x13d783, 0x140004, 0x159de3,
+	0x16e207, 0x172703, 0x180f04, 0x121204, 0x134789, 0x1418e3,
+	0x15e2f7, 0x164505, 0x172c15, 0x185637, 0x121210, 0x130800,
+	0x1446b7, 0x150822, 0x164238, 0x17a783, 0x18f806, 0x12121c,
+	0x133537, 0x140822, 0x1575c1, 0x16f793, 0x178ff7, 0x18e793,
+	0x121228, 0x133007, 0x14a023, 0x15f8f6, 0x162683, 0x173805,
+	0x188593, 0x121234, 0x130ff5, 0x14d793, 0x150086, 0x168b85,
+	0x17e793, 0x180767, 0x121240, 0x138eed, 0x1407a2, 0x158fd5,
+	0x162023, 0x1738f5, 0x187793, 0x12124c, 0x13ffd7, 0x14c23c,
+	0x15e793, 0x160027, 0x17c23c, 0x1847c1, 0x121258, 0x139023,
+	0x1400f4, 0x154501, 0x1622cd, 0x17bbd9, 0x184585, 0x121264,
+	0x134791, 0x14b569, 0x15476d, 0x169fe3, 0x17f6e7, 0x180737,
+	0x121270, 0x130002, 0x144481, 0x150713, 0x160a67, 0x178793,
+	0x184b84, 0x12127c, 0x130786, 0x1497a2, 0x15d683, 0x160ee7,
+	0x178526, 0x180485, 0x121288, 0x13e693, 0x140026, 0x159723,
+	0x160ed7, 0x179702, 0x180737, 0x121294, 0x130002, 0x144791,
+	0x150713, 0x160a67, 0x179ee3, 0x18fcf4, 0x1212a0, 0x130493,
+	0x141000, 0x154501, 0x1614fd, 0x172a15, 0x18fced, 0x1212ac,
+	0x134785, 0x148526, 0x15c03e, 0x16222d, 0x17470d, 0x184782,
+	0x1212b8, 0x135363, 0x1400a7, 0x154781, 0x160485, 0x174711,
+	0x1896e3, 0x1212c4, 0x13fee4, 0x14c38d, 0x156789, 0x164749,
+	0x179023, 0x1800e7, 0x1212d0, 0x1347c5, 0x142c23, 0x150ef4,
+	0x160793, 0x171000, 0x182a23, 0x1212dc, 0x130ef4, 0x1445d1,
+	0x150513, 0x160ec4, 0x172a15, 0x18b709, 0x1212e8, 0x136705,
+	0x149722, 0x155783, 0x16a5a7, 0x1746a1, 0x180785, 0x1212f4,
+	0x1307c2, 0x1483c1, 0x15f963, 0x1602f6, 0x171d23, 0x18a407,
+	0x121300, 0x132823, 0x140e04, 0x154783, 0x160ec4, 0x1789e3,
+	0x18da07, 0x12130c, 0x132783, 0x140f04, 0x1585e3, 0x16da07,
+	0x172783, 0x180f04, 0x121318, 0x138ee3, 0x14da07, 0x154741,
+	0x169de3, 0x17e2e7, 0x1847ed, 0x121324, 0x132823, 0x140ef4,
+	0x15bd05, 0x1606b7, 0x170002, 0x181d23, 0x121330, 0x13a4f7,
+	0x144481, 0x158693, 0x160a66, 0x178793, 0x184b84, 0x12133c,
+	0x130786, 0x1497a2, 0x15d703, 0x160ee7, 0x178526, 0x189b75,
+	0x121348, 0x139723, 0x140ee7, 0x159682, 0x160737, 0x170820,
+	0x189793, 0x121354, 0x130074, 0x140713, 0x152007, 0x1697ba,
+	0x17a023, 0x180007, 0x121360, 0x130737, 0x140002, 0x150485,
+	0x164791, 0x170693, 0x180a67, 0x12136c, 0x1396e3, 0x14fcf4,
+	0x150737, 0x160828, 0x172783, 0x184807, 0x121378, 0x13e793,
+	0x140207, 0x152023, 0x1648f7, 0x1747b9, 0x182823, 0x121384,
+	0x130ef4, 0x14b58d, 0x156709, 0x165683, 0x170007, 0x1847c9,
+	0x121390, 0x1393e3, 0x14e6f6, 0x1547b7, 0x160800, 0x17a783,
+	0x180c87, 0x12139c, 0x130693, 0x141000, 0x1507c2, 0x1683c1,
+	0x17f663, 0x1802f6, 0x1213a8, 0x135783, 0x140027, 0x150785,
+	0x1607c2, 0x1783c1, 0x181123, 0x1213b4, 0x1300f7, 0x144725,
+	0x157fe3, 0x16c6f7, 0x1766b7, 0x180800, 0x1213c0, 0x13a783,
+	0x14f5c6, 0x157779, 0x16177d, 0x178ff9, 0x18ae23, 0x1213cc,
+	0x13f4f6, 0x14b1a5, 0x151123, 0x160007, 0x17b18d, 0x18c1e3,
+	0x1213d8, 0x13dee6, 0x14bbdd, 0x150737, 0x160830, 0x172783,
+	0x181807, 0x1213e4, 0x132703, 0x142007, 0x154685, 0x160263,
+	0x1702d5, 0x18c763, 0x1213f0, 0x1300a6, 0x148bfd, 0x15c111,
+	0x164781, 0x17853e, 0x188082, 0x1213fc, 0x134689, 0x140b63,
+	0x1500d5, 0x16478d, 0x1719e3, 0x18fef5, 0x121408, 0x135793,
+	0x140047, 0x15a011, 0x168395, 0x178bfd, 0x18b7dd, 0x121414,
+	0x1383a9, 0x14bfed, 0x151141, 0x16c422, 0x17c606, 0x1847d1,
+	0x121420, 0x13842a, 0x149a63, 0x1500f5, 0x164508, 0x1707b7,
+	0x180002, 0x12142c, 0x13c02e, 0x148793, 0x156687, 0x169782,
+	0x174582, 0x18c04c, 0x121438, 0x1340b2, 0x144422, 0x150141,
+	0x168082, 0x17ed09, 0x184781, 0x121444, 0x134737, 0x140822,
+	0x152023, 0x16d0f7, 0x172023, 0x18d8f7, 0x121450, 0x132023,
+	0x14e0f7, 0x152023, 0x16e8f7, 0x178082, 0x186785, 0x12145c,
+	0x133737, 0x140822, 0x158693, 0x16fff7, 0x172023, 0x1830d7,
+	0x121468, 0x132023, 0x145007, 0x152023, 0x165807, 0x172023,
+	0x186007, 0x121474, 0x132023, 0x146807, 0x158793, 0x16c007,
+	0x17b7e1, 0x180000, 0x1f00a0, 0x1903f3, 0x1903fb, 0x1f0000,
+};
+
+/* no patch_version, val default=0 */
+static const u16 patch_version3;
+static const u32 init_data3[] = {
+	0x1f00a0, 0x1903f3, 0x1f0012, 0x150100, 0x1f00ad, 0x100000,
+	0x11e0c6, 0x1f00a0, 0x1903fb, 0x1903fb, 0x1903fb, 0x1903fb,
+	0x1903fb, 0x1903fb, 0x1f0012, 0x150000, 0x1f00ad, 0x110000,
+	0x127c30, 0x138137, 0x140000, 0x15006f, 0x1600e0, 0x170000,
+	0x180000, 0x127c3c, 0x130000, 0x140000, 0x150000, 0x161161,
+	0x177601, 0x1895b7, 0x127c48, 0x13fffd, 0x146541, 0x1586b7,
+	0x160002, 0x17c222, 0x18c026, 0x127c54, 0x1307b7, 0x140002,
+	0x150613, 0x162b06, 0x178593, 0x183085, 0x127c60, 0x130293,
+	0x142900, 0x15157d, 0x168693, 0x1797c6, 0x188733, 0x127c6c,
+	0x1300b7, 0x148333, 0x1500c7, 0x16ec63, 0x1734e2, 0x184398,
+	0x127c78, 0x138f69, 0x140713, 0x152b07, 0x162023, 0x1700e3,
+	0x180791, 0x127c84, 0x1393e3, 0x14fed7, 0x1567a1, 0x16659d,
+	0x178793, 0x181377, 0x127c90, 0x132423, 0x142ef0, 0x158713,
+	0x166b75, 0x176785, 0x18ac23, 0x127c9c, 0x13eae7, 0x140737,
+	0x158693, 0x160713, 0x1770a7, 0x18ae23, 0x127ca8, 0x13eae7,
+	0x140737, 0x159737, 0x160713, 0x17a867, 0x18a023, 0x127cb4,
+	0x13ece7, 0x141737, 0x157737, 0x166789, 0x170713, 0x188f77,
+	0x127cc0, 0x13ae23, 0x140ce7, 0x150737, 0x16078a, 0x17a023,
+	0x180ee7, 0x127ccc, 0x130737, 0x14ffc7, 0x150713, 0x167137,
+	0x17a223, 0x180ee7, 0x127cd8, 0x133737, 0x147337, 0x150713,
+	0x162a37, 0x17ae23, 0x183ce7, 0x127ce4, 0x1302b7, 0x14050a,
+	0x150737, 0x160103, 0x17a023, 0x183e57, 0x127cf0, 0x130713,
+	0x143137, 0x15a223, 0x163ee7, 0x17668d, 0x188513, 0x127cfc,
+	0x137375, 0x1404b7, 0x150713, 0x16ae23, 0x17a0a6, 0x188313,
+	0x127d08, 0x1378a4, 0x1404b7, 0x1597ba, 0x16a023, 0x17a266,
+	0x188713, 0x127d14, 0x132474, 0x140437, 0x1577b7, 0x16a223,
+	0x17a2e6, 0x180313, 0x127d20, 0x130a74, 0x146711, 0x152c23,
+	0x16c667, 0x170337, 0x188793, 0x127d2c, 0x132e23, 0x14c667,
+	0x158293, 0x166072, 0x1703b7, 0x187737, 0x127d38, 0x132023,
+	0x14c857, 0x158393, 0x162a73, 0x172823, 0x18d077, 0x127d44,
+	0x1302b7, 0x141793, 0x150637, 0x160713, 0x172a23, 0x18d057,
+	0x127d50, 0x130613, 0x140256, 0x152c23, 0x16d0c7, 0x178493,
+	0x187474, 0x127d5c, 0x132e23, 0x14d097, 0x150413, 0x164a74,
+	0x172423, 0x18e087, 0x127d68, 0x131437, 0x14050a, 0x152623,
+	0x16e067, 0x170413, 0x188c74, 0x127d74, 0x132823, 0x14e087,
+	0x152023, 0x16ec77, 0x172223, 0x18ec57, 0x127d80, 0x1313b7,
+	0x1497ba, 0x152423, 0x16ecc7, 0x178413, 0x18a473, 0x127d8c,
+	0x132623, 0x14ec87, 0x158413, 0x167b75, 0x172223, 0x185287,
+	0x127d98, 0x138437, 0x140cc7, 0x150413, 0x167934, 0x172423,
+	0x185287, 0x127da4, 0x130437, 0x140e87, 0x152e23, 0x1676a7,
+	0x170413, 0x187134, 0x127db0, 0x132223, 0x147887, 0x1504b7,
+	0x160713, 0x176715, 0x182023, 0x127dbc, 0x13baa7, 0x148413,
+	0x1578a4, 0x162223, 0x17ba87, 0x188413, 0x127dc8, 0x131473,
+	0x142423, 0x15ba87, 0x160437, 0x1776b7, 0x180413, 0x127dd4,
+	0x130e64, 0x14c700, 0x150437, 0x16070a, 0x17c740, 0x188437,
+	0x127de0, 0x131306, 0x140413, 0x156934, 0x16cb00, 0x172a23,
+	0x1858a7, 0x127dec, 0x138413, 0x1478a4, 0x152c23, 0x165887,
+	0x178393, 0x185c73, 0x127df8, 0x132e23, 0x145877, 0x15a3b7,
+	0x167737, 0x178413, 0x186f73, 0x127e04, 0x132823, 0x145a87,
+	0x150437, 0x16078a, 0x172a23, 0x185a87, 0x127e10, 0x130437,
+	0x141707, 0x150413, 0x167134, 0x172c23, 0x185a87, 0x127e1c,
+	0x138393, 0x144f73, 0x152823, 0x165c77, 0x170437, 0x18078a,
+	0x127e28, 0x1303b7, 0x141847, 0x152a23, 0x165c87, 0x178393,
+	0x187133, 0x127e34, 0x132c23, 0x145c77, 0x1593b7, 0x167737,
+	0x178393, 0x186a73, 0x127e40, 0x132a23, 0x146a77, 0x152c23,
+	0x166a57, 0x1723b7, 0x1897ba, 0x127e4c, 0x132e23, 0x146ac7,
+	0x158413, 0x16a073, 0x172023, 0x186c87, 0x127e58, 0x131437,
+	0x1477b7, 0x156719, 0x160413, 0x174d74, 0x182623, 0x127e64,
+	0x138e87, 0x142437, 0x15068a, 0x162823, 0x178e67, 0x180413,
+	0x127e70, 0x13c874, 0x142a23, 0x158e87, 0x16c437, 0x177737,
+	0x180413, 0x127e7c, 0x136a74, 0x142c23, 0x15ba87, 0x162e23,
+	0x17ba57, 0x182023, 0x127e88, 0x13bcc7, 0x148613, 0x15dc73,
+	0x162223, 0x17bcc7, 0x18d348, 0x127e94, 0x138613, 0x1478a4,
+	0x15d710, 0x168393, 0x17f873, 0x182623, 0x127ea0, 0x130277,
+	0x14e737, 0x1577b7, 0x160713, 0x178e77, 0x18a423, 0x127eac,
+	0x13cce5, 0x142737, 0x15070a, 0x16a623, 0x17cc65, 0x180713,
+	0x127eb8, 0x130c77, 0x14a823, 0x15cce5, 0x16f737, 0x174510,
+	0x180713, 0x127ec4, 0x138e77, 0x14ac23, 0x1520e7, 0x164737,
+	0x173191, 0x180713, 0x127ed0, 0x135017, 0x14a223, 0x1524e7,
+	0x160737, 0x170200, 0x180713, 0x127edc, 0x137137, 0x14ae23,
+	0x15f6e7, 0x165737, 0x170713, 0x181761, 0x127ee8, 0x13a223,
+	0x14f8e7, 0x150737, 0x16cff8, 0x170713, 0x184007, 0x127ef4,
+	0x13a423, 0x14f8e7, 0x150737, 0x163fb0, 0x170713, 0x187137,
+	0x127f00, 0x13a623, 0x14f8e7, 0x151737, 0x160793, 0x170713,
+	0x188007, 0x127f0c, 0x13a823, 0x14f4e7, 0x151737, 0x16c37c,
+	0x17aa23, 0x18f4e7, 0x127f18, 0x136737, 0x14e793, 0x150713,
+	0x167a17, 0x17ac23, 0x18f4e7, 0x127f24, 0x131737, 0x14cb3c,
+	0x150713, 0x168077, 0x17ae23, 0x18f4e7, 0x127f30, 0x130737,
+	0x146080, 0x150713, 0x167937, 0x17a023, 0x18f6e7, 0x127f3c,
+	0x13d737, 0x148082, 0x150713, 0x16b7c7, 0x17a223, 0x18f6e7,
+	0x127f48, 0x136737, 0x140793, 0x150613, 0x164447, 0x17aa23,
+	0x184cc6, 0x127f54, 0x130637, 0x14a223, 0x150613, 0x162006,
+	0x17ac23, 0x184cc6, 0x127f60, 0x130713, 0x144f47, 0x15ae23,
+	0x164ce6, 0x174737, 0x18d0fc, 0x127f6c, 0x130713, 0x14fa07,
+	0x15a023, 0x164ee6, 0x178737, 0x189207, 0x127f78, 0x130713,
+	0x147937, 0x15a223, 0x16f2e7, 0x17c737, 0x1867a1, 0x127f84,
+	0x130713, 0x1437c7, 0x15a423, 0x16f2e7, 0x178737, 0x187807,
+	0x127f90, 0x130713, 0x147937, 0x15a623, 0x16f2e7, 0x17d737,
+	0x180793, 0x127f9c, 0x130713, 0x14b3c7, 0x15a823, 0x16f2e7,
+	0x176737, 0x18cb7c, 0x127fa8, 0x130713, 0x140807, 0x15aa23,
+	0x16f2e7, 0x178737, 0x188082, 0x127fb4, 0x130713, 0x140827,
+	0x15ac23, 0x16f2e7, 0x17806f, 0x18af4f, 0x127fc0, 0x134412,
+	0x144482, 0x154501, 0x160121, 0x178082, 0x184398, 0x127fcc,
+	0x13b94d, 0x140000, 0x150000, 0x160000, 0x170000, 0x180000,
+	0x110000, 0x127c30, 0x104000, 0x1f0000,
+};
+
+static bool jl2xxx_patch_check(struct phy_device *phydev,
+			      struct jl_patch *patch)
+{
+
+	bool patch_ok = false;
+	int val;
+	int i;
+
+	val = jlsemi_read_paged(phydev, JL2XXX_PAGE0, JL2XXX_PHY_INFO_REG);
+	for (i = 0; i < patch->phy.info_len; i++) {
+		if (val == patch->phy.info[i])
+			patch_ok |= true;
+	}
+
+	return patch_ok;
+}
+
+static bool jl2xxx_patch_sgmii_2_utp_check(struct phy_device *phydev,
+				   struct jl_patch *patch)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	bool patch_ok = false;
+	int mode;
+
+	mode = jlsemi_read_paged(phydev, JL2XXX_PAGE18, JL2XXX_WORK_MODE_REG);
+	/* Can only be used in sgmii->utp mode */
+	if (((priv->work_mode.enable & JL2XXX_WORK_MODE_STATIC_OP_EN) &&
+	   (priv->work_mode.mode == JL2XXX_UTP_SGMII_MODE)) ||
+	   ((mode & JL2XXX_WORK_MODE_MASK) == JL2XXX_UTP_SGMII_MODE)) {
+		patch_ok = jl2xxx_patch_check(phydev, patch);
+	}
+	return patch_ok;
+}
+
+static int jl2xxx_patch_load(struct phy_device *phydev,
+			     struct jl_patch *patch)
+{
+	int regaddr, val;
+	int i, j;
+
+	for (i = 0; i < patch->data_len; i++) {
+		regaddr = ((patch->data[i] >> 16) & 0xff);
+		val = (patch->data[i] & 0xffff);
+		phy_write(phydev, regaddr, val);
+		if (regaddr == 0x18) {
+			phy_write(phydev, 0x10, 0x8006);
+			for (j = 0; j < 8; j++) {
+				if (phy_read(phydev, 0x10) == 0)
+					break;
+			}
+		}
+	}
+	/* Wait load patch complete */
+	msleep(20);
+
+	return 0;
+}
+
+static int jl2xxx_patch_verify_by_version(struct phy_device *phydev,
+					  struct jl_patch *patch)
+{
+	int version;
+
+	version = jlsemi_read_paged(phydev, JL2XXX_PAGE174, JL2XXX_PATCH_REG);
+	if (version != patch->version)
+		JLSEMI_PHY_MSG(KERN_ERR
+			       "%s: patch version is not match\n", __func__);
+	return 0;
+}
+
+static int jl2xxx_patch_verify_by_regval(struct phy_device *phydev,
+					 struct jl_patch *patch)
+{
+	int val;
+
+	val = jlsemi_read_paged(phydev, JL2XXX_PAGE179, JL2XXX_REG16);
+	if (val != patch->version)
+		JLSEMI_PHY_MSG(KERN_ERR "%s: patch load failed!\n", __func__);
+	return 0;
+}
+
+static struct jl_patch phy_patches[] = {
+	{
+		.data = init_data0,
+		.data_len = ARRAY_SIZE(init_data0),
+		.version = patch_version0,
+		{
+			.info = patch_fw_versions0,
+			.info_len = ARRAY_SIZE(patch_fw_versions0),
+		},
+		.check = jl2xxx_patch_check,
+		.load = jl2xxx_patch_load,
+		.verify = jl2xxx_patch_verify_by_version,
+
+	},
+	{
+		.data = init_data1,
+		.data_len = ARRAY_SIZE(init_data1),
+		.version = patch_version1,
+		{
+			.info = patch_fw_versions1,
+			.info_len = ARRAY_SIZE(patch_fw_versions1),
+		},
+		.check = jl2xxx_patch_check,
+		.load = jl2xxx_patch_load,
+		.verify = jl2xxx_patch_verify_by_version,
+	},
+	{
+		.data = init_data2,
+		.data_len = ARRAY_SIZE(init_data2),
+		.version = patch_version2,
+		{
+			.info = patch_fw_versions2,
+			.info_len = ARRAY_SIZE(patch_fw_versions2),
+		},
+		.check = jl2xxx_patch_check,
+		.load = jl2xxx_patch_load,
+		.verify = jl2xxx_patch_verify_by_version,
+	},
+	{
+		.data = init_data3,
+		.data_len = ARRAY_SIZE(init_data3),
+		.version = 0,
+		{
+			.info = patch_fw_versions3,
+			.info_len = ARRAY_SIZE(patch_fw_versions3),
+		},
+		.check = jl2xxx_patch_sgmii_2_utp_check,
+		.load = jl2xxx_patch_load,
+		.verify = jl2xxx_patch_verify_by_regval,
+	},
+};
+
+int jl2xxx_patch_static_op_set(struct phy_device *phydev)
+{
+	int found;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(phy_patches); i++) {
+		found = jl2xxx_pre_init(phydev, &phy_patches[i]);
+		if (found)
+			return found;
+	}
+
+	return 0;
+}
+
+static int jl2xxx_patch_dynamic_op_set(struct phy_device *phydev)
+{
+	const u16 fw_version = 0x2208;
+	static u16 last_status;
+	u16 value, cur_status;
+
+	/* read page 0, reg 29 */
+	value = jlsemi_read_paged(phydev, JL2XXX_PAGE0, JL2XXX_PHY_INFO_REG);
+	if (value != fw_version)
+		return 0;
+
+	while (1) {
+		/* get page 181, reg 18, bit 2 */
+		value = jlsemi_read_paged(phydev, JL2XXX_PAGE181, JL2XXX_REG18);
+		cur_status = (value >> JL2XXX_SERDES_LINK) & 1;
+
+		if (last_status == 0 && cur_status == 1) {
+			/* set page 160, reg 17, bit 2, val 1 */
+			jlsemi_set_bits(phydev, JL2XXX_PAGE160, JL2XXX_REG17, (1 << 2));
+			/* set page 190, reg 23, bit 15, val 1 */
+			jlsemi_set_bits(phydev, JL2XXX_PAGE190, JL2XXX_REG23, (1 << 15));
+		}
+		last_status = cur_status;
+
+		msleep(100);
+	}
+
+	return 0;
+}
+
+int jl1xxx_wol_dynamic_op_get(struct phy_device *phydev)
+{
+	return jlsemi_fetch_bit(phydev, JL1XXX_PAGE129,
+				JL1XXX_WOL_CTRL_REG, JL1XXX_WOL_DIS);
+}
+
+int jl2xxx_wol_dynamic_op_get(struct phy_device *phydev)
+{
+	return jlsemi_fetch_bit(phydev, JL2XXX_WOL_CTRL_PAGE,
+				JL2XXX_WOL_CTRL_REG, JL2XXX_WOL_EN);
+}
+
+static int jl1xxx_wol_static_op_set(struct phy_device *phydev)
+{
+	int err;
+
+	err = jl1xxx_wol_dynamic_op_set(phydev);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+int jl1xxx_intr_ack_event(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+	int err;
+
+	if (priv->intr.enable & JL1XXX_INTR_STATIC_OP_EN) {
+		err = phy_read(phydev, JL1XXX_INTR_STATUS_REG);
+		if (err < 0)
+			return err;
+	}
+
+	return 0;
+}
+
+int jl1xxx_intr_static_op_set(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+	int err;
+	int ret = 0;
+
+	if (priv->intr.enable & JL1XXX_INTR_LINK_CHANGE_EN)
+		ret |= JL1XXX_INTR_LINK;
+	if (priv->intr.enable & JL1XXX_INTR_AN_ERR_EN)
+		ret |= JL1XXX_INTR_AN_ERR;
+
+	err = jlsemi_set_bits(phydev, JL1XXX_PAGE7,
+			      JL1XXX_INTR_REG, ret);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+static int jl2xxx_wol_static_op_set(struct phy_device *phydev)
+{
+	int err;
+
+	err = jl2xxx_wol_dynamic_op_set(phydev);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+int jl1xxx_wol_dynamic_op_set(struct phy_device *phydev)
+{
+	int err;
+
+	err = jl1xxx_wol_cfg_rmii(phydev);
+	if (err < 0)
+		return err;
+
+	err = jl1xxx_wol_enable(phydev, true);
+	if (err < 0)
+		return err;
+
+	err = jl1xxx_wol_store_mac_addr(phydev);
+	if (err < 0)
+		return err;
+
+	if (jl1xxx_wol_receive_check(phydev)) {
+		err = jl1xxx_wol_clear(phydev);
+		if (err < 0)
+			return err;
+	}
+
+	return 0;
+}
+
+int jl2xxx_wol_dynamic_op_set(struct phy_device *phydev)
+{
+	int err;
+
+	err = jl2xxx_wol_enable(phydev, true);
+	if (err < 0)
+		return err;
+
+	err = jl2xxx_wol_clear(phydev);
+	if (err < 0)
+		return err;
+
+	err = jl2xxx_wol_active_low_polarity(phydev, true);
+	if (err < 0)
+		return err;
+
+	err = jl2xxx_store_mac_addr(phydev);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+int jl2xxx_intr_ack_event(struct phy_device *phydev)
+{
+	int err;
+
+	err = jlsemi_read_paged(phydev, JL2XXX_PAGE2627,
+				JL2XXX_INTR_STATUS_REG);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+int jl2xxx_intr_static_op_set(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	int err;
+	int ret = 0;
+
+	if (priv->intr.enable & JL2XXX_INTR_LINK_CHANGE_EN)
+		ret |= JL2XXX_INTR_LINK_CHANGE;
+	if (priv->intr.enable & JL2XXX_INTR_AN_ERR_EN)
+		ret |= JL2XXX_INTR_AN_ERR;
+	if (priv->intr.enable & JL2XXX_INTR_AN_COMPLETE_EN)
+		ret |= JL2XXX_INTR_AN_COMPLETE;
+	if (priv->intr.enable & JL2XXX_INTR_AN_PAGE_RECE)
+		ret |= JL2XXX_INTR_AN_PAGE;
+
+	err = jlsemi_set_bits(phydev, JL2XXX_PAGE2626,
+			      JL2XXX_INTR_CTRL_REG, ret);
+	if (err < 0)
+		return err;
+
+	err = jlsemi_set_bits(phydev, JL2XXX_PAGE158,
+			      JL2XXX_INTR_PIN_REG,
+			      JL2XXX_INTR_PIN_EN);
+	if (err < 0)
+		return err;
+
+	err = jlsemi_set_bits(phydev, JL2XXX_PAGE160,
+			      JL2XXX_PIN_EN_REG,
+			      JL2XXX_PIN_OUTPUT);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+int jl1xxx_operation_args_get(struct phy_device *phydev)
+{
+	jl1xxx_led_operation_args(phydev);
+	jl1xxx_wol_operation_args(phydev);
+	jl1xxx_intr_operation_args(phydev);
+	jl1xxx_mdi_operation_args(phydev);
+	jl1xxx_rmii_operation_args(phydev);
+
+	return 0;
+}
+
+int jl2xxx_operation_args_get(struct phy_device *phydev)
+{
+	jl2xxx_led_operation_args(phydev);
+	jl2xxx_fld_operation_args(phydev);
+	jl2xxx_wol_operation_args(phydev);
+	jl2xxx_intr_operation_args(phydev);
+	jl2xxx_downshift_operation_args(phydev);
+	jl2xxx_rgmii_operation_args(phydev);
+	jl2xxx_patch_operation_args(phydev);
+	jl2xxx_clk_operation_args(phydev);
+	jl2xxx_work_mode_operation_args(phydev);
+	jl2xxx_lpbk_operation_args(phydev);
+	jl2xxx_slew_rate_operation_args(phydev);
+	jl2xxx_rxc_out_operation_args(phydev);
+
+	return 0;
+}
+
+int jl1xxx_static_op_init(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+	int err;
+
+	if (priv->led.enable & JL1XXX_LED_STATIC_OP_EN) {
+		err = jl1xxx_led_static_op_set(phydev);
+		if (err < 0)
+			return err;
+	}
+
+	if (priv->wol.enable & JL1XXX_WOL_STATIC_OP_EN) {
+		err = jl1xxx_wol_static_op_set(phydev);
+		if (err < 0)
+			return err;
+	}
+
+	if (priv->intr.enable & JL1XXX_INTR_STATIC_OP_EN) {
+		err = jl1xxx_intr_static_op_set(phydev);
+		if (err < 0)
+			return err;
+	}
+
+	if (priv->mdi.enable & JL1XXX_MDI_STATIC_OP_EN) {
+		err = jl1xxx_mdi_static_op_set(phydev);
+		if (err < 0)
+			return err;
+	}
+
+	if (priv->rmii.enable & JL1XXX_RMII_STATIC_OP_EN) {
+		err = jl1xxx_rmii_static_op_set(phydev);
+		if (err < 0)
+			return err;
+	}
+
+	return 0;
+}
+
+int jl2xxx_static_sgmii_2_utp_mode_core_vol_adjust(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	int mode;
+	int err;
+
+	mode = jlsemi_read_paged(phydev, JL2XXX_PAGE18, JL2XXX_WORK_MODE_REG);
+	/* Can only be used in sgmii->utp mode */
+	if (((priv->work_mode.enable & JL2XXX_WORK_MODE_STATIC_OP_EN) &&
+	   (priv->work_mode.mode == JL2XXX_UTP_SGMII_MODE)) ||
+	   ((mode & JL2XXX_WORK_MODE_MASK) == JL2XXX_UTP_SGMII_MODE)) {
+		// page 257, reg 29, bit6:  1->1V, 0->0.9V
+		err = jlsemi_set_bits(phydev, JL2XXX_PAGE257,
+					JL2XXX_ANA_PM0_REG,
+					JL2XXX_BUCK_SEL_VOUT_CFG);
+		if (err < 0)
+			return err;
+	}
+
+	return 0;
+}
+
+int jl2xxx_static_op_init(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	int err;
+
+	if (priv->patch.enable & JL2XXX_PATCH_STATIC_OP_EN) {
+		err = jl2xxx_patch_static_op_set(phydev);
+		if (err < 0)
+			return err;
+	}
+
+	if (priv->led.enable & JL2XXX_LED_STATIC_OP_EN) {
+		err = jl2xxx_led_static_op_set(phydev);
+		if (err < 0)
+			return err;
+	}
+
+	if (priv->fld.enable & JL2XXX_FLD_STATIC_OP_EN) {
+		err = jl2xxx_fld_static_op_set(phydev);
+		if (err < 0)
+			return err;
+	}
+
+	if (priv->wol.enable & JL2XXX_WOL_STATIC_OP_EN) {
+		err = jl2xxx_wol_static_op_set(phydev);
+		if (err < 0)
+			return err;
+	}
+
+	if (priv->intr.enable & JL2XXX_INTR_STATIC_OP_EN) {
+		err = jl2xxx_intr_static_op_set(phydev);
+		if (err < 0)
+			return err;
+	}
+
+	if (priv->downshift.enable & JL2XXX_DSFT_STATIC_OP_EN) {
+		err = jl2xxx_downshift_static_op_set(phydev);
+		if (err < 0)
+			return err;
+	}
+
+	if (priv->rgmii.enable & JL2XXX_RGMII_STATIC_OP_EN) {
+		err = jl2xxx_rgmii_static_op_set(phydev);
+		if (err < 0)
+			return err;
+	}
+
+	if (priv->clk.enable & JL2XXX_CLK_STATIC_OP_EN) {
+		err = jl2xxx_clk_static_op_set(phydev);
+		if (err < 0)
+			return err;
+	}
+
+	if (priv->work_mode.enable & JL2XXX_WORK_MODE_STATIC_OP_EN) {
+		err = jl2xxx_work_mode_static_op_set(phydev);
+		if (err < 0)
+			return err;
+	}
+
+	if (priv->lpbk.enable & JL2XXX_LPBK_STATIC_OP_EN) {
+		err = jl2xxx_lpbk_static_op_set(phydev);
+		if (err < 0)
+			return err;
+	}
+#if 0
+	if (priv->slew_rate.enable & JL2XXX_SLEW_RATE_STATIC_OP_EN) {
+		err = jl2xxx_slew_rate_static_op_set(phydev);
+		if (err < 0)
+			return err;
+	}
+#endif
+	if (priv->rxc_out.enable & JL2XXX_RXC_OUT_STATIC_OP_EN) {
+		err = jl2xxx_rxc_out_static_op_set(phydev);
+		if (err < 0)
+			return err;
+	}
+	// SGMII-TO-UTP mode adjust core voltage to 1.0V
+	err = jl2xxx_static_sgmii_2_utp_mode_core_vol_adjust(phydev);
+	if (err < 0)
+		return err;
+	return 0;
+}
+
+int jl2xxx_pre_init(struct phy_device *phydev, struct jl_patch *patch)
+{
+	bool check;
+
+	check = patch->check(phydev, patch);
+	if (!check)
+		return 0;
+	patch->load(phydev, patch);
+	patch->verify(phydev, patch);
+
+	return 1;
+}
+
+int jlsemi_soft_reset(struct phy_device *phydev)
+{
+	int err;
+
+	err = jlsemi_set_bits(phydev, JL2XXX_PAGE0,
+			      JL2XXX_BMCR_REG, JL2XXX_SOFT_RESET);
+	if (err < 0)
+		return err;
+	/* Wait soft reset complete*/
+	msleep(600);
+
+	return 0;
+}
+
+/********************** Convenience function for phy **********************/
+
+/**
+ * jlsemi_write_page() - write the page register
+ * @phydev: a pointer to a &struct phy_device
+ * @page: page values
+ */
+int jlsemi_write_page(struct phy_device *phydev, int page)
+{
+	return phy_write(phydev, JLSEMI_PAGE31, page);
+}
+
+/**
+ * jlsemi_read_page() - write the page register
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Return: get page values at present
+ */
+int jlsemi_read_page(struct phy_device *phydev)
+{
+	return phy_read(phydev, JLSEMI_PAGE31);
+}
+
+/**
+ * __jlsemi_save_page() - save the page value
+ *@phydev: a pointer to a &struct phy_device
+ *
+ * Return: save page value
+ */
+static inline int __jlsemi_save_page(struct phy_device *phydev)
+{
+	return jlsemi_read_page(phydev);
+}
+
+/**
+ * __jlsemi_select_page() - restore the page register
+ * @phydev: a pointer to a &struct phy_device
+ * @page: the page
+ *
+ * Return:
+ * @oldpgae: this is last page value
+ * @ret: if page is change it will return new page value
+ */
+static inline int __jlsemi_select_page(struct phy_device *phydev, int page)
+{
+	int ret, oldpage;
+
+	oldpage = ret = __jlsemi_save_page(phydev);
+	if (ret < 0)
+		return ret;
+
+	if (oldpage != page) {
+		ret = jlsemi_write_page(phydev, page);
+		if (ret < 0)
+			return ret;
+	}
+
+	return oldpage;
+}
+
+/**
+ * __jlsemi_restore_page() - restore the page register
+ * @phydev: a pointer to a &struct phy_device
+ * @oldpage: the old page, return value from __jlsemi_save_page() or
+ * __jlsemi_select_page()
+ * @ret: operation's return code
+ *
+ * Returns:
+ *   @oldpage if it was a negative value, otherwise
+ *   @ret if it was a negative errno value, otherwise
+ *   phy_write_page()'s negative value if it were in error, otherwise
+ *   @ret
+ */
+static inline int __jlsemi_restore_page(struct phy_device *phydev,
+					int oldpage, int ret)
+{
+	int r;
+
+	if (oldpage >= 0) {
+		r = jlsemi_write_page(phydev, oldpage);
+
+		/* Propagate the operation return code if the page write
+		 * was successful.
+		 */
+		if (ret >= 0 && r < 0)
+			ret = r;
+	} else {
+		/* Propagate the phy page selection error code */
+		ret = oldpage;
+	}
+
+	return ret;
+}
+
+/**
+ * __jlsemi_modify_reg() - Convenience function for modifying a PHY register
+ * @phydev: a pointer to a &struct phy_device
+ * @regnum: register number
+ * @mask: bit mask of bits to clear
+ * @set: bit mask of bits to set
+ *
+ * Returns negative errno, 0 if there was no change, and 1 in case of change
+ */
+static inline int __jlsemi_modify_reg(struct phy_device *phydev,
+				      u32 regnum, u16 mask, u16 set)
+{
+	int newval, ret;
+
+	ret = phy_read(phydev, regnum);
+	if (ret < 0)
+		return ret;
+
+	newval = (ret & ~mask) | set;
+	if (newval == ret)
+		return 0;
+
+	ret = phy_write(phydev, regnum, newval);
+
+	return ret < 0 ? ret : 1;
+}
+
+/**
+ * jlsemi_modify_paged_reg() - Function for modifying a paged register
+ * @phydev: a pointer to a &struct phy_device
+ * @page: the page for the phy
+ * @regnum: register number
+ * @mask: bit mask of bits to clear
+ * @set: bit mask of bits to set
+ *
+ * Returns negative errno, 0 if there was no change, and 1 in case of change
+ */
+int jlsemi_modify_paged_reg(struct phy_device *phydev,
+			    int page, u32 regnum,
+			    u16 mask, u16 set)
+{
+	int ret = 0, oldpage;
+
+	oldpage = __jlsemi_select_page(phydev, page);
+	if (oldpage >= 0)
+		ret = __jlsemi_modify_reg(phydev, regnum, mask, set);
+
+	return __jlsemi_restore_page(phydev, oldpage, ret);
+}
+
+/**
+ * jlsemi_set_bits() - Convenience function for setting bits in a PHY register
+ * @phydev: a pointer to a &struct phy_device
+ * @page: the page for the phy
+ * @regnum: register number to write
+ * @val: bits to set
+ */
+int jlsemi_set_bits(struct phy_device *phydev,
+		    int page, u32 regnum, u16 val)
+{
+	return jlsemi_modify_paged_reg(phydev, page, regnum, 0, val);
+}
+
+/**
+ * jlsemi_clear_bits - Convenience function for clearing bits in a PHY register
+ * @phydev: the phy_device struct
+ * @page: the page for the phy
+ * @regnum: register number to write
+ * @val: bits to clear
+ */
+int jlsemi_clear_bits(struct phy_device *phydev,
+		      int page, u32 regnum, u16 val)
+{
+	return jlsemi_modify_paged_reg(phydev, page, regnum, val, 0);
+}
+
+/**
+ * jlsemi_fetch_bit() - Convenience function for setting bits in a PHY register
+ * @phydev: a pointer to a &struct phy_device
+ * @page: the page for the phy
+ * @regnum: register number to write
+ * @val: bit to get
+ *
+ * Note:
+ * you only get one bit at meanwhile
+ *
+ */
+int jlsemi_fetch_bit(struct phy_device *phydev,
+		   int page, u32 regnum, u16 val)
+{
+	int ret = 0, oldpage;
+
+	oldpage = __jlsemi_select_page(phydev, page);
+	if (oldpage >= 0) {
+		ret = phy_read(phydev, regnum);
+		if (ret < 0)
+			return ret;
+		ret = ((ret & val) == val) ? 1 : 0;
+	}
+
+	return __jlsemi_restore_page(phydev, oldpage, ret);
+}
+
+/**
+ * jlsemi_read_paged() - Convenience function for reading a paged register
+ * @phydev: a pointer to a &struct phy_device
+ * @page: the page for the phy
+ * @regnum: register number
+ *
+ * Same rules as for phy_read().
+ */
+int jlsemi_read_paged(struct phy_device *phydev, int page, u32 regnum)
+{
+	int ret = 0, oldpage;
+
+	oldpage = __jlsemi_select_page(phydev, page);
+	if (oldpage >= 0)
+		ret = phy_read(phydev, regnum);
+
+	return __jlsemi_restore_page(phydev, oldpage, ret);
+}
+
+/**
+ * jlsemi_patch_dynamic_op_set() - Convenience function for dynamic set patch
+ * @phydev: a pointer to a &struct phy_device
+ *
+ */
+int jlsemi_patch_dynamic_op_set(struct phy_device *phydev)
+{
+	return jl2xxx_patch_dynamic_op_set(phydev);
+}
+
+#if (KERNEL_VERSION(4, 0, 0) > LINUX_VERSION_CODE)
+int jlsemi_drivers_register(struct phy_driver *phydrvs, int size)
+{
+	int i, j;
+	int ret;
+
+	printk("cy: enter jlsemi_drivers_register 2\n");
+	for (i = 0; i < size; i++) {
+		ret = phy_driver_register(&phydrvs[i]);
+		if (ret)
+			goto err;
+	}
+
+	return 0;
+
+err:
+	for (j = 0; j < i; j++)
+		phy_driver_unregister(&phydrvs[j]);
+
+	printk("cy: enter jlsemi_drivers_register fail\n");
+	return ret;
+}
+
+void jlsemi_drivers_unregister(struct phy_driver *phydrvs, int size)
+{
+	int i;
+
+	printk("cy: exit jlsemi_drivers_register 1\n");
+	for (i = 0; i < size; i++)
+		phy_driver_unregister(&phydrvs[i]);
+}
+#else
+#endif
diff --git a/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/phy/jlsemi-core.h b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/phy/jlsemi-core.h
new file mode 100755
index 0000000..9010042
--- /dev/null
+++ b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/phy/jlsemi-core.h
@@ -0,0 +1,465 @@
+/* SPDX-License-Identifier: GPL-2.0+
+ *
+ * Copyright (C) 2021 JLSemi Corporation
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+#ifndef _JLSEMI_CORE_H
+#define _JLSEMI_CORE_H
+
+#define JLSEMI_KERNEL_DEVICE_TREE_USE	0
+#define JLSEMI_DEBUG_INFO 1
+
+#include <linux/phy.h>
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/of.h>
+#if (JLSEMI_KERNEL_DEVICE_TREE_USE)
+#include <dt-bindings/phy/jlsemi-dt-phy.h>
+#else
+#include "jlsemi-dt-phy.h"
+#endif
+
+#define JL1XXX_PHY_ID		0x937c4023
+#define JL2XXX_PHY_ID		0x937c4032
+#define JLSEMI_PHY_ID_MASK	0xfffffff0
+
+#define JL1XXX_PAGE0		0
+#define JL1XXX_PAGE7		7
+#define JL1XXX_INTR_REG		19
+#define JL1XXX_INTR_LINK	BIT(13)
+#define JL1XXX_INTR_AN_ERR	BIT(11)
+#define JL1XXX_LED_REG		19
+#define JL1XXX_LED_EN		BIT(3)
+#define JL1XXX_INTR_STATUS_REG	30
+
+#define JL1XXX_PAGE7		7
+#define JL1XXX_RMII_CTRL_REG	16
+#define JL1XXX_RMII_OUT		BIT(12)
+#define JL1XXX_RMII_MODE	BIT(3)
+
+#define JL1XXX_PAGE129		129
+#define JL1XXX_LED_MODE_REG	24
+#define JL1XXX_MAC_ADDR0_REG	25
+#define JL1XXX_MAC_ADDR1_REG	26
+#define JL1XXX_MAC_ADDR2_REG	27
+#define JL1XXX_WOL_CTRL_REG	28
+#define JL1XXX_WOL_DIS		BIT(15)
+#define JL1XXX_WOL_CLEAR	BIT(1)
+#define JL1xxx_WOL_RECEIVE	BIT(0)
+#define ADDR8_HIGH_TO_LOW(n)	((n >> 4) | (n << 4))
+
+#define JL1XXX_PAGE24		24
+#define JL1XXX_REG24		24
+#define JL1XXX_MDI_TX_BM_MASK	0x1c00
+#define JL1XXX_MDI_TX_BM(n)	(n << 10)
+#define JL1XXX_MDI_TX_SRN	BIT(0)
+
+#define JL1XXX_PAGE7		7
+#define JL1XXX_REG16		16
+#define JL1XXX_RMII_MODE		BIT(3)
+#define JL1XXX_RMII_CLK_50M_INPUT	BIT(12)
+#define JL1XXX_RMII_TX_SKEW_MASK	(0xf << 8)
+#define JL1XXX_RMII_TX_SKEW(n)		((n << 8) & JL1XXX_RMII_TX_SKEW_MASK)
+#define JL1XXX_RMII_RX_SKEW_MASK	(0xf << 4)
+#define JL1XXX_RMII_RX_SKEW(n)		((n << 4) & JL1XXX_RMII_RX_SKEW_MASK)
+#define JL1XXX_RMII_CRS_DV		BIT(2)
+
+#define JL2XXX_PAGE0		0
+#define JL2XXX_BMCR_REG		0x0000
+#define JL2XXX_SOFT_RESET	BIT(15)
+#define JL2XXX_SPEED_LSB	BIT(13)
+#define JL2XXX_AUTONEG_EN	BIT(12)
+#define JL2XXX_SPEED_MSB	BIT(6)
+#define JL2XXX_DSFT_CTRL_REG	17
+#define JL2XXX_DSFT_EN		BIT(12)
+#define JL2XXX_DSFT_SMART_EN	BIT(13)
+#define JL2XXX_DSFT_TWO_WIRE_EN	BIT(14)
+#define JL2XXX_DSFT_AN_ERR_EN	BIT(15)
+#define JL2XXX_DSFT_STL_MASK	0x03e0
+#define JL2XXX_DSFT_STL_CNT(n)	(((n << 5) & JL2XXX_DSFT_STL_MASK))
+#define JL2XXX_DSFT_AN_MASK	0x001f
+#define JL2XXX_DSFT_CNT_MAX	32
+#define JL2XXX_PHY_INFO_REG	29
+#define JL2XXX_PATCH_MASK	0xffff
+#define JL2XXX_SW_MASK		0xffff
+#define JL2XXX_AUTO_GAIN_DIS	BIT(6)
+
+#define JLSEMI_PAGE31		0x001f
+#define JL2XXX_WOL_CTRL_PAGE	0x0012
+#define JL2XXX_WOL_CTRL_REG	0x0015
+#define JL2XXX_WOL_STAS_PAGE	0x1200
+#define JL2XXX_WOL_STAS_REG	0x0010
+#define JL2XXX_MAC_ADDR2_REG	0x0011
+#define JL2XXX_MAC_ADDR1_REG	0x0012
+#define JL2XXX_MAC_ADDR0_REG	0x0013
+#define JL2XXX_WOL_EVENT	BIT(1)
+#define JL2XXX_WOL_POLARITY	BIT(14)
+#define JL2XXX_WOL_EN		BIT(15)
+#define JL2XXX_WOL_GLB_EN	BIT(6)
+
+#define JL2XXX_PAGE2626		2626
+#define JL2XXX_INTR_CTRL_REG	18
+#define JL2XXX_INTR_LINK_CHANGE	BIT(4)
+#define JL2XXX_INTR_AN_COMPLETE	BIT(3)
+#define JL2XXX_INTR_AN_PAGE	BIT(2)
+#define JL2XXX_INTR_AN_ERR	BIT(0)
+
+#define JL2XXX_PAGE2627		2627
+#define JL2XXX_INTR_STATUS_REG	29
+#define JL2XXX_CLK_CTRL_REG	25
+#define JL2XXX_CLK_OUT_PIN	BIT(0)
+#define JL2XXX_CLK_SSC_EN	BIT(3)
+#define JL2XXX_CLK_125M_OUT	BIT(11)
+#define JL2XXXX_CLK_SRC		BIT(12)
+
+#define JL2XXX_PAGE158		158
+#define JL2XXX_INTR_PIN_REG	16
+#define JL2XXX_INTR_PIN_EN	BIT(14)
+
+#define JL2XXX_PAGE160		160
+#define JL2XXX_PIN_EN_REG	21
+#define JL2XXX_PIN_OUTPUT	BIT(11)
+
+#define JL2XXX_PAGE3336		3336
+#define JL2XXX_RGMII_CTRL_REG	17
+
+#define JL2XXX_PAGE18		18
+#define JL2XXX_RXC_OUT_REG	21
+#define JL2XXX_RXC_OUT		BIT(14)
+
+#define JL2XXX_WORK_MODE_REG	21
+#define JL2XXX_WORK_MODE_MASK	0x7
+
+#define JL2XXX_PAGE160		160
+#define JL2XXX_REG25		25
+#define JL2XXX_CPU_RESET	BIT(3)
+
+#define JL2XXX_PAGE173		173
+#define JL2XXX_PATCH_REG	0x0010
+#define JL2XXX_REG16		16
+#define JL2XXX_REG17		17
+#define JL2XXX_LOAD_GO		0
+#define JL2XXX_LOAD_DATA0	0x3a01
+#define JL2XXX_REG20		20
+#define JL2XXX_REG21		21
+#define JL2XXX_LPBK_MODE_MASK	0x6
+#define JL2XXX_LPBK_PMD_MODE	BIT(2)
+#define JL2XXX_LPBK_EXT_MODE	BIT(1)
+
+#define JL2XXX_PAGE174		174
+
+#define JL2XXX_REG29		29
+
+#define JL2XXX_PAGE179		179
+
+#define JL2XXX_PAGE181		181
+#define JL2XXX_REG18		18
+#define JL2XXX_SERDES_LINK		BIT(2)
+
+#define JL2XXX_PAGE190		190
+#define JL2XXX_REG23		23
+
+#define JL2XXX_PAGE191		191
+#define JL2XXX_RGMII_CFG	BIT(3)
+
+#define JL2XXX_PAGE257		257
+#define JL2XXX_ANA_PM0_REG	29
+#define JL2XXX_BUCK_SEL_VOUT_CFG	BIT(6)
+
+
+#define JL2XXX_PAGE258		258
+#define JL2XXX_SLEW_RATE_CTRL_REG	23
+#define JL2XXX_SLEW_RATE_EN		BIT(12)
+#define JL2XXX_SLEW_RATE_REF_CLK	BIT(13)
+#define JL2XXX_SLEW_RATE_SEL_CLK	BIT(14)
+
+#define JL2XXX_REG20		20
+#define JL2XXX_SPEED1000_NO_AN	(BIT(11) | BIT(10))
+
+#define LED_PERIOD_MASK		0xff00
+#define LEDPERIOD(n)		((n << 8) & LED_PERIOD_MASK)
+#define LED_ON_MASK		0x00ff
+#define LEDON(n)		((n << 0) & LED_ON_MASK)
+
+#define ADVERTISE_FIBER_1000HALF	0x40
+#define ADVERTISE_FIBER_1000FULL	0x20
+
+/*************************************************************************/
+struct jl_patch {
+	const u32 *data;
+	u16 data_len;
+	const u16 version;
+	struct {
+		const u16 *info;
+		u16 info_len;
+	} phy;
+	bool (*check)(struct phy_device *phydev, struct jl_patch *patch);
+	int (*load)(struct phy_device *phydev, struct jl_patch *patch);
+	int (*verify)(struct phy_device *phydev, struct jl_patch *patch);
+};
+
+struct jl_hw_stat {
+	const char *string;
+	u8 reg;
+	u16 page;
+	u16 mask;
+	u16 enable;
+};
+
+static const struct jl_hw_stat jl_phy[] = {
+	{
+		.string = "page0,reg0",
+		.enable = true,
+		.page = 0,
+		.reg = 0,
+	}, {
+		.string = "page0,reg1",
+		.enable = false,
+		.page = 0,
+		.reg = 1,
+	},
+};
+
+static const struct jl_hw_stat jl2xxx_hw_stats[] = {
+	{
+		.string	= "phy_patch_version",
+		.reg	= JL2XXX_PATCH_REG,
+		.page	= JL2XXX_PAGE174,
+		.mask	= JL2XXX_PATCH_MASK,
+	}, {
+		.string	= "phy_software_version",
+		.reg	= JL2XXX_PHY_INFO_REG,
+		.page	= JL2XXX_PAGE0,
+		.mask	= JL2XXX_SW_MASK,
+	},
+};
+
+struct jl_led_ctrl {
+	u32 enable;			/* LED control enable */
+	u32 mode;			/* LED work mode */
+	u32 global_period;		/* LED global twinkle period */
+	u32 global_on;			/* LED global twinkle hold on time */
+	u32 gpio_output;		/* LED is used as gpio output */
+	u32 polarity;			/* LED polarity */
+	bool ethtool;			/* Whether the ethtool is supported */
+};
+
+struct jl_fld_ctrl {
+	u32 enable;			/* Fast link down control enable */
+	u32 delay;			/* Fast link down time */
+	bool ethtool;			/* Whether the ethtool is supported */
+};
+
+struct jl_wol_ctrl {
+	u32 enable;			/* Wake On LAN control enable */
+	bool ethtool;			/* Whether the ethtool is supported */
+};
+
+struct jl_intr_ctrl {
+	u32 enable;			/* Interrupt control enable */
+	bool ethtool;			/* Whether the ethtool is supported */
+};
+
+struct jl_downshift_ctrl {
+	u32 enable;			/* Downshift control enable */
+	u32 count;			/* Downshift control count */
+	bool ethtool;			/* Whether the ethtool is supported */
+};
+
+struct jl_rgmii_ctrl {
+	u32 enable;			/* Rgmii control enable */
+	u32 rx_delay;			/* Rgmii control rx delay */
+	u32 tx_delay;			/* Rgmii control tx delay */
+	bool ethtool;			/* Whether the ethtool is supported */
+};
+
+struct jl_patch_ctrl {
+	u32 enable;			/* Patch control enable */
+	bool ethtool;			/* Whether the ethtool is supported */
+};
+
+struct jl_clk_ctrl {
+	u32 enable;			/* Clock 125M control enable */
+	bool ethtool;			/* Whether the ethtool is supported */
+};
+
+struct jl_work_mode_ctrl {
+	u32 enable;			/* Work mode control enable */
+	u32 mode;			/* Work mode select mode */
+	bool ethtool;			/* Whether the ethtool is supported */
+};
+
+struct jl_loopback_ctrl {
+	u32 enable;			/* Loopback control enable */
+	u32 mode;			/* Loopback select mode */
+	bool ethtool;			/* Whether the ethtool is supported */
+};
+
+struct jl_mdi_ctrl {
+	u32 enable;			/* Mdi control enable */
+	u32 rate;			/* Mdi select Rate */
+	u32 amplitude;			/* Mdi select amplitude */
+	bool ethtool;			/* Whether the ethtool is supported */
+};
+
+struct jl_rmii_ctrl {
+	u32 enable;			/* Rmii control enable */
+	u32 tx_timing;			/* Rmii modify tx timing */
+	u32 rx_timing;			/* Rmii modify rx timing */
+	bool ethtool;			/* Whether the ethtool is supported */
+};
+
+struct jl_slew_rate_ctrl {
+	u32 enable;			/* Slew rate control enable */
+	bool ethtool;			/* Whether the ethtool is supported */
+};
+
+struct jl_rxc_out_ctrl {
+	u32 enable;			/* Rx clock out control enable */
+	bool inited;			/* Only execute once flag */
+	bool ethtool;			/* Whether the ethtool is supported */
+};
+
+struct jl1xxx_priv {
+	struct jl_led_ctrl led;
+	struct jl_wol_ctrl wol;
+	struct jl_intr_ctrl intr;
+	bool static_inited;		/* Initialization flag */
+	struct jl_mdi_ctrl mdi;
+	struct jl_rmii_ctrl rmii;
+};
+
+struct jl2xxx_priv {
+	struct jl_led_ctrl led;
+	struct jl_fld_ctrl fld;
+	struct jl_wol_ctrl wol;
+	struct jl_intr_ctrl intr;
+	struct jl_downshift_ctrl downshift;
+	struct jl_rgmii_ctrl rgmii;
+	struct jl_patch_ctrl patch;
+	struct jl_clk_ctrl clk;
+	const struct jl_hw_stat *hw_stats;
+	bool static_inited;		/* Initialization flag */
+	int nstats;			/* Record for dynamic operation */
+	u64 *stats;			/* Pointer for dynamic operation */
+	struct jl_work_mode_ctrl work_mode;
+	struct jl_loopback_ctrl lpbk;
+	struct jl_slew_rate_ctrl slew_rate;
+	struct jl_rxc_out_ctrl rxc_out;
+};
+
+/* macros to simplify debug checking */
+#define JLSEMI_PHY_MSG(msg, args...) printk(KERN_INFO msg, ## args)
+
+/************************* JLSemi iteration code *************************/
+struct device *jlsemi_get_mdio(struct phy_device *phydev);
+
+int jl2xxx_downshift_dynamic_op_get(struct phy_device *phydev, u8 *data);
+
+int jl2xxx_downshift_dynamic_op_set(struct phy_device *phydev, u8 cnt);
+
+int jlsemi_read_paged(struct phy_device *phydev, int page, u32 regnum);
+
+int jl2xxx_intr_ack_event(struct phy_device *phydev);
+
+int jl2xxx_intr_static_op_set(struct phy_device *phydev);
+
+int jl1xxx_intr_ack_event(struct phy_device *phydev);
+
+int jl1xxx_intr_static_op_set(struct phy_device *phydev);
+
+int jl2xxx_wol_dynamic_op_get(struct phy_device *phydev);
+
+int jl2xxx_wol_dynamic_op_set(struct phy_device *phydev);
+
+int jl1xxx_wol_dynamic_op_get(struct phy_device *phydev);
+
+int jl1xxx_wol_dynamic_op_set(struct phy_device *phydev);
+
+int jl2xxx_fld_dynamic_op_get(struct phy_device *phydev, u8 *msecs);
+
+int jl2xxx_fld_dynamic_op_set(struct phy_device *phydev, const u8 *msecs);
+
+int jl1xxx_operation_args_get(struct phy_device *phydev);
+
+int jl1xxx_static_op_init(struct phy_device *phydev);
+
+int jl2xxx_operation_args_get(struct phy_device *phydev);
+
+int jl2xxx_static_op_init(struct phy_device *phydev);
+
+int jlsemi_soft_reset(struct phy_device *phydev);
+
+int jl2xxx_pre_init(struct phy_device *phydev, struct jl_patch *patch);
+
+bool jl2xxx_read_fiber_status(struct phy_device *phydev);
+
+int jl2xxx_config_aneg_fiber(struct phy_device *phydev);
+
+/********************** Convenience function for phy **********************/
+
+/* Notice: You should change page 0 when you When you call it after */
+int jlsemi_write_page(struct phy_device *phydev, int page);
+
+int jlsemi_read_page(struct phy_device *phydev);
+
+int jlsemi_modify_paged_reg(struct phy_device *phydev,
+			    int page, u32 regnum,
+			    u16 mask, u16 set);
+
+int jlsemi_set_bits(struct phy_device *phydev,
+		    int page, u32 regnum, u16 val);
+
+int jlsemi_clear_bits(struct phy_device *phydev,
+		      int page, u32 regnum, u16 val);
+
+int jlsemi_fetch_bit(struct phy_device *phydev,
+		     int page, u32 regnum, u16 val);
+
+int jlsemi_drivers_register(struct phy_driver *phydrvs, int size);
+
+void jlsemi_drivers_unregister(struct phy_driver *phydrvs, int size);
+
+/**
+ * module_jlsemi_driver() - Helper macro for registering PHY drivers
+ * @__phy_drivers: array of PHY drivers to register
+ *
+ * Helper macro for PHY drivers which do not do anything special in module
+ * init/exit. Each module may only use this macro once, and calling it
+ * replaces module_init() and module_exit().
+ */
+#if (KERNEL_VERSION(4, 0, 0) > LINUX_VERSION_CODE)
+
+#define jlsemi_module_driver(__phy_drivers, __count)			\
+static int __init phy_module_init(void)					\
+{									\
+	return jlsemi_drivers_register(__phy_drivers, __count);		\
+}									\
+module_init(phy_module_init);						\
+static void __exit phy_module_exit(void)				\
+{									\
+	jlsemi_drivers_unregister(__phy_drivers, __count);		\
+}									\
+module_exit(phy_module_exit)
+
+#define module_jlsemi_driver(__phy_drivers)				\
+	jlsemi_module_driver(__phy_drivers, ARRAY_SIZE(__phy_drivers))
+
+#else
+
+#define module_jlsemi_driver(__phy_drivers)				\
+	module_phy_driver(__phy_drivers)
+#endif
+
+#endif /* _JLSEMI_CORE_H */
+
diff --git a/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/phy/jlsemi-dt-phy.h b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/phy/jlsemi-dt-phy.h
new file mode 100755
index 0000000..0a6e221
--- /dev/null
+++ b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/phy/jlsemi-dt-phy.h
@@ -0,0 +1,341 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Device Tree constants for JLSemi PHY
+ *
+ * Author: Gangqiao Kuang
+ *
+ * Copyright (c) 2021 JLSemi Corporation
+ */
+
+#ifndef _DT_BINDINGS_JLSEMI_PHY_H
+#define _DT_BINDINGS_JLSEMI_PHY_H
+
+/**************************** Linux Version Compatible ********************/
+#define JLSEMI_DEV_COMPATIBLE	(KERNEL_VERSION(4, 5, 0) > LINUX_VERSION_CODE)
+#define JL2XXX_GET_STRING	(KERNEL_VERSION(4, 5, 0) <= LINUX_VERSION_CODE)
+#define JL2XXX_GET_STAT		(KERNEL_VERSION(4, 5, 0) <= LINUX_VERSION_CODE)
+#define JL2XXX_PHY_TUNABLE	(KERNEL_VERSION(5, 0, 0) <= LINUX_VERSION_CODE)
+#define JLSEMI_PHY_WOL		(KERNEL_VERSION(3, 10, 0) < LINUX_VERSION_CODE)
+/*************************************************************************/
+
+/**************************** JLSemi Debug *******************************/
+#define JLSEMI_DEBUG_INFO	0
+/*************************************************************************/
+
+/************************* JLSemi Phy Init Reentrant *********************/
+#define JLSEMI_PHY_NOT_REENTRANT	false
+/*************************************************************************/
+
+/**************************** JL1XXX-LED *********************************/
+/* PHY LED Modes Select */
+#define JL1XXX_LED0_STRAP		(1 << 0)
+#define JL1XXX_LED0_EEE			(1 << 1)
+#define JL1XXX_LED0_100_ACTIVITY	(1 << 2)
+#define JL1XXX_LED0_10_ACTIVITY		(1 << 3)
+#define JL1XXX_LED0_100_LINK		(1 << 4)
+#define JL1XXX_LED0_10_LINK		(1 << 5)
+#define JL1XXX_LED1_STRAP		(1 << 8)
+#define JL1XXX_LED1_EEE			(1 << 9)
+#define JL1XXX_LED1_100_ACTIVITY	(1 << 10)
+#define JL1XXX_LED1_10_ACTIVITY		(1 << 11)
+#define JL1XXX_LED1_100_LINK		(1 << 12)
+#define JL1XXX_LED1_10_LINK		(1 << 13)
+
+/* PHY LED As Gpio Output Select */
+#define JL1XXX_GPIO_LED0_OUT		(1 << 2)
+#define JL1XXX_GPIO_LED1_OUT		(1 << 3)
+#define JL1XXX_GPIO_LED0_EN		(1 << 14)
+#define JL1XXX_GPIO_LED1_EN		(1 << 15)
+
+/* PHY LED Control Enable Mask Select */
+#define JL1XXX_LED_STATIC_OP_EN		(1 << 0)
+#define JL1XXX_LED_MODE_EN		(1 << 1)
+#define JL1XXX_LED_GLOABL_PERIOD_EN	(1 << 2)
+#define JL1XXX_LED_GLOBAL_ON_EN		(1 << 3)
+#define JL1XXX_LED_GPIO_OUT_EN		(1 << 4)
+//-----------------------------------------------------------------------//
+/* PHY LED Control Enable Mask Config */
+#define JL1XXX_LED_CTRL_EN	(0)
+
+/* PHY LED Modes Config */
+#define JL1XXX_CFG_LED_MODE	(JL1XXX_LED0_100_LINK | \
+				 JL1XXX_LED0_10_LINK | \
+				 JL1XXX_LED1_100_ACTIVITY | \
+				 JL1XXX_LED1_10_ACTIVITY)
+
+/* PHY LED As Gpio Output Config */
+#define JL1XXX_CFG_GPIO		(JL1XXX_GPIO_LED0_EN | \
+				 JL1XXX_GPIO_LED0_OUT | \
+				 JL1XXX_GPIO_LED1_EN | \
+				 JL1XXX_GPIO_LED1_OUT)
+
+/* PHY LED Global Period Config */
+#define JL1XXX_GLOBAL_PERIOD_MS		0x10
+
+/* PHY LED Global Hold On Config */
+#define JL1XXX_GLOBAL_ON_MS		0x8
+/**************************************************************************/
+
+/****************************** JL1XXX-WOL ********************************/
+/* PHY WOL Control Enable Mask Select */
+#define JL1XXX_WOL_STATIC_OP_EN		(1 << 0)
+//-----------------------------------------------------------------------//
+/* PHY WOL Control Enable Mask Config */
+#define JL1XXX_WOL_CTRL_EN	(0)
+
+/*************************************************************************/
+
+/***************************** JL1XXX-INTR *******************************/
+/* PHY Interrupt Control Enable Mask Select */
+#define JL1XXX_INTR_STATIC_OP_EN	(1 << 0)
+#define JL1XXX_INTR_LINK_CHANGE_EN	(1 << 1)
+#define JL1XXX_INTR_AN_ERR_EN		(1 << 2)
+//-----------------------------------------------------------------------//
+/* PHY Interrupt Irq Number Config */
+#define JL1XXX_INTR_IRQ			-1
+
+/* PHY Interrupt Control Enable Mask Config */
+#define JL1XXX_INTR_CTRL_EN	(0)
+/*************************************************************************/
+
+/**************************** JL1XXX-MDI *********************************/
+/* PHY MDI Control Mode Enable Mask Select */
+#define JL1XXX_MDI_STATIC_OP_EN		(1 << 0)
+#define JL1XXX_MDI_RATE_EN		(1 << 1)
+#define JL1XXX_MDI_AMPLITUDE_EN		(1 << 2)
+
+/* PHY MDI Rate Select */
+#define JL1XXX_MDI_RATE_STANDARD	0
+#define JL1XXX_MDI_RATE_ACCELERATE	1
+
+/* PHY MDI Amplitude Select */
+#define JL1XXX_MDI_AMPLITUDE0		0
+#define JL1XXX_MDI_AMPLITUDE1		1
+#define JL1XXX_MDI_AMPLITUDE2		2
+#define JL1XXX_MDI_AMPLITUDE3		3
+#define JL1XXX_MDI_AMPLITUDE4		4
+#define JL1XXX_MDI_AMPLITUDE5		5
+#define JL1XXX_MDI_AMPLITUDE6		6
+#define JL1XXX_MDI_AMPLITUDE7		7
+//-----------------------------------------------------------------------//
+/* PHY MDI Control Mode Enable Mask Config */
+#define JL1XXX_MDI_CTRL_EN		(0)
+
+/* PHY MDI Rate Config */
+#define JL1XXX_MDI_RATE			JL1XXX_MDI_RATE_ACCELERATE
+
+/* PHY MDI Amplitude Config */
+#define JL1XXX_MDI_AMPLITUDE		JL1XXX_MDI_AMPLITUDE4
+
+/*************************************************************************/
+
+/**************************** JL1XXX-RMII ********************************/
+/* PHY RMII Control Mode Enable Mask Select */
+#define JL1XXX_RMII_STATIC_OP_EN	(1 << 0)
+#define JL1XXX_RMII_MODE_EN		(1 << 1)
+#define JL1XXX_RMII_CLK_50M_INPUT_EN	(1 << 2)
+#define JL1XXX_RMII_TX_SKEW_EN		(1 << 3)
+#define JL1XXX_RMII_RX_SKEW_EN		(1 << 4)
+#define JL1XXX_RMII_CRS_DV_EN		(1 << 5)
+//-----------------------------------------------------------------------//
+/* PHY RMII Control Mode Enable Mask Config */
+#define JL1XXX_RMII_CTRL_EN		(0)
+
+/* PHY RMII Timing Config */
+#define JL1XXX_RMII_TX_TIMING		0xf
+#define JL1XXX_RMII_RX_TIMING		0xf
+
+/*************************************************************************/
+
+/**************************** JL2XXX-LED *********************************/
+/* PHY LED Modes Select*/
+#define JL2XXX_LED0_LINK10		(1 << 0)
+#define JL2XXX_LED0_LINK100		(1 << 1)
+#define JL2XXX_LED0_LINK1000		(1 << 3)
+#define JL2XXX_LED0_ACTIVITY		(1 << 4)
+#define JL2XXX_LED1_LINK10		(1 << 5)
+#define JL2XXX_LED1_LINK100		(1 << 6)
+#define JL2XXX_LED1_LINK1000		(1 << 8)
+#define JL2XXX_LED1_ACTIVITY		(1 << 9)
+#define JL2XXX_LED2_LINK10		(1 << 10)
+#define JL2XXX_LED2_LINK100		(1 << 11)
+#define JL2XXX_LED2_LINK1000		(1 << 13)
+#define JL2XXX_LED2_ACTIVITY		(1 << 14)
+/* mode_A = 0 and mode_B = 1 default mode_A */
+#define JL2XXX_LED_GLB_MODE_B		(1 << 15)
+
+/* PHY LED Polarity Select */
+#define JL2XXX_LED0_POLARITY		(1 << 12)
+#define JL2XXX_LED1_POLARITY		(1 << 11)
+#define JL2XXX_LED2_POLARITY		(1 << 10)
+
+/* PHY LED Control Enable Mask Select */
+#define JL2XXX_LED_STATIC_OP_EN		(1 << 0)
+#define JL2XXX_LED_MODE_EN		(1 << 1)
+#define JL2XXX_LED_GLOABL_PERIOD_EN	(1 << 2)
+#define JL2XXX_LED_GLOBAL_ON_EN		(1 << 3)
+#define JL2XXX_LED_POLARITY_EN		(1 << 4)
+
+//-----------------------------------------------------------------------//
+/* PHY LED Control Enable Mask Config */
+#define JL2XXX_LED_CTRL_EN	(0)
+
+/* PHY LED Modes Config */
+#define JL2XXX_CFG_LED_MODE	(JL2XXX_LED0_LINK10 | \
+				 JL2XXX_LED0_ACTIVITY | \
+				 JL2XXX_LED1_LINK100 | \
+				 JL2XXX_LED1_ACTIVITY | \
+				 JL2XXX_LED2_LINK1000 | \
+				 JL2XXX_LED2_ACTIVITY)
+
+/* PHY LED Polarity Config */
+#define JL2XXX_LED_POLARITY	(JL2XXX_LED0_POLARITY | \
+				 JL2XXX_LED1_POLARITY | \
+				 JL2XXX_LED2_POLARITY)
+
+/* PHY LED Global Period Config */
+#define JL2XXX_GLOBAL_PERIOD_MS		0x3
+
+/* PHY LED Global Hold On Config */
+#define JL2XXX_GLOBAL_ON_MS		0x2
+/*************************************************************************/
+
+/**************************** JL2XXX-FLD *********************************/
+/* PHY Fast Link Down Control Enable Mask Select */
+#define JL2XXX_FLD_STATIC_OP_EN		(1 << 0)
+//-----------------------------------------------------------------------//
+/* PHY Fast Link Down Control Enable Mask Config */
+#define JL2XXX_FLD_CTRL_EN		(0)
+
+/* PHY Fast Link Down Delay Config */
+#define JL2XXX_FLD_DELAY		0
+/*************************************************************************/
+
+/**************************** JL2XXX-WOL *********************************/
+/* PHY WOL Control Enable Mask Select */
+#define JL2XXX_WOL_STATIC_OP_EN		(1 << 0)
+
+//-----------------------------------------------------------------------//
+/* PHY WOL Control Enable Mask Config */
+#define JL2XXX_WOL_CTRL_EN	(0)
+/*************************************************************************/
+
+/**************************** JL2XXX-INTR ********************************/
+/* PHY Interrupt Control Enable Mask Select */
+#define JL2XXX_INTR_STATIC_OP_EN	(1 << 0)
+#define JL2XXX_INTR_LINK_CHANGE_EN	(1 << 1)
+#define JL2XXX_INTR_AN_ERR_EN		(1 << 2)
+#define JL2XXX_INTR_AN_COMPLETE_EN	(1 << 3)
+#define JL2XXX_INTR_AN_PAGE_RECE	(1 << 4)
+//-----------------------------------------------------------------------//
+/* PHY Interrupt Irq Number Config */
+#define JL2XXX_INTR_IRQ			-1
+
+/* PHY Interrupt Control Enable Mask Config */
+#define JL2XXX_INTR_CTRL_EN	(0)
+/*************************************************************************/
+
+/**************************** JL2XXX-DSFT ********************************/
+/* PHY Downshift Control Enable Mask */
+#define JL2XXX_DSFT_STATIC_OP_EN	(1 << 0)
+//-----------------------------------------------------------------------//
+/* PHY Downshift Control Enable Config */
+#define JL2XXX_DSFT_CTRL_EN	(0)
+
+/* PHY Downshift Count Config */
+#define JL2XXX_DSFT_AN_CNT		4
+/*************************************************************************/
+
+/**************************** JL2XXX-RGMII *******************************/
+/* PHY RGMII Control Mode Enable Mask Select */
+#define JL2XXX_RGMII_STATIC_OP_EN	(1 << 0)
+#define JL2XXX_RGMII_TX_DLY_EN		(1 << 1)
+#define JL2XXX_RGMII_RX_DLY_EN		(1 << 2)
+/* PHY RGMII DELAY BIT */
+#define JL2XXX_RGMII_TX_DLY_2NS		(1 << 8)
+#define JL2XXX_RGMII_RX_DLY_2NS		(1 << 9)
+//-----------------------------------------------------------------------//
+/* PHY RGMII Control Mode Enable Mask Config */
+#define JL2XXX_RGMII_CTRL_EN	(0)
+
+/*************************************************************************/
+
+/**************************** JL2XXX-PATCH *******************************/
+/* PHY Patch Control Mode Enable Mask Select */
+#define JL2XXX_PATCH_STATIC_OP_EN	(1 << 0)
+//-----------------------------------------------------------------------//
+/* PHY Patch Control Mode Enable Mask Config */
+#define JL2XXX_PATCH_CTRL_EN	(JL2XXX_PATCH_STATIC_OP_EN)
+
+/*************************************************************************/
+
+/**************************** JL2XXX-CLOCK *******************************/
+/* PHY Clock Control Mode Enable Mask Select */
+#define JL2XXX_CLK_STATIC_OP_EN		(1 << 0)
+#define JL2XXX_25M_CLK_OUT_EN		(1 << 1)
+#define JL2XXX_125M_CLK_OUT_EN		(1 << 2)
+#define JL2XXX_CLK_OUT_DIS		(1 << 3)
+//-----------------------------------------------------------------------//
+/* PHY Clock Control Mode Enable Mask Config */
+#define JL2XXX_CLK_CTRL_EN	(0)
+
+/*************************************************************************/
+
+/**************************** JL2XXX-WORK_MODE ***************************/
+/* PHY Work Mode Control Mode Enable Mask Select */
+#define JL2XXX_WORK_MODE_STATIC_OP_EN	(1 << 0)
+
+/* PHY Work Mode Select */
+#define JL2XXX_UTP_RGMII_MODE		0
+#define JL2XXX_FIBER_RGMII_MODE		1
+#define JL2XXX_UTP_FIBER_RGMII_MODE	2
+#define JL2XXX_UTP_SGMII_MODE		3
+#define JL2XXX_PHY_SGMII_RGMII_MODE	4
+#define JL2XXX_MAC_SGMII_RGMII_MODE	5
+#define JL2XXX_UTP_FIBER_FORCE_MODE1	6
+#define JL2XXX_UTP_FIBER_FORCE_MODE2	7
+//-----------------------------------------------------------------------//
+/* PHY Work Mode Control Mode Enable Mask Config */
+#define JL2XXX_WORK_MODE_CTRL_EN	(0)
+
+/* PHY Work Mode Config */
+#define JL2XXX_WORK_MODE_MODE		JL2XXX_UTP_RGMII_MODE
+
+/*************************************************************************/
+
+/**************************** JL2XXX-LOOPBACK ****************************/
+/* PHY Loopback Control Mode Enable Mask Select */
+#define JL2XXX_LPBK_STATIC_OP_EN	(1 << 0)
+
+/* PHY Loopback Mode Select */
+#define JL2XXX_LPBK_PCS_10M		0
+#define JL2XXX_LPBK_PCS_100M		1
+#define JL2XXX_LPBK_PCS_1000M		2
+#define JL2XXX_LPBK_PMD_1000M		3
+#define JL2XXX_LPBK_EXT_STUB_1000M	4
+//-----------------------------------------------------------------------//
+/* PHY Loopback Control Mode Enable Mask Config */
+#define JL2XXX_LPBK_CTRL_EN		(0)
+
+/* PHY Loopback Mode Config */
+#define JL2XXX_LPBK_MODE		JL2XXX_LPBK_PCS_1000M
+/*************************************************************************/
+
+/**************************** JL2XXX-SLEW_RATE ****************************/
+/* PHY Slew Rate Control Mode Enable Mask Select */
+#define JL2XXX_SLEW_RATE_STATIC_OP_EN	(1 << 0)
+//-----------------------------------------------------------------------//
+/* PHY Slew Rate Control Mode Enable Mask Config */
+#define JL2XXX_SLEW_RATE_CTRL_EN	(0)
+
+/*************************************************************************/
+
+/**************************** JL2XXX-RXC_OUT *****************************/
+/* PHY Rx Clock Out Control Mode Enable Mask Select */
+#define JL2XXX_RXC_OUT_STATIC_OP_EN	(1 << 0)
+//-----------------------------------------------------------------------//
+/* PHY Rx Clock Out Control Mode Enable Mask Config */
+#define JL2XXX_RXC_OUT_CTRL_EN		(0)
+
+/*************************************************************************/
+#endif
diff --git a/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/phy/jlsemi.c b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/phy/jlsemi.c
new file mode 100755
index 0000000..221ccd1
--- /dev/null
+++ b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/phy/jlsemi.c
@@ -0,0 +1,675 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * drivers/net/phy/jlsemi.c
+ *
+ * Driver for JLSemi PHYs
+ *
+ * Author: Gangqiao Kuang <gqkuang@jlsemi.com>
+ *
+ * Copyright (c) 2021 JingLue Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ *
+ */
+#include "jlsemi-core.h"
+#include <linux/phy.h>
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/gmac/gmac.h>
+
+#define DRIVER_VERSION		"1.2.16"
+#define DRIVER_NAME_100M	"JL1xxx Fast Ethernet " DRIVER_VERSION
+#define DRIVER_NAME_1000M	"JL2xxx Gigabit Ethernet " DRIVER_VERSION
+
+MODULE_DESCRIPTION("JLSemi PHY driver");
+MODULE_AUTHOR("Gangqiao Kuang");
+MODULE_LICENSE("GPL");
+
+static int phy_port_state =  0;
+extern void gmac_event_notify(GMAC_NOTIFY_EVENT notify_type, void* puf);
+
+#if (JLSEMI_DEBUG_INFO)
+static int jlsemi_phy_reg_print(struct phy_device *phydev)
+{
+	int ret;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(jl_phy); i++) {
+		if (jl_phy[i].enable) {
+			ret = jlsemi_read_paged(phydev, jl_phy[i].page,
+						jl_phy[i].reg);
+			JLSEMI_PHY_MSG("%s: 0x%x\n", jl_phy[i].string, ret);
+			if (ret < 0)
+				return ret;
+		}
+	}
+
+	return 0;
+}
+#endif
+
+static int jl1xxx_probe(struct phy_device *phydev)
+{
+	struct device *dev = jlsemi_get_mdio(phydev);
+	struct jl1xxx_priv *jl1xxx = NULL;
+	int err;
+
+    printk("cy: jl1xxx_probe begin\n");
+	jl1xxx = devm_kzalloc(dev, sizeof(*jl1xxx), GFP_KERNEL);
+	if (!jl1xxx)
+		return -ENOMEM;
+
+	phydev->priv = jl1xxx;
+
+#if (JLSEMI_KERNEL_DEVICE_TREE_USE)
+	if (!dev->of_node)
+		JLSEMI_PHY_MSG("%s: Find device node failed\n", __func__);
+#endif
+	err = jl1xxx_operation_args_get(phydev);
+	if (err < 0) {
+        //printk("cy: jl1xxx_operation_args_get fail\n");
+		return err;
+	}
+
+	if (jl1xxx->intr.enable & JL1XXX_INTR_STATIC_OP_EN)
+		phydev->irq = JL1XXX_INTR_IRQ;
+
+	jl1xxx->static_inited = false;
+
+    printk("cy: jl1xxx_probe success\n");
+	return 0;
+}
+
+static int jl1xxx_config_init(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+	int ret;
+
+    //printk("cy: jl1xxx_config_init begin\n");
+	if (!priv->static_inited) {
+#if (JLSEMI_DEBUG_INFO)
+		JLSEMI_PHY_MSG("jl1xxx_config_init_before:\n");
+		ret = jlsemi_phy_reg_print(phydev);
+		if (ret < 0)
+			return ret;
+#endif
+		ret = jl1xxx_static_op_init(phydev);
+		if (ret < 0)
+			return ret;
+#if (JLSEMI_DEBUG_INFO)
+		JLSEMI_PHY_MSG("jl1xxx_config_init_after:\n");
+		ret = jlsemi_phy_reg_print(phydev);
+		if (ret < 0)
+			return ret;
+#endif
+		priv->static_inited = JLSEMI_PHY_NOT_REENTRANT;
+	}
+
+	//ret = jlsemi_read_paged(phydev, 7, 16);
+    //printk("cy: jlsemi_read_paged 7 16 : %08x\n", ret);
+	//ret = ret & 0xefff;
+	//printk("cy: set to %08x\n", ret);
+	//jlsemi_set_bits(phydev, 7, 16, ret);
+	//mdelay(10);
+	//ret = jlsemi_read_paged(phydev, 7, 16);
+    //printk("cy: jlsemi_read_paged 7 16 : %08x\n", ret);
+    //printk("cy: jl1xxx_config_init success\n");
+	return 0;
+}
+
+static int jl1xxx_ack_interrupt(struct phy_device *phydev)
+{
+	int err;
+
+	err = jl1xxx_intr_ack_event(phydev);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+static int jl1xxx_config_intr(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+	int err;
+
+	if (priv->intr.enable & JL1XXX_INTR_STATIC_OP_EN) {
+		err = jl1xxx_ack_interrupt(phydev);
+		if (err < 0)
+			return err;
+
+		err = jl1xxx_intr_static_op_set(phydev);
+		if (err < 0)
+			return err;
+	}
+
+	return 0;
+}
+
+static int jl1xxx_read_status(struct phy_device *phydev)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+	int err, ret;
+
+    //printk("cy: jl1xxx_read_status begin\n");
+	if (priv->intr.enable & JL1XXX_INTR_STATIC_OP_EN) {
+		err = jl1xxx_ack_interrupt(phydev);
+		if (err < 0)
+			return err;
+	}
+
+	//ret = jlsemi_read_paged(phydev, 0, 5);
+    //printk("cy: jl1xxx_read_status 0 5 : %08x\n", ret);
+	ret = genphy_read_status(phydev);
+    //printk("cy: jl1xxx_read_status finish %d\n", ret);
+	return ret;
+}
+
+static int jl1xxx_private_proc(struct phy_device *phydev)
+{
+	int err = 0;
+	int i = 0;
+	int islink = 0;
+	int org_phy_status = 0;
+	int new_phy_status = 0;
+
+    //printk("cy: jl1xxx_private_proc begin\n");
+	if(phydev->bus == NULL)
+		return 0;
+
+	org_phy_status = phy_port_state;
+	//islink = jlsemi_read_paged(phydev, 7, 16);
+    //printk("cy: jlsemi_read_paged 7 16 : %08x\n", islink);
+	//islink = jlsemi_read_paged(phydev, 0, 0);
+    //printk("cy: jlsemi_read_paged 0 0 : %08x\n", islink);
+	islink = jlsemi_read_paged(phydev, 0, 1);
+    //printk("cy: jlsemi_read_paged 0 1 : %08x\n", islink);
+	islink = (islink & 0x4)?1:0;
+	//islink = 0;
+
+	phy_port_state = islink;
+	if(islink == 1)
+		new_phy_status = 1;
+
+	
+	//printk("port.1 linkstatus=%d. ",phy_port_state);
+
+	//printk("portlinkstatus=%d.\n",phydev->link);
+
+	if((org_phy_status == 0)&&(new_phy_status == 1))
+	{
+		printk("cy:  gmac_event_notify GMAC_ETH_PHY_PLUGIN\n");
+		gmac_event_notify(GMAC_ETH_PHY_PLUGIN, NULL);
+	}
+
+	if((org_phy_status == 1)&&(new_phy_status == 0))
+	{
+		printk("cy:  gmac_event_notify GMAC_ETH_PHY_PLUGOUT\n");
+		gmac_event_notify(GMAC_ETH_PHY_PLUGOUT, NULL);
+	}
+
+    //printk("cy: jl1xxx_private_proc %d\n", islink);
+	return err;
+}
+
+static void jl1xxx_remove(struct phy_device *phydev)
+{
+	struct device *dev = jlsemi_get_mdio(phydev);
+	struct jl1xxx_priv *priv = phydev->priv;
+
+	if (priv)
+		devm_kfree(dev, priv);
+}
+
+#if (JLSEMI_PHY_WOL)
+static void jl1xxx_get_wol(struct phy_device *phydev,
+			   struct ethtool_wolinfo *wol)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+	int wol_en;
+
+	if (priv->wol.ethtool) {
+		wol->supported = WAKE_MAGIC;
+		wol->wolopts = 0;
+
+		wol_en = jl1xxx_wol_dynamic_op_get(phydev);
+
+		if (!wol_en)
+			wol->wolopts |= WAKE_MAGIC;
+	}
+}
+
+static int jl1xxx_set_wol(struct phy_device *phydev,
+			  struct ethtool_wolinfo *wol)
+{
+	struct jl1xxx_priv *priv = phydev->priv;
+	int err;
+
+	if (priv->wol.ethtool) {
+		if (wol->wolopts & WAKE_MAGIC) {
+			err = jl1xxx_wol_dynamic_op_set(phydev);
+			if (err < 0)
+				return err;
+		}
+	}
+
+	return 0;
+}
+#endif
+
+static int jl1xxx_suspend(struct phy_device *phydev)
+{
+	return genphy_suspend(phydev);
+}
+
+static int jl1xxx_resume(struct phy_device *phydev)
+{
+	return genphy_resume(phydev);
+}
+
+static int jl2xxx_probe(struct phy_device *phydev)
+{
+	struct device *dev = jlsemi_get_mdio(phydev);
+	struct jl2xxx_priv *jl2xxx = NULL;
+	int err;
+
+    printk("cy: jl2xxx_probe begin\n");
+	jl2xxx = devm_kzalloc(dev, sizeof(*jl2xxx), GFP_KERNEL);
+	if (!jl2xxx)
+		return -ENOMEM;
+
+	phydev->priv = jl2xxx;
+
+#if (JLSEMI_KERNEL_DEVICE_TREE_USE)
+	if (!dev->of_node)
+		JLSEMI_PHY_MSG("%s: Find device node failed\n", __func__);
+#endif
+	err = jl2xxx_operation_args_get(phydev);
+	if (err < 0) {
+        printk("cy: jl2xxx_operation_args_get fail\n");
+		return err;
+	}
+
+	if (jl2xxx->intr.enable & JL2XXX_INTR_STATIC_OP_EN) {
+        printk("cy: intr.enable true\n");
+		phydev->irq = JL2XXX_INTR_IRQ;
+	}
+
+	jl2xxx->static_inited = false;
+	jl2xxx->nstats = ARRAY_SIZE(jl2xxx_hw_stats);
+	jl2xxx->hw_stats = jl2xxx_hw_stats;
+	jl2xxx->stats = kcalloc(jl2xxx->nstats, sizeof(u64), GFP_KERNEL);
+	if (!jl2xxx->stats) {
+        printk("cy: jl2xxx->stats fail\n");
+		return -ENOMEM;
+	}
+
+    printk("cy: jl2xxx_probe success\n");
+	return 0;
+}
+
+static int jl2xxx_config_init(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	int ret;
+
+	if (!priv->static_inited) {
+#if (JLSEMI_DEBUG_INFO)
+		JLSEMI_PHY_MSG("jl2xxx_config_init_before:\n");
+		ret = jlsemi_phy_reg_print(phydev);
+		if (ret < 0)
+			return ret;
+#endif
+		ret = jl2xxx_static_op_init(phydev);
+		if (ret < 0)
+			return ret;
+#if (JLSEMI_DEBUG_INFO)
+		JLSEMI_PHY_MSG("jl2xxx_config_init_after:\n");
+		ret = jlsemi_phy_reg_print(phydev);
+		if (ret < 0)
+			return ret;
+#endif
+		priv->static_inited = JLSEMI_PHY_NOT_REENTRANT;
+	}
+
+	return 0;
+}
+
+static int jl2xxx_ack_interrupt(struct phy_device *phydev)
+{
+	int err;
+
+	err = jl2xxx_intr_ack_event(phydev);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+static int jl2xxx_config_intr(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	int err;
+
+	if (priv->intr.enable & JL2XXX_INTR_STATIC_OP_EN) {
+		err = jl2xxx_ack_interrupt(phydev);
+		if (err < 0)
+			return err;
+
+		err = jl2xxx_intr_static_op_set(phydev);
+		if (err < 0)
+			return err;
+	}
+
+	return 0;
+}
+
+static int jl2xxx_read_status(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	bool fiber_mode;
+	int err;
+
+	if ((!priv->rxc_out.inited) &&
+	   (priv->rxc_out.enable & JL2XXX_RXC_OUT_STATIC_OP_EN) &&
+	   (priv->work_mode.mode == JL2XXX_MAC_SGMII_RGMII_MODE)) {
+		err = jlsemi_modify_paged_reg(phydev, JL2XXX_PAGE18,
+					      JL2XXX_WORK_MODE_REG,
+					      JL2XXX_WORK_MODE_MASK,
+					      priv->work_mode.mode);
+		if (err < 0)
+			return err;
+
+		err = jlsemi_soft_reset(phydev);
+		if (err < 0)
+			return err;
+		priv->rxc_out.inited = true;
+	}
+
+	if (priv->intr.enable & JL2XXX_INTR_STATIC_OP_EN) {
+		err = jl2xxx_ack_interrupt(phydev);
+		if (err < 0)
+			return err;
+	}
+
+	fiber_mode = jl2xxx_read_fiber_status(phydev);
+	if (fiber_mode)
+		return 0;
+
+	return genphy_read_status(phydev);
+}
+
+static int jl1xxx_config_aneg(struct phy_device *phydev)
+{
+	int ret;
+	ret = genphy_config_aneg(phydev);
+	printk("cy: jl1xxx_config_aneg %d\n", ret);
+	return ret;
+}
+
+static int jl2xxx_config_aneg(struct phy_device *phydev)
+{
+	u16 phy_mode;
+	int val;
+
+	val = jlsemi_read_paged(phydev, JL2XXX_PAGE18,
+				JL2XXX_WORK_MODE_REG);
+	phy_mode = val & JL2XXX_WORK_MODE_MASK;
+
+	if (((phy_mode == JL2XXX_FIBER_RGMII_MODE) ||
+	    (phy_mode == JL2XXX_UTP_FIBER_RGMII_MODE)))
+		return jl2xxx_config_aneg_fiber(phydev);
+
+	return genphy_config_aneg(phydev);
+}
+
+static int jl2xxx_suspend(struct phy_device *phydev)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+
+	/* clear wol event */
+	if (priv->wol.enable & JL2XXX_WOL_STATIC_OP_EN) {
+		jlsemi_set_bits(phydev, JL2XXX_WOL_STAS_PAGE,
+				JL2XXX_WOL_STAS_REG, JL2XXX_WOL_EVENT);
+		jlsemi_clear_bits(phydev, JL2XXX_WOL_STAS_PAGE,
+				  JL2XXX_WOL_STAS_REG, JL2XXX_WOL_EVENT);
+	}
+	return genphy_suspend(phydev);
+}
+
+static int jl2xxx_resume(struct phy_device *phydev)
+{
+	return genphy_resume(phydev);
+}
+
+#if (JLSEMI_PHY_WOL)
+static void jl2xxx_get_wol(struct phy_device *phydev,
+			   struct ethtool_wolinfo *wol)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	int wol_en;
+
+	if (priv->wol.ethtool) {
+		wol->supported = WAKE_MAGIC;
+		wol->wolopts = 0;
+
+		wol_en = jl2xxx_wol_dynamic_op_get(phydev);
+
+		if (wol_en)
+			wol->wolopts |= WAKE_MAGIC;
+	}
+}
+
+static int jl2xxx_set_wol(struct phy_device *phydev,
+			  struct ethtool_wolinfo *wol)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	int err;
+
+	if (priv->wol.ethtool) {
+		if (wol->wolopts & WAKE_MAGIC) {
+			err = jl2xxx_wol_dynamic_op_set(phydev);
+			if (err < 0)
+				return err;
+		}
+	}
+
+	return 0;
+}
+#endif
+
+#if (JL2XXX_PHY_TUNABLE)
+static int jl2xxx_get_tunable(struct phy_device *phydev,
+			      struct ethtool_tunable *tuna, void *data)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+
+	switch (tuna->id) {
+	case ETHTOOL_PHY_FAST_LINK_DOWN:
+		if (priv->fld.ethtool)
+			return jl2xxx_fld_dynamic_op_get(phydev, data);
+		else
+			return 0;
+	case ETHTOOL_PHY_DOWNSHIFT:
+		if (priv->downshift.ethtool)
+			return jl2xxx_downshift_dynamic_op_get(phydev, data);
+		else
+			return 0;
+	default:
+		return -EOPNOTSUPP;
+	}
+
+	return 0;
+}
+
+static int jl2xxx_set_tunable(struct phy_device *phydev,
+			      struct ethtool_tunable *tuna, const void *data)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+
+	switch (tuna->id) {
+	case ETHTOOL_PHY_FAST_LINK_DOWN:
+		if (priv->fld.ethtool)
+			return jl2xxx_fld_dynamic_op_set(phydev, data);
+		else
+			return 0;
+	case ETHTOOL_PHY_DOWNSHIFT:
+		if (priv->downshift.ethtool)
+			return jl2xxx_downshift_dynamic_op_set(phydev,
+							*(const u8 *)data);
+		else
+			return 0;
+	default:
+		return -EOPNOTSUPP;
+	}
+
+	return 0;
+}
+#endif
+
+#if (JL2XXX_GET_STAT)
+static u64 get_stat(struct phy_device *phydev, int i)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	int val;
+
+	val = jlsemi_read_paged(phydev, priv->hw_stats[i].page,
+				priv->hw_stats[i].reg);
+	if (val < 0)
+		return U64_MAX;
+
+	val = val & priv->hw_stats[i].mask;
+	priv->stats[i] += val;
+
+	return priv->stats[i];
+}
+
+static void jl2xxx_get_stats(struct phy_device *phydev,
+			    struct ethtool_stats *stats, u64 *data)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	int i;
+
+	if (!priv)
+		return;
+
+	for (i = 0; i < priv->nstats; i++)
+		data[i] = get_stat(phydev, i);
+}
+#endif
+
+#if (JL2XXX_GET_STRING)
+static void jl2xxx_get_strings(struct phy_device *phydev, u8 *data)
+{
+	struct jl2xxx_priv *priv = phydev->priv;
+	int i;
+
+	if (!priv)
+		return;
+
+	for (i = 0; i < priv->nstats; i++)
+		strlcpy(data + i * ETH_GSTRING_LEN,
+			priv->hw_stats[i].string, ETH_GSTRING_LEN);
+}
+#endif
+
+static void jl2xxx_remove(struct phy_device *phydev)
+{
+	struct device *dev = jlsemi_get_mdio(phydev);
+	struct jl2xxx_priv *priv = phydev->priv;
+
+	kfree(priv->stats);
+	if (priv)
+		devm_kfree(dev, priv);
+}
+
+static inline int jlsemi_aneg_done(struct phy_device *phydev)
+{
+	int retval = phy_read(phydev, MII_BMSR);
+
+	return (retval < 0) ? retval : (retval & BMSR_ANEGCOMPLETE);
+}
+
+static int jl2xxx_aneg_done(struct phy_device *phydev)
+{
+	u16 phy_mode;
+	int val;
+
+	val = jlsemi_read_paged(phydev, JL2XXX_PAGE18,
+				JL2XXX_WORK_MODE_REG);
+	phy_mode = val & JL2XXX_WORK_MODE_MASK;
+
+	// fiber not an complite
+	if (((phy_mode == JL2XXX_FIBER_RGMII_MODE) ||
+	    (phy_mode == JL2XXX_UTP_FIBER_RGMII_MODE)))
+		return BMSR_ANEGCOMPLETE;
+
+	return jlsemi_aneg_done(phydev);
+}
+
+static struct phy_driver jlsemi_drivers[] = {
+	{
+		.phy_id			= JL1XXX_PHY_ID,
+		.phy_id_mask	= JLSEMI_PHY_ID_MASK,
+		.name			= DRIVER_NAME_100M,
+		/* PHY_BASIC_FEATURES */
+		.features		= PHY_BASIC_FEATURES,
+		.probe			= jl1xxx_probe,
+		//.config_intr	= jl1xxx_config_intr,
+		.read_status	= jl1xxx_read_status,
+		.config_init	= jl1xxx_config_init,
+		.config_aneg	= jl1xxx_config_aneg,
+		//.aneg_done		= jlsemi_aneg_done,
+		.private_proc	= jl1xxx_private_proc,
+		.suspend		= jl1xxx_suspend,
+		.resume			= jl1xxx_resume,
+		.remove			= jl1xxx_remove,
+#if (JLSEMI_PHY_WOL)
+		.get_wol		= jl1xxx_get_wol,
+		.set_wol		= jl1xxx_set_wol,
+#endif
+	},
+	{
+		.phy_id			= JL2XXX_PHY_ID,
+		.phy_id_mask	= JLSEMI_PHY_ID_MASK,
+		.name			= DRIVER_NAME_1000M,
+		/* PHY_BASIC_FEATURES */
+		.features		= PHY_GBIT_FEATURES,
+		.probe			= jl2xxx_probe,
+		.config_intr	= jl2xxx_config_intr,
+		.read_status	= jl2xxx_read_status,
+		.config_init	= jl2xxx_config_init,
+		.config_aneg	= jl2xxx_config_aneg,
+		//.aneg_done		= jl2xxx_aneg_done,
+		.suspend		= jl2xxx_suspend,
+		.resume			= jl2xxx_resume,
+		.remove			= jl2xxx_remove,
+#if (JLSEMI_PHY_WOL)
+		.get_wol		= jl2xxx_get_wol,
+		.set_wol		= jl2xxx_set_wol,
+#endif
+#if (JL2XXX_PHY_TUNABLE)
+		.get_tunable	= jl2xxx_get_tunable,
+		.set_tunable	= jl2xxx_set_tunable,
+#endif
+#if (JL2XXX_GET_STAT)
+		.get_stats		= jl2xxx_get_stats,
+#endif
+#if (JL2XXX_GET_STRING)
+		.get_strings	= jl2xxx_get_strings,
+#endif
+	},
+};
+
+module_jlsemi_driver(jlsemi_drivers);
+
+static struct mdio_device_id __maybe_unused jlsemi_tbl[] = {
+	{JL1XXX_PHY_ID, JLSEMI_PHY_ID_MASK},
+	{JL2XXX_PHY_ID, JLSEMI_PHY_ID_MASK},
+	{ }
+};
+
+MODULE_DEVICE_TABLE(mdio, jlsemi_tbl);
diff --git a/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/wireless/rtl8192cd_92es_wpa2/8192cd_ioctl.c b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/wireless/rtl8192cd_92es_wpa2/8192cd_ioctl.c
new file mode 100755
index 0000000..4454611
--- /dev/null
+++ b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/wireless/rtl8192cd_92es_wpa2/8192cd_ioctl.c
@@ -0,0 +1,11557 @@
+/*
+ *  io-control handling routines
+ *
+ *  $Id: 8192cd_ioctl.c,v 1.36.2.14 2011/01/06 07:50:09 button Exp $
+ *
+ *  Copyright (c) 2009 Realtek Semiconductor Corp.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+
+#define _8192CD_IOCTL_C_
+
+#ifdef __KERNEL__
+#include <linux/module.h>
+#include <linux/init.h>
+#include <asm/uaccess.h>
+#include <linux/unistd.h>
+#include <linux/file.h>
+#include <linux/fs.h>
+#include <linux/delay.h>
+#elif defined(__ECOS)
+#include <cyg/io/eth/rltk/819x/wrapper/sys_support.h>
+#include <cyg/io/eth/rltk/819x/wrapper/skbuff.h>
+#include <cyg/io/eth/rltk/819x/wrapper/timer.h>
+#include <cyg/io/eth/rltk/819x/wrapper/wrapper.h>
+#endif
+
+#include "./8192cd_cfg.h"
+
+#ifdef __LINUX_2_6__
+#include <linux/initrd.h>
+#include <linux/syscalls.h>
+#endif
+
+#if !defined(__KERNEL__) && !defined(__ECOS)
+#include "./sys-support.h"
+#endif
+
+#include "./8192cd_headers.h"
+#include "./8192cd_debug.h"
+
+#ifdef CONFIG_RTL_COMAPI_WLTOOLS
+#include <linux/if_arp.h>
+#include <net/iw_handler.h>
+#include "./8192cd_comapi.h"
+#endif
+#ifdef CONFIG_RTK_MESH
+// for commu with  802.11s path selection deamon;plus note
+#include "../mesh_ext/mesh_route.h"
+#include "../mesh_ext/hash_table.h"
+#endif
+
+#if defined(WIFI_HAPD) || defined(RTK_NL80211)
+#include <linux/wireless.h>
+#include "net80211/ieee80211.h"
+#include "net80211/ieee80211_crypto.h"
+#include "net80211/ieee80211_ioctl.h"
+#include "./8192cd_net80211.h"
+
+#ifdef RTK_NL80211
+#include "8192cd_cfg80211.h" 
+#endif
+
+#define HAPD_IOCTL_SETCONFIG	SIOCIWLASTPRIV //0x8BFF
+#endif
+
+#ifdef WIFI_WPAS
+#define WPAS_IOCTL_CUSTOM		SIOCIWLASTPRIV //0x8BFF
+#endif
+
+
+#define RTL8192CD_IOCTL_SET_MIB				(SIOCDEVPRIVATE + 0x1)	// 0x89f1
+#define RTL8192CD_IOCTL_GET_MIB				(SIOCDEVPRIVATE + 0x2)	// 0x89f2
+#define RTL8192CD_IOCTL_WRITE_REG				(SIOCDEVPRIVATE + 0x3)	// 0x89f3
+#define RTL8192CD_IOCTL_READ_REG				(SIOCDEVPRIVATE + 0x4)	// 0x89f4
+#define RTL8192CD_IOCTL_WRITE_MEM				(SIOCDEVPRIVATE + 0x5)	// 0x89f5
+#define RTL8192CD_IOCTL_READ_MEM				(SIOCDEVPRIVATE + 0x6)	// 0x89f6
+#define RTL8192CD_IOCTL_DEL_STA				(SIOCDEVPRIVATE + 0x7)	// 0x89f7
+#define RTL8192CD_IOCTL_WRITE_EEPROM			(SIOCDEVPRIVATE + 0x8)	// 0x89f8
+#define RTL8192CD_IOCTL_READ_EEPROM			(SIOCDEVPRIVATE + 0x9)	// 0x89f9
+#define RTL8192CD_IOCTL_WRITE_BB_REG			(SIOCDEVPRIVATE + 0xa)	// 0x89fa
+#define RTL8192CD_IOCTL_READ_BB_REG			(SIOCDEVPRIVATE + 0xb)	// 0x89fb
+#define RTL8192CD_IOCTL_WRITE_RF_REG			(SIOCDEVPRIVATE + 0xc)	// 0x89fc
+#define RTL8192CD_IOCTL_READ_RF_REG			(SIOCDEVPRIVATE + 0xd)	// 0x89fd
+#define RTL8192CD_IOCTL_USER_DAEMON_REQUEST	(SIOCDEVPRIVATE + 0xf)	// 0x89ff
+
+#ifdef	CONFIG_RTK_MESH
+#define RTL8192CD_IOCTL_STATIC_ROUTE			(SIOCDEVPRIVATE + 0xe)
+#define RTL8192CD_IOCTL_MANUAL_METRIC			0x8BCA
+#endif
+#define RTL8192CD_IOCTL_SHOWSC			        0x8BCD
+
+
+#define SIOCGIWRTLSTAINFO		0x8B30
+#define SIOCGIWRTLSTANUM		0x8B31
+#define SIOCGIWRTLDRVVERSION	0x8B32
+#define SIOCGIWRTLSCANREQ		0x8B33
+#define SIOCGIWRTLGETBSSDB		0x8B34
+#define SIOCGIWRTLJOINREQ		0x8B35
+#define SIOCGIWRTLJOINREQSTATUS	0x8B36
+#define SIOCGIWRTLGETBSSINFO	0x8B37
+#ifdef WDS
+#define SIOCGIWRTLGETWDSINFO	0x8B38
+#endif
+#define SIOCSIWRTLSTATXRATE		0x8B39
+#ifdef MICERR_TEST
+#define SIOCSIWRTLMICERROR		0x8B3A
+#define SIOCSIWRTLMICREPORT		0x8B3B
+#endif
+#ifdef SUPPORT_SNMP_MIB
+#define SIOCGSNMPMIB			0x8B3D
+#endif
+#ifdef USE_PID_NOTIFY
+#define SIOCSIWRTLSETPID		0x8B3E
+#endif
+#ifdef CONFIG_RTL_WAPI_SUPPORT
+#define SIOCSIWRTLSETWAPIPID		0x8B3F
+#endif
+#define SIOCSMIBDATA	0x8B41
+#define SIOCMIBINIT		0x8B42
+#define SIOCMIBSYNC		0x8B43
+#define SIOCGMIBDATA	0x8B44
+#define SIOCSACLADD		0x8B45
+#define SIOCSACLDEL		0x8B46
+#define SIOCSACLQUERY	0x8B47
+
+#define SIOCGMISCDATA	0x8B48
+
+#ifdef RTK_WOW
+#define SIOCGRTKWOW		0x8B49
+#define SIOCGRTKWOWSTAINFO		0x8B5A
+#endif
+
+#define SIOCSRFPWRADJ	0x8B5B
+#ifdef AUTO_TEST_SUPPORT
+#define SIOCSSREQ		0x8B5C
+#define SIOCJOINREQ		0x8B5D
+#endif
+#ifdef MCR_WIRELESS_EXTEND
+#ifdef CONFIG_WLAN_HAL_8814AE
+#define SIORXANTSELECT	0x8B5E
+#endif
+#endif
+#ifdef BT_COEXIST
+#define SIOBTCH2C 		0x8B60
+#endif
+#ifdef MP_TEST
+#define MP_START_TEST	0x8B61
+#define MP_STOP_TEST	0x8B62
+#define MP_SET_RATE		0x8B63
+#define MP_SET_CHANNEL	0x8B64
+#define MP_SET_TXPOWER	0x8B65
+#define MP_CONTIOUS_TX	0x8B66
+#define MP_ARX			0x8B67
+#define MP_SET_BSSID	0x8B68
+#define MP_ANTENNA_TX	0x8B69
+#define MP_ANTENNA_RX	0x8B6A
+#define MP_SET_BANDWIDTH 0x8B6B
+#define MP_SET_PHYPARA	0x8B6C
+#define MP_QUERY_STATS 	0x8B6D
+#define MP_TXPWR_TRACK	0x8B6E
+#define MP_QUERY_TSSI	0x8B6F
+#define MP_QUERY_THER	0x8B77
+#if defined(CONFIG_RTL_92D_SUPPORT) || defined(CONFIG_RTL_8812_SUPPORT) || defined(CONFIG_WLAN_HAL_8881A)
+#define MP_SET_BAND		0x8B85
+#endif
+#define MP_RESET_STATS	0x8B86
+#define MP_GET_TXPOWER	0x8B87
+#if defined(CONFIG_RTL_8812_SUPPORT)
+#define MP_DIG			0x8B88
+#endif
+#ifdef B2B_TEST
+// set/get convention: set(even number) get (odd number)
+#define MP_TX_PACKET	0x8B71
+#define MP_RX_PACKET	0x8B70
+#define MP_BRX_PACKET	0x8B73
+#endif
+
+#endif // MP_TEST
+
+#if (defined(SW_ANT_SWITCH) || defined(HW_ANT_SWITCH)) 
+#define SIOCANTSELECT	0x8b9d
+#endif
+
+#define SIOCGIWRTLREGDUMP		0x8B78
+
+#if defined(MBSSID) || defined(UNIVERSAL_REPEATER)
+#define SIOCSICOPYMIB			0x8B79
+#endif
+
+#ifdef SUPPORT_TX_MCAST2UNI
+#define SIOCGIMCAST_ADD			0x8B80
+#define SIOCGIMCAST_DEL			0x8B81
+#endif
+
+#ifdef CONFIG_RTL8186_KB
+#define SIOCGIREADGUESTMAC		0x8B82
+#define SIOCSIWRTGUESTMAC		0x8B83
+#endif
+
+#if defined(CONFIG_RTL8186_KB_N)
+#define SIOCGIWRTLAUTH			0x8B84//To get wireless auth result
+#endif
+
+#ifdef MULTI_MAC_CLONE
+#define SIOCSIMCLONE			0x8B8a
+#define SIOCGIMCLONE			0x8B8b
+#define SIOCSIMCLONE_DEL		0x8B8c  // io come from user space
+#define SIOCSIMCLONE_DEL2		0x8B8d  // io come from bridge 
+#endif
+
+
+#define SIOCRADIOOFF		0x8B8E
+
+#if defined(PCIE_POWER_SAVING) || defined(RF_MIMO_SWITCH) || defined(RF_MIMO_PS)
+#define SIOCEPDN		0x8B8F
+#endif
+
+#ifdef EN_EFUSE
+#define SIOCEFUSE_GET 		0x8b9b
+#define SIOCEFUSE_SET 		0x8b9a
+#define SIOCEFUSE_SYNC 		0x8b9c
+#endif
+
+#define SIOCANTSTS              0x8b9d
+#define SIOCACS                 0x8b9f
+
+#ifdef P2P_SUPPORT
+#define SIOCP2PCMD			0x8BD1  // command for p2p 
+#define SIOCP2PSCANREQ		0x8BD2	// issue p2p discovery request
+#define SIOCP2PGETRESULT	0x8BD3	// get p2p discovery result
+#define SIOCP2PPROVREQ		0x8BD4	// issue provision discovery request
+#define SIOCP2WSCMETHODCONF	0x8BD5	// report event and state
+#define SIOCP2PPGETEVNIND	0x8BD6	// get event and state
+
+#define SIOCP2P_WSC_REPORT_STATE			0x8BD7
+#define SIOCP2P_REPORT_CLIENT_STATE			0x8BD8	// report client connect state
+#endif
+
+#define SIOCSTOPPS              0x8b90
+#ifdef BR_SHORTCUT
+#define SIOCLEARBRSC		0x8B91
+#define SIOCLONEEARBRSC		0x8B92
+#endif
+
+#ifdef D_ACL//tsananiu
+#define RTL8192CD_IOCTL_ADD_ACL_TABLE		0x8B96
+#define RTL8192CD_IOCTL_REMOVE_ACL_TABLE	0x8B97
+#define RTL8192CD_IOCTL_GET_ACL_TABLE		0x8B98
+#define RTL8192CD_IOCTL_CLEAR_ACL_TABLE		0x8B9E
+#define ACL_allow 1
+#define ACL_deny 2
+#endif//tsananiu//d
+
+#ifdef	CONFIG_RTK_MESH
+
+#ifdef _11s_TEST_MODE_
+#define SAVE_RECEIBVER_PID 			0x8B92 //PID ioctl
+#define DEQUEUE_RECEIBVER_IOCTL 	0x8B93 //DEQUEUE ioctl
+#endif
+// ==== inserted by GANTOE for manual site survey 2008/12/25 ====
+#define SIOCJOINMESH 				0x8B94
+#define SIOCCHECKMESHLINK			0x8B95	// This OID might be removed when the mesh peerlink precedure has been completed
+// GANTOE
+
+
+
+#define SIOCQPATHTABLE  0x8BA0  // query pathselection table
+#define SIOCUPATHTABLE  0x8BA1  // update  existing entry's date in pathselection table
+#define SIOCAPATHTABLE  0x8BA2  // add a new entry into pathselection table
+
+#define GET_STA_LIST 			0x8BA6
+#define SET_PORTAL_POOL 		0x8BA8
+#define SIOC_NOTIFY_PATH_CREATE 0x8BA9 // path selection daemon notify dirver that the path to des mac has created
+#define SIOC_UPDATE_ROOT_INFO 	0x8BAA // update root mac into driver
+#define SIOC_GET_ROUTING_INFO	0x8BAB // send routing info to user space
+#define REMOVE_PATH_ENTRY		0x8BAC // remove specified path entry
+#define SIOC_SET_ROUTING_INFO	0x8BAD // set MESH routing info from user space
+
+#define SAVEPID_IOCTL			0x8BB0   //PID ioctl
+#define DEQUEUEDATA_IOCTL		0x8BB1   //DEQUEUE ioctl
+
+#ifdef _MESH_ACL_ENABLE_
+#define SIOCSMESHACLADD		0x8BB5
+#define SIOCSMESHACLDEL		0x8BB6
+#define SIOCSMESHACLQUERY	0x8BB7
+#endif
+
+#define SIOCSMESHPXADD	0x8BB8
+#define SIOCSMESHPXDEL	0x8BB9
+
+#endif // CONFIG_RTK_MESH
+
+#define SIOC92DAUTOCH	0x8BC5 // manual auto channel
+
+#if defined(CONFIG_OFFLOAD_FUNCTION) || defined(SDIO_AP_OFFLOAD)
+#define SIOOFFLOADTEST	0x8BC6
+#endif
+
+#ifdef CONFIG_8814_AP_MAC_VERI
+#define SIO_8814_AP_MAC_VERI    0x8BC8
+#endif //#ifdef CONFIG_8814_AP_MAC_VERI
+
+
+#ifdef CONFIG_RTL_COMAPI_CFGFILE
+#define SIOCCOMAPIFILE		0x8BC0
+#endif
+#ifdef CONFIG_RTL_92D_SUPPORT
+#define SIOC92DIQK		0x8BC1
+#ifdef EN_EFUSE
+#define SIOC92DSBANDADDR 0x8BC4 // set hwaddr by band
+#endif
+#ifdef NON_INTR_ANTDIV
+#define SIOC92DATNDIV	0x8BC6 // set hwaddr by band
+#endif
+#ifdef DPK_92D
+#define SIOC92DDPK	0x8BC7 // dpk
+#endif
+#endif
+
+#ifdef MP_PSD_SUPPORT
+#define MP_QUERY_PSD  		0x8BC9
+#endif
+
+#if defined(RTK_AC_SUPPORT) || defined(HS2_SUPPORT) || defined(CONFIG_IEEE80211W)
+/* SIOC8812SIGMA for Hotsport 2.0 Release 1 */
+#define SIOC8812SIGMA 0x8BCB
+#endif
+
+#if defined(RTK_AC_SUPPORT)
+#define SIOC8812SIGMATB 0x8BCC
+#endif
+
+#define SIOCRESETNOPCHANNEL 0x8BCE
+#define SIOCTXPWRAPPLY 0x8BCF
+
+#ifdef DOT11K
+#define SIOC11KLINKREQ		0x8BD0
+#define SIOC11KLINKREP		0x8BD1
+#define SIOC11KBEACONREQ	0x8BD2
+#define SIOC11KBEACONREP	0x8BD3
+#define SIOC11KNEIGHBORREQ	0x8BD4
+#define SIOC11KNEIGHBORRSP	0x8BD5
+#ifdef CONFIG_IEEE80211V
+#define SIOC11VBSSTRANSREQ	0x8BF5
+#endif
+#endif
+
+#define _OFFSET(field)	((int)(long *)&(((struct wifi_mib *)0)->field))
+#define _SIZE(field)	sizeof(((struct wifi_mib *)0)->field)
+
+#define _OFFSET_RFFT(field)	((int)(long *)&(((struct rf_finetune_var *)0)->field))
+#define _SIZE_RFFT(field)	sizeof(((struct rf_finetune_var *)0)->field)
+
+
+#ifdef USE_OUT_SRC
+#define ODEBUG(fmt, args...) printk("odm[%s %d]"fmt,__FUNCTION__,__LINE__,## args)
+#define _OFFSET_ODM_DM(field)	((int)(long *)&((( struct DM_Out_Source_Dynamic_Mechanism_Structure *)0)->field))
+#define _SIZE_ODM_DM(field)	sizeof((( struct DM_Out_Source_Dynamic_Mechanism_Structure *)0)->field)
+#endif
+
+#if defined (NOT_RTK_BSP) && defined(SMP_SYNC) && defined(__KERNEL__)
+unsigned long _ioctl_copy_from_user (struct rtl8192cd_priv *priv, void * to, const void * from, unsigned long n);
+unsigned long _ioctl_copy_to_user (struct rtl8192cd_priv *priv, void * to, const void * from, unsigned long n);
+#endif
+
+#ifdef HANDLE_TX_THREAD_ZTE
+ void rtl81xxes_xmit_kick_thread(struct rtl8192cd_priv *priv)
+{
+	struct priv_shared_info *pshare = priv->pshare;
+	if(!test_and_set_bit(1, &pshare->tx_thread_flag))
+		up(&pshare->tx_thread_sema);
+}
+
+void rtl81xxes_wake_event_xmit_thread(struct rtl8192cd_priv *priv)
+{
+	struct priv_shared_info *pshare = priv->pshare;
+	if (test_and_set_bit(WAKE_EVENT_XMIT, &pshare->wake_event) == 0)
+		wake_up_process(pshare->xmit_thread);
+}
+#endif
+typedef enum {BYTE_T, INT_T, SSID_STRING_T, BYTE_ARRAY_T, ACL_T, IDX_BYTE_ARRAY_T, MULTI_BYTE_T,
+#ifdef _DEBUG_RTL8192CD_
+		DEBUG_T,
+#endif
+	DEF_SSID_STRING_T, STRING_T, RFFT_T, VARLEN_BYTE_T,
+#ifdef WIFI_SIMPLE_CONFIG
+	PIN_IND_T,
+	/* WPS2DOTX   */
+	WSC_SELF_PIN_IND_T,
+	WSC_SEPC_SSID_CONN_IND_T,	
+	WSC_SEPC_MAC_CONN_IND_T,	
+	/* WPS2DOTX   */
+#ifdef INCLUDE_WPS
+#ifndef CONFIG_MSC
+	WSC_IND_T,
+#endif
+	FLASH_RESTORE_T,
+#endif
+
+#ifdef CONFIG_RTL_COMAPI_CFGFILE
+	WSC_START_IND_T,
+	//EV_MODE, EV_STATUS, EV_MEHOD, EV_STEP, EV_OOB
+	WSC_MODE_IND_T,
+	WSC_STATUS_IND_T,
+	WSC_METHOD_IND_T,
+	WSC_STEP_IND_T,
+	WSC_OOB_IND_T,
+#endif  //ifdef CONFIG_RTL_COMAPI_CFGFILE
+#endif
+#ifdef CONFIG_RTK_MESH
+	WORD_T,
+#endif
+	ACL_INT_T,	// mac address + 1 int
+#ifdef CONFIG_RTL_WAPI_SUPPORT
+	INT_ARRAY_T,
+	WAPI_KEY_T,
+#endif
+#ifdef CONFIG_RTL_COMAPI_CFGFILE
+	SSID2SCAN_STRING_T,
+#endif
+	RFFT_ACL_T,
+#ifdef SUPPORT_MULTI_PROFILE
+	AP_PROFILE_T,
+#endif
+
+#ifdef SWITCH_CHAN
+	SWITCH_CHAN_T,
+#endif
+#ifdef USE_OUT_SRC
+	ODM_DM_1UT,
+	ODM_DM_2UT,
+	ODM_DM_4UT,
+	ODM_DM_8UT,	
+#endif
+} TYPE_T;
+
+
+struct iw_priv_args privtab[] = {
+	{ RTL8192CD_IOCTL_SET_MIB, IW_PRIV_TYPE_CHAR | 450, 0, "set_mib" },
+	{ RTL8192CD_IOCTL_GET_MIB, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_BYTE | 128, "get_mib" },
+#ifdef _IOCTL_DEBUG_CMD_
+	{ RTL8192CD_IOCTL_WRITE_REG, IW_PRIV_TYPE_CHAR | 128, 0, "write_reg" },
+	{ RTL8192CD_IOCTL_READ_REG, IW_PRIV_TYPE_CHAR | 128, IW_PRIV_TYPE_BYTE | 128, "read_reg" },
+	{ RTL8192CD_IOCTL_WRITE_MEM, IW_PRIV_TYPE_CHAR | 128, 0, "write_mem" },
+	{ RTL8192CD_IOCTL_READ_MEM, IW_PRIV_TYPE_CHAR | 128, IW_PRIV_TYPE_BYTE | 128, "read_mem" },
+	{ RTL8192CD_IOCTL_WRITE_BB_REG, IW_PRIV_TYPE_CHAR | 128, 0, "write_bb" },
+	{ RTL8192CD_IOCTL_READ_BB_REG, IW_PRIV_TYPE_CHAR | 128, IW_PRIV_TYPE_BYTE | 128, "read_bb" },
+	{ RTL8192CD_IOCTL_WRITE_RF_REG, IW_PRIV_TYPE_CHAR | 128, 0, "write_rf" },
+	{ RTL8192CD_IOCTL_READ_RF_REG, IW_PRIV_TYPE_CHAR | 128, IW_PRIV_TYPE_BYTE | 128, "read_rf" },
+#endif
+	{ RTL8192CD_IOCTL_DEL_STA, IW_PRIV_TYPE_CHAR | 128, 0, "del_sta" },
+	{ RTL8192CD_IOCTL_WRITE_EEPROM, IW_PRIV_TYPE_CHAR | 128, 0, "write_eeprom" },
+	{ RTL8192CD_IOCTL_READ_EEPROM, IW_PRIV_TYPE_CHAR | 128, IW_PRIV_TYPE_BYTE | 128, "read_eeprom" },
+
+#ifdef SUPPORT_SNMP_MIB
+	{ SIOCGSNMPMIB, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_BYTE | 128, "get_snmp_mib" },
+#endif
+
+	{ SIOCSRFPWRADJ, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_CHAR | 128, "rf_pwr" },
+#ifdef AUTO_TEST_SUPPORT
+	{ SIOCSSREQ, IW_PRIV_TYPE_NONE,0,"at_ss" },
+	{ SIOCJOINREQ, IW_PRIV_TYPE_CHAR|40,0,"at_join" },
+#endif
+#ifdef MCR_WIRELESS_EXTEND
+#ifdef CONFIG_WLAN_HAL_8814AE
+	{ SIORXANTSELECT, IW_PRIV_TYPE_CHAR | 40, 0, "set_ant_rx" },
+#endif	
+#endif
+#ifdef CONFIG_RTL_COMAPI_CFGFILE
+	{ SIOCCOMAPIFILE, IW_PRIV_TYPE_NONE, 0, "cfgfile" },
+#endif
+
+#ifdef MP_TEST
+	{ MP_START_TEST, IW_PRIV_TYPE_NONE, 0, "mp_start" },
+	{ MP_STOP_TEST, IW_PRIV_TYPE_NONE, 0, "mp_stop" },
+	{ MP_SET_RATE, IW_PRIV_TYPE_CHAR | 40, 0, "mp_rate" },
+	{ MP_SET_CHANNEL, IW_PRIV_TYPE_CHAR | 40, 0, "mp_channel" },
+	{ MP_SET_TXPOWER, IW_PRIV_TYPE_CHAR | 40, 0, "mp_txpower" },
+	{ MP_CONTIOUS_TX, IW_PRIV_TYPE_CHAR | 128, 0, "mp_ctx" },
+	{ MP_ARX, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_CHAR | 128, "mp_arx" },
+	{ MP_SET_BSSID, IW_PRIV_TYPE_CHAR | 40, 0, "mp_bssid" },
+	{ MP_ANTENNA_TX, IW_PRIV_TYPE_CHAR | 40, 0, "mp_ant_tx" },
+	{ MP_ANTENNA_RX, IW_PRIV_TYPE_CHAR | 40, 0, "mp_ant_rx" },
+	{ MP_SET_BANDWIDTH, IW_PRIV_TYPE_CHAR | 40, 0, "mp_bandwidth" },
+	{ MP_SET_PHYPARA, IW_PRIV_TYPE_CHAR | 40, 0, "mp_phypara" },
+#ifdef B2B_TEST
+	{ MP_TX_PACKET, IW_PRIV_TYPE_CHAR | 128, IW_PRIV_TYPE_CHAR | 128, "mp_tx" },
+	{ MP_BRX_PACKET, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_CHAR | 128, "mp_brx" },
+#if 0
+	{ MP_RX_PACKET, IW_PRIV_TYPE_CHAR | 40, 0, "mp_rx" },
+#endif
+#endif
+	{ MP_QUERY_STATS, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_CHAR | 128, "mp_query" },
+	{ MP_TXPWR_TRACK, IW_PRIV_TYPE_CHAR | 40, 0, "mp_pwrtrk" },
+	{ MP_QUERY_TSSI, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_CHAR | 128, "mp_tssi" },
+#ifdef MP_PSD_SUPPORT
+	{ MP_QUERY_PSD, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_CHAR | 128, "mp_psd" },
+#endif
+	{ MP_QUERY_THER, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_CHAR | 128, "mp_ther" },
+#ifdef CONFIG_RTL_92D_SUPPORT
+	{ MP_SET_BAND, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_CHAR | 128, "mp_phyband" },
+#endif
+	{ MP_RESET_STATS, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_CHAR | 128, "mp_reset_stats" },
+	{ MP_GET_TXPOWER, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_CHAR | 128, "mp_get_pwr" },
+#if 	defined(CONFIG_RTL_8812_SUPPORT)		
+	{ MP_DIG, IW_PRIV_TYPE_CHAR | 40, 0, "mp_dig" },
+#endif		
+#endif // MP_TEST
+
+#if (defined(SW_ANT_SWITCH) || defined(HW_ANT_SWITCH)) 
+	{ SIOCANTSELECT, IW_PRIV_TYPE_CHAR | 128, IW_PRIV_TYPE_CHAR | 128, "dvyAnt_set" },
+#endif
+
+#ifdef MICERR_TEST
+	{ SIOCSIWRTLMICERROR, IW_PRIV_TYPE_CHAR | 40, 0, "mic_error" },
+	{ SIOCSIWRTLMICREPORT, IW_PRIV_TYPE_CHAR | 40, 0, "mic_report" },
+#endif
+	{ SIOCGIWRTLREGDUMP, IW_PRIV_TYPE_CHAR | 40, 0, "reg_dump" },
+
+#if defined(MBSSID) || defined(UNIVERSAL_REPEATER)
+	{ SIOCSICOPYMIB, IW_PRIV_TYPE_CHAR | 40, 0, "copy_mib" },
+#endif
+
+#ifdef CONFIG_RTL8186_KB
+	{ SIOCGIREADGUESTMAC, IW_PRIV_TYPE_CHAR | 40, 0, "read_guestmac" },
+	{ SIOCSIWRTGUESTMAC, IW_PRIV_TYPE_CHAR | 40, 0, "write_guestmac" },
+#endif
+
+#ifdef MULTI_MAC_CLONE
+	{ SIOCGIMCLONE, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_CHAR | 128, "get_mclone" },
+	{ SIOCSIMCLONE, IW_PRIV_TYPE_CHAR | 40, 0, "set_mclone" },
+	{ SIOCSIMCLONE_DEL, IW_PRIV_TYPE_CHAR | 40, 0, "del_mclone" },
+#endif
+
+#ifdef	CONFIG_RTK_MESH
+	{ RTL8192CD_IOCTL_STATIC_ROUTE, IW_PRIV_TYPE_CHAR | 40, 0, "strt" },
+	{ RTL8192CD_IOCTL_MANUAL_METRIC, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_BYTE | 128, "manual_metric" },
+	{ RTL8192CD_IOCTL_SHOWSC, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_BYTE | 128, "showsc" },
+#ifdef D_ACL//tsananiu
+    { RTL8192CD_IOCTL_ADD_ACL_TABLE, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_BYTE | 128, "add_acl_table" },
+    { RTL8192CD_IOCTL_REMOVE_ACL_TABLE, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_BYTE | 128, "del_acl_table" },
+    { RTL8192CD_IOCTL_GET_ACL_TABLE, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_BYTE | 128, "get_acl_table" },
+    { RTL8192CD_IOCTL_CLEAR_ACL_TABLE, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_BYTE | 128, "clear_acl_table" },
+#endif//tsananiu//
+#endif
+#ifdef BR_SHORTCUT
+	{ SIOCLEARBRSC, IW_PRIV_TYPE_CHAR | 40, 0, "clear_brsc" },
+	{ SIOCLONEEARBRSC, IW_PRIV_TYPE_CHAR | 40, 0, "clear_onebrsc" },
+#endif
+
+
+	{ SIOCRADIOOFF, IW_PRIV_TYPE_CHAR | 128, 0, "radio_off" },
+
+#ifdef PCIE_POWER_SAVING
+#ifdef PCIE_POWER_SAVING_DEBUG
+	{ SIOCEPDN, IW_PRIV_TYPE_CHAR | 128, 128, "epdn" },
+#else
+	{ SIOCEPDN, IW_PRIV_TYPE_CHAR | 128, 128, "stopps" },
+#endif
+#elif defined(RF_MIMO_SWITCH) || defined(RF_MIMO_PS)
+	{ SIOCEPDN, IW_PRIV_TYPE_CHAR | 128, 128, "mimo" },
+#endif
+#ifdef SDIO_AP_OFFLOAD
+	{ SIOCSTOPPS, IW_PRIV_TYPE_CHAR | 128, 128, "stopps" },
+#endif
+	{ SIOCACS, IW_PRIV_TYPE_CHAR | 128, 128, "acs" },
+
+	{ SIOCANTSTS, IW_PRIV_TYPE_CHAR | 128, IW_PRIV_TYPE_CHAR | 512, "ant_sts" },	
+#ifdef EN_EFUSE
+	{ SIOCEFUSE_GET, IW_PRIV_TYPE_CHAR | 128, IW_PRIV_TYPE_CHAR | 512, "efuse_get" },
+	{ SIOCEFUSE_SET, IW_PRIV_TYPE_CHAR | 512, IW_PRIV_TYPE_CHAR | 128, "efuse_set" },
+	{ SIOCEFUSE_SYNC, IW_PRIV_TYPE_CHAR | 128, IW_PRIV_TYPE_CHAR |  128, "efuse_sync" },
+#endif
+#ifdef 	P2P_SUPPORT
+	{ SIOCP2PCMD, IW_PRIV_TYPE_CHAR | 128, IW_PRIV_TYPE_CHAR | 128, "p2pcmd" },
+#endif
+#ifdef CONFIG_RTL_92D_SUPPORT
+	{ SIOC92DIQK, IW_PRIV_TYPE_CHAR | 128, 0, "iqk" },
+#ifdef EN_EFUSE
+	{ SIOC92DSBANDADDR, IW_PRIV_TYPE_CHAR | 128, IW_PRIV_TYPE_CHAR | 128, "bandadd" },
+#endif
+#ifdef NON_INTR_ANTDIV
+	{ SIOC92DATNDIV, IW_PRIV_TYPE_CHAR | 128, 0 | 128, "antdiv" },
+#endif
+#ifdef DPK_92D
+	{ SIOC92DDPK, IW_PRIV_TYPE_CHAR | 128, 0 | 128, "dpk" },
+#endif
+#endif // CONFIG_RTL_92D_SUPPORT
+#if defined(RTK_AC_SUPPORT) || defined(HS2_SUPPORT) || defined(CONFIG_IEEE80211W) //for 11ac logo, hs2.0 release 1 logo
+	{ SIOC8812SIGMA, IW_PRIV_TYPE_CHAR | 128, 0 | 128, "sigma_default" }, 
+#endif
+#if defined(RTK_AC_SUPPORT)
+	{ SIOC8812SIGMATB, IW_PRIV_TYPE_CHAR | 128, 0 | 128, "sigma_default_tb" }, 				
+#endif
+	{ SIOC92DAUTOCH, IW_PRIV_TYPE_CHAR | 128, 0, "autoch" },
+
+#if defined(CONFIG_OFFLOAD_FUNCTION) || defined(SDIO_AP_OFFLOAD)
+	{ SIOOFFLOADTEST, IW_PRIV_TYPE_CHAR | 128, 0, "offload" },        
+#endif
+
+#ifdef CONFIG_8814_AP_MAC_VERI
+    { SIO_8814_AP_MAC_VERI, IW_PRIV_TYPE_CHAR | 128, 0, "apTest" },        
+#endif //#ifdef CONFIG_8814_AP_MAC_VERI
+
+#ifdef D_ACL//tsananiu
+	{ RTL8192CD_IOCTL_ADD_ACL_TABLE, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_BYTE | 128, "add_acl_table" },
+	{ RTL8192CD_IOCTL_REMOVE_ACL_TABLE, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_BYTE | 128, "del_acl_table" },
+	{ RTL8192CD_IOCTL_GET_ACL_TABLE, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_BYTE | 128, "get_acl_table" },
+	{ RTL8192CD_IOCTL_CLEAR_ACL_TABLE, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_BYTE | 128, "clear_acl_table" },
+#endif//tsananiu//
+
+	{ SIOCRESETNOPCHANNEL, IW_PRIV_TYPE_CHAR | 128, 0 | 128, "reset_nop" },
+	{ SIOCTXPWRAPPLY, IW_PRIV_TYPE_CHAR | 128, 0 | 128, "txpwr_apply" },
+};
+
+#if defined (CONFIG_RTL_COMAPI_WLTOOLS) || defined(SUPPORT_MONITOR)
+
+static const iw_handler rtl_iwhandler[] =
+{
+	(iw_handler) NULL,					/* SIOCSIWCOMMIT */
+#ifdef WIFI_WPAS_CLI
+	(iw_handler) rtl_wx_get_name,			        /* SIOCGIWNAME	 */
+	(iw_handler) rtl_wx_dummy,                              /* SIOCSIWNWID   */
+	(iw_handler) rtl_wx_dummy,                              /* SIOCGIWNWID   */
+#else
+	(iw_handler) NULL /* supported */,		        /* SIOCGIWNAME	 */
+	(iw_handler) NULL,				        /* SIOCSIWNWID	 */
+	(iw_handler) NULL,					/* SIOCGIWNWID	 */
+#endif
+	(iw_handler) rtl_siwfreq,				/* SIOCSIWFREQ	 */
+#ifdef WIFI_WPAS_CLI
+	(iw_handler) rtl_wx_get_freq,			        /* SIOCGIWFREQ	 */
+	(iw_handler) rtl_wx_set_mode,			        /* SIOCSIWMODE	 */
+#else
+	(iw_handler) rtl_giwfreq,				/* SIOCGIWFREQ	 */
+	(iw_handler) rtl_siwmode,				/* SIOCSIWMODE	 */
+#endif
+	(iw_handler) rtl_giwmode,				/* SIOCGIWMODE	 */
+#ifdef WIFI_WPAS_CLI
+	(iw_handler) rtl_wx_dummy,				/* SIOCSIWSENS	 */
+	(iw_handler) rtl_wx_get_sens,			        /* SIOCGIWSENS	 */	
+#else
+	(iw_handler) NULL,					/* SIOCSIWSENS	 */
+	(iw_handler) NULL,					/* SIOCGIWSENS	 */
+#endif
+	(iw_handler) NULL /* not used */,			/* SIOCSIWRANGE  */
+	(iw_handler) rtl_giwrange,				/* SIOCGIWRANGE  */
+#ifdef BALONG_PLT
+        (iw_handler) rtl_gipriv,                                /* SIOCSIWPRIV   */
+   	(iw_handler) rtl_sipriv /* kernel code */,              /* SIOCGIWPRIV	 */
+#else	
+	(iw_handler) NULL /* not used */,			/* SIOCSIWPRIV	 */
+	(iw_handler) NULL /* kernel code */,		        /* SIOCGIWPRIV	 */
+#endif	
+	(iw_handler) NULL /* not used */,			/* SIOCSIWSTATS  */
+	(iw_handler) NULL /*rtl8192cd_get_wireless_stats*//* kernel code */,	 /* SIOCGIWSTATS  */
+	(iw_handler) NULL,						/* SIOCSIWSPY	 */
+	(iw_handler) NULL,						/* SIOCGIWSPY	 */
+	(iw_handler) NULL,						/* SIOCSIWTHRSPY */
+	(iw_handler) NULL,						/* SIOCGIWTHRSPY */
+	(iw_handler) rtl_siwap,					/* SIOCSIWAP	 */
+	(iw_handler) rtl_giwap,					/* SIOCGIWAP	 */
+#ifdef WIFI_WPAS_CLI
+	(iw_handler) rtl_wx_set_mlme,			/* SIOCSIWMLME	 */	
+#else
+#ifdef SIOCSIWMLME
+	(iw_handler) NULL, //  rt_ioctl_siwmlme,	        /* SIOCSIWMLME   */	//chris: deauth, disassoc for client mode
+#else
+	(iw_handler) NULL,				        /* SIOCSIWMLME */
+#endif // SIOCSIWMLME //
+#endif
+	(iw_handler) rtl_iwaplist,				/* SIOCGIWAPLIST */
+#ifdef SIOCGIWSCAN
+	(iw_handler) rtl_siwscan,				/* SIOCSIWSCAN	 */
+	(iw_handler) rtl_giwscan,				/* SIOCGIWSCAN	 */
+#else
+	(iw_handler) NULL,				        /* SIOCSIWSCAN   */
+	(iw_handler) NULL,				        /* SIOCGIWSCAN   */
+#endif /* SIOCGIWSCAN */
+	(iw_handler) rtl_siwessid, 				/* SIOCSIWESSID  */
+	(iw_handler) rtl_giwessid, 				/* SIOCGIWESSID  */
+	(iw_handler) NULL, //  rt_ioctl_siwnickn, 		/* SIOCSIWNICKN  */
+	(iw_handler) NULL, //  rt_ioctl_giwnickn, 		/* SIOCGIWNICKN  */
+	(iw_handler) NULL,						/* -- hole --	 */
+	(iw_handler) NULL,						/* -- hole --	 */
+	(iw_handler) rtl_siwrate,			/* SIOCSIWRATE	 */
+	(iw_handler) rtl_giwrate,				/* SIOCGIWRATE	 */
+	(iw_handler) rtl_siwrts,				/* SIOCSIWRTS	 */
+	(iw_handler) rtl_giwrts,				/* SIOCGIWRTS	 */
+	(iw_handler) rtl_siwfrag,				/* SIOCSIWFRAG	 */
+	(iw_handler) rtl_giwfrag,				/* SIOCGIWFRAG	 */
+	(iw_handler) NULL,						/* SIOCSIWTXPOW  */
+	(iw_handler) NULL,						/* SIOCGIWTXPOW  */
+	(iw_handler) rtl_siwretry,				/* SIOCSIWRETRY  */
+	(iw_handler) rtl_giwretry,				/* SIOCGIWRETRY  */
+	(iw_handler) rtl_siwencode,				/* SIOCSIWENCODE */
+	(iw_handler) rtl_giwencode,				/* SIOCGIWENCODE */
+	(iw_handler) NULL,						/* SIOCSIWPOWER  */
+	(iw_handler) rtl_giwpower,				/* SIOCGIWPOWER  */
+	(iw_handler) NULL,						/* -- hole -- */
+	(iw_handler) NULL,						/* -- hole -- */
+#if WIRELESS_EXT > 17	// for wpa_supplicant
+#ifdef WIFI_WPAS_CLI
+	(iw_handler) rtl_siwgenie,				/* SIOCSIWGENIE  */
+	(iw_handler) NULL,					/* SIOCGIWGENIE  */
+	(iw_handler) rtl_siwauth,				/* SIOCSIWAUTH	 */
+	(iw_handler) rtl_giwauth,				/* SIOCGIWAUTH	 */
+	(iw_handler) rtl_siwencodeext,			        /* SIOCSIWENCODEEXT */
+	(iw_handler) rtl_giwencodeext,			        /* SIOCGIWENCODEEXT */
+	(iw_handler) rtl_siwpmkid, 				/* SIOCSIWPMKSA  */	
+#else
+	(iw_handler) NULL, //rt_ioctl_siwgenie, 		/* SIOCSIWGENIE  */
+	(iw_handler) NULL, //rt_ioctl_giwgenie, 		/* SIOCGIWGENIE  */
+	(iw_handler) NULL, //rt_ioctl_siwauth,			/* SIOCSIWAUTH	 */
+	(iw_handler) NULL, //rt_ioctl_giwauth,			/* SIOCGIWAUTH	 */
+	(iw_handler) NULL, //rt_ioctl_siwencodeext, 	/* SIOCSIWENCODEEXT */
+	(iw_handler) NULL, //rt_ioctl_giwencodeext, 	/* SIOCGIWENCODEEXT */
+	(iw_handler) NULL, //rt_ioctl_siwpmksa, 		/* SIOCSIWPMKSA  */
+#endif
+#endif
+};
+
+static iw_handler rtl_private_handler[] =
+{
+#if 0
+	NULL, //set_mib,
+	NULL, //get_mib,
+#ifdef _IOCTL_DEBUG_CMD_
+	NULL, //read_reg,
+	NULL, //read_mem,
+	NULL, //read_bb,
+	NULL, //read_rf,
+#endif
+	NULL, //del_sta,
+	NULL, //write_eeprom,
+	NULL, //read_eeprom,
+#ifdef SUPPORT_SNMP_MIB
+	NULL, //get_snmp_mib,
+#endif
+	NULL, //rf_pwr,
+#ifdef AUTO_TEST_SUPPORT
+	NULL, //at_ss,
+	NULL, //at_join,
+#endif
+#ifdef CONFIG_RTL_COMAPI_CFGFILE
+	NULL, //cfgfile,
+#endif
+#ifdef MP_TEST
+	NULL, //mp_start,
+	NULL, //mp_stop,
+	NULL, //mp_rate,
+	NULL, //mp_channel,
+	NULL, //mp_txpower,
+	NULL, //mp_ctx,
+	NULL, //mp_arx,
+	NULL, //mp_bssid,
+	NULL, //mp_ant_tx,
+	NULL, //mp_ant_rx,
+	NULL, //mp_bandwidth,
+	NULL, //mp_phypara,
+
+#ifdef B2B_TEST
+	NULL, //mp_tx,
+	NULL, //mp_brx,
+#if 0
+	mp_rx,
+#endif
+#endif
+	NULL, //mp_query,
+	NULL, //mp_tssi,
+#ifdef RTL8192SE
+	NULL, //mp_ther,
+#endif
+#endif // MP_TEST
+#if (defined(CONFIG_RTL865X) && defined(CONFIG_RTL865X_CLE) && defined(MP_TEST)) || defined(MP_TEST_CFG)
+	NULL, //mp_cfg,
+#endif
+#ifdef MICERR_TEST
+	NULL, //mic_error,
+	NULL, //mic_report,
+#endif
+#ifdef DEBUG_8190
+	NULL, //reg_dump,
+#endif
+
+#if defined(MBSSID) || defined(UNIVERSAL_REPEATER)
+	NULL, //copy_mib,
+#endif
+#ifdef CONFIG_RTL8186_KB
+	NULL, //read_guestmac,
+	NULL, //write_guestmac,
+#endif
+
+#ifdef	CONFIG_RTK_MESH
+	NULL, //strt,
+#ifdef D_ACL //tsananiu
+	NULL, //add_acl_table,
+	NULL, //remove_acl_table,
+	NULL, //get_acl_table,
+#endif
+#endif
+#ifdef BR_SHORTCUT
+	NULL, //clear_brsc,
+#endif
+#else
+	NULL, // return NULL to redirect to dev->ioctl
+#endif
+};
+
+const struct iw_handler_def rtl8192cd_iw_handler_def =
+{
+#define	N(a)	(sizeof (a) / sizeof (a[0]))
+	.standard	= (iw_handler *) rtl_iwhandler,
+	.num_standard	= sizeof(rtl_iwhandler) / sizeof(iw_handler),
+	.private = rtl_private_handler,
+	.private_args = (struct iw_priv_args *)privtab,
+	.num_private = sizeof(rtl_private_handler) / sizeof(iw_handler),
+ 	.num_private_args = sizeof(privtab) / sizeof(struct iw_priv_args),
+#if 0 // IW_HANDLER_VERSION >= 6
+    .get_wireless_stats = rtl8192cd_get_wireless_stats,
+#endif
+};
+
+#endif
+
+
+struct iwpriv_arg {
+	char name[32];	/* mib name */
+	TYPE_T type;	/* Type and number of args */
+	int offset;		/* mib offset */
+	int len;		/* mib byte len */
+	int Default;	/* mib default value */
+};
+
+/* Bit mask value for flags, compatiable with old driver */
+#define STA_INFO_FLAG_AUTH_OPEN     	0x01
+#define STA_INFO_FLAG_AUTH_WEP      	0x02
+#define STA_INFO_FLAG_ASOC          	0x04
+#define STA_INFO_FLAG_ASLEEP        	0x08
+
+/* BSS info, reported to web server */
+typedef struct _bss_info_2_web {
+    unsigned char state;
+    unsigned char channel;
+    unsigned char txRate;
+    unsigned char bssid[6];
+    unsigned char rssi, sq;
+    unsigned char ssid[33];
+} bss_info_2_web;
+
+typedef enum _wlan_mac_state {
+    STATE_DISABLED=0, STATE_IDLE, STATE_SCANNING, STATE_STARTED, STATE_CONNECTED, STATE_WAITFORKEY
+} wlan_mac_state;
+
+#ifdef WDS
+typedef enum _wlan_wds_state {
+	STATE_WDS_EMPTY=0, STATE_WDS_DISABLED, STATE_WDS_ACTIVE
+} wlan_wds_state;
+
+typedef struct _wds_info {
+	unsigned char	state;
+	unsigned char	addr[6];
+	unsigned long	tx_packets;
+	unsigned long	rx_packets;
+	unsigned long	tx_errors;
+	unsigned char	TxOperaRate;
+} web_wds_info;
+#endif
+
+struct _wlan_sta_rateset {
+	unsigned char	mac[6];
+	unsigned char	txrate;
+};
+
+struct _misc_data_ {
+	unsigned char	mimo_tr_hw_support;
+	unsigned char	mimo_tr_used;
+	unsigned char	resv[30];
+};
+
+
+/* MIB table */
+static struct iwpriv_arg mib_table[] = {
+	// struct Dot11RFEntry
+	{"channel",		BYTE_T,		_OFFSET(dot11RFEntry.dot11channel), _SIZE(dot11RFEntry.dot11channel), 0},
+	{"ch_low",		INT_T,		_OFFSET(dot11RFEntry.dot11ch_low), _SIZE(dot11RFEntry.dot11ch_low), 0},
+	{"ch_hi",		INT_T,		_OFFSET(dot11RFEntry.dot11ch_hi), _SIZE(dot11RFEntry.dot11ch_hi), 0},
+	{"pwrlevelCCK_A",		BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrlevelCCK_A), _SIZE(dot11RFEntry.pwrlevelCCK_A), 0},
+	{"pwrlevelCCK_B",		BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrlevelCCK_B), _SIZE(dot11RFEntry.pwrlevelCCK_B), 0},
+	{"pwrlevelHT40_1S_A",	BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrlevelHT40_1S_A), _SIZE(dot11RFEntry.pwrlevelHT40_1S_A), 0},
+	{"pwrlevelHT40_1S_B",	BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrlevelHT40_1S_B), _SIZE(dot11RFEntry.pwrlevelHT40_1S_B), 0},
+	{"pwrdiffHT40_2S",		BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrdiffHT40_2S), _SIZE(dot11RFEntry.pwrdiffHT40_2S), 0},
+	{"pwrdiffHT20",			BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrdiffHT20), _SIZE(dot11RFEntry.pwrdiffHT20), 0},
+	{"pwrdiffOFDM",			BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrdiffOFDM), _SIZE(dot11RFEntry.pwrdiffOFDM), 0},
+#if defined(CONFIG_RTL_92D_SUPPORT) || defined(CONFIG_RTL_8812_SUPPORT) || defined(CONFIG_WLAN_HAL_8881A)
+	{"pwrlevel5GHT40_1S_A",			BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrlevel5GHT40_1S_A), _SIZE(dot11RFEntry.pwrlevel5GHT40_1S_A), 0},
+	{"pwrlevel5GHT40_1S_B",			BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrlevel5GHT40_1S_B), _SIZE(dot11RFEntry.pwrlevel5GHT40_1S_B), 0},
+#endif
+#ifdef CONFIG_RTL_92D_SUPPORT
+	{"pwrdiff5GHT40_2S",			BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrdiff5GHT40_2S), _SIZE(dot11RFEntry.pwrdiff5GHT40_2S), 0},
+	{"pwrdiff5GHT20",			BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrdiff5GHT20), _SIZE(dot11RFEntry.pwrdiff5GHT20), 0},
+	{"pwrdiff5GOFDM",			BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrdiff5GOFDM), _SIZE(dot11RFEntry.pwrdiff5GOFDM), 0},
+#endif
+#ifdef POWER_PERCENT_ADJUSTMENT
+	{"powerpercent",	BYTE_T,	_OFFSET(dot11RFEntry.power_percent), _SIZE(dot11RFEntry.power_percent), 100},
+#endif
+	{"preamble",	INT_T,		_OFFSET(dot11RFEntry.shortpreamble), _SIZE(dot11RFEntry.shortpreamble), 0},
+	{"trswitch",	INT_T,		_OFFSET(dot11RFEntry.trswitch), _SIZE(dot11RFEntry.trswitch), 0},
+	{"disable_ch14_ofdm",	INT_T,	_OFFSET(dot11RFEntry.disable_ch14_ofdm), _SIZE(dot11RFEntry.disable_ch14_ofdm), 0},
+	{"disable_ch1213",	INT_T,	_OFFSET(dot11RFEntry.disable_ch1213), _SIZE(dot11RFEntry.disable_ch1213), 1},
+	{"disable_acs_ch",      INT_T,  _OFFSET(dot11RFEntry.disable_acs_ch), _SIZE(dot11RFEntry.disable_acs_ch), 0},
+	{"xcap",		INT_T,	_OFFSET(dot11RFEntry.xcap), _SIZE(dot11RFEntry.xcap), 0},
+	{"tssi1",		INT_T,	_OFFSET(dot11RFEntry.tssi1), _SIZE(dot11RFEntry.tssi1), 0},
+	{"tssi2",		INT_T,	_OFFSET(dot11RFEntry.tssi2), _SIZE(dot11RFEntry.tssi2), 0},
+	{"ther",		INT_T,	_OFFSET(dot11RFEntry.ther), _SIZE(dot11RFEntry.ther), 0},
+	{"deltaIQK",		INT_T,	_OFFSET(dot11RFEntry.deltaIQK), _SIZE(dot11RFEntry.deltaIQK), 0},
+	{"deltaLCK",		INT_T,	_OFFSET(dot11RFEntry.deltaLCK), _SIZE(dot11RFEntry.deltaLCK), 0},
+	{"MIMO_TR_mode",	INT_T,	_OFFSET(dot11RFEntry.MIMO_TR_mode), _SIZE(dot11RFEntry.MIMO_TR_mode), MIMO_2T2R},
+	{"phyBandSelect",	BYTE_T,	_OFFSET(dot11RFEntry.phyBandSelect), _SIZE(dot11RFEntry.phyBandSelect), PHY_BAND_2G},
+	{"band5GSelected",	BYTE_T,	_OFFSET(dot11RFEntry.band5GSelected), _SIZE(dot11RFEntry.band5GSelected), PHY_BAND_5G_1 | PHY_BAND_5G_2 | PHY_BAND_5G_3 | PHY_BAND_5G_4},
+	{"macPhyMode",	BYTE_T,	_OFFSET(dot11RFEntry.macPhyMode), _SIZE(dot11RFEntry.macPhyMode), SINGLEMAC_SINGLEPHY},
+	{"smcc",	INT_T,	_OFFSET(dot11RFEntry.smcc), _SIZE(dot11RFEntry.smcc), 1},
+	{"smcc_t",	INT_T,	_OFFSET(dot11RFEntry.smcc_t), _SIZE(dot11RFEntry.smcc_t), 6},
+#ifdef PHASE2_TEST
+	{"smcc_p",	INT_T,	_OFFSET(dot11RFEntry.smcc_p), _SIZE(dot11RFEntry.smcc_p), 18},
+#endif
+	{"trsw_pape_C9",		BYTE_T,	_OFFSET(dot11RFEntry.trsw_pape_C9), _SIZE(dot11RFEntry.trsw_pape_C9), 0x0},
+	{"trsw_pape_CC",		BYTE_T,	_OFFSET(dot11RFEntry.trsw_pape_CC), _SIZE(dot11RFEntry.trsw_pape_CC), 0xFF},
+	{"tx2path",				INT_T,	_OFFSET(dot11RFEntry.tx2path), _SIZE(dot11RFEntry.tx2path), 1},
+	{"txbf",				INT_T,	_OFFSET(dot11RFEntry.txbf), _SIZE(dot11RFEntry.txbf), 1},
+	{"txbfer",				INT_T,	_OFFSET(dot11RFEntry.txbfer), _SIZE(dot11RFEntry.txbfer), 1},	
+	{"txbfee",				INT_T,	_OFFSET(dot11RFEntry.txbfee), _SIZE(dot11RFEntry.txbfee), 1},
+	{"target_pwr",			INT_T,	_OFFSET(dot11RFEntry.target_pwr), _SIZE(dot11RFEntry.target_pwr), 0},
+	{"pa_type",			INT_T,	_OFFSET(dot11RFEntry.pa_type), _SIZE(dot11RFEntry.pa_type), 0},
+	{"bcn2path",			BYTE_T,	_OFFSET(dot11RFEntry.bcn2path), _SIZE(dot11RFEntry.bcn2path), 0},
+	{"add_cck1M_pwr",		BYTE_T,	_OFFSET(dot11RFEntry.add_cck1M_pwr), _SIZE(dot11RFEntry.add_cck1M_pwr), 0},
+	{"txpwr_reduction",		BYTE_T,	_OFFSET(dot11RFEntry.txpwr_reduction), _SIZE(dot11RFEntry.txpwr_reduction), 0},
+	{"rfe_type",			BYTE_T,	_OFFSET(dot11RFEntry.rfe_type), _SIZE(dot11RFEntry.rfe_type), 0},	
+	{"acs_type",			INT_T,	_OFFSET(dot11RFEntry.acs_type), _SIZE(dot11RFEntry.acs_type), 1},
+
+	// struct Dot11StationConfigEntry
+	{"ssid",		SSID_STRING_T,	_OFFSET(dot11StationConfigEntry.dot11DesiredSSID), _SIZE(dot11StationConfigEntry.dot11DesiredSSID), 0},
+	{"defssid",		DEF_SSID_STRING_T,	_OFFSET(dot11StationConfigEntry.dot11DefaultSSID), _SIZE(dot11StationConfigEntry.dot11DefaultSSID), 0},
+	{"bssid2join",	BYTE_ARRAY_T,	_OFFSET(dot11StationConfigEntry.dot11DesiredBssid), _SIZE(dot11StationConfigEntry.dot11DesiredBssid), 0},
+	{"bcnint",		INT_T,		_OFFSET(dot11StationConfigEntry.dot11BeaconPeriod), _SIZE(dot11StationConfigEntry.dot11BeaconPeriod), 100},
+	{"dtimperiod",	INT_T,		_OFFSET(dot11StationConfigEntry.dot11DTIMPeriod), _SIZE(dot11StationConfigEntry.dot11DTIMPeriod), 1},
+	{"swcrypto",	INT_T,		_OFFSET(dot11StationConfigEntry.dot11swcrypto), _SIZE(dot11StationConfigEntry.dot11swcrypto), 0},
+	{"aclmode",		INT_T,		_OFFSET(dot11StationConfigEntry.dot11AclMode), _SIZE(dot11StationConfigEntry.dot11AclMode), 0},
+	{"aclnum",		INT_T,		_OFFSET(dot11StationConfigEntry.dot11AclNum), _SIZE(dot11StationConfigEntry.dot11AclNum), 0},
+	{"acladdr",		ACL_T,		_OFFSET(dot11StationConfigEntry.dot11AclAddr), _SIZE(dot11StationConfigEntry.dot11AclAddr), 0},
+	{"oprates",		INT_T,		_OFFSET(dot11StationConfigEntry.dot11SupportedRates), _SIZE(dot11StationConfigEntry.dot11SupportedRates), 0xfff},
+	{"basicrates",	INT_T,		_OFFSET(dot11StationConfigEntry.dot11BasicRates), _SIZE(dot11StationConfigEntry.dot11BasicRates), 0xf},
+#if defined(RTK_NL80211)
+	{"regdomain",	INT_T,		_OFFSET(dot11StationConfigEntry.dot11RegDomain), _SIZE(dot11StationConfigEntry.dot11RegDomain), DOMAIN_TEST},
+#else
+	{"regdomain",	INT_T,		_OFFSET(dot11StationConfigEntry.dot11RegDomain), _SIZE(dot11StationConfigEntry.dot11RegDomain), 1},
+#endif
+	{"txpwr_lmt_index",	INT_T,		_OFFSET(dot11StationConfigEntry.txpwr_lmt_index), _SIZE(dot11StationConfigEntry.txpwr_lmt_index), 0},		
+	{"autorate",	INT_T,		_OFFSET(dot11StationConfigEntry.autoRate), _SIZE(dot11StationConfigEntry.autoRate), 1},
+	{"fixrate",		INT_T,		_OFFSET(dot11StationConfigEntry.fixedTxRate), _SIZE(dot11StationConfigEntry.fixedTxRate), 0},
+	{"swTkipMic",	INT_T,		_OFFSET(dot11StationConfigEntry.swTkipMic), _SIZE(dot11StationConfigEntry.swTkipMic), 1},
+	{"disable_protection", INT_T,	_OFFSET(dot11StationConfigEntry.protectionDisabled), _SIZE(dot11StationConfigEntry.protectionDisabled), 0},
+	{"disable_olbc", INT_T,		_OFFSET(dot11StationConfigEntry.olbcDetectDisabled), _SIZE(dot11StationConfigEntry.olbcDetectDisabled), 0},
+	{"disable_nmlsc", INT_T,		_OFFSET(dot11StationConfigEntry.nmlscDetectDisabled), _SIZE(dot11StationConfigEntry.nmlscDetectDisabled), 0},
+	{"deny_legacy",	INT_T,		_OFFSET(dot11StationConfigEntry.legacySTADeny), _SIZE(dot11StationConfigEntry.legacySTADeny), 0},
+	{"probe_info_enable", INT_T,		_OFFSET(dot11StationConfigEntry.probe_info_enable), _SIZE(dot11StationConfigEntry.probe_info_enable), 0},
+	{"probe_info_timeout", INT_T,		_OFFSET(dot11StationConfigEntry.probe_info_timeout), _SIZE(dot11StationConfigEntry.probe_info_timeout), 180},	//seconds
+#if defined(HS2_SUPPORT) || defined(DOT11K)	
+	{"cubeaconintval",  INT_T,  _OFFSET(dot11StationConfigEntry.channel_utili_beaconIntval), _SIZE(dot11StationConfigEntry.channel_utili_beaconIntval), 10},
+#endif
+#ifdef CLIENT_MODE
+	{"fast_roaming", INT_T,		_OFFSET(dot11StationConfigEntry.fastRoaming), _SIZE(dot11StationConfigEntry.fastRoaming), 0},
+#endif
+	{"lowestMlcstRate", INT_T,	_OFFSET(dot11StationConfigEntry.lowestMlcstRate), _SIZE(dot11StationConfigEntry.lowestMlcstRate), 0},
+	{"stanum",		INT_T,		_OFFSET(dot11StationConfigEntry.supportedStaNum), _SIZE(dot11StationConfigEntry.supportedStaNum), 0},
+#ifdef RX_LOOP_LIMIT
+	{"limit_rxloop",	INT_T,		_OFFSET(dot11StationConfigEntry.limit_rxloop), _SIZE(dot11StationConfigEntry.limit_rxloop), 0},
+#endif
+#ifdef CONFIG_RTL_SIMPLE_CONFIG
+	{"sc_enabled",		INT_T,		_OFFSET(dot11StationConfigEntry.sc_enabled), _SIZE(dot11StationConfigEntry.sc_enabled), 0},
+	{"sc_duration_time",		INT_T,		_OFFSET(dot11StationConfigEntry.sc_duration_time), _SIZE(dot11StationConfigEntry.sc_duration_time), -1},
+	{"sc_get_sync_time",		INT_T,		_OFFSET(dot11StationConfigEntry.sc_get_sync_time), _SIZE(dot11StationConfigEntry.sc_get_sync_time), 30},
+	{"sc_get_profile_time",		INT_T,		_OFFSET(dot11StationConfigEntry.sc_get_profile_time), _SIZE(dot11StationConfigEntry.sc_get_profile_time), 30},
+	{"sc_connect_timeout",		INT_T,		_OFFSET(dot11StationConfigEntry.sc_connect_timeout), _SIZE(dot11StationConfigEntry.sc_connect_timeout), 60},
+	{"sc_vxd_rescan_time",		INT_T,		_OFFSET(dot11StationConfigEntry.sc_vxd_rescan_time), _SIZE(dot11StationConfigEntry.sc_vxd_rescan_time), 10},
+	{"sc_pin_enabled",		INT_T,		_OFFSET(dot11StationConfigEntry.sc_pin_enabled), _SIZE(dot11StationConfigEntry.sc_pin_enabled), 1},
+	{"sc_status",		INT_T,		_OFFSET(dot11StationConfigEntry.sc_status), _SIZE(dot11StationConfigEntry.sc_status), 0},
+	{"sc_pin",		STRING_T,		_OFFSET(dot11StationConfigEntry.sc_pin), _SIZE(dot11StationConfigEntry.sc_pin), 0},
+	{"sc_default_pin",		STRING_T,		_OFFSET(dot11StationConfigEntry.sc_default_pin), _SIZE(dot11StationConfigEntry.sc_default_pin), 0},
+	{"sc_passwd",		STRING_T,		_OFFSET(dot11StationConfigEntry.sc_passwd), _SIZE(dot11StationConfigEntry.sc_passwd), 0},
+	{"sc_device_name",		STRING_T,		_OFFSET(dot11StationConfigEntry.sc_device_name), _SIZE(dot11StationConfigEntry.sc_device_name), 0},
+	{"sc_ack_round",		INT_T,		_OFFSET(dot11StationConfigEntry.sc_ack_round), _SIZE(dot11StationConfigEntry.sc_ack_round), 0},
+	{"sc_check_link_time",		INT_T,		_OFFSET(dot11StationConfigEntry.sc_check_link_time), _SIZE(dot11StationConfigEntry.sc_check_link_time), 10},
+	{"sc_sync_vxd_to_root",		INT_T,		_OFFSET(dot11StationConfigEntry.sc_sync_vxd_to_root), _SIZE(dot11StationConfigEntry.sc_sync_vxd_to_root), 0},
+	{"sc_control_ip",		INT_T,		_OFFSET(dot11StationConfigEntry.sc_control_ip), _SIZE(dot11StationConfigEntry.sc_control_ip), 0},
+	{"sc_debug",		INT_T,		_OFFSET(dot11StationConfigEntry.sc_debug), _SIZE(dot11StationConfigEntry.sc_debug), 1},
+	{"sc_check_level",		INT_T,		_OFFSET(dot11StationConfigEntry.sc_check_level), _SIZE(dot11StationConfigEntry.sc_check_level), 2},
+	{"sc_ignore_overlap",		INT_T,		_OFFSET(dot11StationConfigEntry.sc_ignore_overlap), _SIZE(dot11StationConfigEntry.sc_ignore_overlap), 0},
+	{"sc_reset_beacon_psk",		INT_T,		_OFFSET(dot11StationConfigEntry.sc_reset_beacon_psk), _SIZE(dot11StationConfigEntry.sc_reset_beacon_psk), 1},
+	{"sc_security_type",		INT_T,		_OFFSET(dot11StationConfigEntry.sc_security_type), _SIZE(dot11StationConfigEntry.sc_security_type), 0},
+	{"sc_fix_channel",		INT_T,		_OFFSET(dot11StationConfigEntry.sc_fix_channel), _SIZE(dot11StationConfigEntry.sc_fix_channel), 0},
+#endif
+
+#ifdef	CONFIG_RTK_MESH
+	{"mesh_enable",			BYTE_T,			_OFFSET(dot1180211sInfo.mesh_enable),			_SIZE(dot1180211sInfo.mesh_enable),			0},
+	{"mesh_root_enable",	BYTE_T,			_OFFSET(dot1180211sInfo.mesh_root_enable),		_SIZE(dot1180211sInfo.mesh_root_enable),	0},
+	{"mesh_ap_enable",		BYTE_T,			_OFFSET(dot1180211sInfo.mesh_ap_enable),		_SIZE(dot1180211sInfo.mesh_ap_enable),		0},
+	{"mesh_portal_enable",	BYTE_T,			_OFFSET(dot1180211sInfo.mesh_portal_enable),	_SIZE(dot1180211sInfo.mesh_portal_enable),	0},
+	{"mesh_id",				STRING_T,		_OFFSET(dot1180211sInfo.mesh_id),				_SIZE(dot1180211sInfo.mesh_id),				0},
+	{"mesh_max_neightbor",	WORD_T,			_OFFSET(dot1180211sInfo.mesh_max_neightbor),	_SIZE(dot1180211sInfo.mesh_max_neightbor),	MAX_MPP_NUM},
+	{"log_enabled",			BYTE_T,			_OFFSET(dot1180211sInfo.log_enabled),		_SIZE(dot1180211sInfo.log_enabled),		0},
+	{"mesh_privacy",		INT_T,		_OFFSET(dot11sKeysTable.dot11Privacy),	_SIZE(dot11sKeysTable.dot11Privacy),		0},
+	{"mesh_passphrase",	STRING_T,	        _OFFSET(dot1180211sInfo.dot11PassPhrase), _SIZE(dot1180211sInfo.dot11PassPhrase), 0},
+	{"mesh_igmp_enable",	BYTE_T,			_OFFSET(dot1180211sInfo.mesh_igmp_enable),		_SIZE(dot1180211sInfo.mesh_igmp_enable),	1},
+#ifdef _MESH_ACL_ENABLE_
+	{"meshaclmode", 		INT_T,			_OFFSET(dot1180211sInfo.mesh_acl_mode), 		_SIZE(dot1180211sInfo.mesh_acl_mode),		0},
+	{"meshaclnum",			INT_T,			_OFFSET(dot1180211sInfo.mesh_acl_num), 			_SIZE(dot1180211sInfo.mesh_acl_num),		0},
+	{"meshacladdr", 		ACL_T,			_OFFSET(dot1180211sInfo.mesh_acl_addr), 		_SIZE(dot1180211sInfo.mesh_acl_addr),		0},
+#endif
+
+#ifdef 	_11s_TEST_MODE_
+	{"mesh_reserved1",			WORD_T,			_OFFSET(dot1180211sInfo.mesh_reserved1),	_SIZE(dot1180211sInfo.mesh_reserved1),		0},
+	{"mesh_reserved2",			WORD_T,			_OFFSET(dot1180211sInfo.mesh_reserved2),	_SIZE(dot1180211sInfo.mesh_reserved2),		0},
+	{"mesh_reserved3",			WORD_T,			_OFFSET(dot1180211sInfo.mesh_reserved3),	_SIZE(dot1180211sInfo.mesh_reserved3),		0},
+	{"mesh_reserved4",			WORD_T,			_OFFSET(dot1180211sInfo.mesh_reserved4),	_SIZE(dot1180211sInfo.mesh_reserved4),		0},
+	{"mesh_reserved5",			WORD_T,			_OFFSET(dot1180211sInfo.mesh_reserved5),	_SIZE(dot1180211sInfo.mesh_reserved5),		0},
+	{"mesh_reserved6",			WORD_T,			_OFFSET(dot1180211sInfo.mesh_reserved6),	_SIZE(dot1180211sInfo.mesh_reserved6),		0},
+	{"mesh_reserved7",			WORD_T,			_OFFSET(dot1180211sInfo.mesh_reserved7),	_SIZE(dot1180211sInfo.mesh_reserved7),		0},
+	{"mesh_reserved8",			WORD_T,			_OFFSET(dot1180211sInfo.mesh_reserved8),	_SIZE(dot1180211sInfo.mesh_reserved8),		0},
+	{"mesh_reserved9",			WORD_T,			_OFFSET(dot1180211sInfo.mesh_reserved9),	_SIZE(dot1180211sInfo.mesh_reserved9),		0},
+	{"mesh_reserveda",			WORD_T,			_OFFSET(dot1180211sInfo.mesh_reserveda),	_SIZE(dot1180211sInfo.mesh_reserveda),		0},
+	{"mesh_reservedb",			WORD_T,			_OFFSET(dot1180211sInfo.mesh_reservedb),	_SIZE(dot1180211sInfo.mesh_reservedb),		0},
+	{"mesh_reservedc",			WORD_T,			_OFFSET(dot1180211sInfo.mesh_reservedc),	_SIZE(dot1180211sInfo.mesh_reservedc),		0},
+	{"mesh_reservedd",			WORD_T,			_OFFSET(dot1180211sInfo.mesh_reservedd),	_SIZE(dot1180211sInfo.mesh_reservedd),		0},
+	{"mesh_reservede",			WORD_T,			_OFFSET(dot1180211sInfo.mesh_reservede),	_SIZE(dot1180211sInfo.mesh_reservede),		0},
+	{"mesh_reservedf",			WORD_T,			_OFFSET(dot1180211sInfo.mesh_reservedf),	_SIZE(dot1180211sInfo.mesh_reservedf),		0},
+	{"mesh_reservedstr1",		STRING_T,		_OFFSET(dot1180211sInfo.mesh_reservedstr1),	_SIZE(dot1180211sInfo.mesh_reservedstr1),	0},
+#endif
+
+#endif
+
+	// struct Dot1180211AuthEntry
+	{"authtype",	INT_T,		_OFFSET(dot1180211AuthEntry.dot11AuthAlgrthm), _SIZE(dot1180211AuthEntry.dot11AuthAlgrthm), 0},
+	{"encmode",		BYTE_T,		_OFFSET(dot1180211AuthEntry.dot11PrivacyAlgrthm), _SIZE(dot1180211AuthEntry.dot11PrivacyAlgrthm), 0},
+	{"wepdkeyid",	INT_T,		_OFFSET(dot1180211AuthEntry.dot11PrivacyKeyIndex), _SIZE(dot1180211AuthEntry.dot11PrivacyKeyIndex), 0},
+#if defined(INCLUDE_WPA_PSK) || defined(WIFI_HAPD) || defined(RTK_NL80211)
+	{"psk_enable",	INT_T,		_OFFSET(dot1180211AuthEntry.dot11EnablePSK), _SIZE(dot1180211AuthEntry.dot11EnablePSK), 0},
+	{"wpa_cipher",	INT_T,		_OFFSET(dot1180211AuthEntry.dot11WPACipher), _SIZE(dot1180211AuthEntry.dot11WPACipher), 0},
+#ifdef RTL_WPA2
+	{"wpa2_cipher",	INT_T,		_OFFSET(dot1180211AuthEntry.dot11WPA2Cipher), _SIZE(dot1180211AuthEntry.dot11WPA2Cipher), 0},
+#endif
+	{"passphrase",	STRING_T,	_OFFSET(dot1180211AuthEntry.dot11PassPhrase), _SIZE(dot1180211AuthEntry.dot11PassPhrase), 0},
+#ifdef CONFIG_RTL8186_KB
+	{"passphrase_guest", STRING_T, _OFFSET(dot1180211AuthEntry.dot11PassPhraseGuest), _SIZE(dot1180211AuthEntry.dot11PassPhraseGuest), 0},
+#endif
+	{"gk_rekey",	INT_T,		_OFFSET(dot1180211AuthEntry.dot11GKRekeyTime), _SIZE(dot1180211AuthEntry.dot11GKRekeyTime), 0},
+	{"uk_rekey",	INT_T,		_OFFSET(dot1180211AuthEntry.dot11UKRekeyTime), _SIZE(dot1180211AuthEntry.dot11UKRekeyTime), 0},
+#endif
+
+	// struct Dot118021xAuthEntry
+	{"802_1x",		INT_T,		_OFFSET(dot118021xAuthEntry.dot118021xAlgrthm), _SIZE(dot118021xAuthEntry.dot118021xAlgrthm), 0},
+	{"default_port",INT_T,		_OFFSET(dot118021xAuthEntry.dot118021xDefaultPort), _SIZE(dot118021xAuthEntry.dot118021xDefaultPort), 0},
+	{"acct_enabled",INT_T,		_OFFSET(dot118021xAuthEntry.acct_enabled), _SIZE(dot118021xAuthEntry.acct_enabled), 0},
+	{"acct_timeout_INT",INT_T,_OFFSET(dot118021xAuthEntry.acct_timeout_period), _SIZE(dot118021xAuthEntry.acct_timeout_period), 0},
+	{"acct_timeout_TP",INT_T,_OFFSET(dot118021xAuthEntry.acct_timeout_throughput), _SIZE(dot118021xAuthEntry.acct_timeout_throughput), 0},
+
+	// struct Dot11DefaultKeysTable
+	{"wepkey1",		BYTE_ARRAY_T,	_OFFSET(dot11DefaultKeysTable.keytype[0]), _SIZE(dot11DefaultKeysTable.keytype[0]), 0},
+	{"wepkey2",		BYTE_ARRAY_T,	_OFFSET(dot11DefaultKeysTable.keytype[1]), _SIZE(dot11DefaultKeysTable.keytype[1]), 0},
+	{"wepkey3",		BYTE_ARRAY_T,	_OFFSET(dot11DefaultKeysTable.keytype[2]), _SIZE(dot11DefaultKeysTable.keytype[2]), 0},
+	{"wepkey4",		BYTE_ARRAY_T,	_OFFSET(dot11DefaultKeysTable.keytype[3]), _SIZE(dot11DefaultKeysTable.keytype[3]), 0},
+
+	// struct Dot11OperationEntry
+	{"opmode",		INT_T,		_OFFSET(dot11OperationEntry.opmode), _SIZE(dot11OperationEntry.opmode), 0x10},
+	{"hiddenAP",	INT_T,		_OFFSET(dot11OperationEntry.hiddenAP), _SIZE(dot11OperationEntry.hiddenAP), 0},
+	{"rtsthres",	INT_T,		_OFFSET(dot11OperationEntry.dot11RTSThreshold), _SIZE(dot11OperationEntry.dot11RTSThreshold), 2347},
+#ifdef __ECOS
+	{"fragthres",	INT_T,		_OFFSET(dot11OperationEntry.dot11FragmentationThreshold), _SIZE(dot11OperationEntry.dot11FragmentationThreshold), 2346},
+#else
+	{"fragthres",	INT_T,		_OFFSET(dot11OperationEntry.dot11FragmentationThreshold), _SIZE(dot11OperationEntry.dot11FragmentationThreshold), 2347},
+#endif
+	{"shortretry",	INT_T,		_OFFSET(dot11OperationEntry.dot11ShortRetryLimit), _SIZE(dot11OperationEntry.dot11ShortRetryLimit), 0},
+	{"longretry",	INT_T,		_OFFSET(dot11OperationEntry.dot11LongRetryLimit), _SIZE(dot11OperationEntry.dot11LongRetryLimit), 0},
+	{"expired_time",INT_T,		_OFFSET(dot11OperationEntry.expiretime), _SIZE(dot11OperationEntry.expiretime), 30000}, /*in 10ms*/
+#if defined(CONFIG_RTL8672)
+	{"led_type",	INT_T,		_OFFSET(dot11OperationEntry.ledtype), _SIZE(dot11OperationEntry.ledtype), LEDTYPE_SW_LED2_GPIO8_LINKTXRX},
+#else
+	{"led_type",	INT_T,		_OFFSET(dot11OperationEntry.ledtype), _SIZE(dot11OperationEntry.ledtype), 0},
+#endif
+#ifdef RTL8190_SWGPIO_LED
+	{"led_route",	INT_T,		_OFFSET(dot11OperationEntry.ledroute), _SIZE(dot11OperationEntry.ledroute), 0},
+#endif
+	{"iapp_enable",	INT_T,		_OFFSET(dot11OperationEntry.iapp_enable), _SIZE(dot11OperationEntry.iapp_enable), 0},
+	{"block_relay",	INT_T,		_OFFSET(dot11OperationEntry.block_relay), _SIZE(dot11OperationEntry.block_relay), 0},
+	{"deny_any",	INT_T,		_OFFSET(dot11OperationEntry.deny_any), _SIZE(dot11OperationEntry.deny_any), 0},
+	{"crc_log",		INT_T,		_OFFSET(dot11OperationEntry.crc_log), _SIZE(dot11OperationEntry.crc_log), 0},
+	{"wifi_specific",INT_T,		_OFFSET(dot11OperationEntry.wifi_specific), _SIZE(dot11OperationEntry.wifi_specific), 2},
+#ifdef TX_SHORTCUT
+	{"disable_txsc",INT_T,		_OFFSET(dot11OperationEntry.disable_txsc), _SIZE(dot11OperationEntry.disable_txsc), 0},
+#endif
+#ifdef RX_SHORTCUT
+	{"disable_rxsc",INT_T,		_OFFSET(dot11OperationEntry.disable_rxsc), _SIZE(dot11OperationEntry.disable_rxsc), 0},
+#endif
+#ifdef BR_SHORTCUT
+	{"disable_brsc",INT_T,		_OFFSET(dot11OperationEntry.disable_brsc), _SIZE(dot11OperationEntry.disable_brsc), 0},
+#endif
+	{"keep_rsnie",	INT_T,		_OFFSET(dot11OperationEntry.keep_rsnie), _SIZE(dot11OperationEntry.keep_rsnie), 0},
+	{"guest_access",INT_T,		_OFFSET(dot11OperationEntry.guest_access), _SIZE(dot11OperationEntry.guest_access), 0},
+	{"tdls_prohibited",INT_T,	_OFFSET(dot11OperationEntry.tdls_prohibited), _SIZE(dot11OperationEntry.tdls_prohibited), 0},	
+	{"tdls_cs_prohibited",INT_T, 	_OFFSET(dot11OperationEntry.tdls_cs_prohibited), _SIZE(dot11OperationEntry.tdls_cs_prohibited), 0},
+#ifdef CONFIG_IEEE80211V
+	{"wnmtest", 			BYTE_T,		_OFFSET(dot11StationConfigEntry.wnmtest), _SIZE(dot11StationConfigEntry.wnmtest), 0},
+	{"BssTransEnable", 		BYTE_T,		_OFFSET(wnmEntry.dot11vBssTransEnable), _SIZE(wnmEntry.dot11vBssTransEnable), 1},
+	{"BssReqMode",     		BYTE_T,		_OFFSET(wnmEntry.dot11vReqMode), _SIZE(wnmEntry.dot11vReqMode), 3},
+	{"BssDiassocImminent",		BYTE_T, _OFFSET(wnmEntry.dot11vDiassocImminent),		_SIZE(wnmEntry.dot11vDiassocImminent), 0},
+	{"BssDiassocDeadline", 		INT_T,		_OFFSET(wnmEntry.dot11vDiassocDeadline), _SIZE(wnmEntry.dot11vDiassocDeadline), 0},
+	{"BssTransExpiredTime",		BYTE_T,	_OFFSET(wnmEntry.bssTransExpiredTime),			_SIZE(wnmEntry.bssTransExpiredTime), 10},	//10ms
+	{"Is11kDaemonOn",		BYTE_T,	_OFFSET(wnmEntry.Is11kDaemonOn),				_SIZE(wnmEntry.Is11kDaemonOn), 0}, // construct neighbor repor-> 1:  by dot11k daemon;  0: manually
+	{"algoType",			BYTE_T,	_OFFSET(wnmEntry.algoType),						_SIZE(wnmEntry.algoType), 0},	
+	/* band steering */
+	{"BssDbEnable",			BYTE_T,		_OFFSET(wnmEntry.dot11vDriverBasedEnable), _SIZE(wnmEntry.dot11vDriverBasedEnable), 1},
+	{"BssDbIntval",			INT_T,		_OFFSET(wnmEntry.dot11vDbCheckInterval), _SIZE(wnmEntry.dot11vDbCheckInterval), 30},
+	{"BssDbRedirMask",		BYTE_T,		_OFFSET(wnmEntry.dot11vDbRedirectMask), _SIZE(wnmEntry.dot11vDbRedirectMask), 3},
+	{"BssDbApTxLoadThrd",		INT_T,		_OFFSET(wnmEntry.dot11vDbApTxLoadThreshold), _SIZE(wnmEntry.dot11vDbApTxLoadThreshold), 200},
+	{"BssDbStaTxLoadThrd",		INT_T,		_OFFSET(wnmEntry.dot11vDbStaTxLoadThreshold), _SIZE(wnmEntry.dot11vDbStaTxLoadThreshold), 1},
+	{"BssDbApRxLoadThrd",		INT_T,		_OFFSET(wnmEntry.dot11vDbApRxLoadThreshold), _SIZE(wnmEntry.dot11vDbApRxLoadThreshold), 200},
+	{"BssDbStaRxLoadThrd",		INT_T,		_OFFSET(wnmEntry.dot11vDbStaRxLoadThreshold), _SIZE(wnmEntry.dot11vDbStaRxLoadThreshold), 1},
+	{"BssDbBsEnable",		BYTE_T,		_OFFSET(wnmEntry.dot11vDriverBasedBsEnable), _SIZE(wnmEntry.dot11vDriverBasedBsEnable), 1},
+	{"BsSupportNon11vSta",		BYTE_T,		_OFFSET(wnmEntry.dot11vDriverBasedBsSupportNon11vSta), _SIZE(wnmEntry.dot11vDriverBasedBsSupportNon11vSta), 1},
+#endif
+#ifdef CONFIG_POWER_SAVE
+	{"ps_level",INT_T,		_OFFSET(dot11OperationEntry.ps_level), _SIZE(dot11OperationEntry.ps_level), 2},
+	{"ps_timeout",INT_T,	_OFFSET(dot11OperationEntry.ps_timeout), _SIZE(dot11OperationEntry.ps_timeout), 1000},
+	{"ps_sleep_time",INT_T,		_OFFSET(dot11OperationEntry.ps_sleep_time), _SIZE(dot11OperationEntry.ps_sleep_time), 0},
+#endif
+#ifdef HANDLE_TX_THREAD_ZTE
+	{"ps_try_xmit_event",INT_T,	_OFFSET(dot11OperationEntry.ps_try_xmit_event), _SIZE(dot11OperationEntry.ps_try_xmit_event), 0},
+#endif
+	// struct bss_type
+	{"band",		BYTE_T,		_OFFSET(dot11BssType.net_work_type), _SIZE(dot11BssType.net_work_type), 3},
+
+	// struct erp_mib
+	{"cts2self",	INT_T,		_OFFSET(dot11ErpInfo.ctsToSelf), _SIZE(dot11ErpInfo.ctsToSelf), 0},
+
+#ifdef WDS
+	// struct wds_info
+	{"wds_enable",	INT_T,		_OFFSET(dot11WdsInfo.wdsEnabled), _SIZE(dot11WdsInfo.wdsEnabled), 0},
+	{"wds_pure",	INT_T,		_OFFSET(dot11WdsInfo.wdsPure), _SIZE(dot11WdsInfo.wdsPure), 0},
+	{"wds_priority",INT_T,		_OFFSET(dot11WdsInfo.wdsPriority), _SIZE(dot11WdsInfo.wdsPriority), 0},
+	{"wds_num",		INT_T,		_OFFSET(dot11WdsInfo.wdsNum), _SIZE(dot11WdsInfo.wdsNum), 0},
+	{"wds_add",		ACL_INT_T,		_OFFSET(dot11WdsInfo.entry), _SIZE(dot11WdsInfo.entry), 0},
+	{"wds_encrypt",	INT_T,		_OFFSET(dot11WdsInfo.wdsPrivacy), _SIZE(dot11WdsInfo.wdsPrivacy), 0},
+	{"wds_wepkey",	BYTE_ARRAY_T, _OFFSET(dot11WdsInfo.wdsWepKey), _SIZE(dot11WdsInfo.wdsWepKey), 0},
+	{"wds_keyid",	INT_T, _OFFSET(dot11WdsInfo.wdsKeyId), _SIZE(dot11WdsInfo.wdsKeyId), 0},
+#if defined(INCLUDE_WPA_PSK) || defined(WIFI_HAPD) || defined(RTK_NL80211)
+	{"wds_passphrase",	STRING_T, _OFFSET(dot11WdsInfo.wdsPskPassPhrase), _SIZE(dot11WdsInfo.wdsPskPassPhrase), 0},
+#endif
+#endif
+
+#ifdef RTK_BR_EXT
+	// struct br_ext_info
+	{"nat25_disable",		INT_T,	_OFFSET(ethBrExtInfo.nat25_disable), _SIZE(ethBrExtInfo.nat25_disable), 0},
+	{"macclone_enable",		INT_T,	_OFFSET(ethBrExtInfo.macclone_enable), _SIZE(ethBrExtInfo.macclone_enable), 0},
+	{"dhcp_bcst_disable",	INT_T,	_OFFSET(ethBrExtInfo.dhcp_bcst_disable), _SIZE(ethBrExtInfo.dhcp_bcst_disable), 0},
+	{"add_pppoe_tag",		INT_T,	_OFFSET(ethBrExtInfo.addPPPoETag), _SIZE(ethBrExtInfo.addPPPoETag), 1},
+	{"clone_mac_addr",		BYTE_ARRAY_T,	_OFFSET(ethBrExtInfo.nat25_dmzMac), _SIZE(ethBrExtInfo.nat25_dmzMac), 0},
+	{"nat25sc_disable",		INT_T,	_OFFSET(ethBrExtInfo.nat25sc_disable), _SIZE(ethBrExtInfo.nat25sc_disable), 0},
+#endif
+
+#ifdef DFS
+	//struct Dot11DFSEntry
+	{"disable_DFS",	INT_T,		_OFFSET(dot11DFSEntry.disable_DFS), _SIZE(dot11DFSEntry.disable_DFS), 0},
+	{"disable_tx",	INT_T,		_OFFSET(dot11DFSEntry.disable_tx), _SIZE(dot11DFSEntry.disable_tx), 0},
+	{"DFS_timeout",	INT_T,		_OFFSET(dot11DFSEntry.DFS_timeout), _SIZE(dot11DFSEntry.DFS_timeout), 10},	/*in 10ms*/
+	{"DFS_detected",INT_T,		_OFFSET(dot11DFSEntry.DFS_detected), _SIZE(dot11DFSEntry.DFS_detected), 0},
+	{"NOP_timeout",	INT_T,		_OFFSET(dot11DFSEntry.NOP_timeout), _SIZE(dot11DFSEntry.NOP_timeout), 180500}, /*in 10ms*/
+	{"DFS_TXPAUSE_timeout",	INT_T,		_OFFSET(dot11DFSEntry.DFS_TXPAUSE_timeout), _SIZE(dot11DFSEntry.DFS_TXPAUSE_timeout), 1000}, /*in 10ms*/
+	{"CAC_enable",	INT_T,		_OFFSET(dot11DFSEntry.CAC_enable), _SIZE(dot11DFSEntry.CAC_enable), 1},
+#endif
+
+	//struct miscEntry
+	{"show_hidden_bss",INT_T,	_OFFSET(miscEntry.show_hidden_bss), _SIZE(miscEntry.show_hidden_bss), 0},
+	{"ack_timeout",	INT_T,		_OFFSET(miscEntry.ack_timeout), _SIZE(miscEntry.ack_timeout), 0},
+	{"private_ie",	VARLEN_BYTE_T,	_OFFSET(miscEntry.private_ie), _SIZE(miscEntry.private_ie), 0},
+	{"rxInt",		INT_T,		_OFFSET(miscEntry.rxInt_thrd), _SIZE(miscEntry.rxInt_thrd), 300},
+#ifdef DRVMAC_LB
+	{"dmlb",		INT_T,		_OFFSET(miscEntry.drvmac_lb), _SIZE(miscEntry.drvmac_lb), 1},
+	{"lb_da",		BYTE_ARRAY_T,	_OFFSET(miscEntry.lb_da), _SIZE(miscEntry.lb_da), 0},
+	{"lb_tps",		INT_T,	_OFFSET(miscEntry.lb_tps), _SIZE(miscEntry.lb_tps), 0},
+	{"lb_mlmp",		INT_T,	_OFFSET(miscEntry.lb_mlmp), _SIZE(miscEntry.lb_mlmp), 0},
+#endif
+	{"groupID",		INT_T,		_OFFSET(miscEntry.groupID), _SIZE(miscEntry.groupID), 0},
+#ifdef MBSSID
+	{"vap_enable",	INT_T,		_OFFSET(miscEntry.vap_enable), _SIZE(miscEntry.vap_enable), 0},
+#endif
+#ifdef RESERVE_TXDESC_FOR_EACH_IF
+	{"rsv_txdesc",		INT_T,		_OFFSET(miscEntry.rsv_txdesc), _SIZE(miscEntry.rsv_txdesc), 1},
+#endif
+#ifdef USE_TXQUEUE
+	{"use_txq",		INT_T,		_OFFSET(miscEntry.use_txq), _SIZE(miscEntry.use_txq), 1},
+#endif
+	{"func_off",	INT_T,		_OFFSET(miscEntry.func_off), _SIZE(miscEntry.func_off), 0},
+#ifdef AUTO_CHANNEL_TIMEOUT
+	{"autoch_timeout",      INT_T,          _OFFSET(miscEntry.autoch_timeout), _SIZE(miscEntry.autoch_timeout), 0},
+#endif
+	{"ss_loop_delay",			INT_T,	_OFFSET(miscEntry.ss_loop_delay), _SIZE(miscEntry.ss_loop_delay), 0},
+#ifdef SUPPORT_MONITOR
+	{"chan_switch_time",	BYTE_T, 	_OFFSET(miscEntry.chan_switch_time), _SIZE(miscEntry.chan_switch_time), 500},
+#endif
+#ifdef DFS
+	{"passive_ss_int",  INT_T,  _OFFSET(miscEntry.passive_ss_int), _SIZE(miscEntry.passive_ss_int), 120},
+	{"ss_delay",    INT_T,      _OFFSET(miscEntry.ss_delay), _SIZE(miscEntry.ss_delay), 3000},
+#endif
+#ifdef AUTOCH_SS_SPEEDUP
+	{"autoch_ss_to",  INT_T,  _OFFSET(miscEntry.autoch_ss_to), _SIZE(miscEntry.autoch_ss_to), 0},
+	{"autoch_ss_cnt",  INT_T,  _OFFSET(miscEntry.autoch_ss_cnt), _SIZE(miscEntry.autoch_ss_cnt), 0},
+	{"autoch_1611_enable",    INT_T,      _OFFSET(miscEntry.autoch_1611_enable), _SIZE(miscEntry.autoch_1611_enable), 0},
+#endif
+#if defined(CONFIG_USB_TX_AGGREGATION) || defined(CONFIG_SDIO_TX_AGGREGATION)
+	{"max_xmitbuf_agg",    INT_T,      _OFFSET(miscEntry.max_xmitbuf_agg), _SIZE(miscEntry.max_xmitbuf_agg), MAX_XMITBUF_PKT},
+#endif
+#ifdef CONFIG_SDIO_HCI
+	{"max_recvbuf_agg",    INT_T,      _OFFSET(miscEntry.max_recvbuf_agg), _SIZE(miscEntry.max_recvbuf_agg), 1},
+	{"max_handle_xmitbuf",    INT_T,      _OFFSET(miscEntry.max_handle_xmitbuf), _SIZE(miscEntry.max_handle_xmitbuf), 1},
+	{"max_handle_recvbuf",    INT_T,      _OFFSET(miscEntry.max_handle_recvbuf), _SIZE(miscEntry.max_handle_recvbuf), 2},
+#endif
+	//struct Dot11QosEntry
+#ifdef WIFI_WMM
+	{"qos_enable",	INT_T,		_OFFSET(dot11QosEntry.dot11QosEnable), _SIZE(dot11QosEntry.dot11QosEnable), 1},
+#ifdef WMM_APSD
+	{"apsd_enable",	INT_T,		_OFFSET(dot11QosEntry.dot11QosAPSD), _SIZE(dot11QosEntry.dot11QosAPSD), 0},
+#ifdef CLIENT_MODE
+	{"apsd_sta_be",	INT_T,		_OFFSET(dot11QosEntry.UAPSD_AC_BE), _SIZE(dot11QosEntry.UAPSD_AC_BE), 0},
+	{"apsd_sta_bk",	INT_T,		_OFFSET(dot11QosEntry.UAPSD_AC_BK), _SIZE(dot11QosEntry.UAPSD_AC_BK), 0},
+	{"apsd_sta_vi",	INT_T,		_OFFSET(dot11QosEntry.UAPSD_AC_VI), _SIZE(dot11QosEntry.UAPSD_AC_VI), 0},
+	{"apsd_sta_vo",	INT_T,		_OFFSET(dot11QosEntry.UAPSD_AC_VO), _SIZE(dot11QosEntry.UAPSD_AC_VO), 0},
+#endif
+#endif
+
+#ifdef RTL_MANUAL_EDCA
+	{"manual_edca", 		INT_T,			_OFFSET(dot11QosEntry.ManualEDCA),		_SIZE(dot11QosEntry.ManualEDCA),		0},
+	{"sta_bkq_acm", 		INT_T,			_OFFSET(dot11QosEntry.STA_manualEDCA[BK].ACM), _SIZE(dot11QosEntry.STA_manualEDCA[BK].ACM), 0},
+	{"sta_bkq_aifsn",		INT_T,			_OFFSET(dot11QosEntry.STA_manualEDCA[BK].AIFSN), _SIZE(dot11QosEntry.STA_manualEDCA[BK].AIFSN), 7},
+	{"sta_bkq_cwmin",		INT_T,			_OFFSET(dot11QosEntry.STA_manualEDCA[BK].ECWmin), _SIZE(dot11QosEntry.STA_manualEDCA[BK].ECWmin), 4},
+	{"sta_bkq_cwmax",		INT_T,			_OFFSET(dot11QosEntry.STA_manualEDCA[BK].ECWmax), _SIZE(dot11QosEntry.STA_manualEDCA[BK].ECWmax), 10},
+	{"sta_bkq_txoplimit",	INT_T,			_OFFSET(dot11QosEntry.STA_manualEDCA[BK].TXOPlimit), _SIZE(dot11QosEntry.STA_manualEDCA[BK].TXOPlimit), 0},
+	{"sta_beq_acm", 		INT_T,			_OFFSET(dot11QosEntry.STA_manualEDCA[BE].ACM), _SIZE(dot11QosEntry.STA_manualEDCA[BE].ACM), 0},
+	{"sta_beq_aifsn",		INT_T,			_OFFSET(dot11QosEntry.STA_manualEDCA[BE].AIFSN), _SIZE(dot11QosEntry.STA_manualEDCA[BE].AIFSN), 3},
+	{"sta_beq_cwmin",		INT_T,			_OFFSET(dot11QosEntry.STA_manualEDCA[BE].ECWmin), _SIZE(dot11QosEntry.STA_manualEDCA[BE].ECWmin), 4},
+	{"sta_beq_cwmax",		INT_T,			_OFFSET(dot11QosEntry.STA_manualEDCA[BE].ECWmax), _SIZE(dot11QosEntry.STA_manualEDCA[BE].ECWmax), 10},
+	{"sta_beq_txoplimit",	INT_T,			_OFFSET(dot11QosEntry.STA_manualEDCA[BE].TXOPlimit), _SIZE(dot11QosEntry.STA_manualEDCA[BE].TXOPlimit), 0},
+	{"sta_viq_acm", 		INT_T,			_OFFSET(dot11QosEntry.STA_manualEDCA[VI].ACM), _SIZE(dot11QosEntry.STA_manualEDCA[VI].ACM), 0},
+	{"sta_viq_aifsn",		INT_T,			_OFFSET(dot11QosEntry.STA_manualEDCA[VI].AIFSN), _SIZE(dot11QosEntry.STA_manualEDCA[VI].AIFSN), 2},
+	{"sta_viq_cwmin",		INT_T,			_OFFSET(dot11QosEntry.STA_manualEDCA[VI].ECWmin), _SIZE(dot11QosEntry.STA_manualEDCA[VI].ECWmin), 3},
+	{"sta_viq_cwmax",		INT_T,			_OFFSET(dot11QosEntry.STA_manualEDCA[VI].ECWmax), _SIZE(dot11QosEntry.STA_manualEDCA[VI].ECWmax), 4},
+	{"sta_viq_txoplimit",	INT_T,			_OFFSET(dot11QosEntry.STA_manualEDCA[VI].TXOPlimit), _SIZE(dot11QosEntry.STA_manualEDCA[VI].TXOPlimit), 188},
+	//{"ap_viq_txoplimit",	INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[VI].TXOPlimit), _SIZE(dot11QosEntry.AP_manualEDCA[VI].TXOPlimit), (B band)?188:94},
+	{"sta_voq_acm", 		INT_T,			_OFFSET(dot11QosEntry.STA_manualEDCA[VO].ACM), _SIZE(dot11QosEntry.STA_manualEDCA[VO].ACM), 0},
+	{"sta_voq_aifsn",		INT_T,			_OFFSET(dot11QosEntry.STA_manualEDCA[VO].AIFSN), _SIZE(dot11QosEntry.STA_manualEDCA[VO].AIFSN), 2},
+	{"sta_voq_cwmin",		INT_T,			_OFFSET(dot11QosEntry.STA_manualEDCA[VO].ECWmin), _SIZE(dot11QosEntry.STA_manualEDCA[VO].ECWmin), 2},
+	{"sta_voq_cwmax",		INT_T,			_OFFSET(dot11QosEntry.STA_manualEDCA[VO].ECWmax), _SIZE(dot11QosEntry.STA_manualEDCA[VO].ECWmax), 3},
+	{"sta_voq_txoplimit",	INT_T,			_OFFSET(dot11QosEntry.STA_manualEDCA[VO].TXOPlimit), _SIZE(dot11QosEntry.STA_manualEDCA[VO].TXOPlimit), 102},
+	//{"ap_voq_txoplimit",	INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[VO].TXOPlimit), _SIZE(dot11QosEntry.AP_manualEDCA[VO].TXOPlimit), (B band)?102:47},
+	//{"ap_beq_acm",				INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[BE].ACM), _SIZE(dot11QosEntry.AP_manualEDCA[BE].ACM), 0},
+	{"ap_beq_aifsn",		INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[BE].AIFSN), _SIZE(dot11QosEntry.AP_manualEDCA[BE].AIFSN), 3},
+	{"ap_beq_cwmin",		INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[BE].ECWmin), _SIZE(dot11QosEntry.AP_manualEDCA[BE].ECWmin), 4},
+	{"ap_beq_cwmax",		INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[BE].ECWmax), _SIZE(dot11QosEntry.AP_manualEDCA[BE].ECWmax), 6},
+	{"ap_beq_txoplimit",	INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[BE].TXOPlimit), _SIZE(dot11QosEntry.AP_manualEDCA[BE].TXOPlimit), 0},
+	//{"ap_bkq_acm",				INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[BK].ACM), _SIZE(dot11QosEntry.AP_manualEDCA[BK].ACM), 0},
+	{"ap_bkq_aifsn",		INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[BK].AIFSN), _SIZE(dot11QosEntry.AP_manualEDCA[BK].AIFSN), 7},
+	{"ap_bkq_cwmin",		INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[BK].ECWmin), _SIZE(dot11QosEntry.AP_manualEDCA[BK].ECWmin), 4},
+	{"ap_bkq_cwmax",		INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[BK].ECWmax), _SIZE(dot11QosEntry.AP_manualEDCA[BK].ECWmax), 10},
+	{"ap_bkq_txoplimit",	INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[BK].TXOPlimit), _SIZE(dot11QosEntry.AP_manualEDCA[BK].TXOPlimit), 0},
+	//{"ap_viq_acm",				INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[VI].ACM), _SIZE(dot11QosEntry.AP_manualEDCA[VI].ACM), 0},
+	{"ap_viq_aifsn",		INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[VI].AIFSN), _SIZE(dot11QosEntry.AP_manualEDCA[VI].AIFSN), 1},
+	{"ap_viq_cwmin",		INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[VI].ECWmin), _SIZE(dot11QosEntry.AP_manualEDCA[VI].ECWmin), 3},
+	{"ap_viq_cwmax",		INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[VI].ECWmax), _SIZE(dot11QosEntry.AP_manualEDCA[VI].ECWmax), 4},
+	{"ap_viq_txoplimit",	INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[VI].TXOPlimit), _SIZE(dot11QosEntry.AP_manualEDCA[VI].TXOPlimit), 188},
+	//{"ap_viq_txoplimit",	INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[VI].TXOPlimit), _SIZE(dot11QosEntry.AP_manualEDCA[VI].TXOPlimit), (B band)?188:94},
+	//{"ap_voq_acm",				INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[VO].ACM), _SIZE(dot11QosEntry.AP_manualEDCA[VO].ACM), 0},
+	{"ap_voq_aifsn",		INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[VO].AIFSN), _SIZE(dot11QosEntry.AP_manualEDCA[VO].AIFSN), 1},
+	{"ap_voq_cwmin",		INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[VO].ECWmin), _SIZE(dot11QosEntry.AP_manualEDCA[VO].ECWmin), 2},
+	{"ap_voq_cwmax",		INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[VO].ECWmax), _SIZE(dot11QosEntry.AP_manualEDCA[VO].ECWmax), 3},
+	{"ap_voq_txoplimit",	INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[VO].TXOPlimit), _SIZE(dot11QosEntry.AP_manualEDCA[VO].TXOPlimit), 102},
+	//{"ap_voq_txoplimit",	INT_T,			_OFFSET(dot11QosEntry.AP_manualEDCA[VO].TXOPlimit), _SIZE(dot11QosEntry.AP_manualEDCA[VO].TXOPlimit), (B band)?102:47},
+
+	{"tid0_mapping",		BYTE_T,	_OFFSET(dot11QosEntry.TID_mapping[0]), _SIZE(dot11QosEntry.TID_mapping[0]), BE_QUEUE},
+	{"tid1_mapping",		BYTE_T,	_OFFSET(dot11QosEntry.TID_mapping[1]), _SIZE(dot11QosEntry.TID_mapping[1]), BK_QUEUE},
+	{"tid2_mapping",		BYTE_T,	_OFFSET(dot11QosEntry.TID_mapping[2]), _SIZE(dot11QosEntry.TID_mapping[2]), BK_QUEUE},
+	{"tid3_mapping",		BYTE_T,	_OFFSET(dot11QosEntry.TID_mapping[3]), _SIZE(dot11QosEntry.TID_mapping[3]), BE_QUEUE},
+	{"tid4_mapping",		BYTE_T,	_OFFSET(dot11QosEntry.TID_mapping[4]), _SIZE(dot11QosEntry.TID_mapping[4]), VI_QUEUE},
+	{"tid5_mapping",		BYTE_T,	_OFFSET(dot11QosEntry.TID_mapping[5]), _SIZE(dot11QosEntry.TID_mapping[5]), VI_QUEUE},
+	{"tid6_mapping",		BYTE_T,	_OFFSET(dot11QosEntry.TID_mapping[6]), _SIZE(dot11QosEntry.TID_mapping[6]), VO_QUEUE},
+	{"tid7_mapping",		BYTE_T,	_OFFSET(dot11QosEntry.TID_mapping[7]), _SIZE(dot11QosEntry.TID_mapping[7]), VO_QUEUE},
+#endif //RTL_MANUAL_EDCA
+
+#endif //WIFI_WMM
+
+#ifdef WIFI_SIMPLE_CONFIG
+	// struct WifiSimpleConfigEntry
+	{"wsc_enable",	INT_T,	_OFFSET(wscEntry.wsc_enable), _SIZE(wscEntry.wsc_enable), 0},
+	{"pin",			PIN_IND_T, 0, 0},
+	/* WPS2DOTX   */
+	/* support  Assigned MAC Addr,Assigned SSID,dymanic change STA's PIN code, 2011-0505 */	
+	{"wsc_mypin",	WSC_SELF_PIN_IND_T, 0, 0},
+	{"wsc_specssid",WSC_SEPC_SSID_CONN_IND_T, 0, 0},	
+	{"wsc_specmac",	WSC_SEPC_MAC_CONN_IND_T, 0, 0},	
+	/* WPS2DOTX   */
+#ifdef INCLUDE_WPS
+#ifndef CONFIG_MSC
+	{"wsc_start2",   WSC_IND_T, 0, 0},
+	{"wsc_end",   WSC_IND_T, 0, 0},
+	{"wsc_soap_action",   WSC_IND_T, 0, 0},
+	{"wps_led_control",   WSC_IND_T, 0, 0},
+	{"wps_get_config",   WSC_IND_T, 0, 0},
+	{"wps_debug",   WSC_IND_T, 0, 0},
+	{"wps_reinit",   WSC_IND_T, 0, 0},
+#endif
+#endif
+#ifdef CONFIG_RTL_COMAPI_CFGFILE
+	{"wsc_start",		WSC_START_IND_T, 0, 0},
+	{"wsc_mode",		WSC_MODE_IND_T, 0, 0},
+	{"wsc_status",		WSC_STATUS_IND_T, 0, 0},
+	{"wsc_method",		WSC_METHOD_IND_T, 0, 0},
+	{"wsc_step",		WSC_STEP_IND_T, 0, 0},
+	{"wsc_oob",		WSC_OOB_IND_T, 0, 0},
+#endif //CONFIG_RTL_COMAPI_CFGFILE
+#endif
+
+#ifdef GBWC
+	// struct GroupBandWidthControl
+	{"gbwcmode",	INT_T,		_OFFSET(gbwcEntry.GBWCMode), _SIZE(gbwcEntry.GBWCMode), 0},
+	{"gbwcnum",		INT_T,		_OFFSET(gbwcEntry.GBWCNum), _SIZE(gbwcEntry.GBWCNum), 0},
+	{"gbwcaddr",	ACL_T,		_OFFSET(gbwcEntry.GBWCAddr), _SIZE(gbwcEntry.GBWCAddr), 0},
+	{"gbwcthrd_tx",	INT_T,		_OFFSET(gbwcEntry.GBWCThrd_tx), _SIZE(gbwcEntry.GBWCThrd_tx), 30000},
+	{"gbwcthrd_rx",	INT_T,		_OFFSET(gbwcEntry.GBWCThrd_rx), _SIZE(gbwcEntry.GBWCThrd_rx), 30000},	
+#endif
+
+	// struct Dot11nConfigEntry
+	{"supportedmcs",INT_T,		_OFFSET(dot11nConfigEntry.dot11nSupportedMCS), _SIZE(dot11nConfigEntry.dot11nSupportedMCS), 0xffff},
+	{"basicmcs",	INT_T,		_OFFSET(dot11nConfigEntry.dot11nBasicMCS), _SIZE(dot11nConfigEntry.dot11nBasicMCS), 0},
+	{"use40M",		INT_T,		_OFFSET(dot11nConfigEntry.dot11nUse40M), _SIZE(dot11nConfigEntry.dot11nUse40M), 0},
+	{"2ndchoffset",	INT_T,		_OFFSET(dot11nConfigEntry.dot11n2ndChOffset), _SIZE(dot11nConfigEntry.dot11n2ndChOffset), 1},
+	{"shortGI20M",	INT_T,		_OFFSET(dot11nConfigEntry.dot11nShortGIfor20M), _SIZE(dot11nConfigEntry.dot11nShortGIfor20M), 0},
+	{"shortGI40M",	INT_T,		_OFFSET(dot11nConfigEntry.dot11nShortGIfor40M), _SIZE(dot11nConfigEntry.dot11nShortGIfor40M), 0},
+	{"shortGI80M",	INT_T,		_OFFSET(dot11nConfigEntry.dot11nShortGIfor80M), _SIZE(dot11nConfigEntry.dot11nShortGIfor80M), 0},
+	{"stbc",		INT_T,		_OFFSET(dot11nConfigEntry.dot11nSTBC), _SIZE(dot11nConfigEntry.dot11nSTBC), 1},
+#if defined(CONFIG_RTL8672) && defined(CONFIG_WLAN_HAL_8192EE)
+	{"ldpc",		INT_T,		_OFFSET(dot11nConfigEntry.dot11nLDPC), _SIZE(dot11nConfigEntry.dot11nLDPC), 0},
+#else
+	{"ldpc",		INT_T,		_OFFSET(dot11nConfigEntry.dot11nLDPC), _SIZE(dot11nConfigEntry.dot11nLDPC), 1},
+#endif
+	{"ampdu",		INT_T,		_OFFSET(dot11nConfigEntry.dot11nAMPDU), _SIZE(dot11nConfigEntry.dot11nAMPDU), 0},
+	{"amsdu",		INT_T,		_OFFSET(dot11nConfigEntry.dot11nAMSDU), _SIZE(dot11nConfigEntry.dot11nAMSDU), 0},
+	// for support SIGMA_TEST
+	{"addba_reject",INT_T,		_OFFSET(dot11nConfigEntry.dot11nAddBAreject), _SIZE(dot11nConfigEntry.dot11nAddBAreject), 0},	
+	{"ampduSndSz",	INT_T,		_OFFSET(dot11nConfigEntry.dot11nAMPDUSendSz), _SIZE(dot11nConfigEntry.dot11nAMPDUSendSz), 0},
+	{"ampduRecvSz",		INT_T,	_OFFSET(dot11nConfigEntry.dot11nAMPDURevSz), _SIZE(dot11nConfigEntry.dot11nAMPDURevSz), 0},
+#ifdef CONFIG_WLAN_HAL_8814AE 
+	{"supportedvht",INT_T,		_OFFSET(dot11acConfigEntry.dot11SupportedVHT), _SIZE(dot11acConfigEntry.dot11SupportedVHT), 0xffea},	
+#else
+	{"supportedvht",INT_T,		_OFFSET(dot11acConfigEntry.dot11SupportedVHT), _SIZE(dot11acConfigEntry.dot11SupportedVHT), 0xfffa},	
+#endif		
+	{"vht_txmap",INT_T,		_OFFSET(dot11acConfigEntry.dot11VHT_TxMap), _SIZE(dot11acConfigEntry.dot11VHT_TxMap), 0x3fffffff},
+	
+#ifdef RX_BUFFER_GATHER
+	{"amsduMax",	INT_T,		_OFFSET(dot11nConfigEntry.dot11nAMSDURecvMax), _SIZE(dot11nConfigEntry.dot11nAMSDURecvMax), 1},
+#else
+#if defined(CONFIG_RTL8196B_GW_8M) || defined(CONFIG_RTL8196C_AP_ROOT) || defined(CONFIG_RTL_8198_AP_ROOT) || defined(CONFIG_RTL8196C_CLIENT_ONLY)
+	{"amsduMax",	INT_T,		_OFFSET(dot11nConfigEntry.dot11nAMSDURecvMax), _SIZE(dot11nConfigEntry.dot11nAMSDURecvMax), 0},
+#else
+	{"amsduMax",	INT_T,		_OFFSET(dot11nConfigEntry.dot11nAMSDURecvMax), _SIZE(dot11nConfigEntry.dot11nAMSDURecvMax), 0},
+#endif
+#endif
+	{"amsduTimeout",INT_T,		_OFFSET(dot11nConfigEntry.dot11nAMSDUSendTimeout), _SIZE(dot11nConfigEntry.dot11nAMSDUSendTimeout), 400}, /*in us*/
+	{"amsduNum",	INT_T,		_OFFSET(dot11nConfigEntry.dot11nAMSDUSendNum), _SIZE(dot11nConfigEntry.dot11nAMSDUSendNum), 15},
+	{"lgyEncRstrct",INT_T,		_OFFSET(dot11nConfigEntry.dot11nLgyEncRstrct), _SIZE(dot11nConfigEntry.dot11nLgyEncRstrct), 15},
+#ifdef WIFI_11N_2040_COEXIST
+#ifdef CONFIG_SDIO_HCI
+	{"coexist",		INT_T,		_OFFSET(dot11nConfigEntry.dot11nCoexist), _SIZE(dot11nConfigEntry.dot11nCoexist), 1},
+#else
+	{"coexist",		INT_T,		_OFFSET(dot11nConfigEntry.dot11nCoexist), _SIZE(dot11nConfigEntry.dot11nCoexist), 0},
+	{"coexist_ch_chk",		INT_T,		_OFFSET(dot11nConfigEntry.dot11nCoexist_ch_chk), _SIZE(dot11nConfigEntry.dot11nCoexist_ch_chk), 0},	
+#endif
+	{"bg_ap_rssi_chk_th",	INT_T,		_OFFSET(dot11nConfigEntry.dot11nBGAPRssiChkTh), _SIZE(dot11nConfigEntry.dot11nBGAPRssiChkTh), 20},
+#endif
+	{"txnoack",		INT_T,		_OFFSET(dot11nConfigEntry.dot11nTxNoAck), _SIZE(dot11nConfigEntry.dot11nTxNoAck), 0},
+
+	// struct ReorderControlEntry
+	{"rc_enable",	INT_T,		_OFFSET(reorderCtrlEntry.ReorderCtrlEnable), _SIZE(reorderCtrlEntry.ReorderCtrlEnable), 1},
+	{"rc_winsz",	INT_T,		_OFFSET(reorderCtrlEntry.ReorderCtrlWinSz), _SIZE(reorderCtrlEntry.ReorderCtrlWinSz), RC_ENTRY_NUM},
+	{"rc_timeout",	INT_T,		_OFFSET(reorderCtrlEntry.ReorderCtrlTimeout), _SIZE(reorderCtrlEntry.ReorderCtrlTimeout), 30000}, /*in us*/
+
+#if defined(CONFIG_RTK_VLAN_SUPPORT) || defined(NOT_RTK_BSP_VLAN)
+	// struct VlanConfig
+	{"global_vlan",	INT_T,		_OFFSET(vlan.global_vlan), _SIZE(vlan.global_vlan), 0},
+	{"is_lan",	INT_T,		_OFFSET(vlan.is_lan), _SIZE(vlan.is_lan), 1},
+	{"vlan_enable",	INT_T,		_OFFSET(vlan.vlan_enable), _SIZE(vlan.vlan_enable), 0},
+	{"vlan_tag",	INT_T,		_OFFSET(vlan.vlan_tag), _SIZE(vlan.vlan_tag), 0},
+	{"vlan_id",	INT_T,		_OFFSET(vlan.vlan_id), _SIZE(vlan.vlan_id), 0},
+	{"vlan_pri",	INT_T,		_OFFSET(vlan.vlan_pri), _SIZE(vlan.vlan_pri), 0},
+	{"vlan_cfi",	INT_T,		_OFFSET(vlan.vlan_cfi), _SIZE(vlan.vlan_cfi), 0},
+#endif
+
+#ifdef  CONFIG_RTL_WAPI_SUPPORT
+	{"wapiType",		INT_T,	_OFFSET(wapiInfo.wapiType), _SIZE(wapiInfo.wapiType), 0},
+#ifdef  WAPI_SUPPORT_MULTI_ENCRYPT
+	{"wapiUCastEncodeType",		INT_T,	_OFFSET(wapiInfo.wapiUCastEncodeType), _SIZE(wapiInfo.wapiUCastEncodeType), 0},
+	{"wapiMCastEncodeType",		INT_T,	_OFFSET(wapiInfo.wapiMCastEncodeType), _SIZE(wapiInfo.wapiMCastEncodeType), 0},
+#endif
+	{"wapiPsk",	WAPI_KEY_T,	_OFFSET(wapiInfo.wapiPsk), _SIZE(wapiInfo.wapiPsk), 0},
+	{"wapiPsklen",	INT_T,	_OFFSET(wapiInfo.wapiPsk.len), _SIZE(wapiInfo.wapiPsk.len), 0},
+	{"wapiUCastKeyType",		INT_T,	_OFFSET(wapiInfo.wapiUpdateUCastKeyType), _SIZE(wapiInfo.wapiUpdateUCastKeyType), 0},
+	{"wapiUCastKeyTimeout",		INT_T,	_OFFSET(wapiInfo.wapiUpdateUCastKeyTimeout), _SIZE(wapiInfo.wapiUpdateUCastKeyTimeout), 0},
+	{"wapiUCastKeyPktNum",		INT_T,	_OFFSET(wapiInfo.wapiUpdateUCastKeyPktNum), _SIZE(wapiInfo.wapiUpdateUCastKeyPktNum), 0},
+	{"wapiMCastKeyType",		INT_T,	_OFFSET(wapiInfo.wapiUpdateMCastKeyType), _SIZE(wapiInfo.wapiUpdateMCastKeyType), 0},
+	{"wapiMCastKeyTimeout",		INT_T,	_OFFSET(wapiInfo.wapiUpdateMCastKeyTimeout), _SIZE(wapiInfo.wapiUpdateMCastKeyTimeout), 0},
+	{"wapiMCastKeyPktNum",		INT_T,	_OFFSET(wapiInfo.wapiUpdateMCastKeyPktNum), _SIZE(wapiInfo.wapiUpdateMCastKeyPktNum), 0},
+	{"wapiTimeout",		INT_ARRAY_T,	_OFFSET(wapiInfo.wapiTimeout), _SIZE(wapiInfo.wapiTimeout), 0},
+#endif
+
+#ifdef DOT11D
+	{"countrycode",		INT_T,	_OFFSET(dot11dCountry.dot11CountryCodeSwitch), _SIZE(dot11dCountry.dot11CountryCodeSwitch), 1},
+#endif	
+#if defined(DOT11D) || defined(DOT11H) || defined(DOT11K)
+	{"countrystr",	STRING_T,	_OFFSET(dot11dCountry.dot11CountryString), _SIZE(dot11dCountry.dot11CountryString), 0},
+	{"country2reg",		INT_T,	_OFFSET(dot11dCountry.dot11CountryCodeToRegDomain), _SIZE(dot11dCountry.dot11CountryCodeToRegDomain), 0},
+#endif
+
+#ifdef DOT11H
+	{"tpc_enable", BYTE_T,      _OFFSET(dot11hTPCEntry.tpc_enable), _SIZE(dot11hTPCEntry.tpc_enable), 1},
+#endif
+#if defined(DOT11H) || defined(DOT11K)
+	{"tpc_tx_power", BYTE_T,    _OFFSET(dot11hTPCEntry.tpc_tx_power), _SIZE(dot11hTPCEntry.tpc_tx_power), 12},
+	{"tpc_link_margin", BYTE_T, _OFFSET(dot11hTPCEntry.tpc_link_margin), _SIZE(dot11hTPCEntry.tpc_link_margin), 0}, // set 0 for AP
+	{"lpwrc", RFFT_T, _OFFSET_RFFT(lpwrc), _SIZE_RFFT(lpwrc), 0},
+#if defined(CLIENT_MODE) || defined(CONFIG_RTK_MESH)    
+	{"min_tx_power", BYTE_T, _OFFSET(dot11hTPCEntry.min_tx_power), _SIZE(dot11hTPCEntry.min_tx_power), 0},// for power capability ie
+	{"max_tx_power", BYTE_T, _OFFSET(dot11hTPCEntry.max_tx_power), _SIZE(dot11hTPCEntry.max_tx_power), 20},// for power capability ie
+#endif
+#endif
+
+#ifdef DOT11K /*radio measurement*/
+	{"rm_activated", BYTE_T, _OFFSET(dot11StationConfigEntry.dot11RadioMeasurementActivated), _SIZE(dot11StationConfigEntry.dot11RadioMeasurementActivated), 0},
+	{"rm_link_measure", BYTE_T, _OFFSET(dot11StationConfigEntry.dot11RMLinkMeasurementActivated), _SIZE(dot11StationConfigEntry.dot11RMLinkMeasurementActivated), 1},
+	{"rm_neighbor_report", BYTE_T, _OFFSET(dot11StationConfigEntry.dot11RMNeighborReportActivated), _SIZE(dot11StationConfigEntry.dot11RMNeighborReportActivated), 1},   
+	{"rm_beacon_passive", BYTE_T, _OFFSET(dot11StationConfigEntry.dot11RMBeaconPassiveMeasurementActivated), _SIZE(dot11StationConfigEntry.dot11RMBeaconPassiveMeasurementActivated), 1},
+	{"rm_beacon_active", BYTE_T, _OFFSET(dot11StationConfigEntry.dot11RMBeaconActiveMeasurementActivated), _SIZE(dot11StationConfigEntry.dot11RMBeaconActiveMeasurementActivated), 1},
+	{"rm_beacon_table", BYTE_T, _OFFSET(dot11StationConfigEntry.dot11RMBeaconTableMeasurementActivated), _SIZE(dot11StationConfigEntry.dot11RMBeaconTableMeasurementActivated), 1},
+	{"rm_ap_channel_report", BYTE_T, _OFFSET(dot11StationConfigEntry.dot11RMAPChannelReportActivated), _SIZE(dot11StationConfigEntry.dot11RMAPChannelReportActivated), 1},
+	{"rm_neighbor_expire", INT_T, _OFFSET(dot11StationConfigEntry.dot11RMNeighborReportExpireTime), _SIZE(dot11StationConfigEntry.dot11RMNeighborReportExpireTime), 86400},   
+#endif
+
+#ifdef SUPPORT_MULTI_PROFILE
+	{"ap_profile_enable",		INT_T,	_OFFSET(ap_profile.enable_profile), _SIZE(ap_profile.enable_profile), 0},
+	{"ap_profile_num",		INT_T,	_OFFSET(ap_profile.profile_num), _SIZE(ap_profile.profile_num), 0},	
+	{"ap_profile_add",		AP_PROFILE_T,	_OFFSET(ap_profile), _SIZE(ap_profile), 0},
+	{"sortbyprofile",		INT_T,	_OFFSET(ap_profile.sortbyprofile), _SIZE(ap_profile.sortbyprofile), 0},		
+#endif
+
+/* Hotspot 2.0 */
+#ifdef HS2_SUPPORT
+/* Release 1 */
+	{"timedtimintval",  INT_T,  _OFFSET(hs2Entry.timeadvt_DTIMIntval), _SIZE(hs2Entry.timeadvt_DTIMIntval), 1},
+	{"reqmode",			INT_T,  _OFFSET(hs2Entry.reqmode), _SIZE(hs2Entry.reqmode), 16},
+	{"distime",			INT_T,  _OFFSET(hs2Entry.disassoc_timer), _SIZE(hs2Entry.disassoc_timer), 10},
+	{"valintval",		INT_T,  _OFFSET(hs2Entry.validity_intval), _SIZE(hs2Entry.validity_intval), 0},
+	{"surl",			STRING_T,  _OFFSET(hs2Entry.session_url), _SIZE(hs2Entry.session_url), 0},
+	{"redir_mac",		BYTE_ARRAY_T,   _OFFSET(hs2Entry.redir_mac), _SIZE(hs2Entry.redir_mac), 0},
+	{"tsm_req",			BYTE_ARRAY_T,   _OFFSET(hs2Entry.sta_mac), _SIZE(hs2Entry.sta_mac), 0},
+	{"roam_enable",			INT_T,   _OFFSET(hs2Entry.roam_enable), _SIZE(hs2Entry.roam_enable), 1},	
+	{"mmpdu_limit",			INT_T,   _OFFSET(hs2Entry.mmpdu_limit), _SIZE(hs2Entry.mmpdu_limit), 600},	
+	{"ICMPv4ECHO",			INT_T,   _OFFSET(hs2Entry.ICMPv4ECHO), _SIZE(hs2Entry.ICMPv4ECHO), 2},
+#ifdef HS2_DEBUGMSG
+		{"HS2_debug_info",	INT_T, ((int)(long *)&(_HS2_debug_info)), sizeof(_HS2_debug_info), 1},
+		{"HS2_debug_err",	INT_T, ((int)(long *)&(_HS2_debug_err)), sizeof(_HS2_debug_err), 1},
+		{"HS2_debug_trace", INT_T, ((int)(long *)&(_HS2_debug_trace)), sizeof(_HS2_debug_trace), 0},
+		{"HS2_debug_warn",	INT_T, ((int)(long *)&(_HS2_debug_warn)), sizeof(_HS2_debug_warn), 0},
+#endif		
+#endif	//HS2_SUPPORT
+
+#if defined(SWITCH_CHAN) && defined(UNIVERSAL_REPEATER)
+	{"switch_chan",			SWITCH_CHAN_T,	_OFFSET(dot11RFEntry.dot11channel), _SIZE(dot11RFEntry.dot11channel), 0},
+#endif
+
+#ifdef _DEBUG_RTL8192CD_
+	// debug flag
+	{"debug_err",	DEBUG_T,	1, sizeof(rtl8192cd_debug_err), 0},
+	{"debug_info",	DEBUG_T,	2, sizeof(rtl8192cd_debug_info), 0},
+	{"debug_trace",	DEBUG_T,	3, sizeof(rtl8192cd_debug_trace), 0},
+	{"debug_warn",	DEBUG_T,	4, sizeof(rtl8192cd_debug_warn), 0},
+	{"debug_psk",	DEBUG_T,	5, sizeof(rtl8192cd_debug_psk), 0},
+	{"debug_memlog",DEBUG_T,	6, sizeof(rtl8192cd_debug_memlog), 0},
+#endif
+
+	// for RF debug
+	{"ofdm_1ss_oneAnt",	RFFT_T,	_OFFSET_RFFT(ofdm_1ss_oneAnt), _SIZE_RFFT(ofdm_1ss_oneAnt), 0},// 1ss and ofdm rate using one ant
+	{"pathB_1T",		RFFT_T,	_OFFSET_RFFT(pathB_1T), _SIZE_RFFT(pathB_1T), 0},// using pathB as 1T2R/1T1R tx path
+	{"force_1t2r",	RFFT_T,	_OFFSET_RFFT(force_1t2r), _SIZE_RFFT(force_1t2r), 0},
+	{"rssi_dump",		RFFT_T,	_OFFSET_RFFT(rssi_dump), _SIZE_RFFT(rssi_dump), 0},
+	{"rxfifoO",			RFFT_T,	_OFFSET_RFFT(rxfifoO), _SIZE_RFFT(rxfifoO), 0},
+	{"raGoDownUpper",	RFFT_T,	_OFFSET_RFFT(raGoDownUpper), _SIZE_RFFT(raGoDownUpper), 50},
+	{"raGoDown20MLower",RFFT_T,	_OFFSET_RFFT(raGoDown20MLower), _SIZE_RFFT(raGoDown20MLower), 18},
+	{"raGoDown40MLower",RFFT_T,	_OFFSET_RFFT(raGoDown40MLower), _SIZE_RFFT(raGoDown40MLower), 15},
+	{"raGoUpUpper",		RFFT_T,	_OFFSET_RFFT(raGoUpUpper), _SIZE_RFFT(raGoUpUpper), 55},
+	{"raGoUp20MLower",	RFFT_T,	_OFFSET_RFFT(raGoUp20MLower), _SIZE_RFFT(raGoUp20MLower), 23},
+	{"raGoUp40MLower",	RFFT_T,	_OFFSET_RFFT(raGoUp40MLower), _SIZE_RFFT(raGoUp40MLower), 20},
+	{"dig_enable",		RFFT_T,	_OFFSET_RFFT(dig_enable), _SIZE_RFFT(dig_enable), 1},
+	{"adaptivity_enable",		RFFT_T,	_OFFSET_RFFT(adaptivity_enable), _SIZE_RFFT(adaptivity_enable), 0},
+	{"nbi_filter_enable",	RFFT_T,	_OFFSET_RFFT(nbi_filter_enable), _SIZE_RFFT(nbi_filter_enable), 1},
+	{"dig_cov_enable",		RFFT_T, _OFFSET_RFFT(dig_cov_enable), _SIZE_RFFT(dig_cov_enable), 0},
+	{"adap_debug",		RFFT_T, _OFFSET_RFFT(adap_debug), _SIZE_RFFT(adap_debug), 0},
+#ifdef INTERFERENCE_CONTROL
+	{"digGoLowerLevel", RFFT_T, _OFFSET_RFFT(digGoLowerLevel), _SIZE_RFFT(digGoLowerLevel), 30},
+    {"digGoUpperLevel", RFFT_T, _OFFSET_RFFT(digGoUpperLevel), _SIZE_RFFT(digGoUpperLevel), 35},
+#else
+	{"digGoLowerLevel",	RFFT_T,	_OFFSET_RFFT(digGoLowerLevel), _SIZE_RFFT(digGoLowerLevel), 35},
+	{"digGoUpperLevel",	RFFT_T,	_OFFSET_RFFT(digGoUpperLevel), _SIZE_RFFT(digGoUpperLevel), 40},
+#endif
+	{"dcThUpper",		RFFT_T,	_OFFSET_RFFT(dcThUpper), _SIZE_RFFT(dcThUpper), 30},
+	{"dcThLower",		RFFT_T,	_OFFSET_RFFT(dcThLower), _SIZE_RFFT(dcThLower), 25},
+	{"rssiTx20MUpper",	RFFT_T,	_OFFSET_RFFT(rssiTx20MUpper), _SIZE_RFFT(rssiTx20MUpper), 20},
+	{"rssiTx20MLower",	RFFT_T,	_OFFSET_RFFT(rssiTx20MLower), _SIZE_RFFT(rssiTx20MLower), 15},
+	{"rssi_expire_to",	RFFT_T,	_OFFSET_RFFT(rssi_expire_to), _SIZE_RFFT(rssi_expire_to), 60},
+	{"rts_init_rate",	RFFT_T,	_OFFSET_RFFT(rts_init_rate), _SIZE_RFFT(rts_init_rate), 0},
+	{"auto_rts_rate",	RFFT_T,	_OFFSET_RFFT(auto_rts_rate), _SIZE_RFFT(auto_rts_rate), 1},	
+
+	{"cck_pwr_max",		RFFT_T,	_OFFSET_RFFT(cck_pwr_max), _SIZE_RFFT(cck_pwr_max), 0},
+	{"cck_tx_pathB",	RFFT_T,	_OFFSET_RFFT(cck_tx_pathB), _SIZE_RFFT(cck_tx_pathB), 0},
+
+	{"tx_pwr_ctrl",		RFFT_T,	_OFFSET_RFFT(tx_pwr_ctrl), _SIZE_RFFT(tx_pwr_ctrl), 1},
+
+	// 11n ap AES debug
+	{"aes_check_th",	RFFT_T,	_OFFSET_RFFT(aes_check_th), _SIZE_RFFT(aes_check_th), 2},
+
+	// Tx power tracking
+	{"tpt_period",		RFFT_T,	_OFFSET_RFFT(tpt_period), _SIZE_RFFT(tpt_period), 2},
+
+	// TXOP enlarge
+	{"txop_enlarge_upper",		RFFT_T,	_OFFSET_RFFT(txop_enlarge_upper), _SIZE_RFFT(txop_enlarge_upper), 20},
+	{"txop_enlarge_lower",		RFFT_T,	_OFFSET_RFFT(txop_enlarge_lower), _SIZE_RFFT(txop_enlarge_lower), 15},
+
+#ifdef LOW_TP_TXOP
+	{"low_tp_txop",				RFFT_T,	_OFFSET_RFFT(low_tp_txop),	_SIZE_RFFT(low_tp_txop), 1},
+	{"low_tp_txop_thd_n",		RFFT_T,	_OFFSET_RFFT(low_tp_txop_thd_n),	_SIZE_RFFT(low_tp_txop_thd_n), 22},
+	{"low_tp_txop_thd_g",		RFFT_T,	_OFFSET_RFFT(low_tp_txop_thd_g),	_SIZE_RFFT(low_tp_txop_thd_g), 17},
+	{"low_tp_txop_thd_low",		RFFT_T,	_OFFSET_RFFT(low_tp_txop_thd_low),	_SIZE_RFFT(low_tp_txop_thd_low), 0},
+	{"low_tp_txop_delay",		RFFT_T,	_OFFSET_RFFT(low_tp_txop_delay),	_SIZE_RFFT(low_tp_txop_delay), 1},
+	{"cwmax_enhance_thd",		RFFT_T,	_OFFSET_RFFT(cwmax_enhance_thd), _SIZE_RFFT(cwmax_enhance_thd), 2000},
+#endif
+
+	// 2.3G support
+	{"frq_2_3G",		RFFT_T,	_OFFSET_RFFT(use_frq_2_3G), _SIZE_RFFT(use_frq_2_3G), 0},
+
+	// for mp test
+#ifdef MP_TEST
+	{"mp_specific",		RFFT_T,	_OFFSET_RFFT(mp_specific), _SIZE_RFFT(mp_specific), 0},
+#endif
+
+#ifdef IGMP_FILTER_CMO
+	{"igmp_deny",		RFFT_T,	_OFFSET_RFFT(igmp_deny), _SIZE_RFFT(igmp_deny), 0},
+#endif
+	//Support IP multicast->unicast
+#ifdef SUPPORT_TX_MCAST2UNI
+	{"mc2u_disable",	RFFT_T,	_OFFSET_RFFT(mc2u_disable), _SIZE_RFFT(mc2u_disable), 0},
+#ifdef CONFIG_RTL8672
+	{"mc2u_drop_unknown",	RFFT_T,	_OFFSET_RFFT(mc2u_drop_unknown), _SIZE_RFFT(mc2u_drop_unknown), 1},
+#else	
+	{"mc2u_drop_unknown",	RFFT_T,	_OFFSET_RFFT(mc2u_drop_unknown), _SIZE_RFFT(mc2u_drop_unknown), 0},
+#endif
+	{"mc2u_flood_ctrl",	RFFT_T,	_OFFSET_RFFT(mc2u_flood_ctrl), _SIZE_RFFT(mc2u_flood_ctrl), 0},
+	{"mc2u_flood_mac_num",	RFFT_T,		_OFFSET_RFFT(mc2u_flood_mac_num), _SIZE_RFFT(mc2u_flood_mac_num), 0},
+	{"mc2u_flood_mac",		RFFT_ACL_T,		_OFFSET_RFFT(mc2u_flood_mac), _SIZE_RFFT(mc2u_flood_mac), 0},
+#endif
+
+#ifdef HIGH_POWER_EXT_PA
+	{"use_ext_pa",		RFFT_T,	_OFFSET_RFFT(use_ext_pa), _SIZE_RFFT(use_ext_pa), 0},
+	{"hp_ofdm_max",		RFFT_T,	_OFFSET_RFFT(hp_ofdm_pwr_max), _SIZE_RFFT(hp_ofdm_pwr_max), 63},
+	{"hp_cck_max",		RFFT_T,	_OFFSET_RFFT(hp_cck_pwr_max), _SIZE_RFFT(hp_cck_pwr_max), 63},
+#endif
+
+#if defined(CONFIG_RTL_NOISE_CONTROL) || defined(CONFIG_RTL_NOISE_CONTROL_92C)
+	{"dnc_enable",		RFFT_T,	_OFFSET_RFFT(dnc_enable), _SIZE_RFFT(dnc_enable), 1},
+#endif
+
+#if defined(WIFI_11N_2040_COEXIST_EXT)
+	{"bws_enable", 	RFFT_T, _OFFSET_RFFT(bws_enable), _SIZE_RFFT(bws_enable), 4},
+	{"bws_thd", 	RFFT_T, _OFFSET_RFFT(bws_Thd), _SIZE_RFFT(bws_Thd), 1000},
+	{"bws_keeptime", 	RFFT_T, _OFFSET_RFFT(bws_keeptime), _SIZE_RFFT(bws_keeptime), 60},
+#endif
+#ifdef HIGH_POWER_EXT_LNA
+	{"use_ext_lna",		RFFT_T, _OFFSET_RFFT(use_ext_lna), _SIZE_RFFT(use_ext_lna), 0},
+	{"ext_lna_gain",		RFFT_T, _OFFSET_RFFT(ext_lna_gain), _SIZE_RFFT(ext_lna_gain), 0},
+#endif
+	{"ndsi_support",	RFFT_T, _OFFSET_RFFT(NDSi_support), _SIZE_RFFT(NDSi_support), 0},
+	{"TH_L2H_ini",		RFFT_T,	_OFFSET_RFFT(TH_L2H_ini_backup), _SIZE_RFFT(TH_L2H_ini_backup), 0xf3},// 0xf3
+	{"TH_HL_diff",		RFFT_T,	_OFFSET_RFFT(TH_EDCCA_HL_diff), _SIZE_RFFT(TH_EDCCA_HL_diff), 7},//Adaptivity()
+	{"dcbackoff",		RFFT_T,	_OFFSET_RFFT(dcbackoff), _SIZE_RFFT(dcbackoff), 2},//Adaptivity()
+
+#ifdef EN_EFUSE
+	{"use_efuse",		INT_T,		_OFFSET(efuseEntry.enable_efuse), _SIZE(efuseEntry.enable_efuse), 1},
+#endif
+
+#ifdef RF_MIMO_SWITCH
+	{"rf_mode",		RFFT_T, _OFFSET_RFFT(rf_mode), _SIZE_RFFT(rf_mode), 2},
+#endif
+#ifdef PCIE_POWER_SAVING
+	{"ps",		RFFT_T, _OFFSET_RFFT(power_save), _SIZE_RFFT(power_save), (/*L2_en|*/ L1_en|_1x1_en|offload_en|stop_dma_en)},
+#if defined(RTL8676_WAKE_GPIO) && defined(WIFI_SIMPLE_CONFIG)
+	{"wps_led_active",	RFFT_T, _OFFSET_RFFT(wps_led_active), _SIZE_RFFT(wps_led_active), 0},
+#endif
+#endif
+
+
+#ifdef SW_ANT_SWITCH
+	{"antSw_enable",		RFFT_T, _OFFSET_RFFT(antSw_enable), _SIZE_RFFT(antSw_enable), 1},
+//	{"antSw_dump",			RFFT_T, _OFFSET_RFFT(antSw_dump), _SIZE_RFFT(antSw_dump), 0},
+#endif
+#ifdef HW_ANT_SWITCH
+	{"antHw_enable",		RFFT_T, _OFFSET_RFFT(antHw_enable), _SIZE_RFFT(antHw_enable), 1},
+#endif
+#if defined(HW_ANT_SWITCH) || defined(SW_ANT_SWITCH)
+	{"antdump",				RFFT_T, _OFFSET_RFFT(ant_dump), _SIZE_RFFT(ant_dump), 0},
+	{"antSw_select",		RFFT_T, _OFFSET_RFFT(antSw_select), _SIZE_RFFT(antSw_select), 1},
+#endif
+#ifdef ADD_TX_POWER_BY_CMD
+	{"txPowerPlus_cck_1",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_cck_1), _SIZE_RFFT(txPowerPlus_cck_1), 0x7f},
+	{"txPowerPlus_cck_2",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_cck_2), _SIZE_RFFT(txPowerPlus_cck_2), 0x7f},
+	{"txPowerPlus_cck_5",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_cck_5), _SIZE_RFFT(txPowerPlus_cck_5), 0x7f},
+	{"txPowerPlus_cck_11",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_cck_11), _SIZE_RFFT(txPowerPlus_cck_11), 0x7f},
+	{"txPowerPlus_ofdm_6",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_ofdm_6), _SIZE_RFFT(txPowerPlus_ofdm_6), 0x7f},
+	{"txPowerPlus_ofdm_9",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_ofdm_9), _SIZE_RFFT(txPowerPlus_ofdm_9), 0x7f},
+	{"txPowerPlus_ofdm_12",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_ofdm_12), _SIZE_RFFT(txPowerPlus_ofdm_12), 0x7f},
+	{"txPowerPlus_ofdm_18",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_ofdm_18), _SIZE_RFFT(txPowerPlus_ofdm_18), 0x7f},
+	{"txPowerPlus_ofdm_24",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_ofdm_24), _SIZE_RFFT(txPowerPlus_ofdm_24), 0x7f},
+	{"txPowerPlus_ofdm_36",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_ofdm_36), _SIZE_RFFT(txPowerPlus_ofdm_36), 0x7f},
+	{"txPowerPlus_ofdm_48",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_ofdm_48), _SIZE_RFFT(txPowerPlus_ofdm_48), 0x7f},
+	{"txPowerPlus_ofdm_54",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_ofdm_54), _SIZE_RFFT(txPowerPlus_ofdm_54), 0x7f},
+	{"txPowerPlus_mcs_0",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_mcs_0), _SIZE_RFFT(txPowerPlus_mcs_0), 0x7f},
+	{"txPowerPlus_mcs_1",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_mcs_1), _SIZE_RFFT(txPowerPlus_mcs_1), 0x7f},
+	{"txPowerPlus_mcs_2",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_mcs_2), _SIZE_RFFT(txPowerPlus_mcs_2), 0x7f},
+	{"txPowerPlus_mcs_3",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_mcs_3), _SIZE_RFFT(txPowerPlus_mcs_3), 0x7f},
+	{"txPowerPlus_mcs_4",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_mcs_4), _SIZE_RFFT(txPowerPlus_mcs_4), 0x7f},
+	{"txPowerPlus_mcs_5",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_mcs_5), _SIZE_RFFT(txPowerPlus_mcs_5), 0x7f},
+	{"txPowerPlus_mcs_6",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_mcs_6), _SIZE_RFFT(txPowerPlus_mcs_6), 0x7f},
+	{"txPowerPlus_mcs_7",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_mcs_7), _SIZE_RFFT(txPowerPlus_mcs_7), 0x7f},
+	{"txPowerPlus_mcs_8",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_mcs_8), _SIZE_RFFT(txPowerPlus_mcs_8), 0x7f},
+	{"txPowerPlus_mcs_9",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_mcs_9), _SIZE_RFFT(txPowerPlus_mcs_9), 0x7f},
+	{"txPowerPlus_mcs_10",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_mcs_10), _SIZE_RFFT(txPowerPlus_mcs_10), 0x7f},
+	{"txPowerPlus_mcs_11",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_mcs_11), _SIZE_RFFT(txPowerPlus_mcs_11), 0x7f},
+	{"txPowerPlus_mcs_12",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_mcs_12), _SIZE_RFFT(txPowerPlus_mcs_12), 0x7f},
+	{"txPowerPlus_mcs_13",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_mcs_13), _SIZE_RFFT(txPowerPlus_mcs_13), 0x7f},
+	{"txPowerPlus_mcs_14",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_mcs_14), _SIZE_RFFT(txPowerPlus_mcs_14), 0x7f},
+	{"txPowerPlus_mcs_15",	RFFT_T,	_OFFSET_RFFT(txPowerPlus_mcs_15), _SIZE_RFFT(txPowerPlus_mcs_15), 0x7f},
+#endif
+
+	{"rootFwBeacon",		RFFT_T,	_OFFSET_RFFT(rootFwBeacon), _SIZE_RFFT(rootFwBeacon), 1},
+	{"ledBlinkingFreq",		RFFT_T,	_OFFSET_RFFT(ledBlinkingFreq), _SIZE_RFFT(ledBlinkingFreq), 1},
+
+	{"diffAmpduSz",		RFFT_T,	_OFFSET_RFFT(diffAmpduSz), _SIZE_RFFT(diffAmpduSz), 1},
+	{"ampdu_space",		RFFT_T,	_OFFSET_RFFT(ampdu_min_spacing), _SIZE_RFFT(ampdu_min_spacing), 0xff},
+	{"ampdu_density",		RFFT_T,	_OFFSET_RFFT(ampdu_density), _SIZE_RFFT(ampdu_density), 0xff},
+	{"1rcca",				RFFT_T,	_OFFSET_RFFT(one_path_cca), _SIZE_RFFT(one_path_cca), 0},
+#ifdef CONFIG_1RCCA_RF_POWER_SAVING
+	{"1rcca_ps",			RFFT_T,	_OFFSET_RFFT(_1rcca_ps), _SIZE_RFFT(_1rcca_ps), 2},
+	{"1rcca_ps_rssi_thd",		RFFT_T,	_OFFSET_RFFT(_1rcca_ps_rssi_thd), _SIZE_RFFT(_1rcca_ps_rssi_thd), 30},
+#endif
+
+#if defined(CONFIG_RTL_COMAPI_CFGFILE) || defined(SDIO_2_PORT)
+	{"hwaddr",				BYTE_ARRAY_T,	_OFFSET(dot11OperationEntry.hwaddr), _SIZE(dot11OperationEntry.hwaddr), 0},
+#endif
+#ifdef CONFIG_IEEE80211W_CMD	
+	{"pmf_sta_mac",		BYTE_ARRAY_T,	_OFFSET(dot11StationConfigEntry.deauth_mac),	_SIZE(dot11StationConfigEntry.deauth_mac), 0},
+#ifdef CONFIG_IEEE80211W_CLI
+	{"pmf_sa_mac", 		BYTE_ARRAY_T,	_OFFSET(dot11StationConfigEntry.sa_req_mac), _SIZE(dot11StationConfigEntry.sa_req_mac), 0},
+	{"pmf_cli_test", 	BYTE_T,	_OFFSET(dot11StationConfigEntry.pmf_cli_test), _SIZE(dot11StationConfigEntry.pmf_cli_test), 0},	
+#endif
+	{"pmftest",			BYTE_T,	_OFFSET(dot11StationConfigEntry.pmftest),	_SIZE(dot11StationConfigEntry.pmftest), 0},			
+	{"enableSHA256",	BYTE_T,	_OFFSET(dot1180211AuthEntry.dot11EnableSHA256),	_SIZE(dot1180211AuthEntry.dot11EnableSHA256), 0},	
+	{"dot11IEEE80211W",	BYTE_T,	_OFFSET(dot1180211AuthEntry.dot11IEEE80211W),	_SIZE(dot1180211AuthEntry.dot11IEEE80211W), 0},	
+#endif
+#ifdef CONFIG_RTL_COMAPI_CFGFILE	
+	{"ssid2scan",			SSID2SCAN_STRING_T, _OFFSET(dot11StationConfigEntry.dot11SSIDtoScan), _SIZE(dot11StationConfigEntry.dot11SSIDtoScan), 0},
+#ifdef 	CONFIG_RTK_MESH
+	{"meshSilence", 		BYTE_T, _OFFSET(dot1180211sInfo.meshSilence), _SIZE(dot1180211sInfo.meshSilence), 0},
+#endif
+#endif	
+
+#ifdef DFS
+	{"dfsdbgmode",		RFFT_T,	_OFFSET_RFFT(dfsdbgmode), _SIZE_RFFT(dfsdbgmode), 0},
+	{"force_TP_mode",		RFFT_T,	_OFFSET_RFFT(dfs_force_TP_mode), _SIZE_RFFT(dfs_force_TP_mode), 0},
+	{"dfsdelayiqk",		RFFT_T, _OFFSET_RFFT(dfsdelayiqk), _SIZE_RFFT(dfsdelayiqk), 1},
+	{"dfs_next_ch",		RFFT_T,	_OFFSET_RFFT(dfs_next_ch), _SIZE_RFFT(dfs_next_ch), 0},
+	{"det_off",			RFFT_T,	_OFFSET_RFFT(dfs_det_off), _SIZE_RFFT(dfs_det_off), 0},
+	#if defined(CONFIG_WLAN_HAL_8814AE)
+	{"radar_diff_on",			RFFT_T,	_OFFSET_RFFT(dfs_radar_diff_on), _SIZE_RFFT(dfs_radar_diff_on), 0},
+	{"radar_diff_print",			RFFT_T,	_OFFSET_RFFT(dfs_radar_diff_print), _SIZE_RFFT(dfs_radar_diff_print), 0},
+	{"print_hist_report",			RFFT_T,	_OFFSET_RFFT(dfs_print_hist_report), _SIZE_RFFT(dfs_print_hist_report), 0},	
+	#endif
+	{"det_reset",		RFFT_T,	_OFFSET_RFFT(dfs_det_reset), _SIZE_RFFT(dfs_det_reset), 0},
+	{"fa_lower",		RFFT_T,	_OFFSET_RFFT(dfs_fa_cnt_lower), _SIZE_RFFT(dfs_fa_cnt_lower), 25},
+	{"fa_mid",			RFFT_T,	_OFFSET_RFFT(dfs_fa_cnt_mid), _SIZE_RFFT(dfs_fa_cnt_mid), 35},
+	{"fa_upper",		RFFT_T,	_OFFSET_RFFT(dfs_fa_cnt_upper), _SIZE_RFFT(dfs_fa_cnt_upper), 50},
+	{"fa_hist",			RFFT_T,	_OFFSET_RFFT(dfs_fa_hist), _SIZE_RFFT(dfs_fa_hist), 50},
+	{"fa_inc_ratio",	RFFT_T,	_OFFSET_RFFT(dfs_fa_cnt_inc_ratio), _SIZE_RFFT(dfs_fa_cnt_inc_ratio), 2},	
+	{"crc32_lower",		RFFT_T,	_OFFSET_RFFT(dfs_crc32_cnt_lower), _SIZE_RFFT(dfs_crc32_cnt_lower), 10},
+	{"ratio_th",		RFFT_T,	_OFFSET_RFFT(dfs_fa_ratio_th), _SIZE_RFFT(dfs_fa_ratio_th), 15},
+	{"det_period",		RFFT_T,	_OFFSET_RFFT(dfs_det_period), _SIZE_RFFT(dfs_det_period), 20},
+	{"det_period_jp_w53",		RFFT_T,	_OFFSET_RFFT(dfs_det_period_jp_w53), _SIZE_RFFT(dfs_det_period_jp_w53), 15},
+	{"det_print",		RFFT_T,	_OFFSET_RFFT(dfs_det_print), _SIZE_RFFT(dfs_det_print), 0},
+	{"det_print1",		RFFT_T,	_OFFSET_RFFT(dfs_det_print1), _SIZE_RFFT(dfs_det_print1), 1},
+	{"det_print2",		RFFT_T,	_OFFSET_RFFT(dfs_det_print2), _SIZE_RFFT(dfs_det_print2), 0},
+	{"det_print3",		RFFT_T,	_OFFSET_RFFT(dfs_det_print3), _SIZE_RFFT(dfs_det_print3), 0},
+	{"det_print4",		RFFT_T,	_OFFSET_RFFT(dfs_det_print4), _SIZE_RFFT(dfs_det_print4), 0},
+	{"det_print_psd",		RFFT_T,	_OFFSET_RFFT(dfs_det_print_psd), _SIZE_RFFT(dfs_det_print_psd), 0},
+	{"pulse_print",		RFFT_T,	_OFFSET_RFFT(dfs_pulse_print), _SIZE_RFFT(dfs_pulse_print), 0},
+	{"hist_len",		RFFT_T,	_OFFSET_RFFT(dfs_det_hist_len), _SIZE_RFFT(dfs_det_hist_len), 5},
+	{"sum_th",			RFFT_T,	_OFFSET_RFFT(dfs_det_sum_th), _SIZE_RFFT(dfs_det_sum_th), 2},
+	{"flag_offset",		RFFT_T,	_OFFSET_RFFT(dfs_det_flag_offset), _SIZE_RFFT(dfs_det_flag_offset), 2},
+	{"DPT_FA_TH_upper",	RFFT_T,	_OFFSET_RFFT(dfs_dpt_fa_th_upper), _SIZE_RFFT(dfs_dpt_fa_th_upper), 1000},
+	{"DPT_FA_TH_lower",	RFFT_T,	_OFFSET_RFFT(dfs_dpt_fa_th_lower), _SIZE_RFFT(dfs_dpt_fa_th_lower), 80},
+	{"DPT_Pulse_TH_mid",	RFFT_T,	_OFFSET_RFFT(dfs_dpt_pulse_th_mid), _SIZE_RFFT(dfs_dpt_pulse_th_mid), 3},
+	{"DPT_Pulse_TH_lower",	RFFT_T,	_OFFSET_RFFT(dfs_dpt_pulse_th_lower), _SIZE_RFFT(dfs_dpt_pulse_th_lower), 1},
+	{"DPT_ST_L2H_max",	RFFT_T,	_OFFSET_RFFT(dfs_dpt_st_l2h_max), _SIZE_RFFT(dfs_dpt_st_l2h_max), 0x4e},
+	{"DPT_ST_L2H_min",	RFFT_T,	_OFFSET_RFFT(dfs_dpt_st_l2h_min), _SIZE_RFFT(dfs_dpt_st_l2h_min), 0x20},
+	{"DPT_ST_L2H_add",	RFFT_T,	_OFFSET_RFFT(dfs_dpt_st_l2h_add), _SIZE_RFFT(dfs_dpt_st_l2h_add), 0},
+	{"DPT_ST_L2H_idle_offset",	RFFT_T,	_OFFSET_RFFT(dfs_dpt_st_l2h_idle_offset), _SIZE_RFFT(dfs_dpt_st_l2h_idle_offset), 0},
+	{"DPT_ini_gain_th",	RFFT_T,	_OFFSET_RFFT(dpt_ini_gain_th), _SIZE_RFFT(dpt_ini_gain_th), 0x30},
+	{"pwdb_th",			RFFT_T,	_OFFSET_RFFT(dfs_pwdb_th), _SIZE_RFFT(dfs_pwdb_th), 0x08},
+	{"pwdb_scalar_factor",		RFFT_T,	_OFFSET_RFFT(dfs_pwdb_scalar_factor), _SIZE_RFFT(dfs_pwdb_scalar_factor), 12},
+	{"psd_pw_th",		RFFT_T,	_OFFSET_RFFT(dfs_psd_pw_th), _SIZE_RFFT(dfs_psd_pw_th), 65},
+	{"dfs_psd_idle_on",			RFFT_T,	_OFFSET_RFFT(dfs_psd_idle_on), _SIZE_RFFT(dfs_psd_idle_on), 0},
+	{"dfs_psd_TP_on",			RFFT_T,	_OFFSET_RFFT(dfs_psd_TP_on), _SIZE_RFFT(dfs_psd_TP_on), 0},
+	{"psd_skip_lookup_table",	RFFT_T,	_OFFSET_RFFT(psd_skip_lookup_table), _SIZE_RFFT(psd_skip_lookup_table), 0},
+	{"dfs_psd_delay",		RFFT_T,	_OFFSET_RFFT(dfs_psd_delay), _SIZE_RFFT(dfs_psd_delay), 30},
+	{"psd_fir_decay",	RFFT_T,	_OFFSET_RFFT(dfs_psd_fir_decay), _SIZE_RFFT(dfs_psd_fir_decay), 23},
+	{"skip_iqk",		RFFT_T,	_OFFSET_RFFT(dfs_skip_iqk), _SIZE_RFFT(dfs_skip_iqk), 0},
+	{"scan_inband",		RFFT_T,	_OFFSET_RFFT(dfs_scan_inband), _SIZE_RFFT(dfs_scan_inband), 0},
+	{"psd_op",			RFFT_T,	_OFFSET_RFFT(dfs_psd_op), _SIZE_RFFT(dfs_psd_op), 1},
+	{"psd_tp_th",		RFFT_T,	_OFFSET_RFFT(dfs_psd_tp_th), _SIZE_RFFT(dfs_psd_tp_th), 2},
+	{"pc0_th_idle_w53",	RFFT_T,	_OFFSET_RFFT(dfs_pc0_th_idle_w53), _SIZE_RFFT(dfs_pc0_th_idle_w53), 14},
+	{"pc0_th_idle_w56",	RFFT_T,	_OFFSET_RFFT(dfs_pc0_th_idle_w56), _SIZE_RFFT(dfs_pc0_th_idle_w56), 6},
+	{"max_sht_pusle_cnt_th",RFFT_T,	_OFFSET_RFFT(dfs_max_sht_pusle_cnt_th), _SIZE_RFFT(dfs_max_sht_pusle_cnt_th), 5},
+#endif
+
+#ifdef SW_TX_QUEUE
+	{"swqh",          RFFT_T, _OFFSET_RFFT(swq_en_highthd), _SIZE_RFFT(swq_en_highthd), 400},
+	{"swql",          RFFT_T, _OFFSET_RFFT(swq_dis_lowthd), _SIZE_RFFT(swq_dis_lowthd), 80},
+	{"swqen",         RFFT_T, _OFFSET_RFFT(swq_enable), _SIZE_RFFT(swq_enable), 1},
+	{"swqdbg",        RFFT_T, _OFFSET_RFFT(swq_dbg), _SIZE_RFFT(swq_dbg), 0},
+
+	{"swqaggnum",		RFFT_T, _OFFSET_RFFT(swq_aggnum), _SIZE_RFFT(swq_aggnum), 8},
+
+	{"thd1",			RFFT_T, _OFFSET_RFFT(timeout_thd), _SIZE_RFFT(timeout_thd), 60},
+	{"thd2",            RFFT_T, _OFFSET_RFFT(timeout_thd2), _SIZE_RFFT(timeout_thd2), 150},
+	{"thd3",		  	RFFT_T, _OFFSET_RFFT(timeout_thd3), _SIZE_RFFT(timeout_thd3), 300},
+#endif
+
+#ifdef A4_STA
+	{"a4_enable",			RFFT_T,	_OFFSET_RFFT(a4_enable), _SIZE_RFFT(a4_enable), 1},
+#endif
+
+#ifdef RTL8192D_INT_PA
+	{"use_intpa92d",		RFFT_T,	_OFFSET_RFFT(use_intpa92d), _SIZE_RFFT(use_intpa92d), 0},
+#endif
+#ifdef CONFIG_WLAN_HAL_8881A
+	{"use_intpa8881A",		RFFT_T, _OFFSET_RFFT(use_intpa8881A), _SIZE_RFFT(use_intpa8881A), 0},
+#endif
+	{"pwr_by_rate",        RFFT_T, _OFFSET_RFFT(pwr_by_rate), _SIZE_RFFT(pwr_by_rate), 0},
+#ifdef _TRACKING_TABLE_FILE
+	{"pwr_track_file",        RFFT_T, _OFFSET_RFFT(pwr_track_file), _SIZE_RFFT(pwr_track_file), 1},
+#endif
+#ifdef CONFIG_SDIO_HCI
+	{"disable_pwr_by_rate", RFFT_T, _OFFSET_RFFT(disable_pwr_by_rate), _SIZE_RFFT(disable_pwr_by_rate), 1},
+#else
+	{"disable_pwr_by_rate", RFFT_T, _OFFSET_RFFT(disable_pwr_by_rate), _SIZE_RFFT(disable_pwr_by_rate), 0},
+#endif
+#ifdef TXPWR_LMT
+#ifdef CONFIG_SDIO_HCI
+	{"disable_txpwrlmt",	RFFT_T, _OFFSET_RFFT(disable_txpwrlmt), _SIZE_RFFT(disable_txpwrlmt), 1},
+#else
+	{"disable_txpwrlmt",	RFFT_T, _OFFSET_RFFT(disable_txpwrlmt), _SIZE_RFFT(disable_txpwrlmt), 0},
+#endif
+	{"disable_txpwrlmt2path",	RFFT_T, _OFFSET_RFFT(disable_txpwrlmt2path), _SIZE_RFFT(disable_txpwrlmt2path), 0},
+#endif
+#ifdef CONFIG_RTL_92D_DMDP
+	{"peerReinit",	RFFT_T, _OFFSET_RFFT(peerReinit), _SIZE_RFFT(peerReinit), 0},
+#endif
+#ifdef CONFIG_SDIO_TX_FILTER_BY_PRI
+	{"tx_filter_enable",	RFFT_T, _OFFSET_RFFT(tx_filter_enable), _SIZE_RFFT(tx_filter_enable), 1},
+#endif
+#ifdef WIFI_WMM
+	{"wifi_beq_iot",	RFFT_T, _OFFSET_RFFT(wifi_beq_iot), _SIZE_RFFT(wifi_beq_iot), 0},
+#endif
+	{"bcast_to_dzq",	RFFT_T, _OFFSET_RFFT(bcast_to_dzq), _SIZE_RFFT(bcast_to_dzq), 0},
+#ifdef TLN_STATS
+	{"stats_time_interval",        RFFT_T, _OFFSET_RFFT(stats_time_interval), _SIZE_RFFT(stats_time_interval), 86400},
+#endif
+#ifdef TX_EARLY_MODE
+	{"em_enable",	RFFT_T, _OFFSET_RFFT(em_enable), _SIZE_RFFT(em_enable), 1},
+#endif
+#ifdef CLIENT_MODE
+	{"sta_mode_ps",	RFFT_T, _OFFSET_RFFT(sta_mode_ps), _SIZE_RFFT(sta_mode_ps), 0},
+#endif
+#ifdef CONFIG_RTL_WLAN_DOS_FILTER
+	{"dos_block_time",	RFFT_T, _OFFSET_RFFT(dos_block_time), _SIZE_RFFT(dos_block_time), 20},
+#endif
+
+	{"intel_tp",	RFFT_T, _OFFSET_RFFT(intel_rtylmt_tp_margin), _SIZE_RFFT(intel_rtylmt_tp_margin), 125*1024}, /* unit: byte */
+
+	{"enable_macid_sleep",	RFFT_T, _OFFSET_RFFT(enable_macid_sleep), _SIZE_RFFT(enable_macid_sleep), 1},
+#ifdef CONFIG_RTL_88E_SUPPORT
+	{"disable_pkt_pause",	RFFT_T, _OFFSET_RFFT(disable_pkt_pause), _SIZE_RFFT(disable_pkt_pause), 0},
+	{"disable_pkt_nolink",	RFFT_T, _OFFSET_RFFT(disable_pkt_nolink), _SIZE_RFFT(disable_pkt_nolink), 0},
+        {"maxpktfail",  RFFT_T, _OFFSET_RFFT(max_pkt_fail), _SIZE_RFFT(max_pkt_fail), 50},
+	{"minpktfail",  RFFT_T, _OFFSET_RFFT(min_pkt_fail), _SIZE_RFFT(min_pkt_fail), 30},
+#endif
+	{"low_tp_no_aggr",	RFFT_T, _OFFSET_RFFT(low_tp_no_aggr), _SIZE_RFFT(low_tp_no_aggr), 0},
+#if defined(TX_EARLY_MODE)
+	{"em_que_num",	RFFT_T, _OFFSET_RFFT(em_que_num), _SIZE_RFFT(em_que_num), 10},
+	{"em_swq_thd_high",	RFFT_T, _OFFSET_RFFT(em_swq_thd_high), _SIZE_RFFT(em_swq_thd_high), 70},
+	{"em_swq_thd_low",	RFFT_T, _OFFSET_RFFT(em_swq_thd_low), _SIZE_RFFT(em_swq_thd_low), 60},
+#endif	
+#ifdef CONFIG_TCP_ACK_TXAGG
+	{"tcpack_agg",		RFFT_T, _OFFSET_RFFT(tcpack_agg), _SIZE_RFFT(tcpack_agg), 1},
+#ifdef CONFIG_TCP_ACK_MERGE
+	{"tcpack_merge",	RFFT_T, _OFFSET_RFFT(tcpack_merge), _SIZE_RFFT(tcpack_merge), 0},
+#endif
+#endif // CONFIG_TCP_ACK_TXAGG
+#if defined(CONFIG_USB_HCI) || defined(CONFIG_SDIO_HCI)
+	{"low_traffic_xmit_thd",	RFFT_T, _OFFSET_RFFT(low_traffic_xmit_thd), _SIZE_RFFT(low_traffic_xmit_thd), 20},
+#endif
+	{"low_retry_rssi_thd",		RFFT_T, _OFFSET_RFFT(low_retry_rssi_thd), _SIZE_RFFT(low_retry_rssi_thd), 30},
+	{"low_rate_low_retry",		RFFT_T, _OFFSET_RFFT(low_rate_low_retry), _SIZE_RFFT(low_rate_low_retry), 1},
+#ifdef RSSI_MIN_ADV_SEL
+	{"rssi_min_advsel",		RFFT_T, _OFFSET_RFFT(rssi_min_advsel), _SIZE_RFFT(rssi_min_advsel), 1},
+#endif
+#ifdef BEAMFORMING_SUPPORT
+	{"sndperiod",	RFFT_T, _OFFSET_RFFT(soundingPeriod), _SIZE_RFFT(soundingPeriod), 4000},			//  40ms
+	{"dumpcsi",		RFFT_T, _OFFSET_RFFT(dumpcsi), _SIZE_RFFT(dumpcsi), 100},							// 100
+	{"sndenable",	RFFT_T, _OFFSET_RFFT(soundingEnable), _SIZE_RFFT(soundingEnable), 1},			//  enable	
+	{"ndparate",	RFFT_T, _OFFSET_RFFT(ndparate), _SIZE_RFFT(ndparate), 0},	
+	{"ndpaaid",	RFFT_T, 	_OFFSET_RFFT(ndpaaid), _SIZE_RFFT(ndpaaid), 0xff},
+	{"applyVmatrix",	RFFT_T, 	_OFFSET_RFFT(applyVmatrix), _SIZE_RFFT(applyVmatrix), 1},
+	{"Nsnding3SS",	RFFT_T, 	_OFFSET_RFFT(Nsnding3SS), _SIZE_RFFT(Nsnding3SS), 1},
+#ifdef BEAMFORMING_AUTO		
+	{"txbf_pwrlmt",	RFFT_T, 	_OFFSET_RFFT(txbf_pwrlmt), _SIZE_RFFT(txbf_pwrlmt), 0},	
+#endif
+#endif
+
+	{"no_rtscts", RFFT_T, _OFFSET_RFFT(no_rtscts), _SIZE_RFFT(no_rtscts), 0}, 
+#ifdef RTK_AC_SUPPORT
+// operating mode notification
+	{"opm",	RFFT_T, _OFFSET_RFFT(oper_mode_field), _SIZE_RFFT(oper_mode_field), 0x00},
+	{"opmtest", RFFT_T, _OFFSET_RFFT(opmtest), _SIZE_RFFT(opmtest), 0x00},	
+// channel switch 
+	{"csa",	RFFT_T, _OFFSET_RFFT(csa), _SIZE_RFFT(csa), 0x00},
+	{"lgirate", RFFT_T, _OFFSET_RFFT(lgirate), _SIZE_RFFT(lgirate), 0xffff}, 
+	
+	{"cca_rts",	RFFT_T, _OFFSET_RFFT(cca_rts), _SIZE_RFFT(cca_rts), 0x00},	// 1: static, 2: dynamic
+// Tx Power Diff
+	{"pwrdiff_20BW1S_OFDM1T_A",	BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrdiff_20BW1S_OFDM1T_A), _SIZE(dot11RFEntry.pwrdiff_20BW1S_OFDM1T_A), 0},
+	{"pwrdiff_40BW2S_20BW2S_A",	BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrdiff_40BW2S_20BW2S_A), _SIZE(dot11RFEntry.pwrdiff_40BW2S_20BW2S_A), 0},
+	{"pwrdiff_5G_20BW1S_OFDM1T_A",	BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrdiff_5G_20BW1S_OFDM1T_A), _SIZE(dot11RFEntry.pwrdiff_5G_20BW1S_OFDM1T_A), 0},
+	{"pwrdiff_5G_40BW2S_20BW2S_A",	BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrdiff_5G_40BW2S_20BW2S_A), _SIZE(dot11RFEntry.pwrdiff_5G_40BW2S_20BW2S_A), 0},
+	{"pwrdiff_5G_80BW1S_160BW1S_A",	BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrdiff_5G_80BW1S_160BW1S_A), _SIZE(dot11RFEntry.pwrdiff_5G_80BW1S_160BW1S_A), 0},
+	{"pwrdiff_5G_80BW2S_160BW2S_A", BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrdiff_5G_80BW2S_160BW2S_A), _SIZE(dot11RFEntry.pwrdiff_5G_80BW2S_160BW2S_A), 0},
+	{"pwrdiff_20BW1S_OFDM1T_B", BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrdiff_20BW1S_OFDM1T_B), _SIZE(dot11RFEntry.pwrdiff_20BW1S_OFDM1T_B), 0},
+	{"pwrdiff_40BW2S_20BW2S_B", BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrdiff_40BW2S_20BW2S_B), _SIZE(dot11RFEntry.pwrdiff_40BW2S_20BW2S_B), 0},
+	{"pwrdiff_5G_20BW1S_OFDM1T_B",	BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrdiff_5G_20BW1S_OFDM1T_B), _SIZE(dot11RFEntry.pwrdiff_5G_20BW1S_OFDM1T_B), 0},
+	{"pwrdiff_5G_40BW2S_20BW2S_B",	BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrdiff_5G_40BW2S_20BW2S_B), _SIZE(dot11RFEntry.pwrdiff_5G_40BW2S_20BW2S_B), 0},
+	{"pwrdiff_5G_80BW1S_160BW1S_B", BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrdiff_5G_80BW1S_160BW1S_B), _SIZE(dot11RFEntry.pwrdiff_5G_80BW1S_160BW1S_B), 0},
+	{"pwrdiff_5G_80BW2S_160BW2S_B", BYTE_ARRAY_T, _OFFSET(dot11RFEntry.pwrdiff_5G_80BW2S_160BW2S_B), _SIZE(dot11RFEntry.pwrdiff_5G_80BW2S_160BW2S_B), 0},
+#endif
+	{"txforce", RFFT_T, _OFFSET_RFFT(txforce), _SIZE_RFFT(txforce), 0xff},
+	{"sgiforce", RFFT_T, _OFFSET_RFFT(sgiforce), _SIZE_RFFT(sgiforce), 2},
+#ifdef CONFIG_WLAN_HAL_8192EE
+	{"delay_8b4", RFFT_T, _OFFSET_RFFT(delay_8b4), _SIZE_RFFT(delay_8b4), 30},
+	{"thrd_8b4", RFFT_T, _OFFSET_RFFT(thrd_8b4), _SIZE_RFFT(thrd_8b4), 0x16},
+	{"loop_8b4", RFFT_T, _OFFSET_RFFT(loop_8b4), _SIZE_RFFT(loop_8b4), 50},	
+	{"disable_ACPR", RFFT_T, _OFFSET_RFFT(disable_ACPR), _SIZE_RFFT(disable_ACPR), 1},	
+	{"ldpc_92e", RFFT_T, _OFFSET_RFFT(ldpc_92e), _SIZE_RFFT(ldpc_92e), 0},	
+#endif
+	{"tim_clear_delay", RFFT_T, _OFFSET_RFFT(tim_clear_delay), _SIZE_RFFT(tim_clear_delay), 0},
+#ifdef RTK_NL80211
+        //mark_priv , for some parameter that not support in nl80211 
+	{"rtk_ac_enable",	RFFT_T,	_OFFSET_RFFT(rtk_uci_AcEnable),  _SIZE_RFFT(rtk_uci_AcEnable), 0},
+	// rtk_ac_enable = 0 or 1
+	{"rtk_priv_bw",	RFFT_T,_OFFSET_RFFT(rtk_uci_PrivBandwidth),  _SIZE_RFFT(rtk_uci_PrivBandwidth), 0},
+	// rtk_priv_bw =  5M , 10M ,80M ...
+#endif
+#ifdef AC2G_256QAM
+	{"ac2g_enable", RFFT_T, _OFFSET_RFFT(ac2g_enable), _SIZE_RFFT(ac2g_enable), 1},
+	{"ac2g_phy_type", RFFT_T, _OFFSET_RFFT(ac2g_phy_type), _SIZE_RFFT(ac2g_phy_type), 0},
+	{"ac2g_thd_ldpc", RFFT_T, _OFFSET_RFFT(ac2g_thd_ldpc), _SIZE_RFFT(ac2g_thd_ldpc), 35},
+#endif
+#ifdef CHECK_HANGUP
+	{"check_hang", RFFT_T, _OFFSET_RFFT(check_hang), _SIZE_RFFT(check_hang), 0xff},
+#endif
+#ifdef MCR_WIRELESS_EXTEND
+	{"mcr_ft", RFFT_T, _OFFSET_RFFT(mcr_ft), _SIZE_RFFT(mcr_ft), 1},
+	{"disable_ldpc_thd", RFFT_T, _OFFSET_RFFT(disable_ldpc_thd), _SIZE_RFFT(disable_ldpc_thd), 60},
+#endif
+	{"auto_cipher", RFFT_T, _OFFSET_RFFT(auto_cipher), _SIZE_RFFT(auto_cipher), 0},
+//	{"mp_dig_enable",	RFFT_T, _OFFSET_RFFT(mp_dig_enable), _OFFSET_RFFT(mp_dig_enable), 0},
+#ifdef USE_OUT_SRC
+	{"odmrfpath",	ODM_DM_1UT,	_OFFSET_ODM_DM(RFPathRxEnable), _SIZE_ODM_DM(RFPathRxEnable), 0},// test for ODM DM (byte)
+	{"odmdebuglev",	ODM_DM_4UT,	_OFFSET_ODM_DM(DebugLevel), _SIZE_ODM_DM(DebugLevel), 0},// test for ODM DM (4byte)
+	{"odmdebugcom",	ODM_DM_8UT,	_OFFSET_ODM_DM(DebugComponents), _SIZE_ODM_DM(DebugComponents), 0},// test for ODM DM (long long)
+	{"TH_L2H_Ini",	ODM_DM_1UT,	_OFFSET_ODM_DM(TH_L2H_default), _SIZE_ODM_DM(TH_L2H_default), 0xf3},// for odm_Adaptivity()
+	{"TH_HL_Diff",	ODM_DM_1UT,	_OFFSET_ODM_DM(TH_EDCCA_HL_diff_default), _SIZE_ODM_DM(TH_EDCCA_HL_diff_default), 7},// for odm_Adaptivity()
+	{"TH_L2H_Ini_mode2",	ODM_DM_1UT,	_OFFSET_ODM_DM(TH_L2H_ini_mode2), _SIZE_ODM_DM(TH_L2H_ini_mode2), 20},// for odm_Adaptivity()
+	{"TH_HL_Diff_mode2",	ODM_DM_1UT,	_OFFSET_ODM_DM(TH_EDCCA_HL_diff_mode2), _SIZE_ODM_DM(TH_EDCCA_HL_diff_mode2), 8},// for odm_Adaptivity()
+	{"EDCCA_enable",	ODM_DM_1UT,	_OFFSET_ODM_DM(EDCCA_enable), _SIZE_ODM_DM(EDCCA_enable), 1},// for odm_Adaptivity()
+	{"DCbackoff",	ODM_DM_1UT,	_OFFSET_ODM_DM(DCbackoff), _SIZE_ODM_DM(DCbackoff), 2},// for odm_Adaptivity()
+	{"ada_IGI_upper",	ODM_DM_1UT,	_OFFSET_ODM_DM(Adaptivity_IGI_upper), _SIZE_ODM_DM(Adaptivity_IGI_upper), 0x0},// for odm_Adaptivity()
+	{"antdiv_rssi", ODM_DM_1UT, _OFFSET_ODM_DM(antdiv_rssi), _SIZE_ODM_DM(antdiv_rssi), 0},// for ODM_AntennaDiversity_92E()
+	{"antdiv_intvl", ODM_DM_1UT, _OFFSET_ODM_DM(antdiv_intvl), _SIZE_ODM_DM(antdiv_intvl), 0},
+	{"fat_comb_a", ODM_DM_1UT, _OFFSET_ODM_DM(fat_comb_a), _SIZE_ODM_DM(fat_comb_a), 0},
+	{"fat_comb_b", ODM_DM_1UT, _OFFSET_ODM_DM(fat_comb_b), _SIZE_ODM_DM(fat_comb_b), 0},
+	{"antdiv_period", ODM_DM_1UT, _OFFSET_ODM_DM(antdiv_period), _SIZE_ODM_DM(antdiv_period), 0},// for ODM_AntennaDiversity()
+	{"antdiv_select", ODM_DM_1UT, _OFFSET_ODM_DM(antdiv_select), _SIZE_ODM_DM(antdiv_select), 0},// for ODM_AntennaDiversity()
+	{"bdc_holdstate", ODM_DM_1UT, _OFFSET_ODM_DM(bdc_holdstate), _SIZE_ODM_DM(bdc_holdstate), 0},// for BDC algorithm	{"dm_dig_max_TH", ODM_DM_1UT, _OFFSET_ODM_DM(dm_dig_max_TH), _SIZE_ODM_DM(dm_dig_max_TH), 0},	{"dm_dig_min_TH", ODM_DM_1UT, _OFFSET_ODM_DM(dm_dig_min_TH), _SIZE_ODM_DM(dm_dig_min_TH), 0},
+	{"dm_dig_max_TH", ODM_DM_1UT, _OFFSET_ODM_DM(dm_dig_max_TH), _SIZE_ODM_DM(dm_dig_max_TH), 0},
+	{"dm_dig_min_TH", ODM_DM_1UT, _OFFSET_ODM_DM(dm_dig_min_TH), _SIZE_ODM_DM(dm_dig_min_TH), 0},
+	{"Carrier_Sense_enable",	ODM_DM_1UT,	_OFFSET_ODM_DM(Carrier_Sense_enable), _SIZE_ODM_DM(Carrier_Sense_enable), 0},// for odm_Adaptivity()
+	{"print_agc",	ODM_DM_1UT,	_OFFSET_ODM_DM(print_agc), _SIZE_ODM_DM(print_agc), 0},
+	{"antdiv_evm_en",	ODM_DM_1UT,	_OFFSET_ODM_DM(antdiv_evm_en), _SIZE_ODM_DM(antdiv_evm_en), 0},
+	{"ra_dump", ODM_DM_1UT, _OFFSET_ODM_DM(ra_dump), _SIZE_ODM_DM(ra_dump), 0},// for odm_RateDecision_8188E()
+#endif	
+#ifdef CONFIG_WLAN_HAL_8881A
+	{"pwrtrk_TxAGC_enable",	RFFT_T,	_OFFSET_RFFT(pwrtrk_TxAGC_enable), _SIZE_RFFT(pwrtrk_TxAGC_enable), 1},
+	{"pwrtrk_TxAGC",	RFFT_T,	_OFFSET_RFFT(pwrtrk_TxAGC), _SIZE_RFFT(pwrtrk_TxAGC), 0},
+#endif
+#ifdef CONFIG_RTL_P2P_SUPPORT
+	{"p2p_type",          INT_T,       _OFFSET(p2p_mib.p2p_type),             _SIZE(p2p_mib.p2p_type),0},
+	{"p2p_state",         INT_T,       _OFFSET(p2p_mib.p2p_state),            _SIZE(p2p_mib.p2p_state),0},
+	{"p2p_on_discovery",  INT_T,       _OFFSET(p2p_mib.p2p_on_discovery),     _SIZE(p2p_mib.p2p_type),0},
+	{"p2p_intent",        BYTE_T,      _OFFSET(p2p_mib.p2p_intent),           _SIZE(p2p_mib.p2p_intent),0},
+	{"p2p_listen_channel",BYTE_T,      _OFFSET(p2p_mib.p2p_listen_channel),   _SIZE(p2p_mib.p2p_listen_channel),0},
+	{"p2p_op_channel",    BYTE_T,      _OFFSET(p2p_mib.p2p_op_channel),       _SIZE(p2p_mib.p2p_op_channel),0},
+	{"p2p_event_indiate", BYTE_T,      _OFFSET(p2p_mib.p2p_event_indiate),    _SIZE(p2p_mib.p2p_event_indiate),0},
+	{"p2p_device_name", STRING_T,      _OFFSET(p2p_mib.p2p_device_name),      _SIZE(p2p_mib.p2p_device_name),0},
+	{"p2p_wsc_pin_code",STRING_T,      _OFFSET(p2p_mib.p2p_wsc_pin_code),     _SIZE(p2p_mib.p2p_wsc_pin_code),0},
+	{"p2p_wsc_config_method",INT_T,    _OFFSET(p2p_mib.p2p_wsc_config_method),_SIZE(p2p_mib.p2p_wsc_config_method),0},
+#endif
+	{"bcn_dont_ignore_edcca", RFFT_T, _OFFSET_RFFT(bcn_dont_ignore_edcca), _SIZE_RFFT(bcn_dont_ignore_edcca), 0},
+#ifdef WIFI_SNIFFER
+	{"sniffer",	RFFT_T,	_OFFSET_RFFT(sniffer), _SIZE_RFFT(sniffer), 0},
+#endif
+#ifdef CLIENT_MODE
+	{"bw_follow",	RFFT_T,	_OFFSET_RFFT(bw_follow), _SIZE_RFFT(bw_follow), 0},
+#endif
+#ifdef RTK_NL80211
+	{"nl80211_acs_type",	RFFT_T,	_OFFSET_RFFT(nl80211_acs_type), _SIZE_RFFT(nl80211_acs_type), 1},
+#endif
+};
+
+#ifdef _DEBUG_RTL8192CD_
+unsigned long rtl8192cd_debug_err=0xffffffff;
+unsigned long rtl8192cd_debug_info=0x0;//ffffffff;
+unsigned long rtl8192cd_debug_trace=0x0;//ffffffff;
+unsigned long rtl8192cd_debug_warn=0x0;//ffffffff;
+unsigned long rtl8192cd_debug_psk=0x0;//ffffffff;
+unsigned long rtl8192cd_debug_memlog=0x0;
+extern void rtl8192cd_dbg_showLog(void);
+#endif
+
+#ifdef HS2_DEBUGMSG
+unsigned int _HS2_debug_info=0;  /* info flag */
+unsigned int _HS2_debug_err=0;		/* err flag */
+unsigned int _HS2_debug_trace=0;	/* trace flag */
+unsigned int _HS2_debug_warn=0;	/* warn flag */
+#endif
+
+
+#ifdef __ECOS
+static sta_info_2_web sta_info[NUM_STAT + 1];
+#endif
+
+void MDL_DEVINIT set_mib_default_tbl(struct rtl8192cd_priv *priv)
+{
+	int i;
+	int arg_num = sizeof(mib_table)/sizeof(struct iwpriv_arg);
+
+	for (i=0; i<arg_num; i++) {
+		if (mib_table[i].Default) {
+			if (mib_table[i].type == BYTE_T)
+				*(((unsigned char *)priv->pmib)+mib_table[i].offset) = (unsigned char)mib_table[i].Default;
+			else if (mib_table[i].type == INT_T)
+				memcpy(((unsigned char *)priv->pmib)+mib_table[i].offset, (unsigned char *)&mib_table[i].Default, sizeof(int));
+#if defined(CONFIG_RTK_MESH)
+			else if (mib_table[i].type == WORD_T)
+				memcpy(((unsigned char *)priv->pmib)+mib_table[i].offset, (unsigned char *)&mib_table[i].Default, sizeof(unsigned short));
+#endif	//CONFIG_RTK_MESH
+			else if (mib_table[i].type == RFFT_T && mib_table[i].len == 1)
+				*(((unsigned char *)&(priv->pshare->rf_ft_var))+mib_table[i].offset) = (unsigned char)mib_table[i].Default;
+			else if (mib_table[i].type == RFFT_T && mib_table[i].len == 4)
+				memcpy(((unsigned char *)&(priv->pshare->rf_ft_var))+mib_table[i].offset, (unsigned char *)&mib_table[i].Default, sizeof(int));
+#ifdef USE_OUT_SRC
+			else if (mib_table[i].type == ODM_DM_1UT && mib_table[i].len == 1)
+				*(((unsigned char *)&(priv->pshare->_dmODM))+mib_table[i].offset) = (unsigned char)mib_table[i].Default;
+			else if ((mib_table[i].type == ODM_DM_4UT && mib_table[i].len == 4)) 
+				memcpy(((unsigned char *)&(priv->pshare->_dmODM))+mib_table[i].offset, (unsigned char *)&mib_table[i].Default, sizeof(int));
+#endif			
+			else {
+				// We only give default value of types of BYTE_T and INT_T here.
+				// Some others are gave in set_mib_default().
+			}
+		}
+	}
+}
+
+
+int _convert_2_pwr_dot(char *s, int base)
+{
+	int k = 0, i=0;
+	int flag = 0;
+	char *data = s;
+	
+	k = 0;
+
+	while(s[i] && (s[i] == ' ' || s[i] == '\t'))
+		i++;
+	data = &s[i];
+	
+	if (base == 10) {
+		while ((*data >= '0') && (*data <= '9')) {
+			flag = 1;
+			k = 10 * k + (*data - '0');
+			data++;
+		}
+
+		k = k*2;
+
+		if(*data == '.'){
+			flag = 1;
+			data++;
+			
+			if(*data >= '5' && *data <= '9')
+				k++;				
+		}
+	}
+	else
+		return 0;
+
+	if (!flag) 
+		return -1;	
+
+	return k;
+}
+
+
+
+int _atoi(char *s, int base)
+{
+	int k = 0;
+	int sign = 1;
+
+	k = 0;
+	if (base == 10) {
+		if(*s== '-') {
+			sign = -1;
+			s++;
+		}
+		while (*s != '\0' && *s >= '0' && *s <= '9') {
+			k = 10 * k + (*s - '0');
+			s++;
+		}
+		k *= sign;
+	}
+	else {
+		while (*s != '\0') {
+			int v;
+			if ( *s >= '0' && *s <= '9')
+				v = *s - '0';
+			else if ( *s >= 'a' && *s <= 'f')
+				v = *s - 'a' + 10;
+			else if ( *s >= 'A' && *s <= 'F')
+				v = *s - 'A' + 10;
+			else {
+				_DEBUG_ERR("error hex format!\n");
+#if 1//defined(CONFIG_RTL_8812_SUPPORT) || defined(CONFIG_RTL_88E_SUPPORT) || defined(CONFIG_WLAN_HAL_8192EE) //TXPWR_LMT_8812 TXPWR_LMT_88E
+				return k;
+#else
+				return 0;
+#endif
+			}
+			k = 16 * k + v;
+			s++;
+		}
+	}
+	return k;
+}
+
+#ifdef USE_OUT_SRC
+unsigned long long _atoi_u8(char *s, int base)
+{
+	unsigned long long k = 0;
+	int sign = 1;
+	k = 0;
+	if (base == 10) {
+		if(*s== '-') {
+			sign = -1;
+			s++;
+		}
+		while (*s != '\0' && *s >= '0' && *s <= '9') {
+			k = 10 * k + (*s - '0');
+			s++;
+		}
+		k *= sign;
+	}
+	else {
+		while (*s != '\0') {
+			int v;
+			if ( *s >= '0' && *s <= '9')
+				v = *s - '0';
+			else if ( *s >= 'a' && *s <= 'f')
+				v = *s - 'a' + 10;
+			else if ( *s >= 'A' && *s <= 'F')
+				v = *s - 'A' + 10;
+			else {
+				_DEBUG_ERR("error hex format!\n");
+				return 0;
+			}
+			k = 16 * k + v;
+			s++;
+		}
+	}
+	return k;
+}
+#endif
+static struct iwpriv_arg *get_tbl_entry(char *pstr)
+{
+	int i=0;
+	int arg_num = sizeof(mib_table)/sizeof(struct iwpriv_arg);
+	volatile char name[128];
+
+	while (*pstr && *pstr != '=') {
+		if (i >= sizeof(name)-1)
+			return NULL;
+		name[i++] = *pstr++;
+	}
+	name[i] = '\0';
+
+	for (i=0; i<arg_num; i++) {
+		if (!strcmp((char *)name, mib_table[i].name)) {
+			return &mib_table[i];
+		}
+	}
+	return NULL;
+}
+
+
+int get_array_val(unsigned char *dst, char *src, int len)
+{
+	char tmpbuf[4];
+	int num=0;
+
+	while (len > 0) {
+		memcpy(tmpbuf, src, 2);
+		tmpbuf[2]='\0';
+		*dst++ = (unsigned char)_atoi(tmpbuf, 16);
+		len-=2;
+		src+=2;
+		num++;
+	}
+	return num;
+}
+
+
+char *get_arg(char *src, char *val)
+{
+	int len=0;
+
+	while (*src && *src!=',') {
+		*val++ = *src++;
+		len++;
+	}
+	if (len == 0)
+		return NULL;
+
+	*val = '\0';
+
+	if (*src==',')
+		src++;
+
+	return src;
+}
+
+
+#ifdef SUPPORT_MULTI_PROFILE
+static int  add_ap_profile(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+	char  tmpbuf[100], *ptr;
+	struct ap_profile profile;	
+
+	if (priv->pmib->ap_profile.profile_num >= PROFILE_NUM) {
+		panic_printk("Can't add new one because profile table is full!\n");
+		return -1;		
+	}
+
+	if (data == NULL) {
+		panic_printk("invalid ap_profile_add value [%s] !\n", data);
+		return -1;
+	}
+	ptr  = get_arg((char *)data, tmpbuf);
+	if (ptr == NULL || strlen(tmpbuf) == 0) {
+		panic_printk("SSID must be set!\n");
+		return -1;
+	}		
+	strncpy(profile.ssid, tmpbuf, sizeof(profile.ssid)-1);
+	profile.ssid[sizeof(profile.ssid)-1] = '\0';
+
+	ptr  = get_arg(ptr, tmpbuf);
+	if (ptr == NULL) {
+		panic_printk("encryption must be set!\n");
+		return -1;
+	}				
+	profile.encryption =  _atoi(tmpbuf, 10);		
+	if (profile.encryption > 4) {
+		panic_printk("Invalid encryption value!\n");
+		return -1;
+	}					
+
+	ptr  = get_arg(ptr, tmpbuf);
+	if (ptr == NULL) {
+		panic_printk("auth_type must be set!\n");
+		return -1;
+	}				
+	profile.auth_type =  _atoi(tmpbuf, 10);
+	if (profile.auth_type == 0)
+		goto copy_profile;
+	
+	if (profile.encryption == 1 || profile.encryption == 2) {
+		ptr  = get_arg(ptr, tmpbuf);
+		if (ptr == NULL) {
+			panic_printk("default wep tx key must be set!\n");
+			return -1;
+		}
+		profile.wep_default_key =  _atoi(tmpbuf, 10);
+
+		ptr  = get_arg(ptr, tmpbuf);
+		if (ptr == NULL) {
+			panic_printk("wep key1 must be set!\n");
+			return -1;			
+		}		
+		if (profile.encryption == 1 && strlen(tmpbuf) != 10) {
+			panic_printk("Invalid wep64 key1 value!\n");
+			return -1;
+		}		
+		if (profile.encryption == 2 && strlen(tmpbuf) != 26) {
+			panic_printk("Invalid wep128 key1 value!\n");
+			return -1;
+		}
+		get_array_val(profile.wep_key1, tmpbuf, strlen(tmpbuf));
+		
+		ptr  = get_arg(ptr, tmpbuf);
+		if (ptr == NULL) {
+			panic_printk("wep key2 must be set!\n");
+			return -1;			
+		}		
+		if (profile.encryption == 1 && strlen(tmpbuf) != 10) {
+			panic_printk("Invalid wep64 key2 value!\n");
+			return -1;
+		}
+		if (profile.encryption == 2 && strlen(tmpbuf) != 26) {
+			panic_printk("Invalid wep128 key2 value!\n");
+			return -1;
+		}
+		get_array_val(profile.wep_key2, tmpbuf, strlen(tmpbuf));
+		
+		ptr  = get_arg(ptr, tmpbuf);
+		if (ptr == NULL) {
+			panic_printk("wep key3 must be set!\n");
+			return -1;			
+		}		
+		if (profile.encryption == 1 && strlen(tmpbuf) != 10) {
+			panic_printk("Invalid wep64 key3 value!\n");
+			return -1;
+		}
+		if (profile.encryption == 2 && strlen(tmpbuf) != 26) {
+			panic_printk("Invalid wep128 key3 value!\n");
+			return -1;
+		}
+		get_array_val(profile.wep_key3, tmpbuf, strlen(tmpbuf));
+		
+		ptr  = get_arg(ptr, tmpbuf);
+		if (ptr == NULL) {
+			panic_printk("wep key4 must be set!\n");
+			return -1;			
+		}		
+		if (profile.encryption == 1 && strlen(tmpbuf) != 10) {
+			panic_printk("Invalid wep64 key4 value!\n");
+			return -1;
+		}
+		if (profile.encryption == 2 && strlen(tmpbuf) != 26) {
+			panic_printk("Invalid wep128 key4 value!\n");
+			return -1;
+		}		
+		get_array_val(profile.wep_key4, tmpbuf, strlen(tmpbuf));		
+	}
+	else {
+		ptr  = get_arg(ptr, tmpbuf);
+		if (ptr == NULL) {
+			panic_printk("wpa cipher must be set!\n");
+			return -1;
+		}		
+		profile.wpa_cipher =  _atoi(tmpbuf, 10);
+
+		ptr  = get_arg(ptr, tmpbuf);
+		if (ptr == NULL || strlen(tmpbuf) == 0 || strlen(tmpbuf) < 8 || strlen(tmpbuf) > 64) {
+			panic_printk("Invalid wpa psk!\n");
+			return -1;
+		}						
+		strncpy(profile.wpa_psk, tmpbuf, sizeof(profile.wpa_psk)-1);
+		profile.wpa_psk[sizeof(profile.wpa_psk)-1] = '\0';
+		
+#ifdef CONFIG_IEEE80211W_CLI
+		if((priv->wpa_global_info->rsnie_cap & BIT(6)) && (priv->wpa_global_info->rsnie_cap & BIT(7))){
+			PMFDEBUG("AP PMF capability = Required\n");
+			profile.bss_PMF = MGMT_FRAME_PROTECTION_REQUIRED ;
+		}
+		else if(priv->wpa_global_info->rsnie_cap & BIT(7)){
+			PMFDEBUG("AP PMF capability = MFPC\n");
+			profile.bss_PMF = MGMT_FRAME_PROTECTION_OPTIONAL ;
+		}
+		else{
+			PMFDEBUG("AP PMF capability = None\n");
+			profile.bss_PMF = NO_MGMT_FRAME_PROTECTION ;
+		}		
+#endif
+	}
+	
+copy_profile:	
+	memset(&priv->pmib->ap_profile.profile[priv->pmib->ap_profile.profile_num], '\0', sizeof(profile));	
+	memcpy(&priv->pmib->ap_profile.profile[priv->pmib->ap_profile.profile_num], &profile, sizeof(profile));	
+	priv->pmib->ap_profile.profile_num++;
+	return 0;
+}
+#endif	// SUPPORT_MULTI_PROFILE
+
+#if defined(SWITCH_CHAN) && defined(UNIVERSAL_REPEATER)
+/*  switch channel
+  * 
+  *     iwpriv wlan0 set_mib switch_chan=1,N   //switch channel to N
+  *     iwpriv wlan0 set_mib switch_chan=0	    //switch channel back to root channel
+  */
+static int switch_chan(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+	char tmpbuf[100], *ptr;
+	int mode, chan, i;
+
+	if (data == NULL) {
+		panic_printk("invalid switch_chan value [%s] !\n", data);
+		return -1;
+	}
+	if (!IS_ROOT_INTERFACE(priv)) {
+		panic_printk("Must issue command in root interface !\n");
+		return -1;					
+	}
+	if (!(OPMODE & WIFI_AP_STATE)) {
+		panic_printk("root interface must be AP !\n");
+		return -1;							
+	}		
+	if (!IS_DRV_OPEN(GET_VXD_PRIV(priv))) {
+		panic_printk("vxd interface did not be started yet !\n");
+		return -1;			
+	}
+	ptr  = get_arg((char *)data, tmpbuf);
+	if (ptr == NULL) {
+		panic_printk("argument error, mode must be set !\n");
+		return -1;
+	}				
+	mode =_atoi(tmpbuf, 10);
+
+	if (mode) { // switch to vxd chan	
+		if (!priv->pmib->dot11RFEntry.dot11channel) {
+			panic_printk("channel is not stable in root interface !\n");
+			return -1;			
+		}
+		ptr = get_arg((char *)ptr, tmpbuf);
+		if (ptr == NULL) {
+			panic_printk("argument error, channel number must be set !\n");
+			return -1;
+		}				
+		chan =_atoi(tmpbuf, 10);	
+		for (i=0; i<priv->available_chnl_num; i++) {
+			if (chan == priv->available_chnl[i])
+				break;
+		}
+		if (i == priv->available_chnl_num) {
+			panic_printk("invalid chan [%d] !\n", chan);
+			return -1;			
+		}		
+
+		priv->chan_backup = priv->pmib->dot11RFEntry.dot11channel;
+		priv->bw_backup = priv->pshare->CurrentChannelBW;
+		priv->offset_backup = priv->pshare->offset_2nd_chan;
+		priv->func_backup = priv->pmib->miscEntry.func_off;
+
+		priv->pshare->CurrentChannelBW = HT_CHANNEL_WIDTH_20;
+		priv->pshare->offset_2nd_chan = 0;
+		priv->pmib->dot11RFEntry.dot11channel = chan;
+		priv->pmib->miscEntry.func_off = 1;		
+	}
+	else {
+		priv->pmib->dot11RFEntry.dot11channel = priv->chan_backup;
+		priv->pshare->CurrentChannelBW = priv->bw_backup;
+		priv->pshare->offset_2nd_chan = priv->offset_backup;
+		priv->pmib->miscEntry.func_off = priv->func_backup;
+	}
+
+	SwBWMode(priv, priv->pshare->CurrentChannelBW, priv->pshare->offset_2nd_chan);
+	SwChnl(priv, priv->pmib->dot11RFEntry.dot11channel, priv->pshare->offset_2nd_chan);
+	
+#ifdef CONFIG_RTL_92D_SUPPORT
+	if (GET_CHIP_VER(priv) == VERSION_8192D)
+		PHY_IQCalibrate(priv);
+#endif		
+	
+	return 0;
+}
+#endif	// SUPPORT_MULTI_PROFILE
+
+
+#if (!defined(CONFIG_RTL_COMAPI_CFGFILE) && !defined(CONFIG_RTL_COMAPI_WLTOOLS) && !defined(INCLUDE_WPS))
+static
+#endif
+int set_mib(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+	struct iwpriv_arg *entry;
+	int int_val, int_idx, len, *int_ptr;
+	int is_hex_type=0;
+	unsigned char byte_val;
+#ifdef USE_OUT_SRC	
+	unsigned short short_val;
+	unsigned long long  longlong_val;
+#endif	
+	char *arg_val, tmpbuf[100];
+#ifdef CONFIG_RTK_MESH
+	unsigned short word;
+#endif
+	DEBUG_TRACE;
+
+	DEBUG_INFO("set_mib %s\n", data);
+
+	entry = get_tbl_entry((char *)data);
+	if (entry == NULL) {
+		DEBUG_ERR("invalid mib name [%s] !\n", data);
+		return -1;
+	}
+
+	// search value
+	arg_val = (char *)data;
+	while (*arg_val && *arg_val != '='){
+		arg_val++;
+	}
+
+	if (!*arg_val) {
+		DEBUG_ERR("mib value empty [%s] !\n", data);
+		return -1;
+	}
+	
+	
+	//printk("[%s %d] %c \n",__FUNCTION__,__LINE__ , *arg_val);
+	arg_val++;
+	
+	// skip space
+	while (*arg_val && *arg_val == 0x7f)
+		arg_val++;
+
+	switch (entry->type) {
+	case BYTE_T:
+		byte_val = (unsigned char)_atoi(arg_val, 10);
+		memcpy(((unsigned char *)priv->pmib)+entry->offset, &byte_val,  1);
+		break;
+#ifdef CONFIG_RTK_MESH
+	case WORD_T:
+		word = (unsigned short)_atoi(arg_val, 10);
+		memcpy(((unsigned char *)priv->pmib)+entry->offset, &word,  2);
+		break;
+#endif
+	case INT_T:
+		if(*arg_val=='0' && (*(arg_val+1)== 'x' || *(arg_val+1)== 'X')){
+			is_hex_type=1;
+			arg_val+=2;
+			printk("[%s %d]hex format\n",__FUNCTION__,__LINE__);
+		}
+
+		if(is_hex_type)
+			int_val = _atoi(arg_val, 16);
+		else
+			int_val = _atoi(arg_val, 10);
+		
+#ifdef WIFI_SIMPLE_CONFIG
+		if (strcmp(entry->name, "wsc_enable") == 0) {
+			if (int_val == 4) { // disable hidden AP
+				if (HIDDEN_AP && priv->pbeacon_ssid) {
+					memcpy(priv->pbeacon_ssid+2, SSID, SSID_LEN);
+					priv->hidden_ap_mib_backup = HIDDEN_AP;
+					HIDDEN_AP = 0;
+				}
+				break;
+			}
+			if (int_val == 5) { // restore hidden AP
+				if (priv->pbeacon_ssid && !HIDDEN_AP && priv->hidden_ap_mib_backup) {
+					memset(priv->pbeacon_ssid+2, '\0', SSID_LEN);
+					HIDDEN_AP = priv->hidden_ap_mib_backup;
+				}
+				break;
+			}
+#ifdef CLIENT_MODE
+			if ((priv->pmib->wscEntry.wsc_enable == 1) && (int_val == 0)) { 
+				/*handle for WPS client mode fail or timeout*/ 
+
+				if (priv->recover_join_req) {
+					priv->recover_join_req = 0;
+					priv->pmib->wscEntry.wsc_enable = 0;
+
+					memcpy(&priv->pmib->dot11Bss, &priv->dot11Bss_original, sizeof(struct bss_desc));
+
+					SSID_LEN = priv->orig_SSID_LEN ;	
+					memset(SSID,'\0',sizeof(SSID));					
+					memcpy(SSID , priv->orig_SSID , SSID_LEN);
+
+					SSID2SCAN_LEN = priv->orig_SSID_LEN;
+					memset(SSID2SCAN,'\0',sizeof(SSID2SCAN));
+					memcpy(SSID2SCAN ,priv->orig_SSID , SSID2SCAN_LEN);															
+					//memset(BSSID, 0, MACADDRLEN);
+					if (netif_running(priv->dev))
+					{
+						SMP_UNLOCK(flags);
+						rtl8192cd_close(priv->dev);					
+						rtl8192cd_open(priv->dev);
+						SMP_LOCK(flags);
+					}
+					break;
+				}
+			}
+			else if ((priv->pmib->wscEntry.wsc_enable == 6) && (int_val == 0)) {
+				/*handle for WPS client mode success;(don't do wlan driver close open)*/ 			
+
+				priv->pmib->wscEntry.wsc_enable = 0;
+				
+			}
+			else if ((priv->pmib->wscEntry.wsc_enable == 0) && (int_val == 1)){
+				/*before start of client WPS backup some info for later restroe*/ 
+
+				memcpy(&priv->dot11Bss_original, &priv->pmib->dot11Bss, sizeof(struct bss_desc));
+				memset(priv->orig_SSID,'\0',sizeof(priv->orig_SSID));				
+				memcpy(priv->orig_SSID , SSID , SSID_LEN);
+				priv->orig_SSID_LEN = SSID_LEN;	
+ 				/*fixed for IOT issue */
+				if((OPMODE&(WIFI_STATION_STATE | WIFI_AUTH_SUCCESS | WIFI_ASOC_STATE))
+						==(WIFI_STATION_STATE | WIFI_AUTH_SUCCESS | WIFI_ASOC_STATE))
+				{
+					/*if client mode is associated set recover_join_req;
+					then when wsc immediately be cancelled client will recover orig assoc*/ 
+					priv->recover_join_req = 1;	
+					
+					issue_disassoc(priv, BSSID, _RSON_DEAUTH_STA_LEAVING_);					
+					OPMODE_VAL(OPMODE & ~(WIFI_AUTH_SUCCESS | WIFI_ASOC_STATE));					
+				} 
+ 
+
+				
+			}
+
+#endif
+		}
+#endif
+
+		memcpy(((unsigned char *)priv->pmib)+entry->offset, (unsigned char *)&int_val, sizeof(int));
+
+#ifdef CONFIG_POWER_SAVE
+		if (strcmp(entry->name, "ps_level") == 0)
+		{
+			if (int_val < 0) {
+				DEBUG_ERR("invalid INT_T mib index [%s, %d] !\n", entry->name, int_val);
+				return -1;
+			}
+			if (IS_ROOT_INTERFACE(priv)) {
+				if (int_val == 0)
+					ap_offload_deactivate(priv, OFFLOAD_PROHIBIT_USER);
+				else
+					ap_offload_activate(priv, OFFLOAD_PROHIBIT_USER);
+			}
+		}
+		else if (!strcmp(entry->name, "ps_sleep_time"))
+		{
+			if (int_val < 0 || int_val > 100) {
+				DEBUG_ERR("invalid INT_T mib index [%s, %d] !\n", entry->name, int_val);
+				return -1;
+			}
+			if (IS_ROOT_INTERFACE(priv) && IS_DRV_OPEN(priv)) {
+				if ((RTW_STS_SUSPEND == priv->pshare->pwr_state)
+					|| (priv->pshare->offload_function_ctrl > RTW_PM_PREPROCESS)
+					)
+				{
+					ap_offload_exit(GET_ROOT(priv));
+					rtw_lock_suspend_timeout(priv, 2000);
+				}
+			}
+		}
+#endif
+#ifdef HANDLE_TX_THREAD_ZTE
+		if (strcmp(entry->name, "ps_try_xmit_event") == 0)
+		{
+			int ps_try_xmit_event = int_val;
+			
+			if (ps_try_xmit_event < 0 || ps_try_xmit_event > 2) {
+				DEBUG_ERR("invalid INT_T mib index [%s, %d] !\n", entry->name, ps_try_xmit_event);
+				return -1;
+			}
+
+			if (IS_ROOT_INTERFACE(priv)) {
+				if (ps_try_xmit_event == 1)
+					rtl81xxes_wake_event_xmit_thread(priv);
+				else if (ps_try_xmit_event == 2)
+					rtl81xxes_xmit_kick_thread(priv);
+			}
+		}
+#endif
+		break;
+
+	case SSID_STRING_T:
+		if (strlen(arg_val) > entry->len)
+			arg_val[entry->len] = '\0';
+		memset(priv->pmib->dot11StationConfigEntry.dot11DesiredSSID, 0, sizeof(priv->pmib->dot11StationConfigEntry.dot11DesiredSSID));
+		memcpy(priv->pmib->dot11StationConfigEntry.dot11DesiredSSID, arg_val, strlen(arg_val));
+		priv->pmib->dot11StationConfigEntry.dot11DesiredSSIDLen = strlen(arg_val);
+		if ((SSID_LEN == 3) &&
+			((SSID[0] == 'A') || (SSID[0] == 'a')) &&
+			((SSID[1] == 'N') || (SSID[1] == 'n')) &&
+			((SSID[2] == 'Y') || (SSID[2] == 'y'))) {
+			SSID2SCAN_LEN = 0;
+			memset(SSID2SCAN, 0, 32);
+		}
+		else {
+			SSID2SCAN_LEN = SSID_LEN;
+			memcpy(SSID2SCAN, SSID, SSID_LEN);
+		}
+		break;
+
+	case BYTE_ARRAY_T:
+		len = strlen(arg_val);
+		if (len/2 > entry->len) {
+			DEBUG_ERR("invalid len of BYTE_ARRAY_T mib [%s] !\n", entry->name);
+			return -1;
+		}
+		if (len%2) {
+			DEBUG_ERR("invalid len of BYTE_ARRAY_T mib [%s] !\n", entry->name);
+			return -1;
+		}
+		get_array_val(((unsigned char *)priv->pmib)+entry->offset, arg_val, strlen(arg_val));
+		break;
+
+	case ACL_T:
+	case ACL_INT_T:
+		arg_val = get_arg(arg_val, tmpbuf);
+		if (arg_val == NULL) {
+			DEBUG_ERR("invalid ACL_T addr [%s] !\n", entry->name);
+			return -1;
+		}
+		if (entry->type == ACL_T && strlen(tmpbuf)!=12) {
+			DEBUG_ERR("invalid len of ACL_T mib [%s] !\n", entry->name);
+			return -1;
+		}
+		int_ptr = (int *)(((unsigned char *)priv->pmib)+entry->offset+entry->len);
+		int_idx = *int_ptr;
+		if (entry->type == ACL_T) {
+			if (int_idx < (entry->len/6))
+				get_array_val(((unsigned char *)priv->pmib)+entry->offset+int_idx*6, tmpbuf, 12);
+			else {
+				DEBUG_ERR("reach the max capacity of ACL_T mib [%s] !\n", entry->name);
+				return -1;
+			}
+		} else {
+			if (int_idx < (entry->len/10)) {
+				get_array_val(((unsigned char *)priv->pmib)+entry->offset+int_idx*(6+4), tmpbuf, 12);
+				if (strlen(arg_val) > 0) {
+					int_val = _atoi(arg_val, 10);
+					memcpy(((unsigned char *)priv->pmib)+entry->offset+int_idx*(6+4)+6, &int_val, 4);
+				}
+			} else {
+				DEBUG_ERR("reach the max capacity of ACL_INT_T mib [%s] !\n", entry->name);
+				return -1;
+			}
+		}
+		*int_ptr = *int_ptr + 1;
+		break;
+
+	case IDX_BYTE_ARRAY_T:
+		arg_val = get_arg(arg_val, tmpbuf);
+		if (arg_val == NULL) {
+			DEBUG_ERR("invalid BYTE_ARRAY mib [%s] !\n", entry->name);
+			return -1;
+		}
+		int_idx = _atoi(tmpbuf, 10);
+		if (int_idx+1 > entry->len) {
+			DEBUG_ERR("invalid BYTE_ARRAY mib index [%s, %d] !\n", entry->name, int_idx);
+			return -1;
+		}
+		arg_val = get_arg(arg_val, tmpbuf);
+		if (arg_val == NULL) {
+			DEBUG_ERR("invalid BYTE_ARRAY mib [%s] !\n", entry->name);
+			return -1;
+		}
+		byte_val = (unsigned char)_atoi(tmpbuf, 10);
+		memcpy(((unsigned char *)priv->pmib)+entry->offset+int_idx, (unsigned char *)&byte_val, sizeof(byte_val));
+		break;
+
+	case MULTI_BYTE_T:
+		int_idx=0;
+		while (1) {
+			arg_val = get_arg(arg_val, tmpbuf);
+			if (arg_val == NULL)
+				break;
+			if (int_idx+1 > entry->len) {
+				DEBUG_ERR("invalid MULTI_BYTE_T mib index [%s, %d] !\n", entry->name, int_idx);
+				return -1;
+			}
+			byte_val = (unsigned char)_atoi(tmpbuf, 16);
+			memcpy(((unsigned char *)priv->pmib)+entry->offset+int_idx++, (unsigned char *)&byte_val, sizeof(byte_val));
+		}
+		// copy length to next parameter
+		memcpy( ((unsigned char *)priv->pmib)+entry->offset+entry->len, (unsigned char *)&int_idx, sizeof(int));
+		break;
+
+#ifdef _DEBUG_RTL8192CD_
+	case DEBUG_T:
+		int_val = _atoi(arg_val, 16);
+		if (entry->offset==1)
+			rtl8192cd_debug_err = int_val;
+		else if (entry->offset==2)
+			rtl8192cd_debug_info = int_val;
+		else if (entry->offset==3)
+			rtl8192cd_debug_trace = int_val;
+		else if (entry->offset==4)
+			rtl8192cd_debug_warn = int_val;
+		else if (entry->offset==5)
+			rtl8192cd_debug_psk= int_val;
+		else if (entry->offset==6)
+        {
+            if (int_val == 2)
+            {
+                rtl8192cd_dbg_showLog();     
+            }
+            else
+            {
+                rtl8192cd_debug_memlog = int_val;
+            }
+        }
+		else {
+			DEBUG_ERR("invalid debug index\n");
+		}
+		break;
+#endif // _DEBUG_RTL8192CD_
+
+	case DEF_SSID_STRING_T:
+		if (strlen(arg_val) > entry->len)
+			arg_val[entry->len] = '\0';
+		memset(priv->pmib->dot11StationConfigEntry.dot11DefaultSSID, 0, sizeof(priv->pmib->dot11StationConfigEntry.dot11DefaultSSID));
+		memcpy(priv->pmib->dot11StationConfigEntry.dot11DefaultSSID, arg_val, strlen(arg_val));
+		priv->pmib->dot11StationConfigEntry.dot11DefaultSSIDLen = strlen(arg_val);
+		break;
+#ifdef CONFIG_RTL_COMAPI_CFGFILE
+	case SSID2SCAN_STRING_T:
+		if (strlen(arg_val) > entry->len)
+			arg_val[entry->len] = '\0';
+		memset(priv->pmib->dot11StationConfigEntry.dot11SSIDtoScan, 0, sizeof(priv->pmib->dot11StationConfigEntry.dot11SSIDtoScan));
+		memcpy(priv->pmib->dot11StationConfigEntry.dot11SSIDtoScan, arg_val, strlen(arg_val));
+		priv->pmib->dot11StationConfigEntry.dot11SSIDtoScanLen = strlen(arg_val);
+		break;
+#endif
+
+	case STRING_T:
+		if (strlen(arg_val) >= entry->len)
+			arg_val[entry->len-1] = '\0';
+		strcpy((char *)(((unsigned char *)priv->pmib)+entry->offset), arg_val);
+		break;
+
+	case RFFT_T:
+		if (entry->len == 1) {
+			byte_val = _atoi(arg_val, 10);
+#ifdef WIFI_SNIFFER
+			if (strcmp(entry->name, "sniffer") == 0) {
+				if (priv->pshare->rf_ft_var.sniffer) {
+					if (byte_val == 0)
+						stop_monitor_mode(priv);
+				} else if (byte_val) {
+					start_monitor_mode(priv);
+				}
+			}
+#endif
+			memcpy(((unsigned char *)&priv->pshare->rf_ft_var)+entry->offset, (unsigned char *)&byte_val, entry->len);
+#ifdef DFS
+			if ((strcmp(entry->name, "dfsdbgmode") == 0) && (byte_val)) {
+				if (priv->pmib->dot11StationConfigEntry.dot11RegDomain == DOMAIN_ETSI) {
+					if (GET_CHIP_VER(priv) == VERSION_8192D) {
+						PHY_SetBBReg(priv, 0x90c, bMaskDWord, 0x83321333);
+						PHY_SetBBReg(priv, 0xe10, bMaskDWord, 0x30303030);
+						PHY_SetBBReg(priv, 0x83c, bMaskDWord, 0x30303030);
+					}
+					else if ((GET_CHIP_VER(priv) == VERSION_8812E) || (GET_CHIP_VER(priv) == VERSION_8881A))
+						PHY_SetBBReg(priv, 0x80c, BIT(28), 1);
+				}
+				if (GET_CHIP_VER(priv) == VERSION_8192D) {
+					PHY_SetBBReg(priv, 0xc7c, BIT(28), 0); // ynlin dbg
+					PHY_SetBBReg(priv, 0xcdc, BIT(8)|BIT(9), 1);
+				}
+			}
+			else if ((strcmp(entry->name, "det_reset") == 0) && (byte_val)) {
+				priv->pmib->dot11DFSEntry.DFS_detected = 0;
+				priv->FA_count_pre = 0;
+				priv->VHT_CRC_ok_cnt_pre = 0;
+				priv->HT_CRC_ok_cnt_pre = 0;
+				priv->LEG_CRC_ok_cnt_pre = 0;
+				priv->mask_idx = 0;
+				priv->mask_hist_checked = 0;
+				memset(priv->radar_det_mask_hist, 0, sizeof(priv->radar_det_mask_hist));
+				memset(priv->pulse_flag_hist, 0, sizeof(priv->pulse_flag_hist));
+			}
+#endif
+		} else if (entry->len == 4) {
+			int_val = _atoi(arg_val, 10);
+			memcpy(((unsigned char *)&priv->pshare->rf_ft_var)+entry->offset, (unsigned char *)&int_val, entry->len);
+		}
+#ifdef RTK_NL80211//mark_priv
+		else
+		{
+			if (strlen(arg_val) > entry->len)
+				arg_val[entry->len] = '\0';
+			strcpy(((char *)&priv->pshare->rf_ft_var)+entry->offset ,arg_val);
+		}				
+#endif
+		break;
+
+	case RFFT_ACL_T:
+			arg_val = get_arg(arg_val, tmpbuf);
+			if (arg_val == NULL) {
+				DEBUG_ERR("invalid RFFT_ACL_T addr [%s] !\n", entry->name);
+				return -1;
+			}
+			if (strlen(tmpbuf)!=12) {
+				DEBUG_ERR("invalid len of RFFT_ACL_T mib [%s] !\n", entry->name);
+				return -1;
+			}
+			
+			int_ptr = (int *)(((unsigned char *)&priv->pshare->rf_ft_var)+entry->offset+entry->len);
+			int_idx = *int_ptr;
+			get_array_val(((unsigned char *)&priv->pshare->rf_ft_var)+entry->offset+int_idx*6, tmpbuf, 12);
+			*int_ptr = *int_ptr + 1;
+			break;
+
+	case VARLEN_BYTE_T:
+		len = strlen(arg_val);
+		if (len/2 > entry->len) {
+			DEBUG_ERR("invalid len of VARLEN_BYTE_T mib [%s] !\n", entry->name);
+			return -1;
+		}
+		if (len%2) {
+			DEBUG_ERR("invalid len of VARLEN_BYTE_T mib [%s] !\n", entry->name);
+			return -1;
+		}
+		memset(((unsigned char *)priv->pmib)+entry->offset, 0, entry->len);
+		len = get_array_val(((unsigned char *)priv->pmib)+entry->offset, arg_val, strlen(arg_val));
+		*(unsigned int *)(((unsigned char *)priv->pmib)+entry->offset+entry->len) = len;
+		break;
+
+#ifdef WIFI_SIMPLE_CONFIG
+	case PIN_IND_T:
+		if (strlen(arg_val) > entry->len) {
+
+#ifdef INCLUDE_WPS
+			//include-wps case
+			//upnp will direct function call to wps_pin(arg_val);
+			//printk("set_mib:PIN=%s\n",arg_val);
+			wps_pin(arg_val);
+#else
+			DOT11_WSC_PIN_IND wsc_ind;
+
+			wsc_ind.EventId = DOT11_EVENT_WSC_PIN_IND;
+			wsc_ind.IsMoreEvent = 0;
+			if (strlen(arg_val) >= sizeof(wsc_ind.code)) {
+				strncpy((char *)wsc_ind.code, arg_val, sizeof(wsc_ind.code)-1);
+				wsc_ind.code[sizeof(wsc_ind.code)-1] = '\0';
+			} else
+				strcpy((char *)wsc_ind.code, arg_val);
+			DOT11_EnQueue((unsigned long)priv, priv->pevent_queue, (unsigned char*)&wsc_ind, sizeof(DOT11_WSC_PIN_IND));
+			event_indicate(priv, NULL, -1);
+#endif
+		}
+		break;
+/* WPS2DOTX   */
+	/* support  Assigned MAC Addr,Assigned SSID,dymanic change STA's PIN code, 2011-0505 */	
+	case WSC_SELF_PIN_IND_T:
+		if (strlen(arg_val) > entry->len) {
+			DOT11_WSC_PIN_IND wsc_ind;
+			wsc_ind.EventId = DOT11_EVENT_WSC_SET_MY_PIN;
+			wsc_ind.IsMoreEvent = 0;
+			if (strlen(arg_val) >= sizeof(wsc_ind.code)) {
+				strncpy((char *)wsc_ind.code, arg_val, sizeof(wsc_ind.code)-1);
+				wsc_ind.code[sizeof(wsc_ind.code)-1] = '\0';
+			} else
+				strcpy((char *)wsc_ind.code, arg_val);
+			DOT11_EnQueue((unsigned long)priv, priv->pevent_queue, (unsigned char*)&wsc_ind, sizeof(DOT11_WSC_PIN_IND));
+			event_indicate(priv, NULL, -1);
+		}
+		break;
+	case WSC_SEPC_SSID_CONN_IND_T:
+		if (strlen(arg_val) > entry->len) {
+			DOT11_WSC_PIN_IND wsc_ind;
+
+			wsc_ind.EventId = DOT11_EVENT_WSC_SPEC_SSID;
+			wsc_ind.IsMoreEvent = 0;
+			if (strlen(arg_val) >= sizeof(wsc_ind.code)) {
+				strncpy((char *)wsc_ind.code, arg_val, sizeof(wsc_ind.code)-1);
+				wsc_ind.code[sizeof(wsc_ind.code)-1] = '\0';
+			} else
+				strcpy((char *)wsc_ind.code, arg_val);
+			DOT11_EnQueue((unsigned long)priv, priv->pevent_queue, (unsigned char*)&wsc_ind, sizeof(DOT11_WSC_PIN_IND));
+			event_indicate(priv, NULL, -1);
+		}
+		break;
+	case WSC_SEPC_MAC_CONN_IND_T:
+		if (strlen(arg_val) > entry->len) {
+			DOT11_WSC_PIN_IND wsc_ind;
+			wsc_ind.EventId = DOT11_EVENT_WSC_SPEC_MAC_IND;
+			wsc_ind.IsMoreEvent = 0;
+			if (strlen(arg_val) >= sizeof(wsc_ind.code)) {
+				strncpy((char *)wsc_ind.code, arg_val, sizeof(wsc_ind.code)-1);
+				wsc_ind.code[sizeof(wsc_ind.code)-1] = '\0';
+			} else
+				strcpy((char *)wsc_ind.code, arg_val);
+			DOT11_EnQueue((unsigned long)priv, priv->pevent_queue, (unsigned char*)&wsc_ind, sizeof(DOT11_WSC_PIN_IND));
+			event_indicate(priv, NULL, -1);
+		}
+		break;
+	/* support  Assigned MAC Addr,Assigned SSID,dymanic change STA's PIN code, 2011-0505 */			
+/* WPS2DOTX   */	
+#ifdef INCLUDE_WPS
+#ifndef CONFIG_MSC
+	case WSC_IND_T:
+		/*event notify user space upnp ,call by wps "*/
+	if (strcmp(entry->name, "wps_get_config") == 0)  {
+			printk("sme rx wps_get_config cmd\n");
+			DOT11_WSC_PIN_IND wsc_ind;
+			wsc_ind.EventId = DOT11_EVENT_WSC_GETCONF_IND;
+			wsc_ind.IsMoreEvent = 0;
+			if (strlen(arg_val) >= sizeof(wsc_ind.code)) {
+				strncpy((char *)wsc_ind.code, arg_val, sizeof(wsc_ind.code)-1);
+				wsc_ind.code[sizeof(wsc_ind.code)-1] = '\0';
+			} else
+				strcpy(wsc_ind.code,arg_val);
+			DOT11_EnQueue((unsigned long)priv, priv->pevent_queue, (unsigned char*)&wsc_ind, sizeof(DOT11_WSC_PIN_IND));
+			event_indicate(priv, NULL, -1);
+		}
+		else if (strcmp(entry->name, "wsc_soap_action") == 0)  {
+			DOT11_WSC_SOAP soap;
+	        	struct iw_point wrq;
+
+        		wrq.pointer = (caddr_t)&soap;
+        		wrq.length = sizeof(DOT11_WSC_SOAP);
+
+	       		soap.EventId = DOT11_EVENT_WSC_SOAP;
+        		soap.IsMoreEvent = FALSE;
+	        	strcpy(soap.action, arg_val);
+				printk("ioctl soap name:%s\n",arg_val);
+	        	//rtl8192cd_ioctl_priv_daemonreq(priv->dev, &wrq);
+		}
+
+		else if (strcmp(entry->name, "wsc_event_callback") == 0)  {
+			DOT11_WSC_PIN_IND wsc_ind;
+
+			wsc_ind.EventId = DOT11_EVENT_WSC_GETCONF_IND;
+			wsc_ind.IsMoreEvent = 0;
+            DOT11_EnQueue((unsigned long)priv, priv->pevent_queue, (unsigned char*)&wsc_ind, sizeof(DOT11_WSC_PIN_IND));
+            event_indicate(priv, NULL, -1);
+
+        }
+		else if (strcmp(entry->name, "wps_led_control") == 0) {	/*event to upnp*/
+
+            DOT11_WPS_LEDCRTL wsc_ind;
+                        short flag = 0;
+
+                        wsc_ind.EventId = DOT11_EVENT_WSC_LEDCONTROL_IND;
+
+                        if(strcmp("WSC_START",arg_val) == 0)
+                            flag = -1;
+                        else if(strcmp("WSC_END",arg_val) == 0)
+                            flag = -2;
+                        else if(strcmp("PBC_OVERLAPPED",arg_val) == 0)
+                            flag = -3;
+                        else if(strcmp("WSC_ERROR",arg_val) == 0)
+                            flag = -4;
+                        else if(strcmp("WSC_SUCCESS",arg_val) == 0)
+                            flag = -5;
+                        else if(strcmp("WSC_NOP",arg_val) == 0)
+                            flag = -6;
+                        else
+                            flag = -7;
+
+            wsc_ind.flag = flag;
+            DOT11_EnQueue((unsigned long)priv, priv->pevent_queue, (unsigned char*)&wsc_ind, sizeof(DOT11_WPS_LEDCRTL));
+            event_indicate(priv, NULL, -1);
+
+        }
+		else if (strcmp(entry->name, "wps_debug") == 0) {	/*event to wps*/
+	     	priv->pshare->WSC_CONT_S.debug = _atoi(arg_val,10);
+  	    }
+		else if (strcmp(entry->name, "wps_reinit") == 0) {	/*event to wps*/
+			printk("WPS module reinit from set_mib\n");
+	     	priv->pshare->WSC_CONT_S.wait_reinit = 1 ;
+			wps_init(priv);
+  	    }
+        break;
+
+	// from wps call event to user space upnp
+	case FLASH_RESTORE_T:
+		if (strlen(arg_val) > entry->len) {
+			DOT11_WSC_RESTORE2FLASH_IND	restore2flash;
+			memset(&restore2flash , 0 ,sizeof(struct _DOT11_WSC_RESTORE2FLASH_IND));
+			restore2flash.EventId = DOT11_EVENT_WSC_PUTCONF_IND;
+
+			strcpy(restore2flash.flashcmd[0], arg_val);
+			DOT11_EnQueue((unsigned long)priv, priv->pevent_queue, (unsigned char*)&restore2flash,
+				sizeof(DOT11_WSC_RESTORE2FLASH_IND));
+			event_indicate(priv, NULL, -1);
+		}
+		break;
+
+#endif	// end of CONFIG_MSC
+#endif	// end of INCLUDE_WPS
+#ifdef CONFIG_RTL_COMAPI_CFGFILE
+        case WSC_START_IND_T:
+                if( strlen(arg_val) > 0 ) {
+                        DOT11_WSC_IND wsc_ind;
+                        wsc_ind.EventId = DOT11_EVENT_WSC_START_IND;
+                        wsc_ind.IsMoreEvent = 0;
+                        //wsc_ind.value = arg_val;
+                        DOT11_EnQueue((unsigned long)priv, priv->pevent_queue, (unsigned char*)&wsc_ind, sizeof(DOT11_WSC_IND));
+                        event_indicate(priv, NULL, -1);
+                }
+                break;
+        //EV_MODE, EV_STATUS, EV_MEHOD, EV_STEP, EV_OOB
+        case WSC_MODE_IND_T:
+                if( strlen(arg_val) > 0 ) {
+                        DOT11_WSC_IND wsc_ind;
+                        wsc_ind.EventId = DOT11_EVENT_WSC_MODE_IND;
+                        wsc_ind.IsMoreEvent = 0;
+                        wsc_ind.value = _atoi(arg_val,10);
+                        DOT11_EnQueue((unsigned long)priv, priv->pevent_queue, (unsigned char*)&wsc_ind, sizeof(DOT11_WSC_IND));
+                        event_indicate(priv, NULL, -1);
+                }
+                break;
+        case WSC_STATUS_IND_T:
+                if( strlen(arg_val) > 0 ) {
+                        DOT11_WSC_IND wsc_ind;
+                        wsc_ind.EventId = DOT11_EVENT_WSC_STATUS_IND;
+                        wsc_ind.IsMoreEvent = 0;
+                        wsc_ind.value = _atoi(arg_val,10);
+                        DOT11_EnQueue((unsigned long)priv, priv->pevent_queue, (unsigned char*)&wsc_ind, sizeof(DOT11_WSC_IND));
+                        event_indicate(priv, NULL, -1);
+                }
+                break;
+        case WSC_METHOD_IND_T:
+                if( strlen(arg_val) > 0 ) {
+                        DOT11_WSC_IND wsc_ind;
+                        wsc_ind.EventId = DOT11_EVENT_WSC_METHOD_IND;
+                        wsc_ind.IsMoreEvent = 0;
+                        wsc_ind.value = _atoi(arg_val,10);
+                        if( wsc_ind.value > 3 || wsc_ind.value ==0 )
+                                wsc_ind.value = 1;      //default set to pin method
+                        printk("iwpriv set method = %d\n",wsc_ind.value);
+                        DOT11_EnQueue((unsigned long)priv, priv->pevent_queue, (unsigned char*)&wsc_ind, sizeof(DOT11_WSC_IND));
+                        event_indicate(priv, NULL, -1);
+                }
+                break;
+        case WSC_STEP_IND_T:
+                if( strlen(arg_val) > 0 ) {
+                        DOT11_WSC_IND wsc_ind;
+                        wsc_ind.EventId = DOT11_EVENT_WSC_STEP_IND;
+                        wsc_ind.IsMoreEvent = 0;
+                        //wsc_ind.value = arg_val;
+                        DOT11_EnQueue((unsigned long)priv, priv->pevent_queue, (unsigned char*)&wsc_ind, sizeof(DOT11_WSC_IND));
+                        event_indicate(priv, NULL, -1);
+                }
+                break;
+        case WSC_OOB_IND_T:
+                if( strlen(arg_val) > 0 ) {
+                        DOT11_WSC_IND wsc_ind;
+                        wsc_ind.EventId = DOT11_EVENT_WSC_OOB_IND;
+                        wsc_ind.IsMoreEvent = 0;
+                        //wsc_ind.value = arg_val;
+                        DOT11_EnQueue((unsigned long)priv, priv->pevent_queue, (unsigned char*)&wsc_ind, sizeof(DOT11_WSC_IND));
+                        event_indicate(priv, NULL, -1);
+                }
+                break;
+#endif  //ifdef CONFIG_RTL_COMAPI_CFGFILE
+#endif
+
+#ifdef CONFIG_RTL_WAPI_SUPPORT
+	case INT_ARRAY_T:
+		int_idx=0;
+		while (1) {
+			arg_val = get_arg(arg_val, tmpbuf);
+			if (arg_val == NULL)
+				break;
+			if (int_idx+1 > (entry->len)/sizeof(int)) {
+				DEBUG_ERR("invalid MULTI_BYTE_T mib index [%s, %d] !\n", entry->name, int_idx);
+				return -1;
+			}
+			int_val = _atoi(tmpbuf, 16);
+			memcpy(((unsigned char *)priv->pmib)+entry->offset+int_idx++, (void *)&int_val, sizeof(int_val));
+		}
+		break;
+	case WAPI_KEY_T:
+		{
+			char tmppasswd[100]={0};
+			int password_len;
+			wapiMibPSK *wapipsk=NULL;
+			int_idx=0;
+
+			/*Get Password*/
+			arg_val = get_arg(arg_val, tmpbuf);
+			if (arg_val == NULL)
+				break;
+			strncpy(tmppasswd, tmpbuf, sizeof(tmppasswd)-1);
+			tmppasswd[sizeof(tmppasswd)-1] = '\0';
+			password_len = strlen(tmppasswd);
+
+			/*Get Password length*/
+			arg_val=get_arg(arg_val, tmpbuf);
+			int_val = _atoi(tmpbuf, 16);
+
+			wapipsk=(wapiMibPSK *)((unsigned char *)(priv->pmib)+entry->offset);
+
+			/*Hex or passthru*/
+			if (password_len == 2*int_val)
+			{
+				/*Hex mode*/
+				if (int_val > WAPI_PSK_LEN)
+					int_val = WAPI_PSK_LEN;
+				rtl_string_to_hex(tmppasswd,wapipsk->octet, 2*int_val);
+			}
+			else
+			{
+				memcpy(wapipsk->octet, tmppasswd, 
+					(password_len> WAPI_PSK_LEN)? WAPI_PSK_LEN:password_len);
+			}
+			wapipsk->len = int_val;
+			break;
+	      }
+#endif
+
+#ifdef SUPPORT_MULTI_PROFILE
+	case AP_PROFILE_T:
+		add_ap_profile(priv, arg_val);
+		break;
+#endif
+
+#if defined(SWITCH_CHAN) && defined(UNIVERSAL_REPEATER)
+	case SWITCH_CHAN_T:
+		switch_chan(priv, arg_val);
+		break;
+#endif
+
+#ifdef USE_OUT_SRC
+	case ODM_DM_1UT:
+			byte_val = _atoi(arg_val, 16);
+			memcpy(((unsigned char *)&priv->pshare->_dmODM)+entry->offset, (unsigned char *)&byte_val, entry->len);
+			ODEBUG("set odm,val=0x%x\n",byte_val);			
+			break;		
+	case ODM_DM_2UT:
+			short_val = _atoi(arg_val, 16);
+			memcpy(((unsigned char *)&priv->pshare->_dmODM)+entry->offset, (unsigned char *)&short_val, entry->len);
+			ODEBUG("set odm,val=0x%02x\n",short_val);
+			break;		
+	case ODM_DM_4UT:
+			int_val = _atoi(arg_val, 16);
+			memcpy(((unsigned char *)&priv->pshare->_dmODM)+entry->offset, (unsigned char *)&int_val, entry->len);
+			ODEBUG("set odm,val=0x%04x\n",int_val);
+			break;		
+	case ODM_DM_8UT:
+			longlong_val = _atoi_u8(arg_val, 16);
+			memcpy(((unsigned char *)&priv->pshare->_dmODM)+entry->offset, (unsigned char *)&longlong_val, entry->len);
+			ODEBUG("set odm, val=0x%llx\n",longlong_val);
+			break;		
+#endif
+	default:
+		DEBUG_ERR("invalid mib type!\n");
+		break;
+	}
+
+	return 0;
+}
+#ifndef INCLUDE_WPS
+static
+#endif
+int get_mib(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+	struct iwpriv_arg *entry;
+	int i, len, *int_ptr, copy_len;
+	char tmpbuf[40];
+
+	DEBUG_TRACE;
+
+	DEBUG_INFO("get_mib %s\n", data);
+
+	entry = get_tbl_entry((char *)data);
+	if (entry == NULL) {
+		DEBUG_ERR("invalid mib name [%s] !\n", data);
+		return -1;
+	}
+	copy_len = entry->len;
+
+	switch (entry->type) {
+	case BYTE_T:
+		memcpy(data, ((unsigned char *)priv->pmib)+entry->offset,  1);
+		PRINT_INFO("byte data: %d\n", *data);
+		break;
+#ifdef CONFIG_RTK_MESH
+	case WORD_T:
+		memcpy(data, ((unsigned char *)priv->pmib)+entry->offset,  2);
+		PRINT_INFO("word data: %d\n", *data);
+		break;
+#endif
+	case INT_T:
+		memcpy(data, ((unsigned char *)priv->pmib)+entry->offset, sizeof(int));
+		PRINT_INFO("int data: %d\n", *((int *)data));
+		break;
+
+	case SSID_STRING_T:
+		memcpy(tmpbuf, priv->pmib->dot11StationConfigEntry.dot11DesiredSSID, priv->pmib->dot11StationConfigEntry.dot11DesiredSSIDLen);
+		tmpbuf[priv->pmib->dot11StationConfigEntry.dot11DesiredSSIDLen] = '\0';
+		strcpy((char *)data, tmpbuf);
+		PRINT_INFO("ssid: %s\n", tmpbuf);
+		break;
+
+	case BYTE_ARRAY_T:
+		memcpy(data, ((unsigned char *)priv->pmib)+entry->offset, entry->len);
+		PRINT_INFO("data (hex): ");
+		for (i=0; i<entry->len; i++)
+			PRINT_INFO("%02x", *((unsigned char *)((unsigned char *)priv->pmib)+entry->offset+i));
+		PRINT_INFO("\n");
+		break;
+
+	case ACL_T:
+		int_ptr = (int *)(((unsigned char *)priv->pmib)+entry->offset+entry->len);
+		PRINT_INFO("ACL table (%d):\n", *int_ptr);
+		copy_len = 0;
+		for (i=0; i<*int_ptr; i++) {
+			memcpy(data, ((unsigned char *)priv->pmib)+entry->offset+i*6, 6);
+			PRINT_INFO("mac-addr: %02x-%02x-%02x-%02x-%02x-%02x\n",
+				data[0],data[1],data[2],data[3],data[4],data[5]);
+			data += 6;
+			copy_len += 6;
+		}
+		DEBUG_INFO("\n");
+		break;
+
+	case IDX_BYTE_ARRAY_T:
+		memcpy(data, ((unsigned char *)priv->pmib)+entry->offset, entry->len);
+		PRINT_INFO("data (dec): ");
+		for (i=0; i<entry->len; i++)
+			PRINT_INFO("%d ", *((unsigned char *)((unsigned char *)priv->pmib)+entry->offset+i));
+		PRINT_INFO("\n");
+		break;
+
+	case MULTI_BYTE_T:
+		memcpy(&len, ((unsigned char *)priv->pmib)+entry->offset+entry->len, sizeof(int));
+		memcpy(data, ((unsigned char *)priv->pmib)+entry->offset, len);
+		PRINT_INFO("data (hex): ");
+		for (i=0; i<len; i++)
+			PRINT_INFO("%02x ", *((unsigned char *)((unsigned char *)priv->pmib)+entry->offset+i));
+		PRINT_INFO("\n");
+		break;
+
+#ifdef _DEBUG_RTL8192CD_
+	case DEBUG_T:
+		if (entry->offset==1)
+			memcpy(data, (unsigned char *)&rtl8192cd_debug_err, sizeof(rtl8192cd_debug_err));
+		else if (entry->offset==2)
+			memcpy(data, (unsigned char *)&rtl8192cd_debug_info, sizeof(rtl8192cd_debug_info));
+		else if (entry->offset==3)
+			memcpy(data, (unsigned char *)&rtl8192cd_debug_trace, sizeof(rtl8192cd_debug_trace));
+		else if (entry->offset==4)
+			memcpy(data, (unsigned char *)&rtl8192cd_debug_warn, sizeof(rtl8192cd_debug_warn));
+		else if (entry->offset==5)
+			memcpy(data, (unsigned char *)&rtl8192cd_debug_psk, sizeof(rtl8192cd_debug_psk));
+		else if (entry->offset==6)
+			memcpy(data, (unsigned char *)&rtl8192cd_debug_memlog, sizeof(rtl8192cd_debug_memlog));
+		else {
+			DEBUG_ERR("invalid debug index\n");
+		}
+		PRINT_INFO("debug flag(hex): %08lx\n", *((unsigned long *)data));
+		break;
+#endif // _DEBUG_RTL8192CD_
+
+	case DEF_SSID_STRING_T:
+		memcpy(tmpbuf, priv->pmib->dot11StationConfigEntry.dot11DefaultSSID, priv->pmib->dot11StationConfigEntry.dot11DefaultSSIDLen);
+		tmpbuf[priv->pmib->dot11StationConfigEntry.dot11DefaultSSIDLen] = '\0';
+		strcpy((char *)data, tmpbuf);
+		PRINT_INFO("defssid: %s\n", tmpbuf);
+		break;
+
+	case STRING_T:
+		strcpy((char *)data, (char *)(((unsigned char *)priv->pmib)+entry->offset));
+		PRINT_INFO("string data: %s\n", data);
+		break;
+
+	case RFFT_T:
+		memcpy(data, ((unsigned char *)&priv->pshare->rf_ft_var)+entry->offset, sizeof(int));
+		PRINT_INFO("int data: %d\n", *((int *)data));
+		break;
+	case RFFT_ACL_T:
+		int_ptr = (int *)(((unsigned char *)&priv->pshare->rf_ft_var)+entry->offset+entry->len);
+		copy_len = 0;
+		for (i=0; i<*int_ptr; i++) 
+		{
+			memcpy(data, ((unsigned char *)&priv->pshare->rf_ft_var)+entry->offset+i*6, 6);
+			PRINT_INFO("mac-addr: %02x-%02x-%02x-%02x-%02x-%02x\n",
+				data[0],data[1],data[2],data[3],data[4],data[5]);
+			data += 6;
+			copy_len += 6;
+		}
+		DEBUG_INFO("\n");
+		break;
+
+	case VARLEN_BYTE_T:
+		copy_len = *(unsigned int *)(((unsigned char *)priv->pmib)+entry->offset+entry->len);
+		memcpy(data, ((unsigned char *)priv->pmib)+entry->offset, copy_len);
+		PRINT_INFO("data (hex): ");
+		for (i=0; i<copy_len; i++)
+			PRINT_INFO("%02x", *((unsigned char *)((unsigned char *)priv->pmib)+entry->offset+i));
+		PRINT_INFO("\n");
+		break;
+
+#ifdef USE_OUT_SRC
+	case ODM_DM_1UT:
+		memcpy(data, ((unsigned char *)&priv->pshare->_dmODM)+entry->offset, sizeof(unsigned char));
+		ODEBUG("odm byte val=0x:%x\n", *((unsigned char *)data));
+		break;		
+	case ODM_DM_2UT:
+		memcpy(data, ((unsigned char *)&priv->pshare->_dmODM)+entry->offset, sizeof(unsigned short));
+		ODEBUG("odm short val=0x:%02x\n", *((unsigned short *)data));
+		break;		
+	case ODM_DM_4UT:
+		memcpy(data, ((unsigned char *)&priv->pshare->_dmODM)+entry->offset, sizeof(unsigned int));
+		ODEBUG("odm long val=0x:%04x\n", *((int *)data));
+		break;		
+	case ODM_DM_8UT:
+		memcpy(data, ((unsigned char *)&priv->pshare->_dmODM)+entry->offset, sizeof(unsigned long long));
+		ODEBUG("odm long long val=0x:%llx\n", *((unsigned long long *)data));
+		break;		
+#endif
+	default:
+		DEBUG_ERR("invalid mib type!\n");
+		return 0;
+	}
+
+	return copy_len;
+}
+
+
+#ifdef _IOCTL_DEBUG_CMD_
+/*
+ * Write register, command: "iwpriv wlanX write_reg,type,offset,value"
+ * 	where: type may be: "b" - byte, "w" - word, "dw" - "dw" (based on wlan register offset)
+ *			    "_b" - byte, "_w" - word, "_dw" - "dw" (based on register offset 0)
+ *		offset and value should be input in hex
+ */
+static int write_reg(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+	volatile char name[100];
+	int i=0, op=0, offset;
+	unsigned long ioaddr;
+	unsigned int val;
+#ifdef CONFIG_SDIO_HCI
+	int type = 0;
+#endif
+
+	DEBUG_TRACE;
+
+	// get access type
+	while (*data && *data != ',' && i < sizeof(name)-1)
+		name[i++] = *data++;
+	name[i] = '\0';
+
+#ifdef CONFIG_SDIO_HCI
+	if (!strcmp((char *)name, "sdio")) {
+		data++;
+		i = 0;
+		while (*data && *data != ',' && i < sizeof(name)-1)
+			name[i++] = *data++;
+		name[i] = '\0';
+		type= 1;
+	}
+#endif
+
+	if (!strcmp((char *)name, "b"))
+		op = 1;
+	else if (!strcmp((char *)name, "w"))
+		op = 2;
+	else if (!strcmp((char *)name, "dw"))
+		op = 3;
+	else if (!strcmp((char *)name, "_b"))
+		op = 0x81;
+	else if (!strcmp((char *)name, "_w"))
+		op = 0x82;
+	else if (!strcmp((char *)name, "_dw"))
+		op = 0x83;
+
+	if (op == 0 || !*data++) {
+		DEBUG_ERR("invalid type!\n");
+		return -1;
+	}
+
+	if ( !(op&0x80))  // wlan register
+		ioaddr = priv->pshare->ioaddr;
+	else
+		ioaddr = 0;
+
+	// get offset and value
+	i=0;
+	while (*data && *data != ',' && i < sizeof(name)-1)
+		name[i++] = *data++;
+	name[i] = '\0';
+	if (!*data++) {
+		DEBUG_ERR("invalid offset!\n");
+		return -1;
+	}
+	offset = _atoi((char *)name, 16);
+	val = (unsigned int)_atoi((char *)data, 16);
+
+	DEBUG_INFO("write reg in %s: addr=%08x, val=0x%x\n",
+			(op == 1 ? "byte" : (op == 2 ? "word" : "dword")),
+			offset, val);
+
+	switch (op&0x7f) {
+	case 1:
+#ifdef CONFIG_SDIO_HCI
+		if (type) {
+			unsigned char b_val = (unsigned char)val;
+			sdio_local_write(priv, offset, 1, &b_val);
+		} else
+#endif
+		RTL_W8(offset, ((unsigned char)val));
+		break;
+	case 2:
+#ifdef CONFIG_SDIO_HCI
+		if (type) {
+			unsigned short w_val = (unsigned short)val;
+			w_val = cpu_to_le16(w_val);
+			sdio_local_write(priv, offset, 2, (u8*)&w_val);
+		} else
+#endif
+		RTL_W16(offset, ((unsigned short)val));
+		break;
+	case 3:
+#ifdef CONFIG_SDIO_HCI
+		if (type) {
+			val = cpu_to_le32(val);
+			sdio_local_write(priv, offset, 4, (u8*)&val);
+		} else
+#endif
+		RTL_W32(offset, ((unsigned int)val));
+		break;
+	}
+	return 0;
+}
+
+
+/*
+ * Read register, command: "iwpriv wlanX read_reg,type,offset"
+ * 	where: type may be: "b" - byte, "w" - word, "dw" - "dw" (based on wlan register offset)
+ *			    "_b" - byte, "_w" - word, "_dw" - "dw" (based on register offset 0)
+ *		offset should be input in hex
+ */
+static int read_reg(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+	volatile char name[100];
+	int i=0, op=0, offset, len=0;
+	unsigned long ioaddr;
+	unsigned int dw_val;
+	unsigned char *org_ptr=data, b_val;
+	unsigned short w_val;
+#ifdef CONFIG_SDIO_HCI
+	int type = 0;
+#endif
+
+	DEBUG_TRACE;
+
+	// get access type
+	while (*data && *data != ',' && i < sizeof(name)-1)
+		name[i++] = *data++;
+	name[i] = '\0';
+
+#ifdef CONFIG_SDIO_HCI
+	if (!strcmp((char *)name, "sdio")) {
+		data++;
+		i = 0;
+		while (*data && *data != ',' && i < sizeof(name)-1)
+			name[i++] = *data++;
+		name[i] = '\0';
+		type= 1;
+	}
+#endif
+
+	if (!strcmp((char *)name, "b"))
+		op = 1;
+	else if (!strcmp((char *)name, "w"))
+		op = 2;
+	else if (!strcmp((char *)name, "dw"))
+		op = 3;
+	else if (!strcmp((char *)name, "_b"))
+		op = 0x81;
+	else if (!strcmp((char *)name, "_w"))
+		op = 0x82;
+	else if (!strcmp((char *)name, "_dw"))
+		op = 0x83;
+
+	if (op == 0 || !*data++) {
+		DEBUG_ERR("invalid type!\n");
+		return -1;
+	}
+
+	if ( !(op&0x80))  // wlan register
+		ioaddr = priv->pshare->ioaddr;
+	else
+		ioaddr = 0;
+
+	// get offset
+	offset = _atoi((char *)data, 16);
+
+	switch (op&0x7f) {
+	case 1:
+#ifdef CONFIG_SDIO_HCI
+		if (type) {
+			sdio_local_read(priv, offset, 1, &b_val);
+		}
+		else
+#endif
+		{
+			b_val = (unsigned char)RTL_R8(offset);
+		}
+		panic_printk("\nread byte reg %x=0x%02x\n", offset, b_val);
+		len = 1;
+		memcpy(org_ptr, &b_val, len);
+		break;
+	case 2:
+#ifdef CONFIG_SDIO_HCI
+		if (type) {
+			sdio_local_read(priv, offset, 2, (u8 *)&w_val);
+			w_val = le16_to_cpu(w_val);
+		}
+		else
+#endif
+		{
+			w_val = (unsigned short)RTL_R16(offset);
+		}
+		panic_printk("\nread word reg %x=0x%04x\n", offset, w_val);
+		len = 2;
+#ifdef _LITTLE_ENDIAN_
+		// To fit PSD tool endian requirement
+		 w_val = ___constant_swab16(w_val);
+#endif
+		memcpy(org_ptr, (char *)&w_val, len);
+		break;
+	case 3:
+#ifdef CONFIG_SDIO_HCI
+		if (type) {
+			sdio_local_read(priv, offset, 4, (u8 *)&dw_val);
+			dw_val = le32_to_cpu(dw_val);
+		}
+		else
+#endif
+		{
+			dw_val = (unsigned int)RTL_R32(offset);
+		}
+		panic_printk("\nread dword reg %x=0x%08x\n", offset, dw_val);
+		len = 4;
+#ifdef _LITTLE_ENDIAN_
+		// To fit PSD tool endian requirement
+		dw_val = ___constant_swab32(dw_val);
+#endif
+		memcpy(org_ptr, (char *)&dw_val, len);
+		break;
+	}
+
+	return len;
+}
+
+
+/*
+ * Write memory, command: "iwpriv wlanX write_mem,type,start,len,value"
+ * 	where: type may be: "b" - byte, "w" - word, "dw" - "dw"
+ *		start, len and value should be input in hex
+ */
+static int write_mem(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+	volatile char tmpbuf[100];
+	int i=0, size=0, len;
+	unsigned int val;
+	unsigned long start;
+
+	DEBUG_TRACE;
+
+	// get access type
+	while (*data && *data != ',' && i < sizeof(tmpbuf)-1)
+		tmpbuf[i++] = *data++;
+	tmpbuf[i] = '\0';
+
+	if (!strcmp((char *)tmpbuf, "b"))
+		size = 1;
+	else if (!strcmp((char *)tmpbuf, "w"))
+		size = 2;
+	else if (!strcmp((char *)tmpbuf, "dw"))
+		size = 4;
+
+	if (size == 0 || !*data++) {
+		DEBUG_ERR("invalid command!\n");
+		return -1;
+	}
+
+	// get start, len, and value
+	i=0;
+	while (*data && *data != ',' && i < sizeof(tmpbuf)-1)
+		tmpbuf[i++] = *data++;
+	tmpbuf[i] = '\0';
+	if (i==0 || !*data++) {
+		DEBUG_ERR("invalid start!\n");
+		return -1;
+	}
+	start = (unsigned long)_atoi((char *)tmpbuf, 16);
+
+	i=0;
+	while (*data && *data != ',' && i < sizeof(tmpbuf)-1)
+		tmpbuf[i++] = *data++;
+	tmpbuf[i] = '\0';
+	if (i==0 || !*data++) {
+		DEBUG_ERR("invalid len!\n");
+		return -1;
+	}
+	len = _atoi((char *)tmpbuf, 16);
+	val = (unsigned int)_atoi((char *)data, 16);
+
+	DEBUG_INFO("write memory: start=%08lx, len=%x, data=0x%x (%s)\n",
+		start,	len, val,
+		(size == 1 ? "byte" : (size == 2 ? "word" : "dword")));
+
+	for (i=0; i<len; i++) {
+		memcpy((char *)start, (char *)&val, size);
+		start += size;
+	}
+	return 0;
+}
+
+
+/*
+ * Read memory, command: "iwpriv wlanX read_mem,type,start,len"
+ * 	where: type may be: "b" - byte, "w" - word, "dw" - "dw"
+ *		start, and len should be input in hex
+ */
+static int read_mem(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+	volatile char tmpbuf[100];
+//#ifndef CONFIG_RTL8186_TR	 //brad add for tr 11n
+#if !(defined(CONFIG_RTL865X_AC) || defined(CONFIG_RTL865X_KLD) || defined(CONFIG_RTL8196B_KLD) || defined(CONFIG_RTL865X_SC) || defined(CONFIG_RTL8196C_KLD))
+//#if !defined(__LINUX_2_6__) || defined(CONFIG_PANIC_PRINTK)
+//#ifdef _DEBUG_RTL8192CD_
+	char *tmp1;
+	unsigned int tmp1_size = 0;
+//#endif
+#endif// !define CONFIG_RTL8186_TR
+	int i=0, size=0, len, copy_len;
+	unsigned long start;
+	unsigned int dw_val;
+	unsigned short w_val;
+	unsigned char b_val, *pVal=NULL, *org_ptr=data;
+
+	DEBUG_TRACE;
+
+	tmp1 = (char *)kmalloc(2048, GFP_ATOMIC);
+	if (tmp1 == NULL) {
+		panic_printk("Not enough memory\n");
+		return -1;
+	}
+	tmp1_size = 2048;
+
+	// get access type
+	while (*data && *data != ',' && i < sizeof(tmpbuf)-1)
+		tmpbuf[i++] = *data++;
+	tmpbuf[i] = '\0';
+
+	if (!strcmp((char *)tmpbuf, "b")) {
+		size = 1;
+		pVal = &b_val;
+	}
+	else if (!strcmp((char *)tmpbuf, "w")) {
+		size = 2;
+		pVal = (unsigned char *)&w_val;
+	}
+	else if (!strcmp((char *)tmpbuf, "dw")) {
+		size = 4;
+		pVal = (unsigned char *)&dw_val;
+	}
+
+	if (size == 0 || !*data++) {
+		DEBUG_ERR("invalid type!\n");
+		kfree(tmp1);
+		return -1;
+	}
+
+	// get start and len
+	i=0;
+	while (*data && *data != ',' && i < sizeof(tmpbuf)-1)
+		tmpbuf[i++] = *data++;
+	tmpbuf[i] = '\0';
+	if (i==0 || !*data++) {
+		DEBUG_ERR("invalid start!\n");
+		kfree(tmp1);
+		return -1;
+	}
+	start = (unsigned long)_atoi((char *)tmpbuf, 16);
+	len = _atoi((char *)data, 16);
+#if !(defined(CONFIG_RTL865X_AC) || defined(CONFIG_RTL865X_KLD) || defined(CONFIG_RTL8196B_KLD) || defined(CONFIG_RTL865X_SC) || defined(CONFIG_RTL8196C_KLD))
+//#if !defined(__LINUX_2_6__) || defined(CONFIG_PANIC_PRINTK)
+//#ifdef _DEBUG_RTL8192CD_
+	snprintf(tmp1, tmp1_size, "read memory: from=%lx, len=0x%x (%s)\n",
+		start, len, (size == 1 ? "byte" : (size == 2 ? "word" : "dword")));
+
+	for (i=0; i<len; i++) {
+		char tmp2[10];
+		memcpy(pVal, (char *)start+i*size, size);
+		if (size == 1) {
+			snprintf(tmp2, sizeof(tmp2), "%02x ", b_val);
+			if ((i>0) && ((i%16)==0))
+				strncat(tmp1, "\n", tmp1_size-strlen(tmp1)-1);
+		}
+		else if (size == 2) {
+			snprintf(tmp2, sizeof(tmp2), "%04x ", w_val);
+			if ((i>0) && ((i%8)==0))
+				strncat(tmp1, "\n", tmp1_size-strlen(tmp1)-1);
+		}
+		else if (size == 4) {
+			snprintf(tmp2, sizeof(tmp2), "%08x ", dw_val);
+			if ((i>0) && ((i%8)==0))
+				strncat(tmp1, "\n", tmp1_size-strlen(tmp1)-1);
+		}
+		strncat(tmp1, tmp2, tmp1_size-strlen(tmp1)-1);
+	}
+	strncat(tmp1, "\n", tmp1_size-strlen(tmp1)-1);
+
+	panic_printk("\n%s", tmp1);
+//#endif // _DEBUG_RTL8192CD_
+#endif // !define CONFIG_RTL8186_TR
+	if (size*len > 128)
+		copy_len = 128;
+	else
+		copy_len = size*len;
+	memcpy(org_ptr,  (char *)start, copy_len);
+
+	kfree(tmp1);
+	return copy_len;
+}
+
+
+static int write_bb_reg(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+	return 0;
+}
+
+
+static int read_bb_reg(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+	return 0;
+}
+
+
+static int write_rf_reg(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+	volatile char tmpbuf[32];
+	unsigned int path, offset, val, val_read;
+	int i;
+
+	DEBUG_TRACE;
+
+	if (strlen((char *)data) != 0) {
+		i = 0;
+		while (*data && *data != ',' && i < sizeof(tmpbuf)-1)
+			tmpbuf[i++] = *data++;
+		tmpbuf[i] = '\0';
+		if (i==0 || !*data++) {
+			DEBUG_ERR("invalid path!\n");
+			return -1;
+		}
+		path = _atoi((char *)tmpbuf, 16);
+
+		i = 0;
+		while (*data && *data != ',' && i < sizeof(tmpbuf)-1)
+			tmpbuf[i++] = *data++;
+		tmpbuf[i] = '\0';
+		if (i==0 || !*data++) {
+			DEBUG_ERR("invalid offset!\n");
+			return -1;
+		}
+		offset = _atoi((char *)tmpbuf, 16);
+
+		val = (unsigned int)_atoi((char *)data, 16);
+
+		PHY_SetRFReg(priv, path, offset, bMask20Bits, val);
+		val_read = PHY_QueryRFReg(priv, path, offset, bMask20Bits, 1);
+		printk("write RF %d offset 0x%02x val [0x%05x],  read back [0x%05x]\n",
+			path, offset, val&0xfffff, val_read&0xfffff);
+	}
+
+	return 0;
+}
+
+
+static int read_rf_reg(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+	volatile char tmpbuf[32];
+	unsigned char *arg = data;
+	unsigned int path, offset, val;
+	int i;
+
+	DEBUG_TRACE;
+
+	if (strlen((char *)arg) != 0) {
+		i = 0;
+		while (*arg && *arg != ',' && i < sizeof(tmpbuf)-1)
+			tmpbuf[i++] = *arg++;
+		tmpbuf[i] = '\0';
+		if (i==0 || !*arg++) {
+			DEBUG_ERR("invalid path!\n");
+			return -1;
+		}
+		path = _atoi((char *)tmpbuf, 16);
+
+		offset = (unsigned char)_atoi((char *)arg, 16);
+		val = PHY_QueryRFReg(priv, path, offset, bMask20Bits, 1);
+		panic_printk("\nread RF %d reg %02x=0x%08x\n", path, offset, val);
+#ifdef _LITTLE_ENDIAN_
+		// To fit PSD tool endian requirement
+		val = ___constant_swab32(val);
+#endif
+		memcpy(data, (char *)&val, 4);
+		return 4;
+	}
+	return 1;
+}
+
+
+#ifdef CONFIG_RTL8186_KB
+int get_guestmac(struct rtl8192cd_priv *priv, GUESTMAC_T *macdata)
+{
+	int i=0;
+
+	for (i=0; i<MAX_GUEST_NUM; i++)
+	{
+		if (priv->guestMac[i].valid)
+		{
+			memcpy(macdata->macaddr, priv->guestMac[i].macaddr, 6);
+			macdata->valid = priv->guestMac[i].valid;
+		}
+		else
+			break;
+		macdata++;
+	}
+	return sizeof(GUESTMAC_T)*i;
+}
+
+
+int set_guestmacvalid(struct rtl8192cd_priv *priv, char *buf)
+{
+	int i=0;
+
+	for (i=0; i<MAX_GUEST_NUM; i++)
+	{
+		if (priv->guestMac[i].valid)
+		{
+			continue;
+		}
+		memcpy(priv->guestMac[i].macaddr, buf, 6);
+		priv->guestMac[i].valid = 1;
+		return 0;
+	}
+	/*No slot avaible*/
+	return -1;
+}
+
+
+int set_guestmacinvalid(struct rtl8192cd_priv *priv, char *buf)
+{
+	int i=0;
+
+	for (i=0; i<MAX_GUEST_NUM; i++)
+	{
+		if (priv->guestMac[i].valid && !memcmp(priv->guestMac[i].macaddr, buf, 6))
+		{
+			priv->guestMac[i].valid = 0;
+			return 0;
+		}
+	}
+	/*No such slot*/
+	return -1;
+}
+#endif // CONFIG_RTL8186_KB
+
+#ifdef MULTI_MAC_CLONE
+int get_mclone_addr(struct rtl8192cd_priv *priv, char *buf, unsigned long buf_len)
+{
+	int idx=0;
+	unsigned char *mac;
+	unsigned char tmpbuf[10]={0};
+
+	get_arg(buf, tmpbuf);
+	idx = _atoi(tmpbuf, 10);
+	if (idx > MAX_MAC_CLONE_NUM || idx < 0)
+		return -1;
+
+	mac = (unsigned char *)&priv->pshare->mclone_sta_fixed_addr[idx];
+	snprintf(buf, buf_len, "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+
+	return (strlen(buf)+1);
+}
+
+int set_mclone_addr(struct rtl8192cd_priv *priv, char *buf)
+{
+	int idx=0, i;
+	char *mac;
+	unsigned char tmpbuf[10]={0};
+	unsigned long *mac4;
+
+	mac = get_arg(buf, tmpbuf);
+	idx = _atoi(tmpbuf, 10);
+	if (idx >= MAX_MAC_CLONE_NUM || idx < 0)
+		return -1;
+
+	if (idx==0) {
+		get_array_val(tmpbuf, mac, 12);
+		for (i=0; i<MAX_MAC_CLONE_NUM; i++) {
+			memcpy((priv->pshare->mclone_sta_fixed_addr[i].clone_addr), tmpbuf, 6);
+			mac4 = (unsigned long *)&priv->pshare->mclone_sta_fixed_addr[i].clone_addr[2];
+			#ifdef __ECOS
+			*mac4 = (*mac4)+i;    //temporary modified for ecos compile error. 
+			#else
+			*mac4 = be32_to_cpu(cpu_to_be32(*mac4)+i);
+			#endif
+		}
+	}
+	else {
+		get_array_val((priv->pshare->mclone_sta_fixed_addr[idx].clone_addr), mac, 12);
+	}
+
+	return 0;
+}
+
+int __del_mclone_addr(struct rtl8192cd_priv *priv, unsigned char *tmpAddr)
+{
+#ifndef SMP_SYNC
+	unsigned long flags;
+#endif
+	int idx=-1;
+	int tmpActive = ACTIVE_ID;
+	struct stat_info *pstat=NULL;
+	struct rtl8192cd_priv *tmpPriv;
+
+	idx = mclone_find_address(priv, tmpAddr, NULL, MAC_CLONE_SA_FIND);
+	ACTIVE_ID = idx;
+	
+	if (idx > 0){
+		tmpPriv = priv->pshare->mclone_sta[idx-1].priv;
+
+		SAVE_INT_AND_CLI(flags);
+		pstat = get_stainfo(tmpPriv, (GET_MIB(tmpPriv))->dot11StationConfigEntry.dot11Bssid);
+		if (pstat) {
+			printk("Remove mclone[%d]: %02x%02x%02x%02x%02x%02x\n", idx-1, tmpAddr[0], tmpAddr[1], tmpAddr[2], tmpAddr[3], tmpAddr[4], tmpAddr[5]);
+			if (tmpPriv->pshare->mclone_sta[idx-1].opmode & WIFI_ASOC_STATE)
+				issue_deauth(tmpPriv, (GET_MIB(tmpPriv))->dot11StationConfigEntry.dot11Bssid, _RSON_DEAUTH_STA_LEAVING_);
+
+#ifdef  CONFIG_WLAN_HAL
+			if (IS_HAL_CHIP(tmpPriv))
+				GET_HAL_INTERFACE(tmpPriv)->McloneStopMBSSIDHandler(tmpPriv, (idx-1));
+			else if (CONFIG_WLAN_NOT_HAL_EXIST)
+#endif
+				mclone_stop_mbssid(tmpPriv, (idx-1));//mclone_stop_mbssid need to modify
+			clear_Multi_Mac_Clone(tmpPriv, idx-1);
+
+			if (pstat->expire_to > 0)
+			{
+				cnt_assoc_num(tmpPriv, pstat, DECREASE, (char *)__FUNCTION__);
+				check_sta_characteristic(tmpPriv, pstat, DECREASE);
+			}
+			free_stainfo(tmpPriv, pstat);
+		}
+		
+		RESTORE_INT(flags);
+	}
+	else if (idx == 0) {
+		SAVE_INT_AND_CLI(flags);
+		pstat = get_stainfo(priv, (GET_MIB(priv))->dot11StationConfigEntry.dot11Bssid);
+		if (pstat) {
+			if (pstat->expire_to > 0)
+			{
+				cnt_assoc_num(priv, pstat, DECREASE, (char *)__FUNCTION__);
+				check_sta_characteristic(priv, pstat, DECREASE);
+			}
+			free_stainfo(priv, pstat);
+		}
+		RESTORE_INT(flags);
+	}
+	else {
+		//printk("Could not find the MAC %02x%02x%02x%02x%02x%02x\n", tmpAddr[0], tmpAddr[1], tmpAddr[2], tmpAddr[3], tmpAddr[4], tmpAddr[5]);
+	}
+	
+	ACTIVE_ID = tmpActive;
+	return idx;
+}
+
+int del_mclone_addr(struct rtl8192cd_priv *priv, char *buf)
+{
+	unsigned char tmpAddr[6];
+	
+	printk("buf:%s\n", (buf ? buf : "none"));
+	
+	get_array_val(tmpAddr, buf, 12);
+	
+	__del_mclone_addr(priv, tmpAddr);
+	
+	return 0;
+}
+#endif // MULTI_MAC_CLONE
+
+#ifdef _DEBUG_RTL8192CD_
+
+//_TXPWR_REDEFINE
+
+#define POWER_MIN_CHECK(a,b)            (((a) > (b)) ? (b) : (a))
+#ifndef POWER_RANGE_CHECK
+#define POWER_RANGE_CHECK(val)		(((val) > 0x3f)? 0x3f : ((val < 0) ? 0 : val))
+#endif
+#define COUNT_SIGN_OFFSET(val, oft)	(((oft & 0x08) == 0x08)? (val - (0x10 - oft)) : (val + oft))
+
+#define ASSIGN_TX_POWER_OFFSET(offset, setting) { \
+	if (setting != 0x7f) \
+		offset = setting; \
+}
+
+/*
+//also defined in 8192cd_hw.c
+static int ch2idx(int ch)
+{
+	int val=-1;
+	// |1~14|36, 38, 40, ..., 64|100, 102, ..., 140|149, 151, ..., 165|
+	if (ch<=14)
+		val = ch-1;
+	else if (ch<=64)
+		val = ((ch-36)>>1)+14;
+	else if (ch<=140)
+		val = ((ch-100)>>1)+29;
+	else if (ch<=165)
+		val = ((ch-149)>>1)+50;
+
+	return val;
+}
+*/
+
+
+#ifdef ADD_TX_POWER_BY_CMD
+static void check_txpwr_by_cmd(struct rtl8192cd_priv *priv, 
+	char *MCSTxAgcOffset_A, char *MCSTxAgcOffset_B,
+	char *OFDMTxAgcOffset_A, char *OFDMTxAgcOffset_B,
+	char *CCKTxAgc_A, char *CCKTxAgc_B)
+{
+//	char is_by_cmd = 0;	
+
+	if( (priv->pshare->rf_ft_var.txPowerPlus_cck_11 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_cck_5 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_cck_2 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_cck_1 != 0x7f))
+	{		
+		ASSIGN_TX_POWER_OFFSET(CCKTxAgc_A[0], priv->pshare->rf_ft_var.txPowerPlus_cck_11);
+		ASSIGN_TX_POWER_OFFSET(CCKTxAgc_A[1], priv->pshare->rf_ft_var.txPowerPlus_cck_5);
+		ASSIGN_TX_POWER_OFFSET(CCKTxAgc_A[2], priv->pshare->rf_ft_var.txPowerPlus_cck_2);
+		ASSIGN_TX_POWER_OFFSET(CCKTxAgc_A[3], priv->pshare->rf_ft_var.txPowerPlus_cck_1);
+		ASSIGN_TX_POWER_OFFSET(CCKTxAgc_B[0], priv->pshare->rf_ft_var.txPowerPlus_cck_11);
+		ASSIGN_TX_POWER_OFFSET(CCKTxAgc_B[1], priv->pshare->rf_ft_var.txPowerPlus_cck_5);
+		ASSIGN_TX_POWER_OFFSET(CCKTxAgc_B[2], priv->pshare->rf_ft_var.txPowerPlus_cck_2);
+		ASSIGN_TX_POWER_OFFSET(CCKTxAgc_B[3], priv->pshare->rf_ft_var.txPowerPlus_cck_1);
+
+		printk("TXPWR_BY_CMD: CCK = %02x %02x %02x %02x \n", 
+			priv->pshare->rf_ft_var.txPowerPlus_cck_11,
+			priv->pshare->rf_ft_var.txPowerPlus_cck_5,
+			priv->pshare->rf_ft_var.txPowerPlus_cck_2,
+			priv->pshare->rf_ft_var.txPowerPlus_cck_1);
+	}
+
+
+	if( (priv->pshare->rf_ft_var.txPowerPlus_ofdm_18 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_ofdm_12!= 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_ofdm_9 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_ofdm_6 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_ofdm_54 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_ofdm_48 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_ofdm_36 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_ofdm_24 != 0x7f))
+	{
+		ASSIGN_TX_POWER_OFFSET(OFDMTxAgcOffset_A[0], priv->pshare->rf_ft_var.txPowerPlus_ofdm_18);
+		ASSIGN_TX_POWER_OFFSET(OFDMTxAgcOffset_A[1], priv->pshare->rf_ft_var.txPowerPlus_ofdm_12);
+		ASSIGN_TX_POWER_OFFSET(OFDMTxAgcOffset_A[2], priv->pshare->rf_ft_var.txPowerPlus_ofdm_9);
+		ASSIGN_TX_POWER_OFFSET(OFDMTxAgcOffset_A[3], priv->pshare->rf_ft_var.txPowerPlus_ofdm_6);
+		ASSIGN_TX_POWER_OFFSET(OFDMTxAgcOffset_B[0], priv->pshare->rf_ft_var.txPowerPlus_ofdm_18);
+		ASSIGN_TX_POWER_OFFSET(OFDMTxAgcOffset_B[1], priv->pshare->rf_ft_var.txPowerPlus_ofdm_12);
+		ASSIGN_TX_POWER_OFFSET(OFDMTxAgcOffset_B[2], priv->pshare->rf_ft_var.txPowerPlus_ofdm_9);
+		ASSIGN_TX_POWER_OFFSET(OFDMTxAgcOffset_B[3], priv->pshare->rf_ft_var.txPowerPlus_ofdm_6);
+
+		ASSIGN_TX_POWER_OFFSET(OFDMTxAgcOffset_A[4], priv->pshare->rf_ft_var.txPowerPlus_ofdm_54);
+		ASSIGN_TX_POWER_OFFSET(OFDMTxAgcOffset_A[5], priv->pshare->rf_ft_var.txPowerPlus_ofdm_48);
+		ASSIGN_TX_POWER_OFFSET(OFDMTxAgcOffset_A[6], priv->pshare->rf_ft_var.txPowerPlus_ofdm_36);
+		ASSIGN_TX_POWER_OFFSET(OFDMTxAgcOffset_A[7], priv->pshare->rf_ft_var.txPowerPlus_ofdm_24);
+		ASSIGN_TX_POWER_OFFSET(OFDMTxAgcOffset_B[4], priv->pshare->rf_ft_var.txPowerPlus_ofdm_54);
+		ASSIGN_TX_POWER_OFFSET(OFDMTxAgcOffset_B[5], priv->pshare->rf_ft_var.txPowerPlus_ofdm_48);
+		ASSIGN_TX_POWER_OFFSET(OFDMTxAgcOffset_B[6], priv->pshare->rf_ft_var.txPowerPlus_ofdm_36);
+		ASSIGN_TX_POWER_OFFSET(OFDMTxAgcOffset_B[7], priv->pshare->rf_ft_var.txPowerPlus_ofdm_24);
+
+		printk("TXPWR_BY_CMD: OFDM = %02x %02x %02x %02x %02x %02x %02x %02x \n", 
+			priv->pshare->rf_ft_var.txPowerPlus_ofdm_18,
+			priv->pshare->rf_ft_var.txPowerPlus_ofdm_12,
+			priv->pshare->rf_ft_var.txPowerPlus_ofdm_9,
+			priv->pshare->rf_ft_var.txPowerPlus_ofdm_6, 
+			priv->pshare->rf_ft_var.txPowerPlus_ofdm_54,
+			priv->pshare->rf_ft_var.txPowerPlus_ofdm_48,
+			priv->pshare->rf_ft_var.txPowerPlus_ofdm_36,
+			priv->pshare->rf_ft_var.txPowerPlus_ofdm_24);
+	}
+
+
+	if( (priv->pshare->rf_ft_var.txPowerPlus_mcs_3 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_mcs_2 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_mcs_1 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_mcs_0 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_mcs_7 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_mcs_6 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_mcs_5 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_mcs_4 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_mcs_11 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_mcs_10 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_mcs_9 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_mcs_8 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_mcs_15 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_mcs_14 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_mcs_13 != 0x7f)
+		|| (priv->pshare->rf_ft_var.txPowerPlus_mcs_12 != 0x7f))
+	{
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_A[0], priv->pshare->rf_ft_var.txPowerPlus_mcs_3);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_A[1], priv->pshare->rf_ft_var.txPowerPlus_mcs_2);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_A[2], priv->pshare->rf_ft_var.txPowerPlus_mcs_1);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_A[3], priv->pshare->rf_ft_var.txPowerPlus_mcs_0);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_B[0], priv->pshare->rf_ft_var.txPowerPlus_mcs_3);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_B[1], priv->pshare->rf_ft_var.txPowerPlus_mcs_2);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_B[2], priv->pshare->rf_ft_var.txPowerPlus_mcs_1);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_B[3], priv->pshare->rf_ft_var.txPowerPlus_mcs_0);
+
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_A[4], priv->pshare->rf_ft_var.txPowerPlus_mcs_7);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_A[5], priv->pshare->rf_ft_var.txPowerPlus_mcs_6);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_A[6], priv->pshare->rf_ft_var.txPowerPlus_mcs_5);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_A[7], priv->pshare->rf_ft_var.txPowerPlus_mcs_4);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_B[4], priv->pshare->rf_ft_var.txPowerPlus_mcs_7);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_B[5], priv->pshare->rf_ft_var.txPowerPlus_mcs_6);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_B[6], priv->pshare->rf_ft_var.txPowerPlus_mcs_5);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_B[7], priv->pshare->rf_ft_var.txPowerPlus_mcs_4);
+
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_A[8], priv->pshare->rf_ft_var.txPowerPlus_mcs_11);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_A[9], priv->pshare->rf_ft_var.txPowerPlus_mcs_10);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_A[10], priv->pshare->rf_ft_var.txPowerPlus_mcs_9);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_A[11], priv->pshare->rf_ft_var.txPowerPlus_mcs_8);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_B[8], priv->pshare->rf_ft_var.txPowerPlus_mcs_11);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_B[9], priv->pshare->rf_ft_var.txPowerPlus_mcs_10);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_B[10], priv->pshare->rf_ft_var.txPowerPlus_mcs_9);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_B[11], priv->pshare->rf_ft_var.txPowerPlus_mcs_8);
+
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_A[12], priv->pshare->rf_ft_var.txPowerPlus_mcs_15);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_A[13], priv->pshare->rf_ft_var.txPowerPlus_mcs_14);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_A[14], priv->pshare->rf_ft_var.txPowerPlus_mcs_13);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_A[15], priv->pshare->rf_ft_var.txPowerPlus_mcs_12);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_B[12], priv->pshare->rf_ft_var.txPowerPlus_mcs_15);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_B[13], priv->pshare->rf_ft_var.txPowerPlus_mcs_14);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_B[14], priv->pshare->rf_ft_var.txPowerPlus_mcs_13);
+		ASSIGN_TX_POWER_OFFSET(MCSTxAgcOffset_B[15], priv->pshare->rf_ft_var.txPowerPlus_mcs_12);
+
+		printk("TXPWR_BY_CMD: OFDM = %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x \n", 
+			priv->pshare->rf_ft_var.txPowerPlus_mcs_3,
+			priv->pshare->rf_ft_var.txPowerPlus_mcs_2,
+			priv->pshare->rf_ft_var.txPowerPlus_mcs_1,
+			priv->pshare->rf_ft_var.txPowerPlus_mcs_0, 
+			priv->pshare->rf_ft_var.txPowerPlus_mcs_7,
+			priv->pshare->rf_ft_var.txPowerPlus_mcs_6,
+			priv->pshare->rf_ft_var.txPowerPlus_mcs_5,
+			priv->pshare->rf_ft_var.txPowerPlus_mcs_4, 
+			priv->pshare->rf_ft_var.txPowerPlus_mcs_11,
+			priv->pshare->rf_ft_var.txPowerPlus_mcs_10,
+			priv->pshare->rf_ft_var.txPowerPlus_mcs_9,
+			priv->pshare->rf_ft_var.txPowerPlus_mcs_8, 
+			priv->pshare->rf_ft_var.txPowerPlus_mcs_15,
+			priv->pshare->rf_ft_var.txPowerPlus_mcs_14,
+			priv->pshare->rf_ft_var.txPowerPlus_mcs_13,
+			priv->pshare->rf_ft_var.txPowerPlus_mcs_12);
+	}
+	
+}
+#endif
+
+
+static void dump_cck(struct rtl8192cd_priv *priv, 
+	unsigned char pwrlevelCCK_A, unsigned char pwrlevelCCK_B, 
+	char *CCKTxAgc_A, char *CCKTxAgc_B
+	)
+{
+	char byte, byte1, byte2, byte3;
+
+	if (priv->pshare->rf_ft_var.cck_pwr_max) 
+	{
+		 printk("Use cck_pwr_max = %d\n", priv->pshare->rf_ft_var.cck_pwr_max);
+		 
+		 byte = POWER_RANGE_CHECK(priv->pshare->rf_ft_var.cck_pwr_max);	 
+		 printk("A_CCK1_Mcs32(0xe08): 0x----%02x--\n", byte);
+		 printk("B_CCK5_1_Mcs32(0x838): 0x%02x%02x%02x--\n", byte, byte, byte);
+		 printk("A_CCK11_2_B_CCK11(0x86c): 0x%02x%02x%02x%02x\n", byte, byte, byte, byte);
+		 
+		 return;
+	}
+
+	if (pwrlevelCCK_A == 0) {	// use default value
+#ifdef HIGH_POWER_EXT_PA
+		if (priv->pshare->rf_ft_var.use_ext_pa)
+			byte = HP_CCK_POWER_DEFAULT;
+		else
+#endif
+			byte = 0x24;
+
+		printk("Use default cck value = %d\n", byte);
+
+		pwrlevelCCK_A = pwrlevelCCK_B = byte;
+		byte = 0;
+		ASSIGN_TX_POWER_OFFSET(byte, priv->pshare->rf_ft_var.txPowerPlus_cck_1);
+		byte = POWER_RANGE_CHECK(pwrlevelCCK_A + byte);
+		printk("A_CCK1_Mcs32(0xe08): 0x----%02x--\n", byte);
+		
+		byte = byte1 = byte2 = 0;
+		ASSIGN_TX_POWER_OFFSET(byte, priv->pshare->rf_ft_var.txPowerPlus_cck_1);
+		ASSIGN_TX_POWER_OFFSET(byte1, priv->pshare->rf_ft_var.txPowerPlus_cck_2);
+		ASSIGN_TX_POWER_OFFSET(byte2, priv->pshare->rf_ft_var.txPowerPlus_cck_5);
+		byte  = POWER_RANGE_CHECK(pwrlevelCCK_B + byte);
+		byte1 = POWER_RANGE_CHECK(pwrlevelCCK_B + byte1);
+		byte2 = POWER_RANGE_CHECK(pwrlevelCCK_B + byte2);
+		printk("B_CCK5_1_Mcs32(0x838): 0x%02x%02x%02x--\n", byte2, byte1, byte);
+
+		byte = byte1 = byte2 = 0;
+		ASSIGN_TX_POWER_OFFSET(byte, priv->pshare->rf_ft_var.txPowerPlus_cck_2);
+		ASSIGN_TX_POWER_OFFSET(byte1, priv->pshare->rf_ft_var.txPowerPlus_cck_5);
+		ASSIGN_TX_POWER_OFFSET(byte2, priv->pshare->rf_ft_var.txPowerPlus_cck_11);
+		byte  = POWER_RANGE_CHECK(pwrlevelCCK_A + byte);
+		byte1 = POWER_RANGE_CHECK(pwrlevelCCK_A + byte1);
+		byte2 = POWER_RANGE_CHECK(pwrlevelCCK_A + byte2);
+		printk("A_CCK11_2_B_CCK11(0x86c): 0x%02x%02x%02x%02x\n", byte2, byte1, byte, byte2);
+		
+		return; // use default
+	}
+
+	byte = POWER_RANGE_CHECK(pwrlevelCCK_A + CCKTxAgc_A[3]);
+	printk("A_CCK1_Mcs32(0xe08): 0x----%02x--\n", byte);
+
+	byte = POWER_RANGE_CHECK(pwrlevelCCK_B + CCKTxAgc_B[1]); 
+	byte1 = POWER_RANGE_CHECK(pwrlevelCCK_B + CCKTxAgc_B[2]);
+	byte2 = POWER_RANGE_CHECK(pwrlevelCCK_B + CCKTxAgc_B[3]);
+	printk("B_CCK5_1_Mcs32(0x838): 0x%02x%02x%02x--\n", byte, byte1, byte2);
+	
+	byte = POWER_RANGE_CHECK(pwrlevelCCK_A + CCKTxAgc_A[0]);
+	byte1 = POWER_RANGE_CHECK(pwrlevelCCK_A + CCKTxAgc_A[1]);
+	byte2 = POWER_RANGE_CHECK(pwrlevelCCK_A + CCKTxAgc_A[2]);
+	byte3 = POWER_RANGE_CHECK(pwrlevelCCK_B + CCKTxAgc_B[0]);
+	printk("A_CCK11_2_B_CCK11(0x86c): 0x%02x%02x%02x%02x\n", byte, byte1, byte2, byte3);
+
+	return;
+
+}
+
+
+static void dump_ofdm_mcs0(struct rtl8192cd_priv *priv, int defValue, 
+	unsigned char pwrlevelHT40_1S_A, unsigned char pwrlevelHT40_1S_B, 
+	unsigned char pwrdiffHT40_2S, unsigned char pwrdiffHT20, unsigned char pwrdiffOFDM, 
+	unsigned char pwrlevelHT40_1S_A_6dB, unsigned char pwrlevelHT40_1S_B_6dB,
+	unsigned char pwrdiffHT40_2S_6dB, unsigned char pwrdiffHT20_6dB,
+	char *MCSTxAgcOffset_A, char *MCSTxAgcOffset_B, char *OFDMTxAgcOffset_A, char *OFDMTxAgcOffset_B,
+	int phyBandSelect
+	)
+{
+
+	s1Byte base, byte0, byte1, byte2, byte3;
+	unsigned char  offset;
+	
+#ifdef USB_POWER_SUPPORT
+	s1Byte base_6dBm;
+	unsigned char offset_6dBm;
+#endif
+	
+	if (pwrlevelHT40_1S_A == 0)
+	{
+		
+#ifdef HIGH_POWER_EXT_PA
+		if (priv->pshare->rf_ft_var.use_ext_pa)
+			defValue = HP_OFDM_POWER_DEFAULT ;
+#endif
+		printk("pwrlevelHT40_1S_A = 0, Use Default Value = %d\n", defValue);
+
+		base = defValue;
+		byte0 = byte1 = byte2 = byte3 = 0;
+		ASSIGN_TX_POWER_OFFSET(byte0, priv->pshare->rf_ft_var.txPowerPlus_ofdm_18);
+		ASSIGN_TX_POWER_OFFSET(byte1, priv->pshare->rf_ft_var.txPowerPlus_ofdm_12);
+		ASSIGN_TX_POWER_OFFSET(byte2, priv->pshare->rf_ft_var.txPowerPlus_ofdm_9);
+		ASSIGN_TX_POWER_OFFSET(byte3, priv->pshare->rf_ft_var.txPowerPlus_ofdm_6);
+
+		byte0 = POWER_RANGE_CHECK(base + byte0);
+		byte1 = POWER_RANGE_CHECK(base + byte1);
+		byte2 = POWER_RANGE_CHECK(base + byte2);
+		byte3 = POWER_RANGE_CHECK(base + byte3);
+		
+		printk("A_Rate18_06(0xe00): 0x%02x%02x%02x%02x\n", byte0, byte1, byte2, byte3);
+		printk("B_Rate18_06(0x830): 0x%02x%02x%02x%02x\n", byte0, byte1, byte2, byte3);	
+
+		byte0 = byte1 = byte2 = byte3 = 0;
+		ASSIGN_TX_POWER_OFFSET(byte0, priv->pshare->rf_ft_var.txPowerPlus_ofdm_54);
+		ASSIGN_TX_POWER_OFFSET(byte1, priv->pshare->rf_ft_var.txPowerPlus_ofdm_48);
+		ASSIGN_TX_POWER_OFFSET(byte2, priv->pshare->rf_ft_var.txPowerPlus_ofdm_36);
+		ASSIGN_TX_POWER_OFFSET(byte3, priv->pshare->rf_ft_var.txPowerPlus_ofdm_24);
+		byte0 = POWER_RANGE_CHECK(base + byte0);
+		byte1 = POWER_RANGE_CHECK(base + byte1);
+		byte2 = POWER_RANGE_CHECK(base + byte2);
+		byte3 = POWER_RANGE_CHECK(base + byte3);
+		printk("A_Rate54_24(0xe04): 0x%02x%02x%02x%02x\n", byte0, byte1, byte2, byte3); 
+		printk("B_Rate54_24(0x834): 0x%02x%02x%02x%02x\n", byte0, byte1, byte2, byte3);	 
+
+
+		byte0 = byte1 = byte2 = byte3 = 0;
+		ASSIGN_TX_POWER_OFFSET(byte0, priv->pshare->rf_ft_var.txPowerPlus_mcs_3);
+		ASSIGN_TX_POWER_OFFSET(byte1, priv->pshare->rf_ft_var.txPowerPlus_mcs_2);
+		ASSIGN_TX_POWER_OFFSET(byte2, priv->pshare->rf_ft_var.txPowerPlus_mcs_1);
+		ASSIGN_TX_POWER_OFFSET(byte3, priv->pshare->rf_ft_var.txPowerPlus_mcs_0);
+		byte0 = POWER_RANGE_CHECK(base + byte0);
+		byte1 = POWER_RANGE_CHECK(base + byte1);
+		byte2 = POWER_RANGE_CHECK(base + byte2);
+		byte3 = POWER_RANGE_CHECK(base + byte3);
+		printk("A_Mcs03_Mcs00(0xe10): 0x%02x%02x%02x%02x\n", byte0, byte1, byte2, byte3);
+		printk("B_Mcs03_Mcs00(0x83c): 0x%02x%02x%02x%02x\n", byte0, byte1, byte2, byte3);
+
+		byte0 = byte1 = byte2 = byte3 = 0;
+		ASSIGN_TX_POWER_OFFSET(byte0, priv->pshare->rf_ft_var.txPowerPlus_mcs_7);
+		ASSIGN_TX_POWER_OFFSET(byte1, priv->pshare->rf_ft_var.txPowerPlus_mcs_6);
+		ASSIGN_TX_POWER_OFFSET(byte2, priv->pshare->rf_ft_var.txPowerPlus_mcs_5);
+		ASSIGN_TX_POWER_OFFSET(byte3, priv->pshare->rf_ft_var.txPowerPlus_mcs_4);
+		byte0 = POWER_RANGE_CHECK(base + byte0);
+		byte1 = POWER_RANGE_CHECK(base + byte1);
+		byte2 = POWER_RANGE_CHECK(base + byte2);
+		byte3 = POWER_RANGE_CHECK(base + byte3);
+		printk("A_Mcs07_Mcs04(0xe14): 0x%02x%02x%02x%02x\n", byte0, byte1, byte2, byte3);
+		printk("B_Mcs07_Mcs04(0x848): 0x%02x%02x%02x%02x\n", byte0, byte1, byte2, byte3);
+
+
+//_TXPWR_REDEFINE
+#ifdef USB_POWER_SUPPORT
+		byte0 = byte1 = byte2 = byte3 = -USB_HT_2S_DIFF;
+#else
+		byte0 = byte1 = byte2 = byte3 = 0;
+		ASSIGN_TX_POWER_OFFSET(byte0, priv->pshare->rf_ft_var.txPowerPlus_mcs_11);
+		ASSIGN_TX_POWER_OFFSET(byte1, priv->pshare->rf_ft_var.txPowerPlus_mcs_10);
+		ASSIGN_TX_POWER_OFFSET(byte2, priv->pshare->rf_ft_var.txPowerPlus_mcs_9);
+		ASSIGN_TX_POWER_OFFSET(byte3, priv->pshare->rf_ft_var.txPowerPlus_mcs_8);
+#endif
+
+		byte0 = POWER_RANGE_CHECK(base + byte0);
+		byte1 = POWER_RANGE_CHECK(base + byte1);
+		byte2 = POWER_RANGE_CHECK(base + byte2);
+		byte3 = POWER_RANGE_CHECK(base + byte3);
+		printk("A_Mcs11_Mcs08(0xe18): 0x%02x%02x%02x%02x\n",byte0, byte1, byte2, byte3);
+		printk("B_Mcs11_Mcs08(0x84c): 0x%02x%02x%02x%02x\n",byte0, byte1, byte2, byte3);
+
+//_TXPWR_REDEFINE
+#ifdef USB_POWER_SUPPORT
+		byte0 = byte1 = byte2 = byte3 = -USB_HT_2S_DIFF;
+#else
+		byte0 = byte1 = byte2 = byte3 = 0;
+		ASSIGN_TX_POWER_OFFSET(byte0, priv->pshare->rf_ft_var.txPowerPlus_mcs_15);
+		ASSIGN_TX_POWER_OFFSET(byte1, priv->pshare->rf_ft_var.txPowerPlus_mcs_14);
+		ASSIGN_TX_POWER_OFFSET(byte2, priv->pshare->rf_ft_var.txPowerPlus_mcs_13);
+		ASSIGN_TX_POWER_OFFSET(byte3, priv->pshare->rf_ft_var.txPowerPlus_mcs_12);
+#endif
+
+		byte0 = POWER_RANGE_CHECK(base + byte0);
+		byte1 = POWER_RANGE_CHECK(base + byte1);
+		byte2 = POWER_RANGE_CHECK(base + byte2);
+		byte3 = POWER_RANGE_CHECK(base + byte3);
+		printk("A_Mcs15_Mcs12(0xe1c): 0x%02x%02x%02x%02x\n",byte0, byte1, byte2, byte3);
+		printk("B_Mcs15_Mcs12(0x868): 0x%02x%02x%02x%02x\n",byte0, byte1, byte2, byte3);
+
+		return; // use default
+	}
+	else
+	{
+		//===PATH A===
+		//OFDM
+		base = pwrlevelHT40_1S_A;
+		offset = (pwrdiffOFDM & 0x0f);
+		
+#if defined(CONFIG_RTL_92D_SUPPORT)&& defined(CONFIG_RTL_92D_DMDP)
+		//_TXPWR_REDEFINE??
+		if (priv->pmib->dot11RFEntry.macPhyMode==DUALMAC_DUALPHY && priv->pshare->wlandev_idx == 1) {
+			offset = ((pwrdiffOFDM & 0xf0) >> 4);
+		}
+#endif	
+		base = COUNT_SIGN_OFFSET(base, offset);
+		
+		byte0 = POWER_RANGE_CHECK(base + OFDMTxAgcOffset_A[0]);
+		byte1 = POWER_RANGE_CHECK(base + OFDMTxAgcOffset_A[1]);
+		byte2 = POWER_RANGE_CHECK(base + OFDMTxAgcOffset_A[2]);
+		byte3 = POWER_RANGE_CHECK(base + OFDMTxAgcOffset_A[3]);
+		printk("A_Rate18_06(0xe00): 0x%02x%02x%02x%02x\n", byte0, byte1, byte2, byte3);		
+
+		
+		byte0 = POWER_RANGE_CHECK(base + OFDMTxAgcOffset_A[4]);
+		byte1 = POWER_RANGE_CHECK(base + OFDMTxAgcOffset_A[5]);
+		byte2 = POWER_RANGE_CHECK(base + OFDMTxAgcOffset_A[6]);
+		byte3 = POWER_RANGE_CHECK(base + OFDMTxAgcOffset_A[7]);
+		printk("A_Rate54_24(0xe04): 0x%02x%02x%02x%02x\n", byte0, byte1, byte2, byte3);	 
+
+		//MCS 0 - 7
+		base = pwrlevelHT40_1S_A;
+		if (priv->pshare->CurrentChannelBW == HT_CHANNEL_WIDTH_20) {
+			offset = (pwrdiffHT20 & 0x0f);
+#if defined(CONFIG_RTL_92D_SUPPORT)&& defined(CONFIG_RTL_92D_DMDP)
+			//_TXPWR_REDEFINE??
+			if (priv->pmib->dot11RFEntry.macPhyMode==DUALMAC_DUALPHY && priv->pshare->wlandev_idx == 1) {
+				offset = ((pwrdiffHT20 & 0xf0) >> 4);
+			}
+#endif
+			base = COUNT_SIGN_OFFSET(base, offset);
+		}
+
+		byte0 = POWER_RANGE_CHECK(base + MCSTxAgcOffset_A[0]);
+		byte1 = POWER_RANGE_CHECK(base + MCSTxAgcOffset_A[1]);
+		byte2 = POWER_RANGE_CHECK(base + MCSTxAgcOffset_A[2]);
+		byte3 = POWER_RANGE_CHECK(base + MCSTxAgcOffset_A[3]);
+		printk("A_Mcs03_Mcs00(0xe10): 0x%02x%02x%02x%02x\n", byte0, byte1, byte2, byte3);	
+		
+		byte0 = POWER_RANGE_CHECK(base + MCSTxAgcOffset_A[4]);
+		byte1 = POWER_RANGE_CHECK(base + MCSTxAgcOffset_A[5]);
+		byte2 = POWER_RANGE_CHECK(base + MCSTxAgcOffset_A[6]);
+		byte3 = POWER_RANGE_CHECK(base + MCSTxAgcOffset_A[7]);	  
+		printk("A_Mcs07_Mcs04(0xe14): 0x%02x%02x%02x%02x\n", byte0, byte1, byte2, byte3);
+
+		offset = (pwrdiffHT40_2S & 0x0f);
+#if defined(CONFIG_RTL_92D_SUPPORT)&& defined(CONFIG_RTL_92D_DMDP)
+		//_TXPWR_REDEFINE??
+		if (priv->pmib->dot11RFEntry.macPhyMode==DUALMAC_DUALPHY && priv->pshare->wlandev_idx == 1) {
+			offset = ((pwrdiffHT40_2S & 0xf0) >> 4);
+		}
+#endif	
+		base = COUNT_SIGN_OFFSET(base, offset);
+
+		//MCS 8 -12
+#ifdef USB_POWER_SUPPORT
+
+		base_6dBm = pwrlevelHT40_1S_A_6dB;
+		
+		if (priv->pshare->CurrentChannelBW == HT_CHANNEL_WIDTH_20) 
+		{
+			offset_6dBm = (pwrdiffHT20_6dB & 0x0f);
+				
+#if defined(CONFIG_RTL_92D_SUPPORT)&& defined(CONFIG_RTL_92D_DMDP)
+			if (priv->pmib->dot11RFEntry.macPhyMode==DUALMAC_DUALPHY && priv->pshare->wlandev_idx == 1) {
+				offset_6dBm = ((pwrdiffHT20_6dB & 0xf0) >> 4);
+			}
+#endif	
+			base_6dBm = COUNT_SIGN_OFFSET(base_6dBm, offset_6dBm);
+		}
+			
+		offset_6dBm = (pwrdiffHT40_2S_6dB & 0x0f);
+			
+#if defined(CONFIG_RTL_92D_SUPPORT)&& defined(CONFIG_RTL_92D_DMDP)
+		if (priv->pmib->dot11RFEntry.macPhyMode==DUALMAC_DUALPHY && priv->pshare->wlandev_idx == 1) {
+			offset_6dBm = ((pwrdiffHT40_2S_6dB & 0xf0) >> 4);
+		}
+#endif	
+		
+		base_6dBm = COUNT_SIGN_OFFSET(base_6dBm, offset_6dBm);
+		
+		if ((pwrlevelHT40_1S_A_6dB!= 0) && (pwrlevelHT40_1S_A_6dB!= pwrlevelHT40_1S_A))
+			byte0 = byte1 = byte2 = byte3 = base_6dBm;
+		else if((base - USB_HT_2S_DIFF) > 0)
+			byte0 = byte1 = byte2 = byte3 = POWER_RANGE_CHECK(base - USB_HT_2S_DIFF);
+		else
+			byte0 = byte1 = byte2 = byte3 = POWER_RANGE_CHECK(defValue - USB_HT_2S_DIFF);
+
+		printk("A_Mcs11_Mcs08(0xe18): 0x%02x%02x%02x%02x\n", byte0, byte1, byte2, byte3);
+
+		if ((pwrlevelHT40_1S_A_6dB != 0) && (pwrlevelHT40_1S_A_6dB != pwrlevelHT40_1S_A))
+			byte0 = byte1 = byte2 = byte3 =	base_6dBm;
+		else if((base - USB_HT_2S_DIFF) > 0)
+			byte0 = byte1 = byte2 = byte3 =	POWER_RANGE_CHECK(base - USB_HT_2S_DIFF);
+		else
+			byte0 = byte1 = byte2 = byte3 =	POWER_RANGE_CHECK(defValue - USB_HT_2S_DIFF);
+
+		printk("A_Mcs15_Mcs12(0xe1c): 0x%02x%02x%02x%02x\n", byte0, byte1, byte2, byte3);
+
+#else			
+		byte0 = POWER_RANGE_CHECK(base + priv->pshare->phw->MCSTxAgcOffset_A[8]);
+		byte1 = POWER_RANGE_CHECK(base + priv->pshare->phw->MCSTxAgcOffset_A[9]);
+		byte2 = POWER_RANGE_CHECK(base + priv->pshare->phw->MCSTxAgcOffset_A[10]);
+		byte3 = POWER_RANGE_CHECK(base + priv->pshare->phw->MCSTxAgcOffset_A[11]);
+		printk("A_Mcs11_Mcs08(0xe18): 0x%02x%02x%02x%02x\n",byte0, byte1, byte2, byte3);
+
+		byte0 = POWER_RANGE_CHECK(base + priv->pshare->phw->MCSTxAgcOffset_A[12]);
+		byte1 = POWER_RANGE_CHECK(base + priv->pshare->phw->MCSTxAgcOffset_A[13]);
+		byte2 = POWER_RANGE_CHECK(base + priv->pshare->phw->MCSTxAgcOffset_A[14]);
+		byte3 = POWER_RANGE_CHECK(base + priv->pshare->phw->MCSTxAgcOffset_A[15]);
+		printk("A_Mcs15_Mcs12(0xe1c): 0x%02x%02x%02x%02x\n",byte0, byte1, byte2, byte3);
+#endif
+		//===PATH B===
+		if (pwrlevelHT40_1S_B == 0)
+			pwrlevelHT40_1S_B = defValue;
+		
+		//OFDM
+		base = pwrlevelHT40_1S_B;
+		offset = ((pwrdiffOFDM & 0xf0) >> 4);
+		base = COUNT_SIGN_OFFSET(base, offset);
+		
+		byte0 = POWER_RANGE_CHECK(base + OFDMTxAgcOffset_B[0]);
+		byte1 = POWER_RANGE_CHECK(base + OFDMTxAgcOffset_B[1]);
+		byte2 = POWER_RANGE_CHECK(base + OFDMTxAgcOffset_B[2]);
+		byte3 = POWER_RANGE_CHECK(base + OFDMTxAgcOffset_B[3]);	
+		printk("B_Rate18_06(0x830): 0x%02x%02x%02x%02x\n", byte0, byte1, byte2, byte3);		
+
+		
+		byte0 = POWER_RANGE_CHECK(base + OFDMTxAgcOffset_B[4]);
+		byte1 = POWER_RANGE_CHECK(base + OFDMTxAgcOffset_B[5]);
+		byte2 = POWER_RANGE_CHECK(base + OFDMTxAgcOffset_B[6]);
+		byte3 = POWER_RANGE_CHECK(base + OFDMTxAgcOffset_B[7]);
+		printk("B_Rate54_24(0x834): 0x%02x%02x%02x%02x\n", byte0, byte1, byte2, byte3);	 
+
+		//MCS 0 - 7
+		base = pwrlevelHT40_1S_B;
+		if (priv->pshare->CurrentChannelBW == HT_CHANNEL_WIDTH_20) {
+			offset = ((pwrdiffHT20 & 0xf0) >> 4);
+			base = COUNT_SIGN_OFFSET(base, offset);
+		}
+
+		byte0 = POWER_RANGE_CHECK(base + MCSTxAgcOffset_B[0]);
+		byte1 = POWER_RANGE_CHECK(base + MCSTxAgcOffset_B[1]);
+		byte2 = POWER_RANGE_CHECK(base + MCSTxAgcOffset_B[2]);
+		byte3 = POWER_RANGE_CHECK(base + MCSTxAgcOffset_B[3]);
+		printk("B_Mcs03_Mcs00(0x83c): 0x%02x%02x%02x%02x\n", byte0, byte1, byte2, byte3);	
+		
+		byte0 = POWER_RANGE_CHECK(base + MCSTxAgcOffset_B[4]);
+		byte1 = POWER_RANGE_CHECK(base + MCSTxAgcOffset_B[5]);
+		byte2 = POWER_RANGE_CHECK(base + MCSTxAgcOffset_B[6]);
+		byte3 = POWER_RANGE_CHECK(base + MCSTxAgcOffset_B[7]);	  
+		printk("B_Mcs07_Mcs04(0x848): 0x%02x%02x%02x%02x\n", byte0, byte1, byte2, byte3);
+
+		offset = ((pwrdiffHT40_2S & 0xf0) >> 4);
+		base = COUNT_SIGN_OFFSET(base, offset);
+
+		//MCS 8 -12
+#ifdef USB_POWER_SUPPORT
+
+		base_6dBm = pwrlevelHT40_1S_B_6dB;
+		if (priv->pshare->CurrentChannelBW == HT_CHANNEL_WIDTH_20) {
+			offset_6dBm = ((pwrdiffHT20_6dB & 0xf0) >> 4);
+			base_6dBm = COUNT_SIGN_OFFSET(base_6dBm, offset_6dBm);
+		}
+		
+		offset_6dBm = ((pwrdiffHT40_2S_6dB& 0xf0) >> 4);
+		base_6dBm = COUNT_SIGN_OFFSET(base_6dBm, offset_6dBm);
+		
+		if ((pwrlevelHT40_1S_B_6dB!= 0) && (pwrlevelHT40_1S_B_6dB!= pwrlevelHT40_1S_B))
+			byte0 = byte1 = byte2 = byte3 = base_6dBm;
+		else if((base - USB_HT_2S_DIFF) > 0)
+			byte0 = byte1 = byte2 = byte3 = POWER_RANGE_CHECK(base - USB_HT_2S_DIFF);
+		else
+			byte0 = byte1 = byte2 = byte3 = POWER_RANGE_CHECK(defValue - USB_HT_2S_DIFF);
+
+		printk("B_Mcs11_Mcs08(0x84c): 0x%02x%02x%02x%02x\n",byte0, byte1, byte2, byte3);
+
+		if ((pwrlevelHT40_1S_B_6dB != 0) && (pwrlevelHT40_1S_B_6dB != pwrlevelHT40_1S_B))
+			byte0 = byte1 = byte2 = byte3 =	base_6dBm;
+		else if((base - USB_HT_2S_DIFF) > 0)
+			byte0 = byte1 = byte2 = byte3 =	POWER_RANGE_CHECK(base - USB_HT_2S_DIFF);
+		else
+			byte0 = byte1 = byte2 = byte3 =	POWER_RANGE_CHECK(defValue - USB_HT_2S_DIFF);
+
+		printk("B_Mcs15_Mcs12(0x868): 0x%02x%02x%02x%02x\n",byte0, byte1, byte2, byte3);
+
+#else			
+		byte0 = POWER_RANGE_CHECK(base + priv->pshare->phw->MCSTxAgcOffset_B[8]);
+		byte1 = POWER_RANGE_CHECK(base + priv->pshare->phw->MCSTxAgcOffset_B[9]);
+		byte2 = POWER_RANGE_CHECK(base + priv->pshare->phw->MCSTxAgcOffset_B[10]);
+		byte3 = POWER_RANGE_CHECK(base + priv->pshare->phw->MCSTxAgcOffset_B[11]);
+		printk("B_Mcs11_Mcs08(0x84c): 0x%02x%02x%02x%02x\n",byte0, byte1, byte2, byte3);
+
+		byte0 = POWER_RANGE_CHECK(base + priv->pshare->phw->MCSTxAgcOffset_B[12]);
+		byte1 = POWER_RANGE_CHECK(base + priv->pshare->phw->MCSTxAgcOffset_B[13]);
+		byte2 = POWER_RANGE_CHECK(base + priv->pshare->phw->MCSTxAgcOffset_B[14]);
+		byte3 = POWER_RANGE_CHECK(base + priv->pshare->phw->MCSTxAgcOffset_B[15]);
+		printk("B_Mcs15_Mcs12(0x868): 0x%02x%02x%02x%02x\n",byte0, byte1, byte2, byte3);
+
+		return;
+#endif
+	}
+
+}
+
+static void txpwr_dump(struct rtl8192cd_priv *priv, int start, int end)
+{
+
+	int channel = 0;
+	int tmp = 0;
+	int defValue = 0x28;
+	unsigned int phyBandSelect;
+	
+	char pwrlevelCCK_A = 0;
+	char pwrlevelCCK_B = 0;
+	
+	unsigned char pwrlevelHT40_1S_A = 0;
+	unsigned char pwrlevelHT40_1S_B = 0;
+	unsigned char pwrdiffHT40_2S = 0;
+	unsigned char pwrdiffHT20 = 0;
+	unsigned char pwrdiffOFDM = 0;
+
+#if 1 // USB_POWER_SUPPORT
+	unsigned char pwrlevelHT40_1S_A_6dB = 0;
+	unsigned char pwrlevelHT40_1S_B_6dB = 0;
+	unsigned char pwrdiffHT40_2S_6dB = 0;
+	unsigned char pwrdiffHT20_6dB = 0;
+#endif
+
+	int pg_tbl_idx = 0;
+	int PHYREG_PG = 4;
+	char MCSTxAgcOffset_A[16];
+	char MCSTxAgcOffset_B[16];
+	char OFDMTxAgcOffset_A[8];
+	char OFDMTxAgcOffset_B[8];
+
+	//_TXPWR_REDEFINE ?? int or char ??
+	char CCKTxAgc_A[4];
+	char CCKTxAgc_B[4];
+
+#ifdef TXPWR_LMT
+	unsigned int tgpwr_CCK = 0;
+	unsigned int tgpwr_OFDM = 0;
+	unsigned int txpwr_lmt_CCK = 0;
+	unsigned int txpwr_lmt_OFDM = 0;
+
+	unsigned int tgpwr_HT1S = 0;
+	unsigned int tgpwr_HT2S = 0;
+	unsigned int txpwr_lmt_HT1S = 0;
+	unsigned int txpwr_lmt_HT2S = 0;
+
+	int i;
+	int max_idx;
+#endif
+
+	if(end <= 14)
+		phyBandSelect = PHY_BAND_2G;
+	else
+		phyBandSelect = PHY_BAND_5G;
+
+	
+#ifdef CONFIG_RTL_92D_SUPPORT
+			if (GET_CHIP_VER(priv)==VERSION_8192D) {
+#if defined(CONFIG_RTL_8198) || defined(CONFIG_RTL_819XD) || defined(CONFIG_RTL_8196E)
+				if (phyBandSelect & PHY_BAND_5G)
+					defValue=0x28;
+				else
+					defValue=0x2d;
+#else
+				if (phyBandSelect & PHY_BAND_5G)
+					defValue=0x26;
+				else
+					defValue=0x30;
+#endif
+			}
+#endif
+
+	
+	if(start > end)
+	{
+		printk("Error! start = %d < end = %d\n", start, end);
+	}
+	else if (end <= 14)
+	{
+		for(channel = start; channel <= end; channel++ ) //_TXPWR_REDEFINE ?? DO NOT PRINT TOO MUCH
+		{
+			
+			printk("\n[CHANNEL%03d]", channel);
+			printk("\n");
+
+			//===GET FROM FLASH===
+			
+			pwrlevelCCK_A = priv->pmib->dot11RFEntry.pwrlevelCCK_A[channel-1];
+			pwrlevelCCK_B = priv->pmib->dot11RFEntry.pwrlevelCCK_B[channel-1];
+			pwrlevelHT40_1S_A = priv->pmib->dot11RFEntry.pwrlevelHT40_1S_A[channel-1];
+			pwrlevelHT40_1S_B = priv->pmib->dot11RFEntry.pwrlevelHT40_1S_B[channel-1];
+			pwrdiffHT40_2S = priv->pmib->dot11RFEntry.pwrdiffHT40_2S[channel-1];
+			pwrdiffHT20 = priv->pmib->dot11RFEntry.pwrdiffHT20[channel-1];
+			pwrdiffOFDM = priv->pmib->dot11RFEntry.pwrdiffOFDM[channel-1];
+			
+#ifdef USB_POWER_SUPPORT
+			printk(">>FLASH - 13dBm<<\n");
+#endif
+			printk("pwrlevelCCK_A = %d, pwrlevelCCK_B = %d\n", pwrlevelCCK_A, pwrlevelCCK_B);
+			printk("pwrlevelHT40_1S_A = %d, pwrlevelHT40_1S_B = %d\n", pwrlevelHT40_1S_A, pwrlevelHT40_1S_B);
+			printk("pwrdiffHT40_2S = %d(0x%02x), pwrdiffHT20 = %d(0x%02x), pwrdiffOFDM = %d(0x%02x)\n", 
+						pwrdiffHT40_2S, pwrdiffHT40_2S,
+						pwrdiffHT20, pwrdiffHT20,
+						pwrdiffOFDM, pwrdiffOFDM);
+
+#ifdef USB_POWER_SUPPORT
+			printk(">>FLASH - 6dBm<<\n");
+			pwrlevelHT40_1S_A_6dB = priv->pmib->dot11RFEntry.pwrlevel5GHT40_1S_A[channel-1];
+			pwrlevelHT40_1S_B_6dB = priv->pmib->dot11RFEntry.pwrlevel5GHT40_1S_B[channel-1];
+			pwrdiffHT40_2S_6dB = priv->pmib->dot11RFEntry.pwrdiff5GHT40_2S[channel-1];
+			pwrdiffHT20_6dB = priv->pmib->dot11RFEntry.pwrdiff5GHT20[channel-1];
+			
+			printk("pwrlevelHT40_1S_A = %d, pwrlevelHT40_1S_B = %d\n", pwrlevelHT40_1S_A_6dB, pwrlevelHT40_1S_B_6dB);
+			printk("pwrdiffHT40_2S = %d(0x%02x), pwrdiffHT20 = %d(0x%02x)\n", 
+						pwrdiffHT40_2S_6dB, pwrdiffHT40_2S_6dB,
+						pwrdiffHT20_6dB, pwrdiffHT20_6dB);
+#endif
+
+
+#if defined(CONFIG_RTL_92D_SUPPORT) && defined(CONFIG_RTL_92D_DMDP)
+			if (GET_CHIP_VER(priv)==VERSION_8192D) {
+				if (priv->pmib->dot11RFEntry.macPhyMode==DUALMAC_DUALPHY && priv->pshare->wlandev_idx == 1) {
+					printk("92D-DMDP WLAN1 , Set pwrlevelCCK_A = pwrlevelCCK_B\n");
+					if (phyBandSelect & PHY_BAND_2G)
+						pwrlevelCCK_A = priv->pmib->dot11RFEntry.pwrlevelCCK_B[channel-1];
+				}
+			}
+#endif
+
+
+#ifdef CONFIG_RTL_92D_DMDP//_Eric ?? Get chip ??
+			if (priv->pmib->dot11RFEntry.macPhyMode==DUALMAC_DUALPHY && priv->pshare->wlandev_idx == 1) 
+			{
+				printk("92D-DMDP WLAN1, Set pwrlevelHT40_1S_A = pwrlevelHT40_1S_B\n");
+				if (phyBandSelect & PHY_BAND_5G)
+				{
+					pwrlevelHT40_1S_A = priv->pmib->dot11RFEntry.pwrlevel5GHT40_1S_B[channel-1];
+				}
+				else 
+				{
+					pwrlevelHT40_1S_A = priv->pmib->dot11RFEntry.pwrlevelHT40_1S_B[channel-1];
+				}
+#ifdef USB_POWER_SUPPORT
+				if (phyBandSelect & PHY_BAND_5G) 
+				{
+					pwrlevelHT40_1S_A_6dB= priv->pmib->dot11RFEntry.pwrlevel5GHT40_1S_B[channel];
+				} 
+				else 
+				{
+					pwrlevelHT40_1S_A_6dB= priv->pmib->dot11RFEntry.pwrlevel5GHT40_1S_B[channel-1];
+				}	
+#endif
+			}
+#endif
+
+
+			//===POWER BY RATE===
+			printk(">>Power By Rate Table<<\n");
+			pg_tbl_idx = 0;
+
+#ifdef CONFIG_RTL_92D_SUPPORT
+			if (GET_CHIP_VER(priv) == VERSION_8192D) {
+				if (priv->pshare->is_40m_bw == 0) {
+					if (channel<=3)
+						pg_tbl_idx = BGN_20_CH1_3;
+					else if (channel<=9)
+						pg_tbl_idx = BGN_20_CH4_9;
+					else
+						pg_tbl_idx = BGN_20_CH10_14;
+				} else {
+					if (channel<=3)
+						pg_tbl_idx = BGN_40_CH1_3;
+					else if (channel<=9)
+						pg_tbl_idx = BGN_40_CH4_9;
+					else
+						pg_tbl_idx = BGN_40_CH10_14;
+				}
+			}
+#ifdef MP_TEST
+			//In Noraml Driver mode, and if mib 'pwr_by_rate' = 0 >> Use default power by rate table 
+			if( (priv->pshare->rf_ft_var.mp_specific == 0) && (priv->pshare->rf_ft_var.pwr_by_rate == 0) )
+				pg_tbl_idx = BGN_2040_ALL;
+#endif
+#endif
+
+			printk("pg_tbl_idx = %d\n", pg_tbl_idx);
+
+			Read_PG_File(priv, PHYREG_PG, pg_tbl_idx, 
+					MCSTxAgcOffset_A, MCSTxAgcOffset_B, 
+					OFDMTxAgcOffset_A, OFDMTxAgcOffset_B,
+					CCKTxAgc_A, CCKTxAgc_B);
+
+			printk("MCSTxAgcOffset_A - ");
+			for(tmp = 0; tmp <16; tmp ++)
+				printk("%02x ", MCSTxAgcOffset_A[tmp]);
+			printk("\n");
+
+			printk("MCSTxAgcOffset_B - ");
+			for(tmp = 0; tmp <16; tmp ++)
+				printk("%02x ", MCSTxAgcOffset_B[tmp]);
+			printk("\n");
+
+			printk("OFDMTxAgcOffset_A - ");
+			for(tmp = 0; tmp <8; tmp ++)
+				printk("%02x ", OFDMTxAgcOffset_A[tmp]);
+			printk("\n");
+
+			printk("OFDMTxAgcOffset_B - ");
+			for(tmp = 0; tmp <8; tmp ++)
+				printk("%02x ", OFDMTxAgcOffset_B[tmp]);
+			printk("\n");
+
+			printk("CCKTxAgc_A - ");
+			for(tmp = 0; tmp <4; tmp ++)
+				printk("%02x ", CCKTxAgc_A[tmp]);
+			printk("\n");
+
+			printk("CCKTxAgc_B - ");
+			for(tmp = 0; tmp <4; tmp ++)
+				printk("%02x ", CCKTxAgc_B[tmp]);
+			printk("\n");
+
+#ifdef ADD_TX_POWER_BY_CMD
+			check_txpwr_by_cmd(priv, MCSTxAgcOffset_A, MCSTxAgcOffset_B, 
+			 	OFDMTxAgcOffset_A, OFDMTxAgcOffset_B, CCKTxAgc_A, CCKTxAgc_B);
+#endif
+
+
+			//===Count FLASH + POWER BY RATE===
+
+			printk(">>Tx Power - Power By Rate<<\n");
+	
+			dump_cck(priv, pwrlevelCCK_A, pwrlevelCCK_B, CCKTxAgc_A, CCKTxAgc_B);
+			
+			dump_ofdm_mcs0(priv, defValue, pwrlevelHT40_1S_A, pwrlevelHT40_1S_B, 
+				pwrdiffHT40_2S, pwrdiffHT20, pwrdiffOFDM, 
+				pwrlevelHT40_1S_A_6dB, pwrlevelHT40_1S_B_6dB,
+				pwrdiffHT40_2S_6dB, pwrdiffHT20_6dB,
+				MCSTxAgcOffset_A, MCSTxAgcOffset_B, OFDMTxAgcOffset_A, OFDMTxAgcOffset_B,phyBandSelect);
+				
+			
+#ifdef TXPWR_LMT
+			//===BAND EDGE LIMIT===
+			if (priv->pshare->rf_ft_var.disable_txpwrlmt)
+				continue;
+			
+			printk(">>Band Edge Limit Table<<\n");
+			tmp = ch2idx(channel);
+			
+			txpwr_lmt_CCK = priv->pshare->ch_pwr_lmtCCK[tmp];
+			txpwr_lmt_OFDM = priv->pshare->ch_pwr_lmtOFDM[tmp];
+			tgpwr_CCK = priv->pshare->ch_tgpwr_CCK[tmp];
+			tgpwr_OFDM = priv->pshare->ch_tgpwr_OFDM[tmp];
+
+			printk("txpwr_lmt_CCK = %d tgpwr_CCK = %d\n", txpwr_lmt_CCK,  tgpwr_CCK);
+			printk("txpwr_lmt_OFDM = %d tgpwr_OFDM = %d\n", txpwr_lmt_OFDM,  tgpwr_OFDM);
+
+			if (priv->pshare->is_40m_bw == 0)
+			{
+				txpwr_lmt_HT1S = priv->pshare->ch_pwr_lmtHT20_1S[tmp];
+				txpwr_lmt_HT2S = priv->pshare->ch_pwr_lmtHT20_2S[tmp];
+				tgpwr_HT1S = priv->pshare->ch_tgpwr_HT20_1S[tmp];
+				tgpwr_HT2S = priv->pshare->ch_tgpwr_HT20_2S[tmp];
+
+				printk("txpwr_lmt_HT1S_20M = %d tgpwr_HT1S_20M = %d\n", txpwr_lmt_HT1S,  tgpwr_HT1S);
+				printk("txpwr_lmt_HT2S_20M = %d tgpwr_HT2S_20M = %d\n", txpwr_lmt_HT2S,  tgpwr_HT2S);
+			}
+			else
+			{
+				txpwr_lmt_HT1S = priv->pshare->ch_pwr_lmtHT40_1S[tmp];
+				txpwr_lmt_HT2S = priv->pshare->ch_pwr_lmtHT40_2S[tmp];
+				tgpwr_HT1S = priv->pshare->ch_tgpwr_HT40_1S[tmp];
+				tgpwr_HT2S = priv->pshare->ch_tgpwr_HT40_2S[tmp];
+
+				printk("txpwr_lmt_HT1S_40M = %d tgpwr_HT1S_40M = %d\n", txpwr_lmt_HT1S,  tgpwr_HT1S);
+				printk("txpwr_lmt_HT2S_40M = %d tgpwr_HT2S_40M = %d\n", txpwr_lmt_HT2S,  tgpwr_HT2S);
+			}
+
+			//===Count FLASH + min{POWER BY RATE, LIMIT}===
+			if((txpwr_lmt_CCK == 0) && (txpwr_lmt_OFDM == 0) 
+				&& (txpwr_lmt_HT1S == 0) && (txpwr_lmt_HT1S == 0))
+			{
+				printk("No Band Edge Limit for this channel=%d\n", channel);
+				continue;
+			}
+			
+			if (txpwr_lmt_CCK || tgpwr_CCK){
+				max_idx=255;
+			}else{
+				max_idx = (txpwr_lmt_CCK - tgpwr_CCK);
+			}
+
+			for (i=0; i<=3; i++) {
+				CCKTxAgc_A[i] = POWER_MIN_CHECK(CCKTxAgc_A[i], max_idx);
+				CCKTxAgc_B[i] = POWER_MIN_CHECK(CCKTxAgc_B[i], max_idx);
+			}
+
+			dump_cck(priv, pwrlevelCCK_A, pwrlevelCCK_B, CCKTxAgc_A, CCKTxAgc_B);
+		
+			if (!txpwr_lmt_OFDM || !tgpwr_OFDM){
+				max_idx=255;
+			}else{
+				max_idx = (txpwr_lmt_OFDM - tgpwr_OFDM);
+			}
+
+			for (i=0; i<=7; i++) {
+				OFDMTxAgcOffset_A[i] = POWER_MIN_CHECK(OFDMTxAgcOffset_A[i], max_idx);
+				OFDMTxAgcOffset_B[i] = POWER_MIN_CHECK(OFDMTxAgcOffset_B[i], max_idx);
+			}
+	
+			if (!txpwr_lmt_HT1S || !tgpwr_HT1S){
+				max_idx = 255;
+			}else{
+				max_idx = (txpwr_lmt_HT1S - tgpwr_HT1S);
+			}
+
+			for (i=0; i<=7; i++) {
+				MCSTxAgcOffset_A[i] = POWER_MIN_CHECK(MCSTxAgcOffset_A[i], max_idx);
+				MCSTxAgcOffset_B[i] = POWER_MIN_CHECK(MCSTxAgcOffset_B[i], max_idx);
+			}
+
+			if (!txpwr_lmt_HT2S || !tgpwr_HT2S){
+				max_idx = 255;
+			}else{
+				max_idx = (txpwr_lmt_HT2S - tgpwr_HT2S);
+			}
+
+			for (i=8; i<=15; i++) {
+				MCSTxAgcOffset_A[i] = POWER_MIN_CHECK(MCSTxAgcOffset_A[i], max_idx);
+				MCSTxAgcOffset_B[i] = POWER_MIN_CHECK(MCSTxAgcOffset_B[i], max_idx);
+			}
+
+			dump_ofdm_mcs0(priv, defValue, pwrlevelHT40_1S_A, pwrlevelHT40_1S_B, 
+				pwrdiffHT40_2S, pwrdiffHT20, pwrdiffOFDM, 
+				pwrlevelHT40_1S_A_6dB, pwrlevelHT40_1S_B_6dB,
+				pwrdiffHT40_2S_6dB, pwrdiffHT20_6dB,
+				MCSTxAgcOffset_A, MCSTxAgcOffset_B, OFDMTxAgcOffset_A, OFDMTxAgcOffset_B,phyBandSelect);
+#endif
+	
+		}
+	}
+	else if (end <= 199)
+	{
+		for(channel = start; channel <= end; channel+=2 )
+		{
+			int ori_channel = channel;
+		
+			printk("\n[CHANNEL%03d]", channel);
+			printk("\n");
+
+			//TXPWR_REDEFINE
+			//FLASH GROUP [36-99] [100-148] [149-165] 
+			//Special Cases: [34-2, 34, 34+2,  36-2, 165+2]:No DATA , [149-2]:FLASH DATA OF Channel-146-6dBm
+			//Use Flash data of channel 36 & 140 & 165 for these special cases.
+			if((channel > 30) && (channel < 36))
+				channel = 36;
+			else if (channel == (149-2))
+				channel = 140;
+			else if(channel > 165)
+				channel = 165;
+
+			//===GET FROM FLASH===
+#ifdef RTK_5G_SUPPORT
+			pwrlevelHT40_1S_A = priv->pmib->dot11RFEntry.pwrlevel5GHT40_1S_A[channel-1];
+			pwrlevelHT40_1S_B = priv->pmib->dot11RFEntry.pwrlevel5GHT40_1S_B[channel-1];
+			pwrdiffHT40_2S = priv->pmib->dot11RFEntry.pwrdiff5GHT40_2S[channel-1];
+			pwrdiffHT20 = priv->pmib->dot11RFEntry.pwrdiff5GHT20[channel-1];
+			pwrdiffOFDM = priv->pmib->dot11RFEntry.pwrdiff5GOFDM[channel-1];
+#endif
+		
+#ifdef USB_POWER_SUPPORT
+			printk(">>Flash - 13dBm<<\n");
+#endif
+
+			printk("pwrlevelHT40_1S_A = %d, pwrlevelHT40_1S_B = %d\n", pwrlevelHT40_1S_A, pwrlevelHT40_1S_B);
+			printk("pwrdiffHT40_2S = %d(0x%02x), pwrdiffHT20 = %d(0x%02x), pwrdiffOFDM = %d(0x%02x)\n", 
+						pwrdiffHT40_2S, pwrdiffHT40_2S,
+						pwrdiffHT20, pwrdiffHT20,
+						pwrdiffOFDM, pwrdiffOFDM);
+
+#ifdef USB_POWER_SUPPORT
+			printk(">>Flash - 6dBm<<\n");
+			pwrlevelHT40_1S_A_6dB = priv->pmib->dot11RFEntry.pwrlevel5GHT40_1S_A[channel];
+			pwrlevelHT40_1S_B_6dB = priv->pmib->dot11RFEntry.pwrlevel5GHT40_1S_B[channel];
+			pwrdiffHT40_2S_6dB = priv->pmib->dot11RFEntry.pwrdiff5GHT40_2S[channel];
+			pwrdiffHT20_6dB = priv->pmib->dot11RFEntry.pwrdiff5GHT20[channel];
+
+			printk("pwrlevelHT40_1S_A = %d, pwrlevelHT40_1S_B = %d\n", pwrlevelHT40_1S_A_6dB, pwrlevelHT40_1S_B_6dB);
+			printk("pwrdiffHT40_2S = %d(0x%02x), pwrdiffHT20 = %d(0x%02x)\n", 
+						pwrdiffHT40_2S_6dB, pwrdiffHT40_2S_6dB,
+						pwrdiffHT20_6dB, pwrdiffHT20_6dB);
+#endif
+
+#ifdef CONFIG_RTL_92D_DMDP
+			if (priv->pmib->dot11RFEntry.macPhyMode==DUALMAC_DUALPHY && priv->pshare->wlandev_idx == 1) 
+			{
+				printk("92D-DMDP WLAN1, Set pwrlevelHT40_1S_A = pwrlevelHT40_1S_B\n");
+				if (phyBandSelect & PHY_BAND_5G)
+				{
+					pwrlevelHT40_1S_A = priv->pmib->dot11RFEntry.pwrlevel5GHT40_1S_B[channel-1];
+				}
+				else 
+				{
+					pwrlevelHT40_1S_A = priv->pmib->dot11RFEntry.pwrlevelHT40_1S_B[channel-1];
+				}
+#ifdef USB_POWER_SUPPORT
+				if (phyBandSelect & PHY_BAND_5G) 
+				{
+					pwrlevelHT40_1S_A_6dB= priv->pmib->dot11RFEntry.pwrlevel5GHT40_1S_B[channel];
+				} 
+				else 
+				{
+					pwrlevelHT40_1S_A_6dB= priv->pmib->dot11RFEntry.pwrlevel5GHT40_1S_B[channel-1];
+				}	
+#endif
+			}
+#endif
+
+			channel = ori_channel;
+
+
+			//===POWER BY RATE===
+			printk(">>Power By Rate Table<<\n");
+
+			pg_tbl_idx = 0;
+
+#ifdef CONFIG_RTL_92D_SUPPORT
+			if (GET_CHIP_VER(priv) == VERSION_8192D) {
+				if (priv->pshare->is_40m_bw == 0) {
+					if (channel<=99)
+						pg_tbl_idx = AN_20_CH_36_64;
+					else if (channel<=148)
+						pg_tbl_idx = AN_20_CH_100_140;
+					else
+						pg_tbl_idx = AN_20_CH_149_165;
+				} else {
+					if (channel<=99)
+						pg_tbl_idx = AN_40_CH_36_64;
+					else if (channel<=148)
+						pg_tbl_idx = AN_40_CH_100_140;
+					else
+						pg_tbl_idx = AN_40_CH_149_165;
+				}
+			}
+#ifdef MP_TEST
+			//In Noraml Driver mode, and if mib 'pwr_by_rate' = 0 >> Use default power by rate table 
+			if( (priv->pshare->rf_ft_var.mp_specific == 0) && (priv->pshare->rf_ft_var.pwr_by_rate == 0) )
+				pg_tbl_idx = BGN_2040_ALL;
+#endif
+#endif
+
+			printk("pg_tbl_idx = %d\n", pg_tbl_idx);
+
+			Read_PG_File(priv, PHYREG_PG, pg_tbl_idx, 
+					MCSTxAgcOffset_A, MCSTxAgcOffset_B, 
+					OFDMTxAgcOffset_A, OFDMTxAgcOffset_B,
+					CCKTxAgc_A, CCKTxAgc_B);
+
+			printk("MCSTxAgcOffset_A - ");
+			for(tmp = 0; tmp <16; tmp ++)
+				printk("%02x ", MCSTxAgcOffset_A[tmp]);
+			printk("\n");
+
+			printk("MCSTxAgcOffset_B - ");
+			for(tmp = 0; tmp <16; tmp ++)
+				printk("%02x ", MCSTxAgcOffset_B[tmp]);
+			printk("\n");
+
+			printk("OFDMTxAgcOffset_A - ");
+			for(tmp = 0; tmp <8; tmp ++)
+				printk("%02x ", OFDMTxAgcOffset_A[tmp]);
+			printk("\n");
+
+			printk("OFDMTxAgcOffset_B - ");
+			for(tmp = 0; tmp <8; tmp ++)
+				printk("%02x ", OFDMTxAgcOffset_B[tmp]);
+			printk("\n");
+
+			printk("CCKTxAgc_A - ");
+			for(tmp = 0; tmp <4; tmp ++)
+				printk("%02x ", CCKTxAgc_A[tmp]);
+			printk("\n");
+
+			printk("CCKTxAgc_B - ");
+			for(tmp = 0; tmp <4; tmp ++)
+				printk("%02x ", CCKTxAgc_B[tmp]);
+			printk("\n");
+
+#ifdef ADD_TX_POWER_BY_CMD
+			check_txpwr_by_cmd(priv, MCSTxAgcOffset_A, MCSTxAgcOffset_B, 
+			 	OFDMTxAgcOffset_A, OFDMTxAgcOffset_B, CCKTxAgc_A, CCKTxAgc_B);
+#endif
+
+			//===Count FLASH + POWER BY RATE===
+
+			printk(">>Tx Power - Power By Rate<<\n");
+			
+			dump_ofdm_mcs0(priv, defValue, pwrlevelHT40_1S_A, pwrlevelHT40_1S_B, 
+				pwrdiffHT40_2S, pwrdiffHT20, pwrdiffOFDM, 
+				pwrlevelHT40_1S_A_6dB, pwrlevelHT40_1S_B_6dB,
+				pwrdiffHT40_2S_6dB, pwrdiffHT20_6dB,
+				MCSTxAgcOffset_A, MCSTxAgcOffset_B, OFDMTxAgcOffset_A, OFDMTxAgcOffset_B, phyBandSelect);
+
+
+#ifdef TXPWR_LMT
+			//===BAND EDGE LIMIT===
+			if (priv->pshare->rf_ft_var.disable_txpwrlmt)
+				continue;
+
+			printk(">>Band Edge Limit Table<<\n");
+
+			tmp = ch2idx(channel);
+
+			txpwr_lmt_CCK = priv->pshare->ch_pwr_lmtCCK[tmp];
+			txpwr_lmt_OFDM = priv->pshare->ch_pwr_lmtOFDM[tmp];
+			tgpwr_CCK = priv->pshare->ch_tgpwr_CCK[tmp];
+			tgpwr_OFDM = priv->pshare->ch_tgpwr_OFDM[tmp];
+
+			printk("txpwr_lmt_CCK = %d tgpwr_CCK = %d\n", txpwr_lmt_CCK,  tgpwr_CCK);
+			printk("txpwr_lmt_OFDM = %d tgpwr_OFDM = %d\n", txpwr_lmt_OFDM,  tgpwr_OFDM);
+
+			if (priv->pshare->is_40m_bw == 0)
+			{
+				txpwr_lmt_HT1S = priv->pshare->ch_pwr_lmtHT20_1S[tmp];
+				txpwr_lmt_HT2S = priv->pshare->ch_pwr_lmtHT20_2S[tmp];
+				tgpwr_HT1S = priv->pshare->ch_tgpwr_HT20_1S[tmp];
+				tgpwr_HT2S = priv->pshare->ch_tgpwr_HT20_2S[tmp];
+
+				printk("txpwr_lmt_HT1S_20M = %d tgpwr_HT1S_20M = %d\n", txpwr_lmt_HT1S,  tgpwr_HT1S);
+				printk("txpwr_lmt_HT2S_20M = %d tgpwr_HT2S_20M = %d\n", txpwr_lmt_HT2S,  tgpwr_HT2S);
+			}
+			else
+			{
+				txpwr_lmt_HT1S = priv->pshare->ch_pwr_lmtHT40_1S[tmp];
+				txpwr_lmt_HT2S = priv->pshare->ch_pwr_lmtHT40_2S[tmp];
+				tgpwr_HT1S = priv->pshare->ch_tgpwr_HT40_1S[tmp];
+				tgpwr_HT2S = priv->pshare->ch_tgpwr_HT40_2S[tmp];
+
+				printk("txpwr_lmt_HT1S_40M = %d tgpwr_HT1S_40M = %d\n", txpwr_lmt_HT1S,  tgpwr_HT1S);
+				printk("txpwr_lmt_HT2S_40M = %d tgpwr_HT2S_40M = %d\n", txpwr_lmt_HT2S,  tgpwr_HT2S);
+			}
+
+			//===Count FLASH + min{POWER BY RATE, LIMIT}===
+			if((txpwr_lmt_OFDM == 0) && (txpwr_lmt_HT1S == 0) && (txpwr_lmt_HT1S == 0))
+			{
+				printk("No Band Edge Limit for this channel=%d\n", channel);
+				continue;
+			}
+
+			if (!txpwr_lmt_OFDM || !tgpwr_OFDM){
+				max_idx=255;
+			}else{
+				max_idx = (txpwr_lmt_OFDM - tgpwr_OFDM);
+			}
+
+			for (i=0; i<=7; i++) {
+				OFDMTxAgcOffset_A[i] = POWER_MIN_CHECK(OFDMTxAgcOffset_A[i], max_idx);
+				OFDMTxAgcOffset_B[i] = POWER_MIN_CHECK(OFDMTxAgcOffset_B[i], max_idx);
+			}
+
+			if (!txpwr_lmt_HT1S || !tgpwr_HT1S){
+				max_idx = 255;
+			}else{
+				max_idx = (txpwr_lmt_HT1S - tgpwr_HT1S);
+			}
+			
+			for (i=0; i<=7; i++) {
+				MCSTxAgcOffset_A[i] = POWER_MIN_CHECK(MCSTxAgcOffset_A[i], max_idx);
+				MCSTxAgcOffset_B[i] = POWER_MIN_CHECK(MCSTxAgcOffset_B[i], max_idx);
+			}
+			
+			if (!txpwr_lmt_HT2S || !tgpwr_HT2S){
+				max_idx = 255;
+			}else{
+				max_idx = (txpwr_lmt_HT2S - tgpwr_HT2S);
+			}
+
+			for (i=8; i<=15; i++) {
+				MCSTxAgcOffset_A[i] = POWER_MIN_CHECK(MCSTxAgcOffset_A[i], max_idx);
+				MCSTxAgcOffset_B[i] = POWER_MIN_CHECK(MCSTxAgcOffset_B[i], max_idx);
+			}
+
+			dump_ofdm_mcs0(priv, defValue, pwrlevelHT40_1S_A, pwrlevelHT40_1S_B, 
+				pwrdiffHT40_2S, pwrdiffHT20, pwrdiffOFDM, 
+				pwrlevelHT40_1S_A_6dB, pwrlevelHT40_1S_B_6dB,
+				pwrdiffHT40_2S_6dB, pwrdiffHT20_6dB,
+				MCSTxAgcOffset_A, MCSTxAgcOffset_B, OFDMTxAgcOffset_A, OFDMTxAgcOffset_B, phyBandSelect);
+
+#endif
+			
+		}
+	}
+
+}
+
+#endif
+
+#if defined(CONFIG_RTL_8812_SUPPORT) || defined(CONFIG_WLAN_HAL_8881A)
+void reg_dump_8812(struct rtl8192cd_priv *priv)
+{
+		panic_printk("Initial Gain, Sensitivity:\n");
+		panic_printk(" 0xC50: 0x%02x\n", RTL_R8(0xc50));
+		panic_printk(" 0xE50: 0x%02x\n", RTL_R8(0xe50));
+		panic_printk(" 0xC30: 0x%02x\n", RTL_R8(0xc30));
+		panic_printk(" 0xC87: 0x%02x\n", RTL_R8(0xc87));
+		panic_printk(" 0xA0A: 0x%02x\n", RTL_R8(0xa0a));
+		
+		panic_printk("EDCA para:\n");
+		panic_printk(" VO(0x%03x): 0x%08x\n", EDCA_VO_PARA, RTL_R32(EDCA_VO_PARA));
+		panic_printk(" VI(0x%03x): 0x%08x\n", EDCA_VI_PARA, RTL_R32(EDCA_VI_PARA));
+		panic_printk(" BE(0x%03x): 0x%08x\n", EDCA_BE_PARA, RTL_R32(EDCA_BE_PARA));
+		panic_printk(" BK(0x%03x): 0x%08x\n", EDCA_BK_PARA, RTL_R32(EDCA_BK_PARA));
+		
+		panic_printk("Tx power:\n");
+		panic_printk(" A_CCK11_CCK1(0x%03x):      0x%08x\n", rTxAGC_A_CCK11_CCK1_JAguar, RTL_R32(rTxAGC_A_CCK11_CCK1_JAguar));
+		panic_printk(" A_Rate18_06(0x%03x):       0x%08x\n", rTxAGC_A_Ofdm18_Ofdm6_JAguar, RTL_R32(rTxAGC_A_Ofdm18_Ofdm6_JAguar));
+		panic_printk(" A_Rate54_24(0x%03x):       0x%08x\n", rTxAGC_A_Ofdm54_Ofdm24_JAguar, RTL_R32(rTxAGC_A_Ofdm54_Ofdm24_JAguar));
+		panic_printk(" A_Mcs03_Mcs00(0x%03x):     0x%08x\n", rTxAGC_A_MCS3_MCS0_JAguar, RTL_R32(rTxAGC_A_MCS3_MCS0_JAguar));
+		panic_printk(" A_Mcs07_Mcs04(0x%03x):     0x%08x\n", rTxAGC_A_MCS7_MCS4_JAguar, RTL_R32(rTxAGC_A_MCS7_MCS4_JAguar));
+		panic_printk(" A_Mcs11_Mcs08(0x%03x):     0x%08x\n", rTxAGC_A_MCS11_MCS8_JAguar, RTL_R32(rTxAGC_A_MCS11_MCS8_JAguar));
+		panic_printk(" A_Mcs15_Mcs12(0x%03x):     0x%08x\n", rTxAGC_A_MCS15_MCS12_JAguar, RTL_R32(rTxAGC_A_MCS15_MCS12_JAguar));
+		panic_printk(" A_Nss13_Nss10(0x%03x):     0x%08x\n", rTxAGC_A_Nss1Index3_Nss1Index0_JAguar, RTL_R32(rTxAGC_A_Nss1Index3_Nss1Index0_JAguar));
+		panic_printk(" A_Nss17_Nss14(0x%03x):     0x%08x\n", rTxAGC_A_Nss1Index7_Nss1Index4_JAguar, RTL_R32(rTxAGC_A_Nss1Index7_Nss1Index4_JAguar));
+		panic_printk(" A_Nss21_Nss18(0x%03x):     0x%08x\n", rTxAGC_A_Nss2Index1_Nss1Index8_JAguar, RTL_R32(rTxAGC_A_Nss2Index1_Nss1Index8_JAguar));
+		panic_printk(" A_Nss25_Nss22(0x%03x):     0x%08x\n", rTxAGC_A_Nss2Index5_Nss2Index2_JAguar, RTL_R32(rTxAGC_A_Nss2Index5_Nss2Index2_JAguar));
+		panic_printk(" A_Nss29_Nss26(0x%03x):     0x%08x\n", rTxAGC_A_Nss2Index9_Nss2Index6_JAguar, RTL_R32(rTxAGC_A_Nss2Index9_Nss2Index6_JAguar));
+		panic_printk(" B_CCK11_CCK1(0x%03x):      0x%08x\n", rTxAGC_B_CCK11_CCK1_JAguar, RTL_R32(rTxAGC_B_CCK11_CCK1_JAguar));
+		panic_printk(" B_Rate18_06(0x%03x):       0x%08x\n", rTxAGC_B_Ofdm18_Ofdm6_JAguar, RTL_R32(rTxAGC_B_Ofdm18_Ofdm6_JAguar));
+		panic_printk(" B_Rate54_24(0x%03x):       0x%08x\n", rTxAGC_B_Ofdm54_Ofdm24_JAguar, RTL_R32(rTxAGC_B_Ofdm54_Ofdm24_JAguar));
+		panic_printk(" B_Mcs03_Mcs00(0x%03x):     0x%08x\n", rTxAGC_B_MCS3_MCS0_JAguar, RTL_R32(rTxAGC_B_MCS3_MCS0_JAguar));
+		panic_printk(" B_Mcs07_Mcs04(0x%03x):     0x%08x\n", rTxAGC_B_MCS7_MCS4_JAguar, RTL_R32(rTxAGC_B_MCS7_MCS4_JAguar));
+		panic_printk(" B_Mcs11_Mcs08(0x%03x):     0x%08x\n", rTxAGC_B_MCS11_MCS8_JAguar, RTL_R32(rTxAGC_B_MCS11_MCS8_JAguar));
+		panic_printk(" B_Mcs15_Mcs12(0x%03x):     0x%08x\n", rTxAGC_B_MCS15_MCS12_JAguar, RTL_R32(rTxAGC_B_MCS15_MCS12_JAguar));
+		panic_printk(" B_Nss13_Nss10(0x%03x):     0x%08x\n", rTxAGC_B_Nss1Index3_Nss1Index0_JAguar, RTL_R32(rTxAGC_B_Nss1Index3_Nss1Index0_JAguar));
+		panic_printk(" B_Nss17_Nss14(0x%03x):     0x%08x\n", rTxAGC_B_Nss1Index7_Nss1Index4_JAguar, RTL_R32(rTxAGC_B_Nss1Index7_Nss1Index4_JAguar));
+		panic_printk(" B_Nss21_Nss18(0x%03x):     0x%08x\n", rTxAGC_B_Nss2Index1_Nss1Index8_JAguar, RTL_R32(rTxAGC_B_Nss2Index1_Nss1Index8_JAguar));
+		panic_printk(" B_Nss25_Nss22(0x%03x):     0x%08x\n", rTxAGC_B_Nss2Index5_Nss2Index2_JAguar, RTL_R32(rTxAGC_B_Nss2Index5_Nss2Index2_JAguar));
+		panic_printk(" B_Nss29_Nss26(0x%03x):     0x%08x\n", rTxAGC_B_Nss2Index9_Nss2Index6_JAguar, RTL_R32(rTxAGC_B_Nss2Index9_Nss2Index6_JAguar));
+		return;
+}
+#endif
+
+static void reg_dump(struct rtl8192cd_priv *priv, char *str)
+{
+	int i, j, len;
+	unsigned char tmpbuf[100];
+
+#ifdef CONFIG_SDIO_HCI
+	if (strcmp(str, "sdio_local") == 0) {
+		dump_sdio_local_reg(priv);
+		return;
+	}
+	if (strcmp(str, "sdio_cccr") == 0) {
+		dump_sdio_cccr(priv);
+		return;
+	}
+#endif
+
+//_TXPWR_REDEFINE
+//_TXPWR_REDEFINE ?? Dump Too much will cause hang up ??
+	panic_printk("[Channel-%03d]", priv->pmib->dot11RFEntry.dot11channel);
+
+	if (priv->pshare->CurrentChannelBW == 0)
+	{
+		panic_printk(" - 20M BW");
+	}
+	else
+	{
+		if (priv->pshare->CurrentChannelBW == 1)
+			panic_printk(" - 40M BW ");
+		else
+			panic_printk(" - 80M BW ");
+		
+		if (priv->pshare->offset_2nd_chan == 1)
+			panic_printk("BELOW");
+		else if (priv->pshare->offset_2nd_chan == 2)
+			panic_printk("ABOVE");
+		else if (priv->pshare->offset_2nd_chan == 0)
+			panic_printk("DONT CARE");
+	}
+
+	panic_printk("\n");
+
+#ifdef _DEBUG_RTL8192CD_
+
+	if (strcmp(str, "tx") == 0)
+	{
+		printk("\n==2G L 1-3==\n");
+		txpwr_dump(priv, 1, 1);
+		printk("\n==2G M 4-9==\n");
+		txpwr_dump(priv, 4, 4);
+		printk("\n==2G H 10-14==\n");
+		txpwr_dump(priv, 10, 10);
+
+
+#ifdef CONFIG_RTL_92D_SUPPORT
+		if (GET_CHIP_VER(priv)==VERSION_8192D) {
+			printk("\n==5G G1_L 36-45==\n");
+			txpwr_dump(priv, 36, 36);
+			printk("\n==5G G1_M 46-55==\n");
+			txpwr_dump(priv, 46, 46);
+			printk("\n==5G G1_H 56-99==\n");
+			txpwr_dump(priv, 56, 56);
+			printk("\n==5G G2_L 100-113==\n");
+			txpwr_dump(priv, 100, 100);
+			printk("\n==5G G2_M 114-127==\n");
+			txpwr_dump(priv, 114, 114);
+			printk("\n==5G G2_H 128-148==\n");
+			txpwr_dump(priv, 128, 128);
+			printk("\n==5G G3_L 149-154==\n");
+			txpwr_dump(priv, 149, 149);
+			printk("\n==5G G3_M 155-160==\n");
+			txpwr_dump(priv, 155, 155);
+			printk("\n==5G G3_H 161-165==\n");
+			txpwr_dump(priv, 161, 161);
+		}
+#endif
+
+		return;
+	}
+
+
+	if (strcmp(str, "tx-2g") == 0)
+	{
+			printk("\n==2G L LIST==\n");
+			txpwr_dump(priv, 1, 3);
+			printk("\n==2G M LIST==\n");
+			txpwr_dump(priv, 4, 9);
+			printk("\n==2G H LIST==\n");
+			txpwr_dump(priv, 10, 14);
+
+		return;
+	}
+
+	if (strcmp(str, "tx-5gl") == 0)
+	{
+#ifdef CONFIG_RTL_92D_SUPPORT
+		if (GET_CHIP_VER(priv)==VERSION_8192D) {	
+			printk("\n==5G G1_L LIST==\n");
+			txpwr_dump(priv, 36, 45);
+			printk("\n==5G G1_M LIST==\n");
+			txpwr_dump(priv, 46, 55);
+			printk("\n==5G G1_H LIST==\n");
+			txpwr_dump(priv, 56, 66); //99 > 66, Because dump too much will cause reboot
+		} else
+#endif
+		{
+			printk("NOT 92D, NOT support 5G\n");
+		}
+
+		return;
+	}
+
+	if (strcmp(str, "tx-5gm") == 0)
+	{
+#ifdef CONFIG_RTL_92D_SUPPORT
+		if (GET_CHIP_VER(priv)==VERSION_8192D) {
+			printk("\n==5G G2_L LIST==\n");
+			txpwr_dump(priv, 100, 113);
+			printk("\n==5G G2_M LIST==\n");
+			txpwr_dump(priv, 114, 127);
+			printk("\n==5G G2_H LIST==\n");
+			txpwr_dump(priv, 128, 148);
+		} else
+#endif
+		{
+			printk("NOT 92D, NOT support 5G\n");
+		}
+
+		return;
+	}
+
+	if (strcmp(str, "tx-5gh") == 0)
+	{
+
+#ifdef CONFIG_RTL_92D_SUPPORT
+		if (GET_CHIP_VER(priv)==VERSION_8192D) {
+			printk("\n==5G G3_L LIST==\n");
+			txpwr_dump(priv, 149, 154);
+			printk("\n==5G G3_M LIST==\n");
+			txpwr_dump(priv, 155, 160);
+			printk("\n==5G G3_H LIST==\n");
+			txpwr_dump(priv, 161, 165);
+		} else
+#endif
+		{
+			printk("NOT 92D, NOT support 5G\n");
+		}
+			
+		return;
+	}
+#endif
+
+
+#if defined(CONFIG_RTL_8812_SUPPORT) || defined(CONFIG_WLAN_HAL_8881A)
+	if (strcmp(str, "check") == 0)
+	{
+			return;
+	}
+
+#endif
+
+	if (strcmp(str, "all") != 0) {
+
+#if defined(CONFIG_RTL_8812_SUPPORT) || defined(CONFIG_WLAN_HAL_8881A)
+		if ((GET_CHIP_VER(priv) == VERSION_8812E) || (GET_CHIP_VER(priv) == VERSION_8881A)) {
+			reg_dump_8812(priv);
+			return;
+		}
+#endif
+		panic_printk("Initial Gain, Sensitivity:\n");
+		panic_printk(" 0xC50: 0x%02x\n", RTL_R8(0xc50));
+#if defined(CONFIG_RTL_92C_SUPPORT) || defined(CONFIG_RTL_92D_SUPPORT)
+		if (
+#ifdef CONFIG_RTL_92C_SUPPORT
+			(GET_CHIP_VER(priv)==VERSION_8192C) || (GET_CHIP_VER(priv)==VERSION_8188C)
+#endif
+#ifdef CONFIG_RTL_92D_SUPPORT
+#ifdef CONFIG_RTL_92C_SUPPORT
+			|| 
+#endif
+			(GET_CHIP_VER(priv)==VERSION_8192D)
+#endif
+			)
+			panic_printk(" 0xC58: 0x%02x\n", RTL_R8(0xc58));
+#endif
+		panic_printk(" 0xC30: 0x%02x\n", RTL_R8(0xc30));
+		panic_printk(" 0xC87: 0x%02x\n", RTL_R8(0xc87));
+		panic_printk(" 0xA0A: 0x%02x\n", RTL_R8(0xa0a));
+		panic_printk("EDCA para:\n");
+		panic_printk(" VO(0x%03x): 0x%08x\n", EDCA_VO_PARA, RTL_R32(EDCA_VO_PARA));
+		panic_printk(" VI(0x%03x): 0x%08x\n", EDCA_VI_PARA, RTL_R32(EDCA_VI_PARA));
+		panic_printk(" BE(0x%03x): 0x%08x\n", EDCA_BE_PARA, RTL_R32(EDCA_BE_PARA));
+		panic_printk(" BK(0x%03x): 0x%08x\n", EDCA_BK_PARA, RTL_R32(EDCA_BK_PARA));
+		panic_printk("Tx power:\n");
+		panic_printk(" A_CCK1_Mcs32(0x%03x):      0x%08x\n", rTxAGC_A_CCK1_Mcs32, RTL_R32(rTxAGC_A_CCK1_Mcs32));
+		panic_printk(" B_CCK5_1_Mcs32(0x%03x):    0x%08x\n", rTxAGC_B_CCK5_1_Mcs32, RTL_R32(rTxAGC_B_CCK5_1_Mcs32));
+		panic_printk(" A_CCK11_2_B_CCK11(0x%03x): 0x%08x\n", rTxAGC_A_CCK11_2_B_CCK11, RTL_R32(rTxAGC_A_CCK11_2_B_CCK11));
+		panic_printk(" A_Rate18_06(0x%03x):       0x%08x\n", rTxAGC_A_Rate18_06, RTL_R32(rTxAGC_A_Rate18_06));
+		panic_printk(" A_Rate54_24(0x%03x):       0x%08x\n", rTxAGC_A_Rate54_24, RTL_R32(rTxAGC_A_Rate54_24));
+		panic_printk(" A_Mcs03_Mcs00(0x%03x):     0x%08x\n", rTxAGC_A_Mcs03_Mcs00, RTL_R32(rTxAGC_A_Mcs03_Mcs00));
+		panic_printk(" A_Mcs07_Mcs04(0x%03x):     0x%08x\n", rTxAGC_A_Mcs07_Mcs04, RTL_R32(rTxAGC_A_Mcs07_Mcs04));
+		panic_printk(" A_Mcs11_Mcs08(0x%03x):     0x%08x\n", rTxAGC_A_Mcs11_Mcs08, RTL_R32(rTxAGC_A_Mcs11_Mcs08));
+		panic_printk(" A_Mcs15_Mcs12(0x%03x):     0x%08x\n", rTxAGC_A_Mcs15_Mcs12, RTL_R32(rTxAGC_A_Mcs15_Mcs12));
+		panic_printk(" B_Rate18_06(0x%03x):       0x%08x\n", rTxAGC_B_Rate18_06, RTL_R32(rTxAGC_B_Rate18_06));
+		panic_printk(" B_Rate54_24(0x%03x):       0x%08x\n", rTxAGC_B_Rate54_24, RTL_R32(rTxAGC_B_Rate54_24));
+		panic_printk(" B_Mcs03_Mcs00(0x%03x):     0x%08x\n", rTxAGC_B_Mcs03_Mcs00, RTL_R32(rTxAGC_B_Mcs03_Mcs00));
+		panic_printk(" B_Mcs07_Mcs04(0x%03x):     0x%08x\n", rTxAGC_B_Mcs07_Mcs04, RTL_R32(rTxAGC_B_Mcs07_Mcs04));
+		panic_printk(" B_Mcs11_Mcs08(0x%03x):     0x%08x\n", rTxAGC_B_Mcs11_Mcs08, RTL_R32(rTxAGC_B_Mcs11_Mcs08));
+		panic_printk(" B_Mcs15_Mcs12(0x%03x):     0x%08x\n", rTxAGC_B_Mcs15_Mcs12, RTL_R32(rTxAGC_B_Mcs15_Mcs12));
+		return;
+	}
+
+	panic_printk("\nMAC Registers:\n");
+	for (i=0; i<0x1000; i+=0x10) {
+		len = snprintf((char *)tmpbuf, sizeof(tmpbuf), "%03X\t", i);
+		for (j=i; j<i+0x10; j+=4)
+			len += snprintf((char *)(tmpbuf+len), sizeof(tmpbuf)-len, "%08X ", (unsigned int)RTL_R32(j));
+		panic_printk("%s\n", (char *)tmpbuf);
+	}
+	panic_printk("\n");
+
+	panic_printk("\nRF Registers:\n");
+	len = 0;
+
+	{
+		unsigned int rf_reg_offset = 0x34; /* RTL8192C/RTL8188R */
+#ifdef CONFIG_RTL_92D_SUPPORT
+		if (GET_CHIP_VER(priv) == VERSION_8192D)
+			rf_reg_offset = 0x50;
+#endif
+#ifdef CONFIG_RTL_88E_SUPPORT
+		if (GET_CHIP_VER(priv) == VERSION_8188E)
+			rf_reg_offset = 0xff;
+#endif
+#ifdef CONFIG_RTL_8812_SUPPORT
+		if (GET_CHIP_VER(priv) == VERSION_8812E)
+			rf_reg_offset = 0xff;
+#endif
+#ifdef CONFIG_WLAN_HAL
+        if (IS_HAL_CHIP(priv)) {
+            rf_reg_offset = 0xff;
+        }
+#endif //CONFIG_WLAN_HAL
+
+		for (i = RF92CD_PATH_A; i < priv->pshare->phw->NumTotalRFPath; i++) {
+			for (j = 0; j <= rf_reg_offset; j++) {
+				len += snprintf((char *)(tmpbuf+len), sizeof(tmpbuf)-len, "%d%02x  %05x",
+					i, j, PHY_QueryRFReg(priv, i, j, bMask20Bits, 1));
+
+				if (j && !((j+1)%4)) {
+					panic_printk("%s\n", (char *)tmpbuf);
+					len = 0;
+				} else
+					len += snprintf((char *)(tmpbuf+len), sizeof(tmpbuf)-len, "     ");
+			}
+			panic_printk("%s\n", (len) ? (char *)tmpbuf : "");
+		}
+	}
+}
+#endif // _IOCTL_DEBUG_CMD_
+
+
+/*
+ * data: byte 0 ~ byte 11 is mac addr
+ *       if byte 12 & 13 is "no", will NOT send disasoc request
+ *       else will send disasoc request
+ */
+int del_sta(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+	struct stat_info *pstat;
+	unsigned char macaddr[MACADDRLEN], tmpbuf[3];
+#ifndef SMP_SYNC
+	unsigned long flags;
+#endif
+	int i, send_disasoc=1;
+
+	if (!netif_running(priv->dev))
+		return 0;
+
+	for(i=0; i<MACADDRLEN; i++)
+	{
+		tmpbuf[0] = data[2*i];
+		tmpbuf[1] = data[2*i+1];
+		tmpbuf[2] = 0;
+		macaddr[i] = (unsigned char)_atoi((char *)tmpbuf, 16);
+	}
+
+	if ((data[12] == 'n') && (data[13] == 'o'))
+		send_disasoc = 0;
+
+	DEBUG_INFO("del_sta %02X%02X%02X%02X%02X%02X\n",
+		macaddr[0], macaddr[1], macaddr[2], macaddr[3], macaddr[4], macaddr[5]);
+
+	pstat = get_stainfo(priv, macaddr);
+
+	if (pstat == NULL)
+		return 0;
+
+#if defined(WDS)
+	if(pstat->state & WIFI_WDS) {
+		DEBUG_INFO("%02X%02X%02X%02X%02X%02X is an WDS peer, dismissed\n",
+			macaddr[0], macaddr[1], macaddr[2], macaddr[3], macaddr[4], macaddr[5]);
+
+		return 0;
+	}
+#endif
+
+	return del_station(priv, pstat, send_disasoc);
+}
+
+
+static int write_eeprom(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+	return -1;
+}
+
+
+static int read_eeprom(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+	return -1;
+}
+
+
+static void get_sta_info(struct rtl8192cd_priv *priv, sta_info_2_web *pInfo, int size
+#ifdef RTK_WOW
+				,unsigned int wakeup_on_wlan
+#endif
+				)
+{
+	struct list_head *phead, *plist;
+	struct stat_info *pstat;
+	struct net_device *dev = priv->dev;
+	int i;
+
+	memset((char *)pInfo, '\0', sizeof(sta_info_2_web)*size);
+
+	phead = &priv->asoc_list;
+	if (!(priv->drv_state & DRV_STATE_OPEN) || list_empty(phead))
+		return;
+
+	plist = phead;
+	while (((plist = asoc_list_get_next(priv, plist)) != phead) && (size > 0))
+	{
+		pstat = list_entry(plist, struct stat_info, asoc_list);
+		
+		if ((pstat->state & WIFI_ASOC_STATE) &&
+			((pstat->expire_to > 0)
+#ifdef RTK_WOW
+			|| wakeup_on_wlan
+#endif
+			)
+#ifdef CONFIG_RTK_MESH
+			&& (!(GET_MIB(priv)->dot1180211sInfo.mesh_enable) || isSTA(pstat))	// STA ONLY
+#endif
+#ifdef RTK_WOW
+			&& (!wakeup_on_wlan || pstat->is_rtk_wow_sta)
+#endif
+#ifdef WDS
+			&& !(pstat->state & WIFI_WDS)
+#endif
+		) {
+			pInfo->aid = pstat->aid;
+			memcpy(pInfo->addr, pstat->hwaddr, 6);
+			pInfo->tx_packets = pstat->tx_pkts;
+			pInfo->rx_packets = pstat->rx_pkts;
+			pInfo->expired_time = pstat->expire_to * 100; /*1s to 10ms unit*/
+			pInfo->flags = STA_INFO_FLAG_ASOC;
+			if (!list_empty(&pstat->sleep_list))
+				pInfo->flags |= STA_INFO_FLAG_ASLEEP;
+			pInfo->TxOperaRate = pstat->current_tx_rate;
+			pInfo->RxOperaRate = pstat->rx_rate;
+#ifdef TLN_STATS
+			pInfo->enc_type = pstat->dot11KeyMapping.dot11Privacy;
+
+			if (priv->pmib->dot1180211AuthEntry.dot11EnablePSK) {
+				if (pstat->wpa_sta_info->RSNEnabled & PSK_WPA2)
+					pInfo->auth_type = STATS_PSK_WPA2;
+				else 
+					pInfo->auth_type = STATS_PSK_WPA;
+			} else if (IEEE8021X_FUN && ((pstat->dot11KeyMapping.dot11Privacy != _WEP_40_PRIVACY_) && 
+				(pstat->dot11KeyMapping.dot11Privacy != _WEP_104_PRIVACY_))) {
+				if (pstat->enterpise_wpa_info == STATS_ETP_WPA2)
+					pInfo->auth_type = STATS_ETP_WPA2;
+				else 
+					pInfo->auth_type = STATS_ETP_WPA;
+			} else {
+				 if (pstat->AuthAlgrthm)
+				 	pInfo->auth_type = STATS_AUTH_SHARE;
+				 else
+				 	pInfo->auth_type = STATS_AUTH_OPEN;
+			}
+#endif
+			pInfo->rssi = pstat->rssi;
+			pInfo->link_time = pstat->link_time;
+			pInfo->tx_fail = pstat->tx_fail;
+			pInfo->tx_bytes = pstat->tx_bytes;
+			pInfo->rx_bytes = pstat->rx_bytes;
+
+			if (priv->pmib->dot11BssType.net_work_type & WIRELESS_11A)
+				pInfo->network = WIRELESS_11A;
+			else if (priv->pmib->dot11BssType.net_work_type & WIRELESS_11G) {
+				if (!isErpSta(pstat))
+					pInfo->network = WIRELESS_11B;
+				else {
+					pInfo->network = WIRELESS_11G;
+					for (i=0; i<STAT_OPRATE_LEN; i++) {
+						if (is_CCK_rate(STAT_OPRATE[i])) {
+							pInfo->network |= WIRELESS_11B;
+							break;
+						}
+					}
+				}
+			}
+			else // 11B only
+				pInfo->network = WIRELESS_11B;
+			if (priv->pmib->dot11BssType.net_work_type & WIRELESS_11N) {
+				if (pstat->ht_cap_len) {
+					pInfo->network |= WIRELESS_11N;
+					if (pstat->ht_current_tx_info & TX_USE_40M_MODE)
+						pInfo->ht_info |= TX_USE_40M_MODE;
+					if (pstat->ht_current_tx_info & TX_USE_SHORT_GI)
+						pInfo->ht_info |= TX_USE_SHORT_GI;
+				}
+			}
+			if (priv->pmib->dot11BssType.net_work_type & WIRELESS_11AC)
+			{
+#ifdef CONFIG_RTL_8812_SUPPORT	
+				if(pstat ->vht_cap_len) {
+					if(pstat->tx_bw == HT_CHANNEL_WIDTH_80)
+						pInfo->ht_info |= TX_USE_80M_MODE;
+ 					if (pstat->ht_current_tx_info & TX_USE_40M_MODE)
+						pInfo->ht_info |= TX_USE_40M_MODE;
+					if (pstat->ht_current_tx_info & TX_USE_SHORT_GI)
+						pInfo->ht_info |= TX_USE_SHORT_GI;
+
+					pInfo->acTxOperaRate = query_vht_rate(pstat);
+					pInfo->network |= WIRELESS_11AC;
+				}
+#endif
+			}
+			pInfo++;
+			size--;
+		}
+	}
+}
+
+#ifdef _SINUX_
+/*
+ *  return 1: if mac is wlan client MAC, 0: if not.
+ */
+int rtl8192cd_check_wlan_mac(char *wlan_ifname, unsigned char *mac)
+{
+    struct net_device	*net_dev;
+	struct rtl8192cd_priv	*priv;
+
+	struct list_head *phead, *plist;
+	struct stat_info *pstat;
+	int ret = 0;
+#ifdef SMP_SYNC
+	unsigned long flags = 0;
+#endif
+
+    if (mac == NULL)
+        return 0;
+
+    net_dev = dev_get_by_name(wlan_ifname);
+    if (net_dev == NULL)
+    {
+        printk("rtl8192cd_check_wlan_mac(): can not get dev %s\n", wlan_ifname);
+        return 0;
+    }
+    priv = (struct rtl8192cd_priv *)net_dev -> priv;
+
+	phead = &priv->asoc_list;
+	if (!netif_running(net_dev) || list_empty(phead)){
+		dev_put(net_dev);
+		return 0;
+	}
+
+	SMP_LOCK_ASOC_LIST(flags);
+
+	plist = phead->next;
+	while (plist != phead)
+	{
+		pstat = list_entry(plist, struct stat_info, asoc_list);
+		plist = plist->next;
+		if ((pstat->state & WIFI_ASOC_STATE) && (pstat->expire_to > 0)
+#ifdef WDS
+			&& !(pstat->state & WIFI_WDS)
+#endif
+		) {
+            if (memcmp(mac, pstat->hwaddr,6) == 0) {
+                ret = 1;
+                break;
+            }
+        }
+	}
+
+	SMP_UNLOCK_ASOC_LIST(flags);
+
+    dev_put(net_dev);
+
+    return ret;
+}
+
+typedef struct tag_ASSOCIATE_TABLE{
+    char mac[6];
+    /* err: 0: no error 1: error */
+    char err;
+}ASSOCIATE_TABLE, *PASSOCIATE_TABLE;
+
+int rtl8192cd_getMacTable(char *wlan_ifname,  ASSOCIATE_TABLE *mac_table, int table_num)
+{
+    struct net_device	*net_dev;
+	struct rtl8192cd_priv	*priv;
+
+	struct list_head *phead, *plist;
+	struct stat_info *pstat;
+	int ret = 0;
+#ifdef SMP_SYNC
+	unsigned long flags = 0;
+#endif
+
+
+    net_dev = dev_get_by_name(wlan_ifname);
+    if (net_dev == NULL)
+    {
+        printk("rtl8192cd_check_wlan_mac(): can not get dev %s\n", wlan_ifname);
+        return -1;
+    }
+    priv = (struct rtl8192cd_priv *)net_dev -> priv;
+
+
+	phead = &priv->asoc_list;
+	if (!netif_running(net_dev) || list_empty(phead))
+	{
+		dev_put(net_dev);
+		return -1;
+	}
+
+	SMP_LOCK_ASOC_LIST(flags);
+
+	plist = phead->next;
+	while (plist != phead && table_num > 0 )
+	{
+		pstat = list_entry(plist, struct stat_info, asoc_list);
+		plist = plist->next;
+		if ((pstat->state & WIFI_ASOC_STATE) && (pstat->expire_to > 0)
+#ifdef WDS
+			&& !(pstat->state & WIFI_WDS)
+#endif
+		) {
+            memcpy(mac_table->mac, pstat->hwaddr, 6);
+            mac_table ++;
+            table_num --;
+            ret ++;
+        }
+	}
+
+	SMP_UNLOCK_ASOC_LIST(flags);
+
+    dev_put(net_dev);
+
+    return ret;
+}
+
+#endif
+
+static void get_bss_info(struct rtl8192cd_priv *priv, bss_info_2_web *pBss)
+{
+	struct net_device *dev = priv->dev;
+#ifdef CLIENT_MODE
+	struct stat_info *pstat;
+#endif
+
+	memset(pBss, '\0', sizeof(bss_info_2_web));
+
+	if (!netif_running(dev)) {
+		pBss->state = STATE_DISABLED;
+		return;
+	}
+
+	if (priv->pmib->miscEntry.func_off) {
+		pBss->state = STATE_DISABLED;
+		return;
+	}
+
+	if (OPMODE & WIFI_AP_STATE)
+		pBss->state = STATE_STARTED;
+#ifdef CLIENT_MODE
+	else {
+		switch (JOIN_RES) {
+		case STATE_Sta_No_Bss:
+			pBss->state = STATE_SCANNING;
+			break;
+		case STATE_Sta_Bss:
+			if (IEEE8021X_FUN) {
+				pstat = get_stainfo(priv, BSSID);
+				if (pstat == NULL)
+					return;
+				if (pstat->ieee8021x_ctrlport)
+					pBss->state = STATE_CONNECTED;
+				else
+					pBss->state = STATE_WAITFORKEY;
+			}
+			else
+				pBss->state = STATE_CONNECTED;
+			break;
+		case STATE_Sta_Ibss_Active:
+			pBss->state = STATE_CONNECTED;
+			break;
+		case STATE_Sta_Ibss_Idle:
+			pBss->state = STATE_STARTED;
+			break;
+		default:
+			pBss->state = STATE_SCANNING;
+			break;
+		}
+	}
+#endif
+
+	if (priv->pmib->dot11StationConfigEntry.autoRate)
+		pBss->txRate = find_rate(priv, NULL, 1, 0);
+	else
+		pBss->txRate = get_rate_from_bit_value(priv->pmib->dot11StationConfigEntry.fixedTxRate);
+	memcpy(pBss->ssid, SSID, SSID_LEN);
+	pBss->ssid[SSID_LEN] = '\0';
+	if (OPMODE & WIFI_SITE_MONITOR)
+		pBss->channel = priv->site_survey->ss_channel;
+	else
+		pBss->channel = priv->pmib->dot11RFEntry.dot11channel;
+
+	if (pBss->state == STATE_STARTED || pBss->state == STATE_CONNECTED) {
+#ifdef UNIVERSAL_REPEATER
+		if (IS_VXD_INTERFACE(priv) && (OPMODE & WIFI_AP_STATE))
+			if (IS_DRV_OPEN(priv))
+				memcpy(pBss->bssid, priv->pmib->dot11Bss.bssid, MACADDRLEN);
+			else
+				memset(pBss->bssid, '\0', MACADDRLEN);
+		else
+#endif
+		memcpy(pBss->bssid, BSSID, MACADDRLEN);
+#ifdef CLIENT_MODE
+		if (JOIN_RES == STATE_Sta_Bss) {
+			pstat = get_stainfo(priv, BSSID);
+			if (pstat) {
+				pBss->rssi = pstat->rssi;
+				pBss->sq = pstat->sq;
+			}
+		}
+#endif
+	}
+	else {
+		memset(pBss->bssid, '\0', MACADDRLEN);
+		if (pBss->state == STATE_DISABLED)
+			pBss->channel = 0;
+	}
+}
+
+
+#ifdef WDS
+static int get_wds_info(struct rtl8192cd_priv *priv, web_wds_info *pWds)
+{
+	int i, j=0;
+	struct stat_info *pstat;
+
+	memset(pWds, '\0', NUM_WDS*sizeof(web_wds_info));
+
+	for (j=0, i=0; i<NUM_WDS && i<priv->pmib->dot11WdsInfo.wdsNum; i++) {
+		if (!netif_running(priv->wds_dev[i]))
+			continue;
+
+		memcpy(pWds[j].addr, priv->pmib->dot11WdsInfo.entry[i].macAddr, 6);
+
+		pstat = get_stainfo(priv, pWds[j].addr);
+		if(NULL == pstat)
+			continue;
+
+		pWds[j].state = STATE_WDS_ACTIVE;
+		pWds[j].tx_packets = pstat->tx_pkts;
+		pWds[j].rx_packets = pstat->rx_pkts;
+		pWds[j].tx_errors = pstat->tx_fail;
+		pWds[j].TxOperaRate = pstat->current_tx_rate;
+		j++;
+	}
+
+	return (sizeof(web_wds_info)*j);
+}
+#endif // WDS
+
+
+static int set_sta_txrate(struct rtl8192cd_priv *priv, struct _wlan_sta_rateset *rate_set)
+{
+	struct stat_info *pstat;
+
+	if (!netif_running(priv->dev))
+		return 0;
+
+	pstat = get_stainfo(priv, rate_set->mac);
+	if (pstat == NULL)
+		return 0;
+	if (!(pstat->state & WIFI_ASOC_STATE))
+		return 0;
+	if (priv->pmib->dot11StationConfigEntry.autoRate) {
+		DEBUG_INFO("Auto rate turned on. Can't set rate\n");
+		return 0;
+	}
+
+	pstat->current_tx_rate = rate_set->txrate;
+	return 1;
+}
+
+
+#ifdef MICERR_TEST
+static int issue_mic_err_pkt(struct rtl8192cd_priv *priv, unsigned char *cli_mac)
+{
+	struct sk_buff *skb;
+	struct wlan_ethhdr_t *pethhdr;
+
+	skb = dev_alloc_skb(64);
+	if (skb != NULL) {
+		skb->dev = priv->dev;
+		pethhdr = (struct wlan_ethhdr_t *)(skb->data);
+		if (!(OPMODE & WIFI_STATION_STATE)) {
+			unsigned char null_mac[]={0,0,0,0,0,0};
+			if (!memcmp(cli_mac, null_mac, MACADDRLEN)) {
+				printk("Usage: iwpriv wlanx mic_error [cli_mac_addr]\n");
+				return 0;
+			}
+			printk("%s() Send MIC error packet to %02X:%02X:%02X:%02X:%02X:%02X\n",__func__,cli_mac[0],cli_mac[1],cli_mac[2],cli_mac[3],cli_mac[4],cli_mac[5]);
+			memcpy(pethhdr->daddr, cli_mac, MACADDRLEN);
+		} else {
+			printk("Send MIC error packet to AP...\n");
+			memcpy(pethhdr->daddr, BSSID, MACADDRLEN);
+		}
+		memcpy(pethhdr->saddr, GET_MY_HWADDR, MACADDRLEN);
+		pethhdr->type = 0x888e;
+
+		memset(skb->data+WLAN_ETHHDR_LEN, 0xa5, 32);
+		skb_put(skb, WLAN_ETHHDR_LEN+32);
+
+		priv->micerr_flag = 1;
+		if (rtl8192cd_start_xmit(skb, priv->dev))
+			rtl_kfree_skb(priv, skb, _SKB_TX_);
+	} else {
+		printk("Can't allocate sk_buff\n");
+	}
+	return 0;
+}
+
+
+static int issue_mic_rpt_pkt(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+	struct sk_buff *skb;
+	struct wlan_ethhdr_t *pethhdr;
+	int format;
+	unsigned char pattern[] = {0x01, 0x03, 0x00, 0x5f, 0xfe, 0x0d, 0x00, 0x00};
+
+	if (!(OPMODE & WIFI_STATION_STATE)) {
+		printk("Fail: not in client mode\n");
+		return 0;
+	}
+
+	if (!strcmp(data, "xp"))
+		format = 1;
+	else if (!strcmp(data, "funk"))
+		format = 2;
+	else {
+		printk("Usage: iwpriv wlanx mic_report {xp | funk}\n");
+		return 0;
+	}
+
+	printk("Send MIC report (%s format) to AP...\n", (format==1)? "XP":"Funk");
+	skb = dev_alloc_skb(64);
+	if (skb != NULL)
+	{
+		skb->dev = priv->dev;
+		pethhdr = (struct wlan_ethhdr_t *)(skb->data);
+		memcpy(pethhdr->daddr, BSSID, MACADDRLEN);
+		memcpy(pethhdr->saddr, GET_MY_HWADDR, MACADDRLEN);
+		pethhdr->type = 0x888e;
+
+		if (format == 2)
+			pattern[5] = 0x0f;
+		memcpy(skb->data+WLAN_ETHHDR_LEN, pattern, sizeof(pattern));
+		skb_put(skb, WLAN_ETHHDR_LEN+sizeof(pattern));
+
+		if (rtl8192cd_start_xmit(skb, priv->dev))
+			rtl_kfree_skb(priv, skb, _SKB_TX_);
+	}
+	else
+	{
+		printk("Can't allocate sk_buff\n");
+	}
+	return 0;
+}
+#endif // MICERR_TEST
+
+
+#if defined(D_ACL) || defined(MICERR_TEST) 	//mesh related
+
+static int iwpriv_atoi(struct rtl8192cd_priv *priv, unsigned char *data, unsigned char *buf, int len, unsigned int buf_len)
+{
+	unsigned char tmpbuf[20] = {'\0'};
+	unsigned char ascii_addr[12] = {'\0'};
+	unsigned char hex_addr[6] = {'\0'};
+	int i=0;
+
+	if( (len - 1) == MACADDRLEN ){	//user send 6 byte mac address
+		if (buf_len < len) {
+			DEBUG_ERR("[%s] exceed in size\n", __func__);
+			return -1;
+		}
+		if(ioctl_copy_from_user(buf, (void *)data, len))
+			return -1;
+		return 0;
+	}
+	else if( (len - 1) == MACADDRLEN*2 ){ //user send 12 byte mac string
+		if (buf_len < MACADDRLEN*3+1) {
+			DEBUG_ERR("[%s] exceed in size\n", __func__);
+			return -1;
+		}
+		if(ioctl_copy_from_user(tmpbuf, (void *)data, len))
+			return -1;
+
+		memcpy(ascii_addr, tmpbuf, MACADDRLEN*2);
+		strcpy(buf+MACADDRLEN, tmpbuf);
+
+	  	for(i = 0; i < MACADDRLEN*2; i++){
+        	   	if( '0' <= ascii_addr[i]  && ascii_addr[i] <= '9')
+        			ascii_addr[i] -= 48;
+               		else if( 'A' <= ascii_addr[i] && ascii_addr[i] <= 'F' )
+                		ascii_addr[i] -= 55;
+			else if( 'a' <= ascii_addr[i] && ascii_addr[i] <= 'f' )
+				ascii_addr[i] -= 87;
+	                printk("%d", ascii_addr[i]);
+		}
+
+                for(i = 0; i < MACADDRLEN*2; i+=2)
+                	hex_addr[i>>1] = (ascii_addr[i] << 4) | (ascii_addr[i+1]);
+
+		memcpy(buf,hex_addr,MACADDRLEN);
+		_DEBUG_INFO("in iwpriv_atoi function\n");
+		return 0;
+	}
+	else{
+		_DEBUG_ERR("Wrong input format\n");
+		return -1;
+	}
+
+}
+#endif
+
+static int acl_add_cmd(struct rtl8192cd_priv *priv, unsigned char *data, int len)
+{
+	struct list_head		*phead, *plist, *pnewlist;
+	struct wlan_acl_node	*paclnode;
+	unsigned char macaddr[6];
+	int ret = 0;
+#ifdef SMP_SYNC
+	unsigned long flags = 0;
+#endif
+
+#ifdef D_ACL	//tsananiu	(mesh related)
+	unsigned char tmpbuf[20] = {'\0'};
+	unsigned char tmp_add[12] = {'\0'};
+	int i;
+	if(ioctl_copy_from_user(tmpbuf, (void *)data, len))
+		return -1;
+
+	if( (len - 1) == 6 ){	//user send 6 byte mac address
+		for(i = 0; i < 6; i++)
+			macaddr[i] = tmpbuf[i];
+	}
+	else if( (len - 1) == 12 ){ //user send 12 byte mac string
+
+		memcpy(tmp_add, tmpbuf, 12);
+
+	  	for(i = 0; i < 12; i++){
+        	   	if( '0' <= tmp_add[i]  && tmp_add[i] <= '9')
+        			tmp_add[i] -= 48;
+               		else if( 'A' <= tmp_add[i] && tmp_add[i] <= 'F' )
+                		tmp_add[i] -= 55;
+			else if( 'a' <= tmp_add[i] && tmp_add[i] <= 'f' )
+				tmp_add[i] -= 87;
+	                printk("%d", tmp_add[i]);
+		}
+
+                for(i = 0; i < 12; i+=2){
+                	macaddr[i>>1] = (tmp_add[i] << 4) | (tmp_add[i+1]);
+                }
+	}
+
+	else{
+		printk("Wrong input format\n");
+		return -1;
+	}
+	DEBUG_INFO("in add function\n");
+	len = 6;
+#else
+	if (ioctl_copy_from_user((void *)macaddr, (void *)data, 6))
+		return -1;
+#endif//tsananiu//
+
+	if (!IS_DRV_OPEN(priv)) {
+		DEBUG_INFO("Interface closed, return!\n");
+		return -1;
+	}
+
+	// first of all, check if this address has been in acl_list;
+	phead = &priv->wlan_acl_list;
+
+	DEBUG_INFO("Adding %02X:%02X:%02X:%02X:%02X:%02X to acl_table\n",
+				macaddr[0],macaddr[1],macaddr[2],
+				macaddr[3],macaddr[4],macaddr[5]);
+	
+	SMP_LOCK_ACL(flags);
+
+	plist = phead->next;
+	
+	while(plist != phead)
+	{
+		paclnode = list_entry(plist, struct wlan_acl_node, list);
+		plist = plist->next;
+
+		if (!(memcmp((void *)macaddr, paclnode->addr, 6)))
+		{
+			DEBUG_INFO("mac-addr %02X%02X%02X%02X%02X%02X has been in acl_list\n",
+					macaddr[0], macaddr[1], macaddr[2],
+					macaddr[3], macaddr[4], macaddr[5]);
+			ret = 0;
+			goto exit;
+		}
+	}
+
+	if (list_empty(&priv->wlan_aclpolllist))
+	{
+		DEBUG_INFO("acl_poll is full!\n");
+		ret = -1;
+		goto exit;
+	}
+
+	pnewlist = (priv->wlan_aclpolllist.next);
+	list_del_init(pnewlist);
+
+	paclnode = list_entry(pnewlist, struct wlan_acl_node, list);
+
+	memcpy((void *)paclnode->addr, macaddr, 6);
+
+	if (len == 6)
+		paclnode->mode = (unsigned char)priv->pmib->dot11StationConfigEntry.dot11AclMode;
+	else
+		paclnode->mode = data[6];
+
+	list_add_tail(pnewlist, phead);
+
+exit:
+	SMP_UNLOCK_ACL(flags);
+
+	return ret;
+}
+
+
+static int acl_remove_cmd(struct rtl8192cd_priv *priv, unsigned char *data, int len)
+{
+	struct list_head *phead, *plist;
+	struct wlan_acl_node *paclnode;
+	unsigned char macaddr[6];
+#ifdef SMP_SYNC
+	unsigned long flags = 0;
+#endif
+
+	if (!data)
+		return 0;
+	
+#ifdef D_ACL	//tsananiu	(mesh related)
+	int i;
+	unsigned char tmpbuf[20] = {'\0'};
+	unsigned char tmp_add[12] = {'\0'};
+
+	if(ioctl_copy_from_user(tmpbuf, (void *)data, len))
+		return -1;
+
+	if( (len - 1) == 6 ){	//user send 6 byte mac address
+		for(i = 0; i < 6; i++)
+			macaddr[i] = tmpbuf[i];
+	}
+	else if( (len - 1) == 12 ){ //user send 12 byte mac string
+
+		memcpy(tmp_add, tmpbuf, 12);
+
+	  	for(i = 0; i < 12; i++){
+        	   	if( '0' <= tmp_add[i]  && tmp_add[i] <= '9')
+        			tmp_add[i] -= 48;
+               		else if( 'A' <= tmp_add[i] && tmp_add[i] <= 'F' )
+                		tmp_add[i] -= 55;
+			else if( 'a' <= tmp_add[i] && tmp_add[i] <= 'f' )
+				tmp_add[i] -= 87;
+	                DEBUG_INFO("%d", tmp_add[i]);
+		}
+
+                for(i = 0; i < 12; i+=2){
+                	macaddr[i>>1] = (tmp_add[i] << 4) | (tmp_add[i+1]);
+                }
+	}
+	else{
+		DEBUG_ERR("Wrong input format\n");
+		return -1;
+	}
+	DEBUG_INFO("in remove function\n");
+	DEBUG_INFO("%02X:%02X:%02X:%02X:%02X:%02X\n",
+                macaddr[0],macaddr[1],macaddr[2],
+                macaddr[3],macaddr[4],macaddr[5]);
+	//len = 6;
+#else
+	if (ioctl_copy_from_user((void *)macaddr, (void *)data, 6))
+		return -1;
+
+	DEBUG_INFO("Delete %X:%X:%X:%X:%X:%X to acl_table\n",
+			macaddr[0],macaddr[1],macaddr[2],
+			macaddr[3],macaddr[4],macaddr[5]);
+#endif//tsananiu//
+
+	if (!IS_DRV_OPEN(priv)) {
+		DEBUG_INFO("Interface closed, return!\n");
+		return -1;
+	}
+
+	phead = &priv->wlan_acl_list;
+
+	if (list_empty(phead)) // nothing to remove
+		return 0;
+
+	SMP_LOCK_ACL(flags);
+
+	plist = phead->next;
+
+	while(plist != phead)
+	{
+		paclnode = list_entry(plist, struct wlan_acl_node, list);
+		plist = plist->next;
+
+		if (!(memcmp((void *)macaddr, paclnode->addr, 6)))
+		{
+			list_del_init(&paclnode->list);
+			list_add_tail(&paclnode->list, &priv->wlan_aclpolllist);
+			goto exit;
+		}
+	}
+
+	if (data) {
+		DEBUG_INFO("Delete %02X:%02X:%02X:%02X:%02X:%02X is not in acl_table\n",
+                macaddr[0],macaddr[1],macaddr[2],
+                macaddr[3],macaddr[4],macaddr[5]);
+	}
+exit:
+	SMP_UNLOCK_ACL(flags);
+
+	return 0;
+}
+
+
+static int acl_query_cmd(struct rtl8192cd_priv *priv, unsigned char *data, u16 length)
+{
+	struct list_head	*phead, *plist;
+	struct wlan_acl_node	*paclnode;
+	unsigned char *tmp_buf;
+	int len = 0;
+#ifdef SMP_SYNC
+	unsigned long flags = 0;
+#endif
+
+	phead = &priv->wlan_acl_list;
+
+	if (list_empty(phead) || !IS_DRV_OPEN(priv)) // nothing to remove
+		return 0;
+
+	tmp_buf = (unsigned char *)kmalloc(length, GFP_KERNEL);
+	if (NULL == tmp_buf)
+		return -1;
+
+	SMP_LOCK_ACL(flags);
+	
+	plist = phead->next;
+
+	while (plist != phead) {
+		paclnode = list_entry(plist, struct wlan_acl_node, list);
+		plist = plist->next;
+
+		if ((len + MACADDRLEN) > length)
+			break;
+
+		memcpy(&tmp_buf[len], paclnode->addr, MACADDRLEN);
+		len += MACADDRLEN;
+	}
+
+	SMP_UNLOCK_ACL(flags);
+	
+	if (len) {
+		if (ioctl_copy_to_user((void *)data, tmp_buf, len)) {
+			len = -1;
+		}
+	}
+	kfree(tmp_buf);
+
+	return len;
+}
+
+
+static int acl_clear_cmd(struct rtl8192cd_priv *priv)
+{
+	struct list_head *phead, *plist;
+	struct wlan_acl_node *paclnode;
+#ifdef SMP_SYNC
+	unsigned long flags = 0;
+#endif
+
+	phead = &priv->wlan_acl_list;
+
+	if (list_empty(phead) || !IS_DRV_OPEN(priv)) // nothing to remove
+		return 0;
+
+	SMP_LOCK_ACL(flags);
+
+	plist = phead->next;
+
+	while(plist != phead)
+	{
+		paclnode = list_entry(plist, struct wlan_acl_node, list);
+		plist = plist->next;
+		list_del_init(&paclnode->list);
+		list_add_tail(&paclnode->list, &priv->wlan_aclpolllist);
+	}
+
+	SMP_UNLOCK_ACL(flags);
+
+	return 0;
+}
+
+
+#if defined(CONFIG_RTK_MESH) && defined(_MESH_ACL_ENABLE_)
+// Copy from acl_add_cmd
+static int mesh_acl_add_cmd(struct rtl8192cd_priv *priv, unsigned char *data, int len)
+{
+	struct list_head		*phead, *plist, *pnewlist;
+	struct wlan_acl_node	*paclnode;
+	unsigned char macaddr[MACADDRLEN];
+#ifdef SMP_SYNC
+	unsigned long flags = 0;
+#endif
+
+	if (ioctl_copy_from_user((void *)macaddr, (void *)data, MACADDRLEN))
+		return -1;
+
+	// first of all, check if this address has been in acl_list;
+	phead = &priv->mesh_acl_list;
+
+	DEBUG_INFO("Adding %X:%X:%X:%X:%X:%X to mesh_acl_table\n",
+				macaddr[0],macaddr[1],macaddr[2],
+				macaddr[3],macaddr[4],macaddr[5]);
+
+	SMP_LOCK_MESH_ACL(flags);
+
+	plist = phead->next;
+	while(plist != phead)
+	{
+		paclnode = list_entry(plist, struct wlan_acl_node, list);
+		plist = plist->next;
+
+		if (!(memcmp((void *)macaddr, paclnode->addr, MACADDRLEN)))
+		{
+			DEBUG_INFO("mac-addr %02X%02X%02X%02X%02X%02X has been in mesh_acl_list\n",
+					macaddr[0], macaddr[1], macaddr[2],
+					macaddr[3], macaddr[4], macaddr[5]);
+			goto exit;
+		}
+	}
+
+	if (list_empty(&priv->mesh_aclpolllist))
+	{
+		DEBUG_INFO("mesh_acl_poll is full!\n");
+		goto exit;
+	}
+
+	pnewlist = (priv->mesh_aclpolllist.next);
+	list_del_init(pnewlist);
+
+	paclnode = list_entry(pnewlist, struct wlan_acl_node, list);
+
+	memcpy((void *)paclnode->addr, macaddr, MACADDRLEN);
+
+	if (len == 6)
+		paclnode->mode = (unsigned char)priv->pmib->dot1180211sInfo.mesh_acl_mode;
+	else
+		paclnode->mode = data[6];
+
+	list_add_tail(pnewlist, phead);
+
+exit:
+	SMP_UNLOCK_MESH_ACL(flags);
+
+	return 0;
+}
+
+
+// Copy from acl_remove_cmd
+static int mesh_acl_remove_cmd(struct rtl8192cd_priv *priv, unsigned char *data, int len)
+{
+	struct list_head *phead, *plist;
+	struct wlan_acl_node *paclnode;
+	unsigned char macaddr[MACADDRLEN];
+#ifdef SMP_SYNC
+	unsigned long flags = 0;
+#endif
+
+	if (data) {
+		if (ioctl_copy_from_user((void *)macaddr, (void *)data, 6))
+			return -1;
+
+		DEBUG_INFO("Delete %X:%X:%X:%X:%X:%X to mesh_acl_table\n",
+				macaddr[0],macaddr[1],macaddr[2],
+				macaddr[3],macaddr[4],macaddr[5]);
+	}
+
+	phead = &priv->mesh_acl_list;
+
+	if (list_empty(phead)) // nothing to remove
+		return 0;
+
+	SMP_LOCK_MESH_ACL(flags);
+
+	plist = phead->next;
+	while(plist != phead)
+	{
+		paclnode = list_entry(plist, struct wlan_acl_node, list);
+		plist = plist->next;
+
+		if (!(memcmp((void *)macaddr, paclnode->addr, MACADDRLEN)))
+		{
+			list_del_init(&paclnode->list);
+			list_add_tail(&paclnode->list, &priv->mesh_aclpolllist);
+			goto exit;
+		}
+	}
+
+	if (data) {
+		DEBUG_INFO("Delete %X:%X:%X:%X:%X:%X is not in mesh_acl_table\n",
+                macaddr[0],macaddr[1],macaddr[2],
+                macaddr[3],macaddr[4],macaddr[5]);
+	}
+exit:
+	SMP_UNLOCK_MESH_ACL(flags);
+
+	return 0;
+}
+
+
+// Copy from acl_query_cmd
+static int mesh_acl_query_cmd(struct rtl8192cd_priv *priv, unsigned char *data, u16 length)
+{
+	struct list_head	*phead, *plist;
+	struct wlan_acl_node	*paclnode;
+	unsigned char *tmp_buf;
+	int len = 0;
+#ifdef SMP_SYNC
+	unsigned long flags = 0;
+#endif
+
+	phead = &priv->mesh_acl_list;
+
+	if (list_empty(phead)) // nothing to remove
+		return 0;
+
+	tmp_buf = (unsigned char *)kmalloc(length, GFP_KERNEL);
+	if (NULL == tmp_buf)
+		return -1;
+
+	SMP_LOCK_MESH_ACL(flags);
+
+	plist = phead->next;
+	while (plist != phead) {
+		paclnode = list_entry(plist, struct wlan_acl_node, list);
+		plist = plist->next;
+
+		if ((len + MACADDRLEN) > length)
+			break;
+
+		memcpy(&tmp_buf[len], paclnode->addr, MACADDRLEN);
+		len += MACADDRLEN;
+	}
+
+	SMP_UNLOCK_MESH_ACL(flags);
+	
+	if (len) {
+		if (ioctl_copy_to_user((void *)data, tmp_buf, len)) {
+			len = -1;
+		}
+	}
+	kfree(tmp_buf);
+
+	return len;
+}
+#endif	// CONFIG_RTK_MESH && _MESH_ACL_ENABLE_
+
+
+static void get_misc_data(struct rtl8192cd_priv *priv, struct _misc_data_ *pdata)
+{
+	memset(pdata, '\0', sizeof(struct _misc_data_));
+
+	pdata->mimo_tr_hw_support = GET_HW(priv)->MIMO_TR_hw_support;
+
+	// get number of tx path
+	if (get_rf_mimo_mode(priv) == MIMO_1T2R)
+		pdata->mimo_tr_used = 1;
+	else if (get_rf_mimo_mode(priv) == MIMO_1T1R)
+		pdata->mimo_tr_used = 1;
+	else if (get_rf_mimo_mode(priv) == MIMO_2T2R)
+		pdata->mimo_tr_used = 2;
+	else if (get_rf_mimo_mode(priv) == MIMO_3T3R)
+		pdata->mimo_tr_used = 3;
+	else if (get_rf_mimo_mode(priv) == MIMO_4T4R)
+		pdata->mimo_tr_used = 4;
+	else	// MIMO_2T4R
+		pdata->mimo_tr_used = 2;
+
+	return;
+}
+
+
+#ifdef AUTO_TEST_SUPPORT
+static void rtl8192cd_SSReq_AutoTest(struct rtl8192cd_priv *priv)
+{
+	INT8 ret = 0;
+	//int i1;
+	//static int timerbeinit = 0;
+#if defined(MBSSID) && (defined(CONFIG_USB_HCI) || defined(CONFIG_SDIO_HCI))
+	if (IS_VAP_INTERFACE(priv))
+		return;
+#endif
+
+	#ifdef CONFIG_RTK_MESH
+	if((priv->auto_channel &0x30) && timer_pending(&priv->ss_timer))
+		ret = -2;
+	else
+	#endif
+	if (!netif_running(priv->dev) || priv->ss_req_ongoing)
+		ret = -1;
+	else
+		ret = 0;
+
+	if (!ret)	// now, let's start site survey
+	{
+		priv->ss_ssidlen = 0;
+		DEBUG_INFO("start_clnt_ss, trigger by %s, ss_ssidlen=0\n", (char *)__FUNCTION__);
+		priv->ss_req_ongoing = 1;
+		start_clnt_ss(priv);
+	}else{
+		return ;
+	}
+}
+
+
+#ifdef CLIENT_MODE
+
+#if defined(WIFI_WPAS) || defined(RTK_NL80211)
+int check_bss_encrypt(struct rtl8192cd_priv *priv)
+#else
+static int check_bss_encrypt(struct rtl8192cd_priv *priv)
+#endif
+{
+
+#if defined(CONFIG_RTL_WAPI_SUPPORT)
+	//	WAPI
+	if (priv->pmib->wapiInfo.wapiType!=wapiDisable
+		|| priv->pmib->dot1180211AuthEntry.dot11PrivacyAlgrthm==_WAPI_SMS4_)
+	{
+		if ((priv->pmib->dot11Bss.capability & BIT(4)) == 0)
+			return FAIL;
+		else if (priv->pmib->dot11Bss.t_stamp[0] != SECURITY_INFO_WAPI)
+			return FAIL;
+		else
+			return SUCCESS;
+	} else
+#endif
+	// no encryption
+	if (priv->pmib->dot1180211AuthEntry.dot11PrivacyAlgrthm == 0)
+	{
+		if (priv->pmib->dot11Bss.capability & BIT(4))
+			return FAIL;
+		else
+			return SUCCESS;
+	}
+	// legacy encryption
+	else if (!IEEE8021X_FUN &&
+		((priv->pmib->dot1180211AuthEntry.dot11PrivacyAlgrthm == _WEP_104_PRIVACY_) ||
+		 (priv->pmib->dot1180211AuthEntry.dot11PrivacyAlgrthm == _WEP_40_PRIVACY_)))
+	{
+		if ((priv->pmib->dot11Bss.capability & BIT(4)) == 0)
+			return FAIL;
+		else if (priv->pmib->dot11Bss.t_stamp[0] != 0)
+			return FAIL;
+		else
+			return SUCCESS;
+	}
+	// WPA/WPA2
+	else
+	{
+		if ((priv->pmib->dot11Bss.capability & BIT(4)) == 0)
+			return FAIL;
+		else if (priv->pmib->dot11Bss.t_stamp[0] == 0)
+			return FAIL;
+		else if ((priv->pmib->dot11RsnIE.rsnie[0] == _RSN_IE_1_) &&
+			((priv->pmib->dot11Bss.t_stamp[0] & 0x00000fff) == 0) &&
+			((priv->pmib->dot11Bss.t_stamp[2] & 0x000003ff) == 0))
+			return FAIL;
+		else if ((priv->pmib->dot11RsnIE.rsnie[0] == _RSN_IE_2_) &&
+			((priv->pmib->dot11Bss.t_stamp[0] & 0x0fff0000) == 0) &&
+			((priv->pmib->dot11Bss.t_stamp[2] & 0x03ff0000) == 0))
+			return FAIL;
+		else
+			return SUCCESS;
+	}
+}
+
+
+static int rtl8192cd_join_AutoTest(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+	INT8 ret = 0;
+
+	char tmpbuf[33];
+	char SSID123[34];
+	int ix  = 0;
+	int found = 0 ;
+
+
+	if (!netif_running(priv->dev))
+		ret = 2;
+	else if (priv->ss_req_ongoing)
+		ret = 1;
+	else
+		ret = 0;
+
+	if (ioctl_copy_from_user((void *)SSID123, (void *)data, 33) ){
+		panic_printk("copy SSID fail!!\n");
+		return -1;
+	}
+
+	for(ix = 0 ; ix < priv->site_survey->count_backup ; ix++){
+		if(!strcmp(priv->site_survey->bss_backup[ix].ssid , SSID123 )){
+				found = 1;
+				break;
+		}
+	}
+
+	if(found == 0){
+		ret = 3;
+		panic_printk("SSID not found!!\n");
+	}else{
+		memcpy((void *)&(priv->pmib->dot11Bss) ,
+		(void *)&priv->site_survey->bss_backup[ix] , sizeof(struct bss_desc));
+	}
+
+
+
+
+	if (!ret)	// now, let's start site survey and join
+	{
+
+
+#ifdef WIFI_SIMPLE_CONFIG
+		if (priv->pmib->wscEntry.wsc_enable && (priv->pmib->dot11Bss.bsstype&WIFI_WPS)) {
+			priv->pmib->dot11Bss.bsstype &= ~WIFI_WPS;
+			priv->wps_issue_join_req = 1;
+		}
+		else
+#endif
+		{
+			if (check_bss_encrypt(priv) == FAIL) {
+				DEBUG_INFO("Encryption mismatch!\n");
+				ret = 2;
+				if (ioctl_copy_to_user((void *)data, (void *)&ret, 1))
+					return -1;
+				else
+					return 0;
+			}
+		}
+
+		if ((priv->pmib->dot11Bss.ssidlen == 0) || (priv->pmib->dot11Bss.ssid[0] == '\0')) {
+			DEBUG_INFO("Join to a hidden AP!\n");
+			ret = 2;
+			if (ioctl_copy_to_user((void *)data, (void *)&ret, 1))
+				return -1;
+			else
+				return 0;
+		}
+
+#ifdef UNIVERSAL_REPEATER
+		disable_vxd_ap(GET_VXD_PRIV(priv));
+#endif
+
+		memcpy(tmpbuf, priv->pmib->dot11Bss.ssid, priv->pmib->dot11Bss.ssidlen);
+		tmpbuf[priv->pmib->dot11Bss.ssidlen] = '\0';
+		DEBUG_INFO("going to join bss: %s\n", tmpbuf);
+
+		panic_printk("going to join bss: %s\n", tmpbuf);
+
+		memcpy(SSID2SCAN, priv->pmib->dot11Bss.ssid, priv->pmib->dot11Bss.ssidlen);
+		SSID2SCAN_LEN = priv->pmib->dot11Bss.ssidlen;
+
+		SSID_LEN = SSID2SCAN_LEN;
+		memcpy(SSID, SSID2SCAN, SSID_LEN);
+		memset(BSSID, 0, MACADDRLEN);
+
+// button 2009.05.21
+// derive  PSK with slelected SSID
+#ifdef INCLUDE_WPA_PSK
+		if (priv->pmib->dot1180211AuthEntry.dot11EnablePSK)
+			derivePSK(priv);
+#endif
+		JOIN_REQ_ONGOING_VAL(1);
+		AUTH_MODE_RETRY_VAL(0);
+		start_clnt_join(priv);
+	}
+
+	return 0;
+}
+#endif
+#endif
+
+#ifdef CONFIG_8814_AP_MAC_VERI
+
+typedef enum _AP_MAC_VERI_8814_
+{
+   RetryLimitForEachMACID = 0x0,
+   LowestRetryRateInTXDESC,
+   ReleaseOnePKtbyMACIDeep,
+   AppendMACHeaderForRXpacket,
+   HWAutoAppendMACID,
+   HWSupportPowerStatedetect,
+}AP_MAC_VERI_8814,*PAP_MAC_VERI_8814;
+
+EXTERN void rtl88XX_tx_dsr(unsigned long task_priv);
+
+#ifdef CONFIG_8814_AP_MAC_VERI
+
+void RX_MAC_Verify_8814(struct rtl8192cd_priv *priv,unsigned char * pframe,struct rx_frinfo *pfrinfo)
+{
+     PRX_DESC_88XX                   prx_desc;
+    int i;
+    unsigned char macid;
+    unsigned char pattern[5] = {0x55,0x55,0x55,0x55,0x55};
+    unsigned char pwrBit;
+    unsigned char payLoadMACid;
+        
+    prx_desc                        = (PRX_DESC_88XX)(pframe-sizeof(RX_DESC_88XX));
+
+    if(!memcmp((pframe+pfrinfo->hdr_len),&pattern,5))
+    {
+
+       // printk("pfrinfo->macid = %x \n",pfrinfo->macid); 
+        // Verify MACID
+
+        payLoadMACid = *(pframe+pfrinfo->hdr_len+6);
+    #ifdef HW_FILL_MACID        
+        if(pfrinfo->macid == payLoadMACid)
+        {
+            printk("macID %x match \n",pfrinfo->macid);
+        }
+        else
+        {
+           printk("macID mismatch HW = %x SW = %x \n",pfrinfo->macid,payLoadMACid);
+
+           for(i=0 ; i<pfrinfo->hdr_len ;i++ )
+           {
+               printk("%02X ",*(pframe+i));
+        
+               if((i%16)==15)
+               {
+                   printk("\n");
+               }
+           }
+           printk("\n\n");
+        }
+    #endif //HW_FILL_MACID        
+            
+    #ifdef HW_DETEC_POWER_STATE
+        // Verify PowerBit
+        pwrBit = GetPwrMgt(pframe);
+        static u4Byte seq = 0;
+        static u4Byte carrier = 0;
+      
+
+        if(pfrinfo->macid != 0x7F) {
+            //if(priv->testResult == true)            
+            {
+                if(priv->pwrState[pfrinfo->macid]!= pwrBit) {
+                    priv->pwrStateCnt[pfrinfo->macid]++;                  
+
+                     RTL_W16(0x1a2,RTL_R16(0x1a2)+1);
+                     RTL_W16(0x1a6,priv->pwrStateCnt[pfrinfo->macid]);                     
+                     RTL_W8(0x1a5,pwrBit); 
+
+                       if(GetSequence(pframe)== 0xfff)
+                       {
+                           priv->sw_Carrier++;
+                           carrier++;
+                       }
+                   
+                   printk("[%s][%d]power state change at MACID:%x, Seq:%x, Cur Pwr:%x Cnt = %x HW pwr =%x HW seq=%x carrier =%x \n"
+                        ,__FUNCTION__,__LINE__,pfrinfo->macid,GetSequence(pframe),pwrBit,priv->pwrStateCnt[pfrinfo->macid],RTL_R8(0x1140),priv->hw_seq[0],carrier);
+
+                    // comapre HW&SW pwrBit,seq,Cnt
+                    if(pwrBit!= priv->pshare->HWPwroldState[pfrinfo->macid])
+                    {
+                       
+                        printk("MACID%x PwrStatus error SW=%x HW=%x \n",pfrinfo->macid,pwrBit,priv->pshare->HWPwroldState[pfrinfo->macid]);
+                        priv->testResult = false;
+                    }
+
+                    if(priv->pwrStateCnt[pfrinfo->macid]!= priv->pwrStateHWCnt[pfrinfo->macid])
+                    {
+                                           
+                        printk("MACID%x PwrStatus CNT error SW=%x HW=%x \n",
+                            pfrinfo->macid,priv->pwrStateCnt[pfrinfo->macid],priv->pwrStateHWCnt[pfrinfo->macid]);
+                        priv->testResult = false;
+                    }                    
+
+                    if(GetSequence(pframe)!= priv->hw_seq[pfrinfo->macid])
+                    {
+                        printk("MACID%x Sequence error SW=%x HW=%x sw_Carrier =%x hw_Carrier =%x \n",
+                        pfrinfo->macid,GetSequence(pframe),priv->hw_seq[0],priv->sw_Carrier,priv->hw_Carrier);
+                        priv->testResult = false;
+                    }
+
+                    if(priv->test_seq_MACID == pfrinfo->macid)
+                    {
+//                        if(GetSequence(pframe) < priv->hw_seq[pfrinfo->macid])
+                        if(GetSequence(pframe)!= priv->hw_seq[pfrinfo->macid])
+                        {
+                            printk("MACID%x Sequence error SW=%x HW=%x \n",
+                            pfrinfo->macid,GetSequence(pframe),priv->hw_seq[pfrinfo->macid]);
+                            priv->testResult = false;
+                        }
+                        else
+                        {
+                            printk("MACID%x Sequence pass \n",pfrinfo->macid);
+                        }
+                    }
+
+                    priv->test_seq_MACID = pfrinfo->macid+1;
+
+                    if(priv->test_seq_MACID == 127)
+                        priv->test_seq_MACID = 0;
+
+                    RTL_W8(0x1150,priv->test_seq_MACID);
+                    printk("MACID%x PASS CNT = %x \n",pfrinfo->macid,priv->pwrStateCnt[pfrinfo->macid]);
+                }
+                else
+                {
+                    printk("MACID%x No change \n",pfrinfo->macid);
+                }
+            }
+            priv->pwrState[pfrinfo->macid] = pwrBit;  
+            // compare seq number
+        }else {
+            printk("[%x][%d]MacId can't Read \n",__FUNCTION__,__LINE__);                
+        }
+
+    #endif   //  #ifdef HW_DETEC_POWER_STATE
+          
+    }         
+}
+
+#endif   //    #ifdef CONFIG_8814_AP_MAC_VERI
+
+
+static void issue_Test_NullData(struct rtl8192cd_priv *priv,unsigned char macID,unsigned char type)
+{
+	struct wifi_mib *pmib;
+//	unsigned char hwaddr[6] = {0x22,0x22,0x33,0x44,0x55,0x66};
+	unsigned char hwaddr[6] = {0x00,0x11,0x11,0x11,0x11,0x11};
+    unsigned char pattern[5] = {0x55,0x55,0x55,0x55,0x55};
+    unsigned char *pbuf;
+    unsigned char i;    
+    unsigned char pattern_len = 10;    
+	DECLARE_TXINSN(txinsn);
+
+	pmib = GET_MIB(priv);
+	txinsn.retry = pmib->dot11OperationEntry.dot11ShortRetryLimit;
+	//hwaddr = pmib->dot11OperationEntry.hwaddr;
+
+    //printk("issue_Test_NullData type = %x \n",type);
+
+    txinsn.q_num = type;
+   //  if txinsn.q_num = MGNT_QUEUE, test data retry 
+    // else test RTS retry 
+    
+	txinsn.fr_type = _PRE_ALLOCMEM_;    
+	txinsn.tx_rate = find_rate(priv, NULL, 0, 1);
+	txinsn.fixed_rate = 1;
+
+	txinsn.phdr = get_wlanhdr_from_poll(priv);
+
+	if (txinsn.phdr == NULL)
+	{
+        printk("txinsn.phdr NULL \n");
+		goto send_fail;    
+	}
+    
+    pbuf = txinsn.pframe = get_mgtbuf_from_poll(priv);    
+    if (txinsn.pframe == NULL)
+    {
+        printk("txinsn.pframe NULL \n");        
+        goto send_fail;
+    }
+
+	memset((void *)(txinsn.phdr), 0, sizeof (struct	wlan_hdr));
+
+	SetFrameSubType(txinsn.phdr, WIFI_DATA);
+	SetToDs(txinsn.phdr);
+    //SetMData(txinsn.phdr);
+
+	memcpy((void *)GetAddr1Ptr((txinsn.phdr)), hwaddr, MACADDRLEN);
+	memcpy((void *)GetAddr2Ptr((txinsn.phdr)), BSSID, MACADDRLEN);
+	memcpy((void *)GetAddr3Ptr((txinsn.phdr)),  BSSID, MACADDRLEN);
+	txinsn.hdr_len = 0; // hdr_len add in check_desc
+
+    memcpy(pbuf,pattern,5);
+    for(i=5 ;i < pattern_len ;i++)
+    {        
+        pbuf[i] = macID;
+
+    }
+    txinsn.fr_len = pattern_len;
+    priv->macID_temp = macID;
+
+    if ((rtl8192cd_firetx(priv, &txinsn)) == SUCCESS)
+	{
+        printk("MACID = %x tx ok \n",macID);
+		return;
+	}
+    else
+    {
+        printk("MACID = %x tx fail \n",macID);
+    }
+
+send_fail:
+
+	if (txinsn.phdr)
+		release_wlanhdr_to_poll(priv, txinsn.phdr);
+	if (txinsn.pframe)
+		release_mgtbuf_to_poll(priv, txinsn.pframe);    
+}
+
+int APmacTestFunction_8814(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+    unsigned char *val[10];
+    int i=0, op=0, offset;
+    char *delim = ",";
+    unsigned char input;
+
+
+
+    if (strlen(data) == 0) {
+        printk("RetryLimitForEachMACID 0x1 downlaod Rsvd page\n");
+        printk("LowestRetryRateInTXDESC 0x2: AP offload enable \n");
+
+        return 0;
+    }
+
+    for(i=0;i<10;i++)
+    {
+      val[i] = kmalloc(10,GFP_ATOMIC); 
+    }
+
+    if(val[0] = strtok(data,delim))
+    {
+        i= 1;        
+        while(val[i]= strtok(NULL,delim))
+        {
+            i++;
+        }
+    }
+  
+    int mode = 0;
+    unsigned char RetryLimitNum = 0;
+    unsigned char lowestRetry = 0;    
+    unsigned char Enable = 0;    
+    unsigned char macIDNum = 0;      
+    unsigned char lowestRate =0; 
+    unsigned char macID;
+    unsigned char type;    
+    unsigned char tempEn;   
+
+    // mode2
+    unsigned char option;   
+    unsigned int reg_addr;           
+    unsigned char releaseBit;        
+
+
+    RTL_W32(0x80, RTL_R32(0x80)|BIT15);    
+	mode = _atoi(val[0],16);	
+
+	switch(mode) 
+    {
+    case RetryLimitForEachMACID:
+        //RetryLimitTestCmd iwpriv wlan0 apTest 0,enableBit,RetryLimitNum,macIDNum,type
+        // example iwpriv wlan0 apTest 1,32
+        // Test For 128 MACID
+        
+        if((!val[1])||(!val[2])||(!val[3])||(!val[4])) {
+            printk("%s %d CMD : iwpriv wlan0 apTest 0,enableBit,RetryLimitNum,macIDNum,type\n",__FUNCTION__,__LINE__); 
+            return;
+        }
+   
+        // enable=0, in TXDESC
+        // enable=1, in SRAM
+        // enable=2, TXESC and SRAM all disable
+        Enable = _atoi(val[1],10);           
+        RetryLimitNum = _atoi(val[2],10);           
+        macIDNum = _atoi(val[3],10);           
+        type = _atoi(val[4],10);           
+        
+        // set Rpt buffer
+        for(macID = 0; macID < macIDNum; macID++) {
+            
+            if(Enable==1) {
+                 // set RTY_LMT_EN in SRAM
+                 GET_HAL_INTERFACE(priv)->SetTxRPTHandler(priv, macID, TXRPT_VAR_RTY_LMT_EN, &Enable);
+                 priv->lowestRate_TXDESCen = 0;
+            }
+            else if(Enable ==0){
+                 // default retry = 10 in TXDESC
+                 priv->lowestRate_TXDESCen = 1;
+                 GET_HAL_INTERFACE(priv)->SetTxRPTHandler(priv, macID, TXRPT_VAR_RTY_LOW_RATE_EN, &Enable);                    
+                 GET_HAL_INTERFACE(priv)->SetTxRPTHandler(priv, macID, TXRPT_VAR_RTY_LMT_EN, &Enable);                 
+            }
+            else if(Enable ==2) {
+                // retry limit by register
+                tempEn = 0;
+                priv->lowestRate_TXDESCen = 0;
+                GET_HAL_INTERFACE(priv)->SetTxRPTHandler(priv, macID, TXRPT_VAR_RTY_LMT_EN, &tempEn);                
+            }
+
+            // set RetryLimitNum in SRAM
+            GET_HAL_INTERFACE(priv)->SetTxRPTHandler(priv, macID, TXRPT_VAR_DATA_RT_LMT, &RetryLimitNum);
+
+            // TX pkt
+            issue_Test_NullData(priv,macID,type);
+            rtl8192cd_tx_dsr((unsigned long)priv);
+            delay_ms(1*RetryLimitNum);
+        }
+       
+    break;
+    case LowestRetryRateInTXDESC:
+        //LowestRetryRateInTXDESC iwpriv wlan0 apTest 1,TXDESC/RPTBuffer,LowestRTYRate,macIDNum,type
+        // example iwpriv wlan0 apTest 1,0,4,128 (apTest LowestRetryRateInTXDESC/TXDESC/OFDM 12M/ 128 macIDs)
+        // Test For 128 MACID        
+
+        if((!val[1])||(!val[2])||(!val[3])||(!val[4])) {
+           printk("%s %d CMD : iwpriv wlan0 apTest 1,TXDESC/RPTBuffer,LowestRTYRate,macIDNum,type\n",__FUNCTION__,__LINE__); 
+           return;
+        }
+
+        Enable   = _atoi(val[1],10);
+        lowestRate = _atoi(val[2],10);
+        macIDNum = _atoi(val[3],10);   
+        type = _atoi(val[4],10);   
+
+         // set Rpt buffer
+        for(macID = 0; macID < macIDNum; macID++) {
+           if(Enable==1) {
+                priv->lowestRate_TXDESCen = 0;                
+                // set lowest rate in SRAM
+                GET_HAL_INTERFACE(priv)->SetTxRPTHandler(priv, macID, TXRPT_VAR_RTY_LOW_RATE_EN, &Enable);                
+                GET_HAL_INTERFACE(priv)->SetTxRPTHandler(priv, macID, TXRPT_VAR_RTY_LMT_EN, &Enable);                                
+                RetryLimitNum = 15;   
+                GET_HAL_INTERFACE(priv)->SetTxRPTHandler(priv, macID, TXRPT_VAR_DATA_RT_LMT, &RetryLimitNum);                
+            }else if(Enable==0) {
+                priv->lowestRate_TXDESCen = 1;
+                priv->lowestRate = lowestRate;
+                GET_HAL_INTERFACE(priv)->SetTxRPTHandler(priv, macID, TXRPT_VAR_RTY_LMT_EN, &Enable);                
+                GET_HAL_INTERFACE(priv)->SetTxRPTHandler(priv, macID, TXRPT_VAR_RTY_LOW_RATE_EN, &Enable);
+                // set lowest rate in TXDESC                
+            }else if(Enable ==2) {
+                // retry limit by register
+                tempEn = 0;
+                priv->lowestRate_TXDESCen = 0;
+                GET_HAL_INTERFACE(priv)->SetTxRPTHandler(priv, macID, TXRPT_VAR_RTY_LMT_EN, &tempEn);                
+                GET_HAL_INTERFACE(priv)->SetTxRPTHandler(priv, macID, TXRPT_VAR_RTY_LOW_RATE_EN, &tempEn);  
+            }
+    
+            GET_HAL_INTERFACE(priv)->SetTxRPTHandler(priv, macID, TXRPT_VAR_RTS_RTY_LOW_RATE, &lowestRate);               
+            GET_HAL_INTERFACE(priv)->SetTxRPTHandler(priv, macID, TXRPT_VAR_DATA_RTY_LOW_RATE, &lowestRate);                              
+          
+            // TX pkt
+            issue_Test_NullData(priv,macID,type);
+            rtl8192cd_tx_dsr((unsigned long)priv);
+            delay_ms(1*RetryLimitNum);
+        }
+    break;    
+    case ReleaseOnePKtbyMACIDeep:
+         //ReleaseOnePKtbyMACIDeep iwpriv wlan0 apTest 2,Option,MPDU/AMPDU,macIDNum
+         // example iwpriv wlan0 apTest 2,0,4,128 (apTest LowestRetryRateInTXDESC/TXDESC/OFDM 12M/ 128 macIDs)
+         // Test For 128 MACID        
+        
+        if((!val[1])||(!val[2])||(!val[3])) {
+           printk("%s %d CMD : iwpriv wlan0 apTest 2,Option,MPDU/AMPDU,macIDNum\n",__FUNCTION__,__LINE__); 
+           return;
+        }
+
+        option = _atoi(val[1],10);
+        macID = _atoi(val[2],10);        
+        type = _atoi(val[3],10);        
+        reg_addr = 0x1434 + (macID >>5)*4;
+        releaseBit = macID%32;    
+        switch(option)
+        {
+        case 1:
+            // 1.) MACID Sleep disable,
+            // 2.) MACID release bit set1, do nothing
+            for(macID = 0;macID < 128; macID++)
+            {
+                reg_addr = 0x1434 + (macID >>5)*4;
+                releaseBit = macID%32;
+
+                RTL_W32(reg_addr, RTL_R32(reg_addr) | BIT(releaseBit));
+
+                delay_us(1000);
+                if(RTL_R32(reg_addr)&BIT(releaseBit))
+                {
+                    printk("Test1 fail at MACID:%x\n",macID);
+                }
+            }
+            printk("Test1 finish \n");
+        break;            
+        case 2:
+            for(macID = 0;macID < 128; macID++)
+            {
+                // 1.) MACID sleep enable (pause)         
+                GET_HAL_INTERFACE(priv)->SetMACIDSleepHandler(priv,1,macID);
+                // 2.) TX one packet (download)
+                issue_Test_NullData(priv,macID,0);                
+                // 3.) MACID release one (release)
+                reg_addr = 0x1434 + (macID >>5)*4;
+                releaseBit = macID%32;
+                RTL_W32(reg_addr, RTL_R32(reg_addr) | BIT(releaseBit));            
+
+                // polling 0 (TX done), or fail 
+
+                delay_ms(100);
+                if(RTL_R32(reg_addr)&BIT(releaseBit))
+                {
+                    printk("First TX done fail at MACID:%x\n",macID);
+                }
+
+              
+                rtl8192cd_tx_dsr((unsigned long)priv);
+            }
+        break;      
+
+        case 3:
+
+             for(macID = 0;macID < 128; macID++)
+             {
+                  // 1.) MACID sleep enable (pause)         
+                   GET_HAL_INTERFACE(priv)->SetMACIDSleepHandler(priv,1,macID);
+
+                  reg_addr = 0x1434 + (macID >>5)*4;
+                  releaseBit = macID%32;
+
+                  // 2.) MACID release one (release)
+                  RTL_W32(reg_addr, RTL_R32(reg_addr) | BIT(releaseBit));            
+
+                  // polling 1 (TX done), or fail 
+                  delay_ms(100);                    
+                  if(!(RTL_R32(reg_addr)&BIT(releaseBit)))
+                  {                
+                      printk("TX queue fail at MACID:%x\n",macID);
+                  }
+                  
+                  // 5.) TX one packet (download)
+                  issue_Test_NullData(priv,macID,0);                
+
+                  delay_ms(50);                    
+                  // polling 0 (TX done), or fail 
+                  if(RTL_R32(reg_addr)&BIT(releaseBit))
+                  {
+                      printk("Last TX done fail at MACID:%x\n",macID);
+                  }
+
+                  rtl8192cd_tx_dsr((unsigned long)priv);        
+             }
+        break;
+        case 4:        
+            // TXDESC set 1
+            for(macID = 0;macID < 128; macID++)
+            {
+               reg_addr = 0x1434 + (macID >>5)*4;
+               releaseBit = macID%32;
+               priv->lowestRate_TXDESCen = 1; // TXDESC moredata = 1;
+               GET_HAL_INTERFACE(priv)->SetMACIDSleepHandler(priv,1,macID);
+               issue_Test_NullData(priv,macID,2);  
+               RTL_W32(reg_addr, RTL_R32(reg_addr) | BIT(releaseBit));   // moreData = 1               
+                while(RTL_R32(reg_addr)&BIT(releaseBit))
+                {
+                    delay_ms(5);  
+                }
+               issue_Test_NullData(priv,macID,1);     
+               RTL_W32(reg_addr, RTL_R32(reg_addr) | BIT(releaseBit));   // moreData = 1
+
+                while(RTL_R32(reg_addr)&BIT(releaseBit))
+                {
+                    delay_ms(5);  
+                }               
+                
+               issue_Test_NullData(priv,macID,2);     
+               RTL_W32(reg_addr, RTL_R32(reg_addr) | BIT(releaseBit));   // moreData = 1
+
+                while(RTL_R32(reg_addr)&BIT(releaseBit))
+                {
+                    delay_ms(5);  
+                }
+               rtl8192cd_tx_dsr((unsigned long)priv);        
+               delay_ms(50);                
+            }
+        break;          
+        case 5:      
+            // No TXDESC, 
+            // 2.) MACID release one (release)
+             for(macID = 0;macID < 128; macID++)
+             {
+                reg_addr = 0x1434 + (macID >>5)*4;
+                releaseBit = macID%32;
+                priv->lowestRate_TXDESCen = 0; // TXDESC moredata = 0;
+                GET_HAL_INTERFACE(priv)->SetMACIDSleepHandler(priv,1,macID);
+                issue_Test_NullData(priv,macID,1);  
+                issue_Test_NullData(priv,macID,2);                  
+                issue_Test_NullData(priv,macID,3);     
+     
+                RTL_W32(reg_addr, RTL_R32(reg_addr) | BIT(releaseBit));   // moreData = 1
+                while(RTL_R32(reg_addr)&BIT(releaseBit)){delay_ms(5); }
+                RTL_W32(reg_addr, RTL_R32(reg_addr) | BIT(releaseBit));   // moreData = 1  
+                while(RTL_R32(reg_addr)&BIT(releaseBit)){delay_ms(5); }                
+                RTL_W32(reg_addr, RTL_R32(reg_addr) | BIT(releaseBit));   // moreData = 0                
+                while(RTL_R32(reg_addr)&BIT(releaseBit)){delay_ms(5); }
+
+                issue_Test_NullData(priv,macID,2);                     
+                issue_Test_NullData(priv,macID,2);          
+                RTL_W32(reg_addr, RTL_R32(reg_addr) | BIT(releaseBit));   // moreData = 1                                                
+                while(RTL_R32(reg_addr)&BIT(releaseBit)){delay_ms(5); }
+
+                issue_Test_NullData(priv,macID,2);                         
+                RTL_W32(reg_addr, RTL_R32(reg_addr) | BIT(releaseBit));   // moreData = 1                                                
+                while(RTL_R32(reg_addr)&BIT(releaseBit)){delay_ms(5); }
+                RTL_W32(reg_addr, RTL_R32(reg_addr) | BIT(releaseBit));   // moreData = 0  
+                while(RTL_R32(reg_addr)&BIT(releaseBit)){delay_ms(5); }                
+                RTL_W32(reg_addr, RTL_R32(reg_addr) | BIT(releaseBit));   
+                rtl8192cd_tx_dsr((unsigned long)priv);                                                 
+                issue_Test_NullData(priv,macID,2);                        // moreData = 0  
+
+                rtl8192cd_tx_dsr((unsigned long)priv);        
+                delay_ms(50); 
+             }
+        break;       
+        case 6: 
+             // disable HW_auto_fill_moreData
+             RTL_W8(0x454,RTL_R8(0x454)&~(BIT2));
+             for(macID = 0;macID < 128; macID++)
+             {
+                reg_addr = 0x1434 + (macID >>5)*4;
+                releaseBit = macID%32;
+                priv->lowestRate_TXDESCen = 0; // TXDESC moredata = 0;
+                GET_HAL_INTERFACE(priv)->SetMACIDSleepHandler(priv,1,macID);
+                issue_Test_NullData(priv,macID,1);  
+                issue_Test_NullData(priv,macID,2);                  
+                issue_Test_NullData(priv,macID,3);     
+     
+                RTL_W32(reg_addr, RTL_R32(reg_addr) | BIT(releaseBit));   // moreData = 0
+                while(RTL_R32(reg_addr)&BIT(releaseBit)){delay_ms(5); }
+                RTL_W32(reg_addr, RTL_R32(reg_addr) | BIT(releaseBit));   // moreData = 0  
+                while(RTL_R32(reg_addr)&BIT(releaseBit)){delay_ms(5); }                
+                RTL_W32(reg_addr, RTL_R32(reg_addr) | BIT(releaseBit));   // moreData = 0                
+                while(RTL_R32(reg_addr)&BIT(releaseBit)){delay_ms(5); }
+
+                issue_Test_NullData(priv,macID,2);                     
+                issue_Test_NullData(priv,macID,2);          
+                RTL_W32(reg_addr, RTL_R32(reg_addr) | BIT(releaseBit));   // moreData = 0                                                
+                while(RTL_R32(reg_addr)&BIT(releaseBit)){delay_ms(5); }
+
+                issue_Test_NullData(priv,macID,2);                         
+                RTL_W32(reg_addr, RTL_R32(reg_addr) | BIT(releaseBit));   // moreData = 0                                                
+                while(RTL_R32(reg_addr)&BIT(releaseBit)){delay_ms(5); }
+                RTL_W32(reg_addr, RTL_R32(reg_addr) | BIT(releaseBit));   // moreData = 0  
+                while(RTL_R32(reg_addr)&BIT(releaseBit)){delay_ms(5); }                
+                RTL_W32(reg_addr, RTL_R32(reg_addr) | BIT(releaseBit));   
+                rtl8192cd_tx_dsr((unsigned long)priv);                                                 
+                issue_Test_NullData(priv,macID,2);                        // moreData = 0  
+
+                rtl8192cd_tx_dsr((unsigned long)priv);        
+                delay_ms(50); 
+             }
+        break;       
+        case 7:        
+            // pause
+            GET_HAL_INTERFACE(priv)->SetMACIDSleepHandler(priv,1,macID);
+        break;
+        case 8:     
+            // download packet
+            // 5.) TX one packet (download)
+            issue_Test_NullData(priv,macID,type);  
+        break;        
+        case 9:        
+            // release packet
+            // 2.) MACID release one (release)
+            RTL_W32(reg_addr, RTL_R32(reg_addr) | BIT(releaseBit));      
+        break;      
+        case 10:        
+            // Set AMPDU
+            tempEn = 1;
+            GET_HAL_INTERFACE(priv)->SetTxRPTHandler(priv, macID, TXRPT_VAR_PKT_TX_ONE_SEL, &tempEn);                            
+        break;           
+        default:
+            printk("%s %d Unkonw option =%x\n",__FUNCTION__,__LINE__,option);
+        break; 
+        }
+        
+        printk("%s %d ReleaseOnePKtbyMACIDeep Test\n",__FUNCTION__,__LINE__);        
+    break;    
+    case AppendMACHeaderForRXpacket:
+        printk("%s %d AppendMACHeaderForRXpacket Test \n",__FUNCTION__,__LINE__);        
+    break; 
+    case HWAutoAppendMACID:
+        //HWAutoAppendMACID iwpriv wlan0 apTest 4,macID,
+        // example iwpriv wlan0 apTest 4,1 
+        // Test For 128 MACID        
+
+        if((!val[1])) {
+           printk("%s %d CMD : iwpriv wlan0 apTest 1,TXDESC/RPTBuffer,LowestRTYRate,macIDNum,type\n",__FUNCTION__,__LINE__); 
+           return;
+        }
+
+        macIDNum = _atoi(val[1],10);   
+        RTL_W32(0x6bc, 0x03000000);  // set CRC5 buffer addr                 
+        // fill mac address
+    	unsigned char hwaddr[6] = {0x00,0x11,0x11,0x11,0x11,0x11};     
+        unsigned int test;
+        for(macID = 0;macID < macIDNum;macID++)
+        {
+            hwaddr[5]= 0x11 + macID;
+            GET_HAL_INTERFACE(priv)->SetTxRPTHandler(priv, macID, TXRPT_VAR_MAC_ADDRESS, &hwaddr);   
+            GET_HAL_INTERFACE(priv)->SetCRC5ToRPTBufferHandler(priv,CRC5(hwaddr,6), macID,1);               
+         }
+
+         priv->testResult = false;        
+         priv->RXMACIDTestEn = true;
+         
+         printk("%s %d HWAutoAppendMACID Test \n",__FUNCTION__,__LINE__);        
+    break;
+    case HWSupportPowerStatedetect:
+        if((!val[1])) {
+           printk("%s %d CMD : iwpriv wlan0 apTest 5,macID\n",__FUNCTION__,__LINE__); 
+           return;
+        }
+
+         RTL_W32(0x6bc, 0x03000000);  // set CRC5 buffer addr
+        RTL_W32(0x7D4, RTL_R32(0x7D4)|BIT17);  // set ps detect enable
+        priv->test_seq_MACID = 0;
+        RTL_W32(0x1150,0x0); // set ps seq debug port     
+        priv->testResult = true;        
+       // macIDNum = _atoi(val[1],10);   
+       // RTL_W8(0x1150,macIDNum);            
+        
+       // priv->test_seq_MACID = macIDNum;
+          printk("%s %d HWSupportPowerStatedetect Test \n",__FUNCTION__,__LINE__);        
+      break;
+	  case 0xdd: // for verify FAST EDCA
+	  {
+		  /* 
+		   *  iwpriv wlan0 apTest dd,macID,type,cnt 
+		   *  iwpriv wlan0 apTest dd,1,2,3	  
+			  BK_QUEUE		  = 1,
+			  BE_QUEUE		  = 2,
+			  VI_QUEUE		  = 3,
+			  VO_QUEUE		  = 4,
+		   */
+		  unsigned char macID;
+		  unsigned int type;
+		  unsigned int cnt;
+		  unsigned int i;
+	  
+		  if((!val[1])||(!val[2])||(!val[3])) {
+			  printk("%s(%d): CMD: iwpriv wlan0 apTest dd,macID,type,cnt \n", __FUNCTION__, __LINE__);
+			  return;
+		  }
+	  
+		  macID = _atoi(val[1], 10);
+		  type = _atoi(val[2], 10);
+		  cnt = _atoi(val[3], 10);
+	  
+		  for (i = 0; i < cnt; i++) {
+			  issue_Test_NullData(priv, macID, type);
+			  if (i != 0 && i%8 == 0) {
+				  rtl8192cd_tx_dsr((unsigned long)priv);
+			  }
+		  }
+		  rtl8192cd_tx_dsr((unsigned long)priv);
+	}
+	break;
+	case 0xde:
+	{
+        /*  tx pkt buf          0x18780000 + 0x1b000 = 0x1879B000 */
+        /* (0x400[10:0] * 0x80 + 0x18780000)[23:12] */
+		/* iwpriv wlan0 apTest de,400,32 */
+		/* check 0x41A first */
+		unsigned int reg1 = 0;
+		unsigned int base_reg = 0x8000;
+		unsigned int value32 = 0, valueA = 0, valueB = 0;
+		unsigned int num = 0;
+		unsigned int cur_reg;
+
+		if((!val[1])||(!val[2])) {
+			printk("%s(%d): CMD: iwpriv wlan0 apTest de,REG_QX_INFO,cnt \n", __FUNCTION__, __LINE__);
+			return;
+		}
+
+		reg1 = _atoi(val[1], 16); // ex: 400
+		num = _atoi(val[2], 16);
+
+		value32 = RTL_R32(reg1) & 0x7FF; // [10:0]
+		value32 = value32 * 0x80;
+		value32 = value32 + 0x18780000;
+
+		valueA = (value32 >> 12) & 0xFFF;
+		valueB = value32 & 0xFFF;
+		base_reg = base_reg + valueB;
+		
+		printk("0x140: 0x%X\n", valueA);
+		RTL_W8(0x106, 0x69);
+		RTL_W32(0x140, valueA);
+		
+		printk("print reg:0x%X, num(dw):0x%x \n", base_reg, num);
+		
+		for (i = 0; i < num; i++) {
+			cur_reg = base_reg + 0x4 * i;
+			value32 = RTL_R32(cur_reg);
+#if 0
+			printk("%s(%d): cur_reg:%04X, value32:%08X \n", __FUNCTION__, __LINE__, cur_reg, value32);
+#else
+			printk("%08X ", value32);
+			if (i % 4 == 3) {
+				printk("\n");
+			}
+#endif
+		}
+		printk("\n");
+	}
+	break;
+    case 0xEE:
+        RTL_W8(0x106,0x69);            
+        RTL_W32(0x140,0x780);                    
+       
+       // clear MACID
+            for(i=0;i<0xFFF;i++) {
+                RTL_W8(0x8000+i,0);
+            }
+        printk("Reset TXPKTBuffer !!! \n");      
+        return;        
+    case 0xFF:
+        GET_HAL_INTERFACE(priv)->SetTxRPTHandler(priv, macID, TXRPT_VAR_ALL, NULL);
+
+        for(i=0;i<128;i++) {
+            priv->pwrState[i] = 0;
+            priv->pwrHWState[i] = 0;            
+            priv->pwroldHWState[i] = 0;            
+            priv->pwrStateCnt[i] = 0;            
+            priv->pwrStateHWCnt[i] = 0;            
+            priv->hw_seq[i] = 0;              
+        }
+
+        priv->testResult = true;  
+        RTL_W32(0x1140,0x0);  
+        RTL_W32(0x1144,0x0);          
+        RTL_W32(0x1148,0x0);          
+        printk("Reset RPTBuffer !!! \n");
+        return;
+    break;
+    
+    default:
+        printk("%s %d Unkonw operation ! mode=%x\n",__FUNCTION__,__LINE__,mode);
+    break;        
+	}
+ }
+
+
+
+
+#endif //#ifdef CONFIG_8814_AP_MAC_VERI
+
+
+#ifndef CONFIG_RTL_COMAPI_WLTOOLS
+static
+#endif
+int rtl8192cd_ss_req(struct rtl8192cd_priv *priv, unsigned char *data, int len)
+{
+	INT8 ret = 0;
+#ifdef CONFIG_RTK_MESH
+	// by GANTOE for manual site survey 2008/12/25
+	// inserted by Joule for simple channel unification protocol 2009/01/06
+	if((priv->auto_channel &0x30) && timer_pending(&priv->ss_timer))
+		ret = -2;
+	else
+#endif
+	if (!IS_DRV_OPEN(priv) || priv->ss_req_ongoing)
+		ret = -1;
+#if defined( WIFI_SIMPLE_CONFIG	) && defined(UNIVERSAL_REPEATER)
+    else if(priv->wsc_ss_delay > 0){
+        STADEBUG("reject by wsc_ss_delay\n");    
+        ret = -3;        
+    }
+#endif  
+#ifdef SMART_REPEATER_MODE
+    else if (IS_DRV_OPEN(GET_VXD_PRIV(priv)) && GET_VXD_PRIV(priv)->ss_req_ongoing) {
+        STADEBUG("VXD is scanning. Don't site-survey\n");
+        ret = -4;
+    }
+#endif
+#ifdef CONFIG_RTL_SIMPLE_CONFIG_USE_WPS_BUTTON
+	else if((priv->simple_config_status>=2) && (priv->pmib->wscEntry.wsc_enable))
+	{
+		STADEBUG("it is get simple profile now, don't switch channel from ioctl\n");
+		ret = -5;
+	}
+#endif
+	else{
+		ret = 0;
+    }
+
+
+	if (!ret)	// now, let's start site survey
+	{
+		priv->ss_ssidlen = 0;
+		DEBUG_INFO("start_clnt_ss, trigger by %s, ss_ssidlen=0\n", (char *)__FUNCTION__);
+
+		if (len == 2){
+            STADEBUG("Req from WSC\n");
+			priv->ss_req_ongoing = SSFROM_WSC;	// WiFi-Simple-Config scan-req
+            #if defined( WIFI_SIMPLE_CONFIG	) && defined(UNIVERSAL_REPEATER)			
+			if(IS_VXD_INTERFACE(priv)){
+                if(get_ss_level(priv)==0){  //exist some STA connected to root or VAP
+                    priv->wsc_ss_delay = 5; // SCAN interval , unit is second
+                }
+            }
+            #endif            
+		}else
+
+        {
+            STADEBUG("req_from_Web\n");        
+			priv->ss_req_ongoing = 1;	//SS req by Web
+        }
+			
+		start_clnt_ss(priv);
+	}
+
+	if (ioctl_copy_to_user((void *)data, (void *)&ret, 1))
+		return -1;
+
+	return 0;
+}
+
+static int rtl8192cd_autochannel_sel(struct rtl8192cd_priv *priv)
+{
+	INT8 ret = 0;
+
+	if (!netif_running(priv->dev) || priv->ss_req_ongoing)
+		ret = -1;
+	else
+		ret = 0;
+
+    /* get available channels before ACS */
+	get_available_channel(priv);
+	
+	if (!ret)	// now, let's start site survey
+	{
+		priv->ss_ssidlen = 0;
+		DEBUG_INFO("start_clnt_ss, trigger by %s, ss_ssidlen=0\n", (char *)__FUNCTION__);
+		priv->ss_req_ongoing = 1;
+		priv->auto_channel = 1;
+		start_clnt_ss(priv);
+	}
+	return ret;
+}
+
+static void rtl8192cd_del_all_sta(struct rtl8192cd_priv *priv)
+{
+	if (OPMODE & WIFI_AP_STATE) {
+		int i;
+		for(i = 0; i < NUM_STAT; i++)
+		{
+	
+		     if (priv->pshare->aidarray[i] && (priv->pshare->aidarray[i]->used == TRUE)
+#ifdef WDS
+	
+    	             && !(priv->pshare->aidarray[i]->station.state & WIFI_WDS)
+#endif		
+		     ) {
+#if defined(UNIVERSAL_REPEATER) || defined(MBSSID)			    
+		        if (priv != priv->pshare->aidarray[i]->priv)				
+			    continue;			
+#endif
+			    issue_deauth(priv, priv->pshare->aidarray[i]->station.hwaddr, _RSON_DEAUTH_STA_LEAVING_);														
+		     }		     
+         }
+         delay_ms(10);		 
+     }
+}
+
+static int rtl8192cd_get_ss_status(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+	UINT8 flags;
+	INT8 ret = 0;
+
+	if (ioctl_copy_from_user((void *)&flags, (void *)(data), 1))
+		return -1;
+
+	if (!netif_running(priv->dev) || priv->ss_req_ongoing)
+	{
+		ret = -1;
+		if (ioctl_copy_to_user((void *)(data), (void *)&ret, 1))
+			return -1;
+	}
+	else if (flags == 1)
+	{
+		ret = priv->site_survey->count_backup;
+		if (ioctl_copy_to_user((void *)(data), (void *)&ret, 1))
+			return -1;
+	}
+	else if (flags == 0)
+	{
+		ret = priv->site_survey->count_backup;
+		if (ioctl_copy_to_user((void *)data, (void *)&ret, 1))
+			return -1;
+		// now we should report data base.
+		if (ioctl_copy_to_user((void *)(data+4), priv->site_survey->bss_backup,
+				sizeof(struct bss_desc)*priv->site_survey->count_backup))
+			return -1;
+	}
+
+#ifdef WIFI_SIMPLE_CONFIG
+	else if (flags == 2) { // get simple-config scan result, append WSC IE
+		ret = priv->site_survey->count_backup;
+		if (ioctl_copy_to_user((void *)data, (void *)&ret, 1))
+			return -1;
+		// now we should report data base.
+		if (ioctl_copy_to_user((void *)(data+4), priv->site_survey->wscie_backup,
+				sizeof(struct wps_ie_info2)*priv->site_survey->count_backup))
+			return -1;
+	}
+#endif
+
+	return 0;
+}
+#ifdef P2P_SUPPORT
+
+int p2p_get_p2pconnect_state(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+	struct p2p_state_event	p2p_state_event_t;
+	memset(&p2p_state_event_t , 0 ,sizeof(struct p2p_state_event));	
+	
+	if(priv->p2pPtr==NULL)
+			return -1;	
+		
+	p2p_state_event_t.p2p_status = P2P_STATE;
+
+	if(P2P_STATE == P2P_S_CLIENT_CONNECTED_DHCPC){
+
+		P2P_DEBUG("Wlan driver report client is connected\n");
+		P2P_DEBUG("Indicate web server to start udhcpc \n\n");		
+		
+		P2P_STATE = P2P_S_CLIENT_CONNECTED_DHCPC_done ;	// after web rdy get this state ; change it
+		
+	}else if(P2P_STATE == P2P_S_preGO2GO_DHCPD){
+
+		P2P_DEBUG("now is GO mode\n");
+		P2P_DEBUG("Indicate web server to start udhcpd ...\n\n");		
+		P2P_STATE = P2P_S_preGO2GO_DHCPD_done ;	// after web rdy get this state ; change it
+		
+	}else if(P2P_STATE == P2P_S_back2dev){
+		// indicate web server to reset to p2p device mode
+		P2P_DEBUG("reinit by web server\n");
+		P2P_STATE = P2P_S_IDLE;
+
+	}	
+	
+	if (ioctl_copy_to_user((void *)(data), (void *)&p2p_state_event_t, sizeof(struct p2p_state_event)))
+		return -1;	
+
+	return 0;
+
+}
+
+int p2p_get_event_state(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+	int MethodCase=0;
+	struct p2p_state_event	p2p_state_event_t;
+	memset(&p2p_state_event_t , 0 ,sizeof(struct p2p_state_event));
+	
+	if(priv->p2pPtr==NULL)
+			return -1;	
+		
+	if(P2P_STATE>=P2P_S_PROVI_TX_REQ && P2P_STATE<=P2P_S_NEGO_WAIT_CONF )
+		p2p_state_event_t.p2p_status = 4;
+	else if(P2P_STATE ==P2P_S_CLIENT_CONNECTED_DHCPC ||  P2P_STATE ==P2P_S_CLIENT_CONNECTED_DHCPC_done)
+		p2p_state_event_t.p2p_status = 5;
+	else if(P2P_STATE == P2P_S_preGO2GO_DHCPD ||  P2P_STATE ==P2P_S_preGO2GO_DHCPD_done)
+		p2p_state_event_t.p2p_status = 6;	
+	else if(P2P_STATE == P2P_S_back2dev )
+		p2p_state_event_t.p2p_status = 7;
+	else
+		p2p_state_event_t.p2p_status = P2P_STATE;
+
+	
+	p2p_state_event_t.p2p_role = P2PMODE;	
+
+	if(P2P_EVENT_INDICATE){
+		
+		p2p_state_event_t.p2p_event = P2P_EVENT_INDICATE;	
+		
+		if(P2P_EVENT_INDICATE == P2P_EVENT_RX_PROVI_REQ)
+		{
+			MethodCase = priv->p2pPtr->wsc_method_from_target_dev;
+
+			switch(MethodCase){
+				case CONFIG_METHOD_PIN:
+				case CONFIG_METHOD_DISPLAY:  
+					p2p_state_event_t.p2p_wsc_method = CONFIG_METHOD_DISPLAY;
+					break;
+	 	 	    case CONFIG_METHOD_PBC:
+					p2p_state_event_t.p2p_wsc_method = CONFIG_METHOD_PBC;
+					break;
+			    case CONFIG_METHOD_KEYPAD:
+					p2p_state_event_t.p2p_wsc_method = CONFIG_METHOD_KEYPAD;
+					break;
+			}
+			
+		}
+		P2P_EVENT_INDICATE = 0 ;		
+	}
+
+	if (ioctl_copy_to_user((void *)(data), (void *)&p2p_state_event_t, sizeof(struct p2p_state_event)))
+		return -1;	
+
+	return 0;
+}
+
+
+int p2p_wps_indicate_state(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+
+	unsigned char flags;
+
+
+	printk("(%s %d)\n\n\n",__FUNCTION__,__LINE__);	
+
+	
+  	if (ioctl_copy_from_user((void *)&flags, (void *)(data), 1)){
+		return -1;
+  	}
+
+	P2P_DEBUG("Report from wscd , WPS is %s\n\n\n", (flags==1?"success":"fail"));
+
+	if(flags == GO_WPS_SUCCESS){
+		if(P2PMODE == P2P_PRE_GO)
+		{
+			P2P_DEBUG("pre-GO mdoe ;rx Report from wscd ; WPS is done \n\n");	
+			// mode change
+			P2PMODE = P2P_TMP_GO ;
+
+			// state change
+			P2P_STATE = P2P_S_preGO2GO_DHCPD;
+
+			/*build beacon P2P IE  ; 
+			 when from (Pre go) switch to GO only need change beacon P2P IE*/ 			
+			if(P2PMODE == P2P_TMP_GO || P2PMODE == P2P_PRE_GO )
+				priv->p2pPtr->p2p_beacon_ie_len = 
+					p2p_build_beacon_ie(priv,priv->p2pPtr->p2p_beacon_ie);
+	
+		}else if(P2PMODE == P2P_PRE_CLIENT){
+			P2P_DEBUG("Pre-Client mdoe ;Report from wscd ; WPS is  done \n\n");			
+			P2PMODE = P2P_CLIENT ;
+		}
+	}
+	return 0;
+	
+}
+
+int rtl8192cd_p2p_ss_req(struct rtl8192cd_priv *priv, unsigned char *data, int len)
+{
+	INT8 ret = 0;
+	if (!netif_running(priv->dev)  || P2P_DISCOVERY	)
+		ret = -1;
+	else
+		ret = 0;
+
+	if (!ret)	// now, let's start site survey
+	{
+		printk("\n\n trigger P2P_discovery from UI\n");	
+			
+		P2P_DISCOVERY = 1;
+		priv->site_survey->count = 0;
+		P2P_scan(priv,NULL);	
+	}
+
+	if (ioctl_copy_to_user((void *)data, (void *)&ret, 1))
+		return -1;
+
+	return 0;
+}
+
+
+
+static int rtl8192cd_p2p_get_ss_status(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+	UINT8 flags;
+	INT8 ret = 0;
+	//int idx ;
+	if (ioctl_copy_from_user((void *)&flags, (void *)(data), 1))
+		return -1;
+
+	if (!netif_running(priv->dev) || P2P_DISCOVERY)
+	{
+		ret = -1;
+		if (ioctl_copy_to_user((void *)(data), (void *)&ret, 1))
+			return -1;
+	}
+	else if (flags == 1)
+	{
+		ret = priv->site_survey->count_backup;
+		if (ioctl_copy_to_user((void *)(data), (void *)&ret, 1))
+			return -1;
+	}
+	else if (flags == 0)
+	{
+		ret = priv->site_survey->count_backup;
+		if (ioctl_copy_to_user((void *)data, (void *)&ret, 1))
+			return -1;
+		// now we should report data base.
+				
+		if (ioctl_copy_to_user((void *)(data+4), priv->site_survey->bss_backup,
+				sizeof(struct bss_desc)*priv->site_survey->count_backup))
+			return -1;
+	}
+
+
+	return 0;
+}
+
+
+#endif
+
+#ifdef CLIENT_MODE
+static int	rtl8192cd_join(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+	INT8 ret = 0;
+	char tmpbuf[33];
+
+	if (!netif_running(priv->dev))
+		ret = 2;
+	else if (priv->ss_req_ongoing)
+		ret = 1;
+	else
+		ret = 0;
+
+	if (!ret)	// now, let's start site survey and join
+	{
+		if (ioctl_copy_from_user((void *)&(priv->pmib->dot11Bss), (void *)data, sizeof(struct bss_desc)))
+			return -1;
+
+#ifdef WIFI_SIMPLE_CONFIG
+		if (priv->pmib->wscEntry.wsc_enable && (priv->pmib->dot11Bss.bsstype&WIFI_WPS)) {
+			priv->pmib->dot11Bss.bsstype &= ~WIFI_WPS;
+			priv->wps_issue_join_req = 1;
+		}
+		else
+#endif
+		{
+			if (check_bss_encrypt(priv) == FAIL) {
+				DEBUG_INFO("Encryption mismatch!\n");
+				ret = 2;
+				if (ioctl_copy_to_user((void *)data, (void *)&ret, 1))
+					return -1;
+				else
+					return 0;
+			}
+		}
+
+		if ((priv->pmib->dot11Bss.ssidlen == 0) || (priv->pmib->dot11Bss.ssid[0] == '\0')) {
+			DEBUG_INFO("Join to a hidden AP!\n");
+			ret = 2;
+			if (ioctl_copy_to_user((void *)data, (void *)&ret, 1))
+				return -1;
+			else
+				return 0;
+		}
+
+#ifdef UNIVERSAL_REPEATER
+		disable_vxd_ap(GET_VXD_PRIV(priv));
+#endif
+
+		memcpy(tmpbuf, priv->pmib->dot11Bss.ssid, priv->pmib->dot11Bss.ssidlen);
+		tmpbuf[priv->pmib->dot11Bss.ssidlen] = '\0';
+		DEBUG_INFO("going to join bss: %s\n", tmpbuf);
+
+		memcpy(SSID2SCAN, priv->pmib->dot11Bss.ssid, priv->pmib->dot11Bss.ssidlen);
+		SSID2SCAN_LEN = priv->pmib->dot11Bss.ssidlen;
+
+		SSID_LEN = SSID2SCAN_LEN;
+		memcpy(SSID, SSID2SCAN, SSID_LEN);
+		memset(BSSID, 0, MACADDRLEN);
+
+// button 2009.05.21
+// derive  PSK with slelected SSID
+#ifdef INCLUDE_WPA_PSK
+		if (priv->pmib->dot1180211AuthEntry.dot11EnablePSK)
+			derivePSK(priv);
+#endif
+
+#ifdef CONFIG_IEEE80211W_CLI
+		sync_PMF_SHA256(priv, &priv->pmib->dot11Bss, 1);
+#endif
+		syncMulticastCipher(priv, &priv->pmib->dot11Bss);
+
+		JOIN_REQ_ONGOING_VAL(1);
+		AUTH_MODE_RETRY_VAL(0);
+		start_clnt_join(priv);
+	}
+
+	if (ioctl_copy_to_user((void *)data, (void *)&ret, 1))
+		return -1;
+	return 0;
+}
+
+#ifdef CONFIG_RTK_MESH
+// ==== inserted by GANTOE for site survey 2008/12/25 ====
+// This function might be modifed when the mesh peerlink precedure has been completed
+static int rtl8192cd_join_mesh (struct rtl8192cd_priv *priv, unsigned char* meshid, int meshid_len, int channel, int offset, int reset)
+{
+    int i, ret = -1;
+#ifndef SMP_SYNC
+   unsigned long flags;
+#endif
+
+    SAVE_INT_AND_CLI(flags);
+
+    if(reset == 0) {
+        for(i = 0; i < priv->site_survey->count; i++)
+        {
+            if(!memcmp(meshid, priv->site_survey->bss[i].meshid, meshid_len) && priv->site_survey->bss[i].channel == channel)
+                break;
+        }
+    }
+
+
+    if(reset || i < priv->site_survey->count) {
+        priv->pshare->offset_2nd_chan = reset? priv->pmib->dot11nConfigEntry.dot11n2ndChOffset : offset;
+        priv->pmib->dot11RFEntry.dot11channel = channel;
+        SwChnl(priv, channel, priv->pshare->offset_2nd_chan); // in this version, automatically establishing link
+        SwBWMode(priv, priv->pshare->CurrentChannelBW, priv->pshare->offset_2nd_chan);        
+        memcpy(GET_MIB(priv)->dot1180211sInfo.mesh_id, meshid, meshid_len);
+        GET_MIB(priv)->dot1180211sInfo.mesh_id[meshid_len]=0;
+        update_beacon(priv);
+        ret = 0;
+    }
+
+    RESTORE_INT(flags);
+    return ret;
+}
+
+// This function might be removed when the mesh peerlink precedure has been completed
+static int rtl8192cd_check_mesh_link (struct rtl8192cd_priv *priv, unsigned char* macaddr)
+{
+	int ret = -1;
+	unsigned long flags;
+	struct stat_info *pstat;
+	struct list_head *phead, *plist, *pprevlist;
+
+	SAVE_INT_AND_CLI(flags);
+	SMP_LOCK_MESH_MP_HDR(flags);
+
+	phead= &priv->mesh_mp_hdr;
+	plist = phead->next;
+	pprevlist = phead;
+
+	while(plist != phead)
+	{
+		pstat = list_entry(plist, struct stat_info, mesh_mp_ptr);
+		if(!memcmp(pstat->hwaddr, macaddr, 6))
+		{
+			ret = 0;
+			break;
+		}
+		plist = plist->next;
+		pprevlist = plist->prev;
+	}
+
+	SMP_UNLOCK_MESH_MP_HDR(flags);
+	RESTORE_INT(flags);
+	return ret;
+}
+#endif
+
+static int rtl8192cd_join_status(struct rtl8192cd_priv *priv, unsigned char *data)
+{
+	INT8 ret = 0;
+
+	if (!netif_running(priv->dev) || JOIN_REQ_ONGOING)
+		ret = -1;	// pending
+	else
+		ret = JOIN_RES;
+
+	if (ioctl_copy_to_user((void *)data, (void *)&ret, 1))
+		return -1;
+
+	return 0;
+}
+#endif // CLIENT_MODE
+
+#ifdef	SUPPORT_TX_MCAST2UNI
+#ifndef CONFIG_MSC
+static
+#endif
+void AddDelMCASTGroup2STA(struct rtl8192cd_priv *priv, unsigned char *mac2addr, int add)
+{
+    int i, found=0;
+    struct stat_info	*pstat;
+    struct list_head	*phead, *plist;
+#ifdef CONFIG_RTK_MESH
+    struct proxy_table_entry*	pProxyEntry;
+    struct path_sel_entry *pEntry;  
+#endif
+#ifdef SMP_SYNC
+	unsigned long flags = 0;
+#endif
+
+    phead = &priv->asoc_list;
+
+	if (!(priv->drv_state & DRV_STATE_OPEN))
+		return;
+
+	SMP_LOCK_ASOC_LIST(flags);
+
+    plist = phead->next;
+    while (plist != phead) {
+        pstat = list_entry(plist, struct stat_info, asoc_list);
+        plist = plist->next;
+
+        // Search from SA stat list. If found check if mc entry is existed in table
+        if (((OPMODE & WIFI_AP_STATE) && !memcmp(pstat->hwaddr, mac2addr+6 , 6))
+#ifdef CLIENT_MODE
+        || !(OPMODE & WIFI_AP_STATE)
+#endif
+        ) {
+
+#ifdef WDS
+            if ((OPMODE & WIFI_AP_STATE) && (pstat->state & WIFI_WDS))
+                continue;	// Do not need to mc2uni coNversion in WDS
+#endif
+            found = 1;
+            break;
+        }
+
+    }
+
+
+#ifdef CONFIG_RTK_MESH
+    /*if we can not find the sta in asoc_list, search mesh proxy table to see if it is proxied by remote mesh node*/
+    if(found == 0 && priv->pmib->dot1180211sInfo.mesh_enable && priv->pmib->dot1180211sInfo.mesh_igmp_enable) {
+        pProxyEntry = (struct proxy_table_entry*) HASH_SEARCH(priv->proxy_table, mac2addr+6);
+        if(pProxyEntry) {
+            pEntry = (struct path_sel_entry *)HASH_SEARCH( priv->pathsel_table, pProxyEntry->owner);
+            if(pEntry) {
+                 pstat = get_stainfo(pEntry->priv, pEntry->nexthopMAC);
+                 if(pstat)
+                     found = 1;
+            }
+        }    
+    }        
+#endif
+
+
+    if(found) {
+        found = 0;
+        for (i=0; i < pstat->ipmc_num; i++) {
+            if (!memcmp(pstat->ipmc[i].mcmac, mac2addr, 6)) {
+                found = 1;
+                break;
+            }
+        }
+
+        if (found) {
+            if (!add) { // delete entry
+                if (i != pstat->ipmc_num-1) {
+                    memcpy(pstat->ipmc[i].mcmac, pstat->ipmc[pstat->ipmc_num-1].mcmac, 6);
+                }
+                pstat->ipmc_num--;
+            }
+        } else { // not found
+            if (add) { // add entry
+                if (pstat->ipmc_num < MAX_IP_MC_ENTRY) {
+                    memcpy(pstat->ipmc[pstat->ipmc_num].mcmac, mac2addr, 6);
+                    pstat->ipmc_num++;
+                }
+            }
+        }
+    }
+
+	SMP_UNLOCK_ASOC_LIST(flags);
+}
+
+int ioctl_AddDelMCASTGroup2STA(struct net_device *dev, struct ifreq *ifr, int cmd)
+{
+	struct rtl8192cd_priv *priv = GET_DEV_PRIV(dev);
+
+	int ret, i;
+	if (!priv->pshare->rf_ft_var.mc2u_disable) {
+#if defined(UNIVERSAL_REPEATER) || defined(MBSSID)
+		struct net_device *dev_vap;
+		struct rtl8192cd_priv	*priv_vap;
+
+		if (IS_ROOT_INTERFACE(priv))
+#endif
+		{
+#ifdef MBSSID
+			if (priv->pmib->miscEntry.vap_enable)
+			{
+				for (i=0; i<RTL8192CD_NUM_VWLAN; i++) {
+					if (IS_DRV_OPEN(priv->pvap_priv[i])) {
+//							rtl8192cd_ioctl(priv->pvap_priv[i]->dev, ifr, cmd);
+						dev_vap = priv->pvap_priv[i]->dev;
+						priv_vap = priv->pvap_priv[i];
+						if (netif_running(dev_vap)) {
+							if ((((GET_MIB(priv_vap))->dot11OperationEntry.opmode) & WIFI_AP_STATE)
+#ifdef CLIENT_MODE
+								|| ((((GET_MIB(priv_vap))->dot11OperationEntry.opmode) & (WIFI_STATION_STATE|WIFI_ASOC_STATE))==(WIFI_STATION_STATE|WIFI_ASOC_STATE))
+#endif
+								)
+								AddDelMCASTGroup2STA(priv_vap,(unsigned char *)ifr, (cmd == SIOCGIMCAST_ADD) ? 1 : 0);
+						}
+					}
+				}
+			}
+#endif
+#ifdef UNIVERSAL_REPEATER
+			if (IS_DRV_OPEN(GET_VXD_PRIV(priv))) {
+				dev_vap = (GET_VXD_PRIV(priv))->dev;
+				priv_vap = GET_DEV_PRIV(dev_vap);
+				
+//					rtl8192cd_ioctl((GET_VXD_PRIV(priv))->dev, ifr, cmd);
+				if (netif_running(dev_vap)) {
+					if ((((GET_MIB(priv_vap))->dot11OperationEntry.opmode) & WIFI_AP_STATE)
+#ifdef CLIENT_MODE
+						|| ((((GET_MIB(priv_vap))->dot11OperationEntry.opmode) & (WIFI_STATION_STATE|WIFI_ASOC_STATE))==(WIFI_STATION_STATE|WIFI_ASOC_STATE))
+#endif
+						)
+						AddDelMCASTGroup2STA(priv_vap,(unsigned char *)ifr, (cmd == SIOCGIMCAST_ADD) ? 1 : 0);
+				}
+			}
+#endif
+		}
+		if (netif_running(priv->dev)) {
+			DEBUG_INFO("%s: %s MCAST Group mac %02x%02x%02x%02x%02x%02x\n",  priv->dev->name,
+				((cmd == SIOCGIMCAST_ADD) ? "Add" : "Del"),
+				((unsigned char *)ifr)[0],((unsigned char *)ifr)[1],
+				((unsigned char *)ifr)[2],((unsigned char *)ifr)[3],((unsigned char *)ifr)[4],((unsigned char *)ifr)[5]);
+			DEBUG_INFO("STA mac %02x%02x%02x%02x%02x%02x\n", ((unsigned char *)ifr)[6],((unsigned char *)ifr)[7],
+				((unsigned char *)ifr)[8],((unsigned char *)ifr)[9],((unsigned char *)ifr)[10],((unsigned char *)ifr)[11]);
+
+			if ((OPMODE & WIFI_AP_STATE)
+#ifdef CLIENT_MODE
+					|| ((OPMODE & (WIFI_STATION_STATE|WIFI_ASOC_STATE))==(WIFI_STATION_STATE|WIFI_ASOC_STATE))
+#endif
+				)
+				AddDelMCASTGroup2STA(priv,(unsigned char *)ifr, (cmd == SIOCGIMCAST_ADD) ? 1 : 0);
+		}
+	}
+	ret = 0;
+	return ret;
+}
+
+#endif // SUPPORT_TX_MCAST2UNI
+
+
+#ifdef DRVMAC_LB
+void drvmac_loopback(struct rtl8192cd_priv *priv)
+{
+	struct stat_info *pstat;
+	unsigned char *da = priv->pmib->miscEntry.lb_da;
+
+	// prepare station info
+	if (memcmp(da, "\x0\x0\x0\x0\x0\x0", 6) && !IS_MCAST(da))
+	{
+		pstat = get_stainfo(priv, da);
+		if (pstat == NULL)
+		{
+			pstat = alloc_stainfo(priv, da, -1);
+			pstat->state = WIFI_AUTH_SUCCESS | WIFI_ASOC_STATE;
+			memcpy(pstat->bssrateset, AP_BSSRATE, AP_BSSRATE_LEN);
+			pstat->bssratelen = AP_BSSRATE_LEN;
+			pstat->expire_to = 30000;
+			asoc_list_add(priv, pstat);
+			cnt_assoc_num(priv, pstat, INCREASE, (char *)__FUNCTION__);
+			if (QOS_ENABLE)
+				pstat->QosEnabled = 1;
+			if (priv->pmib->dot11BssType.net_work_type & WIRELESS_11N) {
+				pstat->ht_cap_len = priv->ht_cap_len;
+				memcpy(&pstat->ht_cap_buf, &priv->ht_cap_buf, priv->ht_cap_len);
+			}
+			pstat->current_tx_rate = find_rate(priv, pstat, 1, 0);
+			update_fwtbl_asoclst(priv, pstat);
+//			add_update_RATid(priv, pstat);
+		}
+	}
+
+#ifdef  CONFIG_WLAN_HAL
+	if (IS_HAL_CHIP(priv)) {
+	    GET_HAL_INTERFACE(priv)->SetHwRegHandler(priv, HW_VAR_MAC_LOOPBACK_ENABLE, NULL);
+	} else if (CONFIG_WLAN_NOT_HAL_EXIST)
+#endif
+	{
+		// accept all packets
+	//	RTL_W32(_RCR_, RTL_R32(_RCR_) | _AAP_);
+		RTL_W32(RCR, RTL_R32(RCR) | RCR_AAP);
+
+
+		// enable MAC loopback
+	//	RTL_W32(_CPURST_, RTL_R32(_CPURST_) | BIT(16) | BIT(17));
+		RTL_W32(CR, RTL_R32(CR) | (LB_MAC_DLY&LBMODE_Mask)<<LBMODE_SHIFT);
+	}
+}
+#endif // DRVMAC_LB
+
+
+int dynamic_RF_pwr_adj(struct rtl8192cd_priv *priv, unsigned char *data, unsigned long data_len)
+{
+	unsigned char *ptr = data;
+	int index, minus_sign, adj_value;
+	unsigned int writeVal, readVal;
+	unsigned char byte0, byte1, byte2, byte3;
+	unsigned char RF6052_MAX_TX_PWR = 0x3F;
+
+	if (*ptr == '-') {
+		minus_sign = 1;
+		ptr++;
+	}
+	else if (*ptr == '+') {
+		minus_sign = 0;
+		ptr++;
+	}
+	else {
+		snprintf((char *)data, data_len, "[FAIL] No sign to know to add or subtract\n");
+		return strlen((char *)data)+1;
+	}
+
+	adj_value = _atoi((char *)ptr, 10);
+	if (adj_value >= 64) {
+		snprintf((char *)data, data_len, "[FAIL] Adjust value too large\n");
+		return strlen((char *)data)+1;
+	}
+
+	for (index=0; index<8; index++)
+	{
+		if ((index == 2) || (index == 3))
+			continue;
+
+		readVal = PHY_QueryBBReg(priv, rTxAGC_A_Rate18_06+index*4, 0x7f7f7f7f);
+		byte0 = (readVal & 0xff000000) >> 24;
+		byte1 = (readVal & 0x00ff0000) >> 16;
+		byte2 = (readVal & 0x0000ff00) >> 8;
+		byte3 = (readVal & 0x000000ff);
+
+		if (minus_sign) {
+			if (byte0 >= adj_value)
+				byte0 -= adj_value;
+			else
+				byte0 = 0;
+			if (byte1 >= adj_value)
+				byte1 -= adj_value;
+			else
+				byte1 = 0;
+			if (byte2 >= adj_value)
+				byte2 -= adj_value;
+			else
+				byte2 = 0;
+			if (byte3 >= adj_value)
+				byte3 -= adj_value;
+			else
+				byte3 = 0;
+		}
+		else {
+			byte0 += adj_value;
+			byte1 += adj_value;
+			byte2 += adj_value;
+			byte3 += adj_value;
+		}
+
+		// Max power index = 0x3F Range = 0-0x3F
+		if (byte0 > RF6052_MAX_TX_PWR)
+			byte0 = RF6052_MAX_TX_PWR;
+		if (byte1 > RF6052_MAX_TX_PWR)
+			byte1 = RF6052_MAX_TX_PWR;
+		if (byte2 > RF6052_MAX_TX_PWR)
+			byte2 = RF6052_MAX_TX_PWR;
+		if (byte3 > RF6052_MAX_TX_PWR)
+			byte3 = RF6052_MAX_TX_PWR;
+
+		writeVal = (byte0<<24) | (byte1<<16) |(byte2<<8) | byte3;
+		PHY_SetBBReg(priv, rTxAGC_A_Rate18_06+index*4, 0x7f7f7f7f, writeVal);
+	}
+
+	byte0 = PHY_QueryBBReg(priv, rTxAGC_A_CCK1_Mcs32, bTxAGCRateCCK);
+	if (minus_sign)
+		byte0 -= adj_value;
+	else
+		byte0 += adj_value;
+	if (byte0 > RF6052_MAX_TX_PWR)
+		byte0 = RF6052_MAX_TX_PWR;
+	PHY_SetBBReg(priv, rTxAGC_A_CCK1_Mcs32, bTxAGCRateCCK, byte0);
+
+	snprintf((char *)data, data_len, "[SUCCESS] %s %d level RF power\n", minus_sign?"Subtract":"Add", adj_value);
+	return strlen((char *)data)+1;
+}
+
+
+#ifdef DFS
+void reset_nop_channel(struct rtl8192cd_priv *priv)
+{
+	if (timer_pending(&priv->ch52_timer)) {
+		del_timer_sync(&priv->ch52_timer);
+		rtl8192cd_ch52_timer(priv);
+	}
+
+	if (timer_pending(&priv->ch56_timer)) {
+		del_timer_sync(&priv->ch56_timer);
+		rtl8192cd_ch56_timer(priv);
+	}
+
+	if (timer_pending(&priv->ch60_timer)) {
+		del_timer_sync(&priv->ch60_timer);
+		rtl8192cd_ch60_timer(priv);
+	}
+
+	if (timer_pending(&priv->ch64_timer)) {
+		del_timer_sync(&priv->ch64_timer);
+		rtl8192cd_ch64_timer(priv);
+	}
+
+	if (timer_pending(&priv->ch100_timer)) {
+		del_timer_sync(&priv->ch100_timer);
+		rtl8192cd_ch100_timer(priv);
+	}
+
+	if (timer_pending(&priv->ch104_timer)) {
+		del_timer_sync(&priv->ch104_timer);
+		rtl8192cd_ch104_timer(priv);
+	}
+
+	if (timer_pending(&priv->ch108_timer)) {
+		del_timer_sync(&priv->ch108_timer);
+		rtl8192cd_ch108_timer(priv);
+	}
+
+	if (timer_pending(&priv->ch112_timer)) {
+		del_timer_sync(&priv->ch112_timer);
+		rtl8192cd_ch112_timer(priv);
+	}
+
+	if (timer_pending(&priv->ch116_timer)) {
+		del_timer_sync(&priv->ch116_timer);
+		rtl8192cd_ch116_timer(priv);
+	}
+
+	if (timer_pending(&priv->ch120_timer)) {
+		del_timer_sync(&priv->ch120_timer);
+		rtl8192cd_ch120_timer(priv);
+	}
+
+	if (timer_pending(&priv->ch124_timer)) {
+		del_timer_sync(&priv->ch124_timer);
+		rtl8192cd_ch124_timer(priv);
+	}
+
+	if (timer_pending(&priv->ch128_timer)) {
+		del_timer_sync(&priv->ch128_timer);
+		rtl8192cd_ch128_timer(priv);
+	}
+
+	if (timer_pending(&priv->ch132_timer)) {
+		del_timer_sync(&priv->ch132_timer);
+		rtl8192cd_ch132_timer(priv);
+	}
+
+	if (timer_pending(&priv->ch136_timer)) {
+		del_timer_sync(&priv->ch136_timer);
+		rtl8192cd_ch136_timer(priv);
+	}
+
+	if (timer_pending(&priv->ch140_timer)) {
+		del_timer_sync(&priv->ch140_timer);
+		rtl8192cd_ch140_timer(priv);
+	}
+
+	if (timer_pending(&priv->ch144_timer)) {
+		del_timer_sync(&priv->ch144_timer);
+		rtl8192cd_ch144_timer(priv);
+	}
+}
+#endif
+
+
+extern void clear_shortcut_cache(void);
+
+#ifdef WIFI_HAPD
+
+int rtl8192cd_net80211_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+{
+	struct rtl8192cd_priv *priv = GET_DEV_PRIV(dev);
+	struct wifi_mib *pmib = priv->pmib;
+	unsigned long flags;
+	struct iwreq *wrq = (struct iwreq *) ifr;
+	unsigned char *tmpbuf, *tmp1;
+	UINT16 sta_num;
+	int i = 0, ret = 0, sizeof_tmpbuf;
+	static unsigned char tmpbuf1[1024];
+
+	DEBUG_TRACE;
+
+	sizeof_tmpbuf = sizeof(tmpbuf1);
+	tmpbuf = tmpbuf1;
+	memset(tmpbuf, '\0', sizeof_tmpbuf);
+
+	SAVE_INT_AND_CLI(flags);
+	SMP_LOCK(flags);
+
+	//printk("rtl8192cd_net80211_ioctl, name = %s, cmd =0x%x\n", wrq->ifr_name, cmd);
+
+	switch ( cmd )
+	{
+
+		case IEEE80211_IOCTL_SETPARAM:
+			ret = rtl_net80211_setparam(dev, NULL, &wrq->u, NULL);
+			break;
+		case IEEE80211_IOCTL_GETPARAM:
+			break;
+		case IEEE80211_IOCTL_SETMODE:
+			break;
+		case IEEE80211_IOCTL_GETMODE:
+			break;
+		case IEEE80211_IOCTL_SETWMMPARAMS:
+			break;
+		case IEEE80211_IOCTL_GETWMMPARAMS:
+			break;
+		case IEEE80211_IOCTL_SETCHANLIST:
+			break;
+		case IEEE80211_IOCTL_GETCHANLIST:
+			break;
+		case IEEE80211_IOCTL_CHANSWITCH:
+			break;
+		case IEEE80211_IOCTL_GET_APPIEBUF:
+			ret = rtl_net80211_getwpaie(dev, NULL, &wrq->u, NULL);
+			break;
+		case IEEE80211_IOCTL_SET_APPIEBUF:
+			ret = rtl_net80211_setappiebuf(dev, NULL, &wrq->u, NULL);
+			break;
+		case IEEE80211_IOCTL_FILTERFRAME:
+			break;
+		case IEEE80211_IOCTL_GETCHANINFO:
+			break;
+		case IEEE80211_IOCTL_SETOPTIE:
+#ifdef WIFI_WPAS
+			ret = rtl_net80211_setoptie(dev, NULL, &wrq->u, NULL);
+#endif
+			break;
+		case IEEE80211_IOCTL_GETOPTIE:
+			break;
+		case IEEE80211_IOCTL_SETMLME:
+			ret = rtl_net80211_setmlme(dev, NULL, &wrq->u, NULL);
+			break;
+		case IEEE80211_IOCTL_SETKEY:
+			ret = rtl_net80211_setkey(dev, NULL, &wrq->u, NULL);
+			break;
+		case IEEE80211_IOCTL_DELKEY:
+			ret = rtl_net80211_delkey(dev, NULL, &wrq->u, NULL);
+			break;
+		case IEEE80211_IOCTL_ADDMAC:
+			break;
+		case IEEE80211_IOCTL_DELMAC:
+			break;
+#if	((defined(WIFI_HAPD) || defined(RTK_NL80211)) && defined(WDS)) && !defined(HAPD_DRV_PSK_WPS)
+		case IEEE80211_IOCTL_WDSADDMAC:
+			ret = rtl_net80211_wdsaddmac(dev, NULL, &wrq->u, NULL);
+			break;
+		case IEEE80211_IOCTL_WDSDELMAC:
+			ret = rtl_net80211_wdsdelmac(dev, NULL, &wrq->u, NULL);
+			break;
+#endif
+		case IEEE80211_IOCTL_KICKMAC:
+			break;
+
+#ifdef WIFI_WPAS
+		case WPAS_IOCTL_CUSTOM: //_Eric ?? No need to define ??
+			{
+				unsigned char *is_hapd = (unsigned char *)(wrq->u.data.pointer);
+
+				if(*is_hapd == 0)
+					ret = rtl_wpas_custom(dev, NULL, &wrq->u, NULL);
+				else
+					ret = rtl_hapd_config(dev, NULL, &wrq->u, NULL);
+			}
+
+			break;
+#else
+		case HAPD_IOCTL_SETCONFIG:
+			ret = rtl_hapd_config(dev, NULL, &wrq->u, NULL);
+			break;
+#endif
+
+		default:
+			break;
+
+	}
+
+	RESTORE_INT(flags);
+	SMP_UNLOCK(flags);
+
+	return ret;
+
+}
+#endif
+
+#if defined(RTK_AC_SUPPORT) || defined(HS2_SUPPORT) || defined(CONFIG_IEEE80211W)//for 11ac logo
+void reset_default_sigma(struct rtl8192cd_priv *priv)
+{
+#ifdef RTK_AC_SUPPORT
+	if (priv->pmib->dot11RFEntry.phyBandSelect == PHY_BAND_5G)
+		printk("reset_default_sigma for VHT5G (11AC, 80M) +++\n");
+	else
+	{
+		printk("2.4G, No need to reset_default_sigma\n");
+		return;
+	}
+	
+	//No Need to reset ssid, channel, band, rts , frag, security, edcu	  
+
+	//priv->pmib->dot11RFEntry.dot11channel	
+	//priv->pmib->dot11StationConfigEntry.dot11DesiredSSID
+	//priv->pmib->dot11OperationEntry.dot11FragmentationThreshold
+	priv->pmib->dot11StationConfigEntry.dot11BeaconPeriod = 100;
+	priv->pmib->dot11nConfigEntry.dot11nUse40M = 2;
+	//priv->pmib->dot11OperationEntry.dot11RTSThreshold
+	//priv->pmib->dot11nConfigEntry.dot11n2ndChOffset = 1;
+	//priv->pmib->dot11OperationEntry.opmode
+	priv->pmib->dot11nConfigEntry.dot11nShortGIfor20M = 1;	  
+	priv->pmib->dot11nConfigEntry.dot11nShortGIfor40M = 1;
+	priv->pmib->dot11nConfigEntry.dot11nShortGIfor80M = 1;
+	priv->pmib->dot11nConfigEntry.dot11nAMPDU = 1;
+	priv->pmib->dot11nConfigEntry.dot11nAMSDU = 1;
+	priv->pmib->dot11nConfigEntry.dot11nAddBAreject = 0;
+	//priv->pmib->dot11RFEntry.phyBandSelect
+	priv->pmib->dot11BssType.net_work_type = (WIRELESS_11A |WIRELESS_11N |WIRELESS_11AC);
+	priv->pmib->dot11StationConfigEntry.legacySTADeny = 0;
+	//priv->pmib->dot1180211AuthEntry.dot11PrivacyAlgrthm
+	//priv->pmib->dot1180211AuthEntry.dot11PassPhraseGuest
+	priv->pmib->dot11QosEntry.dot11QosEnable = 1;
+	priv->pmib->dot11RFEntry.MIMO_TR_mode = MIMO_2T2R;
+	priv->pmib->dot11acConfigEntry.dot11SupportedVHT = 0xfffa;
+	priv->pmib->dot11acConfigEntry.dot11VHT_TxMap = 0xfffff;
+	priv->pshare->rf_ft_var.cca_rts = 0;
+	priv->pmib->dot11StationConfigEntry.autoRate = 1;
+	priv->pmib->dot11StationConfigEntry.fixedTxRate	= 0;
+	priv->pshare->rf_ft_var.txforce = 0xff;
+	priv->pshare->rf_ft_var.sgiforce = 2;
+	priv->pmib->dot11nConfigEntry.dot11nTxNoAck = 0;
+#ifdef RTL_MANUAL_EDCA
+	priv->pmib->dot11QosEntry.ManualEDCA = 0;
+#endif
+	priv->pmib->dot11nConfigEntry.dot11nLgyEncRstrct=15;
+	priv->pshare->rf_ft_var.opmtest = 0;
+	priv->pmib->dot11RFEntry.txbf = 1;
+	priv->pmib->dot11nConfigEntry.dot11nLDPC = 1;
+	priv->pmib->dot11nConfigEntry.dot11nSTBC = 1;
+	//priv->pmib->dot11RFEntry.txldpc =0;
+	//priv->pmib->dot11RFEntry.rxldpc =0;
+	priv->pshare->rf_ft_var.lgirate = 0xffff;
+	priv->pshare->rf_ft_var.lpwrc = 20;
+	priv->pshare->rf_ft_var.no_rtscts = 0;
+	priv->pmib->dot11StationConfigEntry.dot11RegDomain = DOMAIN_TEST;
+	priv->pshare->rf_ft_var.sigma_mode = AC_SIGMA_APUT;
+#ifdef BEAMFORMING_SUPPORT
+	priv->pshare->rf_ft_var.ndparate = 0x2c;
+#endif
+#endif
+
+#ifdef HS2_SUPPORT
+/* Hotsport 2.0 Release 1 */
+	priv->pmib->dot11OperationEntry.block_relay = 0;
+	priv->pmib->dot11RFEntry.phyBandSelect == PHY_BAND_2G;
+	priv->pmib->dot11RFEntry.dot11channel = 6;
+#endif
+}
+#endif
+
+#if defined(RTK_AC_SUPPORT)
+void reset_default_sigma_testbed(struct rtl8192cd_priv *priv)
+{
+	if (priv->pmib->dot11RFEntry.phyBandSelect == PHY_BAND_5G)
+		printk("reset_default_sigma_testbed for VHT5G (11AC, 80M) +++\n");
+	else
+	{
+		printk("2.4G, No need to reset_default_sigma_testbed\n");
+		return;
+	}
+
+	priv->pmib->dot11nConfigEntry.dot11nShortGIfor20M = 0;	  
+	priv->pmib->dot11nConfigEntry.dot11nShortGIfor40M = 0;
+	priv->pmib->dot11nConfigEntry.dot11nShortGIfor80M = 0;
+	priv->pmib->dot11acConfigEntry.dot11SupportedVHT = 0xfff0;
+	priv->pmib->dot11acConfigEntry.dot11VHT_TxMap = 0x3fcff;
+	priv->pmib->dot11RFEntry.txbf = 0;
+	priv->pmib->dot11nConfigEntry.dot11nSTBC = 0;
+	//priv->pmib->dot11nConfigEntry.dot11nAMSDU = 0;
+	priv->pmib->dot11nConfigEntry.dot11nLDPC = 0;
+	priv->pshare->rf_ft_var.sigma_mode = AC_SIGMA_APTB;
+}
+
+#endif
+
+#if defined(SMP_SYNC) && defined(__KERNEL__) && defined(CONFIG_PCI_HCI)
+unsigned long _ioctl_copy_from_user (struct rtl8192cd_priv *priv, void * to, const void * from, unsigned long n)
+{
+	unsigned long ret;
+
+	SMP_UNLOCK(priv->pshare->irq_save);
+	RESTORE_INT(priv->pshare->irq_save);
+	ret = copy_from_user(to, from, n);
+	SAVE_INT_AND_CLI(priv->pshare->irq_save);
+	SMP_LOCK(priv->pshare->irq_save);		
+
+	return ret;
+}
+
+unsigned long _ioctl_copy_to_user (struct rtl8192cd_priv *priv, void * to, const void * from, unsigned long n)
+{
+	unsigned long ret;
+
+	SMP_UNLOCK(priv->pshare->irq_save);
+	RESTORE_INT(priv->pshare->irq_save);
+	ret = copy_to_user(to, from, n);
+	SAVE_INT_AND_CLI(priv->pshare->irq_save);
+	SMP_LOCK(priv->pshare->irq_save);		
+
+	return ret;
+}
+#endif
+
+int rtl8192cd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+{
+	struct rtl8192cd_priv *priv = GET_DEV_PRIV(dev);
+	struct wifi_mib *pmib = priv->pmib;
+	unsigned long flags;
+	struct iwreq *wrq = (struct iwreq *) ifr;
+	unsigned char *tmpbuf, *tmp1;
+	UINT16 sta_num;
+	int	i = 0, ret = -1, sizeof_tmpbuf;
+#ifdef CONFIG_RTL8672
+	// MBSSID Port Mapping
+	int ifgrp_member_tmp;
+#endif
+	static unsigned char tmpbuf1[1560];		// enlarge for pass EAP packet by event queue
+#ifdef RTK_WOW
+	unsigned int wakeup_on_wlan = 0;
+#endif
+#ifdef D_ACL
+	struct stat_info *pstat;
+#endif
+
+#ifdef CONFIG_RTK_MESH
+	unsigned char strPID[10];
+	int len;
+	static UINT8 QueueData[MAXDATALEN2];
+	int		QueueDataLen;
+	// UINT8	val8;
+
+	// int j;
+	#define DATAQUEUE_EMPTY "Queue is empty"
+#endif
+
+	DEBUG_TRACE;
+
+
+#ifdef WIFI_HAPD
+		if((IEEE80211_IOCTL_SETPARAM <= cmd) && (cmd <= IEEE80211_IOCTL_KICKMAC))
+			return rtl8192cd_net80211_ioctl(dev, ifr, cmd);
+
+		if(cmd == HAPD_IOCTL_SETCONFIG)
+			return rtl8192cd_net80211_ioctl(dev, ifr, cmd);
+#endif
+
+#ifdef SMP_SYNC	
+	SAVE_INT_AND_CLI(priv->pshare->irq_save);
+	SMP_LOCK(priv->pshare->irq_save);
+#else
+	SAVE_INT_AND_CLI(flags);
+#endif
+
+	sizeof_tmpbuf = sizeof(tmpbuf1);
+	tmpbuf = tmpbuf1;
+	memset(tmpbuf, '\0', sizeof_tmpbuf);
+
+#ifdef MULTI_MAC_CLONE
+	ACTIVE_ID = 0;
+#endif
+
+	switch ( cmd )
+	{
+
+	case SIOCGIWNAME:
+		strncpy(wrq->u.name, "IEEE 802.11-DS", (IFNAMSIZ-1));
+		wrq->u.name[IFNAMSIZ-1] = '\0';
+		ret = 0;
+		break;
+#ifdef CONFIG_RTL_COMAPI_WLTOOLS
+	case SIOCGIFHWADDR:
+
+#ifdef WIFI_HAPD //_Eric ??
+		memcpy(ifr->ifr_hwaddr.sa_data, pmib->dot11OperationEntry.hwaddr, MACADDRLEN);
+#endif
+
+		memcpy(wrq->u.name, pmib->dot11OperationEntry.hwaddr, MACADDRLEN);
+		ret = 0;
+		break;
+	case SIOCSIWFREQ:	//set channel/frequency (Hz)
+	{
+		ret = rtl_siwfreq(dev, NULL, &wrq->u, NULL);
+		break;
+	}
+	case SIOCGIWFREQ:	// get channel/frequency (Hz)
+	{
+		ret = rtl_giwfreq(dev, NULL, &wrq->u, NULL);
+		break;
+	}
+#ifdef WIFI_WPAS
+	case SIOCSIWMODE:	//set operation mode
+	{
+		ret = rtl_siwmode(dev, NULL, &wrq->u, NULL);
+		break;
+	}
+#endif
+	case SIOCGIWMODE:	//get operation mode
+	{
+		ret = rtl_giwmode(dev, NULL, &wrq->u, NULL);
+		break;
+	}
+	case SIOCSIWAP:  //set access point MAC addresses
+	{
+		struct sockaddr *ap_addr=&wrq->u.ap_addr;
+		ret = rtl_siwap(dev, NULL, &wrq->u, ap_addr->sa_data);
+		break;
+	}
+	case SIOCGIWAP: 	//get access point MAC addresses
+	{
+		struct sockaddr *ap_addr=&wrq->u.ap_addr;
+		ret = rtl_giwap(dev, NULL, &wrq->u, ap_addr->sa_data);
+		break;
+	}
+	case SIOCGIWESSID:	//Get ESSID
+	{
+		struct iw_point *essid=&wrq->u.essid;
+		ret = rtl_giwessid(dev, NULL, &wrq->u, essid->pointer);
+		break;
+	}
+	case SIOCSIWESSID:	//Set ESSID
+	{
+		struct iw_point *essid=&wrq->u.essid;
+		ret = rtl_siwessid(dev, NULL, &wrq->u, essid->pointer);
+		break;
+	}
+	case SIOCGIWRATE: //get default bit rate (bps)
+		ret = rtl_giwrate(dev, NULL, &wrq->u, NULL);
+		break;
+	case SIOCSIWRATE:  //set default bit rate (bps)
+		ret = rtl_siwrate(dev, NULL, &wrq->u, NULL);
+		break;
+	case SIOCGIWRANGE: //Range of Parameters
+	{
+		struct iw_point *data = &wrq->u.data;
+		ret = rtl_giwrange(dev, NULL, &wrq->u, data->pointer);
+		break;
+	}
+	case SIOCSIWSCAN:
+	{
+		struct iw_point *data = &wrq->u.data;
+		ret = rtl_siwscan(dev, NULL, &wrq->u, data->pointer);
+		break;
+	}
+	case SIOCGIWSCAN:
+	{
+		struct iw_point *data = &wrq->u.data;
+		ret = rtl_giwscan(dev, NULL, &wrq->u, data->pointer);
+		break;
+	}
+	case SIOCGIWRTS:  // get RTS/CTS threshold (bytes)
+	{
+		ret = rtl_giwrts(dev, NULL, &wrq->u, NULL);
+		break;
+	}
+	case SIOCSIWRTS:  //set RTS/CTS threshold (bytes)
+	{
+		ret = rtl_siwrts(dev, NULL, &wrq->u, NULL);
+		break;
+	}
+	case SIOCGIWFRAG:  //get fragmentation thr (bytes)
+	{
+		ret = rtl_giwfrag(dev, NULL, &wrq->u, NULL);
+		break;
+	}
+	case SIOCSIWFRAG:  //set fragmentation thr (bytes)
+	{
+		ret = rtl_siwfrag(dev, NULL, &wrq->u, NULL);
+		break;
+	}
+	case SIOCSIWRETRY:	//set retry limit
+	{
+		ret = rtl_siwretry(dev, NULL, &wrq->u, NULL);
+		break;
+	}
+	case SIOCGIWRETRY:	//get retry limit
+	{
+		ret = rtl_giwretry(dev, NULL, &wrq->u, NULL);
+		break;
+	}
+	case SIOCSIWENCODE:  //get encoding token & mode
+	{
+		struct iw_point *erq=&wrq->u.encoding;
+		if(erq)
+			ret = rtl_siwencode(dev, NULL, &wrq->u, erq->pointer);
+		break;
+	}
+	case SIOCGIWENCODE:  //get encoding token & mode
+	{
+		struct iw_point *erq=&wrq->u.encoding;
+		if(erq)
+			ret = rtl_giwencode(dev, NULL, &wrq->u, erq->pointer);
+		break;
+	}
+	case SIOCGIWPOWER:
+	{
+		ret = rtl_giwpower(dev, NULL, &wrq->u, NULL);
+		break;
+	}
+#endif
+
+	case SIOCMIBINIT:	//-- copy kernel data to user data --//
+		if (wrq->u.data.length != sizeof(struct wifi_mib)) {
+			panic_printk("IOCTL: mib size mismatch!\n");
+			ret = -1;
+			break;
+		}
+		if (ioctl_copy_to_user((void *)wrq->u.data.pointer, (void *)pmib, wrq->u.data.length) == 0)
+			ret = 0;
+		break;
+
+	case SIOCMIBSYNC:	//-- sync user data to kernel data  --//
+		if (wrq->u.data.length != sizeof(struct wifi_mib)) {
+			panic_printk("IOCTL: mib size mismatch!\n");
+			ret = -1;
+			break;
+		}
+		if (ioctl_copy_from_user((void *)pmib, (void *)wrq->u.data.pointer, wrq->u.data.length) == 0)
+			ret = 0;
+		break;
+
+	case SIOCGIWPRIV:	//-- get private ioctls for iwpriv --//
+		if (wrq->u.data.pointer) {
+#ifdef __KERNEL__
+#ifdef __LINUX_2_6__
+			ret = access_ok(VERIFY_WRITE, (const void *)wrq->u.data.pointer, sizeof(privtab));
+			if (!ret) {
+				ret = -EFAULT;
+				DEBUG_ERR("user space valid check error!\n");
+				break;
+			}
+#else
+			ret = verify_area(VERIFY_WRITE, (const void *)wrq->u.data.pointer, sizeof(privtab));
+			if (ret) {
+				DEBUG_ERR("verify_area() error!\n");
+				break;
+			}
+#endif
+#else
+			ret = 0;
+#endif
+#ifdef CONFIG_RTL8672
+			wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
+			if (ioctl_copy_to_user((void *)wrq->u.data.pointer, privtab, sizeof(privtab)))
+				ret = -EFAULT;
+#else
+			if ((sizeof(privtab) / sizeof(privtab[0])) <= wrq->u.data.length)
+			{
+			wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
+				if (ioctl_copy_to_user((void *)wrq->u.data.pointer, privtab, sizeof(privtab)))
+				ret = -EFAULT;
+			}else{
+				ret = -E2BIG;
+			}
+#endif
+		}
+		break;
+
+
+#ifdef D_ACL	//tsananiu ; mesh related
+	case RTL8192CD_IOCTL_ADD_ACL_TABLE:
+		if ((ret = iwpriv_atoi(priv,(unsigned char *)(wrq->u.data.pointer),tmpbuf,wrq->u.data.length, sizeof_tmpbuf)) )
+		{
+			DEBUG_ERR("Trasnslate MAC address from user space error\n");
+			break;
+		}
+		ret = acl_add_cmd(priv, (unsigned char *)(wrq->u.data.pointer), wrq->u.data.length);
+		if (ret >= 0) {
+			pstat = get_stainfo(priv, tmpbuf);
+
+			if (priv->pmib->dot11StationConfigEntry.dot11AclMode == ACL_deny) {
+				if (NULL != pstat) {
+#ifdef CONFIG_RTK_MESH
+					if (!isSTA(pstat)) {
+						DEBUG_INFO("I am a mesh node\n");
+						issue_disassoc_MP(priv, pstat, 0, 0);
+					} else
+#endif
+					{	//if station
+						sprintf((char *)tmpbuf, "%02x%02x%02x%02x%02x%02x",
+							pstat->hwaddr[0],pstat->hwaddr[1],pstat->hwaddr[2],pstat->hwaddr[3],pstat->hwaddr[4],pstat->hwaddr[5]);
+						del_sta(priv, tmpbuf);
+					}
+				}
+			}
+		}
+		break;
+
+	case RTL8192CD_IOCTL_REMOVE_ACL_TABLE:
+		if ((ret = iwpriv_atoi(priv,(unsigned char *)(wrq->u.data.pointer),tmpbuf,wrq->u.data.length, sizeof_tmpbuf)) )
+		{
+			DEBUG_ERR("Trasnslate MAC address from user space error\n");
+			break;
+		}
+		ret = acl_remove_cmd(priv, (unsigned char *)(wrq->u.data.pointer), wrq->u.data.length);
+		if (ret >= 0) {
+			pstat = get_stainfo(priv, tmpbuf);
+
+			if (priv->pmib->dot11StationConfigEntry.dot11AclMode == ACL_allow) {
+				if (NULL != pstat) {
+#ifdef CONFIG_RTK_MESH
+					if (!isSTA(pstat)) {
+						DEBUG_INFO("I am a mesh node\n");
+						issue_disassoc_MP(priv, pstat, 0, 0);
+					} else
+#endif
+					{	//if station
+						sprintf((char *)tmpbuf, "%02x%02x%02x%02x%02x%02x",
+							pstat->hwaddr[0],pstat->hwaddr[1],pstat->hwaddr[2],pstat->hwaddr[3],pstat->hwaddr[4],pstat->hwaddr[5]);
+						del_sta(priv, tmpbuf);
+					}
+				}
+			}
+		}
+		break;
+
+	case RTL8192CD_IOCTL_GET_ACL_TABLE:
+		ret = acl_query_cmd(priv, (unsigned char *)(wrq->u.data.pointer), wrq->u.data.length);
+		if (ret >= 0) {
+			wrq->u.data.length = ret;
+			ret = 0;
+		}
+
+		break;
+
+	case RTL8192CD_IOCTL_CLEAR_ACL_TABLE:
+		ret = acl_clear_cmd(priv);
+		break;
+
+#endif//tsananiu//
+
+	case RTL8192CD_IOCTL_SET_MIB:
+		if ((wrq->u.data.length > sizeof_tmpbuf) ||
+			ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		ret = set_mib(priv, tmpbuf);
+		break;
+
+	case RTL8192CD_IOCTL_GET_MIB:
+		if ((wrq->u.data.length > sizeof_tmpbuf) ||
+			ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		i = get_mib(priv, tmpbuf);
+		if (i >= 0) {
+			if ((i > 0) && ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+				break;
+			wrq->u.data.length = i;
+			ret = 0;
+		}
+		break;
+
+#ifdef _IOCTL_DEBUG_CMD_
+	case RTL8192CD_IOCTL_WRITE_REG:
+		if ((wrq->u.data.length > sizeof_tmpbuf) ||
+			ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		ret = write_reg(priv, tmpbuf);
+		break;
+
+	case RTL8192CD_IOCTL_READ_REG:
+		if ((wrq->u.data.length > sizeof_tmpbuf) ||
+			ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		i = read_reg(priv, tmpbuf);
+		if (i >= 0) {
+			if ((i > 0) && ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+				break;
+			wrq->u.data.length = i;
+			ret = 0;
+		}
+		break;
+
+	case RTL8192CD_IOCTL_WRITE_MEM:
+		if ((wrq->u.data.length > sizeof_tmpbuf) ||
+			ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		ret = write_mem(priv, tmpbuf);
+		break;
+
+	case RTL8192CD_IOCTL_READ_MEM:
+		if ((wrq->u.data.length > sizeof_tmpbuf) ||
+			ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+				break;
+		i = read_mem(priv, tmpbuf);
+		if (i >= 0) {
+			if ((i > 0) && ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+				break;
+			wrq->u.data.length = i;
+			ret = 0;
+		}
+		break;
+
+	case RTL8192CD_IOCTL_WRITE_BB_REG:
+		if ((wrq->u.data.length > sizeof_tmpbuf) ||
+			ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		ret = write_bb_reg(priv, tmpbuf);
+		break;
+
+	case RTL8192CD_IOCTL_READ_BB_REG:
+		if ((wrq->u.data.length > sizeof_tmpbuf) ||
+			ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		i = read_bb_reg(priv, tmpbuf);
+		if (i >= 0) {
+			if ((i > 0) && ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+				break;
+			wrq->u.data.length = i;
+			ret = 0;
+		}
+		break;
+
+	case RTL8192CD_IOCTL_WRITE_RF_REG:
+		if ((wrq->u.data.length > sizeof_tmpbuf) ||
+			ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		ret = write_rf_reg(priv, tmpbuf);
+		break;
+
+	case RTL8192CD_IOCTL_READ_RF_REG:
+		if ((wrq->u.data.length > sizeof_tmpbuf) ||
+			ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		i = read_rf_reg(priv, tmpbuf);
+		if (i >= 0) {
+			if ((i > 0) && ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+				break;
+			wrq->u.data.length = i;
+			ret = 0;
+		}
+		break;
+#endif // _IOCTL_DEBUG_CMD_
+
+
+	case RTL8192CD_IOCTL_DEL_STA:
+		if ((wrq->u.data.length > sizeof_tmpbuf) ||
+			ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		ret = del_sta(priv, tmpbuf);
+		break;
+
+
+	case RTL8192CD_IOCTL_WRITE_EEPROM:
+		if ((wrq->u.data.length > sizeof_tmpbuf) ||
+			ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		ret = write_eeprom(priv, tmpbuf);
+		break;
+
+	case RTL8192CD_IOCTL_READ_EEPROM:
+		if ((wrq->u.data.length > sizeof_tmpbuf) ||
+			ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		i = read_eeprom(priv, tmpbuf);
+		if (i >= 0) {
+			if ((i > 0) && ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+				break;
+			wrq->u.data.length = i;
+			ret = 0;
+		}
+		break;
+
+#ifdef RTK_WOW
+	case SIOCGRTKWOWSTAINFO:	//-- get station info for Realtek proprietary wake up on wlan mode--//
+		wakeup_on_wlan = 1;
+#endif
+	case SIOCGIWRTLSTAINFO:	//-- get station table information --//
+		sizeof_tmpbuf = sizeof(sta_info_2_web) * (NUM_STAT + 1); // for the max of all sta info
+#ifdef __ECOS
+		tmp1 = (unsigned char *)sta_info;
+#else
+		tmp1 = (unsigned char *)kmalloc(sizeof_tmpbuf, GFP_KERNEL);
+		if (!tmp1) {
+			printk("Unable to allocate temp buffer for ioctl (SIOCGIWRTLSTAINFO)!\n");
+			ret = -ENOMEM;
+			break;
+		}
+		memset(tmp1, '\0', sizeof(sta_info_2_web));
+#endif
+		do {
+		if (ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, 1)) {
+			ret = -EFAULT;
+			break;
+		}
+		if ((tmpbuf[0] == 0) || (tmpbuf[0] > NUM_STAT))
+			sta_num = NUM_STAT;
+		else
+			sta_num = tmpbuf[0];
+#ifdef RTK_WOW
+		get_sta_info(priv, (sta_info_2_web *)(tmp1 + sizeof(sta_info_2_web)), sta_num, wakeup_on_wlan);
+#else
+		get_sta_info(priv, (sta_info_2_web *)(tmp1 + sizeof(sta_info_2_web)), sta_num);
+#endif
+		if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmp1, sizeof(sta_info_2_web)*(sta_num+1)))
+			break;
+		wrq->u.data.length = sizeof(sta_info_2_web)*(sta_num+1);
+		ret = 0;
+		} while (0);
+
+#ifndef __ECOS
+		kfree(tmp1);
+#endif
+		break;
+
+	case SIOCGIWRTLSTANUM:	//-- get the number of stations in table --//
+#ifdef UNIVERSAL_REPEATER
+		if (IS_VXD_INTERFACE(priv) && (OPMODE & WIFI_AP_STATE) &&
+				!IS_DRV_OPEN(priv))
+			sta_num = 0;
+		else
+#endif
+		//sta_num = get_assoc_sta_num(priv);	// this will count expired sta
+		sta_num = priv->assoc_num;
+		if (ioctl_copy_to_user((void *)wrq->u.data.pointer, &sta_num, sizeof(sta_num)))
+			break;
+		wrq->u.data.length = sizeof(sta_num);
+		ret = 0;
+		break;
+
+	case SIOCGIWRTLDRVVERSION:
+		tmpbuf[0] = DRV_VERSION_H;
+		tmpbuf[1] = DRV_VERSION_L;
+		if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, 2))
+			break;
+		wrq->u.data.length = 2;
+		ret = 0;
+		break;
+
+	case SIOCGIWRTLGETBSSINFO: //-- get BSS info --//
+		get_bss_info(priv, (bss_info_2_web *)tmpbuf);
+		if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, sizeof(bss_info_2_web)))
+			break;
+		wrq->u.data.length = sizeof(bss_info_2_web);
+		ret = 0;
+		break;
+
+#if defined(CONFIG_RTL8186_KB_N)//To get auth result
+	case SIOCGIWRTLAUTH:
+		if (ioctl_copy_to_user((void *)wrq->u.data.pointer, &authRes, sizeof(authRes)))
+			break;
+		wrq->u.data.length = sizeof(authRes);
+		ret = 0;
+		authRes = 0;//To init authRes
+		break;
+#endif
+
+#ifdef WDS
+	case SIOCGIWRTLGETWDSINFO: //-- get WDS table information --//
+		ret = get_wds_info(priv, (web_wds_info *)tmpbuf);
+		if ((ret > 0) && ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, ret))
+			break;
+		wrq->u.data.length = ret;
+#ifdef __ECOS
+		ret = 0;
+#endif
+		break;
+#endif
+
+	case SIOCSIWRTLSTATXRATE:	//-- set station tx rate --//
+		if (wrq->u.data.length != sizeof(struct _wlan_sta_rateset) ||
+			ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, sizeof(struct _wlan_sta_rateset)))
+			break;
+		ret = set_sta_txrate(priv, (struct _wlan_sta_rateset *)tmpbuf);
+		break;
+
+
+#ifdef MICERR_TEST
+	case SIOCSIWRTLMICERROR:
+		ret = iwpriv_atoi(priv,(unsigned char *)(wrq->u.data.pointer),tmpbuf,wrq->u.data.length, sizeof_tmpbuf);
+		ret = issue_mic_err_pkt(priv, tmpbuf);
+		break;
+#ifdef CLIENT_MODE
+	case SIOCSIWRTLMICREPORT:
+	{
+		struct sta_info *pstat;
+		if ((pstat = get_stainfo(priv, BSSID)) != NULL)
+			ClientSendEAPOL(priv, pstat, 0);
+	}
+		ret = 0;
+		break;
+#endif
+#endif
+
+
+	case SIOCSACLADD:
+		ret = acl_add_cmd(priv, (unsigned char *)(wrq->u.data.pointer), wrq->u.data.length);
+		break;
+
+	case SIOCSACLDEL:
+		ret = acl_remove_cmd(priv, (unsigned char *)(wrq->u.data.pointer), wrq->u.data.length);
+		break;
+
+	case SIOCSACLQUERY:
+		ret = acl_query_cmd(priv, (unsigned char *)(wrq->u.data.pointer), wrq->u.data.length);
+		if (ret >= 0) {
+			wrq->u.data.length = ret;
+			ret = 0;
+		}
+		break;
+
+#if defined(CONFIG_RTK_MESH) && defined(_MESH_ACL_ENABLE_)
+	case SIOCSMESHACLADD:
+		ret = mesh_acl_add_cmd(priv, (unsigned char *)(wrq->u.data.pointer), wrq->u.data.length);
+		break;
+
+	case SIOCSMESHACLDEL:
+		ret = mesh_acl_remove_cmd(priv, (unsigned char *)(wrq->u.data.pointer), wrq->u.data.length);
+		break;
+
+	case SIOCSMESHACLQUERY:
+		ret = mesh_acl_query_cmd(priv, (unsigned char *)(wrq->u.data.pointer), wrq->u.data.length);
+		if (ret >= 0) {
+			wrq->u.data.length = ret;
+			ret = 0;
+		}
+		break;
+#endif
+
+	case SIOCGMISCDATA:
+		get_misc_data(priv, (struct _misc_data_ *)tmpbuf);
+		if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, sizeof(struct _misc_data_)))
+			break;
+		wrq->u.data.length = sizeof(struct _misc_data_);
+		ret = 0;
+		break;
+
+
+	case RTL8192CD_IOCTL_USER_DAEMON_REQUEST:
+		{
+		struct iw_point iw_data;
+		
+		if (wrq->u.data.length > sizeof_tmpbuf) {
+			printk("[%s][%s] length(%d) too long!\n", __func__, "daemonreq", wrq->u.data.length);
+			break;
+		}
+		if (ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length)) {
+			printk("[%s][%s] copy_from_user error!\n", __func__, "daemonreq");
+			break;
+		}
+		memcpy(&iw_data, &wrq->u.data, sizeof(wrq->u.data));
+		iw_data.pointer = tmpbuf;
+		
+#ifdef PCIE_POWER_SAVING
+		PCIeWakeUp(priv, POWER_DOWN_T0);
+#endif
+
+		ret = rtl8192cd_ioctl_priv_daemonreq(dev, &iw_data);
+		if (ret > 0) {
+			if (ret > sizeof_tmpbuf) {
+				printk("[%s][%s] ret(%d) too long!\n", __func__, "daemonreq", ret);
+				ret = -1;
+				break;
+			}
+			if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, ret)) {
+				printk("[%s][%s] copy_to_user error!\n", __func__, "daemonreq");
+				ret = -1;
+				break;
+			}
+			wrq->u.data.length = ret;
+			ret = 0;
+		}
+		}
+		break;
+
+
+#ifdef USE_PID_NOTIFY
+	case SIOCSIWRTLSETPID:
+		priv->pshare->wlanapp_pid = -1;
+		if (wrq->u.data.length != sizeof(pid_t) ||
+			ioctl_copy_from_user(&priv->pshare->wlanapp_pid, (void *)wrq->u.data.pointer, sizeof(pid_t))) {
+			//break;
+		} else {
+			ret = 0;
+		}
+
+	#if defined(LINUX_2_6_27_)
+		if (priv->pshare->wlanapp_pid != -1)
+		{
+			rcu_read_lock();
+			_wlanapp_pid = get_pid(find_vpid(priv->pshare->wlanapp_pid));
+			rcu_read_unlock();
+		}
+	#endif
+		break;
+#endif
+
+#ifdef CONFIG_RTL_WAPI_SUPPORT
+	case SIOCSIWRTLSETWAPIPID:
+		priv->pshare->wlanwapi_pid= -1;
+		if (wrq->u.data.length != sizeof(pid_t) ||
+			ioctl_copy_from_user(&priv->pshare->wlanwapi_pid, (void *)wrq->u.data.pointer, sizeof(pid_t))) {
+			//break;
+		} else {
+		ret = 0;
+		}
+
+	#if defined(LINUX_2_6_27_)
+		if (priv->pshare->wlanwapi_pid != -1)
+		{
+			rcu_read_lock();
+			_wlanwapi_pid = get_pid(find_vpid(priv->pshare->wlanwapi_pid));
+			rcu_read_unlock();
+		}
+	#endif
+		break;
+#endif
+        case RTL8192CD_IOCTL_SHOWSC:
+        {
+
+            #if defined(RTL_CACHED_BR_STA) && defined(BR_SHORTCUT)
+            extern struct brsc_cache_t brsc_cache_arr[MAX_BRSC_NUM];
+            int idx2;
+            unsigned char* cached_br_sta_mac;
+			int index = priv->dev->name[4] - '0';
+			panic_printk("Bridge shortcut info.:\n");
+            for(idx2=0;idx2<MAX_BRSC_NUM;idx2++){
+                if(brsc_cache_arr[idx2].occupy) {
+                    cached_br_sta_mac=brsc_cache_arr[idx2].cached_br_sta_mac;
+    	            panic_printk("  Source[%d]:%02x-%02x-%02x-%02x-%02x-%02x\n",idx2,
+    					cached_br_sta_mac[0],cached_br_sta_mac[1],cached_br_sta_mac[2],
+    					cached_br_sta_mac[3],cached_br_sta_mac[4],cached_br_sta_mac[5]);
+    	            panic_printk("  Interface\t:%s\n",brsc_cache_arr[idx2].cached_br_sta_dev->name);
+    			} else {
+    				panic_printk("cached_br_sta_dev is not valid entry\n");
+    			}
+            }
+            #endif            
+            #if defined(RTL_MESH_TXCACHE)            
+			extern unsigned char cached_mesh_mac[2][MACADDRLEN];
+			extern struct net_device *cached_mesh_dev[2];            
+            if(cached_mesh_dev[index]) {
+				panic_printk("  Source\t:%02x-%02x-%02x-%02x-%02x-%02x\n",
+					cached_mesh_mac[index][0],cached_mesh_mac[index][1],cached_mesh_mac[index][2],
+					cached_mesh_mac[index][3],cached_mesh_mac[index][4],cached_mesh_mac[index][5]);
+				panic_printk("  Interface\t:%s\n",cached_mesh_dev[index]->name);
+			} else {
+				panic_printk("cached_mesh_dev[%d] is not valid entry\n",index);
+			}
+
+			panic_printk("Mesh TX shortcut info:\n");
+            panic_printk("  Dirty : %d\n",priv->mesh_txcache.dirty);
+			panic_printk("  Destination\t:%02x-%02x-%02x-%02x-%02x-%02x\n",
+				priv->mesh_txcache.ether_da[0],priv->mesh_txcache.ether_da[1],priv->mesh_txcache.ether_da[2],
+				priv->mesh_txcache.ether_da[3],priv->mesh_txcache.ether_da[4],priv->mesh_txcache.ether_da[5]);
+			panic_printk("  Source\t:%02x-%02x-%02x-%02x-%02x-%02x\n",
+	            priv->mesh_txcache.ether_sa[0],priv->mesh_txcache.ether_sa[1],priv->mesh_txcache.ether_sa[2],
+            	priv->mesh_txcache.ether_sa[3],priv->mesh_txcache.ether_sa[4],priv->mesh_txcache.ether_sa[5]);
+			panic_printk("  Mesh Next-hop\t:%02x-%02x-%02x-%02x-%02x-%02x\n",
+	            priv->mesh_txcache.txcfg.nhop_11s[0],priv->mesh_txcache.txcfg.nhop_11s[1],priv->mesh_txcache.txcfg.nhop_11s[2],
+            	priv->mesh_txcache.txcfg.nhop_11s[3],priv->mesh_txcache.txcfg.nhop_11s[4],priv->mesh_txcache.txcfg.nhop_11s[5]);
+            #endif
+			ret = 0;
+        }
+        break;
+
+
+
+#ifdef	CONFIG_RTK_MESH
+	case RTL8192CD_IOCTL_STATIC_ROUTE:
+		if ((wrq->u.data.length > sizeof_tmpbuf) ||
+			ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		if( memcmp(tmpbuf, "del", 3)==0 )
+		{
+			mac12_to_6(tmpbuf+4, tmpbuf+0x100);
+			ret = remove_path_entry(priv, tmpbuf+0x100);
+		}
+		else if((memcmp(tmpbuf, "add", 3)==0) && (wrq->u.data.length>28) )
+		{
+			struct path_sel_entry Entry;
+			memset((void*)&Entry, 0, sizeof(struct path_sel_entry));
+			mac12_to_6(tmpbuf+4, Entry.destMAC);
+			mac12_to_6(tmpbuf+4+13, Entry.nexthopMAC);
+			Entry.flag=1;
+			ret = pathsel_table_entry_insert_tail( priv, &Entry);
+		}else
+			ret =0;
+		break;
+#if defined(RTK_MESH_MANUALMETRIC)
+            case RTL8192CD_IOCTL_MANUAL_METRIC:
+                if ((wrq->u.data.length > sizeof_tmpbuf) ||
+                    ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+                    break;
+        
+                ret = set_metric_manually(priv,tmpbuf);
+                break;
+#endif
+	case SIOCJOINMESH:
+		{
+			struct
+			{
+				unsigned char *meshid;
+				int meshid_len, channel, offset, reset;
+			}mesh_identifier;
+			if(wrq->u.data.length > 0)
+			{
+				memcpy(&mesh_identifier, wrq->u.data.pointer, wrq->u.data.length);
+                ret = rtl8192cd_join_mesh(priv, mesh_identifier.meshid, mesh_identifier.meshid_len, mesh_identifier.channel, mesh_identifier.offset,  mesh_identifier.reset);
+			}
+			else
+				ret = -1;
+		}
+		break;
+	case SIOCCHECKMESHLINK:	// This case might be removed when the mesh peerlink precedure has been completed
+		{
+			if(wrq->u.data.length == 6)
+				ret = rtl8192cd_check_mesh_link(priv, wrq->u.data.pointer);
+			else
+				ret = -1;
+		}
+		break;
+// ==== GANTOE ====
+#endif
+	case SIOCGIWRTLSCANREQ:		//-- Issue SS request --//
+	
+#if defined(CONFIG_RTL_SIMPLE_CONFIG_USE_WPS_BUTTON)
+		if(priv->simple_config_status >= 2)
+		{
+			break;
+		}
+#endif
+#ifdef UNIVERSAL_REPEATER
+		if (IS_VXD_INTERFACE(priv) && !priv->pmib->wscEntry.wsc_enable) {
+			DEBUG_ERR("can't do site-survey for vxd!\n");
+			break;
+		}
+#endif
+#ifdef MBSSID
+		if (
+			GET_ROOT(priv)->pmib->miscEntry.vap_enable &&
+			IS_VAP_INTERFACE(priv) && !priv->pmib->wscEntry.wsc_enable) {
+			DEBUG_ERR("can't do site-survey for vap!\n");
+			break;
+		}
+#endif
+
+#ifdef PCIE_POWER_SAVING
+		PCIeWakeUp(priv, POWER_DOWN_T0);
+#endif
+		ret = rtl8192cd_ss_req(priv, (unsigned char *)(wrq->u.data.pointer), wrq->u.data.length);
+		break;
+
+	case SIOCGIWRTLGETBSSDB:	//-- Get SS Status --//
+#if defined(CONFIG_RTL_SIMPLE_CONFIG_USE_WPS_BUTTON)
+		if(priv->simple_config_status >= 2)
+		{
+			break;
+		}
+#endif
+#ifdef UNIVERSAL_REPEATER
+		if (IS_VXD_INTERFACE(priv) && !priv->pmib->wscEntry.wsc_enable) {
+			DEBUG_ERR("can't get site-survey status for vxd!\n");
+			break;
+		}
+#endif
+#ifdef MBSSID
+		if (
+			GET_ROOT(priv)->pmib->miscEntry.vap_enable &&
+			IS_VAP_INTERFACE(priv) && !priv->pmib->wscEntry.wsc_enable) {
+			DEBUG_ERR("can't get site-survey status for vap!\n");
+			break;
+		}
+#endif
+		ret	= rtl8192cd_get_ss_status(priv, (unsigned char *)(wrq->u.data.pointer));
+		break;
+
+/*--------------P2P related ioctl----------------------------------start*/
+#ifdef P2P_SUPPORT
+	/*P2P UI request do p2p discovery */
+	case SIOCP2PSCANREQ:		
+		if(!(OPMODE&WIFI_P2P_SUPPORT))
+			return -1;
+
+		if((P2PMODE  != P2P_DEVICE) && (P2PMODE  != P2P_CLIENT))
+			return -1;		
+
+
+#ifdef PCIE_POWER_SAVING
+		PCIeWakeUp(priv, POWER_DOWN_T0);
+#endif
+		ret = rtl8192cd_p2p_ss_req(priv, (unsigned char *)(wrq->u.data.pointer), wrq->u.data.length);
+		break;
+	/*P2P UI get P2P SS Status and Result*/
+	case SIOCP2PGETRESULT:	
+
+		if(!(OPMODE&WIFI_P2P_SUPPORT))
+			return -1;
+		if((P2PMODE  != P2P_DEVICE) && (P2PMODE  != P2P_CLIENT))
+			return -1;
+		
+#ifdef UNIVERSAL_REPEATER
+		if (IS_VXD_INTERFACE(priv)) {
+			DEBUG_ERR("can't get site-survey status for vxd!\n");
+			break;
+		}
+#endif
+#ifdef MBSSID
+		if (
+			GET_ROOT(priv)->pmib->miscEntry.vap_enable &&
+			IS_VAP_INTERFACE(priv)) {
+			DEBUG_ERR("can't get site-survey status for vap!\n");
+			break;
+		}
+#endif
+		ret	= rtl8192cd_p2p_get_ss_status(priv, (unsigned char *)(wrq->u.data.pointer));
+		break;
+
+	//-- issue provision discovery request , need device address from P2P UI --//
+	case SIOCP2PPROVREQ:	
+
+		#ifdef PCIE_POWER_SAVING
+		PCIeWakeUp(priv, POWER_DOWN_T0);
+		#endif
+		ret	= req_p2p_provision_req(priv, (unsigned char *)(wrq->u.data.pointer));
+		break;
+
+	/*P2P UI confirm wsc method,pincode,Target device to wlan driver, 
+	  if we active send provision req  before ,then will send nego req here */
+	case SIOCP2WSCMETHODCONF:	
+
+		#ifdef PCIE_POWER_SAVING
+		PCIeWakeUp(priv, POWER_DOWN_T0);
+		#endif
+		ret	= req_p2p_wsc_confirm(priv, (unsigned char *)(wrq->u.data.pointer));
+		break;
+
+	//-- report event and state to P2P UI--//		
+	case SIOCP2PPGETEVNIND:	
+		ret	= p2p_get_event_state(priv, (unsigned char *)(wrq->u.data.pointer));
+		break;
+
+	//-- wscd(GO mode) report WPS success or fail --//
+	case SIOCP2P_WSC_REPORT_STATE:	
+		ret	= p2p_wps_indicate_state(priv, (unsigned char *)(wrq->u.data.pointer));
+		break;
+
+	/*Report 1.p2p client connect state to web server ; for process start udhcpc
+			 2.p2p pre-GO change to GO (WPS is done and success) indicate web server need start udhcpd*/		
+	case SIOCP2P_REPORT_CLIENT_STATE:	
+		ret	= p2p_get_p2pconnect_state(priv, (unsigned char *)(wrq->u.data.pointer));
+		break;
+	
+#endif	// end of P2P_SUPPORT
+/*--------------P2P related ioctl----------------------------------end*/
+
+#ifdef AUTO_TEST_SUPPORT
+	case SIOCSSREQ:
+		rtl8192cd_SSReq_AutoTest(priv);
+		ret = 0;
+		break;
+
+	case SIOCJOINREQ:
+#ifdef CLIENT_MODE
+		ret = rtl8192cd_join_AutoTest(priv ,  (unsigned char *)(wrq->u.data.pointer));
+#endif
+		break;
+
+#endif
+
+#ifdef CLIENT_MODE
+	case SIOCGIWRTLJOINREQ:		//-- Issue Join Request --//
+		ret = rtl8192cd_join(priv, (unsigned char *)(wrq->u.data.pointer));
+		break;
+
+	case SIOCGIWRTLJOINREQSTATUS:	//-- Get Join Status --//
+		ret = rtl8192cd_join_status(priv, (unsigned char *)(wrq->u.data.pointer));
+		break;
+#endif
+
+
+#ifdef RTK_WOW
+	case SIOCGRTKWOW:	//-- issue Realtek proprietary wake up on wlan mode --//
+		ret = 5;
+		do {
+			issue_rtk_wow(priv,  (unsigned char *)(wrq->u.data.pointer));
+		} while(--ret > 0);
+		break;
+#endif
+
+	case SIOCSRFPWRADJ:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		i = dynamic_RF_pwr_adj(priv, tmpbuf, sizeof_tmpbuf);
+		if (i > 0) {
+			if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+				break;
+		}
+		wrq->u.data.length = i;
+		ret = 0;
+		break;
+
+#ifdef MCR_WIRELESS_EXTEND
+#ifdef CONFIG_WLAN_HAL_8814AE
+	case SIORXANTSELECT:
+		{
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		if (Switch_Antenna_8814(priv, tmpbuf))
+			GDEBUG("- Usage : # iwpriv wlan0 set_ant_rx ss=x,path=y\n");
+		ret = 0;
+		break;			
+		}
+#endif	
+#endif
+#ifdef MP_TEST
+	case MP_START_TEST:
+#ifdef NOT_RTK_BSP
+		RESTORE_INT(priv->pshare->irq_save);
+		SMP_UNLOCK(priv->pshare->irq_save);
+#else
+		RESTORE_INT(flags);
+		SMP_UNLOCK(flags);
+#endif
+		mp_start_test(priv);
+#ifdef NOT_RTK_BSP
+		SAVE_INT_AND_CLI(priv->pshare->irq_save);
+		SMP_LOCK(priv->pshare->irq_save);
+#else
+		SAVE_INT_AND_CLI(flags);
+		SMP_LOCK(flags);
+#endif
+		ret = 0;
+		break;
+
+	case MP_STOP_TEST:
+#ifdef NOT_RTK_BSP
+		RESTORE_INT(priv->pshare->irq_save);
+		SMP_UNLOCK(priv->pshare->irq_save);
+#else
+		RESTORE_INT(flags);
+		SMP_UNLOCK(flags);
+#endif
+		mp_stop_test(priv);
+#ifdef NOT_RTK_BSP
+		SAVE_INT_AND_CLI(priv->pshare->irq_save);
+		SMP_LOCK(priv->pshare->irq_save);
+#else
+		SAVE_INT_AND_CLI(flags);
+		SMP_LOCK(flags);
+#endif
+		ret = 0;
+		break;
+
+#ifdef SDIO_AP_OFFLOAD
+	case SIOCSTOPPS:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+		    break;
+
+		set_ap_ps_mode(priv, tmpbuf, wrq->u.data.length);
+		// assign_MIMO_TR_Mode(priv, tmpbuf);
+		wrq->u.data.length = 0;
+		ret = 0;
+		break;
+#endif
+
+	case MP_SET_RATE:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		mp_set_datarate(priv, tmpbuf);
+		ret = 0;
+		break;
+
+	case MP_SET_CHANNEL:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		mp_set_channel(priv, tmpbuf);
+		ret = 0;
+		break;
+
+	case MP_SET_BANDWIDTH:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		mp_set_bandwidth(priv, tmpbuf);
+		ret = 0;
+		break;
+
+	case MP_SET_TXPOWER:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		mp_set_tx_power(priv, tmpbuf);
+		ret = 0;
+		break;
+
+	case MP_CONTIOUS_TX:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+#ifdef SMP_SYNC	
+		RESTORE_INT(priv->pshare->irq_save);
+		SMP_UNLOCK(priv->pshare->irq_save);
+#else
+		RESTORE_INT(flags);
+#endif		
+		mp_ctx(priv, tmpbuf);
+#ifdef SMP_SYNC	
+		SAVE_INT_AND_CLI(priv->pshare->irq_save);
+		SMP_LOCK(priv->pshare->irq_save);
+#else
+		SAVE_INT_AND_CLI(flags);
+		SMP_LOCK(flags);
+#endif		
+		ret = 0;
+		break;
+
+	case MP_ARX:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		i = mp_arx(priv, tmpbuf, sizeof_tmpbuf);
+		if (i > 0) {
+			if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+				break;
+		}
+		wrq->u.data.length = i;
+		ret = 0;
+		break;
+
+	case MP_SET_BSSID:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		mp_set_bssid(priv, tmpbuf);
+		ret = 0;
+		break;
+
+	case MP_ANTENNA_TX:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		mp_set_ant_tx(priv, tmpbuf);
+		ret = 0;
+		break;
+
+	case MP_ANTENNA_RX:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		mp_set_ant_rx(priv, tmpbuf);
+		ret = 0;
+		break;
+
+#if defined(CONFIG_RTL_92D_SUPPORT) || defined(CONFIG_RTL_8812_SUPPORT) || defined(CONFIG_WLAN_HAL_8881A)
+	case MP_SET_BAND:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		mp_set_phyBand(priv, tmpbuf);
+		ret = 0;
+		break;
+#endif
+
+	case MP_RESET_STATS:
+		mp_reset_stats(priv);
+		ret = 0;
+		break;
+
+	case MP_SET_PHYPARA:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		mp_set_phypara(priv, tmpbuf);
+		ret = 0;
+		break;
+
+#ifdef B2B_TEST
+	case MP_TX_PACKET:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+#ifdef SMP_SYNC	
+		RESTORE_INT(priv->pshare->irq_save);
+#else
+		RESTORE_INT(flags);
+#endif
+		i = mp_tx(priv, tmpbuf, sizeof_tmpbuf);
+#ifdef SMP_SYNC	
+		SAVE_INT_AND_CLI(priv->pshare->irq_save);	
+#else
+		SAVE_INT_AND_CLI(flags);
+#endif
+		if (i > 0) {
+			if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+				break;
+		}
+		wrq->u.data.length = i;
+		ret = 0;
+		break;
+
+#if 0
+	case MP_RX_PACKET:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+#ifndef __LINUX_2_6__
+		RESTORE_INT(flags);
+#endif
+		mp_rx(priv, tmpbuf);
+#ifndef __LINUX_2_6__
+		SAVE_INT_AND_CLI(flags);
+#endif
+		ret = 0;
+		break;
+#endif
+
+	case MP_BRX_PACKET:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+#ifdef SMP_SYNC	
+		RESTORE_INT(priv->pshare->irq_save);
+#else
+		RESTORE_INT(flags);
+#endif
+		i = mp_brx(priv, tmpbuf, sizeof_tmpbuf);
+#ifdef SMP_SYNC	
+		SAVE_INT_AND_CLI(priv->pshare->irq_save);
+#else
+		SAVE_INT_AND_CLI(flags);
+#endif
+		if (i > 0) {
+			if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+				break;
+		}
+		wrq->u.data.length = i;
+		ret = 0;
+		break;
+#endif // B2B_TEST
+
+	case MP_QUERY_STATS:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		i = mp_query_stats(priv, tmpbuf, sizeof_tmpbuf);
+		if (i > 0) {
+			if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+				break;
+		}
+		wrq->u.data.length = i;
+		ret = 0;
+		break;
+
+	case MP_TXPWR_TRACK:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+#ifdef SMP_SYNC	
+		RESTORE_INT(priv->pshare->irq_save);
+#else
+		RESTORE_INT(flags);
+#endif
+		mp_txpower_tracking(priv, tmpbuf);
+#ifdef SMP_SYNC
+		SAVE_INT_AND_CLI(priv->pshare->irq_save);
+#else
+		SAVE_INT_AND_CLI(flags);
+#endif
+		ret = 0;
+		break;
+
+	case MP_QUERY_TSSI:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+#ifdef SMP_SYNC
+		RESTORE_INT(priv->pshare->irq_save);
+#else
+		RESTORE_INT(flags);
+#endif
+		i = mp_query_tssi(priv, tmpbuf, sizeof_tmpbuf);
+#ifdef SMP_SYNC
+		SAVE_INT_AND_CLI(priv->pshare->irq_save);
+#else
+		SAVE_INT_AND_CLI(flags);
+#endif
+		if (i > 0) {
+			if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+				break;
+			wrq->u.data.length = i;
+			ret = 0;
+		}
+		break;
+
+	case MP_QUERY_THER:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+#ifdef SMP_SYNC
+		RESTORE_INT(priv->pshare->irq_save);
+#else
+		RESTORE_INT(flags);
+#endif
+		i = mp_query_ther(priv, tmpbuf, sizeof_tmpbuf);
+#ifdef SMP_SYNC
+		SAVE_INT_AND_CLI(priv->pshare->irq_save);
+#else
+		SAVE_INT_AND_CLI(flags);
+#endif
+		if (i > 0) {
+			if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+				break;
+			wrq->u.data.length = i;
+			ret = 0;
+		}
+		break;
+	#ifdef MP_PSD_SUPPORT
+	case MP_QUERY_PSD:	
+		if (ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;		
+
+#ifdef SMP_SYNC
+		RESTORE_INT(priv->pshare->irq_save);
+#else
+		RESTORE_INT(flags);
+#endif
+		i = mp_query_psd(priv, tmpbuf, sizeof_tmpbuf);
+#ifdef SMP_SYNC
+		SAVE_INT_AND_CLI(priv->pshare->irq_save);
+#else
+		SAVE_INT_AND_CLI(flags);
+#endif
+		if (i > 0 ) {
+			if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i )) 
+				break;
+			wrq->u.data.length = i;
+			ret = 0;
+			//printk("The address of DA is 0x%p\n",(void *)wrq->u.data.pointer);
+		}
+		break;
+	#endif
+	case MP_GET_TXPOWER:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+#ifdef SMP_SYNC
+		RESTORE_INT(priv->pshare->irq_save);
+#else
+		RESTORE_INT(flags);
+#endif
+		i = mp_get_txpwr(priv, tmpbuf, sizeof_tmpbuf);
+#ifdef SMP_SYNC
+		SAVE_INT_AND_CLI(priv->pshare->irq_save);
+#else
+		SAVE_INT_AND_CLI(flags);
+#endif
+		if (i > 0) {
+			if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+				break;
+			wrq->u.data.length = i;
+			ret = 0;
+		}
+		break;
+
+#if 	defined(CONFIG_RTL_8812_SUPPORT)
+	case MP_DIG:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+#ifdef SMP_SYNC
+		RESTORE_INT(priv->pshare->irq_save);
+#else
+		RESTORE_INT(flags);
+#endif
+		mp_dig(priv, tmpbuf);
+#ifdef SMP_SYNC
+		SAVE_INT_AND_CLI(priv->pshare->irq_save);
+#else
+		SAVE_INT_AND_CLI(flags);
+#endif
+		ret = 0;
+		break;			
+#endif
+#endif	// MP_TEST
+
+#if (defined(SW_ANT_SWITCH) || defined(HW_ANT_SWITCH))
+	case SIOCANTSELECT:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+#if (defined(CONFIG_RTL_92C_SUPPORT) || defined(CONFIG_RTL_92D_SUPPORT))		
+		if (GET_CHIP_VER(priv) <= VERSION_8192D) {
+			diversity_antenna_select(priv, tmpbuf);
+		} else
+#endif
+		{
+#ifdef USE_OUT_SRC
+			priv->pshare->_dmODM.antdiv_select = _atoi(tmpbuf, 10);
+			panic_printk("SIOCANTSELECT --> antdiv_select=%d\n", priv->pshare->_dmODM.antdiv_select);
+			ODM_AntDiv(ODMPTR);
+#endif
+		}
+		ret = 0;
+		break;
+#endif
+
+	case SIOCGIWRTLREGDUMP:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+#ifdef SMP_SYNC
+		RESTORE_INT(priv->pshare->irq_save);
+#else
+		RESTORE_INT(flags);
+#endif
+		reg_dump(priv, (char *)tmpbuf);
+#ifdef SMP_SYNC
+		SAVE_INT_AND_CLI(priv->pshare->irq_save);
+#else
+		SAVE_INT_AND_CLI(flags);
+#endif
+		ret = 0;
+		break;
+
+#ifdef BR_SHORTCUT
+	case SIOCLEARBRSC:
+		clear_shortcut_cache();
+		ret = 0;
+		break;
+
+	case SIOCLONEEARBRSC:
+    {
+        int idx;
+        unsigned char macaddr[MACADDRLEN];
+        unsigned char tmpbuf2[4];        
+        if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+            break;
+
+    	for(idx=0; idx<MACADDRLEN; idx++)
+    	{
+    		tmpbuf2[0] = tmpbuf[2*idx];
+    		tmpbuf2[1] = tmpbuf[2*idx+1];
+    		tmpbuf2[2] = 0;
+    		macaddr[idx] = (unsigned char)_atoi((char *)tmpbuf2, 16);
+    	}  
+
+    	DEBUG_INFO("del_br_sc %02X%02X%02X%02X%02X%02X\n",
+		macaddr[0], macaddr[1], macaddr[2], macaddr[3], macaddr[4], macaddr[5]);        
+
+        release_brsc_cache(macaddr);
+		ret = 0;
+		break;  
+       }
+#endif
+	case SIOCRADIOOFF:
+#ifdef PCIE_POWER_SAVING
+		radio_off(priv);
+#endif
+		ret = 0;
+		break;
+
+	case SIOCACS:
+        if (ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+             break;
+
+		rtl8192cd_del_all_sta(priv);
+		rtl8192cd_autochannel_sel(priv);
+
+        wrq->u.data.length = 0;
+        ret = 0;
+        break;	
+	
+	case SIOCANTSTS:
+		i = sprintf(tmpbuf, "%x:%x", priv->pshare->mp_antenna_tx, priv->pshare->mp_antenna_rx);
+		if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+			break;
+
+		wrq->u.data.length = i;
+		ret = 0;
+		break;
+
+#if defined(PCIE_POWER_SAVING) || defined(RF_MIMO_SWITCH) || defined(RF_MIMO_PS)
+	case SIOCEPDN:
+#ifdef PCIE_POWER_SAVING		
+#ifdef PCIE_POWER_SAVING_DEBUG
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		i = PCIE_PowerDown(priv, tmpbuf);
+
+		if (i > 0) {
+			if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+				break;
+		}
+		wrq->u.data.length = i;
+#else
+		priv->pshare->rf_ft_var.power_save &=0xf0;
+		PCIeWakeUp(priv, (POWER_DOWN_T0));
+#endif
+#else
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		assign_MIMO_TR_Mode(priv, tmpbuf);
+		wrq->u.data.length = 0;
+#endif
+		ret = 0;
+		break;
+#endif
+#ifdef EN_EFUSE
+	case SIOCEFUSE_GET:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		i = efuse_get(priv, tmpbuf);
+		if (i > 0) {
+			if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+				break;
+		}
+		wrq->u.data.length = i;
+		ret = 0;
+		break;
+
+	case SIOCEFUSE_SET:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		i = efuse_set(priv, tmpbuf);
+		if (i > 0) {
+			if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+				break;
+		}
+		wrq->u.data.length = i;
+		ret = 0;
+		break;
+
+	case SIOCEFUSE_SYNC:
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		i = efuse_sync(priv, tmpbuf);
+		if (i > 0) {
+			if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+				break;
+		}
+		wrq->u.data.length = i;
+		ret = 0;
+		break;
+
+#endif
+
+
+#ifdef P2P_SUPPORT
+	case SIOCP2PCMD:
+
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		
+		//printk("ioctl-->process_p2p_cmd\n");
+		
+		i = process_p2p_cmd(priv, tmpbuf);
+		if (i > 0) {
+			if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+				break;
+		}
+		wrq->u.data.length = i;
+		ret = 0;
+		break;
+		
+#endif
+
+#if defined(MBSSID) || defined(UNIVERSAL_REPEATER)
+	case SIOCSICOPYMIB:
+		{
+		unsigned char	hwaddr[MACADDRLEN];
+		int func_off = priv->pmib->miscEntry.func_off;
+		memcpy(hwaddr, GET_MY_HWADDR, MACADDRLEN);
+		
+		memcpy(priv->pmib, GET_ROOT(priv)->pmib, sizeof(struct wifi_mib));
+		
+		priv->pmib->miscEntry.func_off = func_off;
+		memcpy(GET_MY_HWADDR, hwaddr, MACADDRLEN);
+		D("func_off = %d\n", func_off);
+#ifdef WIFI_WPAS_CLI
+		priv->pmib->wscEntry.wsc_enable = 0;
+		priv->pmib->wscEntry.beacon_ielen = 0;
+		priv->pmib->wscEntry.probe_rsp_ielen = 0;
+		priv->pmib->wscEntry.probe_req_ielen = 0;
+		priv->pmib->wscEntry.assoc_ielen = 0;
+#endif
+		ret = 0;
+		break;
+		}
+#endif
+
+#ifdef CONFIG_RTL8186_KB
+	case SIOCGIREADGUESTMAC:
+		i = get_guestmac(priv, (GUESTMAC_T *)tmpbuf);
+		if (i >= 0) {
+			if ((i > 0) && ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+				break;
+			wrq->u.data.length = i;
+			ret = 0;
+		}
+		break;
+
+	case SIOCSIWRTGUESTMAC:
+		if (ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		set_guestmacvalid(priv, tmpbuf);
+		ret = 0;
+		break;
+#endif
+
+#ifdef MULTI_MAC_CLONE
+	case SIOCGIMCLONE:
+		if (ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		i = get_mclone_addr(priv, tmpbuf, sizeof_tmpbuf);
+		if (i > 0) {
+			if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+				break;
+		}
+		wrq->u.data.length = i;
+		ret = 0;
+		break;
+
+	case SIOCSIMCLONE:
+		if (ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		set_mclone_addr(priv, tmpbuf);
+		ret = 0;
+		break;
+
+	case SIOCSIMCLONE_DEL:
+	    if (ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		del_mclone_addr(priv, tmpbuf);
+		ret = 0;
+	    break;
+
+    case SIOCSIMCLONE_DEL2:
+        if( ( ((GET_MIB(priv))->dot11OperationEntry.opmode & (WIFI_STATION_STATE|WIFI_ASOC_STATE))==(WIFI_STATION_STATE|WIFI_ASOC_STATE) )&& MCLONE_NUM ){
+            __del_mclone_addr(priv, (unsigned char *)ifr);
+        }
+        ret = 0;
+        break;
+#endif
+
+#ifdef SUPPORT_SNMP_MIB
+	case SIOCGSNMPMIB:
+		if ((wrq->u.data.length > sizeof_tmpbuf) ||
+			ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+
+		if (mib_get(priv, tmpbuf, tmpbuf, sizeof_tmpbuf, &i)) {
+			if ((i > 0) && ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+				break;
+			wrq->u.data.length = i;
+			ret = 0;
+		}
+		break;
+#endif
+
+#ifdef	SUPPORT_TX_MCAST2UNI
+	case SIOCGIMCAST_ADD:
+	case SIOCGIMCAST_DEL:
+		ret = ioctl_AddDelMCASTGroup2STA(dev, ifr, cmd);
+		break;
+#endif	// SUPPORT_TX_MCAST2UNI
+#ifdef	CONFIG_RTK_MESH
+	case SIOCQPATHTABLE:
+   	{
+		unsigned char destaddr[MACADDRLEN] = {0};
+
+		ioctl_copy_from_user(destaddr, (void *)(wrq->u.data.pointer), MACADDRLEN);
+		//MESH_DEBUG_MSG("kernel destaddr = %s\n",destaddr);
+		struct path_sel_entry *pEntry = pathsel_query_table( priv, destaddr); // modified by chuangch 2007.09.14
+		ret = -1;
+		if(pEntry!= (struct path_sel_entry *)-1)
+		{
+			if (ioctl_copy_to_user((void *)wrq->u.data.pointer, (void *)pEntry, (int)&((struct path_sel_entry*)0)->start) == 0)
+			{
+				ret = 0;
+				wrq->u.data.length = sizeof(struct path_sel_entry);
+			}
+		}
+		break;
+	}
+
+	case SIOCUPATHTABLE:
+	{
+		struct path_sel_entry Entry;
+		ioctl_copy_from_user((struct path_sel_entry *)&Entry, (void *)(wrq->u.data.pointer), (int)&((struct path_sel_entry*)0)->start);
+		ret = pathsel_modify_table_entry(priv, &Entry); // chuangch 2007.09.14
+		break;
+	}
+	case SIOCAPATHTABLE:
+	{
+		struct path_sel_entry Entry, *pEntry;
+		memset((void*)&Entry, 0, sizeof(Entry));
+		ioctl_copy_from_user((struct path_sel_entry *)&Entry, (void *)(wrq->u.data.pointer), (int)&((struct path_sel_entry*)0)->start);
+		ret = 0;
+		pEntry = pathsel_query_table( priv, Entry.destMAC );
+
+		if( pEntry == (struct path_sel_entry *)-1 || pEntry->flag==0)
+		{
+            /*prevent update path relative to any invalid neighbor*/
+            if(get_stainfo(priv, Entry.nexthopMAC)) {
+                Entry.priv = priv;                
+            }
+            #if !defined(CONFIG_RTL_MESH_CROSSBAND)
+            else if(priv->mesh_priv_sc && get_stainfo(priv->mesh_priv_sc, Entry.nexthopMAC)) {
+                Entry.priv = priv->mesh_priv_sc;
+            }            
+            #endif
+            else {
+                return -1;
+            }
+
+        
+			Entry.update_time = xtime; // chuangch 2007.09.19
+			#ifdef MESH_ROUTE_MAINTENANCE
+			Entry.routeMaintain = xtime; // chuangch 10.19
+			#endif
+			ret = pathsel_table_entry_insert_tail( priv, &Entry); //chuangch 2007.09.14
+
+			MESH_DEBUG_MSG("create path to:%02X:%02X:%02X:%02X:%02X:%02X, Nexthop=%02X:%02X:%02X:%02X:%02X:%02X, Hop count=%d\n",
+				Entry.destMAC[0], Entry.destMAC[1], Entry.destMAC[2], Entry.destMAC[3], Entry.destMAC[4], Entry.destMAC[5],
+				Entry.nexthopMAC[0],  Entry.nexthopMAC[1], Entry.nexthopMAC[2], Entry.nexthopMAC[3], Entry.nexthopMAC[4], Entry.nexthopMAC[5],
+				Entry.hopcount);
+		}
+
+		break;
+	}
+
+	//modify by Jason 2007.11.26
+	case REMOVE_PATH_ENTRY:
+	{
+		unsigned char invalid_node_addr[MACADDRLEN] = {0};
+		struct path_sel_entry *pEntry;
+
+		if ( ioctl_copy_from_user((void *)invalid_node_addr, (void *)(wrq->u.data.pointer), MACADDRLEN) ) {
+			ret = -1;
+			break;
+		}
+
+		MESH_DEBUG_MSG("REMOVE_PATH_ENTRY\n");
+		MESH_DEBUG_MSG("invalid_node_addr =%2X-%2X-%2X-%2X-%2X-%2X-\n",invalid_node_addr[0],invalid_node_addr[1],invalid_node_addr[2],invalid_node_addr[3],invalid_node_addr[4],invalid_node_addr[5]);
+
+		pEntry = pathsel_query_table( priv, invalid_node_addr );
+		if(pEntry != (struct path_sel_entry *)-1 && pEntry->flag==0)
+		{
+#ifdef __LINUX_2_6__
+/*by qjj_qin and hf_shi*/
+#else
+			SAVE_INT_AND_CLI(flags);
+#endif
+			ret = remove_path_entry(priv,invalid_node_addr);
+#ifdef __LINUX_2_6__
+/*by qjj_qin and hf_shi*/
+#else
+			RESTORE_INT(flags);
+#endif
+		}
+		break;
+	}
+
+	case GET_STA_LIST:
+	{
+		struct stat_info	*pstat;
+
+		struct proxy_table_entry *pEntry=NULL;
+		static unsigned char node[MACADDRLEN] = {0};
+
+		if ( ioctl_copy_from_user((void *)node, (void *)(wrq->u.data.pointer), MACADDRLEN) ) {
+			ret = -1;
+			break;
+		}
+
+        #if 0 //do not use station info
+		// my station
+		pstat = get_stainfo(priv, node);
+
+		if(pstat != 0)
+		{
+			if(isSTA(pstat) && (pstat->state & WIFI_ASOC_STATE)) {
+				ret = 0;
+				break;
+			}
+			else // a neighbor
+				goto ret_nothing;
+		}
+        #endif
+
+		pEntry = HASH_SEARCH(priv->proxy_table,node);
+
+		// my proxied entry
+		if(pEntry && (memcmp(GET_MY_HWADDR, pEntry->owner, MACADDRLEN)==0))
+		{
+			ret = 0;
+			break;
+		}
+
+ret_nothing:
+		// if not my station or not my proxied entry, then just fill garbage(0x0b) and return normally
+		memset(node, 0x0b, sizeof(node));
+	       	if (ioctl_copy_to_user((void *)wrq->u.data.pointer, (void *)node, MACADDRLEN) != 0)
+		{
+			ret = -1;
+			break;
+		}
+		ret = 0;
+		break;
+	}
+
+	case SET_PORTAL_POOL:
+	{
+		if ( ioctl_copy_from_user( (priv->pann_mpp_tb->pann_mpp_pool), (void *)(wrq->u.data.pointer), sizeof(struct pann_mpp_tb_entry) * MAX_MPP_NUM ) ) {
+			ret = -1;
+			break;
+		}
+		ret = 0;
+  		break;
+	}
+
+	case SIOC_NOTIFY_PATH_CREATE:
+	{
+		unsigned char destaddr[MACADDRLEN] = {0};
+
+		if ( ioctl_copy_from_user((void *)destaddr, (void *)(wrq->u.data.pointer), MACADDRLEN) ) {
+			ret = -1;
+			break;
+		}
+		notify_path_found(destaddr,priv);
+		// MESH_DEBUG_MSG("destaddr =%2X-%2X-%2X-%2X-%2X-%2X-\n",destaddr[0],destaddr[1],destaddr[2],destaddr[3],destaddr[4],destaddr[5]);
+		ret = 0;
+  		break;
+	}
+
+	case SIOC_UPDATE_ROOT_INFO:
+	{
+		if ( ioctl_copy_from_user((void *)priv->root_mac, (void *)(wrq->u.data.pointer), MACADDRLEN) ) {
+			ret = -1;
+			break;
+		}
+		ret = 0;
+#if 0
+		LOG_MESH_MSG("Root MAC = %02X:%02X:%02X:%02X:%02X:%02X\n",
+			priv->root_mac[0],priv->root_mac[1],priv->root_mac[2],priv->root_mac[3],priv->root_mac[4],priv->root_mac[5]);
+#endif
+  		break;
+	}
+
+	case SIOC_GET_ROUTING_INFO:
+	{
+		unsigned char buffer[128] = {0};
+		buffer[0] = (unsigned short)(priv->pmib->dot1180211sInfo.mesh_root_enable);
+		buffer[1] = (unsigned short)(priv->pmib->dot1180211sInfo.mesh_portal_enable);
+#ifdef	_11s_TEST_MODE_
+		buffer[2] = (unsigned short)(priv->pmib->dot1180211sInfo.mesh_reserved1);
+#endif
+		if (ioctl_copy_to_user((void *)wrq->u.data.pointer, (void *)buffer, 128) == 0)
+			ret = 0;
+		else
+			ret = -1;
+
+  		break;
+	}
+
+case SIOC_SET_ROUTING_INFO:
+	{
+		unsigned char buffer[128] = {0};
+
+		if ( !wrq->u.data.pointer ){
+				ret = -1;
+				break;
+		}
+
+		if (ioctl_copy_from_user((void *)buffer, (void *)wrq->u.data.pointer, 128) == 0)
+			ret = 0;
+		else
+			ret = -1;
+
+		priv->pmib->dot1180211sInfo.mesh_root_enable = buffer[0];
+		priv->pmib->dot1180211sInfo.mesh_portal_enable = buffer[1];
+  		break;
+	}
+
+
+#ifdef  _11s_TEST_MODE_
+	case SAVE_RECEIBVER_PID:
+	{
+		if ( !wrq->u.data.pointer ){
+				ret = -1;
+				break;
+		}
+
+		len = wrq->u.data.length;
+		memset(strPID, 0, sizeof(strPID));
+		ioctl_copy_from_user(strPID, (void *)wrq->u.data.pointer, len);
+
+		pid_receiver = 0;
+		for(i = 0; i < len; i++) //char -> int
+		{
+			pid_receiver = pid_receiver * 10 + (strPID[i] - 48);
+		}
+		ret = 0;
+		break;
+	}
+
+	case DEQUEUE_RECEIBVER_IOCTL:
+	{
+		if((ret = DOT11_DeQueue2((unsigned long)priv, priv->receiver_queue, QueueData, &QueueDataLen)) != 0) {
+			ioctl_copy_to_user((void *)(wrq->u.data.pointer), DATAQUEUE_EMPTY, sizeof(DATAQUEUE_EMPTY));
+			wrq->u.data.length = sizeof(DATAQUEUE_EMPTY);
+		} else {
+			ioctl_copy_to_user((void *)wrq->u.data.pointer, (void *)QueueData, QueueDataLen);
+			wrq->u.data.length = QueueDataLen;
+		}
+		break;
+	}
+#endif
+
+	case SAVEPID_IOCTL:
+	{
+		if ( !wrq->u.data.pointer ){
+			ret = -1;
+			break;
+		}
+
+		len = wrq->u.data.length;
+		memset(strPID, 0, sizeof(strPID));
+		ioctl_copy_from_user(strPID, (void *)wrq->u.data.pointer, len);
+
+		priv->pid_pathsel = 0;
+		for(i = 0; i < len; i++) //char -> int
+		{
+			priv->pid_pathsel = priv->pid_pathsel * 10 + (strPID[i] - 48);
+		}
+
+		ret = 0;
+		break;
+	}
+
+	case DEQUEUEDATA_IOCTL:
+	{
+		if((ret = DOT11_DeQueue2((unsigned long)priv, priv->pathsel_queue, QueueData, &QueueDataLen)) != 0) {
+			ioctl_copy_to_user((void *)(wrq->u.data.pointer), DATAQUEUE_EMPTY, sizeof(DATAQUEUE_EMPTY));
+			wrq->u.data.length = sizeof(DATAQUEUE_EMPTY);
+		} else {
+			ioctl_copy_to_user((void *)wrq->u.data.pointer, (void *)QueueData, QueueDataLen);
+			wrq->u.data.length = QueueDataLen;
+		}
+
+		break;
+	}
+#endif // CONFIG_RTK_MESH
+
+#ifdef CONFIG_RTL_COMAPI_CFGFILE
+	case SIOCCOMAPIFILE:
+	{
+		ret = CfgFileProc(dev);
+		break;
+	}
+#endif
+
+	case SIOC92DAUTOCH:
+	{
+		if (!(OPMODE & WIFI_AP_STATE)){
+			DEBUG_ERR("can't do auto-channel select for non-AP mode!\n");
+			break;
+		}
+#ifdef UNIVERSAL_REPEATER
+		if (IS_VXD_INTERFACE(priv)) {
+			DEBUG_ERR("can't do auto-channel select for vxd!\n");
+			break;
+		}
+#endif
+#ifdef MBSSID
+		if (
+			GET_ROOT(priv)->pmib->miscEntry.vap_enable &&
+			IS_VAP_INTERFACE(priv)) {
+			DEBUG_ERR("can't do auto-channel select for vap!\n");
+			break;
+		}
+#endif
+
+#ifdef PCIE_POWER_SAVING
+		PCIeWakeUp(priv, POWER_DOWN_T0);
+#endif
+		ret = rtl8192cd_autochannel_sel(priv);
+		break;
+	}
+
+#if defined(CONFIG_OFFLOAD_FUNCTION) || defined(SDIO_AP_OFFLOAD)
+	case SIOOFFLOADTEST:
+	{
+		if(ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+		i = offloadTestFunction(priv, tmpbuf);
+
+		if (i > 0) {
+			if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i))
+				break;
+		}
+		wrq->u.data.length = i;
+
+		ret = 0;
+		break;
+	}
+#endif // CONFIG_OFFLOAD_FUNCTION || SDIO_AP_OFFLOAD
+
+
+#ifdef CONFIG_8814_AP_MAC_VERI
+    case SIO_8814_AP_MAC_VERI:
+    {
+        if(copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+                    break;
+        APmacTestFunction_8814(priv, tmpbuf);
+
+        ret = 0;
+        break;
+    }
+#endif //#ifdef CONFIG_8814_AP_MAC_VERI
+
+#ifdef CONFIG_RTL_92D_SUPPORT
+	case SIOC92DIQK:
+	{
+		PHY_IQCalibrate(priv);
+		ret = 0;
+		break;
+	}
+
+#ifdef EN_EFUSE
+	case SIOC92DSBANDADDR:
+	{
+		unsigned int phyband;
+		u8 efuse_MAC=0;
+		if (wrq->u.data.pointer) {
+			if ((wrq->u.data.length > sizeof_tmpbuf) ||
+				ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+				break;
+
+			phyband = _atoi(tmpbuf, 16);
+			printk("get phyband = %d \n",phyband);
+			if (phyband==2)
+				efuse_MAC = EEPROM_MAC0_MACADDRESS;
+			else
+				efuse_MAC = EEPROM_MAC1_MACADDRESS;
+
+			if (/*priv->AutoloadFailFlag==FALSE &&*/ priv->pmib->efuseEntry.enable_efuse==1) {
+#ifdef __KERNEL__
+				struct sockaddr addr;
+#endif
+				unsigned char *hwinfo = &(priv->EfuseMap[EFUSE_INIT_MAP][0]);
+				unsigned char *mac = hwinfo + efuse_MAC;
+				unsigned char zero[] = {0, 0, 0, 0, 0, 0};
+				/* printk("wlan%d EFUSE MAC [%02x:%02x:%02x:%02x:%02x:%02x]\n", priv->pshare->wlandev_idx,
+						*mac, *(mac+1), *(mac+2), *(mac+3), *(mac+4), *(mac+5)); */
+				if(memcmp(mac, zero, MACADDRLEN) && !IS_MCAST(mac)) {
+#ifdef __KERNEL__
+					memcpy(addr.sa_data, mac, MACADDRLEN);
+					rtl8192cd_set_hwaddr(priv->dev, (void *)&addr);
+#else
+					rtl8192cd_set_hwaddr(priv->dev, (void *)mac);
+#endif
+				}
+			}
+
+			ret = 0;
+		} else {
+			ret = -1;
+		}
+		break;
+	}
+#endif // EN_EFUSE
+
+#ifdef NON_INTR_ANTDIV
+	case SIOC92DATNDIV:
+	{
+		if (priv->pmib->dot11RFEntry.macPhyMode == DUALMAC_DUALPHY){
+			extern u32 if_priv[];
+			unsigned long temp_18[2], temp_28[2], temp_0b[2];
+			int i, ch[2];
+
+			// Backup RF 18, 28, 0B
+			for (i=0;i<2;i++) {
+				temp_18[i] = DMDP_PHY_QueryRFReg(i, RF92CD_PATH_A, 0x18, bMask20Bits, 1);
+				ch[i] = temp_18[i] & 0xff;
+				temp_28[i] = DMDP_PHY_QueryRFReg(i, RF92CD_PATH_A, 0x28, bMask20Bits, 1);
+				temp_0b[i] = DMDP_PHY_QueryRFReg(i, RF92CD_PATH_A, 0x0b, bMask20Bits, 1);
+				printk("RF[%d] 18=0x%05x 28=0x%05x 0B=0x%05x\n",i, temp_18[i], temp_28[i], temp_0b[i]);
+			}
+
+
+			PHY_SetBBReg(priv, 0xb30, BIT(27), 1);
+
+			// Restore RF 18, 28, 0B
+			for (i=0;i<2;i++) {
+				DMDP_PHY_SetRFReg(i, RF92CD_PATH_A, 0x18, bMask20Bits, temp_18[i]);
+				//DMDP_PHY_SetRFReg(i, RF92CD_PATH_A, 0x28, BIT(7)|BIT(6), (temp_28[i]&(BIT(7)|BIT(6)))>>6);
+				DMDP_PHY_SetRFReg(i, RF92CD_PATH_A, 0x0b, bMask20Bits, temp_0b[i]);
+			}
+			for (i=0;i<2;i++)
+				SetIMR_n((struct rtl8192cd_priv *)if_priv[i], ch[i]);
+			for (i=0;i<2;i++)
+				PHY_IQCalibrate((struct rtl8192cd_priv *)if_priv[i]);
+
+			printk("Non-interrupt antenna switched!\n");
+			ret = 0;
+		}else {
+			printk("NOT DMDP, cannot support antenna switch\n");
+			ret = -1;
+		}
+		break;
+	}
+#endif // EN_EFUSE
+#ifdef DPK_92D
+	case SIOC92DDPK:
+	{
+		if (priv->pmib->dot11RFEntry.phyBandSelect==PHY_BAND_5G){
+			if (priv->pshare->rf_ft_var.dpk_on){
+				int ch = PHY_QueryRFReg(priv,RF92CD_PATH_A,0x18,0xff,1);
+				unsigned int curMaxRFPath, eRFPath;
+				if (priv->pmib->dot11RFEntry.macPhyMode == DUALMAC_DUALPHY)
+					curMaxRFPath = RF92CD_PATH_B;
+				else
+					curMaxRFPath = RF92CD_PATH_MAX;
+
+				for(eRFPath = RF92CD_PATH_A; eRFPath < curMaxRFPath; eRFPath++){
+					if (eRFPath == RF92CD_PATH_A)
+						PHY_SetBBReg(priv, 0xb68, bMaskDWord, 0x28080000);
+					else
+						PHY_SetBBReg(priv, 0xb6c, bMaskDWord, 0x28080000);
+						
+					if (ch<=64){
+						PHY_SetRFReg(priv,eRFPath,0x03,bMask20Bits,0x94a12);
+						delay_us(10);
+						PHY_SetRFReg(priv,eRFPath,0x04,bMask20Bits,0x94a12);
+						PHY_SetRFReg(priv,eRFPath,0x0e,bMask20Bits,0x94a12);
+					}else if (ch<=140){
+						PHY_SetRFReg(priv,eRFPath,0x03,bMask20Bits,0x94a52);
+						delay_us(10);
+						PHY_SetRFReg(priv,eRFPath,0x04,bMask20Bits,0x94a52);
+						PHY_SetRFReg(priv,eRFPath,0x0e,bMask20Bits,0x94a52);
+					}else{
+						PHY_SetRFReg(priv,eRFPath,0x03,bMask20Bits,0x94a12);
+						delay_us(10);
+						PHY_SetRFReg(priv,eRFPath,0x04,bMask20Bits,0x94a12);
+						PHY_SetRFReg(priv,eRFPath,0x0e,bMask20Bits,0x94a12);
+					}
+
+					PHY_SetRFReg(priv,eRFPath,0x16,bMask20Bits,0xe1874);
+					PHY_SetRFReg(priv,eRFPath,0x16,bMask20Bits,0xa1874);
+					PHY_SetRFReg(priv,eRFPath,0x16,bMask20Bits,0x61874);
+					PHY_SetRFReg(priv,eRFPath,0x16,bMask20Bits,0x21874);
+
+				}
+				priv->pshare->rf_ft_var.dpk_on = 0;
+				panic_printk("DPK OFF!\n");
+			}else{
+				priv->pshare->rf_ft_var.dpk_on = 1;
+				panic_printk("DPK ON!\n");
+				PHY_DPCalibrate(priv);
+			}
+			ret = 0;
+		}else {
+			panic_printk("NO DPK for 2G!\n");
+			ret = -1;
+		}
+		break;
+	}
+#endif
+#endif // CONFIG_RTL_92D_SUPPORT
+#if defined(RTK_AC_SUPPORT) || defined(HS2_SUPPORT) || defined(CONFIG_IEEE80211W)//for 11ac logo, hs2.0 release 1 logo
+	case SIOC8812SIGMA:
+	{
+		panic_printk("Reset Default for SIGMA!!\n");
+		reset_default_sigma(priv);
+		ret=0;
+		break;
+	}
+#endif
+
+#if defined(RTK_AC_SUPPORT)
+	case SIOC8812SIGMATB:
+	{
+		panic_printk("Reset Default for SIGMA TestBed!!\n");
+		reset_default_sigma(priv);
+		reset_default_sigma_testbed(priv);
+		ret=0;
+		break;
+	}
+#endif
+
+	case SIOCTXPWRAPPLY:
+		SetTxPowerLevel(priv);
+		ret = 0;
+		break;
+
+#ifdef DFS
+	case SIOCRESETNOPCHANNEL:
+		reset_nop_channel(priv);
+		ret = 0;
+		break;
+#endif
+
+#ifdef DOT11K
+	case SIOC11KLINKREQ:
+	{
+		if ((wrq->u.data.length < MACADDRLEN) ||
+			ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, MACADDRLEN))
+				break;
+		ret = rm_link_measurement_request(priv, tmpbuf);
+		break;
+	}
+	case SIOC11KLINKREP:
+	{
+		if ((wrq->u.data.length < MACADDRLEN) ||
+			ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, MACADDRLEN))
+				break;
+		i = rm_get_link_report(priv, tmpbuf, tmpbuf);
+		if (i > 0) {
+			if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i)) {
+				break;
+			}
+			wrq->u.data.length = i;
+			ret = 0;
+		}
+		break;
+	}
+	case SIOC11KBEACONREQ:
+	{
+		if ((wrq->u.data.length < MACADDRLEN + sizeof(struct dot11k_beacon_measurement_req)) ||
+			ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, MACADDRLEN + sizeof(struct dot11k_beacon_measurement_req)))
+				break;
+		ret = rm_beacon_measurement_request(priv, tmpbuf, (struct dot11k_beacon_measurement_req *)(tmpbuf + MACADDRLEN));
+		break;
+	}
+	case SIOC11KBEACONREP:
+	{
+		unsigned char *tmpbuf2=NULL;
+		if ((wrq->u.data.length < MACADDRLEN) ||
+			ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, MACADDRLEN))
+				break;
+
+		i = rm_get_beacon_report(priv, tmpbuf, &tmpbuf2);
+		if (i > 0) {
+			if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf2, i)) {
+				if (tmpbuf2)
+					kfree(tmpbuf2);
+				break;
+			}
+			wrq->u.data.length = i;
+			ret = 0;
+		}
+
+		if (tmpbuf2)
+			kfree(tmpbuf2);
+		break;
+	}
+#ifdef CLIENT_MODE
+	case SIOC11KNEIGHBORREQ:
+	{
+		if (wrq->u.data.length && ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, wrq->u.data.length))
+			break;
+
+		ret = rm_neighbor_request(priv, wrq->u.data.length?tmpbuf:NULL);
+		break;
+	}
+	case SIOC11KNEIGHBORRSP:
+	{
+		i = rm_get_neighbor_report(priv, tmpbuf);
+		if (i > 0) {
+			if (ioctl_copy_to_user((void *)wrq->u.data.pointer, tmpbuf, i)) {
+				break;
+			}
+			wrq->u.data.length = i;
+			ret = 0;
+		}
+		break;
+	}
+#endif
+#ifdef CONFIG_IEEE80211V
+	case SIOC11VBSSTRANSREQ:
+	{
+		if ((wrq->u.data.length < sizeof(struct bss_transition_para)) ||
+				ioctl_copy_from_user(tmpbuf, (void *)wrq->u.data.pointer, sizeof(struct bss_transition_para)))
+			break;
+
+		set_BssTransPara(priv, tmpbuf);
+		ret = 0;
+		break;
+	}
+#endif
+#endif // DOT11K
+	}
+
+#ifdef SMP_SYNC
+		RESTORE_INT(priv->pshare->irq_save);
+		SMP_UNLOCK(priv->pshare->irq_save);
+#else
+	RESTORE_INT(flags);
+#endif
+
+	return ret;
+}
+
+
+void delay_us(unsigned int t)
+{
+#ifdef __LINUX_2_6__
+#if defined(CONFIG_RTL8672) || defined(NOT_RTK_BSP)
+	udelay(t);
+#else
+	__udelay(t);
+#endif
+#else
+	__udelay(t, __udelay_val);
+#endif
+}
+
+#ifdef CONFIG_RTL_ALP
+#define STATUS_FILE "/var/run/sitesurvey.xml"
+#include <stdio.h>
+int rtl8192cd_ss_req_toXML(struct rtl8192cd_priv *priv)
+{
+	INT8 ret = 0;
+#ifdef CONFIG_RTK_MESH
+	// by GANTOE for manual site survey 2008/12/25
+	// inserted by Joule for simple channel unification protocol 2009/01/06
+	if((priv->auto_channel &0x30) && timer_pending(&priv->ss_timer))
+		ret = -2;
+	else
+#endif
+	{
+		if (!netif_running(priv->dev) || priv->ss_req_ongoing)
+			ret = -1;
+		else
+			ret = 0;
+	}
+	if (!ret)	// now, let's start site survey
+	{
+		priv->ss_ssidlen = 0;
+		DEBUG_INFO("start_clnt_ss, trigger by %s, ss_ssidlen=0\n", (char *)__FUNCTION__);
+		priv->ss_req_ongoing = 1;
+		start_clnt_ss(priv);
+	}
+	return 0;
+}
+
+extern int encode_ssid_str(const char *source,char *dest);
+typedef enum { BAND_11B=1, BAND_11G=2, BAND_11BG=3, BAND_11A=4, BAND_11N=8, BAND_5G_11AN=12 } BAND_TYPE_T;
+int rtl8192cd_get_ss_status_toXML(struct rtl8192cd_priv *priv, int *data)
+{
+	INT8 ret = 0;
+	FILE *fptr;
+	int cnt;
+	struct bss_desc bss;
+	char tmp1Buf[20], tmp2Buf[20];
+	char wpa_tkip_aes[20],wpa2_tkip_aes[20];
+	char decode_ssid[200];
+
+	if (!netif_running(priv->dev) || priv->ss_req_ongoing)
+	{
+		diag_printf("%s: netif is not running or sitesurvey ongoing\n", __func__);
+		ret = -1;
+	}
+	else
+	{
+		fptr=fopen(STATUS_FILE,"w+");
+		if (fptr==NULL){
+			diag_printf("%s: Fail to create %s\n", __FUNCTION__, STATUS_FILE);
+			return -1;
+		}
+		
+		fprintf(fptr,"<XML_ROOT><runtime><sitesurvey>");
+		fprintf(fptr,"<count>%d</count>",priv->site_survey->count_backup);
+
+		if (priv->site_survey->count_backup){
+			for (cnt=0; cnt<priv->site_survey->count_backup; cnt++){
+				bss = priv->site_survey->bss_backup[cnt];
+				
+				memset(decode_ssid,0x00,sizeof(decode_ssid));
+ 				encode_ssid_str(bss.ssid,decode_ssid);
+				
+				fprintf(fptr, "<entry><ssid>%s</ssid>", decode_ssid);
+				fprintf(fptr, "<bssid>%02x:%02x:%02x:%02x:%02x:%02x</bssid>",
+						bss.bssid[0], bss.bssid[1], bss.bssid[2],
+						bss.bssid[3],bss.bssid[4], bss.bssid[5]);
+				memset(wpa_tkip_aes,0x00,sizeof(wpa_tkip_aes));
+				memset(wpa2_tkip_aes,0x00,sizeof(wpa2_tkip_aes));
+				if ((bss.capability & 0x10/*cPrivacy*/) == 0) {
+					/* No Encryption */
+					sprintf(tmp2Buf, "OPEN");
+				} else {
+					if (bss.t_stamp[0] == 0) {
+						/* WEP */
+						sprintf(tmp2Buf, "WEP");
+					} else {
+						int wpa_exist = 0, idx = 0;
+						if ((bss.t_stamp[0] & 0x00000fff) && (bss.t_stamp[2] & 0x000003ff)) {
+							/* WPA */
+							idx = sprintf(tmp2Buf, "WPA");
+							if ((bss.t_stamp[2] & 0x0000000f) == 0x4) {
+								/* WPA-PSK*/
+								idx += sprintf(tmp2Buf+idx, "-PSK");
+							}
+							wpa_exist = 1;
+
+							if (((bss.t_stamp[0] & 0x00000f00) >> 8) == 0x5) {
+								/* Auto Cipher*/
+								sprintf(wpa_tkip_aes,"%s","aes+tkip");
+							} else if (((bss.t_stamp[0] & 0x00000f00) >> 8) == 0x4) {
+								/* AES */
+								sprintf(wpa_tkip_aes,"%s","aes");
+							} else if (((bss.t_stamp[0] & 0x00000f00) >> 8) == 0x1) {
+								/* TKIP */
+								sprintf(wpa_tkip_aes,"%s","tkip");
+							}
+						}
+						if ((bss.t_stamp[0] & 0x0fff0000) && (bss.t_stamp[2] & 0x03ff0000)) {
+							if (wpa_exist)
+								idx += sprintf(tmp2Buf+idx, "/");
+							/* WPA2*/
+							idx += sprintf(tmp2Buf+idx, "WPA2");
+							if ((bss.t_stamp[2] & 0x000f0000) == 0x4) {
+								/*WPA2-PSK*/
+								idx += sprintf(tmp2Buf+idx, "-PSK");
+							}
+
+							if (((bss.t_stamp[0] & 0x0f000000) >> 24) == 0x5) {
+								/* Auto Cipher*/
+								sprintf(wpa2_tkip_aes,"%s","aes+tkip");
+							} else if (((bss.t_stamp[0] & 0x0f000000) >> 24) == 0x4) {
+								/* AES */
+								sprintf(wpa2_tkip_aes,"%s","aes");
+							} else if (((bss.t_stamp[0] & 0x0f000000) >> 24) == 0x1) {
+								/* TKIP */
+								sprintf(wpa2_tkip_aes,"%s","tkip");
+							}
+						}
+					}
+				}
+				fprintf(fptr, "<encrypt>%s</encrypt>", tmp2Buf);
+				if ((strlen(wpa_tkip_aes)!=0)&&(strlen(wpa2_tkip_aes)!=0))
+					fprintf(fptr, "<cipher>%s/%s</cipher>", wpa_tkip_aes, wpa2_tkip_aes);
+				else if (strlen(wpa_tkip_aes)!=0)
+					fprintf(fptr, "<cipher>%s</cipher>", wpa_tkip_aes);
+				else if (strlen(wpa2_tkip_aes)!=0)
+					fprintf(fptr, "<cipher>%s</cipher>", wpa2_tkip_aes);
+				else
+					fprintf(fptr, "<cipher>%s</cipher>", "");
+				if (bss.network==BAND_11B)
+					strcpy(tmp1Buf, " (B)");
+				else if (bss.network==BAND_11G)
+					strcpy(tmp1Buf, " (G)");
+				else if (bss.network==(BAND_11G|BAND_11B))
+					strcpy(tmp1Buf, " (B+G)");
+				else if (bss.network==(BAND_11N))
+					strcpy(tmp1Buf, " (N)");
+				else if (bss.network==(BAND_11G|BAND_11N))
+					strcpy(tmp1Buf, " (G+N)");
+				else if (bss.network==(BAND_11G|BAND_11B | BAND_11N))
+					strcpy(tmp1Buf, " (B+G+N)");
+				else if(bss.network== BAND_11A)
+					strcpy(tmp1Buf, " (A)");
+				else
+					strcpy(tmp1Buf, " ---");
+                fprintf(fptr, "<channel>%d</channel>", bss.channel);
+                fprintf(fptr, "<wlmode>%s</wlmode>", tmp1Buf);
+				fprintf(fptr, "<signal>%d</signal></entry>", bss.rssi);
+			}
+		};
+		fprintf(fptr,"</sitesurvey></runtime></XML_ROOT>");
+	}
+
+	return 0;
+}
+#endif
+
+void delay_ms(unsigned int t)
+{
+#if defined(CONFIG_USB_HCI) || defined(CONFIG_SDIO_HCI)
+	// use msleep instead of mdelay to improve CPU loading when in process context
+	if (!in_atomic() && !irqs_disabled() && t >= (MSEC_PER_SEC / HZ))
+		msleep(t);
+	else
+#endif
+	mdelay(t);
+}
+
+#ifdef _SINUX_
+enum iwpriv_type {
+    IW_NA,
+    IW_RD,
+    IW_WR,
+    IW_DP
+};
+
+typedef int cmd_rw_handler(struct rtl8192cd_priv *, unsigned char *);
+typedef void cmd_dump_handler(struct rtl8192cd_priv *, unsigned char *);
+
+struct cmd_map_stru {
+    char *cmd_str;
+    void *cmd_handler;
+    int  type;
+};
+
+static struct cmd_map_stru iwpriv_cmds[] = {
+    {"set_mib",     set_mib,    IW_WR},
+    {"get_mib",     get_mib,    IW_RD},
+    {"write_mem",   write_mem,  IW_WR},
+    {"read_mem",    read_mem,   IW_RD},
+    {"read_reg",    read_reg,   IW_RD},
+    {"write_reg",   write_reg,  IW_WR},
+    {"read_rf",     read_rf_reg,   IW_RD},
+    {"write_rf",    write_rf_reg,  IW_WR},
+    {"reg_dump",    reg_dump,      IW_DP},
+    {NULL,          NULL,       IW_NA}
+};
+
+
+int rtl8192cd_iwpriv_cmd_process(unsigned char *ifname, unsigned char *data)
+{
+    static unsigned char buf[1024]={0};
+    struct cmd_map_stru * p_cmd;
+    unsigned char *para;
+    int ret;
+    struct net_device *net_dev;
+    struct rtl8192cd_priv *priv;
+    cmd_rw_handler *cmd_rw;
+    cmd_dump_handler *cmd_dump;
+
+
+    struct cmd_map_stru * cmds = iwpriv_cmds;
+    int i = 0 ;
+
+    printk("\n");
+    printk("rtl8192cd_iwpriv_cmd_process: cmd=%s\n", data);
+
+    while (cmds[i].cmd_str != NULL ) {
+        if ( memcmp(data, cmds[i].cmd_str, strlen(cmds[i].cmd_str)) == 0 )
+           break;
+        else
+            i++;
+    }
+
+    if (cmds[i].cmd_str == NULL || cmds[i].cmd_handler == NULL) {
+       printk(" wireless ioctl command '%s' invalid !\n", data);
+        return -1;
+    }
+
+    // get priv
+    net_dev = dev_get_by_name(ifname);
+    if (net_dev == NULL)
+    {
+        printk("rtl8192cd_iwpriv_cmd_process: can not get dev %s\n", data);
+        return -ENETDOWN;
+    }
+    priv = (struct rtl8192cd_priv *)net_dev -> priv;
+
+    // put command parameter into buf
+    para = data + strlen(cmds[i].cmd_str);
+    para += strspn(para, " \t");
+
+    strncpy(buf, para, sizeof(buf)-1);
+    buf[sizeof(buf)-1] = '\0';
+
+    // run command
+    printk("wireless ioctl: cmd=%s, para=%s\n", cmds[i].cmd_str, buf);
+
+    if (cmds[i].type == IW_DP) { // dump command
+        cmd_dump = (cmd_dump_handler *)cmds[i].cmd_handler;
+        cmd_dump(priv, buf);
+        dev_put(net_dev);
+        return 0;
+    }
+    else {  // read/write command
+        cmd_rw = (cmd_rw_handler *)cmds[i].cmd_handler;
+        ret = cmd_rw(priv, buf);
+	  dev_put(net_dev);
+        if (ret < 0) {
+            printk("run fail!\n");
+            return ret;
+        }
+    }
+
+    printk("run successful !\n");
+
+    if (cmds[i].type == IW_RD) {
+        buf[ret] = '\0'; // add '\0' end for string
+        printk("    result length: %d\n", ret);
+        printk("    result text  : %s\n", buf);
+        for (i=0; i<ret; i++)
+            printk(" %02X", buf[i]);
+        printk("\n");
+    }
+
+    return 0;
+}
+
+
+int sos_ioctl_priv_get(char *ifname, char *cmd, char* data)
+{
+    struct net_device	*net_dev;
+	struct rtl8192cd_priv	*priv;
+    int retlen;
+
+
+    net_dev = dev_get_by_name(ifname);
+
+    if (net_dev == NULL)
+    {
+        printk("sos_ioctl_priv_stat: can not get dev %s\n", data);
+        return -ENETDOWN;
+    }
+
+    priv = (struct rtl8192cd_priv *)net_dev -> priv;
+
+    retlen = get_mib(priv, data);
+
+    dev_put(net_dev);
+
+    if (retlen > 0)
+        return retlen;
+    else
+        return -1;
+}
+
+
+int sos_ioctl_priv_set(
+    char *netName,
+    char	*name,
+    void	*value)
+{
+    int ret = 0;
+#ifndef SMP_SYNC
+	unsigned long flags;
+#endif
+    struct net_device	*net_dev;
+	struct rtl8192cd_priv	*priv;
+    int sizeof_tmpbuf;
+    static unsigned char tmpbuf[1024];
+
+    char *this_char = name;
+    char *this_value = (char *)value;
+
+    sizeof_tmpbuf = sizeof(tmpbuf);
+    memset(tmpbuf, '\0', sizeof_tmpbuf);
+
+    net_dev = dev_get_by_name(netName);
+
+    if (net_dev == NULL)
+    {
+        printk("sos_ioctl_priv_set: %scan not get dev\n", netName);
+        return -ENETDOWN;
+    }
+
+	priv = (struct rtl8192cd_priv *)net_dev->priv;
+
+	SAVE_INT_AND_CLI(flags);
+
+    memcpy(tmpbuf, this_char, strlen(this_char));
+    ret = set_mib(priv, tmpbuf);
+    dev_put(net_dev);
+    if (ret == 0)
+        strcpy(this_value, tmpbuf);
+
+    printk("sos_ioctl_priv_set: set_mib return %d\n", ret);
+
+	RESTORE_INT(flags);
+
+    return ret;
+}
+
+struct wifi_mib * get_wlandev_mib(struct net_device *dev)
+{
+ 	struct rtl8192cd_priv * priv;
+
+    if (dev == NULL)
+       return NULL;
+
+    priv  = (struct rtl8192cd_priv *) (dev -> priv);
+
+    return priv -> pmib;
+}
+
+struct spinlock_t * get_wlandev_lock (struct net_device *dev)
+{
+ 	struct rtl8192cd_priv * priv;
+
+    if (dev == NULL)
+        return NULL;
+
+    priv  = (struct rtl8192cd_priv *) (dev -> priv);
+
+    return & (priv -> pshare -> lock);
+
+}
+
+#if 0
+/* rtl8192cd_getMacTable return mac num, if fail return -1 */
+int rtl8192cd_get_staInfo(char *wlan_ifname, sta_info_2_web **ppsta_info, int *sta_len)
+{
+    struct net_device	*net_dev;
+	struct rtl8192cd_priv	*priv;
+    int sizeof_tmpbuf;
+    unsigned char *tmp1;
+    sta_info_2_web *psta_info;
+    int i,j=0;
+
+    net_dev = dev_get_by_name(wlan_ifname);
+
+    if (net_dev == NULL)
+    {
+        printk("rtl8192cd_get_staInfo(): can not get dev %s\n", wlan_ifname);
+        return -1;
+    }
+
+    priv = (struct rtl8192cd_priv *)net_dev -> priv;
+
+    dev_put(net_dev);
+
+
+	sizeof_tmpbuf = sizeof(sta_info_2_web) * (NUM_STAT + 1); // for the max of all sta info
+    tmp1 = (unsigned char *)kmalloc(sizeof_tmpbuf, GFP_ATOMIC);
+
+    if (!tmp1) {
+		printk("Unable to allocate temp buffer for rtl8192cd_get_staInfo()!\n");
+		return -1;
+	}
+	memset(tmp1, '\0', sizeof(sta_info_2_web));
+
+	get_sta_info(priv, (sta_info_2_web *)(tmp1 + sizeof(sta_info_2_web)), NUM_STAT);
+
+/*
+    for (i=0,j=0; i< maxLen; i++) {
+        psta_info = (sta_info_2_web *)(tmp1 + sizeof(sta_info_2_web)*(i+1));
+        if (memcmp(psta_info->addr, "\x0\x0\x0\x0\x0\x0", 6)!=0) {
+            memcpy(macTable+j*6, psta_info->addr, 6);
+            j++;
+        }
+    }
+*/
+    *ppsta_info = tmp1;
+    *sta_len = NUM_STAT+1;
+
+    return 0;
+}
+
+
+void rtl8192cd_put_staInfo(sta_info_2_web *psta_info)
+{
+    if (psta_info != NULL)
+        kfree(psta_info);
+
+    return;
+}
+
+#endif
+
+int rtl8192cd_getAutoChannel(char *wlan_ifname, int *channel)
+{
+    struct net_device	*net_dev;
+	struct rtl8192cd_priv	*priv;
+	unsigned int ret;
+
+    net_dev = dev_get_by_name(wlan_ifname);
+
+    if (net_dev == NULL)
+    {
+        printk("sos_ioctl_priv_stat: can not get dev %s\n", wlan_ifname);
+        return -1;
+    }
+
+    priv = (struct rtl8192cd_priv *)net_dev -> priv;
+
+    *channel = priv->pmib->dot11RFEntry.dot11channel;
+
+    ret=priv->pmib->dot11nConfigEntry.dot11n2ndChOffset;
+
+    dev_put(net_dev);
+
+    return ret;
+}
+
+int rtl8192cd_get_sta_num(char *wlan_ifname)
+{
+    struct net_device	*net_dev=NULL;
+	struct rtl8192cd_priv	*priv=NULL;
+	int number=0;
+
+    net_dev = dev_get_by_name(wlan_ifname);
+    if (net_dev )
+    {
+        priv = (struct rtl8192cd_priv *)net_dev -> priv;
+        number = priv->assoc_num;
+        dev_put(net_dev);
+    }
+
+	return number;
+}
+
+#ifdef _SINUX_
+/*   Dynamic adjust RF power
+ *
+ *   para values is char array, length must be 28.
+ *
+ */
+int rtl8192cd_adjust_rf_power(struct net_device *wdev, char *values)
+{
+	struct rtl8192cd_priv *priv         = wdev->priv;
+    struct rf_finetune_var	* pvar   = &(priv->pshare->rf_ft_var);
+
+    pvar->txPowerPlus_cck_1     = values[0];
+	pvar->txPowerPlus_cck_2     = values[1];
+	pvar->txPowerPlus_cck_5     = values[2];
+	pvar->txPowerPlus_cck_11    = values[3];
+	pvar->txPowerPlus_ofdm_6    = values[4];
+	pvar->txPowerPlus_ofdm_9    = values[5];
+	pvar->txPowerPlus_ofdm_12   = values[6];
+	pvar->txPowerPlus_ofdm_18   = values[7];
+	pvar->txPowerPlus_ofdm_24   = values[8];
+	pvar->txPowerPlus_ofdm_36   = values[9];
+	pvar->txPowerPlus_ofdm_48   = values[10];
+	pvar->txPowerPlus_ofdm_54   = values[11];
+	pvar->txPowerPlus_mcs_0     = values[12];
+	pvar->txPowerPlus_mcs_1     = values[13];
+	pvar->txPowerPlus_mcs_2     = values[14];
+	pvar->txPowerPlus_mcs_3     = values[15];
+	pvar->txPowerPlus_mcs_4     = values[16];
+	pvar->txPowerPlus_mcs_5     = values[17];
+	pvar->txPowerPlus_mcs_6     = values[18];
+	pvar->txPowerPlus_mcs_7     = values[19];
+	pvar->txPowerPlus_mcs_8     = values[20];
+	pvar->txPowerPlus_mcs_9     = values[21];
+	pvar->txPowerPlus_mcs_10    = values[22];
+	pvar->txPowerPlus_mcs_11    = values[23];
+	pvar->txPowerPlus_mcs_12    = values[24];
+	pvar->txPowerPlus_mcs_13    = values[25];
+	pvar->txPowerPlus_mcs_14    = values[26];
+	pvar->txPowerPlus_mcs_15    = values[27];
+
+    return 0;
+}
+
+EXPORT_SYMBOL(rtl8192cd_adjust_rf_power);
+#endif
+
+EXPORT_SYMBOL(AddDelMCASTGroup2STA);
+EXPORT_SYMBOL(rtl8192cd_get_sta_num);
+EXPORT_SYMBOL(get_wlandev_lock);
+EXPORT_SYMBOL(get_wlandev_mib);
+EXPORT_SYMBOL(sos_ioctl_priv_set);
+EXPORT_SYMBOL(sos_ioctl_priv_get);
+EXPORT_SYMBOL(rtl8192cd_getMacTable);
+EXPORT_SYMBOL(rtl8192cd_check_wlan_mac);
+EXPORT_SYMBOL(rtl8192cd_getAutoChannel);
+EXPORT_SYMBOL(rtl8192cd_iwpriv_cmd_process);
+
+#endif
+
diff --git a/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/wireless/rtl8192cd_92es_wpa2/config.mk b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/wireless/rtl8192cd_92es_wpa2/config.mk
new file mode 100755
index 0000000..a1969e2
--- /dev/null
+++ b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/net/wireless/rtl8192cd_92es_wpa2/config.mk
@@ -0,0 +1,361 @@
+#
+# RTL WLan AP Driver All In One Configure
+#
+
+#
+# Wireless LAN
+#
+
+# Driver Module/Build In Driver ==> :=m/:=y
+#CONFIG_RTL8192CD :=m
+
+# RTK Platform ?
+RTK_BSP :=n
+
+# Select Support WLan Chip
+CONFIG_RTL_92C_SUPPORT ?=n
+CONFIG_RTL_92D_SUPPORT ?=n
+CONFIG_RTL_8812_SUPPORT ?=n
+CONFIG_RTL_8814_SUPPORT ?=n
+
+CONCURRENT_MODE :=n
+
+# Bus Interface Type, PCIE / USB / SDIO
+CONFIG_PCI_HCI :=n
+CONFIG_USB_HCI :=n
+CONFIG_SDIO_HCI :=y
+
+# RTL Platform Support
+CONFIG_RTL_819X :=n
+CONFIG_RTL_819XD :=n
+
+# Driver Configuration
+CONFIG_RTL8190_PRIV_SKB :=n
+CONFIG_PREALLOC_MODULE :=n
+
+CONFIG_RTL_WAPI_SUPPORT :=n
+
+# If Use External PA, LNA ?
+CONFIG_EXT_PA :=n
+CONFIG_EXT_LNA :=n
+# 0:22dB LNA gain; 1:18dB LNA gain; 2:16dB LNA gain; 3:14dB LNA gain
+CONFIG_EXT_LNA_TYPE := 3
+# 0:22dB LNA gain; 1:18dB LNA gain; 2:16dB LNA gain; 3:14dB LNA gain
+CONFIG_EXT_PA_LNA_TYPE :=3
+
+# If Support Dynamic Freqence Selection ?
+CONFIG_RTL_DFS_SUPPORT :=n
+
+# Number of Virtual AP ?
+ifeq ($(RTL8192CD_NUM_VWLAN),)
+RTL8192CD_NUM_VWLAN := 2
+endif
+
+# If Support Client Mode ?
+CONFIG_RTL_CLIENT_MODE_SUPPORT :=y
+CONFIG_RTL_REPEATER_MODE_SUPPORT :=y
+CONFIG_RTL_SUPPORT_MULTI_PROFILE :=n
+CONFIG_RTL_MULTI_CLONE_SUPPORT :=n
+
+# If Support Wireless Distribution System ?
+CONFIG_RTL_WDS_SUPPORT :=n
+
+# If Enable On-Chip EFuse ?
+CONFIG_ENABLE_EFUSE :=y
+
+# If support non-HAL Chip ? (92C, 92D, 88E, 8812)
+CONFIG_RTL_WLAN_HAL_NOT_EXIST :=y
+
+CONFIG_MP_PSD_SUPPORT :=n
+CONFIG_RTL_P2P_SUPPORT :=n
+CONFIG_RTL_MESH_SUPPORT :=n
+CONFIG_RTL_WLAN_DOS_FILTER :=n
+CONFIG_TXPWR_LMT :=n
+CONFIG_RTL_WPS2_SUPPORT :=y
+ifdef CONFIG_RTL_92E_SUPPORT
+    CONFIG_POWER_SAVE :=n
+else
+    CONFIG_POWER_SAVE :=y
+endif
+CONFIG_RTL_COMAPI_CFGFILE :=n
+CONFIG_RTL_COMAPI_WLTOOLS :=n
+# [WPA Supplicant] 0:None; 1:wext; 2:nl80211
+CONFIG_WPAS_CLI :=1
+CONFIG_NL80211_AP :=n
+
+# Select WLan PHY Clock Source, 40MHz/25MHz. For WLan module, we use 40MHz usually
+CONFIG_PHY_EAT_40MHZ :=y
+CONFIG_PHY_WLAN_EAT_40MHZ :=y
+
+CONFIG_IGMP_SNOOPING_SUPPORT:=y
+CONFIG_MLD_SNOOPING_SUPPORT:=y
+
+# 802.11w support
+CONFIG_RTL_11W_SUPPORT:=n
+
+# 802.11k support
+CONFIG_RTL_DOT11K_SUPPORT:=n
+
+# 802.11v support
+CONFIG_RTL_11V_SUPPORT:=n
+
+# VLAN tag support
+CONFIG_RTL_VLAN_SUPPORT:=n
+CONFIG_ZTE_TASKLET_TO_THERAD:=n
+CONFIG_ZTE_TIMESTAMP:=n
+CONFIG_ZTE_TXDMAERROR_RESET=y
+######## Don't Modify Following Code ########
+ifeq ($(CONFIG_ZTE_TASKLET_TO_THERAD),y)
+	EXTRA_CFLAGS += -DHANDLE_TX_THREAD_ZTE
+	EXTRA_CFLAGS += -DHANDLE_RX_THREAD_ZTE
+endif
+ifeq ($(CONFIG_ZTE_TXDMAERROR_RESET),y)
+	EXTRA_CFLAGS += -DCONFIG_ZTE_TXDMAERROR_RESET
+endif
+ifeq ($(CONFIG_ZTE_TIMESTAMP),y)
+	EXTRA_CFLAGS += -DCONFIG_ZTE_TIMESTAMP
+endif
+EXTRA_CFLAGS += -DCONFIG_RTL_80211D_SUPPORT
+EXTRA_CFLAGS += -DCONFIG_RTL8192CD
+
+ifeq ($(RTK_BSP),n)
+	EXTRA_CFLAGS += -DNOT_RTK_BSP
+	EXTRA_CFLAGS += -DCONFIG_WIRELESS_LAN_MODULE
+endif
+
+ifeq ($(CONFIG_PCI_HCI),y)
+	EXTRA_CFLAGS += -DCONFIG_PCI_HCI
+endif
+
+ifeq ($(CONFIG_USB_HCI),y)
+	EXTRA_CFLAGS += -DCONFIG_USB_HCI
+endif
+
+ifeq ($(CONFIG_SDIO_HCI),y)
+	EXTRA_CFLAGS += -DCONFIG_SDIO_HCI
+	# 0: No AP power saving 1: RF off  2: beacon offload
+	CONFIG_AP_PS := 0
+endif
+
+ifeq ($(CONFIG_RTL_92C_SUPPORT),y)
+	CONFIG_RTL_WLAN_HAL_NOT_EXIST :=y
+	EXTRA_CFLAGS += -DCONFIG_RTL_92C_SUPPORT
+endif
+  
+ifeq ($(CONFIG_RTL_92D_SUPPORT),y)
+	CONFIG_RTL_WLAN_HAL_NOT_EXIST :=y
+	EXTRA_CFLAGS += -DCONFIG_RTL_92D_SUPPORT
+	#EXTRA_CFLAGS += -DCONFIG_RTL_92D_DMDP
+endif
+
+ifeq ($(CONFIG_RTL_88E_SUPPORT),y)
+	CONFIG_RTL_WLAN_HAL_NOT_EXIST :=y
+	CONFIG_RTL_ODM_WLAN_DRIVER :=y
+	EXTRA_CFLAGS += -DCONFIG_RTL_88E_SUPPORT
+endif
+
+ifeq ($(CONFIG_RTL_8812_SUPPORT),y)
+#	CONFIG_RTL_DFS_SUPPORT :=n
+	CONFIG_RTL_WLAN_HAL_NOT_EXIST :=y
+	CONFIG_RTL_ODM_WLAN_DRIVER :=y
+	EXTRA_CFLAGS += -DCONFIG_RTL_8812_SUPPORT
+endif
+
+ifeq ($(CONFIG_RTL_8814_SUPPORT),y)
+	CONFIG_WLAN_HAL :=y
+	CONFIG_WLAN_HAL_88XX :=y
+	CONFIG_WLAN_HAL_8814AE :=y
+	CONFIG_RTL_ODM_WLAN_DRIVER :=y
+	EXTRA_CFLAGS += -DCONFIG_WLAN_HAL_8814AE
+endif
+
+ifeq ($(CONFIG_RTL_92E_SUPPORT),y)
+	CONFIG_WLAN_HAL :=y
+	CONFIG_WLAN_HAL_88XX :=y
+	CONFIG_WLAN_HAL_8192EE :=y
+	CONFIG_RTL_ODM_WLAN_DRIVER :=y
+	EXTRA_CFLAGS += -DCONFIG_WLAN_HAL_8192EE
+	ifeq ($(CONFIG_BEAMFORMING_SUPPORT), y)
+		EXTRA_CFLAGS += -DCONFIG_BEAMFORMING_SUPPORT
+	endif
+endif
+
+ifeq ($(CONFIG_WLAN_HAL),y)	
+	EXTRA_CFLAGS += -DCONFIG_WLAN_HAL
+
+	ifeq ($(CONFIG_WLAN_HAL_88XX),y)
+		EXTRA_CFLAGS += -DCONFIG_WLAN_HAL_88XX
+	endif
+
+	ifeq ($(CONFIG_WLAN_HAL_8881A),y)
+		RTL_WLAN_DATA_DIR := WlanHAL/Data/8881A
+	endif
+else
+	EXTRA_CFLAGS += -DCONFIG_RTL_WLAN_HAL_NOT_EXIST
+endif
+
+ifeq ($(CONFIG_RTL_WLAN_HAL_NOT_EXIST),y)
+	EXTRA_CFLAGS += -DCONFIG_RTL_WLAN_HAL_NOT_EXIST
+endif
+
+ifeq ($(CONFIG_RTL_ODM_WLAN_DRIVER),y)
+	EXTRA_CFLAGS += -DCONFIG_RTL_ODM_WLAN_DRIVER
+endif
+
+# TODO: We need to assign which NIC is using external PA and LNA
+ifeq ($(CONFIG_EXT_PA),y)
+	EXTRA_CFLAGS += -DCONFIG_SLOT_0_EXT_PA
+	EXTRA_CFLAGS += -DCONFIG_SLOT_1_EXT_PA
+endif
+
+ifeq ($(CONFIG_EXT_LNA),y)
+	EXTRA_CFLAGS += -DCONFIG_SLOT_0_EXT_LNA
+	EXTRA_CFLAGS += -DCONFIG_SLOT_1_EXT_LNA
+	ifeq ($(CONFIG_EXT_PA),y)
+		EXTRA_CFLAGS += -DEXT_LNA_TYPE=$(CONFIG_EXT_PA_LNA_TYPE)
+	else
+		EXTRA_CFLAGS += -DEXT_LNA_TYPE=$(CONFIG_EXT_LNA_TYPE)
+	endif
+endif
+
+ifeq ($(CONFIG_RTL_DFS_SUPPORT),y)
+	EXTRA_CFLAGS += -DCONFIG_RTL_DFS_SUPPORT
+endif
+
+ifneq ($(RTL8192CD_NUM_VWLAN),0)
+	EXTRA_CFLAGS += -DCONFIG_RTL_VAP_SUPPORT
+endif
+EXTRA_CFLAGS += -DRTL8192CD_NUM_VWLAN=$(RTL8192CD_NUM_VWLAN)
+
+ifeq ($(CONFIG_RTL_CLIENT_MODE_SUPPORT),y)
+	EXTRA_CFLAGS += -DCONFIG_RTL_CLIENT_MODE_SUPPORT
+else
+	CONFIG_WPAS_CLI :=0
+endif
+
+ifeq ($(CONFIG_RTL_REPEATER_MODE_SUPPORT),y)
+	EXTRA_CFLAGS += -DCONFIG_RTL_REPEATER_MODE_SUPPORT
+endif
+
+ifeq ($(CONFIG_RTL_SUPPORT_MULTI_PROFILE),y)
+	EXTRA_CFLAGS += -DCONFIG_RTL_SUPPORT_MULTI_PROFILE
+endif
+
+ifeq ($(CONFIG_RTL_MULTI_CLONE_SUPPORT),y)
+	EXTRA_CFLAGS += -DCONFIG_RTL_MULTI_CLONE_SUPPORT
+endif
+
+ifeq ($(CONFIG_RTL_WDS_SUPPORT),y)
+	EXTRA_CFLAGS += -DCONFIG_RTL_WDS_SUPPORT
+endif
+
+ifeq ($(CONFIG_ENABLE_EFUSE),y)
+	EXTRA_CFLAGS += -DCONFIG_ENABLE_EFUSE
+endif
+
+ifeq ($(CONFIG_RTL_COMAPI_CFGFILE),y)
+	EXTRA_CFLAGS += -DCONFIG_RTL_COMAPI_CFGFILE
+endif
+
+ifeq ($(CONFIG_RTL_COMAPI_WLTOOLS),y)
+	EXTRA_CFLAGS += -DCONFIG_RTL_COMAPI_WLTOOLS
+endif
+
+ifeq ($(CONFIG_WPAS_CLI),1)		# wext
+	EXTRA_CFLAGS += -DCONFIG_RTL_COMAPI_WLTOOLS -DWIFI_WPAS_CLI -DSDIO_2_PORT
+	ifeq ($(CONFIG_NL80211_AP),y)
+		EXTRA_CFLAGS += -DNON_NL80211_WPAS
+	endif
+endif
+ifeq ($(CONFIG_WPAS_CLI),2)		# nl80211
+	EXTRA_CFLAGS += -DCPTCFG_CFG80211_MODULE
+	ifeq ($(CONFIG_NL80211_AP),n)
+		EXTRA_CFLAGS += -DNON_NL80211_AP
+	endif
+else
+	ifeq ($(CONFIG_NL80211_AP),y)
+		EXTRA_CFLAGS += -DCPTCFG_CFG80211_MODULE
+	endif
+endif
+
+ifeq ($(CONFIG_MP_PSD_SUPPORT),y)
+	EXTRA_CFLAGS += -DCONFIG_MP_PSD_SUPPORT
+endif
+
+ifeq ($(CONFIG_RTL_P2P_SUPPORT),y)
+	EXTRA_CFLAGS += -DCONFIG_RTL_P2P_SUPPORT
+endif
+
+ifeq ($(CONFIG_TXPWR_LMT),y)
+	EXTRA_CFLAGS += -DCONFIG_TXPWR_LMT
+endif
+
+ifeq ($(CONFIG_RTL_MESH_SUPPORT),y)
+	EXTRA_CFLAGS += -DCONFIG_RTL_MESH_SUPPORT
+endif
+
+ifeq ($(CONFIG_RTL_WLAN_DOS_FILTER),y)
+	EXTRA_CFLAGS += -DCONFIG_RTL_WLAN_DOS_FILTER
+endif
+
+ifeq ($(CONCURRENT_MODE),y)
+	EXTRA_CFLAGS += -DCONCURRENT_MODE
+endif
+
+ifeq ($(CONFIG_RTL8190_PRIV_SKB),y)
+	EXTRA_CFLAGS += -DCONFIG_RTL8190_PRIV_SKB
+endif
+
+ifeq ($(CONFIG_RTL_WPS2_SUPPORT),y)
+	EXTRA_CFLAGS += -DCONFIG_RTL_WPS2_SUPPORT
+endif
+
+ifeq ($(CONFIG_PHY_EAT_40MHZ),y)
+	EXTRA_CFLAGS += -DCONFIG_PHY_EAT_40MHZ
+endif
+ifeq ($(CONFIG_PHY_WLAN_EAT_40MHZ),y)
+	EXTRA_CFLAGS += -DCONFIG_PHY_WLAN_EAT_40MHZ
+endif
+
+ifeq ($(CONFIG_RTL_WAPI_SUPPORT),y)
+	EXTRA_CFLAGS += -DCONFIG_RTL_WAPI_SUPPORT
+endif
+
+ifeq ($(CONFIG_IGMP_SNOOPING_SUPPORT),y)
+	EXTRA_CFLAGS += -D_FULLY_WIFI_IGMP_SNOOPING_SUPPORT_
+endif
+
+ifeq ($(CONFIG_MLD_SNOOPING_SUPPORT),y)
+	EXTRA_CFLAGS += -D_FULLY_WIFI_MLD_SNOOPING_SUPPORT_
+endif
+
+ifeq ($(CONFIG_POWER_SAVE),y)
+	EXTRA_CFLAGS += -DSDIO_AP_OFFLOAD -DCONFIG_POWER_SAVE
+endif
+
+ifeq ($(CONFIG_PREALLOC_MODULE),y)
+	EXTRA_CFLAGS += -DUSE_PREALLOC_MODULE
+endif
+
+ifeq ($(CONFIG_RTL_11W_SUPPORT),y)
+	EXTRA_CFLAGS += -DCONFIG_RTL_11W_SUPPORT
+	ifeq ($(CONFIG_RTL_CLIENT_MODE_SUPPORT),y)
+		EXTRA_CFLAGS += -DCONFIG_RTL_11W_CLI_SUPPORT
+	endif
+endif
+
+ifeq ($(CONFIG_RTL_DOT11K_SUPPORT),y)
+		EXTRA_CFLAGS += -DCONFIG_RTL_DOT11K_SUPPORT
+endif
+
+ifeq ($(CONFIG_RTL_11V_SUPPORT),y)
+		EXTRA_CFLAGS += -DCONFIG_RTL_11V_SUPPORT
+endif
+
+ifeq ($(CONFIG_WIFI_SNIFFER),y)
+	EXTRA_CFLAGS += -DWIFI_SNIFFER
+endif
+
+ifeq ($(CONFIG_RTL_VLAN_SUPPORT),y)
+	EXTRA_CFLAGS += -DNOT_RTK_BSP_VLAN
+endif
\ No newline at end of file
diff --git a/lynq/S300/ap/os/linux/linux-3.4.x/drivers/power/aw3215_charger.c b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/power/aw3215_charger.c
new file mode 100644
index 0000000..e93a2b0
--- /dev/null
+++ b/lynq/S300/ap/os/linux/linux-3.4.x/drivers/power/aw3215_charger.c
@@ -0,0 +1,1251 @@
+/*
+ * Driver for the TI zx234502 battery charger.
+ *
+ * Author: Mark A. Greer <mgreer@animalcreek.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <linux/of_irq.h>
+#include <linux/of_device.h>
+#include <linux/pm_runtime.h>
+#include <linux/power_supply.h>
+#include <linux/gpio.h>
+#include <linux/i2c.h>
+#include <linux/irq.h>
+#include <linux/kthread.h>
+//#include <linux/mutex.h>
+#include <linux/semaphore.h>
+
+#include <linux/power/aw3215_charger.h>
+#include <linux/mfd/zx234290.h>
+
+#include <mach/gpio.h>
+#include <mach/pcu.h>
+#include <mach/zx29_usb.h>
+#include <linux/workqueue.h>
+
+#include <linux/slab.h>
+#include <linux/debugfs.h>
+#include <asm/uaccess.h>
+#include <linux/wakelock.h>
+
+#define CHG_DEBUG
+#ifdef CHG_DEBUG
+#define GIC_DIST_ENABLE_SET		0x100
+#define GIC_DIST_PENDING_SET	0x200
+extern void __iomem *base_testtt;
+#endif
+
+static volatile int s_chg_chin_cnt = 0;
+static volatile int s_chg_chstate_cnt = 0;
+
+
+#define USB_IN		GPIO_LOW
+#define USB_OUT		GPIO_HIGH
+#define CHG_START	GPIO_LOW
+#define CHG_STOP	GPIO_HIGH
+#ifdef _USE_V3PHONE_TYPE_XRSD_
+#define CHG_EN_TYPE		GPIO_HIGH
+#define CHG_DISEN_TYPE	GPIO_LOW
+#else
+#define CHG_EN_TYPE		GPIO_LOW
+#define CHG_DISEN_TYPE	GPIO_HIGH
+#endif
+
+//*when the bat voltage <3.2V usb will not enum ,then the sys fall in lowpower*/
+#define USB_ENUM_MIN	3400
+
+/*
+ * The FAULT register is latched by the zx234502 (except for NTC_FAULT)
+ * so the first read after a fault returns the latched value and subsequent
+ * reads return the current value.  In order to return the fault status
+ * to the user, have the interrupt handler save the reg's value and retrieve
+ * it in the appropriate health/status routine.  Each routine has its own
+ * flag indicating whether it should use the value stored by the last run
+ * of the interrupt handler or do an actual reg read.  That way each routine
+ * can report back whatever fault may have occured.
+ */
+ enum chg_stop_reason{
+	CHG_STOP_REASON_NO = 0,
+	CHG_STOP_REASON_TEMP= 1,
+	CHG_STOP_REASON_FULL = 2,
+	CHG_STOP_DEFALT= 0xff
+};
+struct aw3215_dev_info {
+	struct device		*dev;
+	struct power_supply	charger;
+	struct power_supply	battery;
+
+	kernel_ulong_t		model;
+	unsigned int		chgin_irq;
+	unsigned int		chgstate_irq;
+	//struct task_struct	*chgin_irq_thread;
+	struct task_struct	*chgstate_irq_thread;
+
+	u8					watchdog;
+
+	struct aw3215_platform_data 	*pdata;
+	unsigned int					chgin_type;
+	unsigned int					chgstate_type;
+	bool							chg_en;
+	unsigned int					chg_state;
+	//struct semaphore		chgin_sem;
+	struct semaphore		chgstate_sem;	
+	enum chg_stop_reason	stopchg_flag;
+	struct timer_list		changed_timer;
+	struct wake_lock		wlock_chgfull;
+
+};
+
+struct aw3215_dev_info *g_bdi = NULL;
+
+/* Charger power supply property routines */
+
+static int aw3215_charger_get_charge_type(struct aw3215_dev_info *bdi,union power_supply_propval *val)
+{
+	val->intval = bdi->charger.type;
+	return 0;
+}
+
+static int aw3215_charger_get_status(struct aw3215_dev_info *bdi,union power_supply_propval *val)
+{
+    int battery_voltage = get_adc2_voltage() * 3 - 115;
+
+    if (battery_voltage <= 10) {
+        val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
+        return 0;
+    }
+
+#if 1
+	val->intval = bdi->chg_state;
+#else
+	if(false==bdi->chg_en){
+		val->intval=POWER_SUPPLY_STATUS_NOT_CHARGING;/*diaable chg*/
+		return 0;
+	}
+	if (USB_IN==bdi->chgin_type) {
+		if(CHG_STOP==bdi->chgstate_type)
+			val->intval= POWER_SUPPLY_STATUS_FULL;
+		else if (CHG_START==bdi->chgstate_type)
+			val->intval= POWER_SUPPLY_STATUS_CHARGING;
+		else
+			val->intval=POWER_SUPPLY_STATUS_NOT_CHARGING;/*diaable chg*/
+	} else {
+		val->intval=POWER_SUPPLY_STATUS_DISCHARGING;/*usb not insert*/
+	}
+#endif
+	return 0;
+}
+
+static int aw3215_charger_get_health(struct aw3215_dev_info *bdi,union power_supply_propval *val)
+{
+    int battery_voltage = get_adc2_voltage();
+    if (battery_voltage <= 10) {
+        val->intval = POWER_SUPPLY_HEALTH_UNKNOWN;
+    } else {
+        val->intval = POWER_SUPPLY_HEALTH_GOOD;
+    }
+
+	return 0;
+}
+
+int aw3215_charger_get_online(struct aw3215_dev_info *bdi,union power_supply_propval *val)
+{
+	if (USB_IN==bdi->chgin_type) {
+		val->intval= 1;
+	} else {
+		val->intval=0;/*usb not insert*/
+	}
+
+	return 0;
+}EXPORT_SYMBOL (aw3215_charger_get_online);
+
+
+static int aw3215_charger_get_charger_enabled(struct aw3215_dev_info *bdi,union power_supply_propval *val)
+{
+	val->intval = bdi->chg_en;
+
+	return 0;
+}
+static int aw3215_charger_get_voltage_max(struct aw3215_dev_info *bdi,union power_supply_propval *val)
+{
+	val->intval = 4200;
+
+	return 0;
+}
+
+static int aw3215_charger_set_voltage(struct aw3215_dev_info *bdi,const union power_supply_propval *val)
+{
+	return 0;
+}
+static int aw3215_charger_set_charger_config(struct aw3215_dev_info *bdi,const union power_supply_propval *val)
+{
+	int ret = 0;
+	int gpio_state = 0;
+
+	if (val->intval==1) {
+		if (bdi->chg_en)
+			return 0;
+		gpio_state = CHG_EN_TYPE ;/*gpio low en chg*/
+		printk("mmi start chg\n");
+	} else {
+		if (!bdi->chg_en)
+			return 0;
+		gpio_state = CHG_DISEN_TYPE ;/*gpio high stop chg*/
+		printk("mmi stop chg\n");
+	}
+
+	disable_irq(bdi->chgstate_irq);
+
+	if (gpio_state == CHG_EN_TYPE) {
+		bdi->chg_en = true;		/*(~gpio_state)*/
+		bdi->chgstate_type = CHG_START;
+		bdi->stopchg_flag = CHG_STOP_REASON_NO;
+		gpio_set_value(bdi->pdata->gpio_chgen, gpio_state);
+
+		if (bdi->chgin_type == USB_IN) {	
+			bdi->chg_state = POWER_SUPPLY_STATUS_CHARGING;		
+			irq_set_irq_type(bdi->chgstate_irq, IRQ_TYPE_LEVEL_HIGH);
+			/* start charging in 5.3ms after enable */
+			if (gpio_get_value(bdi->pdata->gpio_chgstate))
+				mdelay(40);
+			if (gpio_get_value(bdi->pdata->gpio_chgstate)){
+				printk(KERN_INFO "chg still not chargin\n"); /* should not go here */	
+				bdi->chg_state = POWER_SUPPLY_STATUS_FULL;			
+				irq_set_irq_type(bdi->chgstate_irq, IRQ_TYPE_LEVEL_LOW);
+			}
+
+		}
+	} else {
+		bdi->chg_en = false;
+		bdi->chgstate_type = CHG_STOP;
+		bdi->stopchg_flag = CHG_STOP_REASON_TEMP;
+		if (2==val->intval){/*chg full stop*/
+			bdi->stopchg_flag = CHG_STOP_REASON_FULL;
+			bdi->chg_state = POWER_SUPPLY_STATUS_FULL;
+			printk("mmi full stop chg\n");
+	
+		}
+		else if (bdi->chgin_type == USB_IN)
+			bdi->chg_state = POWER_SUPPLY_STATUS_NOT_CHARGING;
+
+			gpio_set_value(bdi->pdata->gpio_chgen, gpio_state);
+		/* charger state changes from 0 to 1 in 0.12ms */
+			if (!gpio_get_value(bdi->pdata->gpio_chgstate))
+				udelay(500);
+
+			irq_set_irq_type(bdi->chgstate_irq, IRQ_TYPE_LEVEL_LOW);
+
+	}
+
+	enable_irq(bdi->chgstate_irq);
+#ifdef CHG_DEBUG
+		printk("irq1 chg_in= %d,chg_state_cnt= %d\n",s_chg_chstate_cnt,s_chg_chin_cnt);
+		printk("chg int enable reg1 =0x%x:\n", zx_read_reg(base_testtt + GIC_DIST_ENABLE_SET+0x4));
+		printk("chg int enable reg2 =0x%x:\n", zx_read_reg(base_testtt + GIC_DIST_ENABLE_SET+0x8));
+		printk("chg int pending reg1 =0x%x:\n", zx_read_reg(base_testtt + GIC_DIST_PENDING_SET+0x4));
+		printk("chg int pending reg2 =0x%x:\n", zx_read_reg(base_testtt + GIC_DIST_PENDING_SET+0x8));
+		printk("irq2 chg_in= %d,chg_state_cnt= %d\n",s_chg_chstate_cnt,s_chg_chin_cnt);
+#endif
+
+	power_supply_changed(&bdi->charger);
+
+	return ret;
+}
+
+
+static int aw3215_charger_get_property(struct power_supply *psy,enum power_supply_property psp, union power_supply_propval *val)
+{
+	struct aw3215_dev_info *bdi = container_of(psy, struct aw3215_dev_info, charger);
+	int ret;
+
+	//dev_dbg(bdi->dev, "prop: %d\n", psp);
+
+	//pm_runtime_get_sync(bdi->dev);
+
+	switch (psp) {
+	case POWER_SUPPLY_PROP_PC1_AC2:
+		ret = aw3215_charger_get_charge_type(bdi, val);
+		break;
+
+	case POWER_SUPPLY_PROP_STATUS:
+		ret = aw3215_charger_get_status(bdi, val);
+		break;
+	case POWER_SUPPLY_PROP_HEALTH:
+		ret = aw3215_charger_get_health(bdi, val);
+		break;
+	case POWER_SUPPLY_PROP_ONLINE:
+		ret = aw3215_charger_get_online(bdi, val);
+		break;
+
+	case POWER_SUPPLY_PROP_VOLTAGE_MAX:
+		ret = aw3215_charger_get_voltage_max(bdi, val);
+		break;
+
+	case POWER_SUPPLY_PROP_CHARGE_ENABLED:
+		ret = aw3215_charger_get_charger_enabled(bdi, val);
+		break;
+	default:
+		ret = -ENODATA;
+	}
+
+	//pm_runtime_put_sync(bdi->dev);
+	return ret;
+}
+
+static int aw3215_charger_set_property(struct power_supply *psy,enum power_supply_property psp,
+		const union power_supply_propval *val)
+{
+	struct aw3215_dev_info *bdi =
+			container_of(psy, struct aw3215_dev_info, charger);
+	int ret;
+
+	//dev_dbg(bdi->dev, "prop: %d\n", psp);
+
+	//pm_runtime_get_sync(bdi->dev);
+
+	switch (psp) {
+#if 0
+	case POWER_SUPPLY_PROP_CURRENT_NOW:
+		ret = zx234502_charger_set_current(bdi, val);
+		break;
+#endif
+	case POWER_SUPPLY_PROP_VOLTAGE_MAX:
+		ret = aw3215_charger_set_voltage(bdi, val);
+		break;
+
+    case POWER_SUPPLY_PROP_CHARGE_ENABLED:
+        ret = aw3215_charger_set_charger_config(bdi, val);
+        break;
+	default:
+		ret = -EINVAL;
+	}
+
+	//pm_runtime_put_sync(bdi->dev);
+	return ret;
+}
+
+static int aw3215_charger_property_is_writeable(struct power_supply *psy,enum power_supply_property psp)
+{
+	int ret;
+
+	switch (psp)
+	{
+    	//case POWER_SUPPLY_PROP_CURRENT_NOW:
+    	case POWER_SUPPLY_PROP_VOLTAGE_MAX:
+	case POWER_SUPPLY_PROP_CHARGE_ENABLED:
+    		ret = 1;
+    		break;
+	default:
+		ret = 0;
+		break;
+	}
+
+	return ret;
+}
+
+static enum power_supply_property aw3215_charger_properties[] = {
+	POWER_SUPPLY_PROP_PC1_AC2,
+	POWER_SUPPLY_PROP_STATUS,
+	POWER_SUPPLY_PROP_HEALTH,
+	POWER_SUPPLY_PROP_ONLINE,
+	//POWER_SUPPLY_PROP_CURRENT_NOW,
+	//POWER_SUPPLY_PROP_CURRENT_MAX,
+	//POWER_SUPPLY_PROP_VOLTAGE_NOW,
+	POWER_SUPPLY_PROP_VOLTAGE_MAX,
+	POWER_SUPPLY_PROP_CHARGE_ENABLED,
+};
+
+static char *aw3215_charger_supplied_to[] = {
+	"main-battery",
+};
+
+static void aw3215_charger_init(struct power_supply *charger)
+{
+	charger->name = "charger";
+	charger->type = POWER_SUPPLY_PCAC_UNKNOWN;
+	charger->properties = aw3215_charger_properties;
+	charger->num_properties = ARRAY_SIZE(aw3215_charger_properties);
+	charger->supplied_to = aw3215_charger_supplied_to;
+	//charger->num_supplies = ARRAY_SIZE(aw3215_charger_supplied_to);
+	charger->get_property = aw3215_charger_get_property;
+	charger->set_property = aw3215_charger_set_property;
+	charger->property_is_writeable = aw3215_charger_property_is_writeable;
+}
+
+/* Battery power supply property routines */
+
+static int aw3215_battery_get_health(struct aw3215_dev_info *bdi,union power_supply_propval *val)
+{
+    int battery_voltage = get_adc2_voltage();
+    if (battery_voltage <= 10) {
+        val->intval = POWER_SUPPLY_HEALTH_UNKNOWN;
+    } else {
+        val->intval = POWER_SUPPLY_HEALTH_GOOD;
+    }
+	return 0;
+}
+
+static int aw3215_battery_get_online(struct aw3215_dev_info *bdi,union power_supply_propval *val)
+{
+    int battery_voltage = get_adc2_voltage();
+    if (battery_voltage <= 10) {
+        val->intval = 0;
+    } else {
+        val->intval = 1;
+    }
+	return 0;
+}
+
+static int aw3215_battery_set_online(struct aw3215_dev_info *bdi,const union power_supply_propval *val)
+{
+	return 0;
+}
+
+
+static int aw3215_battery_get_property(struct power_supply *psy,enum power_supply_property psp,
+		union power_supply_propval *val)
+{
+	struct aw3215_dev_info *bdi =
+			container_of(psy, struct aw3215_dev_info, battery);
+	int ret;
+
+	//dev_dbg(bdi->dev, "prop: %d\n", psp);
+
+	//pm_runtime_get_sync(bdi->dev);
+
+	switch (psp) {
+
+	case POWER_SUPPLY_PROP_HEALTH:
+		ret = aw3215_battery_get_health(bdi, val);
+		break;
+	case POWER_SUPPLY_PROP_ONLINE:
+		ret = aw3215_battery_get_online(bdi, val);
+		break;
+
+	case POWER_SUPPLY_PROP_TEMP:
+		val->intval = get_adc1_voltage() - 15;
+		ret = 0;
+		break;
+
+	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+		//#ifdef CONFIG_ZX234290_ADC
+		msleep(100);
+		val->intval = get_adc2_voltage() * 3 - 120;
+		ret = 0;
+		break;
+	default:
+		ret = -ENODATA;
+	}
+
+	//pm_runtime_put_sync(bdi->dev);
+	return ret;
+}
+
+static int aw3215_battery_set_property(struct power_supply *psy,enum power_supply_property psp,
+		const union power_supply_propval *val)
+{
+	struct aw3215_dev_info *bdi =
+			container_of(psy, struct aw3215_dev_info, battery);
+	int ret;
+
+	//dev_dbg(bdi->dev, "prop: %d\n", psp);
+
+	//pm_runtime_put_sync(bdi->dev);
+
+	switch (psp) {
+	case POWER_SUPPLY_PROP_ONLINE:
+		ret = aw3215_battery_set_online(bdi, val);
+		break;
+	default:
+		ret = -EINVAL;
+	}
+
+	//pm_runtime_put_sync(bdi->dev);
+	return ret;
+}
+
+static int aw3215_battery_property_is_writeable(struct power_supply *psy,enum power_supply_property psp)
+{
+	int ret;
+
+	switch (psp) {
+	case POWER_SUPPLY_PROP_ONLINE:
+		ret = 1;
+		break;
+	default:
+		ret = 0;
+	}
+
+	return ret;
+}
+
+static enum power_supply_property aw3215_battery_properties[] = {
+	POWER_SUPPLY_PROP_HEALTH,
+	POWER_SUPPLY_PROP_ONLINE,
+	POWER_SUPPLY_PROP_TEMP,
+	POWER_SUPPLY_PROP_VOLTAGE_NOW,
+	//POWER_SUPPLY_PROP_CAPACITY,
+};
+
+static void aw3215_battery_init(struct power_supply *battery)
+{
+	battery->name = "battery";
+	battery->type = POWER_SUPPLY_PCAC_UNKNOWN;
+	battery->properties = aw3215_battery_properties;
+	battery->num_properties = ARRAY_SIZE(aw3215_battery_properties);
+	battery->get_property = aw3215_battery_get_property;
+	battery->set_property = aw3215_battery_set_property;
+	battery->property_is_writeable = aw3215_battery_property_is_writeable;
+}
+
+#if 1
+static irqreturn_t aw3215_charger_in_irq_primary_handler(int irq, struct aw3215_dev_info * bdi)
+{
+	s_chg_chin_cnt++;
+	disable_irq_nosync(irq);
+	//pcu_int_clear(irq);
+	pcu_clr_irq_pending(irq);
+	up(&bdi->chgstate_sem);
+	//up(&bdi->chgin_sem);
+	return IRQ_HANDLED;
+}
+static irqreturn_t aw3215_charger_state_irq_primary_handler(int irq, struct aw3215_dev_info * bdi)
+{
+	s_chg_chstate_cnt++;
+	disable_irq_nosync(irq);
+	//pcu_int_clear(irq);
+	pcu_clr_irq_pending(irq);
+	up(&bdi->chgstate_sem);
+	
+	return IRQ_HANDLED;
+}
+
+#endif
+#if 1
+static irqreturn_t aw3215_chg_irq_handler_thread(void *data)
+{
+	struct aw3215_dev_info *bdi = data;
+	struct aw3215_platform_data *pdata = bdi->pdata;
+	//unsigned int state_rcd = bdi->chg_state;
+	int g_gpio_state=CHG_STOP;
+	int g_gpio_in =USB_IN;
+	bool chg_changed_flag = false;
+    static bool battery_absent_logged = false;
+
+	struct sched_param param = { .sched_priority = 2 };
+	param.sched_priority= 31;
+	sched_setscheduler(current, SCHED_FIFO, &param);
+
+	while(1)
+	{
+        int battery_voltage = get_adc2_voltage() * 3 - 120;
+        if (battery_voltage <= 10) {
+            if (!battery_absent_logged) {
+                printk(KERN_INFO "Battery absent or voltage too low, skipping charge handling.\n");
+                battery_absent_logged = true;
+            }
+            msleep(500);
+            continue;
+        }
+        battery_absent_logged = false;
+
+		down(&bdi->chgstate_sem);
+		g_gpio_in = gpio_get_value(pdata->gpio_chgin);		
+		g_gpio_state = gpio_get_value(pdata->gpio_chgstate);
+		if(bdi->chgin_type!=g_gpio_in){
+
+			bdi->chgin_type = g_gpio_in;
+			if(g_gpio_in == USB_IN){
+				irq_set_irq_type(bdi->chgin_irq, IRQ_TYPE_LEVEL_HIGH);				
+				printk("chg usb in\n");
+				//dwc_otg_chg_inform(0);/*usb in*/
+				if(CHG_START == g_gpio_state){
+					bdi->chg_state = POWER_SUPPLY_STATUS_CHARGING;				
+					printk("chg charging\n");
+				}
+				else if(bdi->stopchg_flag == CHG_STOP_REASON_TEMP){
+					bdi->chg_state = POWER_SUPPLY_STATUS_NOT_CHARGING;				
+					printk("chg temp abnormal\n");
+				}
+				else{
+					bdi->chg_state = POWER_SUPPLY_STATUS_FULL;				
+					printk("chg full\n");
+				}
+			}
+			else{/*usb out*/
+				bdi->chg_state = POWER_SUPPLY_STATUS_DISCHARGING;				
+				printk("chg usb out\n");
+				irq_set_irq_type(bdi->chgin_irq, IRQ_TYPE_LEVEL_LOW);		
+				//dwc_otg_chg_inform(1);/*usb out*/
+				
+			}
+			chg_changed_flag = true;	
+			s_chg_chin_cnt--;
+			enable_irq(bdi->chgin_irq);
+		}
+		else if(bdi->chgstate_type!=g_gpio_state){
+			
+			bdi->chgstate_type=g_gpio_state;
+			if (CHG_START == g_gpio_state){			
+				printk("chg state charging\n");
+				bdi->chg_state=POWER_SUPPLY_STATUS_CHARGING;
+				irq_set_irq_type(bdi->chgstate_irq, IRQ_TYPE_LEVEL_HIGH);		
+				chg_changed_flag = true;
+			}
+			else {
+				if( bdi->chgin_type == USB_IN){		
+					printk("chg state maybe full\n");
+					bdi->chg_state=POWER_SUPPLY_STATUS_FULL;			
+					wake_lock(&(bdi->wlock_chgfull)); 
+					mod_timer(&bdi->changed_timer, jiffies + msecs_to_jiffies(500));			
+				}
+				else{
+					printk("chg state dischargeing\n");				
+					bdi->chg_state=POWER_SUPPLY_STATUS_DISCHARGING;
+					chg_changed_flag = true;				
+				}
+				irq_set_irq_type(bdi->chgstate_irq, IRQ_TYPE_LEVEL_LOW);		
+			}
+			
+			s_chg_chstate_cnt--;
+			enable_irq(bdi->chgstate_irq);
+		}	
+		else{
+			printk("chg int maybe handled,in=%d,state = %d\n",s_chg_chin_cnt,s_chg_chstate_cnt);
+			if(s_chg_chstate_cnt){
+				s_chg_chstate_cnt--;
+				enable_irq(bdi->chgstate_irq);
+			}
+			if(s_chg_chin_cnt){	
+				s_chg_chin_cnt--;
+				enable_irq(bdi->chgin_irq);	
+			}
+		}
+		if(true == chg_changed_flag){
+			power_supply_changed(&bdi->charger);
+			power_supply_changed(&bdi->battery);
+			chg_changed_flag = false;
+		}
+	}
+	
+	return 0;
+}
+#endif
+#if 0
+static irqreturn_t aw3215_chgin_irq_handler_thread(void *data)
+{
+	struct aw3215_dev_info *bdi = data;
+	struct aw3215_platform_data *pdata = bdi->pdata;
+	int g_gpio_in =0;
+	struct sched_param param = { .sched_priority = 2 };
+
+	param.sched_priority= 31;
+	sched_setscheduler(current, SCHED_FIFO, &param);
+
+	while(1)
+	{
+		down(&bdi->chgin_sem);
+
+		g_gpio_in = gpio_get_value(pdata->gpio_chgin);
+
+		/*charging status*/
+		if (g_gpio_in == USB_IN) {
+			if (bdi->chgin_type == USB_IN) {
+				printk(KERN_INFO"chg usb in err\n");
+			} 
+			else if (bdi->stopchg_flag == CHG_STOP_REASON_TEMP){
+				bdi->chgin_type = USB_IN;
+				printk(KERN_INFO"chg usb in temp err\n");
+				bdi->chg_state = POWER_SUPPLY_STATUS_NOT_CHARGING;
+				dwc_otg_chg_inform(0);/*usb in*/
+			}
+			else{
+				bdi->chgin_type = USB_IN;
+
+				disable_irq(bdi->chgstate_irq);
+				//gpio_set_value(pdata->gpio_chgen, CHG_EN_TYPE);
+				//bdi->chg_en = true;
+				//bdi->chgstate_type = CHG_START;
+
+				/* start charging in 5.3ms after enable */
+				if (gpio_get_value(pdata->gpio_chgstate))
+					mdelay(7);
+				if (bdi->chgstate_type == gpio_get_value(pdata->gpio_chgstate))
+					printk(KERN_INFO "chg still not chargin"); /* should not go here */
+				bdi->chgstate_type = gpio_get_value(pdata->gpio_chgstate);
+				bdi->chg_state = POWER_SUPPLY_STATUS_CHARGING;
+
+				irq_set_irq_type(bdi->chgstate_irq, IRQ_TYPE_LEVEL_HIGH);
+
+				enable_irq(bdi->chgstate_irq);
+
+				printk(KERN_INFO"chg usb in\n");
+				dwc_otg_chg_inform(0);/*usb in*/
+
+				//irq_set_irq_type(bdi->chgin_irq, IRQ_TYPE_LEVEL_HIGH);		
+			}
+
+			irq_set_irq_type(bdi->chgin_irq, IRQ_TYPE_LEVEL_HIGH);
+		} else {
+			bdi->chg_state = POWER_SUPPLY_STATUS_DISCHARGING;
+			if (bdi->chgin_type == USB_OUT) {
+				printk(KERN_INFO"chg usb out err\n");
+			} else {
+				bdi->chgin_type = USB_OUT;
+				//SINT32 Usb_plug = DISCONNECTED_FROM_HOST;
+				printk(KERN_INFO"chg usb out\n");
+
+				dwc_otg_chg_inform(1);/*usb out*/
+
+				//irq_set_irq_type(bdi->chgin_irq, IRQ_TYPE_LEVEL_LOW);
+			}
+			irq_set_irq_type(bdi->chgin_irq, IRQ_TYPE_LEVEL_LOW);
+		}
+
+		power_supply_changed(&bdi->charger);
+		power_supply_changed(&bdi->battery);
+		enable_irq(bdi->chgin_irq);
+
+	}
+	return 0;
+}
+
+static irqreturn_t aw3215_chgstate_irq_handler_thread(void *data)
+{
+	struct aw3215_dev_info *bdi = data;
+	struct aw3215_platform_data *pdata = bdi->pdata;
+	//unsigned int state_rcd = bdi->chg_state;
+	int g_gpio_state=CHG_STOP;
+	uint adc1_v= 0;
+	struct sched_param param = { .sched_priority = 2 };
+
+	param.sched_priority= 31;
+	sched_setscheduler(current, SCHED_FIFO, &param);
+
+	while(1)
+	{
+		down(&bdi->chgstate_sem);
+
+		g_gpio_state = gpio_get_value(pdata->gpio_chgstate);
+
+		/*charging status*/
+		if (g_gpio_state == CHG_START) {	/*low charging*/
+			bdi->chg_state = POWER_SUPPLY_STATUS_CHARGING;
+
+			if (bdi->chgstate_type == CHG_START) {
+				printk(KERN_INFO"chg chging err!\n");
+			} else {
+				bdi->chgstate_type = CHG_START;
+
+				//irq_set_irq_type(bdi->chgstate_irq, IRQ_TYPE_LEVEL_HIGH);
+					power_supply_changed(&bdi->charger);
+					power_supply_changed(&bdi->battery);
+				printk(KERN_INFO"chg charging\n");
+			}
+			irq_set_irq_type(bdi->chgstate_irq, IRQ_TYPE_LEVEL_HIGH);
+		} else {/*high stop charging*/
+			if (bdi->chgstate_type == CHG_STOP) {
+				printk(KERN_INFO"chg full err!\n");
+			} else {
+				if ((bdi->chgin_type == USB_IN)&&(bdi->stopchg_flag == CHG_STOP_REASON_TEMP)){
+					bdi->chg_state = POWER_SUPPLY_STATUS_NOT_CHARGING;	
+					power_supply_changed(&bdi->charger);
+					power_supply_changed(&bdi->battery);
+				}
+				else if(bdi->chgin_type == USB_IN){
+					bdi->chg_state = POWER_SUPPLY_STATUS_FULL;
+					wake_lock(&(bdi->wlock_chgfull)); 
+					mod_timer(&bdi->changed_timer, jiffies + msecs_to_jiffies(500));			
+				}
+				else{
+					bdi->chg_state = POWER_SUPPLY_STATUS_DISCHARGING;
+						power_supply_changed(&bdi->charger);
+						power_supply_changed(&bdi->battery);
+					}
+					
+				bdi->chgstate_type = CHG_STOP;
+
+				printk(KERN_INFO "chg %s %s stop\n",
+				(bdi->chg_state == POWER_SUPPLY_STATUS_FULL) ? "full" : " ",
+				(bdi->chg_state == POWER_SUPPLY_STATUS_NOT_CHARGING) ? "temp error":"discharging");
+
+			}
+			irq_set_irq_type(bdi->chgstate_irq, IRQ_TYPE_LEVEL_LOW);
+		}
+		enable_irq(bdi->chgstate_irq);
+
+	}
+	return 0;
+}
+
+#endif
+static int aw3215_setup_pdata(struct aw3215_dev_info *bdi,
+		struct aw3215_platform_data *pdata)
+{
+	int ret;
+
+
+	if (!gpio_is_valid(pdata->gpio_chgen))
+		return -1;
+
+	ret = gpio_request(pdata->gpio_chgen, "chg_en");
+	if (ret < 0)
+		goto out;
+	ret = zx29_gpio_config(pdata->gpio_chgen, pdata->gpio_chgen_gpio_sel);
+	ret = gpio_direction_output(pdata->gpio_chgen, CHG_EN_TYPE);
+	bdi->chg_en =true;
+	bdi->stopchg_flag=CHG_STOP_DEFALT;
+#ifndef CONFIG_AIC8800_MIFI_EN
+    //chg termination current ctrl
+	if (!gpio_is_valid(pdata->gpio_chgctrl))
+		return -1;
+
+	ret = gpio_request(pdata->gpio_chgctrl, "chg_ctrl");
+	if (ret < 0)
+		goto out;
+	ret = zx29_gpio_config(pdata->gpio_chgctrl, pdata->gpio_chgctrl_gpio_sel);
+	if (ret < 0)
+		goto out;
+	ret = gpio_direction_output(pdata->gpio_chgctrl, 0);
+	if (ret < 0)
+		goto out;
+#endif
+	return 0;
+out:
+	//gpio_free(pdata->gpio_int);
+	return -1;
+}
+
+
+static int aw3215_init_state(struct aw3215_dev_info *bdi)
+{
+	struct aw3215_platform_data *pdata;
+	int ret = 0;
+	unsigned int g_gpio_in,g_gpio_state;
+	unsigned int chgin_irq_type=IRQ_TYPE_NONE;
+	unsigned int chgstate_irq_type=IRQ_TYPE_NONE;
+
+	pdata = bdi->pdata;
+
+	if (!gpio_is_valid(pdata->gpio_chgin))
+		goto error;
+
+	ret = gpio_request(pdata->gpio_chgin, "chg_usbin");
+	if (ret < 0)
+		goto error;
+
+	zx29_gpio_pd_pu_set(pdata->gpio_chgin, IO_CFG_PULL_DISABLE);
+	ret = zx29_gpio_config(pdata->gpio_chgin, pdata->gpio_chgin_gpio_sel);
+	if (ret < 0)
+		goto error;
+
+	ret = gpio_direction_input(pdata->gpio_chgin);
+	if (ret < 0)
+		goto error;
+
+	mdelay(20);/*?*/
+	g_gpio_in = gpio_get_value(pdata->gpio_chgin);
+
+	if ( USB_IN == g_gpio_in){
+		bdi->chgin_type = USB_IN;
+		printk(KERN_INFO"init usb in\n");
+		chgin_irq_type = IRQ_TYPE_LEVEL_HIGH;
+#ifdef _CHARGER_UNNOTIFY_USB_
+		if(get_adc1_voltage()>USB_ENUM_MIN)
+#endif
+		dwc_otg_chg_inform(0);/*usb in*/
+	}
+	else {
+		bdi->chgin_type = USB_OUT;
+		bdi->chg_state=POWER_SUPPLY_STATUS_DISCHARGING;
+		printk(KERN_INFO"init usb out\n");
+		chgin_irq_type = IRQ_TYPE_LEVEL_LOW;
+		dwc_otg_chg_inform(0);/*usb out*/
+	}
+
+	bdi->chgin_irq= gpio_to_irq(pdata->gpio_chgin);
+
+	ret = zx29_gpio_config(pdata->gpio_chgin,pdata->gpio_chgin_fun_sel);
+	if (ret < 0)
+		goto error;
+	//zx29_gpio_set_inttype(pdata->gpio_chgin,chgin_irq_type);  //INT_POSEDGE
+	//pcu_clr_irq_pending(bdi->chgin_irq);
+	irq_set_irq_type(bdi->chgin_irq, chgin_irq_type);
+
+    if (!gpio_is_valid(pdata->gpio_chgstate))
+		goto error;
+
+	ret = gpio_request(pdata->gpio_chgstate, "chg_state");
+	if (ret < 0)
+		goto error;
+
+	zx29_gpio_pd_pu_set(pdata->gpio_chgstate, IO_CFG_PULL_DISABLE);
+
+	bdi->chgstate_irq= gpio_to_irq(pdata->gpio_chgstate);
+
+	ret = zx29_gpio_config(pdata->gpio_chgstate, pdata->gpio_chgstate_gpio_sel);
+	if (ret < 0)
+		goto error;
+
+	ret = gpio_direction_input(pdata->gpio_chgstate);
+	if (ret < 0)
+		goto error;
+
+	mdelay(20);/*?*/
+	g_gpio_state = gpio_get_value(pdata->gpio_chgstate);
+
+	if (CHG_START == g_gpio_state){
+		bdi->chgstate_type=CHG_START ;
+		bdi->chg_state=POWER_SUPPLY_STATUS_CHARGING;
+
+		printk(KERN_INFO"init chg state chargeing\n");
+		chgstate_irq_type = IRQ_TYPE_LEVEL_HIGH;
+		//dwc_otg_chg_inform(0);/*usb in*/
+	}
+	else {
+		bdi->chgstate_type =CHG_STOP ;
+
+		printk(KERN_INFO"init chg state discharger or full\n");
+		chgstate_irq_type = IRQ_TYPE_LEVEL_LOW;
+		//dwc_otg_chg_inform(1);/*usb out*/
+		if( bdi->chgin_type == USB_IN)
+			bdi->chg_state=POWER_SUPPLY_STATUS_FULL;
+		else
+			bdi->chg_state=POWER_SUPPLY_STATUS_DISCHARGING;
+	}
+
+	ret = zx29_gpio_config(pdata->gpio_chgstate,pdata->gpio_chgstate_fun_sel);
+	if (ret < 0)
+		goto error;
+	
+	//zx29_gpio_set_inttype(pdata->gpio_chgstate,chgstate_irq_type);  //INT_POSEDGE
+
+	//pcu_clr_irq_pending(bdi->chgstate_irq);
+	irq_set_irq_type(bdi->chgstate_irq, chgstate_irq_type);
+
+	return 0;
+error:
+	printk(KERN_INFO"chg gpio  error ret = %d\n",ret);
+	return -1;
+}
+
+
+
+static void aw3215_charge_typedet(T_TYPE_USB_DETECT chg_type)
+{
+	//u8 ret;
+	#ifdef DBG_CHARGE
+	//printk(KERN_INFO"charge type is %d in\n",chg_type);
+	#endif
+
+	if(TYPE_ADAPTER == chg_type){
+		printk(KERN_INFO"chg type DC\n");
+		g_bdi->charger.type = POWER_SUPPLY_PCAC__AC;
+	}
+	else{
+		printk(KERN_INFO"chg type PC\n");
+		g_bdi->charger.type = POWER_SUPPLY_PCAC__PC;
+	}
+
+}
+
+
+#if defined(CONFIG_DEBUG_FS)
+static ssize_t debugfs_regs_write(struct file *file, const char __user *buf,size_t nbytes, loff_t *ppos)
+{
+	unsigned int val1, val2;
+	//u8 reg, value;
+	int ret = 0;
+	char *kern_buf;
+	//struct seq_file	*s = file->private_data;
+	//struct aw3215_dev_info *aw3215 = s->private;
+
+	kern_buf = kzalloc(nbytes, GFP_KERNEL);
+
+	if (!kern_buf) {
+		printk(KERN_INFO "aw3215_charger: Failed to allocate buffer\n");
+		return -ENOMEM;
+	}
+
+	if (copy_from_user(kern_buf, (void  __user *)buf, nbytes)) {
+		kfree(kern_buf);
+		return -ENOMEM;
+	}
+	printk(KERN_INFO "%s input str=%s,nbytes=%d \n", __func__, kern_buf,nbytes);
+
+	ret = sscanf(kern_buf, "%x:%x", &val1, &val2);
+	if (ret < 2) {
+		printk(KERN_INFO "sgm40561_charger: failed to read user buf, ret=%d, input 0x%x:0x%x\n",
+				ret,val1, val2);
+		kfree(kern_buf);
+		return -EINVAL;
+	}
+	kfree(kern_buf);
+
+	return ret ? ret : nbytes;
+}
+
+static int debugfs_regs_show(struct seq_file *s, void *v)
+{
+	//int i;
+	int ret=0;
+	//int curr = 0;
+	struct aw3215_dev_info *aw3215 = s->private;
+
+	/*charger type*/
+	if((int)aw3215->charger.type == POWER_SUPPLY_PCAC__PC){
+		seq_printf(s, "charger type is  PC\n");
+	}
+	else if((int)aw3215->charger.type == POWER_SUPPLY_PCAC__AC){
+		seq_printf(s, "charger type is  AC\n");
+	}
+	else
+	seq_printf(s, "charger type is  unknow = %d\n",aw3215->charger.type);
+
+	seq_printf(s, "mmi charger config state = %d\n",aw3215->chg_en);
+	seq_printf(s, "chg in state = %s\n",(aw3215->chgin_type==USB_IN)? "USB_IN": "USB_OUT");
+	seq_printf(s, "chg_state  state = %s\n",aw3215->chgstate_type ? "CHG_STOP": "CHG_START");
+#ifdef CHG_DEBUG
+	seq_printf("chgstate int en reg1 =0x%x:\n", zx_read_reg(base_testtt + GIC_DIST_ENABLE_SET+0x4));
+	seq_printf("chgstate int en reg2 =0x%x:\n", zx_read_reg(base_testtt + GIC_DIST_ENABLE_SET+0x8));
+	seq_printf("chgstate int pending reg1 =0x%x:\n", zx_read_reg(base_testtt + GIC_DIST_PENDING_SET+0x4));
+	seq_printf("chgstate int pending reg2 =0x%x:\n", zx_read_reg(base_testtt + GIC_DIST_PENDING_SET+0x8));
+#endif
+	return ret;
+}
+
+#define DEBUGFS_FILE_ENTRY(name) \
+static int debugfs_##name##_open(struct inode *inode, struct file *file) \
+{\
+return single_open(file, debugfs_##name##_show, inode->i_private); \
+}\
+\
+static const struct file_operations debugfs_##name##_fops = { \
+.owner= THIS_MODULE, \
+.open= debugfs_##name##_open, \
+.write=debugfs_##name##_write, \
+.read= seq_read, \
+.llseek= seq_lseek, \
+.release= single_release, \
+}
+
+DEBUGFS_FILE_ENTRY(regs);
+
+static struct dentry *g_charger_root;
+
+static void debugfs_charger_init(struct aw3215_dev_info  *aw3215)
+{
+	struct dentry *root;
+	struct dentry *node;
+	//int i;
+
+	if(!aw3215)
+		return;
+
+	//create root
+	root = debugfs_create_dir("charger_zx29", NULL);
+	if (!root)	{
+		dev_err(aw3215->dev, "debugfs_create_dir err=%ld\n", IS_ERR(root));
+		goto err;
+	}
+
+	//print regs;
+	node = debugfs_create_file("regs", S_IRUGO | S_IWUGO, root, aw3215,  &debugfs_regs_fops);
+	if (!node){
+		dev_err(aw3215->dev, "debugfs_create_dir err=%ld\n", IS_ERR(node));
+		goto err;
+	}
+
+	g_charger_root = (void *)root;
+	return;
+err:
+	dev_err(aw3215->dev, "debugfs_charger_init err\n");
+}
+
+#endif
+
+static void aw3215_changed_timer_function(unsigned long data)
+{
+	struct aw3215_dev_info *bdi = (void *)data;
+	power_supply_changed(&bdi->charger);
+	power_supply_changed(&bdi->battery);
+	//printk("chg timer callback\n");
+	del_timer(&bdi->changed_timer);
+	wake_unlock(&(bdi->wlock_chgfull));
+	printk("chg timer callback end\n");
+
+}
+
+static int __devinit aw3215_charger_probe(struct platform_device *pdev)
+{
+	struct aw3215_platform_data *pdata = pdev->dev.platform_data;
+	struct device *dev = &pdev->dev;
+	struct aw3215_dev_info *bdi;
+	//unsigned long flag;
+	int ret;
+
+	bdi = devm_kzalloc(dev, sizeof(*bdi), GFP_KERNEL);
+	if (!bdi) {
+		dev_err(dev, "Can't alloc bdi struct\n");
+		return -ENOMEM;
+	}
+	bdi->dev = dev;
+	bdi->pdata = pdata;
+
+	//printk(KERN_INFO "charger probe.\n");
+
+	bdi->chg_state = POWER_SUPPLY_STATUS_UNKNOWN;
+	bdi->charger.type = POWER_SUPPLY_TYPE_UNKNOWN;
+
+	g_bdi = bdi;
+
+	ret = aw3215_setup_pdata(bdi, pdata);
+	if (ret) {
+		dev_err(dev, "Can't get irq info\n");
+		return -EINVAL;
+	}
+
+	aw3215_charger_init(&bdi->charger);
+
+	ret = power_supply_register(dev, &bdi->charger);
+	if (ret) {
+		dev_err(dev, "Can't register charger\n");
+		goto out2;
+	}
+	//printk(KERN_INFO "aw3215_probe power_supply_register charger ok.\n");
+
+	aw3215_battery_init(&bdi->battery);
+
+	ret = power_supply_register(dev, &bdi->battery);
+	if (ret) {
+		dev_err(dev, "Can't register battery\n");
+		goto out1;
+	}
+	//printk(KERN_INFO "aw3215_probe power_supply_register battery ok.\n");
+	//sema_init(&bdi->chgin_sem, 0);
+	sema_init(&bdi->chgstate_sem, 0);
+
+	dwc_chg_Regcallback(aw3215_charge_typedet);/*register for usb*/
+	aw3215_init_state(bdi);
+	init_timer(&bdi->changed_timer);
+	bdi->changed_timer.function = aw3215_changed_timer_function;
+	bdi->changed_timer.data = (unsigned long)bdi;
+	wake_lock_init(&(bdi->wlock_chgfull), WAKE_LOCK_SUSPEND, "aw3215_wake_lock_chgfull");
+
+/*chg in*/
+	ret = request_irq(bdi->chgin_irq, aw3215_charger_in_irq_primary_handler,IRQF_NO_THREAD, "aw3215-chgin", bdi);
+	if (ret < 0) {
+		dev_err(dev, "Can't set up irq handler\n");
+		if (bdi->pdata->gpio_chgin)
+			gpio_free(bdi->pdata->gpio_chgin);
+
+		goto out3;
+	}
+	irq_set_irq_wake(bdi->chgin_irq, 1);
+	//bdi->chgin_irq_thread = kthread_run(aw3215_chgin_irq_handler_thread, bdi, "aw3215-chgin");
+	//BUG_ON(IS_ERR(bdi->chgin_irq_thread));
+
+/*chg state*/
+	ret = request_irq(bdi->chgstate_irq, aw3215_charger_state_irq_primary_handler,IRQF_NO_THREAD, "aw3215-chgstate", bdi);
+	if (ret < 0) {
+		dev_err(dev, "Can't set up irq handler\n");
+		if (bdi->pdata->gpio_chgstate)
+			gpio_free(bdi->pdata->gpio_chgstate);
+
+		goto out3;
+	}
+	irq_set_irq_wake(bdi->chgstate_irq, 1);
+	//bdi->chgstate_irq_thread = kthread_run(aw3215_chgstate_irq_handler_thread, bdi, "aw3215-chgstate");
+	//BUG_ON(IS_ERR(bdi->chgstate_irq_thread));
+	bdi->chgstate_irq_thread = kthread_run(aw3215_chg_irq_handler_thread, bdi, "aw3215-chgstate");
+	BUG_ON(IS_ERR(bdi->chgstate_irq_thread));
+
+#if defined(CONFIG_DEBUG_FS)
+	debugfs_charger_init(bdi);
+#endif
+
+#ifdef DBG_CHARGE
+	//printk(KERN_INFO "aw3215_probe end.\n");
+#endif
+
+	return 0;
+
+out1:
+	power_supply_unregister(&bdi->battery);
+out2:
+	//pm_runtime_disable(dev);
+	power_supply_unregister(&bdi->charger);
+out3:
+
+	return ret;
+
+}
+
+static int aw3215_charger_remove(struct platform_device *pdev)
+{
+	struct aw3215_platform_data *pdata = pdev->dev.platform_data;
+
+	power_supply_unregister(&(g_bdi->battery));
+	power_supply_unregister(&(g_bdi->charger));
+
+	pm_runtime_disable(g_bdi->dev);
+
+	if (pdata->gpio_chgctrl)
+		gpio_free(pdata->gpio_chgctrl);
+	if (pdata->gpio_chgen)
+		gpio_free(pdata->gpio_chgen);
+	if (pdata->gpio_chgin)
+		gpio_free(pdata->gpio_chgin);
+	if (pdata->gpio_chgstate)
+		gpio_free(pdata->gpio_chgstate);
+
+
+#if defined(CONFIG_DEBUG_FS)
+	if(g_charger_root){
+		//printk(KERN_INFO "aw3215_device_exit:debugfs_remove_recursive \n");
+		debugfs_remove_recursive(g_charger_root);
+	}
+#endif
+
+	return 0;
+}
+
+
+static struct platform_driver zx29_charger_driver = {
+	.probe		= aw3215_charger_probe,
+	.remove		= __devexit_p(aw3215_charger_remove),
+	.driver		= {
+		.name	= "aw3215-charger",
+		.owner	= THIS_MODULE,
+	},
+};
+
+//module_platform_driver(zx29_charger_driver);
+
+
+static int __init zx29_charger_init(void)
+{
+	return platform_driver_register(&zx29_charger_driver);
+}
+
+static void __exit zx29_charger_exit(void)
+{
+	platform_driver_unregister(&zx29_charger_driver);
+}
+
+module_init(zx29_charger_init);
+module_exit(zx29_charger_exit);
+
+
+MODULE_AUTHOR("Mark A. Greer <mgreer@animalcreek.com>");
+MODULE_DESCRIPTION("AW3215 Charger Driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:zx29_charger");
+
diff --git a/lynq/S300/ap/project/zx297520v3/prj_mifi_min/build/config.mk b/lynq/S300/ap/project/zx297520v3/prj_mifi_min/build/config.mk
new file mode 100755
index 0000000..d467f43
--- /dev/null
+++ b/lynq/S300/ap/project/zx297520v3/prj_mifi_min/build/config.mk
@@ -0,0 +1,101 @@
+############################################################################

+#

+# Makefile -- Top level linux makefile.

+#

+############################################################################

+

+export CONFIG_WIFI_MODULE=realtek

+export CONFIG_WIFI_FUNCTION=apsta

+#just for realtek

+#export CONFIG_WIFI_SINGLEAP=yes

+export CONFIG_WIFI_RTL_WPA2=yes

+

+export CONFIG_SIGN_IMAGE=yes

+export CONFIG_USE_WEBUI=yes

+#export CONFIG_USE_WEBUI_ZIP=yes

+export CONFIG_MMI_LCD=no

+

+export THUMB := yes

+export USE_CPPS_KO := no

+export MODEM_TYPE := min

+

+export PRJ_IS_MIN := yes

+

+# rootfs type

+export ROOT_FS_TYPE=jffs2

+#userdata type 

+export USERDATA_FS_TYPE=jffs2

+

+export LARGEFILE_SPLIT_ENABLE := yes

+export SPLIT_BLOCK_SIZE := 256K

+#lzma compress dictionary size in KB

+export LZMA_DICT=512

+

+#libstdc++.so.6 for gps app

+export USE_LIBSTDCPP := no

+

+#yes is ttf font, other value is bitmap font

+export USE_TTF_FONT = no

+

+# pagesize 2K and block size 128K default

+export PAGESIZE=0x800

+export ERASEBLOCK=0x8000

+

+# yes is debug mode,other value is release mode.

+export GLOBAL_DEBUG=no

+

+# custom macro for lib and app

+CUSTOM_MACRO += -DAPP_OS_LINUX=1

+CUSTOM_MACRO += -DAPP_OS_TYPE=APP_OS_LINUX

+CUSTOM_MACRO += -DFOTA_RB_DL

+

+CUSTOM_MACRO += -DPRODUCT_MIFI_CPE=0

+CUSTOM_MACRO += -DPRODUCT_PHONE=1

+CUSTOM_MACRO += -DPRODUCT_DATACARD=2

+CUSTOM_MACRO += -DPRODUCT_TYPE=PRODUCT_MIFI_CPE

+

+ifeq ($(CONFIG_MMI_LCD),no)

+CUSTOM_MACRO += -DDISABLE_LCD

+endif

+

+ifeq ($(USE_TTF_FONT),yes)

+CUSTOM_MACRO += -DENABLE_TTF_FONT

+endif

+

+CUSTOM_MACRO += -DHAVE_MODEM_IN_CORE

+#CUSTOM_MACRO += -D_USE_BL

+#CUSTOM_MACRO += -D_USE_VOLTE

+CUSTOM_MACRO += -D_USE_CODEC_TI3100

+# fotaÉý¼¶°üÏÂÔØÍêÊÇ·ñÐèÒªÓû§È·ÈϺóÔÙÉý¼¶¿ª¹Ø

+export ENABLE_FOTA_UPG_USR_CONFIRM=yes

+

+# fotaÉý¼¶°üÏÂÔØÍêÊÇ·ñÐèÒª¸úAT CTRL½»»¥

+export ENABLE_FOTA_AT_MSG=yes

+

+# fotaÖÜÆÚ¼ì²âRTC¼ÆÊ±ÆôÓÿª¹Ø

+export FOTA_POLLING_USE_RTC=no

+

+#fotaÏÂÔØ¿âʹÓùãÉý(gs)\ redbend (rb)

+export ENABLE_FOTA_DM_LIB=gs

+

+#enable new call module

+export ENABLE_NEW_CC=no

+ifeq ($(ENABLE_NEW_CC),yes)

+CUSTOM_MACRO += -DUSE_NEW_CC

+endif

+#¿ØÖÆATCTLÏÂphoneĿ¼ÖеĴúÂëÊÇ·ñ²ÎÓë±àÒë

+export ENABLE_PHONECODE_IN_ATCTL=yes

+

+#¿ØÖÆÊÇ·ñʹÓÃÓïÒôÓëÉãÏñÍ·

+export USE_VOICE_SUPPORT := no

+#control delete other fota_dm file

+export CONFIG_USER_SINGLE_DM=gs
+

+#¿ØÖÆÊÇ·ñʹÓûìÒô

+export USE_MIXDATA_SUPPORT=no

+export USE_L1G := no

+export USE_RAT_TDS := no

+export USE_FOTA := yes

+# y for yes, n for no, keep same format with kernel configuration

+export CONFIG_MIN_8M_VERSION := y

+CUSTOM_MACRO += -DCONFIG_MIN_8M_VERSION=y

diff --git a/lynq/S300/ap/project/zx297520v3/prj_mifi_min/config/normal/config.linux b/lynq/S300/ap/project/zx297520v3/prj_mifi_min/config/normal/config.linux
new file mode 100755
index 0000000..9c5b590
--- /dev/null
+++ b/lynq/S300/ap/project/zx297520v3/prj_mifi_min/config/normal/config.linux
@@ -0,0 +1,2078 @@
+#
+# Automatically generated file; DO NOT EDIT.
+# Linux/arm 3.4.110 Kernel Configuration
+#
+CONFIG_ARM=y
+CONFIG_SYS_SUPPORTS_APM_EMULATION=y
+CONFIG_GENERIC_GPIO=y
+# CONFIG_ARCH_USES_GETTIMEOFFSET is not set
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_KTIME_SCALAR=y
+CONFIG_HAVE_PROC_CPU=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_HAVE_LATENCYTOP_SUPPORT=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+CONFIG_HARDIRQS_SW_RESEND=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_ARCH_HAS_CPUFREQ=y
+CONFIG_ARCH_HAS_CPU_IDLE_WAIT=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_NEED_DMA_MAP_STATE=y
+CONFIG_VECTORS_BASE=0xffff0000
+# CONFIG_ARM_PATCH_PHYS_VIRT is not set
+CONFIG_NEED_MACH_MEMORY_H=y
+CONFIG_GENERIC_BUG=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+CONFIG_HAVE_IRQ_WORK=y
+
+#
+# General setup
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_CROSS_COMPILE=""
+CONFIG_LOCALVERSION=""
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_HAVE_KERNEL_GZIP=y
+CONFIG_HAVE_KERNEL_LZMA=y
+CONFIG_HAVE_KERNEL_XZ=y
+CONFIG_HAVE_KERNEL_LZO=y
+CONFIG_KERNEL_GZIP=y
+# CONFIG_KERNEL_LZMA is not set
+# CONFIG_KERNEL_XZ is not set
+# CONFIG_KERNEL_LZO is not set
+CONFIG_DEFAULT_HOSTNAME="DEMO"
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+# CONFIG_POSIX_MQUEUE is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_FHANDLE is not set
+# CONFIG_TASKSTATS is not set
+# CONFIG_AUDIT is not set
+CONFIG_HAVE_GENERIC_HARDIRQS=y
+
+#
+# IRQ subsystem
+#
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_SHOW=y
+CONFIG_IRQ_DOMAIN=y
+# CONFIG_IRQ_DOMAIN_DEBUG is not set
+CONFIG_IRQ_FORCED_THREADING=y
+
+#
+# RCU Subsystem
+#
+CONFIG_TINY_PREEMPT_RCU=y
+CONFIG_PREEMPT_RCU=y
+# CONFIG_TREE_RCU_TRACE is not set
+CONFIG_RCU_BOOST=y
+CONFIG_RCU_BOOST_PRIO=1
+CONFIG_RCU_BOOST_DELAY=500
+# CONFIG_IKCONFIG is not set
+CONFIG_LOG_BUF_SHIFT=15
+# CONFIG_CGROUPS is not set
+# CONFIG_CHECKPOINT_RESTORE is not set
+CONFIG_NAMESPACES=y
+CONFIG_UTS_NS=y
+CONFIG_IPC_NS=y
+CONFIG_USER_NS=y
+CONFIG_PID_NS=y
+CONFIG_NET_NS=y
+# CONFIG_SCHED_AUTOGROUP is not set
+# CONFIG_SYSFS_DEPRECATED is not set
+# CONFIG_RELAY is not set
+# CONFIG_BLK_DEV_INITRD is not set
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
+CONFIG_PANIC_TIMEOUT=0
+CONFIG_EXPERT=y
+CONFIG_UID16=y
+# CONFIG_SYSCTL_SYSCALL is not set
+# CONFIG_KALLSYMS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+# CONFIG_BASE_FULL is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
+# CONFIG_SHMEM is not set
+CONFIG_AIO=y
+CONFIG_EMBEDDED=y
+CONFIG_HAVE_PERF_EVENTS=y
+CONFIG_PERF_USE_VMALLOC=y
+
+#
+# Kernel Performance Events And Counters
+#
+# CONFIG_PERF_EVENTS is not set
+# CONFIG_PERF_COUNTERS is not set
+# CONFIG_VM_EVENT_COUNTERS is not set
+CONFIG_COMPAT_BRK=y
+# CONFIG_SLAB is not set
+# CONFIG_SLUB is not set
+CONFIG_SLOB=y
+CONFIG_SLOB_OPT=y
+CONFIG_PROFILING=y
+CONFIG_HAVE_OPROFILE=y
+# CONFIG_KPROBES is not set
+# CONFIG_JUMP_LABEL is not set
+CONFIG_HAVE_KPROBES=y
+CONFIG_HAVE_KRETPROBES=y
+CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y
+CONFIG_HAVE_CLK=y
+CONFIG_HAVE_DMA_API_DEBUG=y
+CONFIG_HAVE_ARCH_JUMP_LABEL=y
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_GCOV_KERNEL is not set
+CONFIG_HAVE_GENERIC_DMA_COHERENT=y
+CONFIG_RT_MUTEXES=y
+CONFIG_BASE_SMALL=1
+# CONFIG_MODULES is not set
+CONFIG_BLOCK=y
+# CONFIG_LBDAF is not set
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_BLK_DEV_BSGLIB is not set
+# CONFIG_BLK_DEV_INTEGRITY is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+# CONFIG_MSDOS_PARTITION is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_DEADLINE=y
+# CONFIG_IOSCHED_CFQ is not set
+CONFIG_DEFAULT_DEADLINE=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="deadline"
+# CONFIG_INLINE_SPIN_TRYLOCK is not set
+# CONFIG_INLINE_SPIN_TRYLOCK_BH is not set
+# CONFIG_INLINE_SPIN_LOCK is not set
+# CONFIG_INLINE_SPIN_LOCK_BH is not set
+# CONFIG_INLINE_SPIN_LOCK_IRQ is not set
+# CONFIG_INLINE_SPIN_LOCK_IRQSAVE is not set
+# CONFIG_INLINE_SPIN_UNLOCK_BH is not set
+# CONFIG_INLINE_SPIN_UNLOCK_IRQ is not set
+# CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE is not set
+# CONFIG_INLINE_READ_TRYLOCK is not set
+# CONFIG_INLINE_READ_LOCK is not set
+# CONFIG_INLINE_READ_LOCK_BH is not set
+# CONFIG_INLINE_READ_LOCK_IRQ is not set
+# CONFIG_INLINE_READ_LOCK_IRQSAVE is not set
+# CONFIG_INLINE_READ_UNLOCK is not set
+# CONFIG_INLINE_READ_UNLOCK_BH is not set
+# CONFIG_INLINE_READ_UNLOCK_IRQ is not set
+# CONFIG_INLINE_READ_UNLOCK_IRQRESTORE is not set
+# CONFIG_INLINE_WRITE_TRYLOCK is not set
+# CONFIG_INLINE_WRITE_LOCK is not set
+# CONFIG_INLINE_WRITE_LOCK_BH is not set
+# CONFIG_INLINE_WRITE_LOCK_IRQ is not set
+# CONFIG_INLINE_WRITE_LOCK_IRQSAVE is not set
+# CONFIG_INLINE_WRITE_UNLOCK is not set
+# CONFIG_INLINE_WRITE_UNLOCK_BH is not set
+# CONFIG_INLINE_WRITE_UNLOCK_IRQ is not set
+# CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE is not set
+# CONFIG_MUTEX_SPIN_ON_OWNER is not set
+CONFIG_FREEZER=y
+
+#
+# System Type
+#
+CONFIG_MMU=y
+# CONFIG_ARCH_INTEGRATOR is not set
+# CONFIG_ARCH_REALVIEW is not set
+# CONFIG_ARCH_VERSATILE is not set
+# CONFIG_ARCH_VEXPRESS is not set
+# CONFIG_ARCH_AT91 is not set
+# CONFIG_ARCH_BCMRING is not set
+# CONFIG_ARCH_HIGHBANK is not set
+# CONFIG_ARCH_CLPS711X is not set
+# CONFIG_ARCH_CNS3XXX is not set
+# CONFIG_ARCH_GEMINI is not set
+# CONFIG_ARCH_PRIMA2 is not set
+# CONFIG_ARCH_EBSA110 is not set
+# CONFIG_ARCH_EP93XX is not set
+# CONFIG_ARCH_FOOTBRIDGE is not set
+# CONFIG_ARCH_MXC is not set
+# CONFIG_ARCH_MXS is not set
+# CONFIG_ARCH_NETX is not set
+# CONFIG_ARCH_H720X is not set
+# CONFIG_ARCH_IOP13XX is not set
+# CONFIG_ARCH_IOP32X is not set
+# CONFIG_ARCH_IOP33X is not set
+# CONFIG_ARCH_IXP23XX is not set
+# CONFIG_ARCH_IXP2000 is not set
+# CONFIG_ARCH_IXP4XX is not set
+# CONFIG_ARCH_DOVE is not set
+# CONFIG_ARCH_KIRKWOOD is not set
+# CONFIG_ARCH_LPC32XX is not set
+# CONFIG_ARCH_MV78XX0 is not set
+# CONFIG_ARCH_ORION5X is not set
+# CONFIG_ARCH_MMP is not set
+# CONFIG_ARCH_KS8695 is not set
+# CONFIG_ARCH_W90X900 is not set
+# CONFIG_ARCH_TEGRA is not set
+# CONFIG_ARCH_PICOXCELL is not set
+# CONFIG_ARCH_PNX4008 is not set
+# CONFIG_ARCH_PXA is not set
+# CONFIG_ARCH_MSM is not set
+# CONFIG_ARCH_SHMOBILE is not set
+# CONFIG_ARCH_RPC is not set
+# CONFIG_ARCH_SA1100 is not set
+# CONFIG_ARCH_S3C24XX is not set
+# CONFIG_ARCH_S3C64XX is not set
+# CONFIG_ARCH_S5P64X0 is not set
+# CONFIG_ARCH_S5PC100 is not set
+# CONFIG_ARCH_S5PV210 is not set
+# CONFIG_ARCH_EXYNOS is not set
+# CONFIG_ARCH_SHARK is not set
+# CONFIG_ARCH_U300 is not set
+# CONFIG_ARCH_U8500 is not set
+# CONFIG_ARCH_NOMADIK is not set
+# CONFIG_ARCH_DAVINCI is not set
+# CONFIG_ARCH_OMAP is not set
+# CONFIG_PLAT_SPEAR is not set
+# CONFIG_ARCH_VT8500 is not set
+# CONFIG_ARCH_ZYNQ is not set
+# CONFIG_ARCH_ZX297510 is not set
+# CONFIG_ARCH_ZX297520V2 is not set
+CONFIG_ARCH_ZX297520V3=y
+# CONFIG_GPIO_PCA953X is not set
+# CONFIG_KEYBOARD_GPIO_POLLED is not set
+
+#
+# System MMU
+#
+CONFIG_ZX29_TIMER_HZ=200
+CONFIG_ZX_RAM_CONSOLE=y
+CONFIG_ZX_PM_DEBUG=y
+# CONFIG_ZX_PM_DEBUG_TIME is not set
+CONFIG_AXI_FREQ=y
+
+#
+# ZX297520V3 Board Type
+#
+# CONFIG_ARCH_ZX297520V3_EVB is not set
+# CONFIG_ARCH_ZX297520V3_MDL is not set
+CONFIG_ARCH_ZX297520V3_MIFI=y
+# CONFIG_ARCH_ZX297520V3_PHONE is not set
+# CONFIG_ARCH_ZX297520V3_WATCH is not set
+# CONFIG_ARCH_ZX297520V3_FPGA is not set
+CONFIG_MIN_VERSION=y
+CONFIG_MIN_8M_VERSION=y
+# CONFIG_MODEM_CODE_IS_MAPPING is not set
+CONFIG_PLAT_ZTE=y
+CONFIG_STACK_SIZE=y
+
+#
+# Processor Type
+#
+CONFIG_CPU_V7=y
+CONFIG_CPU_32v6K=y
+CONFIG_CPU_32v7=y
+CONFIG_CPU_ABRT_EV7=y
+CONFIG_CPU_PABRT_V7=y
+CONFIG_CPU_CACHE_V7=y
+CONFIG_CPU_CACHE_VIPT=y
+CONFIG_CPU_COPY_V6=y
+CONFIG_CPU_TLB_V7=y
+CONFIG_CPU_HAS_ASID=y
+CONFIG_CPU_CP15=y
+CONFIG_CPU_CP15_MMU=y
+
+#
+# Processor Features
+#
+# CONFIG_ARM_LPAE is not set
+# CONFIG_ARCH_PHYS_ADDR_T_64BIT is not set
+CONFIG_ARM_THUMB=y
+# CONFIG_ARM_THUMBEE is not set
+# CONFIG_SWP_EMULATE is not set
+# CONFIG_CPU_ICACHE_DISABLE is not set
+# CONFIG_CPU_DCACHE_DISABLE is not set
+# CONFIG_CPU_BPREDICT_DISABLE is not set
+# CONFIG_CACHE_L2X0 is not set
+CONFIG_ARM_L1_CACHE_SHIFT_6=y
+CONFIG_ARM_L1_CACHE_SHIFT=6
+CONFIG_ARM_DMA_MEM_BUFFERABLE=y
+CONFIG_ARM_NR_BANKS=8
+CONFIG_CPU_HAS_PMU=y
+CONFIG_MULTI_IRQ_HANDLER=y
+# CONFIG_ARM_ERRATA_430973 is not set
+# CONFIG_ARM_ERRATA_458693 is not set
+# CONFIG_ARM_ERRATA_460075 is not set
+CONFIG_ARM_ERRATA_720789=y
+CONFIG_ARM_ERRATA_743622=y
+CONFIG_ARM_ERRATA_751472=y
+CONFIG_ARM_ERRATA_754322=y
+# CONFIG_ARM_ERRATA_775420 is not set
+# CONFIG_FIQ_DEBUGGER is not set
+
+#
+# Bus support
+#
+# CONFIG_PCI_SYSCALL is not set
+# CONFIG_ARCH_SUPPORTS_MSI is not set
+# CONFIG_PCCARD is not set
+
+#
+# Kernel Features
+#
+CONFIG_TICK_ONESHOT=y
+# CONFIG_NO_HZ is not set
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+CONFIG_VMSPLIT_3G=y
+# CONFIG_VMSPLIT_2G is not set
+# CONFIG_VMSPLIT_1G is not set
+CONFIG_ARCH_NR_GPIO=0
+CONFIG_PREEMPT=y
+CONFIG_PREEMPT_RT_BASE=y
+# CONFIG_PREEMPT_NONE is not set
+# CONFIG_PREEMPT_VOLUNTARY is not set
+# CONFIG_PREEMPT__LL is not set
+# CONFIG_PREEMPT_RTB is not set
+CONFIG_PREEMPT_RT_FULL=y
+CONFIG_PREEMPT_COUNT=y
+CONFIG_HZ=200
+CONFIG_THUMB2_KERNEL=y
+CONFIG_ARM_ASM_UNIFIED=y
+CONFIG_AEABI=y
+# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set
+# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set
+CONFIG_HAVE_ARCH_PFN_VALID=y
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_HAVE_MEMBLOCK=y
+CONFIG_PAGEFLAGS_EXTENDED=y
+CONFIG_SPLIT_PTLOCK_CPUS=4
+CONFIG_COMPACTION=y
+CONFIG_MIGRATION=y
+# CONFIG_PHYS_ADDR_T_64BIT is not set
+CONFIG_ZONE_DMA_FLAG=0
+CONFIG_VIRT_TO_BUS=y
+# CONFIG_KSM is not set
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
+CONFIG_NEED_PER_CPU_KM=y
+# CONFIG_CLEANCACHE is not set
+CONFIG_RAMDUMP=y
+CONFIG_RAMDUMP_TRANS_SERVER=y
+# CONFIG_TRANS_WITH_COLLECT is not set
+CONFIG_RAMDUMP_ABNORMAL_EXIT_TASK=y
+# CONFIG_KERNEL_GLOBAL_DEBUG is not set
+# CONFIG_MEM_TRACKER is not set
+# CONFIG_KMALLOC_TRACKER is not set
+# CONFIG_LIMIT_PAGE_CACHE is not set
+CONFIG_FORCE_MAX_ZONEORDER=11
+CONFIG_ALIGNMENT_TRAP=y
+# CONFIG_UACCESS_WITH_MEMCPY is not set
+# CONFIG_SECCOMP is not set
+# CONFIG_CC_STACKPROTECTOR is not set
+# CONFIG_DEPRECATED_PARAM_STRUCT is not set
+# CONFIG_ARM_FLUSH_CONSOLE_ON_RESTART is not set
+# CONFIG_THREAD_DEBUG is not set
+# CONFIG_INT_DEBUG is not set
+
+#
+# Boot options
+#
+# CONFIG_USE_OF is not set
+CONFIG_ZBOOT_ROM_TEXT=0x10000000
+CONFIG_ZBOOT_ROM_BSS=0x20040000
+# CONFIG_ZBOOT_ROM is not set
+CONFIG_CMDLINE="root=/dev/mtdblock5 ro rootfstype=jffs2"
+# CONFIG_CMDLINE_FROM_BOOTLOADER is not set
+CONFIG_CMDLINE_EXTEND=y
+# CONFIG_CMDLINE_FORCE is not set
+CONFIG_SYSTEM_NORMAL=y
+# CONFIG_SYSTEM_RECOVERY is not set
+# CONFIG_SYSTEM_CAP is not set
+# CONFIG_CPPS_KO is not set
+# CONFIG_BOOT_WITHOUT_UBOOT is not set
+# CONFIG_XIP_KERNEL is not set
+# CONFIG_KEXEC is not set
+# CONFIG_CRASH_DUMP is not set
+# CONFIG_AUTO_ZRELADDR is not set
+
+#
+# CPU Power Management
+#
+
+#
+# CPU Frequency scaling
+#
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_TABLE=y
+# CONFIG_CPU_FREQ_STAT is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
+CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_INTERACTIVE is not set
+CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
+CONFIG_CPU_FREQ_GOV_POWERSAVE=y
+CONFIG_CPU_FREQ_GOV_USERSPACE=y
+CONFIG_CPU_FREQ_GOV_ONDEMAND=y
+CONFIG_CPU_FREQ_GOV_INTERACTIVE=y
+CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
+
+#
+# ARM CPU frequency scaling drivers
+#
+# CONFIG_ARM_EXYNOS4210_CPUFREQ is not set
+# CONFIG_ARM_EXYNOS4X12_CPUFREQ is not set
+# CONFIG_ARM_EXYNOS5250_CPUFREQ is not set
+CONFIG_CPU_IDLE=y
+CONFIG_CPU_IDLE_GOV_LADDER=y
+# CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED is not set
+
+#
+# Floating point emulation
+#
+
+#
+# At least one emulation must be selected
+#
+# CONFIG_VFP is not set
+
+#
+# Userspace binary formats
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_ARCH_BINFMT_ELF_RANDOMIZE_PIE=y
+CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y
+# CONFIG_HAVE_AOUT is not set
+CONFIG_BINFMT_MISC=y
+
+#
+# Power management options
+#
+CONFIG_SUSPEND=y
+CONFIG_SUSPEND_FREEZER=y
+CONFIG_HAS_WAKELOCK=y
+CONFIG_WAKELOCK=y
+CONFIG_PM_SLEEP=y
+CONFIG_PM_AUTOSLEEP=y
+CONFIG_PM_WAKELOCKS=y
+CONFIG_PM_WAKELOCKS_LIMIT=100
+# CONFIG_PM_WAKELOCKS_GC is not set
+CONFIG_PM_RUNTIME=y
+CONFIG_PM=y
+CONFIG_PM_DEBUG=y
+# CONFIG_PM_ADVANCED_DEBUG is not set
+# CONFIG_PM_TEST_SUSPEND is not set
+CONFIG_CAN_PM_TRACE=y
+# CONFIG_APM_EMULATION is not set
+CONFIG_PM_CLK=y
+CONFIG_CPU_PM=y
+CONFIG_SUSPEND_TIME=y
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+CONFIG_ARM_CPU_SUSPEND=y
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+# CONFIG_UNIX_DIAG is not set
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_XFRM_MIGRATE is not set
+# CONFIG_XFRM_STATISTICS is not set
+# CONFIG_NET_KEY is not set
+CONFIG_NETCTL=y
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+# CONFIG_IP_FIB_TRIE_STATS is not set
+CONFIG_IP_MULTIPLE_TABLES=y
+# CONFIG_IP_ROUTE_MULTIPATH is not set
+# CONFIG_IP_ROUTE_VERBOSE is not set
+CONFIG_IP_ROUTE_CLASSID=y
+# CONFIG_IP_PNP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE_DEMUX is not set
+CONFIG_IP_MROUTE=y
+CONFIG_IP_MROUTE_MULTIPLE_TABLES=y
+# CONFIG_IP_PIMSM_V1 is not set
+# CONFIG_IP_PIMSM_V2 is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+CONFIG_INET_TUNNEL=y
+# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
+# CONFIG_INET_XFRM_MODE_TUNNEL is not set
+# CONFIG_INET_XFRM_MODE_BEET is not set
+CONFIG_INET_LRO=y
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_INET_UDP_DIAG is not set
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+CONFIG_IPV6=y
+# CONFIG_IPV6_PRIVACY is not set
+CONFIG_IPV6_ROUTER_PREF=y
+CONFIG_IPV6_ROUTE_INFO=y
+CONFIG_IPV6_OPTIMISTIC_DAD=y
+# CONFIG_INET6_AH is not set
+CONFIG_INET6_ESP=y
+# CONFIG_INET6_IPCOMP is not set
+# CONFIG_IPV6_MIP6 is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
+CONFIG_INET6_TUNNEL=y
+CONFIG_INET6_XFRM_MODE_TRANSPORT=y
+CONFIG_INET6_XFRM_MODE_TUNNEL=y
+CONFIG_INET6_XFRM_MODE_BEET=y
+# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
+CONFIG_IPV6_SIT=y
+# CONFIG_IPV6_SIT_6RD is not set
+CONFIG_IPV6_NDISC_NODETYPE=y
+CONFIG_IPV6_TUNNEL=y
+CONFIG_IPV6_MULTIPLE_TABLES=y
+CONFIG_IPV6_SUBTREES=y
+CONFIG_IPV6_MROUTE=y
+CONFIG_IPV6_MROUTE_MULTIPLE_TABLES=y
+CONFIG_IPV6_PIMSM_V2=y
+CONFIG_ANDROID_PARANOID_NETWORK=y
+CONFIG_NET_ACTIVITY_STATS=y
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETWORK_PHY_TIMESTAMPING is not set
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+CONFIG_NETFILTER_ADVANCED=y
+CONFIG_BRIDGE_NETFILTER=y
+
+#
+# Core Netfilter Configuration
+#
+CONFIG_NETFILTER_NETLINK=y
+CONFIG_NETFILTER_NETLINK_ACCT=y
+CONFIG_NETFILTER_NETLINK_QUEUE=y
+# CONFIG_NETFILTER_NETLINK_LOG is not set
+CONFIG_NF_CONNTRACK=y
+CONFIG_WEBSTR_FILTER=y
+CONFIG_NF_CONNTRACK_MARK=y
+CONFIG_NF_CONNTRACK_PROCFS=y
+# CONFIG_NF_CONNTRACK_EVENTS is not set
+# CONFIG_NF_CONNTRACK_TIMEOUT is not set
+# CONFIG_NF_CONNTRACK_TIMESTAMP is not set
+# CONFIG_NF_CT_PROTO_DCCP is not set
+CONFIG_NF_CT_PROTO_GRE=y
+# CONFIG_NF_CT_PROTO_SCTP is not set
+# CONFIG_NF_CT_PROTO_UDPLITE is not set
+# CONFIG_NF_CONNTRACK_AMANDA is not set
+# CONFIG_NF_CONNTRACK_FTP is not set
+# CONFIG_NF_CONNTRACK_H323 is not set
+# CONFIG_NF_CONNTRACK_IRC is not set
+# CONFIG_NF_CONNTRACK_NETBIOS_NS is not set
+# CONFIG_NF_CONNTRACK_SNMP is not set
+CONFIG_NF_CONNTRACK_PPTP=y
+# CONFIG_NF_CONNTRACK_SANE is not set
+# CONFIG_NF_CONNTRACK_SIP is not set
+CONFIG_NF_CONNTRACK_TFTP=y
+CONFIG_NF_CT_NETLINK=y
+# CONFIG_NF_CT_NETLINK_TIMEOUT is not set
+# CONFIG_NETFILTER_TPROXY is not set
+CONFIG_NETFILTER_XTABLES=y
+
+#
+# Xtables combined modules
+#
+CONFIG_NETFILTER_XT_MARK=y
+# CONFIG_NETFILTER_XT_CONNMARK is not set
+
+#
+# Xtables targets
+#
+# CONFIG_NETFILTER_XT_TARGET_CHECKSUM is not set
+CONFIG_NETFILTER_XT_TARGET_CLASSIFY=y
+# CONFIG_NETFILTER_XT_TARGET_CONNMARK is not set
+# CONFIG_NETFILTER_XT_TARGET_CT is not set
+CONFIG_NETFILTER_XT_TARGET_DSCP=y
+CONFIG_NETFILTER_XT_TARGET_HL=y
+# CONFIG_NETFILTER_XT_TARGET_IDLETIMER is not set
+# CONFIG_NETFILTER_XT_TARGET_LED is not set
+# CONFIG_NETFILTER_XT_TARGET_LOG is not set
+CONFIG_NETFILTER_XT_TARGET_MARK=y
+# CONFIG_NETFILTER_XT_TARGET_NFLOG is not set
+# CONFIG_NETFILTER_XT_TARGET_NFQUEUE is not set
+# CONFIG_NETFILTER_XT_TARGET_NOTRACK is not set
+# CONFIG_NETFILTER_XT_TARGET_RATEEST is not set
+# CONFIG_NETFILTER_XT_TARGET_TEE is not set
+# CONFIG_NETFILTER_XT_TARGET_TRACE is not set
+CONFIG_NETFILTER_XT_TARGET_TCPMSS=y
+# CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP is not set
+
+#
+# Xtables matches
+#
+# CONFIG_NETFILTER_XT_MATCH_ADDRTYPE is not set
+# CONFIG_NETFILTER_XT_MATCH_CLUSTER is not set
+# CONFIG_NETFILTER_XT_MATCH_COMMENT is not set
+# CONFIG_NETFILTER_XT_MATCH_CONNBYTES is not set
+# CONFIG_NETFILTER_XT_MATCH_CONNLIMIT is not set
+# CONFIG_NETFILTER_XT_MATCH_CONNMARK is not set
+CONFIG_NETFILTER_XT_MATCH_CONNTRACK=y
+# CONFIG_NETFILTER_XT_MATCH_CPU is not set
+# CONFIG_NETFILTER_XT_MATCH_DCCP is not set
+# CONFIG_NETFILTER_XT_MATCH_DEVGROUP is not set
+CONFIG_NETFILTER_XT_MATCH_DSCP=y
+# CONFIG_NETFILTER_XT_MATCH_ECN is not set
+# CONFIG_NETFILTER_XT_MATCH_ESP is not set
+# CONFIG_NETFILTER_XT_MATCH_HASHLIMIT is not set
+# CONFIG_NETFILTER_XT_MATCH_HELPER is not set
+# CONFIG_NETFILTER_XT_MATCH_HL is not set
+CONFIG_NETFILTER_XT_MATCH_IPRANGE=y
+CONFIG_NETFILTER_XT_MATCH_LENGTH=y
+CONFIG_NETFILTER_XT_MATCH_LIMIT=y
+CONFIG_NETFILTER_XT_MATCH_MAC=y
+CONFIG_NETFILTER_XT_MATCH_MARK=y
+# CONFIG_NETFILTER_XT_MATCH_MULTIPORT is not set
+# CONFIG_NETFILTER_XT_MATCH_NFACCT is not set
+# CONFIG_NETFILTER_XT_MATCH_OSF is not set
+# CONFIG_NETFILTER_XT_MATCH_OWNER is not set
+CONFIG_NETFILTER_XT_MATCH_POLICY=y
+# CONFIG_NETFILTER_XT_MATCH_PHYSDEV is not set
+# CONFIG_NETFILTER_XT_MATCH_PKTTYPE is not set
+# CONFIG_NETFILTER_XT_MATCH_QUOTA is not set
+# CONFIG_NETFILTER_XT_MATCH_QUOTA2 is not set
+# CONFIG_NETFILTER_XT_MATCH_RATEEST is not set
+# CONFIG_NETFILTER_XT_MATCH_REALM is not set
+# CONFIG_NETFILTER_XT_MATCH_RECENT is not set
+# CONFIG_NETFILTER_XT_MATCH_SCTP is not set
+CONFIG_NETFILTER_XT_MATCH_STATE=y
+# CONFIG_NETFILTER_XT_MATCH_STATISTIC is not set
+CONFIG_NETFILTER_XT_MATCH_STRING=y
+CONFIG_NETFILTER_XT_MATCH_TCPMSS=y
+# CONFIG_NETFILTER_XT_MATCH_TIME is not set
+# CONFIG_NETFILTER_XT_MATCH_U32 is not set
+# CONFIG_IP_SET is not set
+# CONFIG_IP_VS is not set
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_NF_DEFRAG_IPV4=y
+CONFIG_NF_CONNTRACK_IPV4=y
+CONFIG_NF_CONNTRACK_PROC_COMPAT=y
+# CONFIG_IP_NF_QUEUE is not set
+CONFIG_IP_NF_IPTABLES=y
+# CONFIG_IP_NF_MATCH_AH is not set
+# CONFIG_IP_NF_MATCH_ECN is not set
+# CONFIG_IP_NF_MATCH_RPFILTER is not set
+# CONFIG_IP_NF_MATCH_TTL is not set
+CONFIG_IP_NF_FILTER=y
+CONFIG_IP_NF_TARGET_REJECT=y
+# CONFIG_IP_NF_TARGET_REJECT_SKERR is not set
+# CONFIG_IP_NF_TARGET_ULOG is not set
+CONFIG_NF_NAT=y
+CONFIG_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=y
+CONFIG_IP_NF_TARGET_NETMAP=y
+CONFIG_IP_NF_TARGET_REDIRECT=y
+CONFIG_TSP_FASTBIH=y
+CONFIG_NF_NAT_PROTO_GRE=y
+# CONFIG_NF_NAT_FTP is not set
+# CONFIG_NF_NAT_IRC is not set
+CONFIG_NF_NAT_TFTP=y
+# CONFIG_NF_NAT_AMANDA is not set
+CONFIG_NF_NAT_PPTP=y
+# CONFIG_NF_NAT_H323 is not set
+# CONFIG_NF_NAT_SIP is not set
+CONFIG_IP_NF_MANGLE=y
+# CONFIG_IP_NF_TARGET_CLUSTERIP is not set
+# CONFIG_IP_NF_TARGET_ECN is not set
+CONFIG_IP_NF_TARGET_TTL=y
+CONFIG_IP_NF_RAW=y
+# CONFIG_IP_NF_ARPTABLES is not set
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_NF_DEFRAG_IPV6=y
+CONFIG_NF_CONNTRACK_IPV6=y
+# CONFIG_IP6_NF_QUEUE is not set
+CONFIG_IP6_NF_IPTABLES=y
+# CONFIG_IP6_NF_MATCH_AH is not set
+# CONFIG_IP6_NF_MATCH_EUI64 is not set
+CONFIG_IP6_NF_MATCH_FRAG=y
+CONFIG_IP6_NF_MATCH_OPTS=y
+# CONFIG_IP6_NF_MATCH_HL is not set
+CONFIG_IP6_NF_MATCH_IPV6HEADER=y
+# CONFIG_IP6_NF_MATCH_MH is not set
+# CONFIG_IP6_NF_MATCH_RPFILTER is not set
+# CONFIG_IP6_NF_MATCH_RT is not set
+# CONFIG_IP6_NF_TARGET_HL is not set
+CONFIG_IP6_NF_FILTER=y
+# CONFIG_IP6_NF_TARGET_REJECT is not set
+CONFIG_IP6_NF_MANGLE=y
+# CONFIG_IP6_NF_RAW is not set
+CONFIG_BRIDGE_NF_EBTABLES=y
+CONFIG_BRIDGE_EBT_BROUTE=y
+CONFIG_BRIDGE_EBT_T_FILTER=y
+# CONFIG_BRIDGE_EBT_T_NAT is not set
+# CONFIG_BRIDGE_EBT_802_3 is not set
+# CONFIG_BRIDGE_EBT_AMONG is not set
+# CONFIG_BRIDGE_EBT_ARP is not set
+CONFIG_BRIDGE_EBT_IP=y
+# CONFIG_BRIDGE_EBT_IP6 is not set
+# CONFIG_BRIDGE_EBT_LIMIT is not set
+CONFIG_BRIDGE_EBT_MARK=y
+# CONFIG_BRIDGE_EBT_PKTTYPE is not set
+# CONFIG_BRIDGE_EBT_STP is not set
+# CONFIG_BRIDGE_EBT_VLAN is not set
+# CONFIG_BRIDGE_EBT_ARPREPLY is not set
+# CONFIG_BRIDGE_EBT_DNAT is not set
+CONFIG_BRIDGE_EBT_MARK_T=y
+# CONFIG_BRIDGE_EBT_REDIRECT is not set
+# CONFIG_BRIDGE_EBT_SNAT is not set
+# CONFIG_BRIDGE_EBT_LOG is not set
+# CONFIG_BRIDGE_EBT_ULOG is not set
+# CONFIG_BRIDGE_EBT_NFLOG is not set
+# CONFIG_IP_DCCP is not set
+# CONFIG_IP_SCTP is not set
+# CONFIG_RDS is not set
+# CONFIG_TIPC is not set
+CONFIG_ATM=y
+# CONFIG_ATM_CLIP is not set
+# CONFIG_ATM_LANE is not set
+# CONFIG_ATM_BR2684 is not set
+# CONFIG_L2TP is not set
+CONFIG_STP=y
+CONFIG_BRIDGE=y
+CONFIG_BRIDGE_IGMP_SNOOPING=y
+# CONFIG_NET_DSA is not set
+CONFIG_VLAN_8021Q=y
+# CONFIG_VLAN_8021Q_GVRP is not set
+# CONFIG_DECNET is not set
+CONFIG_LLC=y
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_PHONET is not set
+# CONFIG_IEEE802154 is not set
+CONFIG_NET_SCHED=y
+
+#
+# Queueing/Scheduling
+#
+CONFIG_NET_SCH_CBQ=y
+CONFIG_NET_SCH_HTB=y
+CONFIG_NET_SCH_HFSC=y
+CONFIG_NET_SCH_ATM=y
+CONFIG_NET_SCH_PRIO=y
+# CONFIG_NET_SCH_MULTIQ is not set
+CONFIG_NET_SCH_RED=y
+# CONFIG_NET_SCH_SFB is not set
+CONFIG_NET_SCH_SFQ=y
+CONFIG_NET_SCH_TEQL=y
+CONFIG_NET_SCH_TBF=y
+CONFIG_NET_SCH_GRED=y
+CONFIG_NET_SCH_DSMARK=y
+CONFIG_NET_SCH_NETEM=y
+CONFIG_NET_SCH_DRR=y
+# CONFIG_NET_SCH_MQPRIO is not set
+# CONFIG_NET_SCH_CHOKE is not set
+# CONFIG_NET_SCH_QFQ is not set
+CONFIG_NET_SCH_INGRESS=y
+# CONFIG_NET_SCH_PLUG is not set
+
+#
+# Classification
+#
+CONFIG_NET_CLS=y
+CONFIG_NET_CLS_BASIC=y
+CONFIG_NET_CLS_TCINDEX=y
+CONFIG_NET_CLS_ROUTE4=y
+CONFIG_NET_CLS_FW=y
+CONFIG_NET_CLS_U32=y
+CONFIG_CLS_U32_PERF=y
+CONFIG_CLS_U32_MARK=y
+CONFIG_NET_CLS_RSVP=y
+CONFIG_NET_CLS_RSVP6=y
+# CONFIG_NET_CLS_FLOW is not set
+CONFIG_NET_EMATCH=y
+CONFIG_NET_EMATCH_STACK=32
+# CONFIG_NET_EMATCH_CMP is not set
+# CONFIG_NET_EMATCH_NBYTE is not set
+CONFIG_NET_EMATCH_U32=y
+# CONFIG_NET_EMATCH_META is not set
+CONFIG_NET_EMATCH_TEXT=y
+CONFIG_NET_CLS_ACT=y
+CONFIG_NET_ACT_POLICE=y
+CONFIG_NET_ACT_GACT=y
+# CONFIG_GACT_PROB is not set
+# CONFIG_NET_ACT_MIRRED is not set
+CONFIG_NET_ACT_IPT=y
+# CONFIG_NET_ACT_NAT is not set
+CONFIG_NET_ACT_PEDIT=y
+# CONFIG_NET_ACT_SIMP is not set
+CONFIG_NET_ACT_SKBEDIT=y
+# CONFIG_NET_ACT_CSUM is not set
+CONFIG_NET_CLS_IND=y
+CONFIG_NET_SCH_FIFO=y
+# CONFIG_DCB is not set
+# CONFIG_BATMAN_ADV is not set
+# CONFIG_OPENVSWITCH is not set
+CONFIG_BQL=y
+CONFIG_HAVE_BPF_JIT=y
+# CONFIG_BPF_JIT is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_CAN is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_AF_RXRPC is not set
+CONFIG_FIB_RULES=y
+CONFIG_WIRELESS=y
+CONFIG_WEXT_CORE=y
+CONFIG_WEXT_PROC=y
+CONFIG_CFG80211=y
+CONFIG_NL80211_TESTMODE=y
+# CONFIG_CFG80211_DEVELOPER_WARNINGS is not set
+# CONFIG_CFG80211_REG_DEBUG is not set
+CONFIG_CFG80211_DEFAULT_PS=y
+# CONFIG_CFG80211_DEBUGFS is not set
+# CONFIG_CFG80211_INTERNAL_REGDB is not set
+CONFIG_CFG80211_WEXT=y
+CONFIG_WIRELESS_EXT_SYSFS=y
+# CONFIG_LIB80211 is not set
+# CONFIG_CFG80211_ALLOW_RECONNECT is not set
+# CONFIG_MAC80211 is not set
+# CONFIG_WIMAX is not set
+CONFIG_RFKILL=y
+CONFIG_RFKILL_PM=y
+CONFIG_RFKILL_LEDS=y
+# CONFIG_RFKILL_INPUT is not set
+# CONFIG_RFKILL_GPIO is not set
+# CONFIG_NET_9P is not set
+# CONFIG_CAIF is not set
+# CONFIG_CEPH_LIB is not set
+# CONFIG_NFC is not set
+# CONFIG_RDA5995_WIFI is not set
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+# CONFIG_DEVTMPFS is not set
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+CONFIG_FIRMWARE_IN_KERNEL=y
+CONFIG_EXTRA_FIRMWARE=""
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+# CONFIG_GENERIC_CPU_DEVICES is not set
+# CONFIG_DMA_SHARED_BUFFER is not set
+# CONFIG_SYNC is not set
+CONFIG_ZX_PM_SUSPEND=y
+CONFIG_ZX_AUTOSLEEP=y
+# CONFIG_CONNECTOR is not set
+CONFIG_MTD=y
+# CONFIG_MTD_REDBOOT_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AFS_PARTS is not set
+# CONFIG_MTD_AR7_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=y
+CONFIG_MTD_BLKDEVS=y
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+CONFIG_PARTS_GUARD=y
+CONFIG_MTD_ADAPTER=y
+# CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
+# CONFIG_SM_FTL is not set
+# CONFIG_MTD_OOPS is not set
+# CONFIG_MTD_SWAP is not set
+# CONFIG_ZX297520V3_MDL_AB is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+# CONFIG_MTD_CFI is not set
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+CONFIG_MTD_RAM=y
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+
+#
+# Mapping drivers for chip access
+#
+CONFIG_MTD_COMPLEX_MAPPINGS=y
+CONFIG_MTD_PHYSMAP=y
+# CONFIG_MTD_PHYSMAP_COMPAT is not set
+# CONFIG_MTD_GPIO_ADDR is not set
+CONFIG_MTD_PLATRAM=y
+# CONFIG_MTD_LATCH_ADDR is not set
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLOCK2MTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOCG3 is not set
+# CONFIG_MTD_NAND_IDS is not set
+# CONFIG_MTD_NAND is not set
+# CONFIG_MTD_ONENAND is not set
+CONFIG_MTD_SPI_NOR=y
+CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y
+CONFIG_SPI_ZXIC_NOR=y
+CONFIG_ZX297520V3_UFI_MINI_32K_NOR=y
+
+#
+# LPDDR flash memory drivers
+#
+CONFIG_MTD_LPDDR=y
+CONFIG_MTD_QINFO_PROBE=y
+CONFIG_MTD_UBI=y
+CONFIG_MTD_UBI_WL_THRESHOLD=4096
+CONFIG_MTD_UBI_BEB_RESERVE=3
+# CONFIG_MTD_UBI_GLUEBI is not set
+# CONFIG_MTD_UBI_DEBUG is not set
+# CONFIG_PARPORT is not set
+CONFIG_BLK_DEV=y
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_LOOP_MIN_COUNT=8
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+
+#
+# DRBD disabled because PROC_FS, INET or CONNECTOR not selected
+#
+# CONFIG_BLK_DEV_NBD is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=16384
+# CONFIG_BLK_DEV_XIP is not set
+# CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
+# CONFIG_MG_DISK is not set
+# CONFIG_BLK_DEV_RBD is not set
+
+#
+# Misc devices
+#
+# CONFIG_SENSORS_LIS3LV02D is not set
+# CONFIG_AD525X_DPOT is not set
+# CONFIG_ATMEL_PWM is not set
+# CONFIG_ICS932S401 is not set
+# CONFIG_ENCLOSURE_SERVICES is not set
+# CONFIG_APDS9802ALS is not set
+# CONFIG_ISL29003 is not set
+# CONFIG_ISL29020 is not set
+# CONFIG_SENSORS_TSL2550 is not set
+# CONFIG_SENSORS_BH1780 is not set
+# CONFIG_SENSORS_BH1770 is not set
+# CONFIG_SENSORS_APDS990X is not set
+# CONFIG_HMC6352 is not set
+# CONFIG_SENSORS_AK8975 is not set
+# CONFIG_DS1682 is not set
+# CONFIG_UID_STAT is not set
+# CONFIG_BMP085 is not set
+# CONFIG_USB_SWITCH_FSA9480 is not set
+# CONFIG_WL127X_RFKILL is not set
+# CONFIG_C2PORT is not set
+
+#
+# EEPROM support
+#
+# CONFIG_EEPROM_AT24 is not set
+# CONFIG_EEPROM_LEGACY is not set
+# CONFIG_EEPROM_MAX6875 is not set
+# CONFIG_EEPROM_93CX6 is not set
+# CONFIG_IWMC3200TOP is not set
+
+#
+# Texas Instruments shared transport line discipline
+#
+# CONFIG_TI_ST is not set
+# CONFIG_SENSORS_LIS3_I2C is not set
+
+#
+# Altera FPGA firmware download module
+#
+# CONFIG_ALTERA_STAPL is not set
+
+#
+# SCSI device support
+#
+CONFIG_SCSI_MOD=y
+# CONFIG_RAID_ATTRS is not set
+# CONFIG_SCSI is not set
+# CONFIG_SCSI_DMA is not set
+# CONFIG_SCSI_NETLINK is not set
+# CONFIG_ATA is not set
+# CONFIG_MD is not set
+CONFIG_NETDEVICES=y
+CONFIG_NET_CORE=y
+# CONFIG_BONDING is not set
+# CONFIG_DUMMY is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_MII is not set
+# CONFIG_IFB is not set
+# CONFIG_NET_TEAM is not set
+# CONFIG_MACVLAN is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+CONFIG_TUN=y
+# CONFIG_VETH is not set
+CONFIG_ATM_DRIVERS=y
+# CONFIG_ATM_DUMMY is not set
+# CONFIG_ATM_TCP is not set
+
+#
+# CAIF transport drivers
+#
+CONFIG_ETHERNET=y
+CONFIG_NET_VENDOR_ZTE=y
+CONFIG_ZX29_GMAC=y
+# CONFIG_NET_ZX29_GMAC is not set
+CONFIG_PHYLIB=y
+# CONFIG_NET_ZX29_GMAC_PHY is not set
+# CONFIG_NET_ZX29_GMAC_SWITCH is not set
+CONFIG_JLSEMI_PHY=y
+
+CONFIG_PPP=y
+CONFIG_PPP_BSDCOMP=y
+CONFIG_PPP_DEFLATE=y
+# CONFIG_PPP_FILTER is not set
+CONFIG_PPP_MPPE=y
+# CONFIG_PPP_MULTILINK is not set
+# CONFIG_PPPOATM is not set
+CONFIG_PPPOE=y
+# CONFIG_PPPOLAC is not set
+# CONFIG_PPPOPNS is not set
+CONFIG_PPP_ASYNC=y
+# CONFIG_PPP_SYNC_TTY is not set
+# CONFIG_SLIP is not set
+CONFIG_SLHC=y
+CONFIG_WLAN=y
+
+CONFIG_RTL8192CD=y
+CONFIG_MIFI_WIFI=n
+CONFIG_RTL_WIFI_WPA2=y
+CONFIG_RTL_92E_SUPPORT=y
+#
+# Enable WiMAX (Networking options) to see the WiMAX drivers
+#
+# CONFIG_WAN is not set
+CONFIG_PS_NET=y
+# CONFIG_7510_DDR_AP_NET is not set
+CONFIG_NET_ZX29_AT=y
+# CONFIG_ISDN is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
+# CONFIG_INPUT_POLLDEV is not set
+# CONFIG_INPUT_SPARSEKMAP is not set
+
+#
+# Userland interfaces
+#
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_EVBUG is not set
+# CONFIG_INPUT_KEYRESET is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+# CONFIG_KEYBOARD_ADP5588 is not set
+# CONFIG_KEYBOARD_ADP5589 is not set
+# CONFIG_KEYBOARD_ATKBD is not set
+# CONFIG_KEYBOARD_QT1070 is not set
+# CONFIG_KEYBOARD_QT2160 is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_GPIO is not set
+# CONFIG_KEYBOARD_TCA6416 is not set
+# CONFIG_KEYBOARD_TCA8418 is not set
+# CONFIG_KEYBOARD_MATRIX is not set
+# CONFIG_KEYBOARD_LM8323 is not set
+# CONFIG_KEYBOARD_MAX7359 is not set
+# CONFIG_KEYBOARD_MCS is not set
+# CONFIG_KEYBOARD_MPR121 is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+# CONFIG_KEYBOARD_OPENCORES is not set
+# CONFIG_KEYBOARD_SAMSUNG is not set
+# CONFIG_KEYBOARD_STOWAWAY is not set
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_OMAP4 is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_ZX297510 is not set
+CONFIG_KEYBOARD_ZX_INT=y
+# CONFIG_KEYBOARD_ZX_4x4 is not set
+# CONFIG_KEYBOARD_ZX_5x6 is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TABLET is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Hardware I/O ports
+#
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
+
+#
+# Character devices
+#
+# CONFIG_VT is not set
+CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=5
+# CONFIG_SERIAL_NONSTANDARD is not set
+CONFIG_N_GSM=y
+# CONFIG_TRACE_SINK is not set
+CONFIG_DEVMEM=y
+# CONFIG_DEVKMEM is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+# CONFIG_SERIAL_TIMBERDALE is not set
+# CONFIG_SERIAL_ALTERA_JTAGUART is not set
+# CONFIG_SERIAL_ALTERA_UART is not set
+# CONFIG_SERIAL_XILINX_PS_UART is not set
+# CONFIG_SERIAL_ZX297502_UART is not set
+# CONFIG_SERIAL_ZX297510_UART is not set
+CONFIG_SERIAL_ZX29_UART=y
+CONFIG_SERIAL_ZX29_UART_CONSOLE=y
+CONFIG_UART_CONSOLE_ID=1
+# CONFIG_TTY_PRINTK is not set
+# CONFIG_HVC_DCC is not set
+# CONFIG_IPMI_HANDLER is not set
+CONFIG_HW_RANDOM=y
+# CONFIG_HW_RANDOM_TIMERIOMEM is not set
+# CONFIG_R3964 is not set
+# CONFIG_RAW_DRIVER is not set
+# CONFIG_TCG_TPM is not set
+# CONFIG_DCC_TTY is not set
+# CONFIG_RAMOOPS is not set
+CONFIG_I2C=y
+CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_COMPAT=y
+CONFIG_I2C_CHARDEV=y
+# CONFIG_I2C_MUX is not set
+CONFIG_I2C_HELPER_AUTO=y
+
+#
+# I2C Hardware Bus support
+#
+
+#
+# I2C system bus drivers (mostly embedded / system-on-chip)
+#
+# CONFIG_I2C_DESIGNWARE_PLATFORM is not set
+# CONFIG_I2C_GPIO is not set
+# CONFIG_I2C_OCORES is not set
+# CONFIG_I2C_PCA_PLATFORM is not set
+# CONFIG_I2C_PXA_PCI is not set
+# CONFIG_I2C_SIMTEC is not set
+# CONFIG_I2C_XILINX is not set
+CONFIG_I2C_ZX29=y
+
+#
+# External I2C/SMBus adapter drivers
+#
+# CONFIG_I2C_PARPORT_LIGHT is not set
+# CONFIG_I2C_TAOS_EVM is not set
+
+#
+# Other I2C/SMBus bus drivers
+#
+# CONFIG_I2C_STUB is not set
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+CONFIG_SPI=y
+# CONFIG_SPI_DEBUG is not set
+CONFIG_SPI_MASTER=y
+
+#
+# SPI Master Controller Drivers
+#
+# CONFIG_SPI_ALTERA is not set
+# CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_GPIO is not set
+# CONFIG_SPI_OC_TINY is not set
+# CONFIG_SPI_PXA2XX_PCI is not set
+# CONFIG_SPI_XILINX is not set
+# CONFIG_SPI_DESIGNWARE is not set
+CONFIG_SPI_ZX29=y
+
+#
+# SPI Protocol Masters
+#
+CONFIG_SPI_SPIDEV=y
+# CONFIG_SPI_TLE62X0 is not set
+
+# CONFIG_HSI is not set
+
+#
+# PPS support
+#
+# CONFIG_PPS is not set
+
+#
+# PPS generators support
+#
+
+#
+# PTP clock support
+#
+
+#
+# Enable Device Drivers -> PPS to see the PTP clock options.
+#
+CONFIG_ARCH_REQUIRE_GPIOLIB=y
+CONFIG_GPIOLIB=y
+# CONFIG_DEBUG_GPIO is not set
+CONFIG_GPIO_SYSFS=y
+
+#
+# Memory mapped GPIO drivers:
+#
+# CONFIG_GPIO_GENERIC_PLATFORM is not set
+CONFIG_GPIO_ZX29=y
+
+#
+# I2C GPIO expanders:
+#
+# CONFIG_GPIO_MAX7300 is not set
+# CONFIG_GPIO_MAX732X is not set
+# CONFIG_GPIO_PCF857X is not set
+# CONFIG_GPIO_SX150X is not set
+# CONFIG_GPIO_ADP5588 is not set
+
+#
+# PCI GPIO expanders:
+#
+
+#
+# SPI GPIO expanders:
+#
+# CONFIG_GPIO_MCP23S08 is not set
+
+#
+# AC97 GPIO expanders:
+#
+
+#
+# MODULbus GPIO expanders:
+#
+# CONFIG_W1 is not set
+CONFIG_POWER_SUPPLY=y
+CONFIG_POWER_SUPPLY_DEBUG=y
+CONFIG_CHARGER_AW3215=y
+# CONFIG_PDA_POWER is not set
+# CONFIG_TEST_POWER is not set
+# CONFIG_BATTERY_DS2780 is not set
+# CONFIG_BATTERY_DS2781 is not set
+# CONFIG_BATTERY_DS2782 is not set
+# CONFIG_BATTERY_SBS is not set
+# CONFIG_BATTERY_BQ24165 is not set
+# CONFIG_CHARGER_ZX234502 is not set
+# CONFIG_BATTERY_BQ27x00 is not set
+# CONFIG_BATTERY_MAX17040 is not set
+# CONFIG_BATTERY_MAX17042 is not set
+# CONFIG_BATTERY_ANDROID is not set
+# CONFIG_CHARGER_MAX8903 is not set
+# CONFIG_CHARGER_LP8727 is not set
+# CONFIG_CHARGER_GPIO is not set
+# CONFIG_CHARGER_SMB347 is not set
+# CONFIG_HWMON is not set
+# CONFIG_THERMAL is not set
+CONFIG_WATCHDOG=y
+CONFIG_WATCHDOG_CORE=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+
+#
+# Watchdog Device Drivers
+#
+# CONFIG_SOFT_WATCHDOG is not set
+# CONFIG_DW_WATCHDOG is not set
+# CONFIG_MAX63XX_WATCHDOG is not set
+CONFIG_ZX29_WATCHDOG=y
+# CONFIG_ZX29_WDT_TEST is not set
+
+CONFIG_SSB_POSSIBLE=y
+
+#
+#DDR
+#
+CONFIG_DDR_ZX29=y
+
+#
+# TSC
+#
+CONFIG_TSC_ZX29=y
+
+#
+# Sonics Silicon Backplane
+#
+# CONFIG_SSB is not set
+CONFIG_BCMA_POSSIBLE=y
+
+#
+# Broadcom specific AMBA
+#
+# CONFIG_BCMA is not set
+
+#
+# Multifunction device drivers
+#
+CONFIG_MFD_CORE=y
+# CONFIG_MFD_88PM860X is not set
+# CONFIG_MFD_SM501 is not set
+# CONFIG_MFD_ASIC3 is not set
+# CONFIG_HTC_EGPIO is not set
+# CONFIG_HTC_PASIC3 is not set
+# CONFIG_HTC_I2CPLD is not set
+# CONFIG_TPS6105X is not set
+# CONFIG_TPS65010 is not set
+# CONFIG_TPS6507X is not set
+# CONFIG_MFD_TPS65217 is not set
+# CONFIG_MFD_TPS6586X is not set
+# CONFIG_MFD_TPS65910 is not set
+# CONFIG_MFD_TPS65912_I2C is not set
+CONFIG_MFD_ZX234290=y
+CONFIG_MFD_ZX234290_I2C=y
+# CONFIG_TWL4030_CORE is not set
+# CONFIG_TWL6040_CORE is not set
+# CONFIG_MFD_STMPE is not set
+# CONFIG_MFD_TC3589X is not set
+# CONFIG_MFD_TMIO is not set
+# CONFIG_MFD_T7L66XB is not set
+# CONFIG_MFD_TC6387XB is not set
+# CONFIG_MFD_TC6393XB is not set
+# CONFIG_PMIC_DA903X is not set
+# CONFIG_MFD_DA9052_I2C is not set
+# CONFIG_PMIC_ADP5520 is not set
+# CONFIG_MFD_MAX8925 is not set
+# CONFIG_MFD_MAX8997 is not set
+# CONFIG_MFD_MAX8998 is not set
+# CONFIG_MFD_S5M_CORE is not set
+# CONFIG_MFD_WM8400 is not set
+# CONFIG_MFD_WM831X_I2C is not set
+# CONFIG_MFD_WM8350_I2C is not set
+# CONFIG_MFD_WM8994 is not set
+# CONFIG_MFD_PCF50633 is not set
+# CONFIG_ABX500_CORE is not set
+# CONFIG_MFD_WL1273_CORE is not set
+# CONFIG_MFD_TPS65090 is not set
+# CONFIG_MFD_AAT2870_CORE is not set
+# CONFIG_MFD_RC5T583 is not set
+# CONFIG_REGULATOR is not set
+# CONFIG_MEDIA_SUPPORT is not set
+
+#
+# Graphics support
+#
+# CONFIG_DRM is not set
+# CONFIG_ION is not set
+# CONFIG_VGASTATE is not set
+# CONFIG_VIDEO_OUTPUT_CONTROL is not set
+# CONFIG_FB is not set
+# CONFIG_FIRMWARE_EDID is not set
+# CONFIG_FB_DDC is not set
+# CONFIG_FB_BOOT_VESA_SUPPORT is not set
+# CONFIG_FB_CFB_FILLRECT is not set
+# CONFIG_FB_CFB_COPYAREA is not set
+# CONFIG_FB_CFB_IMAGEBLIT is not set
+# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
+# CONFIG_FB_SYS_FILLRECT is not set
+# CONFIG_FB_SYS_COPYAREA is not set
+# CONFIG_FB_SYS_IMAGEBLIT is not set
+# CONFIG_FB_FOREIGN_ENDIAN is not set
+# CONFIG_FB_SYS_FOPS is not set
+# CONFIG_FB_LCD_TE_ON is not set
+# CONFIG_FB_LEADT15DS26 is not set 
+# CONFIG_FB_WMT_GE_ROPS is not set
+# CONFIG_FB_SVGALIB is not set
+# CONFIG_FB_MACMODES is not set
+# CONFIG_FB_BACKLIGHT is not set
+# CONFIG_FB_MODE_HELPERS is not set
+# CONFIG_FB_TILEBLITTING is not set
+
+#
+# Frame buffer hardware drivers
+#
+# CONFIG_FB_S1D13XXX is not set
+# CONFIG_FB_TMIO is not set
+# CONFIG_FB_VIRTUAL is not set
+# CONFIG_FB_METRONOME is not set
+# CONFIG_FB_BROADSHEET is not set
+
+# CONFIG_FB_LCM_LEAD_128_128_F231E is not set
+# CONFIG_EXYNOS_VIDEO is not set
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
+# CONFIG_LOGO is not set
+# CONFIG_SOUND is not set
+# CONFIG_HID_SUPPORT is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+# CONFIG_USB_ARCH_HAS_XHCI is not set
+CONFIG_USB_SUPPORT=y
+CONFIG_USB_COMMON=y
+CONFIG_USB_ARCH_HAS_HCD=y
+# CONFIG_USB is not set
+# CONFIG_USB_OTG_WHITELIST is not set
+# CONFIG_USB_OTG_BLACKLIST_HUB is not set
+CONFIG_DWC_OTG_USB=y
+CONFIG_DWC_DEVICE_ONLY=y
+
+#
+# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
+#
+CONFIG_USB_GADGET=y
+# CONFIG_USB_GADGET_DEBUG is not set
+# CONFIG_USB_GADGET_DEBUG_FILES is not set
+# CONFIG_USB_GADGET_DEBUG_FS is not set
+CONFIG_USB_GADGET_VBUS_DRAW=2
+CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS=2
+# CONFIG_USB_FUSB300 is not set
+# CONFIG_USB_R8A66597 is not set
+# CONFIG_USB_MV_UDC is not set
+# CONFIG_USB_M66592 is not set
+# CONFIG_USB_NET2272 is not set
+# CONFIG_USB_ZERO is not set
+# CONFIG_USB_ETH is not set
+# CONFIG_USB_G_NCM is not set
+# CONFIG_USB_GADGETFS is not set
+# CONFIG_USB_FUNCTIONFS is not set
+# CONFIG_USB_FILE_STORAGE is not set
+# CONFIG_USB_MASS_STORAGE is not set
+# CONFIG_USB_G_SERIAL is not set
+# CONFIG_USB_G_PRINTER is not set
+# CONFIG_USB_CDC_COMPOSITE is not set
+# CONFIG_USB_G_ACM_MS is not set
+# CONFIG_USB_G_MULTI is not set
+# CONFIG_USB_G_HID is not set
+# CONFIG_USB_G_DBGP is not set
+
+#
+# OTG and related infrastructure
+#
+# CONFIG_USB_OTG_WAKELOCK is not set
+# CONFIG_USB_GPIO_VBUS is not set
+# CONFIG_USB_ULPI is not set
+# CONFIG_NOP_USB_XCEIV is not set
+CONFIG_MMC=y
+# CONFIG_MMC_DEBUG is not set
+CONFIG_MMC_UNSAFE_RESUME=y
+# CONFIG_MMC_CLKGATE is not set
+# CONFIG_MMC_EMBEDDED_SDIO is not set
+# CONFIG_MMC_PARANOID_SD_INIT is not set
+
+#
+# MMC/SD/SDIO Card Drivers
+#
+CONFIG_MMC_BLOCK=y
+CONFIG_MMC_BLOCK_MINORS=8
+CONFIG_MMC_BLOCK_BOUNCE=y
+# CONFIG_MMC_BLOCK_DEFERRED_RESUME is not set
+# CONFIG_SDIO_UART is not set
+# CONFIG_MMC_TEST is not set
+
+#
+# MMC/SD/SDIO Host Controller Drivers
+#
+# CONFIG_MMC_SDHCI is not set
+# CONFIG_MMC_SDHCI_PXAV3 is not set
+# CONFIG_MMC_SDHCI_PXAV2 is not set
+# CONFIG_MMC_DW is not set
+CONFIG_MMC_DW_IDMAC=y
+CONFIG_MMC_ZX29=y
+CONFIG_MMC_ZX29_PLTFM=y
+# CONFIG_MMC_ZX29_EDMAC is not set
+# CONFIG_MEMSTICK is not set
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+
+#
+# LED drivers
+#
+# CONFIG_LEDS_LM3530 is not set
+# CONFIG_LEDS_PCA9532 is not set
+CONFIG_LEDS_GPIO=y
+# CONFIG_LEDS_LP3944 is not set
+# CONFIG_LEDS_LP5521 is not set
+# CONFIG_LEDS_LP5523 is not set
+# CONFIG_LEDS_PCA955X is not set
+# CONFIG_LEDS_PCA9633 is not set
+# CONFIG_LEDS_BD2802 is not set
+# CONFIG_LEDS_LT3593 is not set
+# CONFIG_LEDS_RENESAS_TPU is not set
+# CONFIG_LEDS_TCA6507 is not set
+# CONFIG_LEDS_ZX297520UFI is not set
+# CONFIG_LEDS_OT200 is not set
+CONFIG_LEDS_TRIGGERS=y
+
+#
+# LED Triggers
+#
+CONFIG_LEDS_TRIGGER_TIMER=y
+# CONFIG_LEDS_TRIGGER_HEARTBEAT is not set
+# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set
+# CONFIG_LEDS_TRIGGER_GPIO is not set
+# CONFIG_LEDS_TRIGGER_DEFAULT_ON is not set
+
+#
+# iptables trigger is under Netfilter config (LED target)
+#
+# CONFIG_SWITCH is not set
+# CONFIG_ACCESSIBILITY is not set
+
+
+#
+# RTC interfaces
+#
+CONFIG_RTC_LIB=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_HCTOSYS=y
+CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
+# CONFIG_RTC_DEBUG is not set
+CONFIG_RTC_INTF_SYSFS=y
+CONFIG_RTC_INTF_PROC=y
+CONFIG_RTC_INTF_DEV=y
+# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
+# CONFIG_RTC_DRV_TEST is not set
+
+CONFIG_RTC_ZX234290=y
+
+CONFIG_DMADEVICES=y
+CONFIG_DMADEVICES_DEBUG=y
+# CONFIG_DMADEVICES_VDEBUG is not set
+
+#
+# DMA Devices
+#
+CONFIG_ZX29_DMA=y
+# CONFIG_DW_DMAC is not set
+# CONFIG_TIMB_DMA is not set
+CONFIG_DMA_ENGINE=y
+
+#
+# DMA Clients
+#
+# CONFIG_ASYNC_TX_DMA is not set
+# CONFIG_DMATEST is not set
+# CONFIG_AUXDISPLAY is not set
+# CONFIG_UIO is not set
+
+#
+# Virtio drivers
+#
+# CONFIG_VIRTIO_BALLOON is not set
+# CONFIG_VIRTIO_MMIO is not set
+
+#
+# Microsoft Hyper-V guest support
+#
+CONFIG_STAGING=y
+# CONFIG_ECHO is not set
+# CONFIG_IIO is not set
+CONFIG_ZRAM=y
+CONFIG_ZRAM_DEBUG=y
+CONFIG_ZSMALLOC=y
+# CONFIG_FT1000 is not set
+
+#
+# Speakup console speech
+#
+# CONFIG_TOUCHSCREEN_CLEARPAD_TM1217 is not set
+# CONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI4 is not set
+# CONFIG_STAGING_MEDIA is not set
+
+#
+# Android
+#
+# CONFIG_ANDROID is not set
+# CONFIG_PHONE is not set
+
+#
+# ZX297510 USB PROXY
+#
+CONFIG_USB_PROXY=y
+CONFIG_CLKDEV_LOOKUP=y
+
+#
+# ZX297520V3 camera driver
+#
+# CONFIG_CAMERA_DRV is not set
+# CONFIG_SENSOR_GC6133 is not set
+#
+# ZX297520 audiomix driver
+#
+# CONFIG_AUDIOMIX_DRV is not set
+
+#
+# Hardware Spinlock drivers
+#
+CONFIG_IOMMU_SUPPORT=y
+
+#
+# Remoteproc drivers (EXPERIMENTAL)
+#
+
+#
+# Rpmsg drivers (EXPERIMENTAL)
+#
+# CONFIG_VIRT_DRIVERS is not set
+# CONFIG_PM_DEVFREQ is not set
+# CONFIG_RPM_ZX29 is not set
+# CONFIG_OS_EXTEND is not set
+# CONFIG_SI3217X is not set
+# CONFIG_SI3218X is not set
+CONFIG_CPNV=y
+
+#
+# File systems
+#
+# CONFIG_EXT2_FS is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_EXT4_FS is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_BTRFS_FS is not set
+# CONFIG_NILFS2_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+CONFIG_FILE_LOCKING=y
+CONFIG_FSNOTIFY=y
+CONFIG_DNOTIFY=y
+CONFIG_INOTIFY_USER=y
+# CONFIG_FANOTIFY is not set
+# CONFIG_QUOTA is not set
+# CONFIG_QUOTACTL is not set
+# CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
+
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_JOLIET is not set
+# CONFIG_ZISOFS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_SYSCTL=y
+CONFIG_PROC_PAGE_MONITOR=y
+CONFIG_SYSFS=y
+# CONFIG_HUGETLB_PAGE is not set
+# CONFIG_CONFIGFS_FS is not set
+CONFIG_MISC_FILESYSTEMS=y
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+CONFIG_JFFS2_FS=y
+CONFIG_JFFS2_FS_DEBUG=0
+# CONFIG_JFFS2_FS_WRITEBUFFER is not set
+# CONFIG_JFFS2_SUMMARY is not set
+# CONFIG_JFFS2_FS_XATTR is not set
+CONFIG_JFFS2_COMPRESSION_OPTIONS=y
+# CONFIG_JFFS2_ZLIB is not set
+# CONFIG_JFFS2_LZO is not set
+CONFIG_JFFS2_LZMA=y
+# CONFIG_JFFS2_RTIME is not set
+# CONFIG_JFFS2_RUBIN is not set
+# CONFIG_JFFS2_CMODE_NONE is not set
+CONFIG_JFFS2_CMODE_PRIORITY=y
+# CONFIG_JFFS2_CMODE_SIZE is not set
+# CONFIG_JFFS2_CMODE_FAVOURLZO is not set
+# CONFIG_UBIFS_FS is not set
+# CONFIG_LOGFS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_SQUASHFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_OMFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_QNX6FS_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_PSTORE is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+# CONFIG_NETWORK_FILESYSTEMS is not set
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT=""
+# CONFIG_NLS_CODEPAGE_437 is not set
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+# CONFIG_NLS_ISO8859_1 is not set
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+#CONFIG_NLS_UTF8 is not set
+
+#
+# Kernel hacking
+#
+CONFIG_PRINTK_TIME=y
+CONFIG_DEFAULT_MESSAGE_LOGLEVEL=4
+CONFIG_ENABLE_WARN_DEPRECATED=y
+CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_FRAME_WARN=1024
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_STRIP_ASM_SYMS is not set
+# CONFIG_UNUSED_SYMBOLS is not set
+CONFIG_DEBUG_FS=y
+CONFIG_HEADERS_CHECK=y
+# CONFIG_DEBUG_SECTION_MISMATCH is not set
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_LOCKUP_DETECTOR is not set
+# CONFIG_HARDLOCKUP_DETECTOR_NMI is not set
+# CONFIG_HARDLOCKUP_DETECTOR_OTHER_CPU is not set
+# CONFIG_HARDLOCKUP_DETECTOR is not set
+# CONFIG_DETECT_HUNG_TASK is not set
+# CONFIG_SCHED_DEBUG is not set
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_TIMER_STATS is not set
+# CONFIG_DEBUG_OBJECTS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_KMEMLEAK is not set
+# CONFIG_DEBUG_PREEMPT is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_SPARSE_RCU_POINTER is not set
+# CONFIG_LOCK_STAT is not set
+# CONFIG_DEBUG_ATOMIC_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+CONFIG_STACKTRACE=y
+CONFIG_DEBUG_STACK_USAGE=y
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_BUGVERBOSE is not set
+CONFIG_DEBUG_INFO=y
+# CONFIG_DEBUG_INFO_REDUCED is not set
+CONFIG_DEBUG_VM=y
+# CONFIG_DEBUG_WRITECOUNT is not set
+# CONFIG_DEBUG_MEMORY_INIT is not set
+# CONFIG_DEBUG_LIST is not set
+# CONFIG_TEST_LIST_SORT is not set
+# CONFIG_DEBUG_SG is not set
+# CONFIG_DEBUG_NOTIFIERS is not set
+# CONFIG_DEBUG_CREDENTIALS is not set
+# CONFIG_BOOT_PRINTK_DELAY is not set
+# CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_RCU_TRACE is not set
+# CONFIG_BACKTRACE_SELF_TEST is not set
+# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
+# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
+# CONFIG_LKDTM is not set
+# CONFIG_FAULT_INJECTION is not set
+# CONFIG_LATENCYTOP is not set
+# CONFIG_DEBUG_PAGEALLOC is not set
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_DYNAMIC_FTRACE=y
+CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
+CONFIG_HAVE_C_RECORDMCOUNT=y
+CONFIG_TRACING_SUPPORT=y
+# CONFIG_FTRACE is not set
+# CONFIG_BUILD_DOCSRC is not set
+# CONFIG_DYNAMIC_DEBUG is not set
+# CONFIG_DMA_API_DEBUG is not set
+# CONFIG_ATOMIC64_SELFTEST is not set
+# CONFIG_SAMPLES is not set
+CONFIG_HAVE_ARCH_KGDB=y
+# CONFIG_KGDB is not set
+# CONFIG_TEST_KSTRTOX is not set
+# CONFIG_STRICT_DEVMEM is not set
+CONFIG_ARM_UNWIND=y
+CONFIG_DEBUG_USER=y
+CONFIG_DEBUG_RODATA=y
+# CONFIG_DEBUG_RODATA_TEST is not set
+# CONFIG_DEBUG_LL is not set
+CONFIG_ACCURATE_CPU_PERCENT=y
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY_DMESG_RESTRICT is not set
+# CONFIG_SECURITY is not set
+# CONFIG_SECURITYFS is not set
+CONFIG_DEFAULT_SECURITY_DAC=y
+CONFIG_DEFAULT_SECURITY=""
+CONFIG_CRYPTO=y
+
+#
+# Crypto core or helper
+#
+CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_ALGAPI2=y
+CONFIG_CRYPTO_AEAD=y
+CONFIG_CRYPTO_AEAD2=y
+CONFIG_CRYPTO_BLKCIPHER=y
+CONFIG_CRYPTO_BLKCIPHER2=y
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_HASH2=y
+CONFIG_CRYPTO_RNG=y
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_PCOMP2=y
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_MANAGER2=y
+# CONFIG_CRYPTO_USER is not set
+CONFIG_CRYPTO_MANAGER_DISABLE_TESTS=y
+# CONFIG_CRYPTO_GF128MUL is not set
+CONFIG_CRYPTO_NULL=y
+CONFIG_CRYPTO_WORKQUEUE=y
+# CONFIG_CRYPTO_CRYPTD is not set
+CONFIG_CRYPTO_AUTHENC=y
+# CONFIG_CRYPTO_TEST is not set
+
+#
+# Authenticated Encryption with Associated Data
+#
+# CONFIG_CRYPTO_CCM is not set
+# CONFIG_CRYPTO_GCM is not set
+# CONFIG_CRYPTO_SEQIV is not set
+
+#
+# Block modes
+#
+CONFIG_CRYPTO_CBC=y
+# CONFIG_CRYPTO_CTR is not set
+# CONFIG_CRYPTO_CTS is not set
+CONFIG_CRYPTO_ECB=y
+# CONFIG_CRYPTO_LRW is not set
+# CONFIG_CRYPTO_PCBC is not set
+# CONFIG_CRYPTO_XTS is not set
+
+#
+# Hash modes
+#
+CONFIG_CRYPTO_HMAC=y
+# CONFIG_CRYPTO_XCBC is not set
+# CONFIG_CRYPTO_VMAC is not set
+
+#
+# Digest
+#
+CONFIG_CRYPTO_CRC32C=y
+# CONFIG_CRYPTO_GHASH is not set
+# CONFIG_CRYPTO_MD4 is not set
+CONFIG_CRYPTO_MD5=y
+# CONFIG_CRYPTO_MICHAEL_MIC is not set
+# CONFIG_CRYPTO_RMD128 is not set
+# CONFIG_CRYPTO_RMD160 is not set
+# CONFIG_CRYPTO_RMD256 is not set
+# CONFIG_CRYPTO_RMD320 is not set
+CONFIG_CRYPTO_SHA1=y
+CONFIG_CRYPTO_SHA256=y
+CONFIG_CRYPTO_SHA512=y
+# CONFIG_CRYPTO_TGR192 is not set
+# CONFIG_CRYPTO_WP512 is not set
+
+#
+# Ciphers
+#
+CONFIG_CRYPTO_AES=y
+# CONFIG_CRYPTO_ANUBIS is not set
+CONFIG_CRYPTO_ARC4=y
+# CONFIG_CRYPTO_BLOWFISH is not set
+# CONFIG_CRYPTO_CAMELLIA is not set
+# CONFIG_CRYPTO_CAST5 is not set
+# CONFIG_CRYPTO_CAST6 is not set
+CONFIG_CRYPTO_DES=y
+# CONFIG_CRYPTO_FCRYPT is not set
+# CONFIG_CRYPTO_KHAZAD is not set
+# CONFIG_CRYPTO_SALSA20 is not set
+# CONFIG_CRYPTO_SEED is not set
+# CONFIG_CRYPTO_SERPENT is not set
+# CONFIG_CRYPTO_TEA is not set
+CONFIG_CRYPTO_TWOFISH=y
+CONFIG_CRYPTO_TWOFISH_COMMON=y
+
+#
+# Compression
+#
+# CONFIG_CRYPTO_DEFLATE is not set
+# CONFIG_CRYPTO_ZLIB is not set
+# CONFIG_CRYPTO_LZO is not set
+
+#
+# Random Number Generation
+#
+CONFIG_CRYPTO_ANSI_CPRNG=y
+# CONFIG_CRYPTO_USER_API_HASH is not set
+# CONFIG_CRYPTO_USER_API_SKCIPHER is not set
+CONFIG_CRYPTO_HW=y
+# CONFIG_BINARY_PRINTF is not set
+
+#
+# Library routines
+#
+CONFIG_BITREVERSE=y
+CONFIG_GENERIC_PCI_IOMAP=y
+CONFIG_GENERIC_IO=y
+CONFIG_CRC_CCITT=y
+# CONFIG_CRC16 is not set
+# CONFIG_CRC_T10DIF is not set
+CONFIG_CRC_ITU_T=y
+CONFIG_CRC32=y
+# CONFIG_CRC32_SELFTEST is not set
+CONFIG_CRC32_SLICEBY8=y
+# CONFIG_CRC32_SLICEBY4 is not set
+# CONFIG_CRC32_SARWATE is not set
+# CONFIG_CRC32_BIT is not set
+# CONFIG_CRC7 is not set
+# CONFIG_LIBCRC32C is not set
+# CONFIG_CRC8 is not set
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=y
+CONFIG_LZMA_COMPRESS=y
+CONFIG_LZMA_DECOMPRESS=y
+CONFIG_XZ_DEC=y
+CONFIG_XZ_DEC_X86=y
+CONFIG_XZ_DEC_POWERPC=y
+CONFIG_XZ_DEC_IA64=y
+CONFIG_XZ_DEC_ARM=y
+CONFIG_XZ_DEC_ARMTHUMB=y
+CONFIG_XZ_DEC_SPARC=y
+CONFIG_XZ_DEC_BCJ=y
+# CONFIG_XZ_DEC_TEST is not set
+CONFIG_TEXTSEARCH=y
+CONFIG_TEXTSEARCH_KMP=y
+CONFIG_TEXTSEARCH_BM=y
+CONFIG_TEXTSEARCH_FSM=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
+CONFIG_DQL=y
+CONFIG_NLATTR=y
+# CONFIG_AVERAGE is not set
+# CONFIG_CORDIC is not set
+# CONFIG_VOLTE_DRV is not set
+# CONFIG_AMR_DRV is not set
diff --git a/lynq/S300/ap/project/zx297520v3/prj_mifi_min/config/normal/config_app.mk b/lynq/S300/ap/project/zx297520v3/prj_mifi_min/config/normal/config_app.mk
new file mode 100755
index 0000000..2a23cd1
--- /dev/null
+++ b/lynq/S300/ap/project/zx297520v3/prj_mifi_min/config/normal/config_app.mk
@@ -0,0 +1,63 @@
+

+zte_app := busybox busybox_recovery fs_check zte_log_agent\

+			dnsmasq \

+			Script \

+			fota_upi \

+			zte_amt \

+			zte_webui clatd cwmp nvro

+

+#yes only when klocwork static analysis 

+ifneq ($(KW_SKIP),yes)

+zte_app += iproute2 iptables c-ares qrencode

+endif

+

+ifneq ($(CONFIG_WIFI_FUNCTION)), )

+ifeq ($(findstring sta,$(CONFIG_WIFI_FUNCTION)), sta)

+ifneq ($(KW_SKIP),yes)

+ifneq ($(MK_SDK_VERSION),yes)

+zte_app += wpa_supplicant-2.6

+endif

+endif

+endif

+

+ifeq ($(findstring ap,$(CONFIG_WIFI_FUNCTION)), ap)

+ifeq ($(CONFIG_WIFI_MODULE), esp8089)

+ifneq ($(KW_SKIP),yes)

+ifneq ($(MK_SDK_VERSION),yes)

+zte_app += hostapd-2.6

+endif

+endif

+endif

+endif

+

+#zte_app += wlan

+endif

+

+ifeq ($(CONFIG_USE_WEBUI),yes)

+zte_app += goahead

+endif

+zte_app += zte_mifi

+ifneq ($(MK_SDK_VERSION),yes)

+zte_app += cfg_tool zte_arp_proxy zte_ipv6_addr_collect zte_ipv6_addr_conver zte_ipv6_slaac zte_ndp

+ifneq ($(KW_SKIP),yes)

+zte_app += adb dhcp6 miniupnpd radvd-2.14

+endif

+endif

+

+#for app/zte_mainctrl&Script

+export CONFIG_USER_ZTE_APP=y

+

+#for app/iptables

+export CONFIG_USER_IPTABLES_IPTABLES=y

+export CONFIG_USER_IPTABLES_IP6TABLES=y

+

+#for app/iproute2

+export CONFIG_USER_IPROUTE2_TC_TC=y

+export CONFIG_USER_IPROUTE2_IP_RTACCT=y

+export CONFIG_USER_IPROUTE2_IP_IFCFG=y

+export CONFIG_USER_IPROUTE2_IP_IP=y

+export CONFIG_USER_IPROUTE2_IP_ROUTEF=y

+export CONFIG_USER_IPROUTE2_IP_ROUTEL=y

+export CONFIG_USER_IPROUTE2_IP_RTMON=y

+

+export CONFIG_USER_FOTA_OPEN_SOURCE=n

diff --git a/lynq/S300/ap/project/zx297520v3/prj_mifi_min/config/recovery/config.linux b/lynq/S300/ap/project/zx297520v3/prj_mifi_min/config/recovery/config.linux
new file mode 100755
index 0000000..b0a3c65
--- /dev/null
+++ b/lynq/S300/ap/project/zx297520v3/prj_mifi_min/config/recovery/config.linux
@@ -0,0 +1,1175 @@
+#
+# Automatically generated file; DO NOT EDIT.
+# Linux/arm 3.4.110 Kernel Configuration
+#
+CONFIG_ARM=y
+CONFIG_SYS_SUPPORTS_APM_EMULATION=y
+CONFIG_GENERIC_GPIO=y
+# CONFIG_ARCH_USES_GETTIMEOFFSET is not set
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_KTIME_SCALAR=y
+CONFIG_HAVE_PROC_CPU=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_HAVE_LATENCYTOP_SUPPORT=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+CONFIG_HARDIRQS_SW_RESEND=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_ARCH_HAS_CPUFREQ=y
+CONFIG_ARCH_HAS_CPU_IDLE_WAIT=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_NEED_DMA_MAP_STATE=y
+CONFIG_VECTORS_BASE=0xffff0000
+# CONFIG_ARM_PATCH_PHYS_VIRT is not set
+CONFIG_NEED_MACH_MEMORY_H=y
+CONFIG_GENERIC_BUG=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+CONFIG_HAVE_IRQ_WORK=y
+
+#
+# General setup
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_CROSS_COMPILE=""
+CONFIG_LOCALVERSION=""
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_HAVE_KERNEL_GZIP=y
+CONFIG_HAVE_KERNEL_LZMA=y
+CONFIG_HAVE_KERNEL_XZ=y
+CONFIG_HAVE_KERNEL_LZO=y
+CONFIG_KERNEL_GZIP=y
+# CONFIG_KERNEL_LZMA is not set
+# CONFIG_KERNEL_XZ is not set
+# CONFIG_KERNEL_LZO is not set
+CONFIG_DEFAULT_HOSTNAME="DEMO"
+# CONFIG_SWAP is not set
+# CONFIG_SYSVIPC is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_FHANDLE is not set
+CONFIG_HAVE_GENERIC_HARDIRQS=y
+
+#
+# IRQ subsystem
+#
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_SHOW=y
+CONFIG_IRQ_DOMAIN=y
+# CONFIG_IRQ_DOMAIN_DEBUG is not set
+CONFIG_IRQ_FORCED_THREADING=y
+
+#
+# RCU Subsystem
+#
+CONFIG_TINY_PREEMPT_RCU=y
+CONFIG_PREEMPT_RCU=y
+# CONFIG_TREE_RCU_TRACE is not set
+# CONFIG_RCU_BOOST is not set
+CONFIG_IKCONFIG=y
+# CONFIG_IKCONFIG_PROC is not set
+CONFIG_LOG_BUF_SHIFT=16
+# CONFIG_CHECKPOINT_RESTORE is not set
+# CONFIG_NAMESPACES is not set
+# CONFIG_SCHED_AUTOGROUP is not set
+# CONFIG_SYSFS_DEPRECATED is not set
+# CONFIG_RELAY is not set
+# CONFIG_BLK_DEV_INITRD is not set
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL=y
+CONFIG_PANIC_TIMEOUT=0
+CONFIG_EXPERT=y
+CONFIG_UID16=y
+# CONFIG_SYSCTL_SYSCALL is not set
+# CONFIG_KALLSYMS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_BASE_FULL=y
+# CONFIG_FUTEX is not set
+# CONFIG_EPOLL is not set
+# CONFIG_SIGNALFD is not set
+# CONFIG_TIMERFD is not set
+# CONFIG_EVENTFD is not set
+# CONFIG_SHMEM is not set
+# CONFIG_AIO is not set
+CONFIG_EMBEDDED=y
+CONFIG_HAVE_PERF_EVENTS=y
+CONFIG_PERF_USE_VMALLOC=y
+
+#
+# Kernel Performance Events And Counters
+#
+# CONFIG_PERF_EVENTS is not set
+# CONFIG_PERF_COUNTERS is not set
+# CONFIG_VM_EVENT_COUNTERS is not set
+CONFIG_COMPAT_BRK=y
+CONFIG_SLAB=y
+# CONFIG_PROFILING is not set
+CONFIG_HAVE_OPROFILE=y
+# CONFIG_JUMP_LABEL is not set
+CONFIG_HAVE_KPROBES=y
+CONFIG_HAVE_KRETPROBES=y
+CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y
+CONFIG_HAVE_CLK=y
+CONFIG_HAVE_DMA_API_DEBUG=y
+CONFIG_HAVE_ARCH_JUMP_LABEL=y
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_GCOV_KERNEL is not set
+CONFIG_HAVE_GENERIC_DMA_COHERENT=y
+CONFIG_SLABINFO=y
+CONFIG_RT_MUTEXES=y
+CONFIG_BASE_SMALL=0
+# CONFIG_MODULES is not set
+CONFIG_BLOCK=y
+# CONFIG_LBDAF is not set
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_BLK_DEV_BSGLIB is not set
+# CONFIG_BLK_DEV_INTEGRITY is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_DEADLINE=y
+# CONFIG_IOSCHED_CFQ is not set
+CONFIG_DEFAULT_DEADLINE=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="deadline"
+# CONFIG_INLINE_SPIN_TRYLOCK is not set
+# CONFIG_INLINE_SPIN_TRYLOCK_BH is not set
+# CONFIG_INLINE_SPIN_LOCK is not set
+# CONFIG_INLINE_SPIN_LOCK_BH is not set
+# CONFIG_INLINE_SPIN_LOCK_IRQ is not set
+# CONFIG_INLINE_SPIN_LOCK_IRQSAVE is not set
+# CONFIG_INLINE_SPIN_UNLOCK_BH is not set
+# CONFIG_INLINE_SPIN_UNLOCK_IRQ is not set
+# CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE is not set
+# CONFIG_INLINE_READ_TRYLOCK is not set
+# CONFIG_INLINE_READ_LOCK is not set
+# CONFIG_INLINE_READ_LOCK_BH is not set
+# CONFIG_INLINE_READ_LOCK_IRQ is not set
+# CONFIG_INLINE_READ_LOCK_IRQSAVE is not set
+# CONFIG_INLINE_READ_UNLOCK is not set
+# CONFIG_INLINE_READ_UNLOCK_BH is not set
+# CONFIG_INLINE_READ_UNLOCK_IRQ is not set
+# CONFIG_INLINE_READ_UNLOCK_IRQRESTORE is not set
+# CONFIG_INLINE_WRITE_TRYLOCK is not set
+# CONFIG_INLINE_WRITE_LOCK is not set
+# CONFIG_INLINE_WRITE_LOCK_BH is not set
+# CONFIG_INLINE_WRITE_LOCK_IRQ is not set
+# CONFIG_INLINE_WRITE_LOCK_IRQSAVE is not set
+# CONFIG_INLINE_WRITE_UNLOCK is not set
+# CONFIG_INLINE_WRITE_UNLOCK_BH is not set
+# CONFIG_INLINE_WRITE_UNLOCK_IRQ is not set
+# CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE is not set
+# CONFIG_MUTEX_SPIN_ON_OWNER is not set
+CONFIG_FREEZER=y
+
+#
+# System Type
+#
+CONFIG_MMU=y
+# CONFIG_ARCH_INTEGRATOR is not set
+# CONFIG_ARCH_REALVIEW is not set
+# CONFIG_ARCH_VERSATILE is not set
+# CONFIG_ARCH_VEXPRESS is not set
+# CONFIG_ARCH_AT91 is not set
+# CONFIG_ARCH_BCMRING is not set
+# CONFIG_ARCH_HIGHBANK is not set
+# CONFIG_ARCH_CLPS711X is not set
+# CONFIG_ARCH_CNS3XXX is not set
+# CONFIG_ARCH_GEMINI is not set
+# CONFIG_ARCH_PRIMA2 is not set
+# CONFIG_ARCH_EBSA110 is not set
+# CONFIG_ARCH_EP93XX is not set
+# CONFIG_ARCH_FOOTBRIDGE is not set
+# CONFIG_ARCH_MXC is not set
+# CONFIG_ARCH_MXS is not set
+# CONFIG_ARCH_NETX is not set
+# CONFIG_ARCH_H720X is not set
+# CONFIG_ARCH_IOP13XX is not set
+# CONFIG_ARCH_IOP32X is not set
+# CONFIG_ARCH_IOP33X is not set
+# CONFIG_ARCH_IXP23XX is not set
+# CONFIG_ARCH_IXP2000 is not set
+# CONFIG_ARCH_IXP4XX is not set
+# CONFIG_ARCH_DOVE is not set
+# CONFIG_ARCH_KIRKWOOD is not set
+# CONFIG_ARCH_LPC32XX is not set
+# CONFIG_ARCH_MV78XX0 is not set
+# CONFIG_ARCH_ORION5X is not set
+# CONFIG_ARCH_MMP is not set
+# CONFIG_ARCH_KS8695 is not set
+# CONFIG_ARCH_W90X900 is not set
+# CONFIG_ARCH_TEGRA is not set
+# CONFIG_ARCH_PICOXCELL is not set
+# CONFIG_ARCH_PNX4008 is not set
+# CONFIG_ARCH_PXA is not set
+# CONFIG_ARCH_MSM is not set
+# CONFIG_ARCH_SHMOBILE is not set
+# CONFIG_ARCH_RPC is not set
+# CONFIG_ARCH_SA1100 is not set
+# CONFIG_ARCH_S3C24XX is not set
+# CONFIG_ARCH_S3C64XX is not set
+# CONFIG_ARCH_S5P64X0 is not set
+# CONFIG_ARCH_S5PC100 is not set
+# CONFIG_ARCH_S5PV210 is not set
+# CONFIG_ARCH_EXYNOS is not set
+# CONFIG_ARCH_SHARK is not set
+# CONFIG_ARCH_U300 is not set
+# CONFIG_ARCH_U8500 is not set
+# CONFIG_ARCH_NOMADIK is not set
+# CONFIG_ARCH_DAVINCI is not set
+# CONFIG_ARCH_OMAP is not set
+# CONFIG_PLAT_SPEAR is not set
+# CONFIG_ARCH_VT8500 is not set
+# CONFIG_ARCH_ZYNQ is not set
+# CONFIG_ARCH_ZX297510 is not set
+# CONFIG_ARCH_ZX297520V2 is not set
+CONFIG_ARCH_ZX297520V3=y
+# CONFIG_GPIO_PCA953X is not set
+
+#
+# System MMU
+#
+CONFIG_ZX29_TIMER_HZ=200
+CONFIG_ZX_RAM_CONSOLE=y
+CONFIG_ZX_PM_DEBUG=y
+# CONFIG_ZX_PM_DEBUG_TIME is not set
+
+#
+# ZX297520V3 Board Type
+#
+# CONFIG_ARCH_ZX297520V3_EVB is not set
+# CONFIG_ARCH_ZX297520V3_MDL is not set
+CONFIG_ARCH_ZX297520V3_MIFI=y
+# CONFIG_ARCH_ZX297520V3_PHONE is not set
+# CONFIG_ARCH_ZX297520V3_WATCH is not set
+# CONFIG_ARCH_ZX297520V3_FPGA is not set
+CONFIG_MIN_VERSION=y
+CONFIG_PLAT_ZTE=y
+
+#
+# Processor Type
+#
+CONFIG_CPU_V7=y
+CONFIG_CPU_32v6K=y
+CONFIG_CPU_32v7=y
+CONFIG_CPU_ABRT_EV7=y
+CONFIG_CPU_PABRT_V7=y
+CONFIG_CPU_CACHE_V7=y
+CONFIG_CPU_CACHE_VIPT=y
+CONFIG_CPU_COPY_V6=y
+CONFIG_CPU_TLB_V7=y
+CONFIG_CPU_HAS_ASID=y
+CONFIG_CPU_CP15=y
+CONFIG_CPU_CP15_MMU=y
+
+#
+# Processor Features
+#
+# CONFIG_ARM_LPAE is not set
+# CONFIG_ARCH_PHYS_ADDR_T_64BIT is not set
+CONFIG_ARM_THUMB=y
+# CONFIG_ARM_THUMBEE is not set
+# CONFIG_SWP_EMULATE is not set
+# CONFIG_CPU_ICACHE_DISABLE is not set
+# CONFIG_CPU_DCACHE_DISABLE is not set
+# CONFIG_CPU_BPREDICT_DISABLE is not set
+# CONFIG_CACHE_L2X0 is not set
+CONFIG_ARM_L1_CACHE_SHIFT_6=y
+CONFIG_ARM_L1_CACHE_SHIFT=6
+CONFIG_ARM_DMA_MEM_BUFFERABLE=y
+CONFIG_ARM_NR_BANKS=8
+CONFIG_CPU_HAS_PMU=y
+CONFIG_MULTI_IRQ_HANDLER=y
+# CONFIG_ARM_ERRATA_430973 is not set
+# CONFIG_ARM_ERRATA_458693 is not set
+# CONFIG_ARM_ERRATA_460075 is not set
+CONFIG_ARM_ERRATA_720789=y
+CONFIG_ARM_ERRATA_743622=y
+CONFIG_ARM_ERRATA_751472=y
+CONFIG_ARM_ERRATA_754322=y
+# CONFIG_ARM_ERRATA_775420 is not set
+# CONFIG_FIQ_DEBUGGER is not set
+
+#
+# Bus support
+#
+# CONFIG_PCI_SYSCALL is not set
+# CONFIG_ARCH_SUPPORTS_MSI is not set
+# CONFIG_PCCARD is not set
+
+#
+# Kernel Features
+#
+CONFIG_TICK_ONESHOT=y
+# CONFIG_NO_HZ is not set
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+CONFIG_VMSPLIT_3G=y
+# CONFIG_VMSPLIT_2G is not set
+# CONFIG_VMSPLIT_1G is not set
+CONFIG_ARCH_NR_GPIO=0
+CONFIG_PREEMPT=y
+CONFIG_PREEMPT_RT_BASE=y
+# CONFIG_PREEMPT_NONE is not set
+# CONFIG_PREEMPT_VOLUNTARY is not set
+# CONFIG_PREEMPT__LL is not set
+# CONFIG_PREEMPT_RTB is not set
+CONFIG_PREEMPT_RT_FULL=y
+CONFIG_PREEMPT_COUNT=y
+CONFIG_HZ=200
+# CONFIG_THUMB2_KERNEL is not set
+CONFIG_AEABI=y
+# CONFIG_OABI_COMPAT is not set
+# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set
+# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set
+CONFIG_HAVE_ARCH_PFN_VALID=y
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_HAVE_MEMBLOCK=y
+CONFIG_PAGEFLAGS_EXTENDED=y
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_COMPACTION is not set
+# CONFIG_PHYS_ADDR_T_64BIT is not set
+CONFIG_ZONE_DMA_FLAG=0
+CONFIG_VIRT_TO_BUS=y
+# CONFIG_KSM is not set
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
+CONFIG_NEED_PER_CPU_KM=y
+# CONFIG_CLEANCACHE is not set
+# CONFIG_RAMDUMP is not set
+# CONFIG_KERNEL_GLOBAL_DEBUG is not set
+CONFIG_FORCE_MAX_ZONEORDER=11
+CONFIG_ALIGNMENT_TRAP=y
+# CONFIG_UACCESS_WITH_MEMCPY is not set
+# CONFIG_SECCOMP is not set
+# CONFIG_CC_STACKPROTECTOR is not set
+# CONFIG_DEPRECATED_PARAM_STRUCT is not set
+# CONFIG_ARM_FLUSH_CONSOLE_ON_RESTART is not set
+# CONFIG_THREAD_DEBUG is not set
+# CONFIG_INT_DEBUG is not set
+
+#
+# Boot options
+#
+# CONFIG_USE_OF is not set
+CONFIG_ZBOOT_ROM_TEXT=0x10000000
+CONFIG_ZBOOT_ROM_BSS=0x20040000
+# CONFIG_ZBOOT_ROM is not set
+CONFIG_CMDLINE="root=/dev/mtdblock5 ro rootfstype=jffs2"
+# CONFIG_CMDLINE_FROM_BOOTLOADER is not set
+CONFIG_CMDLINE_EXTEND=y
+# CONFIG_CMDLINE_FORCE is not set
+# CONFIG_SYSTEM_NORMAL is not set
+CONFIG_SYSTEM_RECOVERY=y
+# CONFIG_SYSTEM_CAP is not set
+# CONFIG_CPPS_KO is not set
+# CONFIG_BOOT_WITHOUT_UBOOT is not set
+# CONFIG_XIP_KERNEL is not set
+# CONFIG_KEXEC is not set
+# CONFIG_CRASH_DUMP is not set
+# CONFIG_AUTO_ZRELADDR is not set
+
+#
+# CPU Power Management
+#
+
+#
+# CPU Frequency scaling
+#
+# CONFIG_CPU_FREQ is not set
+# CONFIG_CPU_IDLE is not set
+# CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED is not set
+
+#
+# Floating point emulation
+#
+
+#
+# At least one emulation must be selected
+#
+# CONFIG_VFP is not set
+
+#
+# Userspace binary formats
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_ARCH_BINFMT_ELF_RANDOMIZE_PIE=y
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+# CONFIG_HAVE_AOUT is not set
+# CONFIG_BINFMT_MISC is not set
+
+#
+# Power management options
+#
+CONFIG_SUSPEND=y
+CONFIG_SUSPEND_FREEZER=y
+CONFIG_HAS_WAKELOCK=y
+CONFIG_WAKELOCK=y
+CONFIG_PM_SLEEP=y
+# CONFIG_PM_AUTOSLEEP is not set
+# CONFIG_PM_WAKELOCKS is not set
+CONFIG_PM_RUNTIME=y
+CONFIG_PM=y
+# CONFIG_PM_DEBUG is not set
+# CONFIG_APM_EMULATION is not set
+CONFIG_PM_CLK=y
+CONFIG_CPU_PM=y
+# CONFIG_SUSPEND_TIME is not set
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+CONFIG_ARM_CPU_SUSPEND=y
+# CONFIG_NET is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+# CONFIG_DEVTMPFS is not set
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+CONFIG_FIRMWARE_IN_KERNEL=y
+CONFIG_EXTRA_FIRMWARE=""
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+# CONFIG_GENERIC_CPU_DEVICES is not set
+# CONFIG_DMA_SHARED_BUFFER is not set
+# CONFIG_SYNC is not set
+# CONFIG_ZX_PM_SUSPEND is not set
+CONFIG_MTD=y
+# CONFIG_MTD_REDBOOT_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AFS_PARTS is not set
+# CONFIG_MTD_AR7_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=y
+CONFIG_MTD_BLKDEVS=y
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+CONFIG_PARTS_GUARD=y
+# CONFIG_MTD_ADAPTER is not set
+# CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
+# CONFIG_SM_FTL is not set
+# CONFIG_MTD_OOPS is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+# CONFIG_MTD_CFI is not set
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+CONFIG_MTD_RAM=y
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+
+#
+# Mapping drivers for chip access
+#
+CONFIG_MTD_COMPLEX_MAPPINGS=y
+CONFIG_MTD_PHYSMAP=y
+# CONFIG_MTD_PHYSMAP_COMPAT is not set
+# CONFIG_MTD_GPIO_ADDR is not set
+CONFIG_MTD_PLATRAM=y
+# CONFIG_MTD_LATCH_ADDR is not set
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_DATAFLASH is not set
+# CONFIG_MTD_M25P80 is not set
+# CONFIG_MTD_SST25L is not set
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLOCK2MTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOCG3 is not set
+# CONFIG_MTD_NAND_IDS is not set
+# CONFIG_MTD_NAND is not set
+# CONFIG_MTD_ONENAND is not set
+CONFIG_MTD_SPI_NOR=y
+CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y
+CONFIG_SPI_ZXIC_NOR=y
+CONFIG_ZX297520V3_UFI_MINI_32K_NOR=y
+
+#
+# LPDDR flash memory drivers
+#
+CONFIG_MTD_LPDDR=y
+CONFIG_MTD_QINFO_PROBE=y
+# CONFIG_MTD_UBI is not set
+# CONFIG_PARPORT is not set
+CONFIG_BLK_DEV=y
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_LOOP_MIN_COUNT=8
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+
+#
+# DRBD disabled because PROC_FS, INET or CONNECTOR not selected
+#
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=16384
+# CONFIG_BLK_DEV_XIP is not set
+# CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_MG_DISK is not set
+
+#
+# Misc devices
+#
+# CONFIG_AD525X_DPOT is not set
+# CONFIG_ATMEL_PWM is not set
+# CONFIG_ICS932S401 is not set
+# CONFIG_ENCLOSURE_SERVICES is not set
+# CONFIG_APDS9802ALS is not set
+# CONFIG_ISL29003 is not set
+# CONFIG_ISL29020 is not set
+# CONFIG_SENSORS_TSL2550 is not set
+# CONFIG_SENSORS_BH1780 is not set
+# CONFIG_SENSORS_BH1770 is not set
+# CONFIG_SENSORS_APDS990X is not set
+# CONFIG_HMC6352 is not set
+# CONFIG_SENSORS_AK8975 is not set
+# CONFIG_DS1682 is not set
+# CONFIG_UID_STAT is not set
+# CONFIG_BMP085 is not set
+# CONFIG_USB_SWITCH_FSA9480 is not set
+# CONFIG_C2PORT is not set
+
+#
+# EEPROM support
+#
+# CONFIG_EEPROM_AT24 is not set
+# CONFIG_EEPROM_LEGACY is not set
+# CONFIG_EEPROM_MAX6875 is not set
+# CONFIG_EEPROM_93CX6 is not set
+
+#
+# Texas Instruments shared transport line discipline
+#
+
+#
+# Altera FPGA firmware download module
+#
+# CONFIG_ALTERA_STAPL is not set
+
+#
+# SCSI device support
+#
+CONFIG_SCSI_MOD=y
+# CONFIG_RAID_ATTRS is not set
+# CONFIG_SCSI is not set
+# CONFIG_SCSI_DMA is not set
+# CONFIG_SCSI_NETLINK is not set
+# CONFIG_ATA is not set
+# CONFIG_MD is not set
+
+#
+# Input device support
+#
+# CONFIG_INPUT is not set
+
+#
+# Hardware I/O ports
+#
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
+
+#
+# Character devices
+#
+# CONFIG_VT is not set
+CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=5
+# CONFIG_SERIAL_NONSTANDARD is not set
+# CONFIG_TRACE_SINK is not set
+CONFIG_DEVMEM=y
+# CONFIG_DEVKMEM is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+# CONFIG_SERIAL_TIMBERDALE is not set
+# CONFIG_SERIAL_ALTERA_JTAGUART is not set
+# CONFIG_SERIAL_ALTERA_UART is not set
+# CONFIG_SERIAL_XILINX_PS_UART is not set
+# CONFIG_SERIAL_ZX297502_UART is not set
+# CONFIG_SERIAL_ZX297510_UART is not set
+CONFIG_SERIAL_ZX29_UART=y
+CONFIG_SERIAL_ZX29_UART_CONSOLE=y
+CONFIG_UART_CONSOLE_ID=1
+# CONFIG_TTY_PRINTK is not set
+# CONFIG_HVC_DCC is not set
+# CONFIG_IPMI_HANDLER is not set
+CONFIG_HW_RANDOM=y
+# CONFIG_HW_RANDOM_TIMERIOMEM is not set
+# CONFIG_R3964 is not set
+# CONFIG_RAW_DRIVER is not set
+# CONFIG_TCG_TPM is not set
+# CONFIG_DCC_TTY is not set
+# CONFIG_RAMOOPS is not set
+CONFIG_I2C=y
+CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_COMPAT=y
+CONFIG_I2C_CHARDEV=y
+# CONFIG_I2C_MUX is not set
+CONFIG_I2C_HELPER_AUTO=y
+
+#
+# I2C Hardware Bus support
+#
+
+#
+# I2C system bus drivers (mostly embedded / system-on-chip)
+#
+# CONFIG_I2C_DESIGNWARE_PLATFORM is not set
+# CONFIG_I2C_GPIO is not set
+# CONFIG_I2C_OCORES is not set
+# CONFIG_I2C_PCA_PLATFORM is not set
+# CONFIG_I2C_PXA_PCI is not set
+# CONFIG_I2C_SIMTEC is not set
+# CONFIG_I2C_XILINX is not set
+CONFIG_I2C_ZX29=y
+
+#
+# External I2C/SMBus adapter drivers
+#
+# CONFIG_I2C_PARPORT_LIGHT is not set
+# CONFIG_I2C_TAOS_EVM is not set
+
+#
+# Other I2C/SMBus bus drivers
+#
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+CONFIG_SPI=y
+# CONFIG_SPI_DEBUG is not set
+CONFIG_SPI_MASTER=y
+
+#
+# SPI Master Controller Drivers
+#
+# CONFIG_SPI_ALTERA is not set
+# CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_GPIO is not set
+# CONFIG_SPI_OC_TINY is not set
+# CONFIG_SPI_PXA2XX_PCI is not set
+# CONFIG_SPI_XILINX is not set
+# CONFIG_SPI_DESIGNWARE is not set
+# CONFIG_SPI_ZX297520V2 is not set
+CONFIG_SPI_ZX29=y
+#
+# SPI Protocol Masters
+#
+CONFIG_SPI_SPIDEV=y
+# CONFIG_SPI_TLE62X0 is not set
+# CONFIG_HSI is not set
+
+#
+# PPS support
+#
+# CONFIG_PPS is not set
+
+#
+# PPS generators support
+#
+
+#
+# PTP clock support
+#
+
+#
+# Enable Device Drivers -> PPS to see the PTP clock options.
+#
+CONFIG_ARCH_REQUIRE_GPIOLIB=y
+CONFIG_GPIOLIB=y
+# CONFIG_DEBUG_GPIO is not set
+CONFIG_GPIO_SYSFS=y
+
+#
+# Memory mapped GPIO drivers:
+#
+# CONFIG_GPIO_GENERIC_PLATFORM is not set
+CONFIG_GPIO_ZX29=y
+
+#
+# I2C GPIO expanders:
+#
+# CONFIG_GPIO_MAX7300 is not set
+# CONFIG_GPIO_MAX732X is not set
+# CONFIG_GPIO_PCF857X is not set
+# CONFIG_GPIO_SX150X is not set
+# CONFIG_GPIO_ADP5588 is not set
+
+#
+# PCI GPIO expanders:
+#
+
+#
+# SPI GPIO expanders:
+#
+# CONFIG_GPIO_MCP23S08 is not set
+
+#
+# AC97 GPIO expanders:
+#
+
+#
+# MODULbus GPIO expanders:
+#
+# CONFIG_W1 is not set
+CONFIG_POWER_SUPPLY=y
+CONFIG_POWER_SUPPLY_DEBUG=y
+# CONFIG_PDA_POWER is not set
+# CONFIG_TEST_POWER is not set
+# CONFIG_BATTERY_DS2780 is not set
+# CONFIG_BATTERY_DS2781 is not set
+# CONFIG_BATTERY_DS2782 is not set
+# CONFIG_BATTERY_SBS is not set
+# CONFIG_BATTERY_BQ24165 is not set
+# CONFIG_CHARGER_ZX234502 is not set
+# CONFIG_CHARGER_AW3215 is not set
+# CONFIG_CHARGER_SGM40561 is not set
+# CONFIG_BATTERY_BQ27x00 is not set
+# CONFIG_BATTERY_MAX17040 is not set
+# CONFIG_BATTERY_MAX17042 is not set
+# CONFIG_BATTERY_ANDROID is not set
+# CONFIG_CHARGER_MAX8903 is not set
+# CONFIG_CHARGER_LP8727 is not set
+# CONFIG_CHARGER_GPIO is not set
+# CONFIG_CHARGER_SMB347 is not set
+# CONFIG_HWMON is not set
+# CONFIG_THERMAL is not set
+# CONFIG_WATCHDOG is not set
+CONFIG_SSB_POSSIBLE=y
+
+#
+# Sonics Silicon Backplane
+#
+# CONFIG_SSB is not set
+CONFIG_BCMA_POSSIBLE=y
+
+#
+# Broadcom specific AMBA
+#
+# CONFIG_BCMA is not set
+
+#
+# Multifunction device drivers
+#
+CONFIG_MFD_CORE=y
+# CONFIG_MFD_88PM860X is not set
+# CONFIG_MFD_SM501 is not set
+# CONFIG_MFD_ASIC3 is not set
+# CONFIG_HTC_EGPIO is not set
+# CONFIG_HTC_PASIC3 is not set
+# CONFIG_HTC_I2CPLD is not set
+# CONFIG_TPS6105X is not set
+# CONFIG_TPS65010 is not set
+# CONFIG_TPS6507X is not set
+# CONFIG_MFD_TPS65217 is not set
+# CONFIG_MFD_TPS6586X is not set
+# CONFIG_MFD_TPS65910 is not set
+# CONFIG_MFD_TPS65912_I2C is not set
+CONFIG_MFD_ZX234290=y
+CONFIG_MFD_ZX234290_I2C=y
+# CONFIG_TWL4030_CORE is not set
+# CONFIG_TWL6040_CORE is not set
+# CONFIG_MFD_STMPE is not set
+# CONFIG_MFD_TC3589X is not set
+# CONFIG_MFD_TMIO is not set
+# CONFIG_MFD_T7L66XB is not set
+# CONFIG_MFD_TC6387XB is not set
+# CONFIG_MFD_TC6393XB is not set
+# CONFIG_PMIC_DA903X is not set
+# CONFIG_MFD_DA9052_I2C is not set
+# CONFIG_PMIC_ADP5520 is not set
+# CONFIG_MFD_MAX8925 is not set
+# CONFIG_MFD_MAX8997 is not set
+# CONFIG_MFD_MAX8998 is not set
+# CONFIG_MFD_S5M_CORE is not set
+# CONFIG_MFD_WM8400 is not set
+# CONFIG_MFD_WM831X_I2C is not set
+# CONFIG_MFD_WM8350_I2C is not set
+# CONFIG_MFD_WM8994 is not set
+# CONFIG_MFD_PCF50633 is not set
+# CONFIG_ABX500_CORE is not set
+# CONFIG_MFD_WL1273_CORE is not set
+# CONFIG_MFD_TPS65090 is not set
+# CONFIG_MFD_AAT2870_CORE is not set
+# CONFIG_MFD_RC5T583 is not set
+# CONFIG_REGULATOR is not set
+# CONFIG_MEDIA_SUPPORT is not set
+
+#
+# Graphics support
+#
+# CONFIG_DRM is not set
+# CONFIG_ION is not set
+# CONFIG_VGASTATE is not set
+# CONFIG_VIDEO_OUTPUT_CONTROL is not set
+CONFIG_FB=y
+CONFIG_FB_CFB_FILLRECT=y
+CONFIG_FB_CFB_COPYAREA=y
+CONFIG_FB_CFB_IMAGEBLIT=y
+CONFIG_FB_SYS_FOPS=y
+CONFIG_FB_LEADT15DS26=y
+# CONFIG_EXYNOS_VIDEO is not set
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
+# CONFIG_SOUND is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+# CONFIG_USB_ARCH_HAS_XHCI is not set
+# CONFIG_USB_SUPPORT is not set
+# CONFIG_MMC is not set
+# CONFIG_MEMSTICK is not set
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+
+#
+# LED drivers
+#
+# CONFIG_LEDS_LM3530 is not set
+# CONFIG_LEDS_PCA9532 is not set
+CONFIG_LEDS_GPIO=y
+# CONFIG_LEDS_LP3944 is not set
+# CONFIG_LEDS_LP5521 is not set
+# CONFIG_LEDS_LP5523 is not set
+# CONFIG_LEDS_PCA955X is not set
+# CONFIG_LEDS_PCA9633 is not set
+# CONFIG_LEDS_BD2802 is not set
+# CONFIG_LEDS_LT3593 is not set
+# CONFIG_LEDS_RENESAS_TPU is not set
+# CONFIG_LEDS_TCA6507 is not set
+# CONFIG_LEDS_ZX297520UFI is not set
+# CONFIG_LEDS_OT200 is not set
+CONFIG_LEDS_TRIGGERS=y
+
+#
+# LED Triggers
+#
+CONFIG_LEDS_TRIGGER_TIMER=y
+# CONFIG_LEDS_TRIGGER_HEARTBEAT is not set
+# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set
+# CONFIG_LEDS_TRIGGER_GPIO is not set
+# CONFIG_LEDS_TRIGGER_DEFAULT_ON is not set
+# CONFIG_SWITCH is not set
+# CONFIG_ACCESSIBILITY is not set
+CONFIG_RTC_LIB=y
+# CONFIG_RTC_CLASS is not set
+CONFIG_DMADEVICES=y
+# CONFIG_DMADEVICES_DEBUG is not set
+
+#
+# DMA Devices
+#
+CONFIG_ZX29_DMA=y
+# CONFIG_DW_DMAC is not set
+# CONFIG_TIMB_DMA is not set
+CONFIG_DMA_ENGINE=y
+
+#
+# DMA Clients
+#
+# CONFIG_ASYNC_TX_DMA is not set
+# CONFIG_DMATEST is not set
+# CONFIG_AUXDISPLAY is not set
+# CONFIG_UIO is not set
+
+#
+# Virtio drivers
+#
+# CONFIG_VIRTIO_BALLOON is not set
+# CONFIG_VIRTIO_MMIO is not set
+
+#
+# Microsoft Hyper-V guest support
+#
+# CONFIG_STAGING is not set
+CONFIG_CLKDEV_LOOKUP=y
+
+#
+# Hardware Spinlock drivers
+#
+# CONFIG_IOMMU_SUPPORT is not set
+
+#
+# Remoteproc drivers (EXPERIMENTAL)
+#
+
+#
+# Rpmsg drivers (EXPERIMENTAL)
+#
+# CONFIG_VIRT_DRIVERS is not set
+# CONFIG_PM_DEVFREQ is not set
+# CONFIG_RPM_ZX29 is not set
+# CONFIG_OS_EXTEND is not set
+# CONFIG_CPNV is not set
+
+#
+# File systems
+#
+# CONFIG_EXT2_FS is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_EXT4_FS is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_BTRFS_FS is not set
+# CONFIG_NILFS2_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+# CONFIG_FILE_LOCKING is not set
+# CONFIG_FSNOTIFY is not set
+# CONFIG_DNOTIFY is not set
+# CONFIG_INOTIFY_USER is not set
+# CONFIG_FANOTIFY is not set
+# CONFIG_QUOTA is not set
+# CONFIG_QUOTACTL is not set
+# CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
+
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_SYSCTL=y
+CONFIG_PROC_PAGE_MONITOR=y
+CONFIG_SYSFS=y
+# CONFIG_HUGETLB_PAGE is not set
+# CONFIG_CONFIGFS_FS is not set
+CONFIG_MISC_FILESYSTEMS=y
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+CONFIG_JFFS2_FS=y
+CONFIG_JFFS2_FS_DEBUG=0
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+CONFIG_JFFS2_FS_WBUF_VERIFY=y
+# CONFIG_JFFS2_SUMMARY is not set
+# CONFIG_JFFS2_FS_XATTR is not set
+CONFIG_JFFS2_COMPRESSION_OPTIONS=y
+# CONFIG_JFFS2_ZLIB is not set
+# CONFIG_JFFS2_LZO is not set
+CONFIG_JFFS2_LZMA=y
+# CONFIG_JFFS2_RTIME is not set
+# CONFIG_JFFS2_RUBIN is not set
+# CONFIG_JFFS2_CMODE_NONE is not set
+CONFIG_JFFS2_CMODE_PRIORITY=y
+# CONFIG_JFFS2_CMODE_SIZE is not set
+# CONFIG_JFFS2_CMODE_FAVOURLZO is not set
+# CONFIG_UBIFS_FS is not set
+# CONFIG_LOGFS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_SQUASHFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_OMFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_QNX6FS_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_PSTORE is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+# CONFIG_NLS is not set
+
+#
+# Kernel hacking
+#
+CONFIG_PRINTK_TIME=y
+CONFIG_DEFAULT_MESSAGE_LOGLEVEL=4
+CONFIG_ENABLE_WARN_DEPRECATED=y
+CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_FRAME_WARN=1024
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_STRIP_ASM_SYMS is not set
+# CONFIG_UNUSED_SYMBOLS is not set
+CONFIG_DEBUG_FS=y
+CONFIG_HEADERS_CHECK=y
+CONFIG_DEBUG_SECTION_MISMATCH=y
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_LOCKUP_DETECTOR is not set
+# CONFIG_HARDLOCKUP_DETECTOR_NMI is not set
+# CONFIG_HARDLOCKUP_DETECTOR_OTHER_CPU is not set
+# CONFIG_HARDLOCKUP_DETECTOR is not set
+CONFIG_DETECT_HUNG_TASK=y
+CONFIG_DEFAULT_HUNG_TASK_TIMEOUT=120
+# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
+CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
+# CONFIG_SCHED_DEBUG is not set
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_TIMER_STATS is not set
+# CONFIG_DEBUG_OBJECTS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_KMEMLEAK is not set
+# CONFIG_DEBUG_PREEMPT is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_SPARSE_RCU_POINTER is not set
+# CONFIG_LOCK_STAT is not set
+# CONFIG_DEBUG_ATOMIC_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+# CONFIG_STACKTRACE is not set
+# CONFIG_DEBUG_STACK_USAGE is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_BUGVERBOSE is not set
+CONFIG_DEBUG_INFO=y
+# CONFIG_DEBUG_INFO_REDUCED is not set
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_WRITECOUNT is not set
+# CONFIG_DEBUG_MEMORY_INIT is not set
+# CONFIG_DEBUG_LIST is not set
+# CONFIG_TEST_LIST_SORT is not set
+# CONFIG_DEBUG_SG is not set
+# CONFIG_DEBUG_NOTIFIERS is not set
+# CONFIG_DEBUG_CREDENTIALS is not set
+CONFIG_FRAME_POINTER=y
+# CONFIG_BOOT_PRINTK_DELAY is not set
+# CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_RCU_TRACE is not set
+# CONFIG_BACKTRACE_SELF_TEST is not set
+# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
+# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
+# CONFIG_LKDTM is not set
+# CONFIG_FAULT_INJECTION is not set
+# CONFIG_LATENCYTOP is not set
+# CONFIG_DEBUG_PAGEALLOC is not set
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
+CONFIG_HAVE_DYNAMIC_FTRACE=y
+CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
+CONFIG_HAVE_C_RECORDMCOUNT=y
+CONFIG_TRACING_SUPPORT=y
+# CONFIG_FTRACE is not set
+# CONFIG_BUILD_DOCSRC is not set
+# CONFIG_DYNAMIC_DEBUG is not set
+# CONFIG_DMA_API_DEBUG is not set
+# CONFIG_ATOMIC64_SELFTEST is not set
+# CONFIG_SAMPLES is not set
+CONFIG_HAVE_ARCH_KGDB=y
+# CONFIG_KGDB is not set
+# CONFIG_TEST_KSTRTOX is not set
+# CONFIG_STRICT_DEVMEM is not set
+# CONFIG_ARM_UNWIND is not set
+# CONFIG_DEBUG_USER is not set
+# CONFIG_DEBUG_RODATA is not set
+# CONFIG_DEBUG_LL is not set
+# CONFIG_ACCURATE_CPU_PERCENT is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY_DMESG_RESTRICT is not set
+# CONFIG_SECURITY is not set
+# CONFIG_SECURITYFS is not set
+CONFIG_DEFAULT_SECURITY_DAC=y
+CONFIG_DEFAULT_SECURITY=""
+# CONFIG_CRYPTO is not set
+# CONFIG_BINARY_PRINTF is not set
+
+#
+# Library routines
+#
+CONFIG_BITREVERSE=y
+CONFIG_GENERIC_PCI_IOMAP=y
+CONFIG_GENERIC_IO=y
+# CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
+# CONFIG_CRC_T10DIF is not set
+# CONFIG_CRC_ITU_T is not set
+CONFIG_CRC32=y
+# CONFIG_CRC32_SELFTEST is not set
+CONFIG_CRC32_SLICEBY8=y
+# CONFIG_CRC32_SLICEBY4 is not set
+# CONFIG_CRC32_SARWATE is not set
+# CONFIG_CRC32_BIT is not set
+# CONFIG_CRC7 is not set
+# CONFIG_LIBCRC32C is not set
+# CONFIG_CRC8 is not set
+CONFIG_LZMA_COMPRESS=y
+CONFIG_LZMA_DECOMPRESS=y
+# CONFIG_XZ_DEC is not set
+# CONFIG_XZ_DEC_BCJ is not set
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
+# CONFIG_AVERAGE is not set
+# CONFIG_CORDIC is not set
diff --git a/lynq/S300/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/etc/rc b/lynq/S300/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/etc/rc
new file mode 100755
index 0000000..50db166
--- /dev/null
+++ b/lynq/S300/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/etc/rc
@@ -0,0 +1,302 @@
+#!/bin/sh
+
+/bin/mount -t proc proc /proc
+
+echo "Starting mdevd..."
+/bin/mount -t tmpfs mdev /dev
+/bin/mount -t sysfs sysfs /sys
+echo /sbin/mdev > /proc/sys/kernel/hotplug
+#/sbin/mdev -s
+
+
+/bin/mount   -t  tmpfs -o rw,nosuid,nodev,noexec  tmpfs    /tmp
+mkdir /dev/pts
+#mkdir /dev/shm
+/bin/mount   -t  devpts  devpts   /dev/pts
+#/bin/mount   -t  tmpfs   tmpfs    /dev/shm
+/bin/mount   -t  debugfs none     /sys/kernel/debug
+#mount -t jffs2 -o ro mtd:nvrofs /mnt/nvrofs
+mount -t jffs2 -o ro mtd:imagefs /mnt/imagefs
+#mount -t jffs2 mtd:userdata /mnt/userdata
+mdev -s
+fs_check "normal"
+
+#insmod /lib/cpko/cpko.ko
+
+###############zram#################
+echo 80 > /proc/sys/vm/swappiness
+echo 12582912 > /sys/block/zram0/disksize
+mkswap /dev/zram0
+swapon /dev/zram0
+
+#cat /etc/motd
+mkdir -p /mnt/userdata/cache /mnt/userdata/etc_rw /mnt/userdata/var
+echo 1 > /proc/sys/kernel/sysentry
+
+ln -s /tmp /tmp/local
+ln -s /tmp /tmp/tmp
+
+mkdir -p /tmp/mnt
+
+#####sunquan start
+mkdir -p /var/local/tmp/ppp/status
+mkdir -p /var/local/tmp/ppp/peers
+#####sunquan end
+
+mkdir -p /var/run
+mkdir -p /var/log
+mkdir -p /var/db
+mkdir -p /var/ct/tmp
+
+############TZ Support##############
+if [ ! -e /etc_rw/TZ ];then
+    cp /etc/TZ /etc_rw/TZ
+fi
+
+#echo off > /sys/kernel/debug/kmemleak
+echo 32768 > /proc/sys/kernel/msgmnb
+#####sunquan start
+ifconfig lo 127.0.0.1 up
+#####sunquan end
+
+# insmod drivers
+#KVER=`uname -r | cut -f 1 -d '-'`
+KVER=`uname -r`
+
+#####sunquan start
+mknod /dev/myioctl   c 222 0
+#####sunquan end
+
+MODULE_PATH=/lib/modules/$KVER/net
+
+#####sunquan start
+#insert ipt modules
+if [ -f $MODULE_PATH/nf_conntrack_rtsp.ko ]; then
+	insmod $MODULE_PATH/nf_conntrack_rtsp.ko
+fi
+if [ -f $MODULE_PATH/nf_nat_rtsp.ko ]; then
+	insmod $MODULE_PATH/nf_nat_rtsp.ko
+fi
+if [ -f $MODULE_PATH/ipt_classify.ko ]; then
+	insmod $MODULE_PATH/ipt_classify.ko
+fi
+if [ -f $MODULE_PATH/xt_webstr.ko ]; then
+	insmod $MODULE_PATH/xt_webstr.ko
+fi
+#####sunquan end
+
+SOUND_PATH=/lib/modules/$KVER/kernel/sound
+#insert sound modules
+#snd-soc-core.ko depends on regmap-i2c.ko
+if [ -f /lib/modules/$KVER/kernel/drivers/base/regmap/regmap-i2c.ko ]; then
+	insmod /lib/modules/$KVER/kernel/drivers/base/regmap/regmap-i2c.ko
+fi
+if [ -f $SOUND_PATH/soundcore.ko ]; then
+	insmod $SOUND_PATH/soundcore.ko
+fi
+if [ -f $SOUND_PATH/core/snd.ko ]; then
+	insmod $SOUND_PATH/core/snd.ko
+fi
+if [ -f $SOUND_PATH/core/snd-timer.ko ]; then
+	insmod $SOUND_PATH/core/snd-timer.ko
+fi
+if [ -f $SOUND_PATH/core/snd-page-alloc.ko ]; then
+	insmod $SOUND_PATH/core/snd-page-alloc.ko
+fi
+if [ -f $SOUND_PATH/core/snd-pcm.ko ]; then
+	insmod $SOUND_PATH/core/snd-pcm.ko
+fi
+if [ -f $SOUND_PATH/soc/snd-soc-core.ko ]; then
+	insmod $SOUND_PATH/soc/snd-soc-core.ko
+fi
+if [ -f $SOUND_PATH/soc/codecs/snd-soc-tlv320aic31XX.ko ]; then
+	insmod $SOUND_PATH/soc/codecs/snd-soc-tlv320aic31XX.ko
+fi
+if [ -f $SOUND_PATH/soc/sanechips/snd-soc-zx29-i2s.ko ]; then
+	insmod $SOUND_PATH/soc/sanechips/snd-soc-zx29-i2s.ko
+fi
+if [ -f $SOUND_PATH/soc/sanechips/snd-soc-zx29-pcm.ko ]; then
+	insmod $SOUND_PATH/soc/sanechips/snd-soc-zx29-pcm.ko
+fi
+if [ -f $SOUND_PATH/soc/sanechips/snd-soc-zx297520v3-ti3100.ko ]; then
+	insmod $SOUND_PATH/soc/sanechips/snd-soc-zx297520v3-ti3100.ko
+fi
+
+##### for app core dump start
+#ulimit -c unlimited 
+#mkdir -p /cache/pid-core-dumps
+#echo /cache/pid-core-dumps/core.%e > /proc/sys/kernel/core_pattern
+##### for app core dump end
+
+echo 2048 > /proc/sys/vm/min_free_kbytes
+echo 2 > /proc/sys/vm/min_free_order_shift
+
+#nvserver &
+
+cmdline=$(cat /proc/cmdline)
+result=$(echo $cmdline | grep "bootmode=")
+if [[ "$result" != "" ]]; then
+ bootmode=${cmdline##*bootmode=}
+ bootmode=${bootmode%% *}
+else
+ bootmode="0"
+fi
+bootreason="${cmdline##*boot_reason=}"
+bootreason=${bootreason%% *}
+
+#nvserver &
+echo 0 > /etc_rw/wifiStatus
+echo 0 > /etc_rw/wpsStatus
+echo F > /etc_rw/staStatus
+echo 0 > /etc_rw/qrStatus
+echo 0 > /etc_rw/wpsdisplayStatus
+zte_mifi $bootreason $bootmode &
+nv set bootreason=$bootreason
+#echo 1 >/sys/dwc_usb/usbconfig/usbPlug
+
+
+if [[ $bootmode == "amt" ]]; then
+ nv set ver_mode=0
+#zte_usbCfgMng &
+zte_log_agent &
+
+ zte_amt -p 10027 &
+
+
+adbd &
+
+ exit 0
+fi
+modetype=$(nv getro usb_modetype)
+nv set ver_mode=1
+
+
+#####sunquan start
+#syslogd -O /syslogd.log -l 2 -s 1024 &
+sysctl -w net.unix.max_dgram_qlen=5000
+#syslogd -l 2 -s 10240 -f /etc/syslog.conf &
+#####sunquan end
+
+#zte_locknet &
+#at_ctl $bootreason 2>&1 1>/dev/null &
+
+#zte_drvComMng &
+#rtc-service &
+
+bootflag=$(nv get LanEnable)
+
+if [[ $bootreason == "10" ]]; then
+ nv set ver_mode=2
+fi
+
+if [[ $bootflag == "1" ]]; then
+if [[ $bootreason == "2" ]]; then
+ #zte_mmi poweroff_charger &
+# zte_usbCfgMng poweroff_charger &
+# zte_mainctrl poweroff_charger &
+ #zte_watchdog &
+ if [[ $modetype != "user" ]]; then
+adbd &
+fi
+ #zte_log_agent &
+ exit 0
+fi
+fi
+
+#zte_usbCfgMng &
+
+#if [[ $bootflag == "1" ]]; then
+#zte_mmi &
+#fi
+
+echo /sbin/modprobe -d /lib/modules/$KVER > /proc/sys/kernel/modprobe
+
+#####sunquan start
+echo 2 > /proc/sys/net/ipv6/conf/default/accept_dad
+echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
+#####sunquan end
+
+# start the page cache/kmem cache cleanup timer in the kernel
+echo 1 > /proc/sys/vm/drop_caches
+
+#####sunquan start
+# Change default NAT policy of UDP sessions, per Win7 Logo
+# requirement for Xbox-Live. The defaut session timeout on
+# linux 3.4.5 was 30 seconds. Win7 logo requires at least
+# 70.
+echo 120 > /proc/sys/net/ipv4/netfilter/ip_conntrack_udp_timeout
+
+# treat reset close session as fin close session, set same timeout
+# this is required to pass CDRouter NAT timeout test case.
+echo 120 > /proc/sys/net/ipv4/netfilter/ip_conntrack_tcp_timeout_close
+
+# add this to support up to 20 PPTP tunnel
+echo 40 > /proc/sys/net/netfilter/nf_conntrack_expect_max
+#####sunquan end
+
+echo 0 > /proc/sys/kernel/panic
+echo 1 > /proc/sys/kernel/panic_on_oops
+echo 2 > /proc/sys/vm/panic_on_oom
+
+#add for adbd
+chmod a+rw /dev/android_adb /dev/ptmx
+chmod 640  /etc/shadow
+#mkdir -p /system/bin
+#ln -s /bin/busybox /system/bin/sh
+
+# apps start
+#internet.sh
+#zte_mainctrl &
+
+#if [[ $bootflag == "1" ]]; then
+# wifiÒª»ùÓÚÄÚÍø×öÅäÖ㬱ØÐëÆô¶¯ÔÚÄÚÍøºóÃæ
+#wifi_manager &
+#fi
+
+zte_log_agent &
+
+#zte_hotplug &
+
+#zte_watchdog &
+
+if [[ $bootflag == "1" ]]; then
+#fluxstat &
+#sntp &
+goahead &
+#sd_hotplug &
+#ccapp &
+#sms &
+#phonebook &
+fi
+
+if [[ $modetype != "user" ]]; then
+adbd &
+fi
+#mode_test&
+
+echo "Starting FOTA apps......!!"
+#/sbin/start_update_app.sh &
+
+if [[ $bootflag == "1" ]]; then
+#/usr/sbin/telnetd -p 4719 &
+/sbin/start_telnetd.sh &
+fi
+
+# for debug
+netdog_init_set.sh
+#chmod +x /sbin/app_monitor.sh
+#app_monitor.sh open
+
+echo 0 > /proc/sys/kernel/hung_task_timeout_secs
+rm -rf /etc_rw/udhcpd*.pid
+sh /sbin/rm_dev.sh
+echo 1800 > /sys/module/net_ext_modul/parameters/skb_num_limit
+echo 700 > /sys/module/net_ext_modul/parameters/skb_max_panic
+echo 2000 > /proc/sys/net/nf_conntrack_max
+
+cwmpflag=$(nv get cwmp_enable)
+
+if [[ $cwmpflag == "1" ]]; then
+cwmpd &
+fi
+sh /sbin/rtl8192_calibrate.sh 1 &
diff --git a/lynq/S300/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/etc_ro/config/db/netprovider.db b/lynq/S300/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/etc_ro/config/db/netprovider.db
new file mode 100755
index 0000000..17bcdf2
--- /dev/null
+++ b/lynq/S300/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/etc_ro/config/db/netprovider.db
Binary files differ
diff --git a/lynq/S300/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/etc_ro/default/default_parameter_sys b/lynq/S300/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/etc_ro/default/default_parameter_sys
new file mode 100755
index 0000000..5fe73d0
--- /dev/null
+++ b/lynq/S300/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/etc_ro/default/default_parameter_sys
@@ -0,0 +1,401 @@
+
+######SOFTAPרÓà START###################################
+check_roam=yes
+gsm_signalbar0_low=0
+gsm_signalbar0_high=0
+gsm_signalbar1_low=1
+gsm_signalbar1_high=2
+gsm_signalbar2_low=3
+gsm_signalbar2_high=6
+gsm_signalbar3_low=7
+gsm_signalbar3_high=9
+gsm_signalbar4_low=10
+gsm_signalbar4_high=12
+gsm_signalbar5_low=13
+gsm_signalbar5_high=31
+wcdma_signalbar0_low=0
+wcdma_signalbar0_high=0
+wcdma_signalbar1_low=1
+wcdma_signalbar1_high=8
+wcdma_signalbar2_low=9
+wcdma_signalbar2_high=16
+wcdma_signalbar3_low=17
+wcdma_signalbar3_high=22
+wcdma_signalbar4_low=23
+wcdma_signalbar4_high=28
+wcdma_signalbar5_low=29
+wcdma_signalbar5_high=91
+tds_signalbar0_low=0
+tds_signalbar0_high=0
+tds_signalbar1_low=1
+tds_signalbar1_high=8
+tds_signalbar2_low=9
+tds_signalbar2_high=16
+tds_signalbar3_low=17
+tds_signalbar3_high=22
+tds_signalbar4_low=23
+tds_signalbar4_high=28
+tds_signalbar5_low=29
+tds_signalbar5_high=91
+lte_signalbar0_low=0
+lte_signalbar0_high=0
+lte_signalbar1_low=1
+lte_signalbar1_high=25
+lte_signalbar2_low=26
+lte_signalbar2_high=32
+lte_signalbar3_low=33
+lte_signalbar3_high=38
+lte_signalbar4_low=39
+lte_signalbar4_high=44
+lte_signalbar5_low=45
+lte_signalbar5_high=97
+need_cops_number_format=yes
+need_display_searching_status=yes
+need_restart_when_sim_insert=yes
+need_support_pb=yes
+need_support_sms=yes
+network_need_gsm=yes
+network_need_tds=yes
+product_model=MF910W
+roam_setting_option=on
+use_lock_net=no
+network_category_based_on=act
+admin_user=admin
+appKeyMobile=A100000853
+Brand=DEMO
+hostName=dm.wo.com.cn
+Intype=DEMO
+Manuf=
+Model=
+portNum=6001
+registerDmType=0
+secsTime=1
+versionPrevious=
+wa_version=
+OSVersion=1
+OS=TOS
+urlMobile=
+DNS_proxy=
+dnsmasqfile=/var/log/dnsmasq.log
+dnsmasqfileSize=1024
+lan_domain_Enabled=1
+auto_connect_when_limited=no
+is_traffic_aline_on=no
+is_traffic_alining=no
+is_traffic_limit_on=no
+keep_online_when_limited=no
+traffic_sms_number=0
+update_type=mifi_fota
+
+fota_device_type=mifi
+fota_models=ZTE7520V3
+fota_oem=ZTE
+fota_platform=ZX297520
+fota_dm_vendor=rs
+fota_token_rs=8msgzdxxftrtys0irnuifh7o
+fota_product_id=1549891427
+fota_product_secret=f631eba30dc94546ad3f1cd38327af32
+fota_app_version=2
+fota_network_type=WIFI
+fota_token_zx=7CBE016400F65621740A04E742E6FB12
+fota_dl_url_zx=
+fota_chk_url_zx=
+fota_reg_url_zx=
+fota_report_dlr_url_zx=
+fota_report_upgr_url_zx=
+fota_report_sales_url_zx=
+fota_token_gs=97a53ee9f45adfe53c762a72f83f6f43
+fota_dl_url_gs=
+fota_chk_url_gs=
+fota_reg_url_gs=
+fota_report_dlr_url_gs=
+fota_report_upgr_url_gs=
+fota_report_sales_url_gs=
+fota_update_space_threshold=200
+Login=admin
+Password=
+sntp_server_count=3
+MAX_Station_num=16
+wifi_key_gen_type=DEFAULT
+wifi_key_len=8
+wifi_key_only_digit=y
+wifi_lte_intr=1
+wifi_ssid_gen_with_mac_lastbyte=6
+wifi_key_gen_with_mac_lastbyte=8
+wifi_mac_num=2
+wifiwan=wlan0-vxd
+wifiwan_mode=dhcp
+wifi_calibrated=0
+idle_time="600"
+product_type=1
+errnofile=/usr/netlog/errno.log
+errnofileSize=1024
+hotplugfile=/usr/netlog/hotplug.log
+hotplugfileSize=1024
+mynetlinkfile=/usr/netlog/mynetlink.log
+mynetlinkfileSize=1024
+telnetd_enable=n
+print_level=2
+syslog_level=4
+telog_path=/dev/ttyS1
+skb_debug=
+seclog_switch=
+################SOFTAPרÓà END#####################################
+
+######USB¶Ë¿ÚÅäÖÃ#######
+
+##########usb/rj45µÈÈȰβåÏà¹ØÂ·¾¶##############
+#rj45³õʼ״̬·¾¶
+rj45_plugstate_path=/sys/kernel/eth_debug/eth_state
+#usbÍø¿ÚÃû·¾¶
+usb_name_path=/sys/dwc_usb/usbconfig/netname
+#usb¸÷Íø¿Ú״̬·¾¶
+usb_plugstate_path=/sys/dwc_usb/usbconfig/
+################################################
+
+#ÅäÖÃÊÇ·ñÓйâÅÌ
+cdrom_state=1
+#cdromµÚ¶þ½×¶Îö¾Ù£º0Ϊ²»ÐèҪö¾Ù£¬1ΪÐèҪö¾ÙÇÒÐèÒª¹ÒÔØ½éÖÊ£¬2Ϊ²»ÐèÒª¹ÒÔØ½éÖÊ#
+need_support_cdrom_step2=0
+
+#ÅäÖÃWindowsÏÂÍø¿¨ÀàÐÍ
+select_type=select_rndis
+
+####
+#ÅäÖÃÑз¢Ä£Ê½usbÉ豸¶Ë¿Ú×éºÏ
+usb_devices_debug=diag,adb,serial
+
+#ÅäÖÃÓû§Ä£Ê½usbÉ豸¶Ë¿Ú×éºÏ
+usb_devices_user=
+
+#ÅäÖÃÉú²úģʽusbÉ豸¶Ë¿Ú×éºÏ
+usb_devices_factory=serial,diag
+
+#ÅäÖÃAMTģʽusbÉ豸¶Ë¿Ú×éºÏ
+usb_devices_amt=serial,diag
+
+#ÅäÖÃÑз¢Ä£Ê½acm´®¿Ú¸öÊý
+usb_acm_num_debug=0
+
+#ÅäÖÃÑз¢Ä£Ê½serial´®¿Ú¸öÊý
+usb_serial_num_debug=2
+
+#ÅäÖÃÓû§Ä£Ê½acm´®¿Ú¸öÊý
+usb_acm_num_user=0
+
+#ÅäÖÃÓû§Ä£Ê½serial´®¿Ú¸öÊý
+usb_serial_num_user=0
+
+#ÅäÖÃÉú²úģʽacm´®¿Ú¸öÊý
+usb_acm_num_factory=0
+
+#ÅäÖÃÉú²úģʽserial´®¿Ú¸öÊý
+usb_serial_num_factory=1
+
+#ÅäÖÃAMTģʽacm´®¿Ú¸öÊý
+usb_acm_num_amt=0
+
+#ÅäÖÃAMTģʽserial´®¿Ú¸öÊý
+usb_serial_num_amt=2
+
+#wangzhen
+#ÅäÖÃdebugģʽmass_storageµÄlunµÄģʽ
+usb_lun_type_debug=
+
+#ÅäÖÃuserģʽmass_storageµÄlunµÄģʽ
+usb_lun_type_user=
+
+#ÅäÖÃcdromģʽmass_storageµÄlunµÄģʽ
+usb_lun_type_cdrom=
+###
+
+#ÅäÖÃÑз¢Ä£Ê½Íø¿ÚΪNDISʱÉ豸µÄPID
+PID_TSP_NDIS=0581
+###
+
+#ÅäÖÃÑз¢Ä£Ê½Íø¿ÚΪRNDISʱÉ豸µÄPID
+PID_TSP_RNDIS=0581
+
+#ÅäÖÃÑз¢Ä£Ê½Íø¿ÚΪECMʱÉ豸µÄPID
+PID_TSP_ECM=0581
+
+#ÅäÖÃÑз¢Ä£Ê½Ò쳣ʱÉ豸µÄPID
+PID_TEST=ff00
+
+#ÅäÖÃÑÛͼģʽʱÉ豸µÄPID
+PID_YT=0580
+
+#ÅäÖÃÑз¢Ä£Ê½¹âÅÌCDROMµÄPID
+PID_TSP_CDROM=0548
+
+#####
+
+#ÅäÖÃÓû§Ä£Ê½Ä£Ê½¹âÅÌCDROMµÄPID
+PID_USER_CDROM=1225
+
+#####
+#######
+#ÅäÖÃÓû§Ä£Ê½Íø¿ÚΪRNDISʱÉ豸µÄPID
+PID_USER_RNDIS=1557
+
+#ÅäÖÃÓû§Ä£Ê½Íø¿ÚΪECMʱÉ豸µÄPID
+PID_USER_ECM=1557
+
+#ÅäÖÃÓû§Ä£Ê½Íø¿ÚΪNDISʱÉ豸µÄPID
+PID_USER_NDIS=1557
+
+#ÅäÖÃÓû§Ä£Ê½Ã»ÓÐÍø¿ÚʱÉ豸µÄPID
+PID_USER_NOVNIC=0580
+######
+
+#ÅäÖÃËÀ»útrapʱÉ豸µÄPID
+PID_TRAP=0197
+
+#ÅäÖÃÉú²úģʽʱÉ豸µÄPID
+PID_FACTORY=0534
+
+#ÅäÖÃAMTģʽʱÉ豸µÄPID
+PID_AMT=0201
+
+#ÅäÖùػú³äµçʱÉ豸µÄPID
+PID_FASTPOWEROFF=2004
+
+#ÅäÖÃÉ豸µÄVID
+VID_TSP=19D2
+
+#ÅäÖÃÉ豸µÄiSerial×Ö·û´®
+SERIAL_TSP=1234567890ABCDEF
+
+#ÅäÖÃÑз¢Ä£Ê½É豸µÄReleaseID
+RELEASEID_TSP=0100
+
+#ÅäÖÃÓû§Ä£Ê½É豸µÄReleaseID
+RELEASEID_USER=0101
+
+#ÅäÖÃÉ豸µÄmanufacturer×Ö·û´®
+MANUFACTURER_TSP=DEMO,Incorporated
+
+#ÅäÖÃÉ豸µÄproduct×Ö·û´®
+PRODUCT_TSP=DEMO Mobile Boardband
+
+#ÅäÖÃÉ豸µÄconfig×Ö·û´®
+CONFIG_TSP=DEMO Configuration
+
+#cdrom lunµÄvendor×Ö·û´®
+VENDOR_MS_CDROM=DEMO
+
+#cdrom lunµÄproduct×Ö·û´®
+PRODUCT_MS_CDROM=USB SCSI CD-ROM
+
+#cdrom lunµÄrelease×Ö·û´®
+RELEASE_MS_CDROM=2.31
+
+#cdrom lunµÄinquiry×Ö·û´®
+INQUIRY_MS_CDROM=DEMO USB SCSI CD-ROM 2.31
+#mmc lunµÄvendor×Ö·û´®
+VENDOR_MS_MMC=DEMO
+
+#mmc lunµÄproduct×Ö·û´®
+PRODUCT_MS_MMC=MMC Storage
+
+#mmc lunµÄrelease×Ö·û´®
+RELEASE_MS_MMC=2.31
+
+#SD½éÖÊ·¾¶
+usb_tcard_lun_path=/dev/mmcblk0
+
+#mmc lunµÄinquiry×Ö·û´®
+INQUIRY_MS_MMC=DEMO MMC Storage 2.31
+
+#ÅäÖÃECMÍø¿¨¸öÊý
+ECM_NUM=1
+
+#ÅäÖÃRNDISÍø¿¨×î´ó×é°üÊý
+RNDIS_PKT_NUM=10
+
+
+###²¨ÌØÂÊ×ÔÊÊÓ¦¿ª¹Ø###
+self_adaption_port=
+###ijЩ¶Ë¿Ú²»ÐèÒªÏòÓ¦ÓÃÉϱ¨¶Ë¿Ú×¼±¸ºÃÏûÏ¢###
+notify_forbiden_ports=
+
+######USB¶Ë¿ÚÅäÖÃEND#######
+
+######CP²àNVÅäÖÃÐÅÏ¢#######
+#ÄÚ²¿Èí¼þ°æ±¾ºÅ
+zversion=K318V1.0.0B03
+#ÍⲿÈí¼þ°æ±¾ºÅ
+zcgmr=DEMO_V1.0.0B03
+#Ó²¼þ°æ±¾ºÅ
+zhver=V0.1
+#ÄÚ²¿»úÐÍ
+zcgmm=K318
+#Íⲿ»úÐÍ
+zcgmw=K318
+#³§ÉÌÐÅÏ¢
+zcgmi=DEMO
+#SSIDºÅ
+zssid=0
+#WifiKeyµÄÖµ
+zwifikey=0
+#ËøÍø×î´ó½âËø´ÎÊý£¬ËøÍøÄ£¿éʹÓÃ
+zunlocktimes=3
+#°æ±¾Ä£Ê½ÀàÐÍ£¬Õý³£°æ±¾/¹Ò²à°æ±¾
+zversionmode=0
+#ÖÇÄܶÌÐŹ¦ÄÜ¿ª¹Ø
+zisms=0
+#DM¹¦ÄÜ¿ª¹Ø,0:¹Ø±Õ£¬1ÒÆ¶¯£¬2ÁªÍ¨£¬3µçÐÅ
+zdmreg=0
+#ÁªÍ¨DM ×¢²á¿ª»úµÈ´ýʱ¼ä, 1~60 ÓÐЧ£¬µ¥Î»·ÖÖÓ£¬ÆäËûÊýÖµ: ÎÞЧֵ
+zdmregtime=0
+#×Ô¶¯ËÑÍø·½Ê½ÍøÂç½ÓÈë´ÎÐò
+auto_acqorder=
+#¹¤¾ßlog ´æÈ¡
+zcat_mode=
+#ÕÕÏà»úͼƬ·Ö±æÂÊÏÔʾ¿ØÖÆ
+zcamera_interprolation=1
+######CP²àNVÅäÖÃÐÅÏ¢END#######
+
+#for volte
+MTNET_TEST=0
+NSIOT_TEST=0
+amrw=1
+cvmod_ims=3
+EM_CALL_SUPPORT=0
+EMCALL_TO_NORMAL=0
+IMS_APN=
+IMS_CONFURI=
+IMS_URI_TYPE=0
+IMS_REG_EXPIRES=600000
+IMS_REG_SUB_EXPIRES=600000
+NET_IMS_CAP=0
+UDP_THRESH=1300
+IPSEC_DISABLE=0
+PRECONDTION_NOT_SUPPORT=0
+WAIT_RPT_TIME=1000
+OCT_ALGN_AMR=0
+SMS_OVER_IP=1
+IMS_USER_AGENT=
+BSF_PORT=8080
+XCAP_PORT=80
+UT_APN=
+380_THEN_CSFB=0
+DTMF_RFC4733=0
+DIALOG_FORK=0
+DATA_CENTRIC=0
+not_supp_hmac_sha1_96=0
+not_supp_hmac_md5_96=0
+not_supp_des_ede3_cbc=0
+not_supp_aes_cbc=0
+IPV4_PCSCF_ADDR=
+IPV6_PCSCF_ADDR=
+IMS_KOREA_TEST=0
+PCSCF_TEST_ENABLE=0
+G_IMS_CMGF=0
+IMS_SMS_URI_TYPE=0
+IMS_CC_URI_TYPE=0
+T3396_SUPPORT=0
+T3396_CAUSE_REASON=8,27,32,33
+T3396_DURATION=720
+T3396_COUNTS=3
+#for volte end
diff --git a/lynq/S300/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/etc_ro/default/default_parameter_user b/lynq/S300/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/etc_ro/default/default_parameter_user
new file mode 100755
index 0000000..35d52e3
--- /dev/null
+++ b/lynq/S300/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/etc_ro/default/default_parameter_user
@@ -0,0 +1,490 @@
+apn_auto_config=CMCC($)cmnet($)manual($)*99#($)pap($)($)($)IP($)auto($)($)auto($)($)
+APN_config0=Default($)Default($)manual($)($)($)($)($)IP($)auto($)($)auto($)($)
+APN_config1=
+APN_config2=
+APN_config3=
+APN_config4=
+APN_config5=
+APN_config6=
+APN_config7=
+APN_config8=
+APN_config9=
+apn_index=0
+apn_mode=auto
+at_snap_flag=3
+at_wifi_mac=0
+auto_apn_index=0
+cid_reserved=0
+clear_pb_when_restore=no
+clear_sms_when_restore=no
+default_apn=3gnet
+ipv6_APN_config1=
+ipv6_APN_config2=
+ipv6_APN_config3=
+ipv6_APN_config4=
+ipv6_APN_config5=
+ipv6_APN_config6=
+ipv6_APN_config7=
+ipv6_APN_config8=
+ipv6_APN_config9=
+m_profile_name=Internux
+need_init_modem=yes
+net_select=NETWORK_auto
+pdp_type=IP
+ppp_apn=
+max_reconnect_time=3000000
+pppd_auth=noauth
+ppp_auth_mode=none
+ppp_passwd=
+ppp_pdp_type=
+ppp_username=
+ipv6_ppp_auth_mode=none
+ipv6_ppp_passwd=
+ipv6_ppp_username=
+pre_mode=
+prefer_dns_manual=0.0.0.0
+standby_dns_manual=0.0.0.0
+wan_apn=internet
+wan_dial=
+cta_test=0
+safecare_enbale=0
+safecare_hostname=mob.3gcare.cn
+safecare_registed_imei=
+safecare_registed_iccid=
+safecare_contimestart1=
+safecare_contimestart2=
+safecare_contimestart3=
+safecare_contimestop1=
+safecare_contimestop2=
+safecare_contimestop3=
+safecare_contimeinterval=
+safecare_mobsite=http://mob.3gcare.cn
+safecare_chatsite=
+safecare_platno=
+safecare_mobilenumber=
+safecare_version=
+ethwan_dns_mode=auto
+pswan_dns_mode=auto
+wifiwan_dns_mode=auto
+ethwan_ipv6_dns_mode=auto
+wifiwan_ipv6_dns_mode=auto
+pswan_ipv6_dns_mode=auto
+admin_Password=admin
+psw_changed=1
+alg_ftp_enable=0
+alg_sip_enable=0
+blc_wan_auto_mode=AUTO_PPP
+blc_wan_mode=AUTO
+br_ipchange_flag=
+br_node=usblan0+eth0
+clat_fake_subnet=192.0.168.0
+clat_frag_collect_timeout=300
+clat_local_mapping_timeout=300
+clat_mapping_record_timeout=3000
+clat_query_server_port=1464
+DefaultFirewallPolicy=0
+dev_coexist=0
+dhcpDns=192.168.0.1
+dhcpEnabled=1
+dhcpEnd=192.168.0.200
+dhcpLease_hour=24
+dhcpStart=192.168.0.100
+dhcpv6stateEnabled=0
+dhcpv6statelessEnabled=1
+dhcpv6statePdEnabled=0
+dial_mode=auto_dial
+DMZEnable=0
+DMZIPAddress=
+dns_extern=
+ipv6_dns_extern=
+eth_act_type=
+eth_type=lan
+ethlan=eth0
+ethwan=eth0
+ethwan_dialmode=auto
+ethwan_mode=auto
+ethwan_priority=3
+fast_usb=usblan0
+fastnat_level=2
+IPPortFilterEnable=0
+IPPortFilterRules_0=
+IPPortFilterRules_1=
+IPPortFilterRules_2=
+IPPortFilterRules_3=
+IPPortFilterRules_4=
+IPPortFilterRules_5=
+IPPortFilterRules_6=
+IPPortFilterRules_7=
+IPPortFilterRules_8=
+IPPortFilterRules_9=
+IPPortFilterRulesv6_0=
+IPPortFilterRulesv6_1=
+IPPortFilterRulesv6_2=
+IPPortFilterRulesv6_3=
+IPPortFilterRulesv6_4=
+IPPortFilterRulesv6_5=
+IPPortFilterRulesv6_6=
+IPPortFilterRulesv6_7=
+IPPortFilterRulesv6_8=
+IPPortFilterRulesv6_9=
+ipv4_fake_subnet=192.0.0.0
+ipv6_fake_subnet=2016::1
+lan_ipaddr=192.168.0.1
+lan_name=br0
+lan_netmask=255.255.255.0
+LanEnable=1
+mac_ip_list=
+mgmt_quicken_power_on=0
+mtu=1400
+natenable=
+dosenable=0
+need_jilian=1
+nofast_port=21+22+23+25+53+67+68+69+110+115+123+443+500+1352+1723+1990+1991+1992+1993+1994+1995+1996+1997+1998+4500+5060
+nv_save_interval=300
+path_conf=/etc_rw
+path_ro=/etc_ro
+path_log=/var/log/
+path_sh=/sbin
+path_tmp=/tmp
+permit_gw=
+permit_ip6=
+permit_nm=255.255.255.0
+PortForwardEnable=0
+PortForwardRules_0=
+PortForwardRules_1=
+PortForwardRules_2=
+PortForwardRules_3=
+PortForwardRules_4=
+PortForwardRules_5=
+PortForwardRules_6=
+PortForwardRules_7=
+PortForwardRules_8=
+PortForwardRules_9=
+PortMapEnable=0
+PortMapRules_0=
+PortMapRules_1=
+PortMapRules_2=
+PortMapRules_3=
+PortMapRules_4=
+PortMapRules_5=
+PortMapRules_6=
+PortMapRules_7=
+PortMapRules_8=
+PortMapRules_9=
+ppp_name=ppp0
+pppoe_password=
+pppoe_username=
+ps_ext1=usblan0
+ps_ext2=usblan0
+ps_ext3=usblan0
+ps_ext4=usblan0
+ps_ext5=usblan0
+ps_ext6=usblan0
+ps_ext7=usblan0
+ps_ext8=usblan0
+pswan=wan
+pswan_mode=pdp
+pswan_priority=1
+RemoteManagement=0
+rj45_plugstate_path=/sys/gmac/gmacconfig/eth_phy_state
+rootdev_friendlyname=MBB-UPnP
+rootdev_manufacturer=LYNQ
+rootdev_modeldes=MBB
+rootdev_modelname=MBB
+os_url=http://m.home
+serialnumber=See-IMEI
+static_dhcp_enable=1
+static_ethwan_gw=
+static_ethwan_ip=
+static_ethwan_nm=
+static_ethwan_pridns=
+static_ethwan_secdns=
+static_wifiwan_ipaddr=
+static_wifiwan_netmask=
+static_wifiwan_gateway=
+wifiwan_pridns_manual=
+wifiwan_secdns_manual=
+static_wan_gateway=0.0.0.0
+static_wan_ipaddr=0.0.0.0
+static_wan_netmask=0.0.0.0
+static_wan_primary_dns=0.0.0.0
+static_wan_secondary_dns=0.0.0.0
+swlanstr=sw0_lan
+swvlan=sw0
+swwanstr=sw0_wan
+tc_downlink=
+tc_uplink=
+tc_local=1310720
+tc_enable=0
+time_limited=
+time_to_2000_when_restore=yes
+upnpEnabled=0
+usblan=usblan0
+WANPingFilter=0
+websURLFilters=
+wifiwan_priority=2
+DDNS=
+DDNS_Enable=0
+DDNSAccount=
+DDNSPassword=
+DDNSProvider=
+iccidPrevious=
+imeiPrevious=
+registerFlag=0
+registeredRound=
+secsEveryRound=1
+secsEveryTime=1
+regver=4.0
+meid=
+uetype=1
+LocalDomain=m.home
+data_volume_alert_percent=
+data_volume_limit_size=
+data_volume_limit_switch=0
+data_volume_limit_unit=0
+flux_day_total=0
+flux_last_day=
+flux_last_month=
+flux_last_year=
+flux_month_total=0
+flux_set_day=
+flux_set_month=
+flux_set_year=
+monthly_rx_bytes=0
+monthly_time=0
+monthly_tx_bytes=0
+MonthlyConTime_Last=
+dm_nextpollingtime=
+fota_allowRoamingUpdate=0
+fota_dl_pkg_size=0
+fota_update_flag=
+fota_updateIntervalDay=15
+fota_upgrade_result=
+fota_version_delta_id=
+fota_version_delta_url=
+fota_pkg_total_size=0
+fota_version_file_size=
+fota_version_md5sum=
+fota_version_name=
+fota_need_user_confirm_update=0
+fota_need_user_confirm_download=1
+fota_version_force_install=0
+polling_nexttime=0
+pwron_auto_check=1
+fota_updateMode=1
+fota_test_mode=0
+fota_pkg_downloaded=0
+fota_upgrade_result_internal=
+mmi_battery_voltage_line=3090+3300+3450+3490+3510+3540+3550+3570+3580+3600+3620+3650+3670+3710+3740+3780+3850+3900+3950+4000+4060
+mmi_fast_poweron=1
+mmi_led_mode=
+mmi_new_sms_blink_flag=0
+mmi_show_pagetab=page1+page2+page3
+mmi_showmode=led
+mmi_task_tab=net_task+wifi_task+key_task+rj45_task+battery_task
+mmi_temp_voltage_line=948+1199+1694+1736
+mmi_use_protect=
+mmi_use_wifi_usernum=1
+leak_full_panic=
+leak_list_max=
+leak_set_flag=
+monitor_period=300
+netinf_flag=
+skb_all_max=
+skb_data_max=
+skb_fromcp_max=
+skb_max_fail=
+skb_max_panic=
+skb_size_max=
+skb_tocp_max=
+sntp_default_ip=134.170.185.211;131.107.13.100;202.112.31.197;202.112.29.82;202.112.10.36;ntp.gwadar.cn;ntp-sz.chl.la;dns.sjtu.edu.cn;news.neu.edu.cn;dns1.synet.edu.cn;time-nw.nist.gov;pool.ntp.org;europe.pool.ntp.org
+sntp_dst_enable=0
+sntp_other_server0=
+sntp_other_server1=
+sntp_other_server2=
+sntp_server0=time-nw.nist.gov
+sntp_server1=pool.ntp.org
+sntp_server2=europe.pool.ntp.org
+sntp_sync_select_interval_time=30
+sntp_time_set_mode=auto
+sntp_timezone=CST-8
+sntp_timezone_index=0
+assert_errno=
+comm_logsize=16384
+cr_inner_version=V1.0.0B08
+cr_version=V1.0.0B01
+hw_version=PCBMF29S2V1.0.0
+TURNOFF_CHR_NUM=
+watchdog_app=0
+HTTP_SHARE_FILE=
+HTTP_SHARE_STATUS=
+HTTP_SHARE_WR_AUTH=readWrite
+ipv6_pdp_type=
+ipv6_wan_apn=
+Language=en
+manual_time_day=
+manual_time_hour=
+manual_time_minute=
+manual_time_month=
+manual_time_second=
+manual_time_year=
+sdcard_mode_option=0
+AccessControlList0=
+AccessPolicy0=0
+ACL_mode=0
+AuthMode=WPA2PSK
+Channel=0
+closeEnable=0
+closeTime=
+CountryCode=CN
+DefaultKeyID=0
+DtimPeriod=1
+EncrypType=AES
+EX_APLIST=
+EX_APLIST1=
+EX_AuthMode=
+EX_DefaultKeyID=
+EX_EncrypType=
+EX_mac=
+EX_SSID1=NB216_
+EX_WEPKEY=
+EX_wifi_profile=
+EX_WPAPSK1=
+FragThreshold=2346
+HideSSID=0
+HT_GI=1
+Key1Str1=12345
+Key2Str1=
+Key3Str1=
+Key4Str1=
+Key1Type=1
+Key2Type=
+Key3Type=
+Key4Type=
+m_AuthMode=WPA2PSK
+m_DefaultKeyID=
+m_EncrypType=AES
+m_HideSSID=0
+m_Key1Str1=1234
+m_Key2Str1=
+m_Key3Str1=
+m_Key4Str1=
+m_Key1Type=1
+m_Key2Type=
+m_Key3Type=
+m_Key4Type=
+m_MAX_Access_num=0
+m_NoForwarding=
+m_show_qrcode_flag=0
+m_SSID=NB216_
+m_ssid_enable=0
+m_wapiType=
+m_wifi_mac=901D45692A5C
+m_WPAPSK1_aes=
+m_WPAPSK1_encode=MTIzNDU2Nzg=
+MAX_Access_num=10
+MAX_Access_num_bak=10
+NoForwarding=0
+openEnable=0
+openTime=
+operater_ap=
+RekeyInterval=3600
+RTSThreshold=2347
+show_qrcode_flag=0
+Sleep_interval=-1
+ssid_write_flag=0
+SSID1=NB216_
+tsw_sleep_time_hour=
+tsw_sleep_time_min=
+tsw_wake_time_hour=
+tsw_wake_time_min=
+wapiType=
+wifi_11n_cap=1
+wifi_band=b
+wifi_coverage=long_mode
+wifi_hostname_black_list=
+wifi_hostname_white_list=
+wifi_mac=901D45692A5B
+wifi_mac_black_list=
+wifi_mac_white_list=
+wifi_profile=
+wifi_profile1=
+wifi_profile2=
+wifi_profile3=
+wifi_profile4=
+wifi_profile5=
+wifi_profile6=
+wifi_profile7=
+wifi_profile8=
+wifi_profile9=
+wifi_profile_num=0
+wifi_root_dir=
+wifi_sta_connection=0
+wifi_wps_index=1
+wifiEnabled=1
+wifilan=wlan0-va0
+wifilan2=wlan0-va1
+WirelessMode=4
+WPAPSK1_aes=
+WPAPSK1_encode=MTIzNDU2Nzg=
+wps_mode=PBC
+WPS_SSID=
+WscModeOption=0
+monitor_apps=
+at_netdog=
+autorspchannel_list=all
+soctime_switch=0
+uart_control=0
+uart_ctstrs_enable=
+special_cmd_list=$MYNETREAD
+##为入网入库芯片认证版本添加 begin
+atcmd_stream1=AT+ZSET="w_instrument",1
+atcmd_stream2=AT^SYSCONFIG=24,0,1,2
+atcmd_stream3=AT+ZSET="csiiot",2
+atcmd_stream4=AT+ZSET="dlparaflg",0
+atcmd_stream5=AT+ZSET="MTNET_TEST",1;AT+ZGAAT=0;AT+ZSET="CMCC_TEST",1;AT+ZSET="LTE_INFO",6348;AT+ZSET="VOICE_SUPPORT",1;AT+ZSET="FDD_RELEASE",7;AT+ZSET="LTE_RELEASE",1;AT+ZSET="UE_PS_RELEASE",5;AT+ZSET="QOS_RELEASE",4;AT+ZSET="TEBS_THRESHOLD",0
+atcmd_stream6=AT+ZSET="MTNET_TEST",1;AT+ZGAAT=0;AT+ZSET="LTE_INFO",6348;AT+ZSET="VOICE_SUPPORT",1;AT+ZSET="FDD_RELEASE",7;AT+ZSET="LTE_RELEASE",1;AT+ZSET="UE_PS_RELEASE",5;AT+ZSET="QOS_RELEASE",4;AT+ZSET="TEBS_THRESHOLD",0;AT+ZSET="IGNORE_SECURITY_SUPPORT",0;AT+ZSET="csifilter",0;AT+ZSET="csrhobandflg",0;AT+ZSET="dlparaflg",1;AT+ZSET="csiup",1;AT+ZSET="rfparaflag",0,0,1,0;AT+ZSET="csiiot",1;AT+ZSET="EXCEPT_RESET",0;AT+ZSET="ISIM_SUPPORT",1;AT+ZIMSTEST="MTNET_TEST",1;AT+ZSET="MANUAL_SEARCH",0
+##为入网入库芯片认证版本添加 end
+#for audio ctrl 
+audio_priority=0123
+customer_type=sdk_min
+debug_mode=
+cpIndCmdList=+ZMMI+ZURDY+ZUSLOT+ZICCID^MODE+ZPBIC+ZMSRI+CREG+CEREG+CGREG+CGEV
+zephyr_filter_ip=
+wait_timeout=2
+sntp_sync_time=1
+sntp_static_server0=time-nw.nist.gov
+sntp_static_server1=pool.ntp.org
+sntp_static_server2=europe.pool.ntp.org
+vsim_bin_path=/mnt/userdata/vSim.bin
+webv6_enable=
+lan_ipv6addr=fe80::1
+sms_vp=
+at_select_timeout=
+mtnet_test_mcc=
+at_atv=
+at_atq=
+at_at_d=
+base_ip_on_mac=0
+quick_dial=1
+xlat_enable=0
+#for schedule_restart start
+schedule_restart_enable=0
+schedule_restart_option=everyday
+schedule_restart_day=0
+schedule_restart_hour=0
+schedule_restart_minute=0
+schedule_restart_weekday=Mon
+#for schedule_restart end
+set_gmac=1
+#for tr069 start
+cwmp_enable=0
+acs_url=
+acs_username=
+acs_password=
+periodic_enable=
+periodic_interval=300
+cpe_username=
+cpe_password=
+#for tr069 end
+wifi_key_fixed=1
diff --git a/lynq/S300/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/etc_ro/device.xml b/lynq/S300/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/etc_ro/device.xml
new file mode 100755
index 0000000..6524e39
--- /dev/null
+++ b/lynq/S300/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/etc_ro/device.xml
@@ -0,0 +1,338 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<cwmp>
+	<model>
+		<object name="InternetGatewayDevice">
+			<param name="DeviceSummary" get_func="TRF_Get_DeviceSummary"/>
+			<param name="LANDeviceNumberOfEntries" get_func="TRF_Get_LANDeviceNumberOfEntries"/>
+			<param name="WANDeviceNumberOfEntries" get_func="TRF_Get_WANDeviceNumberOfEntries"/>
+			<object name="DeviceInfo">
+				<param name="SpecVersion" type="s64" get_func="get_igd_di_specversion"/>
+				<param name="HardwareVersion" type="s64" get_func="get_igd_di_hardwareversion"  set_func="set_igd_di_hardwareversion"/>
+				<param name="SoftwareVersion" type="s64" get_func="get_igd_di_softwareversion" set_func="set_igd_di_softwareversion"/>
+				<param name="ProvisioningCode" get_func="get_igd_di_provisioningcode" />
+				<param name="Manufacturer" get_func="get_igd_di_manufacturer"/>
+				<param name="ManufacturerOUI" get_func="get_igd_di_manufactureroui"/>
+				<param name="ProductClass" get_func="get_igd_di_productclass"/>
+				<param name="SerialNumber" get_func="get_igd_di_serialnumber"/>
+				<object name="VendorConfigFile" rw="0">
+					<Parameter name="Name" rw="0" type="s64" get_func="get_igd_di_vc_name"/>
+					<Parameter name="Version" rw="0" type="s16" get_func="get_igd_di_vc_version"/>
+					<Parameter name="Date" rw="0" valueType="dt" get_func="get_igd_di_vc_date"/>	
+					<Parameter name="Description" rw="0" type="s256"  get_func="get_igd_di_vc_description"/>			
+				</object>				
+			</object>
+			<object name="ManagementServer">
+				<param name="ConnectionRequestURL" noti_rw="2" type="s256" get_func="get_igd_ms_connectionrequesturl"/>
+				<param name="ConnectionRequestUsername" rw="1" noti_rw="2" type="s256"  get_func="get_igd_ms_connectionrequestusername" set_func="set_igd_ms_connectionrequestusername" notify_func="notify_igd_ms_connectionrequestusername" />
+				<param name="ConnectionRequestPassword" rw="1" noti_rw="2" type="s256"  get_func="get_igd_ms_connectionrequestpassword" set_func="set_igd_ms_connectionrequestpassword"/>
+				<param name="Username" rw="1" noti_rw="0" type="s256"  get_func="get_igd_ms_username" set_func="set_igd_ms_username"/>
+				<param name="Password" rw="1" noti_rw="0"  type="s256"  get_func="get_igd_ms_password" set_func="set_igd_ms_password"/>
+				<param name="URL" noti_rw="0" rw="1" type="s256"  get_func="get_igd_ms_url" set_func="set_igd_ms_url"/>
+				<param name="PeriodicInformEnable" rw="1" noti_rw="0" type="bool" get_func="get_igd_ms_PeriodicInformEnable" set_func="set_igd_ms_PeriodicInformEnable"/>
+				<param name="PeriodicInformInterval"  rw="1" noti_rw="0" type="uint" get_func="get_igd_ms_PeriodicInformInterval" set_func="set_igd_ms_PeriodicInformInterval"/>
+				<param name="PeriodicInformTime" type="dt" get_func="" set_func=""/>
+				<param name="ParameterKey" rw="1"  type="s32" get_func="get_igd_ms_parameterkey" set_func="set_igd_ms_parameterkey"/>
+				<param name="UDPConnectionRequestAddress" get_func="" set_func=""/>
+				<param name="UDPConnectionRequestAddressNotificationLimit" get_func=""/>
+				<param name="STUNEnable" rw="1" type="bool"  get_func="get_igd_ms_STUNEnable" set_func="set_igd_ms_STUNEnable"/>
+				<param name="STUNServerAddress" rw="1" get_func="get_igd_ms_stunserveraddress" set_func="set_igd_ms_stunserveraddress"/>
+				<param name="STUNServerPort" rw="1" get_func="get_igd_ms_stunserverport" set_func="set_igd_ms_stunserverport"/>
+				<param name="STUNUsername" rw="1" get_func="get_igd_ms_stunusername" set_func="set_igd_ms_stunusername"/>
+				<param name="STUNPassword" rw="1" get_func="get_igd_ms_stunpassword" set_func="set_igd_ms_stunpassword"/>
+				<param name="STUNMaximumKeepAlivePeriod" rw="1" type="s" get_func="get_igd_ms_stunmaximumkeepaliveperiod" set_func="set_igd_ms_stunmaximumkeepaliveperiod"/>
+				<param name="STUNMinimumKeepAlivePeriod" rw="1" type="s" get_func="get_igd_ms_stunminimumkeepaliveperiod" set_func="set_igd_ms_stunminimumkeepaliveperiod"/>
+				<param name="NATDetected" rw="1" type="s" get_func="get_igd_ms_natdetected" set_func="set_igd_ms_natdetected"/>
+			</object>
+    		<object name="Time" >
+			    <param name="NTPServer0" rw="1" type="s64" get_func="get_igd_time_ntpserver0" set_func="set_igd_time_ntpserver0"/>
+    		    <param name="NTPServer1" rw="1" type="s64" get_func="get_igd_time_ntpserver1" set_func="set_igd_time_ntpserver1"/>
+    		    <param name="NTPServer2" rw="1" type="s64" get_func="get_igd_time_ntpserver2" set_func="set_igd_time_ntpserver2"/>
+    		    <param name="CurrentLocalTime" rw="0" type="dt" get_func="get_igd_time_currentlocaltime"/>
+    		    <param name="LocalTimeZone" rw="0" type="s6" get_func="get_igd_time_localtimezone"/>
+    		    <param name="LocalTimeZoneName" rw="0" type="s64" get_func="get_igd_time_localtimezonename"/>
+    		    <param name="DaylightSavingsUsed" rw="0" type="bool"/>
+				<param name="DaylightSavingsStart" rw="0" type="dt"/>
+				<param name="DaylightSavingsEnd" rw="0" type="dt"/>
+    		</object>				
+	        <object name="WANDevice" rw="1" refresh_func="refresh_igd_wandevice">
+			    <object name="{i}">
+                    <param name="WANConnectionNumberOfEntries" rw="0" type="uint"/>
+                    <object name="WANCommonInterfaceConfig" rw="0">
+		                <param name="EnableForInternet" rw="0" type="bool"/>
+                        <param name="WANAccessType" rw="0" type="s"/>
+                        <param name="PhysicalLinkStatus" rw="0" type="s"/>
+                        <param name="TotalBytesSent" rw="0" type="uint"/>
+                        <param name="TotalBytesReceived" rw="0" type="uint"/>
+                        <param name="TotalPacketsSent" rw="0" type="uint"/>
+                        <param name="TotalPacketsReceived" rw="0" type="uint"/>
+                    </object>
+		            <object name="COM_WANInterfaceConfig"  rw="0" refresh_func="refresh_igd_wd_comwaninterfaceconfig">
+		                <object name="{i}">
+		                    <param name="NetworkMode" rw="0" type="s"/>
+			                <param name="InterfaceType" rw="0" type="s"/>						
+		                    <object name="Stats"  rw="0">
+			                    <param name="COM_PLMNID" rw="0" type="s6"/>
+				                <param name="COM_RAT" rw="0" type="uint"/>
+				                <param name="COM_2GRSSI" rw="0" type="int"/>
+				                <param name="COM_3GRSSI" rw="0" type="int"/>
+				                <param name="COM_3GRSCP" rw="0" type="int"/>
+				                <param name="COM_3GEcNo" rw="0" type="int"/>
+				                <param name="COM_LTERSSI" rw="0" type="int"/>
+				                <param name="COM_LTERSRP" rw="0" type="int"/>
+				                <param name="COM_LTERSRQ" rw="0" type="int"/>
+				                <param name="COM_LTEBandWidth" rw="0" type="uint"/>
+				                <param name="COM_CellID" rw="0" type="uint"/>
+				                <param name="COM_LAC" rw="0" type="uint"/>
+				                <param name="COM_ARFCN" rw="0" type="s64"/>
+				                <param name="COM_OnlineTime" rw="0" type="uint"/>
+				                <param name="COM_TotalOnlineTime" rw="0" type="uint"/>
+				                <param name="COM_DownRate" rw="0" type="uint"/>
+				                <param name="COM_UpRate" rw="0" type="uint"/>
+				                <param name="COM_DownVolume" rw="0" type="uint"/>
+				                <param name="COM_UpVolume" rw="0" type="uint"/>
+				                <param name="COM_TotalDownVolume" rw="0" type="uint"/>
+				                <param name="COM_TotalUpVolume" rw="0" type="uint"/>
+			                </object>
+		                </object>
+		            </object>
+                    <object name="WANEthernetInterfaceConfig"  rw="0" refresh_func="refresh_igd_wd_wanetherinterfaceconfig">
+                        <object name="{i}">
+                            <param name="Status" rw="0" type="s"/>
+                            <param name="MACAddress" rw="0" type="s"/>						
+                            <object name="Stats"  rw="0">
+                                <param name="BytesSent" rw="0" type="uint"/>
+                                <param name="BytesReceived" rw="0" type="uint"/>
+                                <param name="PacketsSent" rw="0" type="uint"/>
+                                <param name="PacketsReceived" rw="0" type="uint"/>
+                            </object>
+                        </object>
+                    </object>
+                    <object name="WANConnectionDevice"  rw="1" refresh_func="refresh_igd_wd_wanconnectiondevice">
+						<object name="{i}">
+                            <param name="WANIPConnectionNumberOfEntries" rw="0" type="uint"/>
+                            <param name="WANPPPConnectionNumberOfEntries" rw="0" type="uint"/>						
+		                    <object name="COM_WANLinkConfig"  rw="0">
+			                    <param name="ProfileName" rw="0" type="s"/>
+				                <param name="APN" rw="0" type="s128"/>
+				                <param name="PDPType" rw="0" type="uint"/>
+				                <param name="AuthenticationType" rw="0" type="uint"/>
+				                <param name="Username" rw="0" type="s64"/>
+				                <param name="Password" rw="0" type="s64"/>
+				                <param name="PrimaryDNS" rw="0" type="s64"/>
+				                <param name="SecondaryDNS" rw="0" type="s64"/>
+				                <param name="MTU" rw="0" type="uint"/>
+				                <param name="MSS" rw="0" type="uint"/>
+			                </object>
+                            <object name="COM_WANEthernetLinkConfig"  rw="0">
+                                <param name="ConnectionMode" rw="0" type="s"/>
+                                <param name="Username" rw="0" type="s64"/>
+				                <param name="Password" rw="0" type="s64"/>
+				                <param name="MTU" rw="0" type="uint"/>
+				                <param name="MSS" rw="0" type="uint"/>
+                            </object>
+                            <object name="WANIPConnection"  rw="0"  refresh_func="refresh_igd_wd_wcd_wanipconnection">
+                                <object name="{i}">
+                    	            <param name="Enable" rw="0" type="bool" get_func="get_igd_wd_wcd_wic_enable"/>
+                    	            <param name="ConnectionStatus" rw="0" valueType="string" len="16"/>
+                    	            <param name="PossibleConnectionTypes" rw="0" type="s"/>
+                    	            <param name="ConnectionType" rw="0" type="s"/>
+                    	            <param name="Name" rw="0" type="s256"/>
+                    	            <param name="Uptime" rw="0" type="uint"/>
+                    	            <param name="LastConnectionError" rw="0" type="s"/>
+                    	            <param name="AutoDisconnectTime" rw="0" type="uint"/>
+                    	            <param name="IdleDisconnectTime" rw="0" type="uint"/>
+                    	            <param name="WarnDisconnectDelay" rw="0" type="uint"/>
+                     	            <param name="RSIPAvailable" rw="0" type="bool"/>
+                    	            <param name="NATEnabled" rw="0" type="bool"/>
+                    	            <param name="AddressingType" rw="0" type="s"/>
+                    	            <param name="ExternalIPAddress" rw="0" type="s"/>      	
+				    	            <param name="SubnetMask" rw="0" type="s"/>
+                    	            <param name="DefaultGateway" rw="0" type="s32"/>
+                    	            <param name="DNSServers" rw="0" type="s64"/>
+                    	            <param name="ConnectionTrigger" rw="0" type="s"/>
+                    	            <param name="RouteProtocolRx" rw="0" type="s"/>
+                    	            <param name="ShapingRate" rw="0" type="int"/>
+                    	            <param name="ShapingBurstSize" rw="0" type="uint"/>
+                    	            <param name="PortMappingNumberOfEntries" rw="0" type="uint"/>
+                    	            <param name="COM_IPv6IPAddress" rw="0" type="s"/>
+                    	            <param name="COM_IPv6AddressingType" rw="0" type="s"/>
+				    	            <param name="COM_IPv6DNSEnable" rw="0" type="bool"/>
+				    	            <param name="COM_IPv6DNSOverrideAllowed" rw="0" type="bool"/>
+			        	            <param name="COM_IPv6DNSServers" rw="0" type="s"/>
+			        	            <param name="COM_IPv6PrefixOrigin" rw="0" type="s32"/>
+				    	            <param name="COM_IPv6Prefix" rw="0" type="s32"/>
+			        	            <param name="COM_DefaultIPv6Gateway" type="s64"/>
+                    	            <param name="RegisterNetworkType" rw="0" type="s32"/>
+                    	            <param name="CellID" rw="0" valueType="string" len="16"/>
+                    	            <param name="RSRP" rw="0" valueType="string" len="8" get_func="get_igd_wd_wcd_wic_rsrp"/>	
+                    	            <param name="RSRQ" rw="0" valueType="string" len="8"/>	
+                    	            <param name="RSSI" rw="0" valueType="string" len="8" get_func="get_igd_wd_wcd_wic_rssi"/>	
+                    	            <param name="SINR" rw="0" valueType="string" len="8"/>						            
+                                </object>
+						    </object>							
+                        </object>
+                    </object>
+                </object>
+            </object>    
+			<object name="IPPingDiagnostics">
+				<param name="DiagnosticsState" rw="0" get_func="" set_func=""/>
+				<param name="Interface" rw="0" get_func="" set_func=""/>
+				<param name="Host" rw="0" get_func="" set_func=""/>
+				<param name="NumberOfRepetitions" rw="0" get_func="" set_func=""/>
+				<param name="Timeout" rw="0" get_func="" set_func=""/>
+				<param name="DataBlockSize" rw="0" get_func="" set_func=""/>
+				<param name="DSCP" rw="0" get_func="" set_func=""/>
+				<param name="SuccessCount" get_func=""/>
+				<param name="FailureCount" get_func=""/>
+				<param name="AverageResponseTime" get_func=""/>
+				<param name="MinimumResponseTime" get_func=""/>
+				<param name="MaximumResponseTime" get_func=""/>
+			</object>
+			<object name="TraceRouteDiagnostics">
+				<param name="DiagnosticsState" rw="0" get_func="" set_func=""/>
+				<param name="Interface" rw="0" get_func="" set_func=""/>
+				<param name="Host" rw="0" get_func="" set_func=""/>
+				<param name="NumberOfTries" rw="0" get_func="" set_func=""/>
+				<param name="Timeout" rw="0" get_func="" set_func=""/>
+				<param name="DataBlockSize" rw="0" get_func="" set_func=""/>
+				<param name="DSCP" rw="0" get_func="" set_func=""/>
+				<param name="MaxHopCount" rw="0" get_func="" set_func=""/>
+				<param name="ResponseTime" get_func=""/>
+				<param name="RouteHopsNumberOfEntries" get_func=""/>
+				<object name="RouteHops" refresh_func="refresh_igd_TraceRouteDiagnostics_RouteHops">
+					<object name="{i}">
+						<param name="HopHost" get_func=""/>
+						<param name="HopHostAddress" get_func=""/>
+						<param name="HopErrorCode" get_func=""/>
+						<param name="HopRTTimes" get_func=""/>
+					</object>
+				</object>
+			</object>
+			<object name="LANDevice" refresh_func="refresh_igd_landevice">
+			    <object name="{i}">
+				    <param name="LANEthernetInterfaceNumberOfEntries" type="uint" get_func="" set_func=""/>
+				    <param name="LANWLANConfigurationNumberOfEntries" type="uint" get_func="" set_func=""/>
+		            <object name="LANHostConfigManagement"  rw="0">
+				        <param name="DHCPServerEnable" rw="0" type="bool" get_func="get_igd_ld_dhcpserverenable"/>
+					    <param name="MinAddress" rw="0" type="s" get_func="get_igd_ld_minaddress"/>
+					    <param name="MaxAddress" rw="0" type="s" get_func="get_igd_ld_maxaddress"/>
+					    <param name="ReservedAddresses"  type="s256"/>
+					    <param name="SubnetMask" rw="0" type="s" get_func="get_igd_ld_subnetmask"/>
+		                <param name="DNSServers"  type="s64"/>
+		                <param name="DomainName"  type="s64"/>
+		                <param name="IPRouters" rw="0" type="s64" get_func="get_igd_ld_iprouters"/>
+					    <param name="DHCPLeaseTime" rw="0" valueType="int" get_func="get_igd_ld_dhcpleasetime"/>
+					    <param name="UseAllocatedWAN"  type="s"/>
+					    <param name="AssociatedConnection"  type="s256"/>
+		                <param name="PassthroughLease"  type="uint"/>
+		                <param name="PassthroughMACAddress"  type="s"/>
+		                <param name="AllowedMACAddresses"  type="s512"/>
+		                <param name="IPInterfaceNumberOfEntries"  type="uint"/>
+		                <param name="DHCPStaticAddressNumberOfEntries"  type="uint"/>
+		                <object name="IPInterface"  refresh_func="refresh_igd_ld_lhcm_ipinterface">
+		                    <object name="{i}">
+		                        <param name="Enable" rw="0" type="bool"/>
+		                        <param name="IPInterfaceIPAddress" rw="1" type="s" get_func="get_igd_ld_lhcm_ipinterfaceipaddress" set_func="set_igd_ld_lhcm_ipinterfaceipaddress"/>
+		                        <param name="IPInterfaceSubnetMask" rw="1" type="s" get_func="get_igd_ld_lhcm_ipinterfacesubnetMask" set_func="set_igd_ld_lhcm_ipinterfacesubnetMask" />
+		                        <param name="IPInterfaceAddressingType" rw="0" type="s" get_func=""/>               
+					            <object name="COM_IPv6Address"  >
+		                            <param name="LocalAddress"  type="s64"/>
+						        </object>
+					        </object>
+		                </object>
+					    <object name="DHCPStaticAddress" refresh_func="refresh_igd_ld_lhcm_dhcpstaticaddress">
+					        <object name="{i}">
+  		                        <param name="Chaddr" rw="0" type="s"/>
+				                <param name="Yiaddr" rw="0" type="s"/>
+						    </object>
+		                </object>
+		            </object>
+				    <object name="Hosts"  >
+		                <param name="HostNumberOfEntries" rw="0" type="uint"/>
+		                <object name="Host" rw="0">
+		                    <param name="IPAddress" rw="0" type="s"/>
+		                    <param name="MACAddress" rw="0" type="s"/>
+		                    <param name="HostName" rw="0" type="s64"/>
+		                    <param name="InterfaceType" rw="0" type="s64"/>
+		                    <param name="Active" rw="0" type="bool"/>
+		                </object>
+		            </object>
+		            <object name="LANEthernetInterfaceConfig" refresh_func="refresh_igd_ld_lanethernetinterfaceconfig" >
+		                <object name="{i}">
+		                    <param name="Enable" rw="0" type="bool"/>
+		                    <param name="Status" rw="0" type="s"/>
+		                    <param name="MACAddress" rw="0" type="s"/>
+		                    <object name="Stats"  rw="0">
+		                        <param name="BytesSent" rw="0" type="uint"/>
+		                        <param name="BytesReceived" rw="0" type="uint"/>
+		                        <param name="PacketsSent" rw="0" type="uint"/>
+		                        <param name="PacketsReceived" rw="0" type="uint"/>
+		                    </object>
+				        </object>
+		            </object>
+				    <object name="WLANConfiguration" rw="0" refresh_func="refresh_igd_ld_wlanconfiguration">
+				        <object name="{i}">
+		                    <param name="Enable" rw="0" type="bool"/>
+					        <param name="Status"  type="s64"/>
+					        <param name="BSSID" rw="0" type="s64"/>
+					        <param name="Channel" rw="0" type="uint"/>
+					        <param name="AutoChannelEnable" rw="0" type="bool"/>
+					        <param name="SSID" rw="0" type="s64" get_func="get_igd_ld_wc_ssid"/>
+				        	<param name="Standard" rw="0" type="s64"/>
+					   	 	<param name="EncryptionMode" rw="0" type="s64"/>
+					    	<param name="AuthenticationMode" rw="0" type="s64"/>
+					    	<param name="MaxSTAs" rw="0" type="uint"/>
+					    	<param name="Powerlevel" rw="0" type="uint"/>
+					    	<param name="Band" rw="0" type="s64"/>
+					    	<param name="Bandwidth" rw="0" type="s64"/>
+					    	<param name="RegulatoryDomain"  type="s64"/>
+					    	<param name="BasicDataTransmitRates"  type="s64"/>
+					   		<param name="OperationalDataTransmitRates"  type="s64"/>
+				    		<param name="PossibleDataTransmitRates"  type="s64"/>
+				    		<param name="SSIDAdvertisementEnabled" rw="0" type="bool"/>
+					    	<param name="RadioEnabled"  type="bool"/>
+					    	<param name="TransmitPowerSupported"  type="s64"/>
+					    	<param name="TransmitPower"  type="uint"/>
+					    	<param name="AutoRateFallBackEnabled"  type="bool"/>
+					    	<param name="WMMEnable"  type="bool"/>
+					    	<param name="TotalBytesSent"  type="uint"/>
+					   		<param name="TotalBytesReceived"  type="uint"/>
+					    	<param name="TotalPacketsSent"  type="uint"/>
+					    	<param name="TotalPacketsReceived"  type="uint"/>
+					    	<param name="TotalAssociations" rw="0" type="uint"/>
+					    	<object name="WEPKey" refresh_func="refresh_igd_ld_wc_wepkey" >
+					        	<object name="{i}">
+						        	<param name="WEPKey" rw="0" type="s64"/>
+					        	</object>
+					    	</object>
+					    	<object name="PreSharedKey" refresh_func="refresh_igd_ld_wc_presharekey" >
+					        	<object name="{i}">
+					        		<param name="PreSharedKey" rw="0" type="s64"/>
+					        		<param name="KeyPassphrase" rw="0" type="s64"/>
+					        	</object>
+					    	</object>
+			    		</object>
+					</object>		
+			    	<object name="COM_RouterAdvertisement"  >
+				        <param name="Enable" rw="0" type="bool"/>
+				    	<param name="Prefix" rw="0" type="s32"/>
+				    	<param name="PreferredLifetime" rw="0" valueType="int"/>
+				    	<param name="ValidLifetime" rw="0" valueType="int"/>
+				    	<param name="MaxRtrAdvInterval" rw="0" type="uint"/>
+					    <param name="MinRtrAdvInterval" rw="0" type="uint"/>
+					    <param name="AdvManagedFlag" rw="0" type="bool"/>
+				    	<param name="AdvOtherConfigFlag" rw="0" type="bool"/>
+				    	<param name="IPv6DNSServers" rw="0" type="s"/>
+				    </object>
+				</object>
+		    </object>					
+		</object>
+	</model>
+	<inform>
+		<paramlist>
+			<param name=""/>
+		</paramlist>
+	</inform>
+	<rpc>
+    </rpc>
+</cwmp>
diff --git a/lynq/S300/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/sbin/rtl8192_calibrate.sh b/lynq/S300/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/sbin/rtl8192_calibrate.sh
new file mode 100755
index 0000000..c5427cf
--- /dev/null
+++ b/lynq/S300/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/sbin/rtl8192_calibrate.sh
@@ -0,0 +1,160 @@
+#!/bin/sh
+CALI_VERSION=1
+CALi_HW_TX_POWER_CCK_A=2D2D2E2E2E2D2D2D2E2E2E2D2D2D
+CALi_HW_TX_POWER_CCK_B=2C2C2D2D2D2A2A2A2D2D2D2E2E2E
+CALi_HW_TX_POWER_HT40_1S_A=2B2B2B2B2B2B2B2B2B2B2B2B2B2B
+CALi_HW_TX_POWER_HT40_1S_B=2929292929282828282828282828
+CALi_HW_TX_POWER_DIFF_HT20_A=0f
+CALi_HW_TX_POWER_DIFF_HT20_B=00
+CALi_HW_TX_POWER_DIFF_HT20_OFDM_A=0f
+CALi_HW_TX_POWER_DIFF_HT20_OFDM_B=0f
+CALi_HW_TX_POWER_DIFF_HT40_2S_A=00
+CALi_HW_TX_POWER_DIFF_HT40_2S_B=00
+CALi_HW_11N_THER=20
+CALi_HW_11N_XCAP=30
+
+wifi_calibrate_check()
+{
+	if [ $(iwpriv wlan0 efuse_get HW_TX_POWER_CCK_A | grep -i ${CALi_HW_TX_POWER_CCK_A} | wc -l) -eq 0 ];then
+		echo uncalibrated
+		return 2;
+	fi
+	if [ $(iwpriv wlan0 efuse_get HW_TX_POWER_CCK_B | grep -i ${CALi_HW_TX_POWER_CCK_B} | wc -l) -eq 0 ];then
+		echo uncalibrated
+		return 2;
+	fi
+	if [ $(iwpriv wlan0 efuse_get HW_TX_POWER_HT40_1S_A | grep -i ${CALi_HW_TX_POWER_HT40_1S_A} | wc -l) -eq 0 ];then
+		echo uncalibrated
+		return 2;
+	fi
+	if [ $(iwpriv wlan0 efuse_get HW_TX_POWER_HT40_1S_B | grep -i ${CALi_HW_TX_POWER_HT40_1S_B} | wc -l) -eq 0 ];then
+		echo uncalibrated
+		return 2;
+	fi
+	if [ $(iwpriv wlan0 efuse_get HW_TX_POWER_DIFF_HT20_A | grep -i ${CALi_HW_TX_POWER_DIFF_HT20_A} | wc -l) -eq 0 ];then
+		echo uncalibrated
+		return 2;
+	fi
+	if [ $(iwpriv wlan0 efuse_get HW_TX_POWER_DIFF_HT20_B | grep -i ${CALi_HW_TX_POWER_DIFF_HT20_B} | wc -l) -eq 0 ];then
+		echo uncalibrated
+		return 2;
+	fi
+	if [ $(iwpriv wlan0 efuse_get HW_TX_POWER_DIFF_HT20_OFDM_A | grep -i ${CALi_HW_TX_POWER_DIFF_HT20_OFDM_A} | wc -l) -eq 0 ];then
+		echo uncalibrated
+		return 2;
+	fi
+	if [ $(iwpriv wlan0 efuse_get HW_TX_POWER_DIFF_HT20_OFDM_B | grep -i ${CALi_HW_TX_POWER_DIFF_HT20_OFDM_B} | wc -l) -eq 0 ];then
+		echo uncalibrated
+		return 2;
+	fi
+	if [ $(iwpriv wlan0 efuse_get HW_TX_POWER_DIFF_HT40_2S_A | grep -i ${CALi_HW_TX_POWER_DIFF_HT40_2S_A} | wc -l) -eq 0 ];then
+		echo uncalibrated
+		return 2;
+	fi
+	if [ $(iwpriv wlan0 efuse_get HW_TX_POWER_DIFF_HT40_2S_B | grep -i ${CALi_HW_TX_POWER_DIFF_HT40_2S_B} | wc -l) -eq 0 ];then
+		echo uncalibrated
+		return 2;
+	fi
+	if [ $(iwpriv wlan0 efuse_get HW_11N_THER | grep -i ${CALi_HW_11N_THER} | wc -l) -eq 0 ];then
+		echo uncalibrated
+		return 2;
+	fi
+	if [ $(iwpriv wlan0 efuse_get HW_11N_XCAP | grep -i ${CALi_HW_11N_XCAP} | wc -l) -eq 0 ];then
+		echo uncalibrated
+		return 2;
+	fi
+	return 0;
+}
+
+if [ $1 -eq 0 ];then #Judgment calibration
+	if [ $(cat /sys/class/net/wlan0/operstate | grep -i down | wc -l) -eq 1 ];then
+		echo wlan0 down
+		exit 1;
+	fi
+	wifi_calibrate_check
+	result=$?
+	if [ ${result} -eq 2 ];then
+		exit 2;
+	fi
+	echo calibrated
+	exit 0;
+fi
+
+if [ $1 -eq 1 ];then #Set calibration parameters
+	if [ $(nv get wifi_calibrated ) -eq 1 ];then
+		echo Repeated calibration
+		exit 0;
+	fi
+	nvro
+	result=$?
+	if [[ ${result} -gt  ${CALI_VERSION} ]];then
+		nv set wifi_calibrated=1
+		nv save
+		echo Already calibrated by a higher version
+		exit 0;
+	fi
+	sleep 20
+	if [ $(cat /sys/class/net/wlan0/operstate | grep -i down | wc -l) -eq 1 ];then
+		echo wlan0 down
+		exit 1;
+	fi
+	wifi_calibrate_check
+	result=$?
+	if [ ${result} -eq 2 ];then
+		##
+		iwpriv wlan0 efuse_set HW_TX_POWER_CCK_A=${CALi_HW_TX_POWER_CCK_A}
+		iwpriv wlan0 efuse_set HW_TX_POWER_CCK_B=${CALi_HW_TX_POWER_CCK_B}
+		iwpriv wlan0 efuse_set HW_TX_POWER_HT40_1S_A=${CALi_HW_TX_POWER_HT40_1S_A}
+		iwpriv wlan0 efuse_set HW_TX_POWER_HT40_1S_B=${CALi_HW_TX_POWER_HT40_1S_B}
+		iwpriv wlan0 efuse_set HW_TX_POWER_DIFF_HT20_A=${CALi_HW_TX_POWER_DIFF_HT20_A}
+		iwpriv wlan0 efuse_set HW_TX_POWER_DIFF_HT20_B=${CALi_HW_TX_POWER_DIFF_HT20_B}
+		iwpriv wlan0 efuse_set HW_TX_POWER_DIFF_HT20_OFDM_A=${CALi_HW_TX_POWER_DIFF_HT20_OFDM_A}
+		iwpriv wlan0 efuse_set HW_TX_POWER_DIFF_HT20_OFDM_B=${CALi_HW_TX_POWER_DIFF_HT20_OFDM_B}
+		iwpriv wlan0 efuse_set HW_TX_POWER_DIFF_HT40_2S_A=${CALi_HW_TX_POWER_DIFF_HT40_2S_A}
+		iwpriv wlan0 efuse_set HW_TX_POWER_DIFF_HT40_2S_B=${CALi_HW_TX_POWER_DIFF_HT40_2S_B}
+		iwpriv wlan0 efuse_set HW_11N_THER=${CALi_HW_11N_THER}
+		iwpriv wlan0 efuse_set HW_11N_XCAP=${CALi_HW_11N_XCAP}
+		iwpriv wlan0 efuse_sync   #发完这个指令之后才是最终写入
+		nvro ${CALI_VERSION}
+		sleep 2
+		wifi_calibrate_check
+		result=$?
+		if [ ${result} -eq 2 ];then
+			exit 2;
+		fi
+		nv set wifi_calibrated=1
+		nv save
+		##
+		echo calibrated
+	else
+		nvro ${CALI_VERSION}
+		nv set wifi_calibrated=1
+		nv save
+		echo Repeated calibration
+		exit 0;
+	fi
+fi
+
+if [ $1 -eq 2 ];then #Get calibration parameters
+	if [ $(cat /sys/class/net/wlan0/operstate | grep -i down | wc -l) -eq 1 ];then
+		echo wlan0 down
+		exit 1;
+	fi
+	iwpriv wlan0 efuse_get HW_TX_POWER_CCK_A
+	iwpriv wlan0 efuse_get HW_TX_POWER_CCK_B
+	iwpriv wlan0 efuse_get HW_TX_POWER_HT40_1S_A
+	iwpriv wlan0 efuse_get HW_TX_POWER_HT40_1S_B
+	iwpriv wlan0 efuse_get HW_TX_POWER_DIFF_HT20_A
+	iwpriv wlan0 efuse_get HW_TX_POWER_DIFF_HT20_B
+	iwpriv wlan0 efuse_get HW_TX_POWER_DIFF_HT20_OFDM_A
+	iwpriv wlan0 efuse_get HW_TX_POWER_DIFF_HT20_OFDM_B
+	iwpriv wlan0 efuse_get HW_TX_POWER_DIFF_HT40_2S_A
+	iwpriv wlan0 efuse_get HW_TX_POWER_DIFF_HT40_2S_B
+	iwpriv wlan0 efuse_get HW_11N_THER
+	iwpriv wlan0 efuse_get HW_11N_XCAP
+fi
+
+if [ $1 -eq 3 ];then #Get VERSION
+	exit ${CALI_VERSION}
+fi
+exit 0
diff --git a/lynq/S300/boot/common/src/loader/cpu/m0/start.S b/lynq/S300/boot/common/src/loader/cpu/m0/start.S
new file mode 100755
index 0000000..ac539aa
--- /dev/null
+++ b/lynq/S300/boot/common/src/loader/cpu/m0/start.S
@@ -0,0 +1,243 @@
+/*
+ * (C) Copyright 2016 ZXIC Inc.
+ *
+ */
+
+#include <config.h>
+#include <board.h>
+#include <load_mode.h>
+
+.globl stack_setup
+
+stack:
+#if (CONFIG_DL_DISABLE)
+	.word	0x045A0000    /* DL port: 0x5A->Disable. */
+#else
+	.word	0x01000000    /* DL port: 0x00->Enable. */
+#endif
+	.word	0x3537585A    /* = string "57XZ" */
+	.word	0x31563132    /* = string "1V12" */
+	.word	0x00001E70	  /* zdata size = 8K - HdrSize = 8192 - 400 = 7792 Bytes = 0x1E70*/
+
+	/* NOT used now, Just reverse memory for RSA/HASH in near future. */
+	.word	0x00000000    /*puk_rsa_d*/
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+
+	.word	0x00000000    /*puk_rsa_n*/
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+
+	.word	0x00000000    /*hash_y*/
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000
+	.word	0x00000000	/* VID+PID */
+#if defined(CFG_ZLOAD)
+	.word	0x00102800
+	.word	_start - 0x100000 + 0x8A001    /* TBD: MACRO instead of number. */
+#else
+	.word	0x0008A000
+	.word	_start + 0x1
+#endif
+	.word	loop + 1
+	.word	loop + 1
+	
+.globl _bss_start
+_bss_start:
+	.word __bss_start
+	nop
+	nop
+
+.globl _bss_end
+_bss_end:
+	.word __bss_end
+
+.globl _para_start
+_para_start:
+	.word __para_start
+
+.globl _para_end
+_para_end:
+	.word __para_end
+	
+.globl _start
+_start:
+	ldr	r3, =0x0013C800
+	mov	r0, #3 
+	lsl	r2, r0, #28
+	mvn	r0, r2
+	ldr	r2, [r3, #0x4]
+	and	r0, r0, r2
+	str	r0, [r3, #0x4]
+	ldr	r3, =0x0013D040
+	ldr	r0, [r3]
+	ldr	r2, =0x0100
+	mvn	r2, r2
+	and	r0, r0, r2
+	str	r0, [r3]
+	ldr	r0, [r3, #0x18]
+	ldr	r2, =0x0100
+	ORR	r0, r0, r2
+	str	r0, [r3, #0x18]
+	
+#if defined(CFG_ZLOAD)
+	/* check stage1 state */
+	ldr	r3,=CFG_START_STAGE1_ADDR
+	ldr	r4,=CFG_START_STAGE1_STATE
+	ldr	r5, [r3]
+	cmp r4, r5
+	beq set_stack
+	
+	ldr	r0, =0x8a000
+	msr	MSP, r0
+	
+	bl copy_to_iram1
+	ldr	r3,=0x1001B1    /* 0x1b1 = 0x194(header len) + 0x1c(first Ins. offset) + 0x1(16bit thumb instruction) */
+	mov	pc,r3
+set_stack:
+	/* Set up the stack */
+	ldr	r2, =0x100000
+	ldr	r3,=0x194    /*header len=0x194*/
+	add	r2,r3
+	ldr	r0, [r2]
+	msr	MSP, r0
+
+#else
+
+	/* Set up the stack */
+	ldr	r2, =stack
+	ldr	r3,=0x194    /*header len=0x194*/
+	add	r2,r3
+	ldr	r0, [r2]
+	msr	MSP, r0
+
+#endif    /* CFG_ZLOAD */	
+
+/* clear the bss */
+clear_bss:
+	ldr 	r3, =_bss_start
+	ldr	r0, [r3]       /* find start of bss segment     */
+	ldr 	r3, =_bss_end
+	ldr	r1, [r3]       /* stop here                     */
+	cmp	r0, r1
+	beq	clbss_over
+	mov 	r2, #0x0   /* clear value                   */
+clbss_l:
+	str	r2, [r0]       /* clear BSS location            */
+	add	r0, r0, #4     /* increment clear index pointer */
+	cmp	r0, r1         /* are we at the end yet         */	
+	bne	clbss_l        /* keep clearing till at end     */
+clbss_over:
+
+/* remove the para section */
+	ldr	r3, =_para_start
+	ldr 	r4, [r3]
+	ldr	r3, =_para_end
+	ldr 	r1, [r3]
+	sub	r1, r1, r4
+	ldr 	r3, =_bss_end	
+	ldr	r0, [r3]
+	add	r1, r1, r0
+	cmp	r0, r1
+	beq	remove_over
+re_move:	
+	ldr	r2, [r0]
+	str	r2, [r4]
+	add 	r4, r4, #4
+	add	r0, r0, #4    /* increment clear index pointer    */
+	cmp	r0, r1        /* are we at the end yet            */	
+	bne	re_move
+remove_over:
+
+	b	start_armboot
+
+loop:
+	b loop
+
diff --git a/lynq/S300/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_mifi_mini.c b/lynq/S300/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_mifi_mini.c
new file mode 100755
index 0000000..fde67ef
--- /dev/null
+++ b/lynq/S300/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_mifi_mini.c
@@ -0,0 +1,687 @@
+/*********************************************************************
+ Copyright 2016 by	ZIXC Corporation.
+*
+* FileName::	zx297520.c
+* File Mark:
+* Description:
+* Others:
+* Version:	 v1.0
+* Author:	zhouqi
+* Date:	  2014-1-15
+
+* History 1:
+*	  Date:
+*	  Version:
+*	  Author:
+*	  Modification:
+* History 2:
+**********************************************************************/
+
+#include <common.h>
+#include <errno.h>
+#include <nand.h>
+#include <asm/arch/nand.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/uart.h>
+#include <asm/arch/lsp_crpm.h>
+#include <power.h>
+#include <partition_table.h>
+
+#include <mmc.h>
+#include <dwmmc.h>
+#include <boot_mode.h>
+#include <load_image.h>
+#include <zx234290.h>
+#include <charge.h>
+//#include <led.h>
+#include <lcd.h>
+#include <peripheral.h>
+#include "board.h"
+
+#include <drvs_gpio.h>
+
+#include <asm/arch/gmac.h>
+#include <command.h>
+#include <version.h>
+#include <secure_verify.h>
+#include <asm/arch/efuse.h>
+
+#include "cmd_downver.h"
+#include <../drivers/dma/zx29_dma.h>
+
+#include <watchdog.h>
+#include <linux/mtd/partitions.h>
+
+
+#define RET_BOOT_READY		1
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#if	TIME_DEBUG
+#define time_debug_reset(fmt)	fmt = get_timer(0)
+#define time_debug_printf(fmt, val)	printf(fmt ,get_timer(val))
+#else
+#define time_debug_reset(fmt)
+#define time_debug_printf(fmt, val)
+#endif	/* TIME_DEBUG */
+
+typedef struct {
+	int 	(*Init)(void);
+	char	func_name[20];
+}sys_init_func_t;
+
+extern boot_reason_t g_boot_reason;
+extern uint32_t g_gmac_init_flag;
+extern uint32_t g_gmac_init_overtime;
+extern unsigned char g_ddr_size_flag;
+
+unsigned int g_uiDebugLevel = UBOOT_NOTICE;
+unsigned int g_sys_kernel_sdram_size = CONFIG_SYS_SDRAM32_A9_SIZE;
+
+
+#ifndef CFG_TEMP_ADDR
+#define CFG_TEMP_ADDR	0x22000000
+#endif
+
+#define reg32(addr)			(*(volatile unsigned long *)(addr))
+
+#define UDELAY_PARAM_1SEC	(100000/3)
+
+/* DebugLevel - Controlled at compile time
+ * UBOOT_ERR	-> Noncritical error conditions.
+ * UBOOT_WARN	-> Warning conditions that should be taken care of.
+ * UBOOT_NOTICE -> Normal, but significant events.
+ * UBOOT_DBG	-> Informational messages that require no action.
+ * UBOOT_INFO	-> Debugging messages, output if the developer enabled debugging.
+ */
+//unsigned int g_uiDebugLevel = UBOOT_NOTICE;
+extern int copy_ddr_allbin(void);
+
+/*******************************************************************************
+ * Function:	board_init
+ * Description:
+ * Parameters:
+ *	 Input:
+ *
+ *	 Output:
+ *
+ * Returns:
+ *
+ *
+ * Others:
+ ********************************************************************************/
+int board_init(void)
+{
+	return 0;
+}
+
+/*******************************************************************************
+ * Function:	dram_init_banksize
+ * Description:
+ * Parameters:
+ *	 Input:
+ *
+ *	 Output:
+ *
+ * Returns:
+ *
+ *
+ * Others:
+ ********************************************************************************/
+void dram_init_banksize(void)
+{
+	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
+	gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
+}
+
+/*******************************************************************************
+ * Function:	dram_init
+ * Description:
+ * Parameters:
+ *	 Input:
+ *
+ *	 Output:
+ *
+ * Returns:
+ *
+ *
+ * Others:
+ ********************************************************************************/
+int dram_init(void)
+{
+	gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
+				PHYS_SDRAM_1_SIZE);
+
+	return 0;
+}
+
+/*******************************************************************************
+ * Function:	checkboard
+ * Description:
+ * Parameters:
+ *	 Input:
+ *
+ *	 Output:
+ *
+ * Returns:
+ *
+ *
+ * Others:
+ ********************************************************************************/
+int checkboard(void)
+{
+#ifdef CONFIG_DISPLAY_BOARDINFO
+	printf("Board: ZX297520V3\n");
+#endif
+
+	return 0;
+}
+
+void clear_iram(uint32_t addr, uint32_t len)
+{
+	uint32_t i = 0;
+	for(i = addr; i < addr + len; i+=4)
+	{
+		writel(0x0, i);
+	}
+}
+
+void clear_tmp_buf(void)
+{
+	clear_iram(CONFIG_SYS_SDRAM_TEMP_BASE, 0x800);
+}
+
+static int gmac_download_init(void)
+{
+	int ret = 0;
+
+	get_gmac_init_flag();
+	BOOT_PRINTF(UBOOT_DBG, "get_gmac_init_flag = 0x%x, read_gmac_init_flag = 0x%x.\n", get_gmac_init_flag(), read_gmac_init_flag());
+	if(1 == read_gmac_init_flag())
+	{
+		BOOT_PRINTF(UBOOT_NOTICE, "gmac init overtime[%ds].....$$$$$$$$$$$$$$\n", read_gmac_init_overtime());
+
+		puts("Net:	");
+		eth_initialize(gd->bd);
+
+		if (run_command ("downver allbins", 0) >= 0)
+		{
+			ret = copy_ddr_allbin();
+			if(ret != 0)
+			{
+				BOOT_PRINTF(UBOOT_ERR, "net load write from ddr to nand FAILED !!!\n");
+			}
+		}
+		else
+		{
+			BOOT_PRINTF(UBOOT_ERR, "run_command downver allbins FAILED !!!\n");
+		}
+	}
+
+	return 0;
+}
+
+static int test_env_entry(void)
+{
+	/* Ó²¼þ²âÊÔ */
+#if CONFIG_HARDWARE_TEST
+	hardware_test();
+#endif
+
+#if CONFIG_MUTUAL_DEBUG	//ÖÃ1Ö®ºó¾Í¿ÉÒÔ½øÈëUBoot¿ØÖÆÌ¨ÃüÁîÐÐ
+	for (;;)
+	{
+		main_loop();
+	}
+#endif
+
+	return 0;
+}
+
+static int boot_reason_init(void)
+{
+	int ret = 0;
+	unsigned int amt_flag = 0;
+	unsigned int key_times = 0;
+	unsigned int *poweron_type = (unsigned int *)POWERON_TYPE_ADDR;	 //ÁÙʱʹÓÃ
+
+	BOOT_PRINTF(UBOOT_DBG, "Normal mode.\n");
+
+	amt_flag = readl(POWERON_TYPE_ADDR);
+	BOOT_PRINTF(UBOOT_NOTICE, "VALUE = 0x%x!\n", amt_flag);
+	if(amt_flag == AMT_MODE_FLAG)
+	{
+		BOOT_PRINTF(UBOOT_NOTICE, "AMT VALUE = AMT_MODE_FLAG!\n");
+		g_boot_reason = RB_AMT;
+	}
+	else
+	{
+		ret = get_boot_reason();
+		if(ret != 0)
+		{
+			BOOT_PRINTF(UBOOT_ERR, "get boot reason ERROR !!!\n");
+			/* TBD: Error Return. */
+		}
+	}
+
+	if(read_fota_update_flag() == FOTA_RECOVERY)
+	{
+		*poweron_type = POWER_ON_FOTA;
+	}
+	else if(read_fota_update_flag() == FOTA_LOCALUPDATE)
+	{
+		*poweron_type = POWER_ON_LOCALUPDATE;
+	}
+	else if(g_boot_reason == RB_AMT)
+	{
+		*poweron_type = POWER_ON_AMT;
+	}
+	else if(g_boot_reason == RB_PRODUCTION)
+	{
+		*poweron_type = POWER_ON_PRODUCTION;
+	}
+	else if((g_boot_reason & 0xF0) == ZX234290_WDT_RST_FLAG)
+	{
+		*poweron_type = g_boot_reason & 0x0F;
+	}
+	else if(g_boot_reason == RB_RESET_NOMAL)
+	{
+		*poweron_type = POWER_ON_NORMAL;
+	}
+	else if(g_boot_reason == RB_RTC)
+	{
+		*poweron_type = POWER_ON_RTC; //POWER_ON_NORMAL;
+	}
+	else if(g_boot_reason == RB_RESET_EXCEPT)
+	{
+		*poweron_type = POWER_ON_EXCEPTRESET;
+	}
+	else if(g_boot_reason == RB_POWER_KEY_LONG)//add llp restart power on mode by yuxiang
+	{
+		*poweron_type = POWER_ON_NORMAL;
+	}
+	else if(g_boot_reason == RB_POWER_KEY)
+	{
+
+		while(1)
+		{
+			/*******¼ì²âÊÇ·ñ³¤°´¼ü3s********/
+			if(zx234290_get_poweron_state())
+			{
+				key_times++;
+//				printf( "[sys_entry]: power key down,key_times=%d.\n",key_times);
+			}
+			else
+			{
+				*poweron_type = POWER_ON_CHARGING;
+				break;
+			}
+			if(key_times >= 20)
+			{
+				*poweron_type = POWER_ON_NORMAL;
+				break;
+			}
+			udelay(UDELAY_PARAM_1SEC / 100); /*Actual 10ms*/
+		}
+
+	}
+	else if((g_boot_reason == RB_USB_INSERT)||(g_boot_reason == RB_RESET_USB_OFF))
+	{
+		*poweron_type = POWER_ON_CHARGING;
+	}
+	else if(g_boot_reason == RB_POWER_BOOST_IN)
+	{
+		*poweron_type = POWER_ON_BOOST_IN;
+	}
+	else if(g_boot_reason == RB_RESET_ALARM)
+	{
+		*poweron_type = POWER_ON_NORMAL;
+	}
+    else
+    {
+        *poweron_type = POWER_ON_INVALID;
+        BOOT_PRINTF(UBOOT_DBG, "g_boot_reason=0x%x.\n", g_boot_reason);
+    }
+	BOOT_PRINTF(UBOOT_NOTICE, "poweron_type=0x%x.\n", *poweron_type);
+#if 0
+	key_times = 0;
+	while(*poweron_type == POWER_ON_CHARGING)
+	{
+		/* ¼ì²éÊÇ·ñ½ÓÁ˳äµçÆ÷ */
+		if(1)//if(detect_usb_online())
+		{
+			break;
+		}
+		pmu_pull_on_ps_hold();
+		/* ¼ì²éÄÖÖÓ¡¢µ¹¼ÆÊ±Ê¼þ */
+		if(zx234290_get_rtc_state() > 0)
+		{
+			*poweron_type = POWER_ON_RTC;
+			BOOT_PRINTF(UBOOT_NOTICE, "new poweron_type=0x%x.\n", *poweron_type);
+			break;
+		}
+		/* ¼ì²é°´¼ü³¤°´ */
+		if(zx234290_get_poweron_state())
+		{
+			key_times++;
+		}
+		else
+		{
+			key_times = 0;
+		}
+		if(key_times >= 2)
+		{
+			BOOT_PRINTF(UBOOT_NOTICE, "new poweron_type=0x%x.\n", *poweron_type);
+			*poweron_type = POWER_ON_NORMAL;
+			break;
+		}
+		pmu_pull_off_ps_hold();
+		udelay(UDELAY_PARAM_1SEC / 10); /*Actual 100ms*/
+	}
+#endif
+	zx234290_write_flag(ZX234290_WDT_RST_FLAG | *poweron_type);
+
+	return 0;
+}
+
+static int bat_detect(void)
+{
+	unsigned int *poweron_type = (unsigned int *)POWERON_TYPE_ADDR;	 //ÁÙʱʹÓÃ
+	int vBatVoltage = -1;
+	uchar lowbat_keyrelease=0;
+	int vBatPowerOnVoltage = -1;
+
+	if ((*poweron_type == POWER_ON_AMT) ||
+		(*poweron_type == POWER_ON_PRODUCTION) ||
+		(*poweron_type == POWER_ON_LOCALUPDATE)) {
+		BOOT_PRINTF(UBOOT_WARN, "skip battery detect!!!\n");
+	}
+	else if(1==get_battery_detect_flag())/*detect bat start*/
+	{
+		if (!zx_get_battery_Status())
+		{
+			BOOT_PRINTF(UBOOT_WARN, "there is no battery. Forbid power on.\n");
+			pmu_pull_on_ps_hold();
+			Show_No_Battery();
+			udelay(UDELAY_PARAM_1SEC * 3);	/*3s*/
+			pmu_pull_off_ps_hold();
+			hang();
+		}
+
+		vBatVoltage = zx_get_vbat_voltage();
+		BOOT_PRINTF(UBOOT_NOTICE, "zx_get_vbat_voltage= %d.\n", vBatVoltage);
+
+		if (vBatVoltage <= 3400)
+		{
+			pmu_pull_on_ps_hold();
+			BOOT_PRINTF(UBOOT_WARN, "Battery voltage %d. Forbid power on.\n", vBatVoltage);
+			if((*poweron_type == POWER_ON_NORMAL)||(*poweron_type == POWER_ON_FOTA))
+			{
+				/*show the low Battery for 3s*/
+				Show_LowPower();
+				udelay(UDELAY_PARAM_1SEC * 2);	/*3s*/
+			}
+			//pmu_pull_off_ps_hold();
+			wdt_close();//close wdt
+			while(1)
+			{
+				if(!lowbat_keyrelease && !zx234290_get_poweron_state())
+				{
+					zDrvLcd_TurnBacklightOnOff(0);
+					udelay(UDELAY_PARAM_1SEC /10); // 100ms
+					BOOT_PRINTF(UBOOT_WARN, "pwr key released...poweroff\n");
+					pmu_pull_off_ps_hold();
+					udelay(UDELAY_PARAM_1SEC /10); // 100ms
+					lowbat_keyrelease = 1;// usb or other power hold on the system.
+				}
+				vBatPowerOnVoltage = zx_get_vbat_voltage();
+				BOOT_PRINTF(UBOOT_WARN, "the current battery voltage is %d.\n", vBatPowerOnVoltage);
+				if(vBatPowerOnVoltage > 3400)
+				{
+					break;
+				}
+				udelay(UDELAY_PARAM_1SEC );
+			}
+			if(*poweron_type != POWER_ON_FOTA)
+				wdt_open();//open wdt
+		}
+	}/* detect bat end*/
+
+	return 0;
+}
+
+void display_boot_animation(unsigned int poweron_type)
+{
+	switch (poweron_type) {
+	case POWER_ON_LOCALUPDATE:
+		Show_UpdateWait();
+		break;
+
+	case POWER_ON_NORMAL:
+		Show_PowerOn_Normal();
+		break;
+
+	case POWER_ON_FOTA:
+		Show_PowerOn_Fota();
+		break;
+
+	case POWER_ON_CHARGING:
+		Show_Charging();
+		break;
+
+	default:
+		break;
+	}
+}
+
+static int boot_prepare(void)
+{
+	unsigned int poweron_type = reg32(POWERON_TYPE_ADDR);	 //ÁÙʱʹÓÃ
+
+/*
+	if (poweron_type == POWER_ON_CHARGING) {
+		pmu_pull_off_ps_hold();
+	} else {
+		pmu_pull_on_ps_hold();
+	}
+
+*/
+#if 1
+	zx234290_set_softon(1);
+#else
+	zx234290_set_softon(0);
+	pmu_pull_off_ps_hold();
+#endif
+	display_boot_animation(poweron_type);
+
+	return 0;
+}
+
+static int boot_entry(void)
+{
+	int ret = 0;
+	unsigned int poweron_type = reg32(POWERON_TYPE_ADDR);	 //ÁÙʱʹÓÃ
+
+	//g_ddr_size_flag = CHIP_DDR_IS_32M;
+
+	switch (poweron_type) {
+
+	case POWER_ON_LOCALUPDATE:
+		break;
+	case POWER_ON_FOTA:
+		BOOT_PRINTF(UBOOT_NOTICE, "Fota entry!\n");
+		if(g_ddr_size_flag == CHIP_DDR_IS_32M)
+		{
+			g_sys_kernel_sdram_size = CONFIG_SYS_SDRAM32_RECOVERY_A9_SIZE;
+		}
+		else if(g_ddr_size_flag == CHIP_DDR_IS_64M)
+		{
+			g_sys_kernel_sdram_size = CONFIG_SYS_SDRAM64_RECOVERY_A9_SIZE;
+		}
+		else if(g_ddr_size_flag == CHIP_DDR_IS_128M)
+		{
+			g_sys_kernel_sdram_size = CONFIG_SYS_SDRAM128_RECOVERY_A9_SIZE;
+		}		
+		else
+		{
+			g_sys_kernel_sdram_size = CONFIG_SYS_SDRAM256_RECOVERY_A9_SIZE;
+		}
+
+		ret = fs_load_arm_image_linux(ARM_RECOVERY_USERDATA_IMAGE);	/*FOTA-UPDATE*/
+		break;
+	default:
+		BOOT_PRINTF(UBOOT_NOTICE, "Normal entry!\n");
+		if(g_ddr_size_flag == CHIP_DDR_IS_32M)
+		{
+			g_sys_kernel_sdram_size = CONFIG_SYS_SDRAM32_A9_SIZE;
+		}
+		else if(g_ddr_size_flag == CHIP_DDR_IS_64M)
+
+		{
+			g_sys_kernel_sdram_size = CONFIG_SYS_SDRAM64_A9_SIZE;
+		}
+		else if(g_ddr_size_flag == CHIP_DDR_IS_128M)
+		{
+			g_sys_kernel_sdram_size = CONFIG_SYS_SDRAM128_A9_SIZE;
+		}
+		else
+		{
+			g_sys_kernel_sdram_size = CONFIG_SYS_SDRAM256_A9_SIZE;
+		}
+		ret = fs_load_m0_image();
+		ret += fs_load_zsp_image();
+		ret += fs_load_arm_image_linux(ARM_APP_IMAGE);
+		break;
+	}
+
+#if VERSION_RELEASE
+	if( ret != 0 )
+	{
+		BOOT_PRINTF(UBOOT_ERR, "load images ERROR !!!\n");
+	}
+#endif
+
+	return 0;
+}
+
+static const sys_init_func_t uboot_init_func_tbl[] =
+{
+	{wdt_get_reboot_reason,	"wdt_reboot"},
+	{dma_init,				"dma"},
+	{i2c_init,				"i2c"},
+	{peripheral_init,		"peri"},
+	{nand_init,				"nand"},
+	{partition_init,		"partition"},	
+	{gmac_download_init,	"gmac"},
+	{test_env_entry,		"test"},
+	{efuse_init,			"efuse"},	
+	{lcd_init,				"lcd"},//aic8800 init
+	{nvrw_flag_init,		"nvrw_flag"},
+	{boot_reason_init,		"boot_reason"},
+	{wdt_init,				"wdt"},
+	//{bat_detect,			"bat_det"},
+	{boot_prepare,			"boot_prepare"},
+	{NULL,					{}}
+};
+
+static const sys_init_func_t tboot_init_func_tbl[] =
+{
+	{wdt_get_reboot_reason,	"wdt_reboot"},
+	{dma_init,				"dma"},
+	{i2c_init,				"i2c"},
+	{peripheral_init,		"peri"},
+	{nand_init,				"nand"},
+	{NULL,					{}}
+};
+
+int uboot_init_func(void)
+{
+	unsigned int dev_index;
+	int ret;
+
+	BOOT_PRINTF(UBOOT_NOTICE, "go into uboot init func\n");
+
+	for (dev_index = 0; (uboot_init_func_tbl[dev_index].Init != NULL); dev_index++)
+	{
+		ret = uboot_init_func_tbl[dev_index].Init();
+
+		if (ret < 0) {
+			BOOT_PRINTF(UBOOT_ERR, "uboot init %s fail, ret = %d\n",
+				uboot_init_func_tbl[dev_index].func_name, ret);
+			BUG();
+			return ret;
+		} else {
+			BOOT_PRINTF(UBOOT_NOTICE, "uboot init %s success\n",
+				uboot_init_func_tbl[dev_index].func_name);
+		}
+	}
+
+	return SUCCESS;
+}
+
+int tboot_init_func(void)
+{
+	unsigned int dev_index;
+	int ret;
+
+	BOOT_PRINTF(UBOOT_NOTICE, "go into tboot init func\n");
+
+	for (dev_index = 0; (tboot_init_func_tbl[dev_index].Init != NULL); dev_index++)
+	{
+		ret = tboot_init_func_tbl[dev_index].Init();
+		if (ret < 0) {
+			BOOT_PRINTF(UBOOT_ERR, "tboot init %s fail, ret = %d\n",
+				tboot_init_func_tbl[dev_index].func_name, ret);
+			BUG();
+			return ret;
+		} else {
+			BOOT_PRINTF(UBOOT_NOTICE, "tboot init %s success\n",
+				tboot_init_func_tbl[dev_index].func_name);
+		}
+	}
+
+	return SUCCESS;
+}
+
+/*******************************************************************************
+ * Function:	sys_entry
+ * Description: ϵͳÖ÷Á÷³Ì
+ * Parameters:
+ *	 Input:
+ *
+ *	 Output:
+ *
+ * Returns:
+ *
+ *
+ * Others:
+ ********************************************************************************/
+void sys_entry(void)
+{
+
+	BOOT_PRINTF(UBOOT_NOTICE, "sys_entry ...\n");
+
+	switch (get_load_mode()) {
+	case TLOAD_MODE:
+		tboot_init_func();
+		run_command("downloader", 0);
+		break;
+	case ZLOAD_MODE:
+		uboot_init_func();
+		boot_entry();
+		//clear_tmp_buf();
+		break;
+	default:
+		break;
+	}
+
+	add_partition_to_bootargs();
+	for (;;)
+	{
+		main_loop();
+	}
+
+	hang();
+	/* NOTREACHED - no way out of command loop except booting */
+}
+
diff --git a/lynq/S300/boot/common/src/uboot/drivers/mtd/partition/partition.c b/lynq/S300/boot/common/src/uboot/drivers/mtd/partition/partition.c
new file mode 100755
index 0000000..494b353
--- /dev/null
+++ b/lynq/S300/boot/common/src/uboot/drivers/mtd/partition/partition.c
@@ -0,0 +1,456 @@
+/*********************************************************************
+ Copyright 2016 by  ZIXC Corporation.
+*
+* FileName::    partition.c
+* File Mark:
+* Description:  
+* Others:
+* Version:   v1.0
+* Author:   zhouqi
+* Date:   2014-1-15
+
+* History 1:
+*     Date: 
+*     Version:
+*     Author: 
+*     Modification:
+* History 2:
+**********************************************************************/
+
+#include <common.h>
+#include <errno.h>
+#include <command.h>
+#include <malloc.h>
+#include <jffs2/load_kernel.h>
+#include <linux/list.h>
+#include <linux/ctype.h>
+#include <linux/err.h>
+#include <linux/mtd/mtd.h>
+#include <nand.h>  
+#include <linux/mtd/partitions.h>
+#include <asm/io.h>  
+#include <load_image.h>
+#include <boot_mode.h>
+#include <config.h>
+
+
+
+#define DEFINE_PARTITION_TABLE
+#include <partition_table.h>      
+#include <boot_mode.h>
+
+
+#if defined(CONFIG_CMD_NAND)
+#include <linux/mtd/nand.h>
+#include <nand.h>
+#endif
+
+#include <linux/mtd/nor_spifc.h>
+
+u_char * g_table = NULL;                        /* ¶ÁÈ¡µÄ·ÖÇø±íÐÅÏ¢ 2k+64 */
+partition_table_t * g_partition_table = NULL;   /* Ö¸Ïò·ÖÇø±íÐÅÏ¢ */
+extern partition_table_t * g_partition_table_dl;
+extern struct fsl_qspi spi_nor_flash;
+#ifdef CONFIG_ZX297520V3E_MDL_AB
+extern int imagefs_flag;
+#endif
+
+/* ================================================================================
+ *  add_partition_to_bootargs  :  Ôö¼Ó·ÖÇøÐÅÏ¢µ½ bootargs
+ */
+ #ifdef CONFIG_ZX297520V3E_MDL_AB
+ void add_partition_to_bootargs( void )
+{
+	int ret = 0;
+	uint32_t part_nums = 0;
+	uint32_t i = 0;
+	uint32_t start_entry = 0;               /* Æô¶¯·ÖÇøºÅ */
+	uchar bootargs_cmd[1024] = {0};
+	uchar boot_reason_para[32] = {0};
+	uchar boot_mode_para[16] = {0};
+	unsigned int *poweron_type = (unsigned int *)POWERON_TYPE_ADDR;  //ÁÙʱʹÓÃ
+	
+	part_nums = g_partition_table->entrys;    
+
+	partition_entry_t * entry = &g_partition_table->table[0];
+
+	/* console=ttyS1,115200 no_console_suspend */
+	sprintf((char *)bootargs_cmd, "console=ttyS1,921600 no_console_suspend");
+
+	/* denali-nand: */
+	if(read_boot_flashtype() == IF_TYPE_NAND)
+	{
+		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " mtdparts=denali-nand:");
+	}
+	else if (read_boot_flashtype() == IF_TYPE_SPI_NAND)
+	{
+		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " mtdparts=spi-nand:");
+	}
+	else if (read_boot_flashtype() == IF_TYPE_NOR)
+	{
+		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " mtdparts=spi-nor-dt:");
+	}
+
+	/* È¥³ý×îºóµÄ2¸ö·ÖÇø ddr raw */
+	for( i=0; i<part_nums-VIRTUAL_PART_NUM-1; i++ )
+	{
+		if( (entry->part_size >= 0x100000) && (entry->part_size%0x100000 == 0) )
+		{
+			sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), "%dm@0x%lx(%s),", 
+				(entry->part_size) >> 20, (entry->part_offset), (entry->part_name));
+		}
+		else
+		{
+			sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), "%dk@0x%lx(%s),", 
+				 (entry->part_size) >> 10, (entry->part_offset), (entry->part_name));
+		}
+
+		/* »ñÈ¡Æô¶¯·ÖÇøºÅ */
+		//if(read_fota_update_flag())
+		if(imagefs_flag == 1)
+		{
+			if ( 0 == strcmp( (char *)entry->part_name, (char *)ARM_ROOTFS_IMAGE ) )
+			{
+				start_entry = i;
+			}
+		}
+		else if(imagefs_flag == 2)
+		{
+			if ( 0 == strcmp( (char *)entry->part_name, (char *)ARM_ROOTFS2_IMAGE ) )
+			{
+				start_entry = i;
+			}
+		}
+
+		entry++;
+	}
+
+	/* »ñÈ¡Æô¶¯·ÖÇøºÅ */ 
+	if(imagefs_flag == 1)    
+    {
+		if ( 0 == strcmp( (char *)entry->part_name, (char *)ARM_ROOTFS_IMAGE) )
+		{
+			start_entry = i + 1;
+		}
+	}
+	else if(imagefs_flag == 2)   
+	{
+		if ( 0 == strcmp( (char *)entry->part_name, (char *)ARM_ROOTFS2_IMAGE ) )
+		{
+			start_entry = i + 1;
+		}
+	}
+
+	/* ×îºóÒ»¸ö·ÖÇø */
+	if( (entry->part_size >= 0x100000) && (entry->part_size%0x100000 == 0) )
+	{
+		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), "%dm@0x%lx(%s)",
+			(entry->part_size) >> 20, (entry->part_offset), (entry->part_name));
+	}
+	else
+	{
+		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), "%dk@0x%lx(%s)",
+			(entry->part_size) >> 10, (entry->part_offset), (entry->part_name));
+	}
+	
+	/* rootfs=/dev/mtdblock7 rootfs2=/dev/mtdblock8 */
+    sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), 
+		" root=/dev/mtdblock%d ro rootfstype=jffs2", start_entry);
+	
+	printf("rootfs%d entry...\n",start_entry);
+
+	if(RB_AMT == read_boot_reason())
+	{
+		*poweron_type = POWER_ON_AMT;
+		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " boot_reason=%d", *poweron_type);
+		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " bootmode=amt");
+	}
+	else
+	{
+		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " boot_reason=%d", *poweron_type);
+	}
+	BOOT_PRINTF(UBOOT_INFO, "CONFIG_SYS_START_FLAG_ADDR = 0x%x, poweron_type = 0x%x.\n",
+		 POWERON_TYPE_ADDR, *poweron_type);
+
+	if(imagefs_flag == 1)    
+   	{
+		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " system=system_a");
+	}
+	else if(imagefs_flag == 2)   
+	{
+		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " system=system_b");
+	}	
+
+	/* save */
+	setenv("bootargs", (char *)bootargs_cmd);
+}
+ #else
+void add_partition_to_bootargs( void )
+{
+	int ret = 0;
+	uint32_t part_nums = 0;
+	uint32_t i = 0;
+	uint32_t start_entry = 0;               /* Æô¶¯·ÖÇøºÅ */
+	uchar bootargs_cmd[1024] = {0};
+	uchar boot_reason_para[32] = {0};
+	uchar boot_mode_para[16] = {0};
+	unsigned int *poweron_type = (unsigned int *)POWERON_TYPE_ADDR;  //ÁÙʱʹÓÃ
+	
+	part_nums = g_partition_table->entrys;    
+
+	partition_entry_t * entry = &g_partition_table->table[0];
+
+	/* console=ttyS1,115200 no_console_suspend */
+	sprintf((char *)bootargs_cmd, "console=ttyS1,921600 no_console_suspend");
+
+	/* denali-nand: */
+	if(read_boot_flashtype() == IF_TYPE_NAND)
+	{
+		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " mtdparts=denali-nand:");
+	}
+	else if (read_boot_flashtype() == IF_TYPE_SPI_NAND)
+	{
+		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " mtdparts=spi-nand:");
+	}
+	else if (read_boot_flashtype() == IF_TYPE_NOR)
+	{
+		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " mtdparts=spi-nor-dt:");
+	}
+
+	/* È¥³ý×îºóµÄ2¸ö·ÖÇø ddr raw */
+	for( i=0; i<part_nums-VIRTUAL_PART_NUM-1; i++ )
+	{
+		if( (entry->part_size >= 0x100000) && (entry->part_size%0x100000 == 0) )
+		{
+			sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), "%dm@0x%lx(%s),", 
+				(entry->part_size) >> 20, (entry->part_offset), (entry->part_name));
+		}
+		else
+		{
+			sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), "%dk@0x%lx(%s),", 
+				 (entry->part_size) >> 10, (entry->part_offset), (entry->part_name));
+		}
+
+		/* »ñÈ¡Æô¶¯·ÖÇøºÅ */
+		if(read_fota_update_flag())
+		{
+			if ( 0 == strcmp( (char *)entry->part_name, (char *)ARM_RECOVERY_USERDATA_IMAGE ) )
+			{
+				start_entry = i;
+			}
+		}
+		else
+		{
+			if ( 0 == strcmp( (char *)entry->part_name, (char *)ARM_USERDATA_IMAGE ) )
+			{
+				start_entry = i;
+			}
+		}
+
+		entry++;
+	}
+
+	/* »ñÈ¡Æô¶¯·ÖÇøºÅ */ 
+	if(read_fota_update_flag())    /* 3±íʾFOTA-RECOVERY */
+    	{
+		if ( 0 == strcmp( (char *)entry->part_name, (char *)ARM_RECOVERY_USERDATA_IMAGE) )
+		{
+			start_entry = i + 1;
+		}
+	}
+	else    /* Õý³£Æô¶¯Á÷³Ì */
+	{
+		if ( 0 == strcmp( (char *)entry->part_name, (char *)ARM_USERDATA_IMAGE ) )
+		{
+			start_entry = i + 1;
+		}
+	}
+
+	/* ×îºóÒ»¸ö·ÖÇø */
+	if( (entry->part_size >= 0x100000) && (entry->part_size%0x100000 == 0) )
+	{
+		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), "%dm@0x%lx(%s)",
+			(entry->part_size) >> 20, (entry->part_offset), (entry->part_name));
+	}
+	else
+	{
+		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), "%dk@0x%lx(%s)",
+			(entry->part_size) >> 10, (entry->part_offset), (entry->part_name));
+	}
+	 
+	if(RB_AMT == read_boot_reason())
+	{
+		*poweron_type = POWER_ON_AMT;
+		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " boot_reason=%d", *poweron_type);
+		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " bootmode=amt");
+	}
+	else
+	{
+		*poweron_type = POWER_ON_NORMAL;
+		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " boot_reason=%d", *poweron_type);
+	}
+	BOOT_PRINTF(UBOOT_INFO, "CONFIG_SYS_START_FLAG_ADDR = 0x%x, poweron_type = 0x%x.\n",
+		 POWERON_TYPE_ADDR, *poweron_type);
+
+    if(read_fota_update_flag())    
+   	{
+		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " system=recovery");
+	}
+	else  
+	{
+		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " system=normal");
+	}	
+	
+	/* save */
+	setenv("bootargs", (char *)bootargs_cmd);
+}
+#endif
+/*******************************************************************************
+ * Function:    read_partition_and_check
+ * Description: ´ÓFLASHÖжÁÈ¡·ÖÇø±í
+ * Parameters:
+ *	 Input:
+ *
+ *	 Output:
+ *
+ * @return 0        :  ¶ÁÈ¡·ÖÇø±íÓÐЧ
+ * @return 1        :  ¶ÁÈ¡·ÖÇø±íÎÞЧ
+ *
+ * Others:
+ ********************************************************************************/
+int read_partition_and_check( void )
+{
+	struct flash_ops *flash = NULL;
+	nand_info_t *nand = &nand_info[nand_curr_device];
+	int table_size = 2048;
+	int ret = 0;
+	int type = 0;
+	int buf_size = 0;
+	struct fsl_qspi *nor;
+
+	nor = &spi_nor_flash;
+    
+	flash = get_flash_ops();
+	type = read_boot_flashtype();
+	if(type == IF_TYPE_NAND || type == IF_TYPE_SPI_NAND)
+	{
+		buf_size = nand->writesize + nand->oobsize;
+	}
+	else if(type == IF_TYPE_NOR)
+	{
+		buf_size = table_size;
+	}
+	
+	g_table = (u_char *)kzalloc(buf_size, GFP_KERNEL);
+	if ( g_table == NULL ) 
+	{
+		BOOT_PRINTF(UBOOT_ERR, "kzalloc Failed!\n");
+		return -EIO;
+	}
+    
+	/* ¶ÁÈ¡·ÖÇø±í */
+	/*
+    +------------------------------------------------------------+
+    |       z-load.bin                 |    partition_table.bin  |                
+    +------------------------------------------------------------+
+                                       8k           one page     10k
+    */ 
+
+	if(type == IF_TYPE_NAND || type == IF_TYPE_SPI_NAND)
+	{
+		ret = flash->read_with_ecc(nand, (loff_t)8*1024, &table_size, g_table);
+		if(ret)
+		{
+			BOOT_PRINTF(UBOOT_ERR, "read_no_ecc Failed! ret = %d.\n", ret);
+			return -1;
+		}
+	}
+	else if(type == IF_TYPE_NOR)
+	{
+		ret = nand_read(&(nor->nor[0].mtd), (loff_t)8*1024, &table_size, g_table);
+		if(ret)
+		{
+			BOOT_PRINTF(UBOOT_ERR, "nand_read error! ret = %d.\n", ret);
+			return -1;
+		}
+	}
+
+	g_partition_table = (partition_table_t *)g_table;
+	if( g_partition_table->magic != PARTITION_MAGIC )
+	{
+		BOOT_PRINTF(UBOOT_ERR, "Partition Table Invalid! ret = %d.\n", ret);
+		return -EIO; 
+	}
+
+	return SUCCESS;
+}
+
+
+/*******************************************************************************
+ * Function:    find_partition_para
+ * Description:  ͨ¹ý·ÖÇøÃû²éÕÒ·ÖÇøÊ×µØÖ·
+ * Parameters:
+ *	 Input:
+ *
+ *	 Output:
+ *
+ * Returns:
+ *
+ *
+ * Others:
+ ********************************************************************************/ 
+partition_entry_t * find_partition_para( uchar * name )
+{
+	partition_entry_t *entry = NULL;
+	uint32_t entry_nums = 0;
+	
+	if(get_load_mode() == TLOAD_MODE) 
+	{
+		entry = &g_partition_table_dl->table[0];
+		entry_nums = g_partition_table_dl->entrys;
+	}
+	else
+	{
+		entry = &g_partition_table->table[0];
+		entry_nums = g_partition_table->entrys;
+	}
+	while( entry_nums-- )
+	{
+		if ( strcmp( (char *)entry->part_name, (char *)name ) == 0 )
+		{
+			return entry;
+		}
+		entry++;
+	}
+	return NULL;
+}
+
+/*******************************************************************************
+ * Function:    partition_init
+ * Description:  ͨ¹ý·ÖÇøÃû²éÕÒ·ÖÇøÊ×µØÖ·
+ * Parameters:
+ *	 Input:
+ *
+ *	 Output:
+ *
+ * Returns:
+ *
+ *
+ * Others:
+ ********************************************************************************/ 
+int partition_init(void)
+{
+	int ret = 0;
+
+	ret = read_partition_and_check();
+
+	if( ret != 0 )
+	{
+		BOOT_PRINTF(UBOOT_ERR, "read_partition ERROR !!!\n");
+		return -1;
+	}
+
+	return 0;
+}
+
+
diff --git a/lynq/S300/cp/ps/project/zx297520v3/prj_evb/source/drv/inc/drvs_ref_cfg.h b/lynq/S300/cp/ps/project/zx297520v3/prj_evb/source/drv/inc/drvs_ref_cfg.h
new file mode 100755
index 0000000..3e1630a
--- /dev/null
+++ b/lynq/S300/cp/ps/project/zx297520v3/prj_evb/source/drv/inc/drvs_ref_cfg.h
@@ -0,0 +1,267 @@
+/*******************************************************************************

+ * Copyright (C) 2007, ZTE Corporation.

+ *

+ * File Name:

+ * File Mark:

+ * Description:

+ * Others:

+ * Version:       1.0

+ * Author:        geanfeng

+ * Date:          2013-09-25

+ * History 1:

+ *     Date:

+ *     Version:

+ *     Author:

+ *     Modification:

+ * History 2:

+  ********************************************************************************/

+#ifndef _DRVS_REF_CFG_H_

+#define _DRVS_REF_CFG_H_

+#include "drvs_sys.h"

+#include "drvs_pmic_regulator.h"

+#include "drvs_chip_cfg.h" 			/*for reg base*/

+#include <generated/autoconf.h>

+

+

+

+/************************************charger*********************************/

+#define CHG_IN_GPIO_FUNC_SEL	GPIO48_GPIO48

+#define CHG_IN_EXT_INT_FUNC_SEL	GPIO48_EXT_INT1

+#define CHG_STATE_GPIO_FUNC_SEL	GPIO54_GPIO54

+#define CHG_STATE_EXT_INT_FUNC_SEL	GPIO54_EXT_INT7

+#define CHG_CTRL_GPIO_FUNC_SEL	GPIO130_GPIO130

+#define CHG_EN_GPIO_FUNC_SEL	GPIO131_GPIO131

+

+#define CHG_STATE_INT    EX7_INT

+#define CHG_IN_INT      EX1_INT

+/************************************charger   end*********************************/

+

+/************************************i2c*********************************/

+#define I2C0_CLK_FUN_SEL	GPIO43_SCL0

+#define I2C0_DATA_FUN_SEL	GPIO44_SDA0

+

+#define I2C1_CLK_FUN_SEL	GPIO45_SCL1

+#define I2C1_DATA_FUN_SEL	GPIO46_SDA1

+

+#define I2C0_WCLK_SEL      WCLK_I2C_26M

+#define I2C1_WCLK_SEL      WCLK_I2C_26M

+

+/************************************i2c end*********************************/

+

+

+/************************************lcd*********************************/

+//#define LCD_BL_IC_USED   /*GPIO used*/

+

+#define LCD_TE_ON

+

+/* LOAD-BY-TRACE flag storing address.

+    1. In normal startup procedure, BOOT will clear all IRAM space. So the value of this address will be 0.

+    2. In LOAD-BY-TRACE procedure, *.cmm script file have already set this address's content to 1. */

+#define LCD_LOADBYTRACEFLAG_ADDR    (0x82000500)

+

+#define PIN_SPI_CS			GPIO25

+#define PIN_SPI_SCL			GPIO26

+#define PIN_SPI_SDA			GPIO28

+#define PIN_SPI_DCX 			GPIO27

+#define PIN_LCD_TE                 GPIO49

+#define PIN_LCD_BL_EN           GPIO119

+#define PIN_LCD_RST 		       GPIO120

+

+

+#define SPI_CS_FUNC_SEL 	GPIO25_SSP0_CS

+#define SPI_SCL_FUNC_SEL 	GPIO26_SSP0_CLK

+#define SPI_SDA_FUNC_SEL 	GPIO28_SSP0_TXD

+#define SPI_DCX_FUNC_SEL 	GPIO27_SSP0_RXD

+

+#define GPIO_CS_FUNC_SEL 	GPIO25_GPIO25

+#define GPIO_SCL_FUNC_SEL 	GPIO26_GPIO26

+#define GPIO_SDA_FUNC_SEL 	GPIO28_GPIO28

+#define GPIO_DCX_FUNC_SEL 	GPIO27_GPIO27

+

+#define GPIO_RST_FUNC_SEL 	GPIO120_GPIO120

+#define GPIO_BL_EN_FUNC_SEL 	GPIO119_GPIO119

+

+#ifdef LCD_TE_ON

+#define GPIO_TE_FUNC_SEL GPIO49_EXT_INT2

+#define LCD_TE_INT   EX2_INT

+#define LCD_TE_INT_LEVEL   INT_NEGEDGE

+#endif

+

+

+/************************************lcd end*********************************/

+

+

+/************************************pmic*********************************/

+/*define the pmic int to ps or ap*/

+#define PMIC_INT_TO_PS

+

+#define PMIC_INT_0              ( EX0_INT )

+#define EXT_INT0_PMIC_FUNC_SEL	GPIO47_EXT_INT0

+#define PSHOLD1_PIN_GPIO_DIRECTION   GPIO_OUT/*the diff debug by GPIO*/

+

+#define PMIC_LLP_DEFINE  LLP_SHUTDOWN

+

+/************************************pmic end*********************************/

+

+/************************************spi*********************************/

+#define PIN_SPI_CS_0		GPIO25

+#define PIN_SPI_RX_0		GPIO27

+#define PIN_SPI_TX_0		GPIO28

+#define PIN_SPI_CLK_0		GPIO26

+

+#define PIN_SPI_CS_1		GPIO87

+#define PIN_SPI_RX_1		GPIO89

+#define PIN_SPI_TX_1		GPIO90

+#define PIN_SPI_CLK_1		GPIO88

+

+#define GPIO_FUN_SPI_CS_0	GPIO25_GPIO25

+#define GPIO_FUN_SPI_RX_0	GPIO27_GPIO27

+#define GPIO_FUN_SPI_TX_0	GPIO28_GPIO28

+#define GPIO_FUN_SPI_CLK_0	GPIO26_GPIO26

+

+#define GPIO_FUN_SPI_CS_1	GPIO87_GPIO87

+#define GPIO_FUN_SPI_RX_1	GPIO89_GPIO89

+#define GPIO_FUN_SPI_TX_1	GPIO90_GPIO90

+#define GPIO_FUN_SPI_CLK_1	GPIO88_GPIO88

+

+#define SSP_FUN_SPI_CS_0	GPIO25_SSP0_CS

+#define SSP_FUN_SPI_RX_0	GPIO27_SSP0_RXD

+#define SSP_FUN_SPI_TX_0	GPIO28_SSP0_TXD

+#define SSP_FUN_SPI_CLK_0	GPIO26_SSP0_CLK

+

+#define SSP_FUN_SPI_CS_1	GPIO87_CAM_SPI_CS

+#define SSP_FUN_SPI_RX_1	GPIO89_CAM_SPI_DATA0

+#define SSP_FUN_SPI_TX_1	GPIO90_CAM_SPI_TXD

+#define SSP_FUN_SPI_CLK_1	GPIO88_CAM_SPI_CLK

+

+typedef enum _T_SspMasterFreq

+{

+	SSP_MASTER_52M = 	WCLK_SSP_104M,

+	SSP_MASTER_39M = 	WCLK_SSP_78M,

+	SSP_MASTER_26M = 	WCLK_SSP_52M,

+	SSP_MASTER_13M = 	WCLK_SSP_26M,

+	SSP_MASTER_6M5 = 	WCLK_SSP_13M,

+}

+T_SspMasterFreq;

+

+typedef enum _T_SspSlaveFreq

+{		

+	SSP_SLAVE_39M = 	WCLK_SSP_156M,

+	SSP_SLAVE_26M = 	WCLK_SSP_104M,

+	SSP_SLAVE_19M5 = 	WCLK_SSP_78M,

+	SSP_SLAVE_13M = 	WCLK_SSP_52M,

+	SSP_SLAVE_6M5 = 	WCLK_SSP_26M,

+}

+T_SspSlaveFreq;

+

+#ifdef _USE_LCD_SIZE_240_320

+#define DEF_SSP0_CFG_SSPCLK		SSP_MASTER_39M 

+#else

+#define DEF_SSP0_CFG_SSPCLK		SSP_MASTER_13M 

+#endif

+/************************************spi end*********************************/

+

+#define SD_FUN_HOST_CLK_1 		GPIO72_SD1_HOST_SDCLK

+#define SD_FUN_HOST_CMD_1 		GPIO73_SD1_CMD

+#define SD_FUN_HOST_DATA0_1 	GPIO74_SD1_DATA0

+#define SD_FUN_HOST_DATA1_1 	GPIO75_SD1_DATA1

+#define SD_FUN_HOST_DATA2_1 	GPIO76_SD1_DATA2

+#define SD_FUN_HOST_DATA3_1 	GPIO77_SD1_DATA3

+

+/************************************int**************************************/

+#define INT_MODE_BASE        (PS_CRM_REG_BASE + 0x2070)

+

+/************************************int end*********************************/

+

+

+/************************************spinlock*********************************/

+#define SHARED_DEVICE1_REG	 (SOC_CRM_REG_BASE + 0x170)

+#define SHARED_DEVICE2_REG	 (SOC_CRM_REG_BASE + 0x174)

+#define SHARED_DEVICE3_REG	 (SOC_CRM_REG_BASE + 0x178)

+#define SHARED_DEVICE4_REG	 (SOC_CRM_REG_BASE + 0x17c)

+#define SHARED_DEVICE5_REG	 (SOC_CRM_REG_BASE + 0x180)

+#define SHARED_DEVICE6_REG	 (SOC_CRM_REG_BASE + 0x184)

+#define SHARED_DEVICE7_REG	 (SOC_CRM_REG_BASE + 0x188)

+#define SHARED_DEVICE8_REG	 (SOC_CRM_REG_BASE + 0x18c)

+

+/************************************spinlock end*********************************/

+/************************************audio_config*********************************/

+//_USE_REF_AUDIO_ON_7520V3_PHONE

+#define AUDIO_CODEC_EN_GPIO_FUNC_SEL	GPIO123_GPIO123

+#define AUDIO_CODEC_RESET_GPIO_FUNC_SEL	GPIO122_GPIO122

+#define AUDIO_CODEC_CLK_GPIO_FUNC_SEL	GPIO15_CLK_OUT0

+/************************************audio_config   end*********************************/

+

+/************************************camera*********************************/

+#define CAMERA_FUN_POWER       GPIO128_GPIO128

+#define CAMERA_FUN_PWDN        GPIO127_GPIO127

+#define CAMERA_FUN_MCLK        GPIO16_CLK_OUT1

+

+/************************************camera end*********************************/

+

+/************************************spicc*********************************/

+#define SPICC_FUN_CLK          	GPIO88_CAM_SPI_CLK

+#define SPICC_FUN_DATA0			GPIO89_CAM_SPI_DATA0

+#define SPICC_FUN_DATA1			GPIO90_CAM_SPI_DATA1

+#define SPICC_FUN_DATA2			GPIO91_CAM_SPI_DATA2

+#define SPICC_FUN_DATA3			GPIO92_CAM_SPI_DATA3

+

+

+/************************************spicc end*********************************/

+

+/************************************uicc************************************/

+#if (defined CONFIG_ARCH_ZX297520V3_MDL) || (defined CONFIG_ARCH_ZX297520V3_MIFI)

+#define UICC_GPIO			ZX29_GPIO_49

+#define UICC_GPIO_FUN_GPIO	GPIO49_GPIO49

+#define UICC_GPIO_EXT_INT	GPIO49_EXT_INT2

+#define UICC_EXT_INT		EX2_INT

+#define SIM_IN				GPIO_HIGH

+#define SIM_OUT				GPIO_LOW

+#define SIM_IN_LEVEL		INT_HIGHLEVEL

+#define	SIM_OUT_LEVEL		INT_LOWLEVEL

+#else 

+#define UICC_GPIO			ZX29_GPIO_50

+#define UICC_GPIO_FUN_GPIO	GPIO50_GPIO50

+#define UICC_GPIO_EXT_INT	GPIO50_EXT_INT3

+#define UICC_EXT_INT		EX3_INT

+#define SIM_IN				GPIO_LOW

+#define SIM_OUT				GPIO_HIGH

+#define SIM_IN_LEVEL		INT_LOWLEVEL

+#define	SIM_OUT_LEVEL		INT_HIGHLEVEL

+

+#endif

+

+#define UICC_GPIO_NAME		"usim_in"

+#if (defined CONFIG_ARCH_ZX297520V3_EVB) || (defined CONFIG_ARCH_ZX297520V3_MDL) || (defined CONFIG_ARCH_ZX297520V3_CPE) || (defined CONFIG_ARCH_ZX297520V3_WATCH) || (defined CONFIG_ARCH_ZX297520V3_MIFI)

+#define UICC_ENABLE_IN_OUT_DETECTION

+#endif

+/**********************************uicc end**********************************/

+

+

+/************************************dma*********************************/

+#define DMAC0_CFG_CH0		DMA_CHANNEL_CONFIG(DMAC0_CH_UART0_TX,CORE_ID_ARM0,FALSE,FALSE)

+#define DMAC0_CFG_CH1		DMA_CHANNEL_CONFIG(DMAC0_CH_UART0_RX,CORE_ID_ARM0,FALSE,FALSE)

+#define DMAC0_CFG_CH2		DMA_CHANNEL_CONFIG(DMAC0_CH_UART1_TX,CORE_ID_ARM0,FALSE,FALSE)

+#define DMAC0_CFG_CH3		DMA_CHANNEL_CONFIG(DMAC0_CH_UART1_RX,CORE_ID_ARM0,FALSE,FALSE)

+#define DMAC0_CFG_CH4		DMA_CHANNEL_CONFIG(DMAC0_CH_SSP0_TX,CORE_ID_ARM0,FALSE,FALSE)

+#define DMAC0_CFG_CH5		DMA_CHANNEL_CONFIG(DMAC0_CH_SSP0_RX,CORE_ID_ARM0,FALSE,TRUE)

+#define DMAC0_CFG_CH6		DMA_CHANNEL_CONFIG(DMAC0_CH_GPRS0,CORE_ID_ARM0,FALSE,FALSE)

+#define DMAC0_CFG_CH7		DMA_CHANNEL_CONFIG(DMAC0_CH_GPRS1,CORE_ID_ARM0,FALSE,FALSE)

+#define DMAC0_CFG_CH8		DMA_CHANNEL_CONFIG(DMAC0_CH_USIM,CORE_ID_ARM0,FALSE,FALSE)

+#define DMAC0_CFG_CH9		DMA_CHANNEL_CONFIG(DMAC0_CH_I2S0_TX,CORE_ID_ARM0,FALSE,FALSE)

+#define DMAC0_CFG_CH10		DMA_CHANNEL_CONFIG(DMAC0_CH_I2S0_RX0,CORE_ID_ARM0,FALSE,FALSE)

+#define DMAC0_CFG_CH11		DMA_CHANNEL_CONFIG(DMAC0_CH_I2S1_TX,CORE_ID_ARM0,FALSE,FALSE)

+#define DMAC0_CFG_CH12		DMA_CHANNEL_CONFIG(DMAC0_CH_I2S1_RX0,CORE_ID_ARM0,FALSE,FALSE)

+#define DMAC0_CFG_CH13		DMA_CHANNEL_CONFIG(DMAC0_CH_SPIFC0_TX,CORE_ID_ARM0,FALSE,FALSE)

+#define DMAC0_CFG_CH14		DMA_CHANNEL_CONFIG(DMAC0_CH_SPIFC0_RX,CORE_ID_ARM0,FALSE,FALSE)

+#define DMAC0_CFG_CH15		DMA_CHANNEL_CONFIG(DMAC0_CH_SSP1_TX,CORE_ID_ARM0,FALSE,TRUE)

+#define DMAC0_CFG_CH16		DMA_CHANNEL_CONFIG(DMAC0_CH_SSP1_RX,CORE_ID_ARM0,FALSE,FALSE)

+#define DMAC0_CFG_CH17		DMA_CHANNEL_CONFIG(DMAC0_CH_UART2_TX,CORE_ID_ARM0,FALSE,TRUE)

+#define DMAC0_CFG_CH18		DMA_CHANNEL_CONFIG(DMAC0_CH_UART2_RX,CORE_ID_ARM0,FALSE,TRUE)

+#define DMAC0_CFG_CH19		DMA_CHANNEL_CONFIG(DMAC0_CH_EMBMS,CORE_ID_ARM0,FALSE,FALSE)

+#define DMAC0_CFG_CH20		DMA_CHANNEL_CONFIG(DMAC0_CH_USIM1,CORE_ID_ARM0,FALSE,FALSE)

+#define DMAC0_CFG_CH21		DMA_CHANNEL_CONFIG(DMAC0_CH_M2M_TX,CORE_ID_ARM0,FALSE,TRUE)

+#define DMAC0_CFG_CH22		DMA_CHANNEL_CONFIG(DMAC0_CH_M2M_RX,CORE_ID_ARM0,FALSE,TRUE)

+/************************************dma end*********************************/

+

+#endif/*_DRVS_REF_CFG_H_*/