[Bugfix][T106][bug-view-2139][bug-view-2140] support qser_wifi_lanhost_get_list for both wifi
Change-Id: I439a54fb28bee1829516c8ebe0351e303548ecbe
diff --git a/ap/app/zte_comm/wlan/src/wifi_ap_ctrl.c b/ap/app/zte_comm/wlan/src/wifi_ap_ctrl.c
index a0707d7..e32c427 100755
--- a/ap/app/zte_comm/wlan/src/wifi_ap_ctrl.c
+++ b/ap/app/zte_comm/wlan/src/wifi_ap_ctrl.c
@@ -107,6 +107,8 @@
static int g_ap_sta_num_full = 0;
*/
+#define local_wf_msg_to_self(msg_cmd,datalen,pData) wf_msg_to_self((msg_cmd+(ap_svr->g_ap_index == 0 ? 0 : 0x100)), datalen, pData)
+
#define ACCEPT_MAC_FILE (ap_svr->g_accept_mac_file)
#define DENY_MAC_FILE (ap_svr->g_deny_mac_file)
#define HOSTAPD_CONF_FILE (ap_svr->g_hostapd_conf_file)
@@ -2203,7 +2205,7 @@
ap_docmd("DISABLE", NULL);
if(ap_server->ap0_wps_state == 1){
- wf_msg_to_self(MSG_CMD_WIFI_WPS_DOWN, 2, "1");
+ local_wf_msg_to_self(MSG_CMD_WIFI_WPS_DOWN, 2, "1");
}
#if defined(__AIC_8800DW_CHIP__)
@@ -2383,14 +2385,14 @@
//kw 3
if ((p=strstr (buf, AP_STA_CONNECTED)) != NULL) {//STA: AP-STA-CONNECTED a4:44:d1:86:c5:d9
strncpy(mac ,p+strlen(AP_STA_CONNECTED),17);
- wf_msg_to_self (MSG_CMD_AP_STA_CONNECTED, sizeof(mac), mac);
- wf_msg_to_self (MSG_CMD_STA_COUNT_CHANGE, 0, NULL);
+ local_wf_msg_to_self (MSG_CMD_AP_STA_CONNECTED, sizeof(mac), mac);
+ local_wf_msg_to_self (MSG_CMD_STA_COUNT_CHANGE, 0, NULL);
}
else if ((p=strstr (buf, AP_STA_DISCONNECTED)) != NULL) {//STA: AP-STA-DISCONNECTED a4:44:d1:86:c5:d9
strncpy(mac ,p+strlen(AP_STA_DISCONNECTED),17);
- wf_msg_to_self (MSG_CMD_AP_STA_DISCONNECTED, sizeof(mac), mac);
- wf_msg_to_self (MSG_CMD_STA_COUNT_CHANGE, 0, NULL);
+ local_wf_msg_to_self (MSG_CMD_AP_STA_DISCONNECTED, sizeof(mac), mac);
+ local_wf_msg_to_self (MSG_CMD_STA_COUNT_CHANGE, 0, NULL);
}
#if 0
@@ -2398,17 +2400,17 @@
//WPS-PIN-NEEDED 81cd0b24-1bcb-59c3-897b-ae51d0db3bf6 a4:44:d1:86:c5:d9 [m3note|Meizu|m3 note|m3 note|91QECP856P5Z|10-0050F204-5]
wifi_ap_wps_get_uuid(buf, sta_wps_uuid, 63);
- wf_msg_to_self(MSG_CMD_WIFI_WPS, 0, NULL);
+ local_wf_msg_to_self(MSG_CMD_WIFI_WPS, 0, NULL);
}
#endif
else if ((p=strstr (buf, WPS_EVENT_SUCCESS)) != NULL) {
sc_timer_delete(WIFI_WPS_PIN_TIMEOUT_TIMER_ID);
- wf_msg_to_self(MSG_CMD_WIFI_WPS_DOWN, 2, "0");
+ local_wf_msg_to_self(MSG_CMD_WIFI_WPS_DOWN, 2, "0");
}
else if (strstr (buf, WPS_EVENT_FAIL) ||strstr (buf, WPS_EVENT_TIMEOUT)) {
sc_timer_delete(WIFI_WPS_PIN_TIMEOUT_TIMER_ID);
- wf_msg_to_self(MSG_CMD_WIFI_WPS_DOWN, 2, "1");
+ local_wf_msg_to_self(MSG_CMD_WIFI_WPS_DOWN, 2, "1");
}
else if ((p=strstr (buf, AP_EVENT_ENABLED)) != NULL) {
g_ap_enabled = 1;
@@ -2456,14 +2458,14 @@
//kw 3
if ((p=strstr (buf, AP_STA_CONNECTED)) != NULL) {//STA: AP-STA-CONNECTED a4:44:d1:86:c5:d9
strncpy(mac ,p+strlen(AP_STA_CONNECTED),17);
- wf_msg_to_self (MSG_CMD_AP_STA_CONNECTED, sizeof(mac), mac);
- wf_msg_to_self (MSG_CMD_STA_COUNT_CHANGE, 0, NULL);
+ local_wf_msg_to_self (MSG_CMD_AP_STA_CONNECTED, sizeof(mac), mac);
+ local_wf_msg_to_self (MSG_CMD_STA_COUNT_CHANGE, 0, NULL);
}
else if ((p=strstr (buf, AP_STA_DISCONNECTED)) != NULL) {//STA: AP-STA-DISCONNECTED a4:44:d1:86:c5:d9
strncpy(mac ,p+strlen(AP_STA_DISCONNECTED),17);
- wf_msg_to_self (MSG_CMD_AP_STA_DISCONNECTED, sizeof(mac), mac);
- wf_msg_to_self (MSG_CMD_STA_COUNT_CHANGE, 0, NULL);
+ local_wf_msg_to_self (MSG_CMD_AP_STA_DISCONNECTED, sizeof(mac), mac);
+ local_wf_msg_to_self (MSG_CMD_STA_COUNT_CHANGE, 0, NULL);
}
#if 0
@@ -2471,17 +2473,17 @@
//WPS-PIN-NEEDED 81cd0b24-1bcb-59c3-897b-ae51d0db3bf6 a4:44:d1:86:c5:d9 [m3note|Meizu|m3 note|m3 note|91QECP856P5Z|10-0050F204-5]
wifi_ap_wps_get_uuid(buf, sta_wps_uuid, 63);
- wf_msg_to_self(MSG_CMD_WIFI_WPS, 0, NULL);
+ local_wf_msg_to_self(MSG_CMD_WIFI_WPS, 0, NULL);
}
#endif
else if ((p=strstr (buf, WPS_EVENT_SUCCESS)) != NULL) {
sc_timer_delete(WIFI_WPS_PIN_TIMEOUT_TIMER_ID);
- wf_msg_to_self(MSG_CMD_WIFI_WPS_DOWN, 2, "0");
+ local_wf_msg_to_self(MSG_CMD_WIFI_WPS_DOWN, 2, "0");
}
else if (strstr (buf, WPS_EVENT_FAIL) ||strstr (buf, WPS_EVENT_TIMEOUT)) {
sc_timer_delete(WIFI_WPS_PIN_TIMEOUT_TIMER_ID);
- wf_msg_to_self(MSG_CMD_WIFI_WPS_DOWN, 2, "1");
+ local_wf_msg_to_self(MSG_CMD_WIFI_WPS_DOWN, 2, "1");
}/*
else if ((p=strstr (buf, AP_EVENT_ENABLED)) != NULL) {
//g_ap_enabled = 1;
diff --git a/ap/app/zte_comm/wlan/src/wlan_main.c b/ap/app/zte_comm/wlan/src/wlan_main.c
index 56f9afe..d06e589 100755
--- a/ap/app/zte_comm/wlan/src/wlan_main.c
+++ b/ap/app/zte_comm/wlan/src/wlan_main.c
@@ -647,8 +647,10 @@
}
}
-wlan_mac_info_list mac_list ;
-void dump_mac_list()
+wlan_mac_info_list mac_list_real[2] ;
+#define mac_list mac_list_real[ap_svr->g_ap_index]
+
+static void dump_mac_list_real(struct wlan_ap_server *ap_svr)
{
int i=0;
char station_mac_tmp[MAX_NUMBER_OF_MAC*20] = {0};
@@ -660,20 +662,36 @@
wf_log("mac[%d]= %s",i, mac_list.mac_info[i].mac);
}
- sc_cfg_set("station_mac", station_mac_tmp);
- wf_log("station_mac= %s",station_mac_tmp);
+ if (ap_svr->g_ap_index == 0)
+ {
+ sc_cfg_set("station_mac", station_mac_tmp);
+ wf_log("station_mac= %s",station_mac_tmp);
+ }
+ else
+ {
+ sc_cfg_set("wifi2_station_mac", station_mac_tmp);
+ wf_log("wifi2_station_mac= %s",station_mac_tmp);
+ }
+
}
-void update_sta_count(int num)
+static void update_sta_count_real(struct wlan_ap_server *ap_svr, int num)
{
char sta_count[12] = {0}; //klocwork
sprintf(sta_count, "%d", num);
- sc_cfg_set ("sta_count", sta_count);
- ap_server1->g_sta_num = num;
+ if (ap_svr->g_ap_index == 0)
+ {
+ sc_cfg_set ("sta_count", sta_count);
+ }
+ else
+ {
+ sc_cfg_set ("wifi2_sta_count", sta_count);
+ }
+ ap_svr->g_sta_num = num;
}
-void add_sta_mac(unsigned char *mac)
+static void add_sta_mac_real(struct wlan_ap_server *ap_svr, unsigned char *mac)
{
if (mac_list.access_count >= MAX_NUMBER_OF_MAC-1) {
wf_log("mac_list over limit = %d!!!",mac_list.access_count);
@@ -681,12 +699,12 @@
}
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);
+ dump_mac_list_real(ap_svr);
+ update_sta_count_real(ap_svr, mac_list.access_count);
}
-void remove_sta_mac(unsigned char *mac)
+static void remove_sta_mac_real(struct wlan_ap_server *ap_svr, unsigned char *mac)
{
int i=0,j=0;
@@ -702,8 +720,8 @@
}
mac_list.access_count--;
- dump_mac_list();
- update_sta_count(mac_list.access_count);
+ dump_mac_list_real(ap_svr);
+ update_sta_count_real(ap_svr, mac_list.access_count);
}
@@ -765,6 +783,7 @@
DHCPOFFERADDR_LIST_t * p_dhcp_info = NULL;
INIT_LIST_HEAD(&dhcp_info_list);
char *mac_tmp=safe_malloc (6, 0);
+ struct wlan_ap_server *ap_svr = ap_server1;
if (mac_tmp == NULL) { //kw 1
wf_log("process_get_user_list_req malloc fail");
goto out;
@@ -1770,14 +1789,14 @@
break;
#endif
case MSG_CMD_AP_STA_CONNECTED:
- add_sta_mac(pstMsg->aucDataBuf);
+ add_sta_mac_real(ap_svr, pstMsg->aucDataBuf);
#ifdef USE_CAP_SUPPORT
//Èç¹û¸±ssidÒ²Òª,¸±ssidµÄMSG_CMD_AP_STA_CONNECTED»»Ò»¸öÏûÏ¢Ãû
send_sta_change_to_cap(IN_WIFI_AP_INDEX_MAX, 1, pstMsg->aucDataBuf);
#endif
break;
case MSG_CMD_AP_STA_DISCONNECTED:
- remove_sta_mac(pstMsg->aucDataBuf);
+ remove_sta_mac_real(ap_svr, pstMsg->aucDataBuf);
//wlan_prepare_sleep();
#ifdef USE_CAP_SUPPORT
//Èç¹û¸±ssidÒ²Òª,¸±ssidµÄMSG_CMD_AP_STA_CONNECTED»»Ò»¸öÏûÏ¢Ãû
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-wifi/lynq-qser-wifi.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-wifi/lynq-qser-wifi.cpp
index 21d1901..f186a55 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-wifi/lynq-qser-wifi.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-wifi/lynq-qser-wifi.cpp
@@ -1753,7 +1753,7 @@
return -1;
}
int ret = -1;
- ret = sc_wifi_init();
+ ret = sc_wifi_init_ext(1);
if (0 != ret)
{
LYERRLOG("[%s ] init wifi ret = %d fail\n", __func__,ret);
@@ -1895,7 +1895,7 @@
return ret;
}
lynq_wifi2_enable = false;
- ret = sc_wifi_uninit();
+ ret = sc_wifi_uninit_ext(1);
if (0 != ret)
{
LYERRLOG("[%s ] uninit ret = %d\n", __func__,ret);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/wlan_proxy/wlan_proxy.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/wlan_proxy/wlan_proxy.c
index 18f5e54..d18d627 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/wlan_proxy/wlan_proxy.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/wlan_proxy/wlan_proxy.c
@@ -40,14 +40,16 @@
static int wifi_evts_proc(const struct _sc_ipc_event_* const pevt, const sc_ipc_msg* const pmsg);
-static int clear_sta_record_by_idx(int idx);
+static int clear_sta_record_by_idx(int client_id, int idx);
static int clear_all_sta_record(void);
//ÈçÒì³£Á÷³Ìδdeint,»á´æÔÚÒѶϿªµÄclient key,²»Ó°ÏìÕý³£µÄclient½ÓÊÕ,ÇÒkeyûÊÍ·Å,²»»á±»ÆäËûÄ£¿é¸´ÓÃ
-static struct list_head cli_msgkey_list;
+static struct list_head cli_msgkey_list_real[2];
+#define cli_msgkey_list cli_msgkey_list_real[get_client_id(pmsg)]
//record all stas uptime in AP
-static struct list_head sta_uptime_list;
+static struct list_head sta_uptime_list_real[2];
+#define sta_uptime_list sta_uptime_list_real[get_client_id(pmsg)]
//¼Ç¼ap²àµÄÉϱ¨×´Ì¬, wifi×´Ì¬ÖØÆôʧЧ,²»ÓÃnv
//ÒªºÍsc_wifi_ap_status_tͬ²½,ap²à·Å¼¸¸ösc_wifi.hµÄenum
@@ -228,12 +230,12 @@
memcpy(pipcmsg->data, data, len);
}
-static int record_client_key(int key)
+static int record_client_key(int idx, int key)
{
scwifi_cli_key_t *pCur = NULL;
scwifi_cli_key_t *pTmp = NULL;
- list_for_each_entry(pTmp, &cli_msgkey_list, list) {
+ list_for_each_entry(pTmp, &cli_msgkey_list_real[idx], list) {
if (pTmp->cli_key == key) {
slog(WIFI_PRINT, SLOG_ERR, "wifi client:%d already in list!\n", key);
return SC_ERR_SUCCESS;
@@ -248,16 +250,16 @@
memset(pCur, 0, sizeof(scwifi_cli_key_t));
pCur->cli_key = key;
- list_add_tail(&pCur->list, &cli_msgkey_list);
+ list_add_tail(&pCur->list, &cli_msgkey_list_real[idx]);
return SC_ERR_SUCCESS;
}
-static int remove_client_key(int key)
+static int remove_client_key(int client_id, int key)
{
scwifi_cli_key_t *pTmp, *pTmp1;
- list_for_each_entry_safe(pTmp, pTmp1, &cli_msgkey_list, list) {
+ list_for_each_entry_safe(pTmp, pTmp1, &cli_msgkey_list_real[client_id], list) {
if (pTmp->cli_key == key) {
list_del(&pTmp->list);
free(pTmp);
@@ -303,11 +305,11 @@
comm_res.result = SC_ERR_SUCCESS;
if(SC_WIFI_DISABLE == pdata_info->enable) {
- comm_res.result = remove_client_key(pmsg->fd_cli);
+ comm_res.result = remove_client_key(get_client_id(pmsg), pmsg->fd_cli);
slog(WIFI_PRINT, SLOG_ERR, "wifi client(0x%x) disconnect[%d].\n", pmsg->fd_cli, comm_res.result);
}
else {
- comm_res.result = record_client_key(pmsg->fd_cli);
+ comm_res.result = record_client_key(get_client_id(pmsg), pmsg->fd_cli);
slog(WIFI_PRINT, SLOG_ERR, "wifi client(0x%x) connect[%d].\n", pmsg->fd_cli, comm_res.result);
}
@@ -973,7 +975,7 @@
g_ap_enable = pdata_info->enable;
g_ap_cur_idx = pdata_info->idx;
if (pdata_info->enable == SC_WIFI_DISABLE) {
- clear_sta_record_by_idx(pdata_info->idx);
+ clear_sta_record_by_idx(get_client_id(pmsg), pdata_info->idx);
}
}
@@ -1142,7 +1144,7 @@
list_for_each_entry(pTmp, &sta_uptime_list, list) {
if (idx == pTmp->idx || idx == IN_WIFI_AP_INDEX_MAX) { //max = total sta
//todo: get iface by pTmp->idx
- strncpy(data_res.sta_status[i].ifname, "wlan0", sizeof(data_res.sta_status[i].ifname) - 1);
+ strncpy(data_res.sta_status[i].ifname, get_client_id(pmsg) == 0 ? "wlan0" : "wlan1", sizeof(data_res.sta_status[i].ifname) - 1);
strncpy(data_res.sta_status[i].mac, pTmp->macaddr, sizeof(data_res.sta_status[i].mac) - 1);
data_res.sta_status[i].uptime = (int)(time_sec() - pTmp->access_time);
i++;
@@ -1683,7 +1685,7 @@
g_wifi_enable_status[client_id] = status->wifi_status;
- if (list_empty(&cli_msgkey_list)) {
+ if (list_empty(&cli_msgkey_list_real[client_id])) {
slog(WIFI_PRINT, SLOG_ERR, "wifi_enable_status_ind no client.\n");
return NULL;
}
@@ -1745,12 +1747,12 @@
return pmsg_ind;
}
-static int record_sta_connect(int idx, char *macaddr)
+static int record_sta_connect(int client_id, int idx, char *macaddr)
{
scwifi_sta_uptime_t *pCur = NULL;
scwifi_sta_uptime_t *pTmp = NULL;
- list_for_each_entry(pTmp, &sta_uptime_list, list) {
+ list_for_each_entry(pTmp, &sta_uptime_list_real[client_id], list) {
if (pTmp->idx == idx && 0 == strcmp(pTmp->macaddr, macaddr)) {
slog(WIFI_PRINT, SLOG_ERR, "sta:[%d,%s] already in list!\n", idx, macaddr);
return SC_ERR_SUCCESS;
@@ -1767,16 +1769,16 @@
pCur->idx = idx;
strncpy(pCur->macaddr, macaddr, sizeof(pCur->macaddr) - 1);
pCur->access_time = time_sec();
- list_add_tail(&pCur->list, &sta_uptime_list);
+ list_add_tail(&pCur->list, &sta_uptime_list_real[client_id]);
return SC_ERR_SUCCESS;
}
-static int remove_sta_disconnect(int idx, char *macaddr)
+static int remove_sta_disconnect(int client_id, int idx, char *macaddr)
{
scwifi_sta_uptime_t *pTmp, *pTmp1;
- list_for_each_entry_safe(pTmp, pTmp1, &sta_uptime_list, list) {
+ list_for_each_entry_safe(pTmp, pTmp1, &sta_uptime_list_real[client_id], list) {
if (pTmp->idx == idx && 0 == strcmp(pTmp->macaddr, macaddr)) {
list_del(&pTmp->list);
free(pTmp);
@@ -1787,11 +1789,11 @@
}
//disable
-static int clear_sta_record_by_idx(int idx)
+static int clear_sta_record_by_idx(int client_id, int idx)
{
scwifi_sta_uptime_t *pTmp, *pTmp1;
- list_for_each_entry_safe(pTmp, pTmp1, &sta_uptime_list, list) {
+ list_for_each_entry_safe(pTmp, pTmp1, &sta_uptime_list_real[client_id], list) {
if (pTmp->idx == idx) {
list_del(&pTmp->list);
free(pTmp);
@@ -1805,7 +1807,12 @@
{
scwifi_sta_uptime_t *pTmp, *pTmp1;
- list_for_each_entry_safe(pTmp, pTmp1, &sta_uptime_list, list) {
+ list_for_each_entry_safe(pTmp, pTmp1, &sta_uptime_list_real[0], list) {
+ list_del(&pTmp->list);
+ free(pTmp);
+ }
+
+ list_for_each_entry_safe(pTmp, pTmp1, &sta_uptime_list_real[1], list) {
list_del(&pTmp->list);
free(pTmp);
}
@@ -1814,13 +1821,13 @@
}
-static int update_sta_record(wlan_sta_connect_status_t *sta_status)
+static int update_sta_record(int client_id, wlan_sta_connect_status_t *sta_status)
{
if (sta_status->is_connected) {
- record_sta_connect(sta_status->idx, sta_status->macaddr);
+ record_sta_connect(client_id, sta_status->idx, sta_status->macaddr);
}
else {
- remove_sta_disconnect(sta_status->idx, sta_status->macaddr);
+ remove_sta_disconnect(client_id, sta_status->idx, sta_status->macaddr);
}
return SC_ERR_SUCCESS;
}
@@ -1830,12 +1837,16 @@
wlan_sta_connect_status_t *ap_status = (wlan_sta_connect_status_t *)pmsg->aucDataBuf;
sc_ipc_msg *pmsg_ind = NULL;
unsigned short offset = 0;
+ int client_id = 0;
if (pmsg->usMsgCmd >= (MSG_CMD_WIFI_BASE + 0x100))
+ {
offset += 0x100;
+ client_id = 1;
+ }
- update_sta_record(ap_status);
+ update_sta_record(client_id, ap_status);
- if (list_empty(&cli_msgkey_list)) {
+ if (list_empty(&cli_msgkey_list_real[client_id])) {
slog(WIFI_PRINT, SLOG_ERR, "wifi_ap_status_ind no client.\n");
return NULL;
}
@@ -1856,52 +1867,56 @@
wlan_sta_status_t *ap_status = (wlan_sta_status_t *)pmsg->aucDataBuf;
sc_ipc_msg *pmsg_ind = NULL;
unsigned short offset = 0;
+ int client_id = 0;
if (pmsg->usMsgCmd >= (MSG_CMD_WIFI_BASE + 0x100))
+ {
offset += 0x100;
+ client_id = 1;
+ }
- g_wifi_sta_status.pre_status = g_wifi_sta_status.status;
+ g_wifi_sta_status_real[client_id].pre_status = g_wifi_sta_status_real[client_id].status;
- g_wifi_sta_status.status = ap_status->status;
- strncpy(g_wifi_sta_status.ifname, ap_status->ifname, sizeof(g_wifi_sta_status.ifname) - 1);
- strncpy(g_wifi_sta_status.ap_bssid, ap_status->ap_bssid, sizeof(g_wifi_sta_status.ap_bssid) - 1);
- g_wifi_sta_status.rssi = ap_status->rssi;
- g_wifi_sta_status.signal_level = ap_status->signal_level;
- g_wifi_sta_status.has_addr = ap_status->has_addr;
- strncpy(g_wifi_sta_status.addr.addr, ap_status->addr.addr, sizeof(g_wifi_sta_status.addr.addr) - 1);
- strncpy(g_wifi_sta_status.addr.netmask, ap_status->addr.netmask, sizeof(g_wifi_sta_status.addr.netmask) - 1);
- g_wifi_sta_status.addr.subnet_bits = ap_status->addr.subnet_bits;
- strncpy(g_wifi_sta_status.addr.gateway, ap_status->addr.gateway, sizeof(g_wifi_sta_status.addr.gateway) - 1);
- strncpy(g_wifi_sta_status.addr.dnsp, ap_status->addr.dnsp, sizeof(g_wifi_sta_status.addr.dnsp) - 1);
- strncpy(g_wifi_sta_status.addr.dnss, ap_status->addr.dnss, sizeof(g_wifi_sta_status.addr.dnss) - 1);
- g_wifi_sta_status.has_addr6 = ap_status->has_addr6;
- strncpy(g_wifi_sta_status.addr6.addr, ap_status->addr6.addr, sizeof(g_wifi_sta_status.addr6.addr) - 1);
- strncpy(g_wifi_sta_status.addr6.prefix, ap_status->addr6.prefix, sizeof(g_wifi_sta_status.addr6.prefix) - 1);
- g_wifi_sta_status.addr6.prefix_bits = ap_status->addr6.prefix_bits;
- strncpy(g_wifi_sta_status.addr6.gateway, ap_status->addr6.gateway, sizeof(g_wifi_sta_status.addr6.gateway) - 1);
- strncpy(g_wifi_sta_status.addr6.dnsp, ap_status->addr6.dnsp, sizeof(g_wifi_sta_status.addr6.dnsp) - 1);
- strncpy(g_wifi_sta_status.addr6.dnss, ap_status->addr6.dnss, sizeof(g_wifi_sta_status.addr6.dnss) - 1);
- g_wifi_sta_status.reason_code = ap_status->reason_code;
+ g_wifi_sta_status_real[client_id].status = ap_status->status;
+ strncpy(g_wifi_sta_status_real[client_id].ifname, ap_status->ifname, sizeof(g_wifi_sta_status_real[client_id].ifname) - 1);
+ strncpy(g_wifi_sta_status_real[client_id].ap_bssid, ap_status->ap_bssid, sizeof(g_wifi_sta_status_real[client_id].ap_bssid) - 1);
+ g_wifi_sta_status_real[client_id].rssi = ap_status->rssi;
+ g_wifi_sta_status_real[client_id].signal_level = ap_status->signal_level;
+ g_wifi_sta_status_real[client_id].has_addr = ap_status->has_addr;
+ strncpy(g_wifi_sta_status_real[client_id].addr.addr, ap_status->addr.addr, sizeof(g_wifi_sta_status_real[client_id].addr.addr) - 1);
+ strncpy(g_wifi_sta_status_real[client_id].addr.netmask, ap_status->addr.netmask, sizeof(g_wifi_sta_status_real[client_id].addr.netmask) - 1);
+ g_wifi_sta_status_real[client_id].addr.subnet_bits = ap_status->addr.subnet_bits;
+ strncpy(g_wifi_sta_status_real[client_id].addr.gateway, ap_status->addr.gateway, sizeof(g_wifi_sta_status_real[client_id].addr.gateway) - 1);
+ strncpy(g_wifi_sta_status_real[client_id].addr.dnsp, ap_status->addr.dnsp, sizeof(g_wifi_sta_status_real[client_id].addr.dnsp) - 1);
+ strncpy(g_wifi_sta_status_real[client_id].addr.dnss, ap_status->addr.dnss, sizeof(g_wifi_sta_status_real[client_id].addr.dnss) - 1);
+ g_wifi_sta_status_real[client_id].has_addr6 = ap_status->has_addr6;
+ strncpy(g_wifi_sta_status_real[client_id].addr6.addr, ap_status->addr6.addr, sizeof(g_wifi_sta_status_real[client_id].addr6.addr) - 1);
+ strncpy(g_wifi_sta_status_real[client_id].addr6.prefix, ap_status->addr6.prefix, sizeof(g_wifi_sta_status_real[client_id].addr6.prefix) - 1);
+ g_wifi_sta_status_real[client_id].addr6.prefix_bits = ap_status->addr6.prefix_bits;
+ strncpy(g_wifi_sta_status_real[client_id].addr6.gateway, ap_status->addr6.gateway, sizeof(g_wifi_sta_status_real[client_id].addr6.gateway) - 1);
+ strncpy(g_wifi_sta_status_real[client_id].addr6.dnsp, ap_status->addr6.dnsp, sizeof(g_wifi_sta_status_real[client_id].addr6.dnsp) - 1);
+ strncpy(g_wifi_sta_status_real[client_id].addr6.dnss, ap_status->addr6.dnss, sizeof(g_wifi_sta_status_real[client_id].addr6.dnss) - 1);
+ g_wifi_sta_status_real[client_id].reason_code = ap_status->reason_code;
slog(WIFI_PRINT, SLOG_ERR, "wifi_sta_status_ind %d,%s,%s,%d,%d,[%s,%s,%d,%s,%s,%s],%d,[%s,%s,%d,%s,%s,%s],%d\n",
- g_wifi_sta_status.status, g_wifi_sta_status.ifname, g_wifi_sta_status.ap_bssid,
- g_wifi_sta_status.rssi,
- g_wifi_sta_status.has_addr,
- g_wifi_sta_status.addr.addr,
- g_wifi_sta_status.addr.netmask,
- g_wifi_sta_status.addr.subnet_bits,
- g_wifi_sta_status.addr.gateway,
- g_wifi_sta_status.addr.dnsp,
- g_wifi_sta_status.addr.dnss,
- g_wifi_sta_status.has_addr6,
- g_wifi_sta_status.addr6.addr,
- g_wifi_sta_status.addr6.prefix,
- g_wifi_sta_status.addr6.prefix_bits,
- g_wifi_sta_status.addr6.gateway,
- g_wifi_sta_status.addr6.dnsp,
- g_wifi_sta_status.addr6.dnss,
- g_wifi_sta_status.reason_code);
+ g_wifi_sta_status_real[client_id].status, g_wifi_sta_status_real[client_id].ifname, g_wifi_sta_status_real[client_id].ap_bssid,
+ g_wifi_sta_status_real[client_id].rssi,
+ g_wifi_sta_status_real[client_id].has_addr,
+ g_wifi_sta_status_real[client_id].addr.addr,
+ g_wifi_sta_status_real[client_id].addr.netmask,
+ g_wifi_sta_status_real[client_id].addr.subnet_bits,
+ g_wifi_sta_status_real[client_id].addr.gateway,
+ g_wifi_sta_status_real[client_id].addr.dnsp,
+ g_wifi_sta_status_real[client_id].addr.dnss,
+ g_wifi_sta_status_real[client_id].has_addr6,
+ g_wifi_sta_status_real[client_id].addr6.addr,
+ g_wifi_sta_status_real[client_id].addr6.prefix,
+ g_wifi_sta_status_real[client_id].addr6.prefix_bits,
+ g_wifi_sta_status_real[client_id].addr6.gateway,
+ g_wifi_sta_status_real[client_id].addr6.dnsp,
+ g_wifi_sta_status_real[client_id].addr6.dnss,
+ g_wifi_sta_status_real[client_id].reason_code);
- if (list_empty(&cli_msgkey_list)) {
+ if (list_empty(&cli_msgkey_list_real[client_id])) {
slog(WIFI_PRINT, SLOG_ERR, "wifi_ap_status_ind no client.\n");
return NULL;
}
@@ -1922,13 +1937,17 @@
sc_ipc_msg *pmsg_ind = NULL;
int i = 0;
unsigned short offset = 0;
+ int client_id = 0;
if (pmsg->usMsgCmd >= (MSG_CMD_WIFI_BASE + 0x100))
+ {
offset += 0x100;
+ client_id = 1;
+ }
sc_timer_delete(STA_SCAN_SOFTTIMER_ID);
g_sta_scaning = 0;
- if (list_empty(&cli_msgkey_list)) {
+ if (list_empty(&cli_msgkey_list_real[client_id])) {
slog(WIFI_PRINT, SLOG_ERR, "wifi_ap_status_ind no client.\n");
return NULL;
}
@@ -1958,7 +1977,7 @@
sc_ipc_msg *pmsg_ind = NULL;
scwifi_serv_err_t status = {0};
- if (list_empty(&cli_msgkey_list)) {
+ if (list_empty(&cli_msgkey_list_real[0]) && list_empty(&cli_msgkey_list_real[1])) {
slog(WIFI_PRINT, SLOG_ERR, "wifi_proxy_exit_ind no client.\n");
return NULL;
}
@@ -1971,9 +1990,12 @@
slog(WIFI_PRINT, SLOG_ERR, "wifi_proxy_exit_ind %d\n", errcode);
wifi_ipcmsg_set(0, SCWIFI_CMD_SERV_ERROR_IND, (void *)&status, sizeof(scwifi_serv_err_t), pmsg_ind);
- wifi_ipcmsg_set(0, SCWIFI_CMD_SERV_ERROR_IND + 0x100, (void *)&status, sizeof(scwifi_serv_err_t), pmsg_ind);
send_msg_by_key(pmsg_ind);
+
+ wifi_ipcmsg_set(0, SCWIFI_CMD_SERV_ERROR_IND + 0x100, (void *)&status, sizeof(scwifi_serv_err_t), pmsg_ind);
+ send_msg_by_key(pmsg_ind);
+
sc_ipc_msg_free(pmsg_ind);
}
@@ -2051,8 +2073,10 @@
cap_wifi_nv_init();
- INIT_LIST_HEAD(&cli_msgkey_list);
- INIT_LIST_HEAD(&sta_uptime_list);
+ INIT_LIST_HEAD(&cli_msgkey_list_real[0]);
+ INIT_LIST_HEAD(&cli_msgkey_list_real[1]);
+ INIT_LIST_HEAD(&sta_uptime_list_real[0]);
+ INIT_LIST_HEAD(&sta_uptime_list_real[1]);
//ÄÚ²¿Ò²Òª¸Ä ÔÝʱÕâÑù
sc_ipc_start_loop("wifi_proxy_ipc");//key = MODULE_ID_WLAN_PROXY;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_wifi.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_wifi.h
index 15250a5..4f730ed 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_wifi.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_wifi.h
@@ -335,8 +335,9 @@
* @note ͬ²½½Ó¿Ú
*
*/
-int sc_wifi_init(void);
+int sc_wifi_init_ext(int client_id);
+#define sc_wifi_init() sc_wifi_init_ext(0)
/**
* @brief ³õʼ»¯wifi·þÎñ
* @param (in) ÎÞ
@@ -346,7 +347,8 @@
* @note ͬ²½½Ó¿Ú
*
*/
-int sc_wifi_uninit(void);
+int sc_wifi_uninit_ext(int client_id);
+#define sc_wifi_uninit() sc_wifi_uninit_ext(0)
/**
* @brief ¿ªÆôwifi¹¦ÄÜ
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/wifi/sc_wifi.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/wifi/sc_wifi.c
index 41325a8..c6a234f 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/wifi/sc_wifi.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/wifi/sc_wifi.c
@@ -69,7 +69,6 @@
static int sc_wifi_service_error_ind(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg);
-static volatile int s_ref_cnt = 0;
static struct scwifi_context scwifi_ctx = {0};
static struct scwifi_context scwifi_ctx2 = {0};
static sc_ipc_event scwifi_notify_evt[] = {
@@ -552,14 +551,13 @@
}
}
-static int scwifi_connect(int enable)
+static int scwifi_connect(int client_id, int enable)
{
sc_ipc_msg *conn_req_msg = NULL;
sc_ipc_msg *conn_rsp_msg = NULL;
scwifi_connect_t connect_info;
scwifi_common_res_t *comm_res = NULL;
int ret = SC_ERR_FAIL;
- int client_id = 0;
memset(&connect_info, 0, sizeof(connect_info));
connect_info.enable = enable;
@@ -588,77 +586,95 @@
}
//µ¥½ø³Ìµ¥´Îµ÷ÓÃ
-int sc_wifi_init(void)
+int sc_wifi_init_ext(int client_id)
{
int i;
sc_ipc_event *pevt;
- if(scwifi_ctx.have_init == 1 || scwifi_ctx2.have_init == 1) {
+ if((client_id == 0 && scwifi_ctx.have_init == 1) || (client_id == 1 && scwifi_ctx2.have_init == 1)) {
SCLOGE("wifi has inited!!\n");
- s_ref_cnt ++;
return SC_ERR_SUCCESS;
}
//Ö÷ÒªÓÃÓÚЯ´ø»Øµ÷cb
- memset(&scwifi_ctx, 0, sizeof(struct scwifi_context));
- memset(&scwifi_ctx2, 0, sizeof(struct scwifi_context));
+ if (client_id == 0)
+ memset(&scwifi_ctx, 0, sizeof(struct scwifi_context));
+ else if (client_id == 1)
+ memset(&scwifi_ctx2, 0, sizeof(struct scwifi_context));
+ else
+ return -1;
- sc_ipc_start_loop(NULL);
+
+ if (scwifi_ctx.have_init == 0 && scwifi_ctx2.have_init == 0)
+ sc_ipc_start_loop(NULL);
/*×¢²áʼþÉϱ¨ÏûÏ¢´¦Àí*/
for(i = 0; i < sizeof(scwifi_notify_evt) / sizeof(sc_ipc_event); i++) {
pevt = &scwifi_notify_evt[i];
- if (pevt->msg_id > 0x7300)
+ if (pevt->msg_id > 0x7300 && client_id == 1)
+ {
pevt->param = &scwifi_ctx2;
- else
+ sc_ipc_register_events(pevt, 1);
+ }
+ else if (client_id == 0)
+ {
pevt->param = &scwifi_ctx;
- sc_ipc_register_events(pevt, 1);
+ sc_ipc_register_events(pevt, 1);
+ }
}
- if(0 == scwifi_connect(SC_WIFI_ENABLE)) {
+ if(0 == scwifi_connect(client_id, SC_WIFI_ENABLE)) {
SCLOGI("connect wlan proxy success.\n");
}
- scwifi_ctx.pre_wifi_status = SC_WIFI_STATUS_DISABLED;
+ if (client_id == 0)
+ {
+ scwifi_ctx.pre_wifi_status = SC_WIFI_STATUS_DISABLED;
- scwifi_ctx.have_init = 1;
+ scwifi_ctx.have_init = 1;
+ }
- scwifi_ctx2.pre_wifi_status = SC_WIFI_STATUS_DISABLED;
+ else
+ {
+ scwifi_ctx2.pre_wifi_status = SC_WIFI_STATUS_DISABLED;
- scwifi_ctx2.have_init = 1;
+ scwifi_ctx2.have_init = 1;
+ }
SCLOGI("sc_wifi_init suc!\n");
- s_ref_cnt ++;
return SC_ERR_SUCCESS;
}
-int sc_wifi_uninit(void)
+int sc_wifi_uninit_ext(int client_id)
{
int i;
sc_ipc_event *pevt;
- s_ref_cnt --;
- if (s_ref_cnt > 0)
- return 0;
- if(scwifi_ctx.have_init == 0) {
- SCLOGE("wifi has uninited!!\n");
+ if((client_id == 0 && scwifi_ctx.have_init == 0) || (client_id == 1 && scwifi_ctx2.have_init == 0)) {
+ SCLOGE("wifi %d has uninited!!\n", client_id);
return SC_ERR_SUCCESS;
}
for(i = 0; i < sizeof(scwifi_notify_evt) / sizeof(sc_ipc_event); i++) {
pevt = &scwifi_notify_evt[i];
- sc_ipc_event_del(pevt);
+ if (pevt->msg_id > 0x7300 && client_id == 1)
+ sc_ipc_event_del(pevt);
+ else if (pevt->msg_id <= 0x7300 && client_id == 0)
+ sc_ipc_event_del(pevt);
}
- if(SC_ERR_SUCCESS == scwifi_connect(SC_WIFI_DISABLE)) {
+ if(SC_ERR_SUCCESS == scwifi_connect(client_id, SC_WIFI_DISABLE)) {
SCLOGI("sc_wifi_uninit disconnect success.\n");
}
- sc_ipc_terminate_loop();
+ if (client_id == 0)
+ scwifi_ctx.have_init = 0;
+ else if (client_id == 1)
+ scwifi_ctx2.have_init = 0;
- scwifi_ctx.have_init = 0;
- scwifi_ctx2.have_init = 0;
-
+ if (scwifi_ctx.have_init == 0 && scwifi_ctx2.have_init == 0)
+ sc_ipc_terminate_loop();
+
SCLOGI("wifi uninit suc!\n");
return 0;
}