[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit

Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/ap/app/zte_comm/wlan/inc/Vector.h b/ap/app/zte_comm/wlan/inc/Vector.h
new file mode 100755
index 0000000..bc46527
--- /dev/null
+++ b/ap/app/zte_comm/wlan/inc/Vector.h
@@ -0,0 +1,55 @@
+#ifndef __VECTOR_H__
+#define __VECTOR_H__
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+#include <assert.h>
+
+#define VECTOR_DEFAULT_CAPACITY (100)
+
+typedef enum
+{
+    TYPE_UNDEFINED,
+    IS_LONG,
+    IS_FLOAT,
+    IS_STRING
+} Type;
+
+typedef struct var
+{
+    Type type;
+    union
+    {
+        long lval;
+        float fval;
+        struct
+        {
+            size_t len;
+            char* sval;
+        } str;
+    } val;
+}Var;
+
+typedef struct vector
+{
+    size_t size;
+    size_t capacity;
+    Var** data;
+} vector_t;
+
+Var* var_long(long value);
+Var* var_float(float value);
+Var* var_string(char* value);
+void var_print(Var* var);
+void var_destroy(Var* var);
+const char* const var_type_of_token(Type t);
+
+vector_t* vector_init();
+void vector_push_back(vector_t*, Var*);
+size_t vector_size(vector_t*);
+Var* vector_get(vector_t*, size_t);
+void vector_free(vector_t*);
+
+#endif /* __VECTOR_H__ */
diff --git a/ap/app/zte_comm/wlan/inc/wifi_ap_ctrl.h b/ap/app/zte_comm/wlan/inc/wifi_ap_ctrl.h
new file mode 100755
index 0000000..078563f
--- /dev/null
+++ b/ap/app/zte_comm/wlan/inc/wifi_ap_ctrl.h
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _SOFTAP_CONTROLLER_H
+#define _SOFTAP_CONTROLLER_H
+#include <stdbool.h>
+
+#include <net/if.h>
+#include <wifi_socket.h>
+#include <semaphore.h>
+#include <rtc_timer.h>
+
+#define SOFTAP_MAX_BUFFER_SIZE	4096
+#define AP_BSS_START_DELAY	200000
+#define AP_BSS_STOP_DELAY	500000
+#define AP_SET_CFG_DELAY	500000
+#define AP_DRIVER_START_DELAY	800000
+#define AP_CHANNEL_DEFAULT	6
+
+/* Used to retry syscalls that can return EINTR. */
+#ifndef TEMP_FAILURE_RETRY
+#define TEMP_FAILURE_RETRY(exp) ({           \
+	typeof (exp) _rc;                        \
+	do{                                      \
+		_rc = (exp);                         \
+	}while((_rc == -1) && (errno == EINTR)); \
+	_rc; })
+#endif
+
+#define NVIO_WIFI_LEN_8					8
+#define NVIO_WIFI_LEN_16				16
+#define NVIO_WIFI_LEN_32				32
+
+typedef struct   wlan_ap_para {
+	char wifi_set_flags[NVIO_WIFI_LEN_8];
+	char ssid[WIFI_STATION_SSID_LEN];
+	char ignore_broadcast_ssid[NVIO_WIFI_LEN_8];
+	char auth_mode[WIFI_STATION_AUTH_MODE_LEN];
+	char password[WIFI_STATION_SPOT_PASSWORD_LEN];
+	char max_num_sta[NVIO_WIFI_LEN_8];
+	char wifi_11n_cap[NVIO_WIFI_LEN_8];
+	char WirelessMode[NVIO_WIFI_LEN_8];
+	char  Channel[NVIO_WIFI_LEN_8];
+	char  CountryCode[NVIO_WIFI_LEN_8];
+	char  wifi_band[NVIO_WIFI_LEN_8] ;
+	char wifi_coverage[NVIO_WIFI_LEN_16];
+	char accesspolicy0[NVIO_WIFI_LEN_8];
+	char m_ssid[WIFI_STATION_SSID_LEN];
+	char m_ignore_broadcast_ssid[NVIO_WIFI_LEN_8];
+	char m_auth_mode[WIFI_STATION_AUTH_MODE_LEN];
+	char m_password[WIFI_STATION_SPOT_PASSWORD_LEN];
+	char m_max_num_sta[NVIO_WIFI_LEN_8];
+}basic_para;
+
+
+typedef struct   wlan_ap_server {
+	struct   wlan_socket  sock;
+	struct   wlan_socket  sock_m;
+	struct   wlan_ap_para  ap_para;
+	struct   wlan_drv_proxy  drv_proxy;
+
+	int		ap0_state;		//0 :close   1: open
+	int 		ap1_state;
+	int 		ap0_wps_state;
+	int		ap1_wps_state;
+	int 		g_tsw_sleep_flag;//ÓÐÎÞ´´½¨¶¨Ê±Ë¯ÃßµÄrtc timer
+	int 		g_tsw_wake_flag;//ÓÐÎÞ´´½¨¶¨Ê±»½ÐѵÄrtc timer
+
+	int 		g_sta_num;
+	sem_t 	g_hostap_id;
+	int 		g_hostap;
+
+	void 		(*drv_insmod)(struct   wlan_ap_server *ap_svr);
+	void 		(*init)(struct   wlan_ap_server *ap_svr);
+	int 		(*enable)(struct   wlan_ap_server *ap_svr);
+	void 		(*disable)(struct   wlan_ap_server *ap_svr);
+	void  	(*open)(struct   wlan_ap_server *ap_svr);
+	int  		(*setap)(struct   wlan_ap_server *ap_svr);
+	int  		(*startap)(struct   wlan_ap_server *ap_svr);
+	int		(*stopap)(struct   wlan_ap_server *ap_svr);
+	int		(*basic_deal)(struct   wlan_ap_server *ap_svr, int  cmd);
+	
+}wlan_ap_server_t;
+
+
+void *hostap_loop (void *param);
+#if defined(__MULTI_AP__)
+void *hostap_loop_multi(void *param);
+#endif
+
+
+LONG wlan_get_wps_sta();
+int captureWlanStaInfo();
+void wps_deal (MSG_BUF *pstMsg);
+void acl_set_process();
+void wps_down (MSG_BUF* pMsg);
+void wps_up();
+void wlan_ap_open ();
+int wifi_fw_mac_config_ssid(struct wlan_ap_server *ap_svr);
+void apsta_connect_enable_ap();
+
+
+#endif
diff --git a/ap/app/zte_comm/wlan/inc/wifi_drv_ko.h b/ap/app/zte_comm/wlan/inc/wifi_drv_ko.h
new file mode 100755
index 0000000..cc084f8
--- /dev/null
+++ b/ap/app/zte_comm/wlan/inc/wifi_drv_ko.h
@@ -0,0 +1,49 @@
+

+#ifndef   __WIFI_DRV_KO__

+

+#define __WIFI_DRV_KO__

+

+#include "wifi_util.h"

+

+#define  SSV6X5X_INSMODE_STACMD  	 "/sbin/insmod /lib/modules/3.4.110-rt140/kernel/drivers/net/wireless/ssv6x5x/ssv6x5x_host/ssv6x5x.ko stacfgpath=/etc/firmware/ssv6x5x-wifi.cfg"

+#define  SSV6X5X_RMMOD_STACMD		 "/sbin/rmmod ssv6x5x"

+#define  SSV6X5X_PREALLOC_INSMODE  	 "/sbin/insmod /lib/modules/3.4.110-rt140/kernel/drivers/net/wireless/ssv6x5x/prealloc/ssv6xxx_prealloc_skb.ko"

+

+#define  AIC8800DW_INSMODE_STACMD  	 "/sbin/insmod /lib/modules/3.4.110-rt140/kernel/drivers/net/wireless/aic8800/aic8818_fdrv.ko"

+#define  AIC8800DW_RMMOD_STACMD		 "/sbin/rmmod aic8818_fdrv"

+

+

+#define  XR819_INSMODE_STACMD  	 "/sbin/insmod /lib/modules/3.4.110-rt140/kernel/drivers/net/wireless/xradio/wlan/xradio_wlan.ko"

+#define  XR819_RMMOD_STACMD		 "/sbin/rmmod xradio_wlan"

+

+#define  ESP8089_INSMODE_STACMD  	 "/sbin/insmod /lib/modules/3.4.110-rt140/kernel/drivers/net/wireless/esp8089/eagle.ko"

+#define  ESP8089_RMMOD_STACMD		 "/sbin/rmmod eagle"

+

+

+#define  RDA5995_INSMODE_APCMD   	"/sbin/insmod /lib/modules/3.4.110-rt140/kernel/drivers/net/wireless/rdaw5995/rdawlan/rdawfmac.ko firmware_path=ap"

+#define  RDA5995_INSMODE_STACMD  	"/sbin/insmod /lib/modules/3.4.110-rt140/kernel/drivers/net/wireless/rdaw5995/rdawlan/rdawfmac.ko firmware_path=sta"

+#define  RDA5995_RMMOD_CMD			"/sbin/rmmod rdawfmac"

+

+

+//#define  RDA5995_INSMODE_APCMD   	"insmod /lib/modules/3.4.110/kernel/drivers/net/wireless/rdaw5995/rdawlan/rdawfmac.ko firmware_path=ap"

+//#define  RDA5995_INSMODE_STACMD  	"insmod /lib/modules/3.4.110/kernel/drivers/net/wireless/rdaw5995/rdawlan/rdawfmac.ko firmware_path=sta"

+//#define  RDA5995_RMMOD_CMD			"rmmod rdawfmac"

+

+

+

+struct wlan_drv_proxy {

+	int		drv_init_flag;

+	char *	iface_name;

+	char*	insmod_cmd;

+	char* 	rmmod_cmd;

+	int 		(*drv_init)(struct   wlan_drv_proxy *drv_proxy);

+	int 		(*drv_deinit)(struct   wlan_drv_proxy *drv_proxy);

+};

+

+int   wlan_drv_deinit(struct  wlan_drv_proxy * proxy);

+

+int   wlan_drv_init(struct  wlan_drv_proxy * proxy);

+

+int   wlan_drv_pre_init(struct  wlan_drv_proxy * proxy);

+

+#endif

diff --git a/ap/app/zte_comm/wlan/inc/wifi_hal.h b/ap/app/zte_comm/wlan/inc/wifi_hal.h
new file mode 100755
index 0000000..2ba575e
--- /dev/null
+++ b/ap/app/zte_comm/wlan/inc/wifi_hal.h
@@ -0,0 +1,66 @@
+

+#ifndef __WIIF__HAL_H__

+#define  __WIIF__HAL_H__

+

+extern int capturemactimer_create;

+extern int g_wifi_state;

+extern int g_wps_state;

+extern int g_va1_state;

+extern int g_tsw_sleep_flag;

+extern int g_tsw_wake_flag;

+

+

+#define STATION_ACCESS_CHECK_PERIOD 3000 // 1000-->3000, avoid not sleep

+#define WIFI_INIT_TIMEOUT_VAL 300000

+#define TIMER_FLAG_RESTART 1  

+#define TIMER_GET_COUNT 30  

+#define TIMER_WIFI_INIT 31

+#define WIFI_MODULE_ID 1000

+#define ACL_TIMER_ID 10001

+

+#ifndef OK

+#define OK 0

+#endif

+

+#ifndef ERROR

+#define ERROR 1

+#endif

+

+

+

+

+void handle_wps_mac(MSG_BUF *pstMsg);

+

+//TODO: ÕâÁ½¸öº¯ÊýûÓÐʵÏÖÌå

+void wlan_config_pwr_save_enable();

+void wlan_config_pwr_save_disable();

+

+//void remove_all_acl_timer();

+void  wlan_netlink_parse_msg(int event_type);

+

+int  captureWlanStaInfo();

+

+void wps_off();

+void wps_up();

+void wps_down(MSG_BUF* pMsg);

+void acl_set_mac(char *athx);

+

+#ifdef __ACL_MAC__

+void wlan_acl_set_mac_timer(MSG_BUF *pstMsg);

+void wlan_del_mac_from_acl_time_list(MSG_BUF *pstMsg);

+#endif

+

+#ifdef __WIFI_LTE__

+void basic_deal_for_lte();

+extern int g_need_for_change_channel_for_deal;

+

+//extern int g_need_for_change_channel_for_wps;

+

+#endif

+

+void wlan_init(void);

+void acl_set_process();

+LONG wlan_get_wps_sta();

+

+

+#endif

diff --git a/ap/app/zte_comm/wlan/inc/wifi_socket.h b/ap/app/zte_comm/wlan/inc/wifi_socket.h
new file mode 100755
index 0000000..4f3553c
--- /dev/null
+++ b/ap/app/zte_comm/wlan/inc/wifi_socket.h
@@ -0,0 +1,172 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _WIFI_H
+#define _WIFI_H
+
+#if __cplusplus
+extern "C" {
+#endif
+
+
+struct  wlan_socket{
+	char * 	iface_name;
+	char * 	sockets_dir;
+	struct 	wpa_ctrl *ctrl_conn;
+	struct 	wpa_ctrl *monitor_conn;
+ 	int 		exit_sockets[2];/* socket pair used to exit from a blocking read */
+ 	pid_t 	pid;
+};
+
+/**
+ * Load the Wi-Fi driver.
+ *
+ * @return 0 on success, < 0 on failure.
+ */
+int wifi_load_driver();
+
+/**
+ * Unload the Wi-Fi driver.
+ *
+ * @return 0 on success, < 0 on failure.
+ */
+int wifi_unload_driver();
+
+/**
+ * Check if the Wi-Fi driver is loaded.
+ *
+ * @return 0 on success, < 0 on failure.
+ */
+int is_wifi_driver_loaded();
+
+
+/**
+ * Start supplicant.
+ *
+ * @return 0 on success, < 0 on failure.
+ */
+//int wifi_start_supplicant (struct  wlan_sta_manager *sta_ctrl);
+/**
+ * Stop supplicant.
+ *
+ * @return 0 on success, < 0 on failure.
+ */
+//int wifi_stop_supplicant(struct  wlan_sta_manager *sta_ctrl);
+
+/**
+ * Open a connection to supplicant
+ *
+ * @return 0 on success, < 0 on failure.
+ */
+int wifi_connect_to_supplicant(struct  wlan_socket*skt);
+
+/**
+ * Close connection to supplicant
+ *
+ * @return 0 on success, < 0 on failure.
+ */
+//void wifi_close_supplicant_connection(struct  wlan_sta_manager *sta_ctrl);
+
+/**
+ * wifi_wait_for_event() performs a blocking call to 
+ * get a Wi-Fi event and returns a string representing 
+ * a Wi-Fi event when it occurs.
+ *
+ * @param buf is the buffer that receives the event
+ * @param len is the maximum length of the buffer
+ *
+ * @returns number of bytes in buffer, 0 if no
+ * event (for instance, no connection), and less than 0
+ * if there is an error.
+ */
+int wifi_wait_for_event(struct wlan_socket *skt, char *buf, size_t len);
+
+/**
+ * wifi_command() issues a command to the Wi-Fi driver.
+ *
+ * Android extends the standard commands listed at
+ * /link http://hostap.epitest.fi/wpa_supplicant/devel/ctrl_iface_page.html
+ * to include support for sending commands to the driver:
+ *
+ * See wifi/java/android/net/wifi/WifiNative.java for the details of
+ * driver commands that are supported
+ *
+ * @param command is the string command (preallocated with 32 bytes)
+ * @param commandlen is command buffer length
+ * @param reply is a buffer to receive a reply string
+ * @param reply_len on entry, this is the maximum length of
+ *        the reply buffer. On exit, the number of
+ *        bytes in the reply buffer.
+ *
+ * @return 0 if successful, < 0 if an error.
+ */
+int wifi_command(struct wlan_socket *skt, const char *command, char *reply, size_t *reply_len);
+
+/**
+ * do_dhcp_request() issues a dhcp request and returns the acquired
+ * information. 
+ * 
+ * All IPV4 addresses/mask are in network byte order.
+ *
+ * @param ipaddr return the assigned IPV4 address
+ * @param gateway return the gateway being used
+ * @param mask return the IPV4 mask
+ * @param dns1 return the IPV4 address of a DNS server
+ * @param dns2 return the IPV4 address of a DNS server
+ * @param server return the IPV4 address of DHCP server
+ * @param lease return the length of lease in seconds.
+ *
+ * @return 0 if successful, < 0 if error.
+ */
+int do_dhcp_request(int *ipaddr, int *gateway, int *mask,
+                   int *dns1, int *dns2, int *server, int *lease);
+
+/**
+ * Return the error string of the last do_dhcp_request().
+ */
+const char *get_dhcp_error_string();
+
+/**
+ * Return the path to requested firmware
+ */
+#define WIFI_GET_FW_PATH_STA	0
+#define WIFI_GET_FW_PATH_AP	1
+#define WIFI_GET_FW_PATH_P2P	2
+const char *wifi_get_fw_path(int fw_type);
+
+/**
+ * Change the path to firmware for the wlan driver
+ */
+int wifi_change_fw_path(const char *fwpath);
+
+/**
+ * Check and create if necessary initial entropy file
+ */
+#define WIFI_ENTROPY_FILE	"/data/misc/wifi/entropy.bin"
+int ensure_entropy_file_exists();
+
+pid_t read_wpa_pid();
+
+int wifi_connect_to_hostapd(struct wlan_socket *skt);
+void wifi_close_sockets(struct wlan_socket *skt);
+char *docmd (struct wlan_socket *skt, const char *command);
+int check_alive(struct wlan_socket *skt);
+
+#if __cplusplus
+};  // extern "C"
+#endif
+
+#endif  // _WIFI_H
diff --git a/ap/app/zte_comm/wlan/inc/wifi_sta_ctrl.h b/ap/app/zte_comm/wlan/inc/wifi_sta_ctrl.h
new file mode 100755
index 0000000..fefdcfe
--- /dev/null
+++ b/ap/app/zte_comm/wlan/inc/wifi_sta_ctrl.h
@@ -0,0 +1,29 @@
+#ifndef RDA_SM_H

+#define RDA_SM_H

+

+#include "wifi_socket.h"

+#include "wifi_drv_ko.h"

+

+#define  WIRI_ROOT_DIR		"/etc_rw"

+#define  SUPPLICANT_CONF		WIRI_ROOT_DIR"/wifi/wpa_supplicant.conf"

+#define WPA_PID_FILE   		WIRI_ROOT_DIR"/wifi/wpa_file.pid"

+

+struct   wlan_sta_manager {

+

+	struct wlan_socket  sock;

+	struct wlan_drv_proxy  drv_proxy;

+

+	void 		(*init)(struct   wlan_sta_manager *sta_ctrl);

+	int 		(*start_supplicant)(struct   wlan_sta_manager *sta_ctrl);

+	int 		(*stop_supplciant)(struct   wlan_sta_manager *sta_ctrl);

+	void 		 (*close_connection)(struct   wlan_sta_manager *sta_ctrl);

+	void		(*scan)(struct   wlan_sta_manager *sta_ctrl);

+};

+

+

+

+

+

+

+

+#endif

diff --git a/ap/app/zte_comm/wlan/inc/wifi_util.h b/ap/app/zte_comm/wlan/inc/wifi_util.h
new file mode 100755
index 0000000..61c6bfe
--- /dev/null
+++ b/ap/app/zte_comm/wlan/inc/wifi_util.h
@@ -0,0 +1,103 @@
+/*

+        Wifi Ä£¿é¹«¹²¹¤¾ßÍ·Îļþ

+*/

+

+#ifndef  WIFI_UTIL_H

+#define WIFI_UTIL_H

+

+#include <stdio.h>

+#include <errno.h>

+#include <string.h>

+#include <stdlib.h>

+#include <stdarg.h>

+#include <sys/types.h>

+#include <sys/ioctl.h>

+#include <sys/prctl.h>

+#include <pthread.h>

+#include <linux/netlink.h>

+#include <sys/inotify.h>

+#include <linux/rtc.h>

+#include <sys/stat.h>

+#include <fcntl.h>

+#include <netinet/in.h>

+#include <unistd.h>

+#include <sys/ipc.h>

+#include <sys/msg.h>

+#include <syslog.h>

+#include <signal.h>

+#include <sys/time.h>

+#include <time.h>

+#include "softap_api.h"

+#include "netotherapi.h"

+

+

+

+#define CASE_RETURN_STR(x) case x: return #x;

+// Useful macros..

+#define MIN( a, b ) ((a) < (b) ? (a) : (b))

+#define MAX( a, b ) ((a) < (b) ? (b) : (a))

+#define safe_free(x) do { if(x) {free(x); x=NULL;} } while(0)

+#define itoa(i,a,b) (((b) == 16) ? sprintf((a), "%x", (i)) : sprintf((a), "%d", (i)))

+

+

+enum {

+	WIFI_CFG_OPEN,                //´ò¿ªwifi

+	WIFI_CFG_CLOSE,               //¹Ø±Õwifi

+	WIFI_CFG_OPEN_MSSID,          //´ò¿ª¸±ssid

+	WIFI_CFG_CLOSE_MSSID,         //¹Ø±Õ¸±ssid

+	WIFI_CFG_OPEN_VA0_VA1,        //´ò¿ªÖ÷¸±ssid

+	WIFI_CFG_RF,                  //ÅäÖÃÉ䯵²ÎÊý

+	WIFI_CFG_AP,                  //ÅäÖÃAP

+	WIFI_CFG_MSSID,               //ÅäÖø±ssid

+	WIFI_CFG_RESTART_APSTATION,   //ÖØÆôap station

+	WIFI_CFG_RESTART_AP,          //ÖØÆôap

+	WIFI_CFG_CLOSESTA_OPENMSSID,  //¹Ø±Õstation£¬´ò¿ª¸±ssid

+	WIFI_CFG_FORCE_RESTART,       //Ç¿ÖÆÖØÆôwifi

+	WIFI_CFG_SLEEP,               //˯Ãß

+	WIFI_CFG_CHANNEL_FOLLOW,      //APÐŵÀ¸úËæSTA

+	WIFI_CFG_APSTA_OPEN_AP,		  //apstaÁ¬½Ó³É¹¦´ò¿ªap

+};

+

+void wf_write_file (char* file, char* status);

+int wf_get_msg_qid (int module_id);

+int wf_create_msg_id (int module_id);

+void wf_ms_sleep (unsigned long mSec);

+int find_substr_num (char* str, char substr);

+int find_substr_num_for_acl (char* str, char substr);

+void write_status (char* file, const char* status);

+void wlan_write_file (char* file_path, char* param);

+int wf_create_msg_qid (int module_id);

+void  wf_create_thread (void *thread_name, void * (*thread_loop) (void*));

+#define  wf_err(fmt, args...)	\

+	do {slog(WIFI_PRINT,SLOG_ERR,   "[wlan][%s-%d]: " fmt"\n", __FUNCTION__, __LINE__, ## args);} while (0)

+

+

+#define  wf_log(fmt, args...)	\

+	do {slog(WIFI_PRINT,SLOG_ERR,   "[wlan][%s-%d]: " fmt"\n", __FUNCTION__, __LINE__, ## args);} while (0)

+

+//	do {wlog("[wlan][%s]: " fmt"\n", __FUNCTION__, ## args);} while (0)

+unsigned int deleteCharFromStr (char c, char* instr, char* outstr);

+void* safe_malloc (int size, unsigned char is_assert);

+void safe_strcpy (char* dest, char* source, int size);

+int wlan_readfile (const char *path, char * buf,  int  len);

+int wfsystem(const char * cmd);

+unsigned char s2x (char *s);

+

+int ensure_config_dir_exist(char * dir);

+ int   get_file_size (char * file);

+

+int ensure_file_exist(char * file);

+void write_lockfile (char *filepath, char *setbuf);

+

+

+int wf_msg_to_zcore(unsigned short msg_cmd, unsigned short datalen, unsigned char *pData);

+int wf_msg_to_mmi(unsigned short msg_cmd, unsigned short datalen, unsigned char *pData);

+int wf_msg_to_self(unsigned short msg_cmd, unsigned short datalen, unsigned char *pData);

+#ifdef __AP_FUNC__

+int wifi_aes_init_key(void);

+int wifi_encrypt_code(void);

+int wifi_decrypt_code(void);

+int wifi_decode_b2s(void);

+#endif

+

+#endif

diff --git a/ap/app/zte_comm/wlan/inc/wlan-station.h b/ap/app/zte_comm/wlan/inc/wlan-station.h
new file mode 100755
index 0000000..dfd477b
--- /dev/null
+++ b/ap/app/zte_comm/wlan/inc/wlan-station.h
@@ -0,0 +1,36 @@
+#ifndef _WLAN_STATION
+#define _WLAN_STATION
+
+#include <linux/rtc.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <netinet/in.h>
+#include <unistd.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+#include <pthread.h>
+#include <syslog.h>
+#include <signal.h>
+#include <sys/time.h>
+#include <time.h>
+#include "../include/softap_api.h"
+//#include "../include/errorcode.h"
+//#include "../include/netapi.h"
+
+void   wlan_station_init(void);
+BOOL wlan_station_is_station_msg(unsigned short msg);
+void   wlan_station_msg_handle(MSG_BUF *pMsg);
+void Delete_connect_timeout_timer(void);
+void wifi_station_close();
+
+void  wlan_statemachine_init();
+void  wlan_station_open();
+
+#endif
+
diff --git a/ap/app/zte_comm/wlan/inc/wlan_config_ssid.h b/ap/app/zte_comm/wlan/inc/wlan_config_ssid.h
new file mode 100755
index 0000000..623bfa3
--- /dev/null
+++ b/ap/app/zte_comm/wlan/inc/wlan_config_ssid.h
@@ -0,0 +1,32 @@
+#ifndef _WLAN_SSID
+#define _WLAN_SSID
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/msg.h>
+#include <softap_api.h>
+#include "cfg_api.h"
+//#include <nvram.h>
+//#include <cfg_param.h>
+
+#include <semaphore.h>
+#include "wifi_util.h"
+#define WLAN_MAC_ADDR_LEN  12    //WIFI KEY LEN
+#define WLAN_NV_WPAPSK1_NAME "WPAPSK1"
+#define WLAN_NV_WPAPSK1_LENGTH 65
+#define WLAN_NV_WIFI_WPS_DEF_PIN_NAME "wifi_def_pin"
+
+/**********************************************************************************
+º¯Êý×÷ÓÃ:Ïß³ÌÈë¿Ú º¯Êý
+***********************************************************************************/
+//VOID *wifi_ssid_init_entry(VOID *args);
+void get_mac_config_ssid_key_nv();
+void  send_get_mac_req();
+
+char* wlan_base64_encode (const char* data, int data_len);
+
+#endif
diff --git a/ap/app/zte_comm/wlan/inc/wlan_main.h b/ap/app/zte_comm/wlan/inc/wlan_main.h
new file mode 100755
index 0000000..4f8ddf4
--- /dev/null
+++ b/ap/app/zte_comm/wlan/inc/wlan_main.h
@@ -0,0 +1,13 @@
+#ifndef _WLAN_SERVER
+#define _WLAN_SERVER
+#include <semaphore.h>
+#include "softap_api.h"
+//#include "errorcode.h"
+#include "wlan_interface.h"
+
+#define CASE_RETURN_STR(x) case x: return #x;
+
+
+
+#endif
+
diff --git a/ap/app/zte_comm/wlan/inc/wlan_rtc_sleep.h b/ap/app/zte_comm/wlan/inc/wlan_rtc_sleep.h
new file mode 100755
index 0000000..6504a80
--- /dev/null
+++ b/ap/app/zte_comm/wlan/inc/wlan_rtc_sleep.h
@@ -0,0 +1,23 @@
+#ifndef __WLAN_RTC_SLEEP__

+#define __WLAN_RTC_SLEEP__

+

+

+

+

+int disable_rtc_tsw_close_timer();

+int disable_rtc_tsw_open_timer();

+int create_rtc_tsw_close_timer (ULONG ulSec);

+int create_rtc_tsw_open_timer (ULONG ulSec);

+void handle_tsw_setting();

+void wlan_reset_sleep_timer();

+ void check_to_presleep (int wifi_status, int charging_status, int sta_num, int wps_status);

+

+void cancel_all_timer();

+void wlan_prepare_sleep();

+

+ LONG create_rtc_wps_timer (int ulSec);

+int  disable_rtc_sleep_timer();

+int disable_rtc_wps_timer();

+void handle_tsw_close();

+

+#endif

diff --git a/ap/app/zte_comm/wlan/inc/wlan_sm.h b/ap/app/zte_comm/wlan/inc/wlan_sm.h
new file mode 100755
index 0000000..7991b4c
--- /dev/null
+++ b/ap/app/zte_comm/wlan/inc/wlan_sm.h
Binary files differ
diff --git a/ap/app/zte_comm/wlan/inc/wlan_sta_manager.h b/ap/app/zte_comm/wlan/inc/wlan_sta_manager.h
new file mode 100755
index 0000000..a438ac2
--- /dev/null
+++ b/ap/app/zte_comm/wlan/inc/wlan_sta_manager.h
@@ -0,0 +1,145 @@
+#ifndef STA_MANAGER_H

+#define STA_MANAGER_H

+

+#include "wlan_sm.h"

+

+#define  SUCCESS  "1"

+#define  FAILED   "0"

+#define REPLY_BUF_SIZE 4096 // wpa_supplicant's maximum size.

+

+#define WIFI_STATION_TIMER_SCAN           111

+#define WIFI_STATION_TIMER_SCAN_INTERVAL  60000  /// 10 ----> 15s nxl

+

+#define WIFI_STATION_CMD_LEN    256

+#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_FLAGS_LEN    128

+

+

+#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_SPOT_LEN  256

+#define WIFI_STATION_SPOT_LIST_NUM  10

+

+#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_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_ENCRYPT_WEP  "WEP"

+#define WIFI_STATION_PROFILE_ENCRYPT_CCMP  "CCMP"

+#define WIFI_STATION_PROFILE_ENCRYPT_TKIP  "TKIP"

+

+

+#define NV_WIFI_ENABLED		"wifiEnabled"

+#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"

+

+

+

+

+

+typedef struct {

+	char  mac[WIFI_STATION_MAC_LEN];

+	char  ssid[WIFI_STATION_SSID_LEN];

+	char  password[WIFI_STATION_SPOT_PASSWORD_LEN];

+}connect_ssid_t;

+

+

+typedef void (*sta_sm_handler_t)(wlan_sm_event_t evt, void * data);

+

+typedef enum{

+	DISCONNECT_AUTO,

+	DISCONNECT_MANUAL,

+}disconnect_type_t;

+

+typedef enum{

+	CONNECT_AUTO,

+	CONNECT_MANUAL,

+}connect_type_t;

+

+

+#define  DHCP_RETRY_TIMES		3

+#define  CONN_RETRY_TIMES		3

+

+typedef struct {

+	int list_id;// g_spot_list  id

+	int linked_id;

+	char linking_mac[WIFI_STATION_MAC_LEN];

+	int conn_status;

+	disconnect_type_t  disc_type;

+	connect_type_t  conn_type;

+	wlan_sm_handle_t sm_handle;

+	int spots_num;

+	int scan_spot_num;

+	int dhcp_retry_times;

+	int conn_retry_times;

+	int disable_others;

+	int softtimer;

+}wlan_sta_handle_t;

+

+typedef struct {

+	int id;

+	int auth_failures;

+	int wrong_key;

+	int conn_failed;

+	int auth_failed;

+}tmp_disabled_t;

+

+typedef struct {

+	char  mac[WIFI_STATION_MAC_LEN] ;

+	char  ssid[WIFI_STATION_SSID_LEN];

+}try_assoc_t;

+

+

+typedef struct {

+	int   id;

+	char  mac[WIFI_STATION_MAC_LEN] ;

+}sup_connected_t;

+

+

+typedef struct {

+	wlan_sm_event_t evt;

+	char data[512];

+}supplicant_evt_t;

+

+void  wlan_statemachine_init();

+int wlan_sta_parse_msg (MSG_BUF *pMsg);

+void  wlan_station_open();

+void *station_loop (void *param);

+

+#endif