From caf8792027071e839823c7702abd8eaf5c8b5dc0 Mon Sep 17 00:00:00 2001 From: Sameer Thalappil Date: Mon, 30 Jan 2012 16:56:29 -0800 Subject: [PATCH] system/qcom: Add new SoftAP APIs to send new commands to driver - Add SoftAP API to send initAP cmd to Driver - Add SoftAP API to send exitAP cmd to Driver - Add SoftAP API to update macaddr_acl value CRs-fixed: 331343, 333643 Change-Id: I662b819a4055a652649748461e58b1ab50e0b01e Acked-by: Ramasundar Kara Venkata --- softap/sdk/qsap.c | 76 +++++++++++++++++++++++++++++++++++++++++++ softap/sdk/qsap.h | 5 +++ softap/sdk/qsap_api.c | 19 +++++++++-- softap/sdk/qsap_api.h | 9 +++-- 4 files changed, 104 insertions(+), 5 deletions(-) diff --git a/softap/sdk/qsap.c b/softap/sdk/qsap.c index 4c1ebe5..16dd2dc 100755 --- a/softap/sdk/qsap.c +++ b/softap/sdk/qsap.c @@ -263,6 +263,63 @@ void qsap_send_module_down_indication(void) } } + +s32 qsap_send_init_ap(void) +{ + int s, ret; + struct iwreq wrq; + s32 status = eSUCCESS; + u32 *params = (u32 *)&wrq.u; + + /* Equivalent to: iwpriv wlan0 initAP */ + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) >= 0) { + strncpy(wrq.ifr_name, "wlan0", IFNAMSIZ); + wrq.u.data.length = 0; /* No Set arguments */ + wrq.u.data.flags = 2; /* WE_INIT_AP sub-command */ + ret = ioctl(s, (SIOCIWFIRSTPRIV + 6), &wrq); + if (ret < 0 ) { + LOGE("ioctl failed: %s", strerror(errno)); + status = eERR_START_SAP; + } + close(s); + sched_yield(); + } + else { + LOGE("Socket open failed: %s", strerror(errno)); + status = eERR_START_SAP; + } + return status; +} + + +s32 qsap_send_exit_ap(void) +{ + int s, ret; + struct iwreq wrq; + s32 status = eSUCCESS; + u32 *params = (u32 *)&wrq.u; + + /* Equivalent to: iwpriv wlan0 exitAP */ + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) >= 0) { + strncpy(wrq.ifr_name, "wlan0", IFNAMSIZ); + wrq.u.data.length = 0; /* No Set arguments */ + wrq.u.data.flags = 3; /*WE_EXIT_AP sub-command */ + + ret = ioctl(s, (SIOCIWFIRSTPRIV + 6), &wrq); + if (ret < 0 ) { + LOGE("ioctl failed: %s", strerror(errno)); + status = eERR_STOP_SAP; + } + close(s); + sched_yield(); + } + else { + LOGE("Socket open failed: %s", strerror(errno)); + status = eERR_STOP_SAP; + } + return status; +} + s32 wifi_qsap_unload_driver() { s32 ret = eSUCCESS; @@ -434,6 +491,25 @@ s32 wifi_qsap_start_softap() return eERR_START_SAP; } +#ifdef QCOM_WLAN_CONCURRENCY +s32 wifi_qsap_start_softap_in_concurrency() +{ + s32 status; + /*Send initAP IOCTL to Driver. Hostapd start is done by Netd.*/ + status = qsap_send_init_ap(); + return status; +} + +s32 wifi_qsap_stop_softap_in_concurrency() +{ + s32 status; + /*Send exitAP IOCTL to Driver. Hostapd stop is done by Netd.*/ + status = qsap_send_exit_ap(); + return status; +} +#endif + + s32 wifi_qsap_stop_softap() { s32 ret = eSUCCESS; diff --git a/softap/sdk/qsap.h b/softap/sdk/qsap.h index 9d2600d..9805ced 100644 --- a/softap/sdk/qsap.h +++ b/softap/sdk/qsap.h @@ -47,6 +47,11 @@ s32 wifi_qsap_stop_softap(void); s32 wifi_qsap_reload_softap(void); s32 wifi_qsap_unload_wifi_sta_driver(void); +#ifdef QCOM_WLAN_CONCURRENCY +s32 wifi_qsap_start_softap_in_concurrency(void); +s32 wifi_qsap_stop_softap_in_concurrency(void); +#endif + #if __cplusplus }; // extern "C" #endif diff --git a/softap/sdk/qsap_api.c b/softap/sdk/qsap_api.c index 88c9ab9..e7a738c 100755 --- a/softap/sdk/qsap_api.c +++ b/softap/sdk/qsap_api.c @@ -2291,20 +2291,25 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen) value = atoi(pVal); if(FALSE == IS_VALID_MAC_ACL(value)) goto error; - + /** Write back the integer value. This is to avoid values like 01, 001, 0001 * being written to the configuration */ snprintf(pVal, sizeof(u32), "%ld", value); - + if(ACL_ALLOW_LIST == value) { value = ENABLE; status = DISABLE; } - else { + else if(ACL_DENY_LIST == value){ value = DISABLE; status = ENABLE; } + else { + // must be ACL_ALLOW_AND_DENY_LIST + value = ENABLE; + status = ENABLE; + } if(eERR_UNKNOWN != qsap_change_cfg(pconffile, &qsap_str[STR_ACCEPT_MAC_FILE], value)) { if(eERR_UNKNOWN != qsap_change_cfg(pconffile, &qsap_str[STR_DENY_MAC_FILE], status)) @@ -2508,6 +2513,14 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen) if(status == eSUCCESS) status = wifi_qsap_unload_driver(); } +#ifdef QCOM_WLAN_CONCURRENCY + else if(SAP_INITAP == value) { + status = wifi_qsap_start_softap_in_concurrency(); + } + else if(SAP_EXITAP == value) { + status = wifi_qsap_stop_softap_in_concurrency(); + } +#endif else { status = !eSUCCESS; } diff --git a/softap/sdk/qsap_api.h b/softap/sdk/qsap_api.h index f76991e..7f013a4 100644 --- a/softap/sdk/qsap_api.h +++ b/softap/sdk/qsap_api.h @@ -392,7 +392,8 @@ enum auth_alg { /** Allow or Deny MAC address list selection */ enum macaddr_acl { ACL_DENY_LIST = 0, - ACL_ALLOW_LIST = 1 + ACL_ALLOW_LIST = 1, + ACL_ALLOW_AND_DENY_LIST = 2 }; enum ap_reset { @@ -400,6 +401,10 @@ enum ap_reset { SAP_RESET_DRIVER_BSS = 1, SAP_STOP_BSS = 2, SAP_STOP_DRIVER_BSS = 3, +#ifdef QCOM_WLAN_CONCURRENCY + SAP_INITAP = 4, + SAP_EXITAP = 5, +#endif SAP_RESET_INVALID }; @@ -442,7 +447,7 @@ struct Command #define IS_VALID_SEC_MODE(x) (((x >= SEC_MODE_NONE) && (x < SEC_MODE_INVALID)) ? TRUE : FALSE) /** Validate the selection of access or deny MAC address list */ -#define IS_VALID_MAC_ACL(x) (((x==ACL_DENY_LIST) || (x==ACL_ALLOW_LIST)) ? TRUE : FALSE) +#define IS_VALID_MAC_ACL(x) (((x==ACL_DENY_LIST) || (x==ACL_ALLOW_LIST) || (x==ACL_ALLOW_AND_DENY_LIST)) ? TRUE : FALSE) /** Validate the broadcast SSID status */ #define IS_VALID_BSSID(x) (((value == ENABLE) || (value == DISABLE)) ? TRUE: FALSE)