summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Altensen <info@stricted.net>2025-01-26 18:59:58 +0100
committerJan Altensen <info@stricted.net>2025-01-26 18:59:58 +0100
commit033d40050c5e23120a5dd0612270cb137a16b300 (patch)
treed4468e42b27a706fd19b78c9ced3dcab32925108
parent7fbb62e5d21d9f07f5382a46fdb8734ffa761dd2 (diff)
wifi_hal: update to latest linaro sourcew16.0
taken from https://gitlab.com/Linaro/96boards/e850-96/platform/hardware/samsung_slsi/-/tree/android13-e850-96/scsc_wifibt/wifi_hal @ 3f80ca082ee2471ffa4c22f70b131dd6af456de3 Change-Id: I0f2499742eaceb650eb332253ce81ba6e3123de2
-rwxr-xr-xcommon.cpp102
-rwxr-xr-xcommon.h35
-rwxr-xr-xcpp_bindings.cpp34
-rwxr-xr-xcpp_bindings.h9
-rwxr-xr-xgscan.cpp6
-rwxr-xr-xlink_layer_stats.cpp35
-rwxr-xr-xnan_common.h37
-rwxr-xr-xroam.cpp24
-rwxr-xr-xrtt.cpp90
-rwxr-xr-xwifi_hal.cpp288
-rwxr-xr-xwifi_logger.cpp6
-rwxr-xr-xwifi_nan.cpp471
-rwxr-xr-xwifi_nan_data_path.cpp85
-rwxr-xr-xwifi_offload.cpp7
14 files changed, 1025 insertions, 204 deletions
diff --git a/common.cpp b/common.cpp
index 37e7498..272d843 100755
--- a/common.cpp
+++ b/common.cpp
@@ -20,6 +20,8 @@
#include "common.h"
#include "cpp_bindings.h"
+static uint8_t reset_in_progress;
+
interface_info *getIfaceInfo(wifi_interface_handle handle)
{
return (interface_info *)handle;
@@ -222,7 +224,7 @@ void wifi_unregister_cmd(wifi_handle handle, WifiCommand *cmd)
if (info->cmd[i].cmd == cmd) {
memmove(&info->cmd[i], &info->cmd[i+1], (info->num_cmd - i) * sizeof(cmd_info));
info->num_cmd--;
- //ALOGI("Successfully removed command %d: %p from %d", id, cmd, i);
+ //ALOGI("Successfully removed command : %p from %d", cmd, i);
break;
}
}
@@ -258,4 +260,100 @@ void wifi_reset_nan_cmd(wifi_handle handle)
WifiCommand *wifi_get_nan_cmd(wifi_handle handle) {
hal_info *info = (hal_info *)handle;
return info->nanCmd;
-} \ No newline at end of file
+}
+
+void wifi_log_hex2string(const u8 *hex_buffer, int length, char *hex_string)
+{
+ int slen = 0, i = 0;
+ int max_size = WIFI_MAX_INFO_BUFFER_SIZE;
+
+ for (i = 0; i < length && slen < max_size - 2; i++)
+ slen += snprintf(&hex_string[slen], WIFI_MAX_INFO_BUFFER_SIZE - slen, "%02x", hex_buffer[i]);
+ hex_string[slen] = '\0';
+}
+
+void wifi_log_hex_buffer_debug(const char *pre_str, const char *post_str, const u8 *hex_buffer, int hex_len)
+{
+ char hex_string[WIFI_MAX_INFO_BUFFER_SIZE] = {'0'};
+ int len = hex_len > 20 ? 20 : hex_len; /* only first 20bytes needs to be printed. */
+
+ if (!len || !hex_buffer)
+ return;
+ wifi_log_hex2string(hex_buffer, len, hex_string);
+ if (pre_str && post_str)
+ ALOGD("%s %s %s\n", pre_str, hex_string, post_str);
+ else if (pre_str)
+ ALOGD("%s %s\n", pre_str, hex_string);
+ else if (post_str)
+ ALOGD("%s %s\n", hex_string, post_str);
+ else
+ ALOGD("%s\n", hex_string);
+ return;
+}
+
+void wifi_log_hex_buffer_warn(const char *pre_str, const char *post_str, const u8 *hex_buffer, int hex_len)
+{
+ char hex_string[WIFI_MAX_INFO_BUFFER_SIZE] = {'0'};
+ int len = hex_len > 20 ? 20 : hex_len; /* only first 20bytes needs to be printed. */
+
+ if (!len || !hex_buffer)
+ return;
+ wifi_log_hex2string(hex_buffer, len, hex_string);
+ if (pre_str && post_str)
+ ALOGW("%s %s %s\n", pre_str, hex_string, post_str);
+ else if (pre_str)
+ ALOGW("%s %s\n", pre_str, hex_string);
+ else if (post_str)
+ ALOGW("%s %s\n", hex_string, post_str);
+ else
+ ALOGW("%s\n", hex_string);
+ return;
+}
+
+void wifi_log_hex_buffer_info(const char *pre_str, const char *post_str, const u8 *hex_buffer, int hex_len)
+{
+ char hex_string[WIFI_MAX_INFO_BUFFER_SIZE] = {'0'};
+ int len = hex_len > 20 ? 20 : hex_len; /* only first 20bytes needs to be printed. */
+
+ if (!len || !hex_buffer)
+ return;
+ wifi_log_hex2string(hex_buffer, len, hex_string);
+ if (pre_str && post_str)
+ ALOGI("%s %s %s\n", pre_str, hex_string, post_str);
+ else if (pre_str)
+ ALOGI("%s %s\n", pre_str, hex_string);
+ else if (post_str)
+ ALOGI("%s %s\n", hex_string, post_str);
+ else
+ ALOGI("%s\n", hex_string);
+ return;
+}
+
+void wifi_log_hex_buffer_error(const char *pre_str, const char *post_str, const u8 *hex_buffer, int hex_len)
+{
+ char hex_string[WIFI_MAX_INFO_BUFFER_SIZE] = {'0'};
+ int len = hex_len > 20 ? 20 : hex_len; /* only first 20bytes needs to be printed. */
+
+ if (!len || !hex_buffer)
+ return;
+ wifi_log_hex2string(hex_buffer, len, hex_string);
+ if (pre_str && post_str)
+ ALOGE("%s %s %s\n", pre_str, hex_string, post_str);
+ else if (pre_str)
+ ALOGE("%s %s\n", pre_str, hex_string);
+ else if (post_str)
+ ALOGE("%s %s\n", hex_string, post_str);
+ else
+ ALOGE("%s\n", hex_string);
+ return;
+}
+
+void set_reset_in_progress(uint8_t value)
+{
+ reset_in_progress = value;
+}
+
+uint8_t is_reset_in_progress()
+{
+ return reset_in_progress;
+}
diff --git a/common.h b/common.h
index e9ea548..ba03a0c 100755
--- a/common.h
+++ b/common.h
@@ -9,7 +9,7 @@
#endif
#define LOG_TAG "WifiHAL"
-#include <utils/Log.h>
+#include <log/log.h>
#include "nl80211_copy.h"
#include "sync.h"
@@ -18,6 +18,16 @@
#define DEFAULT_EVENT_CB_SIZE (64)
#define DEFAULT_CMD_SIZE (64)
#define DOT11_OUI_LEN 3
+#define WIFI_MAX_INFO_BUFFER_SIZE 41
+
+#ifdef SLSI_WIFI_HAL_NL_ATTR_CONFIG
+#define WIFI_HAL_ATTR_START 1
+#define NLA_F_NESTED (1 << 15)
+#define NLA_F_NET_BYTEORDER (1 << 14)
+#define NLA_TYPE_MASK ~(NLA_F_NESTED | NLA_F_NET_BYTEORDER)
+#else
+#define WIFI_HAL_ATTR_START 0
+#endif
typedef struct {
int num_bssid;
@@ -31,6 +41,8 @@ typedef struct {
*/
const uint32_t GOOGLE_OUI = 0x001A11;
+const uint32_t SAMSUNG_OUI = 0x0000f0;
+
/* TODO: define vendor OUI here */
typedef enum {
@@ -157,6 +169,7 @@ typedef enum {
SLSI_NL80211_VENDOR_SUBCMD_GET_ROAMING_CAPABILITIES,
SLSI_NL80211_VENDOR_SUBCMD_SET_ROAMING_STATE,
SLSI_NL80211_VENDOR_SUBCMD_SET_LATENCY_MODE,
+ SLSI_NL80211_VENDOR_SUBCMD_GET_USABLE_CHANNELS,
SLSI_NL80211_VENDOR_SUBCMD_NAN_ENABLE = ANDROID_NL80211_SUBCMD_NAN_RANGE_START,
SLSI_NL80211_VENDOR_SUBCMD_NAN_DISABLE,
@@ -196,7 +209,7 @@ typedef enum {
WIFI_HANGED_EVENT,
WIFI_EPNO_EVENT,
WIFI_HOTSPOT_MATCH,
- WIFI_RSSI_REPORT_EVENT,
+ WIFI_RSSI_REPORT_EVENT = 10,
ENHANCE_LOGGER_RING_EVENT,
ENHANCE_LOGGER_MEM_DUMP_EVENT,
/* NAN events start */
@@ -207,7 +220,7 @@ typedef enum {
SLSI_NAN_EVENT_SUBSCRIBE_TERMINATED,
SLSI_NAN_EVENT_FOLLOWUP,
SLSI_NAN_EVENT_DISCOVERY_ENGINE,
- SLSI_NAN_EVENT_DISABLED,
+ SLSI_NAN_EVENT_DISABLED = 20,
SLSI_RTT_RESULT_EVENT,
SLSI_RTT_EVENT_COMPLETE,
WIFI_ACS_EVENT, /* Handled by supplicant. not in Wifi-HAL */
@@ -217,7 +230,10 @@ typedef enum {
/* NAN DATA PATH EVENTS*/
SLSI_NAN_EVENT_NDP_REQ,
SLSI_NAN_EVENT_NDP_CFM,
- SLSI_NAN_EVENT_NDP_END
+ SLSI_NAN_EVENT_NDP_END,
+ WIFI_SUBSYSTEM_RESTART_EVENT = 33,
+ SLSI_NL80211_VENDOR_NAN_INTERFACE_CREATED = 39,
+ SLSI_NL80211_VENDOR_NAN_INTERFACE_DELETED
} WIFI_EVENT;
@@ -240,7 +256,7 @@ typedef struct {
typedef struct {
wifi_handle handle; // handle to wifi data
- char name[8+1]; // interface name + trailing null
+ char name[IFNAMSIZ+1]; // interface name + trailing null
int id; // id to use when talking to driver
} interface_info;
@@ -250,6 +266,7 @@ typedef struct {
struct nl_sock *event_sock; // event socket object
int nl80211_family_id; // family id for 80211 driver
int cleanup_socks[2]; // sockets used to implement wifi_cleanup
+ int ioctl_sock;
bool in_event_loop; // Indicates that event loop is active
bool clean_up; // Indication to clean up the socket
@@ -297,6 +314,14 @@ wifi_interface_handle getIfaceHandle(interface_info *info);
void wifi_set_nan_cmd(wifi_handle handle, WifiCommand *cmd);
void wifi_reset_nan_cmd(wifi_handle handle);
WifiCommand *wifi_get_nan_cmd(wifi_handle handle);
+void wifi_log_hex2string(const u8 *hex_buffer, int length, char *hex_string);
+void wifi_log_hex_buffer_debug(const char *pre_str, const char *post_str, const u8 *hex_buffer, int hex_len);
+void wifi_log_hex_buffer_info(const char *pre_str, const char *post_str, const u8 *hex_buffer, int hex_len);
+void wifi_log_hex_buffer_warn(const char *pre_str, const char *post_str, const u8 *hex_buffer, int hex_len);
+void wifi_log_hex_buffer_error(const char *pre_str, const char *post_str, const u8 *hex_buffer, int hex_len);
+void set_reset_in_progress(uint8_t value);
+uint8_t is_reset_in_progress();
+
// some common macros
#define min(x, y) ((x) < (y) ? (x) : (y))
diff --git a/cpp_bindings.cpp b/cpp_bindings.cpp
index 5ab68b1..837aa42 100755
--- a/cpp_bindings.cpp
+++ b/cpp_bindings.cpp
@@ -588,6 +588,38 @@ out:
nl_cb_put(cb);
return err;
}
+int WifiCommand::linuxSetIfaceFlags(char *ifname, int flag) {
+ struct ifreq ifr;
+ int ret = 0;
+
+ memset(&ifr, 0, sizeof(ifr));
+ strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
+
+ ret = ioctl(mInfo->ioctl_sock, SIOCGIFFLAGS, &ifr);
+ if (ret)
+ return ret;
+
+ if (flag) {
+ if (ifr.ifr_flags & IFF_UP) {
+ ALOGE("interface %s is already up\n", ifname);
+ return 0;
+ }
+ ifr.ifr_flags |= IFF_UP;
+ } else {
+ if (!(ifr.ifr_flags & IFF_UP)) {
+ ALOGE("interface %s is already down\n", ifname);
+ return 0;
+ }
+ ifr.ifr_flags &= ~IFF_UP;
+ }
+ if (ioctl(mInfo->ioctl_sock, SIOCSIFFLAGS, &ifr) != 0) {
+ ALOGE("Could not set interface %s flags \n", ifname);
+ return ret;
+ } else {
+ ALOGE("set interface %s flags (%s)\n", ifname, flag ? "UP" : "DOWN");
+ }
+ return 0;
+}
int WifiCommand::requestEvent(int cmd) {
@@ -689,6 +721,6 @@ int WifiCommand::error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, vo
int *ret = (int *)arg;
*ret = err->error;
- /*ALOGD("error_handler received : %d", err->error);*/
+ /*ALOGD("error_handler received : %d %s", err->error, nl_geterror(err->error));*/
return NL_SKIP;
}
diff --git a/cpp_bindings.h b/cpp_bindings.h
index d1e1e5a..fa4f698 100755
--- a/cpp_bindings.h
+++ b/cpp_bindings.h
@@ -106,7 +106,13 @@ public:
return pos;
}
uint16_t get_type() {
- return pos->nla_type;
+ uint16_t type;
+#ifdef SLSI_WIFI_HAL_NL_ATTR_CONFIG
+ type = pos->nla_type & NLA_TYPE_MASK;
+#else
+ type = pos->nla_type;
+#endif
+ return type;
}
uint8_t get_u8() {
return nla_get_u8(pos);
@@ -274,6 +280,7 @@ public:
int requestEvent(int cmd);
int requestVendorEvent(uint32_t id, int subcmd);
int requestResponse(WifiRequest& request);
+ int linuxSetIfaceFlags(char *ifname, int flag);
protected:
wifi_handle wifiHandle() {
diff --git a/gscan.cpp b/gscan.cpp
index e3227e1..090b664 100755
--- a/gscan.cpp
+++ b/gscan.cpp
@@ -18,14 +18,14 @@
#include "sync.h"
-#include <utils/Log.h>
+#include <log/log.h>
#include "wifi_hal.h"
#include "common.h"
#include "cpp_bindings.h"
typedef enum {
- EPNO_ATTRIBUTE_MINIMUM_5G_RSSI,
+ EPNO_ATTRIBUTE_MINIMUM_5G_RSSI = WIFI_HAL_ATTR_START,
EPNO_ATTRIBUTE_MINIMUM_2G_RSSI,
EPNO_ATTRIBUTE_INITIAL_SCORE_MAX,
EPNO_ATTRIBUTE_CUR_CONN_BONUS,
@@ -42,7 +42,7 @@ typedef enum {
} EPNO_ATTRIBUTE;
typedef enum {
- EPNO_ATTRIBUTE_HS_PARAM_LIST,
+ EPNO_ATTRIBUTE_HS_PARAM_LIST = WIFI_HAL_ATTR_START,
EPNO_ATTRIBUTE_HS_NUM,
EPNO_ATTRIBUTE_HS_ID,
EPNO_ATTRIBUTE_HS_REALM,
diff --git a/link_layer_stats.cpp b/link_layer_stats.cpp
index bfdeac8..2ad57a7 100755
--- a/link_layer_stats.cpp
+++ b/link_layer_stats.cpp
@@ -17,7 +17,7 @@
#include "sync.h"
-#include <utils/Log.h>
+#include <log/log.h>
#include "wifi_hal.h"
#include "common.h"
@@ -206,6 +206,8 @@ protected:
// assuming max peers is 16
wifi_iface_stat *iface_stat = (wifi_iface_stat *) malloc(sizeof(wifi_iface_stat) + sizeof(wifi_peer_info) * 16);
+ wifi_iface_stat *iface_stat2;
+ iface_stat2 = iface_stat;
if (!iface_stat) {
ALOGE("Memory alloc failed for iface_stat in response handler!!!");
return NL_SKIP;
@@ -229,10 +231,24 @@ protected:
radio_data_len1 = (u8 *)&(radio_stat->num_tx_levels) - (u8*)radio_stat;
radio_data_len2 = (u8 *)(radio_stat->channels) - (u8*)&(radio_stat->rx_time);
+ int iface_data_len1;
+ iface_data_len1 = (u8 *)&(iface_stat->peer_info) - (u8*)iface_stat;
+
//kernel is 64 bit. if userspace is 64 bit, typecastting buffer works else, make corrections
if (sizeof(iface_stat->iface) == 8) {
- memcpy(iface_stat, data, sizeof(wifi_iface_stat) + sizeof(wifi_peer_info) * ((wifi_iface_stat *)data)->num_peers);
- data += sizeof(wifi_iface_stat) + sizeof(wifi_peer_info) * ((wifi_iface_stat *)data)->num_peers;
+ memcpy(iface_stat2, data, iface_data_len1);
+ data += iface_data_len1;
+
+ for (i = 0; i < iface_stat2->num_peers; i++) {
+ memcpy(&iface_stat2->peer_info[i].type, data, sizeof(wifi_peer_type));
+ data += sizeof(wifi_peer_type);
+ memcpy(iface_stat2->peer_info[i].peer_mac_address, data, (sizeof(u8) * 6));
+ data += (sizeof(u8) * 6) + 2; //for allignment skip 2 bytes
+ memcpy(&iface_stat2->peer_info[i].capabilities, data, sizeof(u32));
+ data += sizeof(u32);
+ memcpy(&iface_stat2->peer_info[i].num_rate, data, sizeof(u32));
+ data += sizeof(u32);
+ }
} else {
/* for 64 bit kernel ad 32 bit user space, there is 4 byte extra at the begining and another 4 byte pad after 80 bytes
* so remove first 4 and 81-84 bytes from NL buffer.*/
@@ -241,9 +257,18 @@ protected:
data += 80 + 4; //for allignment skip 4 bytes
memcpy(((u8 *)iface_stat) + 80, data, sizeof(wifi_iface_stat) - 80);
data += sizeof(wifi_iface_stat) - 80;
- memcpy(iface_stat->peer_info, data, sizeof(wifi_peer_info) * iface_stat->num_peers);
- data += sizeof(wifi_peer_info) * iface_stat->num_peers;
+ for (i = 0; i < iface_stat->num_peers; i++) {
+ memcpy(&iface_stat->peer_info[i].type, data, sizeof(wifi_peer_type));
+ data += sizeof(wifi_peer_type);
+ memcpy(iface_stat->peer_info[i].peer_mac_address, data, (sizeof(u8) * 6));
+ data += (sizeof(u8) * 6) + 2; //for allignment skip 2 bytes
+ memcpy(&iface_stat->peer_info[i].capabilities, data, sizeof(u32));
+ data += sizeof(u32);
+ memcpy(&iface_stat->peer_info[i].num_rate, data, sizeof(u32));
+ data += sizeof(u32);
+ }
}
+
for (i = 0; i < num_radios; i++) {
memcpy(radio_stat2, data, radio_data_len1);
data += radio_data_len1;
diff --git a/nan_common.h b/nan_common.h
index 7a75a6b..18a5ff8 100755
--- a/nan_common.h
+++ b/nan_common.h
@@ -46,7 +46,7 @@
}
typedef enum {
- NAN_REQ_ATTR_MASTER_PREF,
+ NAN_REQ_ATTR_MASTER_PREF = 1,
NAN_REQ_ATTR_CLUSTER_LOW,
NAN_REQ_ATTR_CLUSTER_HIGH,
NAN_REQ_ATTR_HOP_COUNT_LIMIT_VAL,
@@ -58,7 +58,7 @@ typedef enum {
NAN_REQ_ATTR_RSSI_CLOSE_2G4_VAL,
NAN_REQ_ATTR_RSSI_MIDDLE_2G4_VAL,
NAN_REQ_ATTR_RSSI_PROXIMITY_2G4_VAL,
- NAN_REQ_ATTR_BEACONS_2G4_VAL,
+ NAN_REQ_ATTR_BEACONS_2G4_VAL = 11,
NAN_REQ_ATTR_SDF_2G4_VAL,
NAN_REQ_ATTR_CHANNEL_2G4_MHZ_VAL,
NAN_REQ_ATTR_RSSI_PROXIMITY_VAL,
@@ -70,7 +70,7 @@ typedef enum {
NAN_REQ_ATTR_RSSI_PROXIMITY_5G_VAL,
NAN_REQ_ATTR_BEACON_5G_VAL,
NAN_REQ_ATTR_SDF_5G_VAL,
- NAN_REQ_ATTR_CHANNEL_5G_MHZ_VAL,
+ NAN_REQ_ATTR_CHANNEL_5G_MHZ_VAL = 21,
NAN_REQ_ATTR_RSSI_WINDOW_SIZE_VAL,
NAN_REQ_ATTR_OUI_VAL,
@@ -81,7 +81,7 @@ typedef enum {
NAN_REQ_ATTR_RANDOM_FACTOR_FORCE_VAL,
NAN_REQ_ATTR_HOP_COUNT_FORCE_VAL,
NAN_REQ_ATTR_CONN_CAPABILITY_PAYLOAD_TX,
- NAN_REQ_ATTR_CONN_CAPABILITY_IBSS,
+ NAN_REQ_ATTR_CONN_CAPABILITY_IBSS = 31,
NAN_REQ_ATTR_CONN_CAPABILITY_WFD,
NAN_REQ_ATTR_CONN_CAPABILITY_WFDS,
NAN_REQ_ATTR_CONN_CAPABILITY_TDLS,
@@ -91,7 +91,7 @@ typedef enum {
NAN_REQ_ATTR_DISCOVERY_ATTR_VAL,
NAN_REQ_ATTR_CONN_TYPE,
NAN_REQ_ATTR_NAN_ROLE,
- NAN_REQ_ATTR_TRANSMIT_FREQ,
+ NAN_REQ_ATTR_TRANSMIT_FREQ = 41,
NAN_REQ_ATTR_AVAILABILITY_DURATION,
NAN_REQ_ATTR_AVAILABILITY_INTERVAL,
NAN_REQ_ATTR_MESH_ID_LEN,
@@ -101,7 +101,7 @@ typedef enum {
NAN_REQ_ATTR_FURTHER_AVAIL_NUM_ENTRIES,
NAN_REQ_ATTR_FURTHER_AVAIL_VAL,
NAN_REQ_ATTR_FURTHER_AVAIL_ENTRY_CTRL,
- NAN_REQ_ATTR_FURTHER_AVAIL_CHAN_CLASS,
+ NAN_REQ_ATTR_FURTHER_AVAIL_CHAN_CLASS = 51,
NAN_REQ_ATTR_FURTHER_AVAIL_CHAN,
NAN_REQ_ATTR_FURTHER_AVAIL_CHAN_MAPID,
NAN_REQ_ATTR_FURTHER_AVAIL_INTERVAL_BITMAP,
@@ -111,7 +111,7 @@ typedef enum {
NAN_REQ_ATTR_PUBLISH_TYPE,
NAN_REQ_ATTR_PUBLISH_TX_TYPE,
NAN_REQ_ATTR_PUBLISH_COUNT,
- NAN_REQ_ATTR_PUBLISH_SERVICE_NAME_LEN,
+ NAN_REQ_ATTR_PUBLISH_SERVICE_NAME_LEN = 61,
NAN_REQ_ATTR_PUBLISH_SERVICE_NAME,
NAN_REQ_ATTR_PUBLISH_MATCH_ALGO,
NAN_REQ_ATTR_PUBLISH_SERVICE_INFO_LEN,
@@ -121,7 +121,7 @@ typedef enum {
NAN_REQ_ATTR_PUBLISH_TX_MATCH_FILTER_LEN,
NAN_REQ_ATTR_PUBLISH_TX_MATCH_FILTER,
NAN_REQ_ATTR_PUBLISH_RSSI_THRESHOLD_FLAG,
- NAN_REQ_ATTR_PUBLISH_CONN_MAP,
+ NAN_REQ_ATTR_PUBLISH_CONN_MAP = 71,
NAN_REQ_ATTR_PUBLISH_RECV_IND_CFG,
NAN_REQ_ATTR_SUBSCRIBE_ID,
NAN_REQ_ATTR_SUBSCRIBE_TTL,
@@ -131,7 +131,7 @@ typedef enum {
NAN_REQ_ATTR_SUBSCRIBE_RESP_INCLUDE,
NAN_REQ_ATTR_SUBSCRIBE_USE_RESP_FILTER,
NAN_REQ_ATTR_SUBSCRIBE_SSI_REQUIRED,
- NAN_REQ_ATTR_SUBSCRIBE_MATCH_INDICATOR,
+ NAN_REQ_ATTR_SUBSCRIBE_MATCH_INDICATOR = 81,
NAN_REQ_ATTR_SUBSCRIBE_COUNT,
NAN_REQ_ATTR_SUBSCRIBE_SERVICE_NAME_LEN,
NAN_REQ_ATTR_SUBSCRIBE_SERVICE_NAME,
@@ -141,7 +141,7 @@ typedef enum {
NAN_REQ_ATTR_SUBSCRIBE_RX_MATCH_FILTER,
NAN_REQ_ATTR_SUBSCRIBE_TX_MATCH_FILTER_LEN,
NAN_REQ_ATTR_SUBSCRIBE_TX_MATCH_FILTER,
- NAN_REQ_ATTR_SUBSCRIBE_RSSI_THRESHOLD_FLAG,
+ NAN_REQ_ATTR_SUBSCRIBE_RSSI_THRESHOLD_FLAG = 91,
NAN_REQ_ATTR_SUBSCRIBE_CONN_MAP,
NAN_REQ_ATTR_SUBSCRIBE_NUM_INTF_ADDR_PRESENT,
NAN_REQ_ATTR_SUBSCRIBE_INTF_ADDR,
@@ -151,7 +151,7 @@ typedef enum {
NAN_REQ_ATTR_FOLLOWUP_ADDR,
NAN_REQ_ATTR_FOLLOWUP_PRIORITY,
NAN_REQ_ATTR_FOLLOWUP_SERVICE_NAME_LEN,
- NAN_REQ_ATTR_FOLLOWUP_SERVICE_NAME,
+ NAN_REQ_ATTR_FOLLOWUP_SERVICE_NAME = 101,
NAN_REQ_ATTR_FOLLOWUP_TX_WINDOW,
NAN_REQ_ATTR_FOLLOWUP_RECV_IND_CFG,
NAN_REQ_ATTR_SUBSCRIBE_SID_BEACON_VAL,
@@ -162,7 +162,7 @@ typedef enum {
NAN_REQ_ATTR_PUBLISH_SDEA,
NAN_REQ_ATTR_RANGING_AUTO_RESPONSE,
- NAN_REQ_ATTR_SDEA_PARAM_NDP_TYPE,
+ NAN_REQ_ATTR_SDEA_PARAM_NDP_TYPE = 111,
NAN_REQ_ATTR_SDEA_PARAM_SECURITY_CFG,
NAN_REQ_ATTR_SDEA_PARAM_RANGING_STATE,
NAN_REQ_ATTR_SDEA_PARAM_RANGE_REPORT,
@@ -172,7 +172,7 @@ typedef enum {
NAN_REQ_ATTR_RANGING_CFG_INGRESS_MM,
NAN_REQ_ATTR_RANGING_CFG_EGRESS_MM,
NAN_REQ_ATTR_CIPHER_TYPE,
- NAN_REQ_ATTR_SCID_LEN,
+ NAN_REQ_ATTR_SCID_LEN = 121,
NAN_REQ_ATTR_SCID,
NAN_REQ_ATTR_SECURITY_KEY_TYPE,
NAN_REQ_ATTR_SECURITY_PMK_LEN,
@@ -182,7 +182,7 @@ typedef enum {
NAN_REQ_ATTR_RANGE_RESPONSE_CFG_PUBLISH_ID,
NAN_REQ_ATTR_RANGE_RESPONSE_CFG_REQUESTOR_ID,
NAN_REQ_ATTR_RANGE_RESPONSE_CFG_PEER_ADDR,
- NAN_REQ_ATTR_RANGE_RESPONSE_CFG_RANGING_RESPONSE,
+ NAN_REQ_ATTR_RANGE_RESPONSE_CFG_RANGING_RESPONSE = 131,
NAN_REQ_ATTR_REQ_INSTANCE_ID,
NAN_REQ_ATTR_NDP_INSTANCE_ID,
NAN_REQ_ATTR_CHAN_REQ_TYPE,
@@ -192,10 +192,15 @@ typedef enum {
NAN_REQ_ATTR_APP_INFO_LEN,
NAN_REQ_ATTR_APP_INFO,
NAN_REQ_ATTR_SERVICE_NAME_LEN,
- NAN_REQ_ATTR_SERVICE_NAME,
+ NAN_REQ_ATTR_SERVICE_NAME = 141,
NAN_REQ_ATTR_NDP_RESPONSE_CODE,
NAN_REQ_ATTR_USE_NDPE_ATTR,
- NAN_REQ_ATTR_HAL_TRANSACTION_ID
+ NAN_REQ_ATTR_HAL_TRANSACTION_ID,
+ NAN_REQ_ATTR_CONFIG_DISC_MAC_ADDR_RANDOM,
+ NAN_REQ_ATTR_DISCOVERY_BEACON_INT,
+ NAN_REQ_ATTR_NSS,
+ NAN_REQ_ATTR_ENABLE_RANGING,
+ NAN_REQ_ATTR_DW_EARLY_TERMINATION
} NAN_REQ_ATTRIBUTES;
typedef enum {
diff --git a/roam.cpp b/roam.cpp
index 0993ec7..f902df0 100755
--- a/roam.cpp
+++ b/roam.cpp
@@ -20,7 +20,7 @@
#define LOG_TAG "WifiHAL"
-#include <utils/Log.h>
+#include <log/log.h>
#include "wifi_hal.h"
#include "common.h"
@@ -32,7 +32,8 @@
enum roam_attributes {
SLSI_ATTR_ROAM_CAPABILITY_BLACKLIST_SIZE,
SLSI_ATTR_ROAM_CAPABILITY_WHITELIST_SIZE,
- SLSI_ATTR_ROAM_STATE
+ SLSI_ATTR_ROAM_STATE,
+ SLSI_ATTR_ROAM_MAX
};
class BssidBlacklistCommand : public WifiCommand
@@ -56,10 +57,12 @@ public:
return result;
}
- for (int i = 0; i < mParams->num_bssid; i++) {
- result = request.put_addr(GSCAN_ATTRIBUTE_BLACKLIST_BSSID, mParams->bssids[i]);
- if (result < 0) {
- return result;
+ if (mParams->num_bssid > 0) {
+ for (int i = 0; i < mParams->num_bssid; i++) {
+ result = request.put_addr(GSCAN_ATTRIBUTE_BLACKLIST_BSSID, mParams->bssids[i]);
+ if (result < 0) {
+ return result;
+ }
}
}
request.attr_end(data);
@@ -205,13 +208,14 @@ wifi_error wifi_configure_roaming(wifi_interface_handle iface, wifi_roaming_conf
if (!roaming_config) {
ALOGE("%s: Invalid Buffer provided. Exit", __FUNCTION__);
return WIFI_ERROR_INVALID_ARGS;
- }
+ }
/* Generate request id randomly*/
- requestId = get_requestid();
- bssid_params.num_bssid = roaming_config->num_blacklist_bssid;
+ requestId = get_requestid();
+ bssid_params.num_bssid = roaming_config->num_blacklist_bssid;
+
- memcpy(bssid_params.bssids, roaming_config->blacklist_bssid,
+ memcpy(bssid_params.bssids, roaming_config->blacklist_bssid,
(bssid_params.num_bssid * sizeof(mac_addr)));
ret = wifi_set_bssid_blacklist(requestId, iface, bssid_params);
diff --git a/rtt.cpp b/rtt.cpp
index 9a1ef3a..b28a8bf 100755
--- a/rtt.cpp
+++ b/rtt.cpp
@@ -1,3 +1,20 @@
+/*
+ * Copyright 2019 Samsung Electronics Co. Ltd
+ *
+ * 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.
+ */
+
#include <stdint.h>
#include <fcntl.h>
#include <sys/socket.h>
@@ -19,7 +36,7 @@
#include "sync.h"
-#include <utils/Log.h>
+#include <log/log.h>
#include "wifi_hal.h"
#include "common.h"
@@ -27,7 +44,7 @@
using namespace std;
typedef enum {
- SLSI_RTT_ATTRIBUTE_TARGET_CNT = 0,
+ SLSI_RTT_ATTRIBUTE_TARGET_CNT = WIFI_HAL_ATTR_START,
SLSI_RTT_ATTRIBUTE_TARGET_INFO,
SLSI_RTT_ATTRIBUTE_TARGET_MAC,
SLSI_RTT_ATTRIBUTE_TARGET_TYPE,
@@ -47,7 +64,8 @@ typedef enum {
SLSI_RTT_ATTRIBUTE_RESULTS_PER_TARGET,
SLSI_RTT_ATTRIBUTE_RESULT_CNT,
SLSI_RTT_ATTRIBUTE_RESULT,
- SLSI_RTT_ATTRIBUTE_TARGET_ID
+ SLSI_RTT_ATTRIBUTE_TARGET_ID,
+ SLSI_RTT_ATTRIBUTE_MAX
} SLSI_RTT_ATTRIBUTE;
enum slsi_rtt_event_attributes {
@@ -129,7 +147,7 @@ static const strmap_entry_t err_info[] = {
}*/
class RttCommand : public WifiCommand
{
- int rtt_id;
+ int request_id;
unsigned numTargetDevice;
int mCompleted;
int currentIdx;
@@ -141,7 +159,7 @@ class RttCommand : public WifiCommand
public:
RttCommand(wifi_interface_handle iface, int id, unsigned num_rtt_config,
wifi_rtt_config rtt_config[], wifi_rtt_event_handler handler)
- : WifiCommand(iface, id), rtt_id(id), numTargetDevice(num_rtt_config), rttParams(rtt_config),
+ : WifiCommand(iface, id), request_id(id), numTargetDevice(num_rtt_config), rttParams(rtt_config),
rttHandler(handler)
{
memset(rttResults, 0, sizeof(rttResults));
@@ -151,7 +169,7 @@ public:
}
RttCommand(wifi_interface_handle iface, int id)
- : WifiCommand(iface, id), rtt_id(id), rttParams(NULL)
+ : WifiCommand(iface, id), request_id(id), rttParams(NULL)
{
rttHandler.on_rtt_results = NULL;
memset(rttResults, 0, sizeof(rttResults));
@@ -166,7 +184,7 @@ public:
return result;
}
nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
- result = request.put_u16(SLSI_RTT_ATTRIBUTE_TARGET_ID, rtt_id);
+ result = request.put_u16(SLSI_RTT_ATTRIBUTE_TARGET_ID, request_id);
if (result < 0) {
return result;
}
@@ -185,13 +203,13 @@ public:
return result;
}
- result = request.put_u16(SLSI_RTT_ATTRIBUTE_TARGET_TYPE, rttParams[i].type);
+ result = request.put_u8(SLSI_RTT_ATTRIBUTE_TARGET_TYPE, rttParams[i].type);
ALOGI("\trtt_type %d\n",rttParams[i].type);
if (result < 0) {
return result;
}
- result = request.put_u16(SLSI_RTT_ATTRIBUTE_TARGET_PEER, rttParams[i].peer);
+ result = request.put_u8(SLSI_RTT_ATTRIBUTE_TARGET_PEER, rttParams[i].peer);
ALOGI("\trtt_peer %d\n",rttParams[i].peer);
if (result < 0) {
return result;
@@ -283,7 +301,6 @@ public:
return result;
}
nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
- request.put_u16(SLSI_RTT_ATTRIBUTE_TARGET_ID, rtt_id);
request.put_u16(SLSI_RTT_ATTRIBUTE_TARGET_CNT, num_devices);
for(unsigned i = 0; i < num_devices; i++) {
result = request.put_addr(SLSI_RTT_ATTRIBUTE_TARGET_MAC, addr[i]);
@@ -358,27 +375,23 @@ public:
}
virtual int handleEvent(WifiEvent& event) {
- currentIdx=0;
nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA);
int event_id = event.get_vendor_subcmd();
ALOGD("Got an RTT event with id:%d\n",event_id);
if(event_id == SLSI_RTT_EVENT_COMPLETE) {
ALOGD("RTT event complete\n");
- unregisterVendorHandler(GOOGLE_OUI, SLSI_RTT_RESULT_EVENT);
- WifiCommand *cmd = wifi_unregister_cmd(wifiHandle(), id());
- if (cmd)
- cmd->releaseRef();
+ mCompleted = 1;
+ request_id = (u16)event.get_u16(NL80211_ATTR_VENDOR_DATA);
} else if (event_id == SLSI_RTT_RESULT_EVENT) {
int result_cnt = 0;
- int rtt_id = 0;
ALOGD("RTT result event\n");
for (nl_iterator it(vendor_data); it.has_next(); it.next()) {
if (it.get_type() == SLSI_RTT_ATTRIBUTE_RESULT_CNT) {
result_cnt = it.get_u16();
ALOGD("RTT results count : %d\n", result_cnt);
} else if (it.get_type() == SLSI_RTT_ATTRIBUTE_TARGET_ID) {
- rtt_id = it.get_u16();
- ALOGD("RTT target id : %d\n", rtt_id);
+ request_id = it.get_u16();
+ ALOGD("RTT target id : %d\n", request_id);
} else if (it.get_type() == SLSI_RTT_ATTRIBUTE_RESULT) {
ALOGD("RTT result attribute : %d\n", SLSI_RTT_ATTRIBUTE_RESULT);
rttResults[currentIdx] = (wifi_rtt_result *)malloc(sizeof(wifi_rtt_result));
@@ -388,11 +401,14 @@ public:
unregisterVendorHandler(GOOGLE_OUI, SLSI_RTT_RESULT_EVENT);
break;
}
+ memset(rtt_result, 0, sizeof(wifi_rtt_result));
+ rtt_result->LCI = NULL;
+ rtt_result->LCR = NULL;
for(nl_iterator nl_nested_itr((struct nlattr *)it.get()); nl_nested_itr.has_next(); nl_nested_itr.next()) {
if (nl_nested_itr.get_type() == SLSI_RTT_EVENT_ATTR_ADDR) {
memcpy(rtt_result->addr, nl_nested_itr.get_data(), nl_nested_itr.get_len());
} else if (nl_nested_itr.get_type() == SLSI_RTT_EVENT_ATTR_BURST_NUM) {
- rtt_result->burst_num = (unsigned)nl_nested_itr.get_u8();
+ rtt_result->burst_num = (unsigned)nl_nested_itr.get_u16();
} else if (nl_nested_itr.get_type() == SLSI_RTT_EVENT_ATTR_MEASUREMENT_NUM) {
rtt_result->measurement_number = (unsigned)nl_nested_itr.get_u8();
} else if (nl_nested_itr.get_type() == SLSI_RTT_EVENT_ATTR_SUCCESS_NUM) {
@@ -404,11 +420,11 @@ public:
} else if (nl_nested_itr.get_type() == SLSI_RTT_EVENT_ATTR_RETRY_AFTER_DURATION) {
rtt_result->retry_after_duration = (unsigned char)nl_nested_itr.get_u8();
} else if (nl_nested_itr.get_type() == SLSI_RTT_EVENT_ATTR_TYPE) {
- rtt_result->type = (wifi_rtt_type)nl_nested_itr.get_u16();
+ rtt_result->type = (wifi_rtt_type)nl_nested_itr.get_u8();
} else if (nl_nested_itr.get_type() == SLSI_RTT_EVENT_ATTR_RSSI) {
- rtt_result->rssi = (wifi_rssi)nl_nested_itr.get_u16();
+ rtt_result->rssi = (wifi_rssi)nl_nested_itr.get_u8();
} else if (nl_nested_itr.get_type() == SLSI_RTT_EVENT_ATTR_RSSI_SPREAD) {
- rtt_result->rssi_spread= (wifi_rssi)nl_nested_itr.get_u16();
+ rtt_result->rssi_spread= (wifi_rssi)nl_nested_itr.get_u8();
} else if (nl_nested_itr.get_type() == SLSI_RTT_EVENT_ATTR_TX_PREAMBLE) {
rtt_result->tx_rate.preamble = nl_nested_itr.get_u32();
} else if (nl_nested_itr.get_type() == SLSI_RTT_EVENT_ATTR_TX_NSS) {
@@ -464,15 +480,24 @@ public:
currentIdx++;
}
}
- (*rttHandler.on_rtt_results)(id() ,currentIdx, rttResults);
- for (int i = 0; i < currentIdx; i++) {
- free(rttResults[i]);
- rttResults[i] = NULL;
- }
- currentIdx = 0;
}
- ALOGE("Handled response for rtt config");
- return NL_SKIP;
+ if (mCompleted) {
+ unregisterVendorHandler(GOOGLE_OUI, SLSI_RTT_EVENT_COMPLETE);
+ unregisterVendorHandler(GOOGLE_OUI, SLSI_RTT_RESULT_EVENT);
+ (*rttHandler.on_rtt_results)(request_id ,currentIdx, rttResults);
+ for (int i = 0; i < currentIdx; i++) {
+ free(rttResults[i]);
+ rttResults[i] = NULL;
+ }
+ currentIdx = 0;
+ WifiCommand *cmd = wifi_unregister_cmd(wifiHandle(), request_id);
+ if (cmd)
+ cmd->releaseRef();
+ mCompleted = 0;
+ return NL_OK;
+ }
+ ALOGE("Handled response for rtt config");
+ return NL_SKIP;
}
};
class GetRttCapabilitiesCommand : public WifiCommand
@@ -560,7 +585,7 @@ protected:
wifi_error wifi_rtt_range_request(wifi_request_id id, wifi_interface_handle iface,
unsigned num_rtt_config, wifi_rtt_config rtt_config[], wifi_rtt_event_handler handler)
{
- ALOGE("Inside RTT RANGE range request");
+ ALOGE("Inside RTT RANGE request");
wifi_handle handle = getWifiHandle(iface);
RttCommand *cmd = new RttCommand(iface, id, num_rtt_config, rtt_config, handler);
NULL_CHECK_RETURN(cmd, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY);
@@ -571,9 +596,10 @@ wifi_error wifi_rtt_range_request(wifi_request_id id, wifi_interface_handle ifac
}
result = (wifi_error)cmd->start();
if (result != WIFI_SUCCESS) {
+ (*handler.on_rtt_results)(id, 0, NULL);
wifi_unregister_cmd(handle, id);
cmd->releaseRef();
- return result;
+ return WIFI_SUCCESS;
}
ALOGE("wifi range request successfully executed");
return result;
diff --git a/wifi_hal.cpp b/wifi_hal.cpp
index 11d32f0..e04c3f1 100755
--- a/wifi_hal.cpp
+++ b/wifi_hal.cpp
@@ -1,3 +1,20 @@
+/*
+ * Copyright 2019 Samsung Electronics Co. Ltd
+ *
+ * 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.
+ */
+
#include <errno.h>
#include <stdint.h>
#include <string.h>
@@ -26,7 +43,7 @@
#define LOG_TAG "WifiHAL"
-#include <utils/Log.h>
+#include <log/log.h>
#include "wifi_hal.h"
#include "common.h"
#include "cpp_bindings.h"
@@ -39,8 +56,10 @@
#define FEATURE_SET 0
#define FEATURE_SET_MATRIX 1
#define ATTR_NODFS_VALUE 3
+#ifndef SLSI_WIFI_HAL_NL_ATTR_CONFIG
#define ATTR_COUNTRY_CODE 4
#define ATTR_LOW_LATENCY_MODE 5
+#endif
static int internal_no_seq_check(nl_msg *msg, void *arg);
static int internal_valid_message_handler(nl_msg *msg, void *arg);
@@ -49,21 +68,24 @@ static int wifi_add_membership(wifi_handle handle, const char *group);
static wifi_error wifi_init_interfaces(wifi_handle handle);
typedef enum wifi_attr {
- ANDR_WIFI_ATTRIBUTE_ND_OFFLOAD_CONFIG,
- ANDR_WIFI_ATTRIBUTE_PNO_RANDOM_MAC_OUI
+ ANDR_WIFI_ATTRIBUTE_ND_OFFLOAD_CONFIG = WIFI_HAL_ATTR_START,
+ ANDR_WIFI_ATTRIBUTE_PNO_RANDOM_MAC_OUI,
+ ANDR_WIFI_ATTRIBUTE_GSCAN_OUI_MAX
} wifi_attr_t;
enum wifi_rssi_monitor_attr {
- RSSI_MONITOR_ATTRIBUTE_MAX_RSSI,
+ RSSI_MONITOR_ATTRIBUTE_MAX_RSSI = WIFI_HAL_ATTR_START,
RSSI_MONITOR_ATTRIBUTE_MIN_RSSI,
RSSI_MONITOR_ATTRIBUTE_START,
+ RSSI_MONITOR_ATTRIBUTE_MAX
};
enum wifi_apf_attr {
APF_ATTRIBUTE_VERSION,
APF_ATTRIBUTE_MAX_LEN,
APF_ATTRIBUTE_PROGRAM,
- APF_ATTRIBUTE_PROGRAM_LEN
+ APF_ATTRIBUTE_PROGRAM_LEN,
+ APF_ATTRIBUTE_MAX
};
enum apf_request_type {
@@ -72,10 +94,46 @@ enum apf_request_type {
READ_APF_PROGRAM
};
+#ifdef SLSI_WIFI_HAL_NL_ATTR_CONFIG
+enum wifi_low_latency_attr {
+ ATTR_LOW_LATENCY_MODE = 1,
+ ATTR_LOW_LATENCY_MAX
+};
+
+enum country_code_attr {
+ ATTR_COUNTRY_CODE = 1,
+ ATTR_COUNTRY_CODE_MAX
+};
+#endif
+
+enum slsi_usable_channel_attr {
+ SLSI_UC_ATTRIBUTE_BAND = 1,
+ SLSI_UC_ATTRIBUTE_IFACE_MODE,
+ SLSI_UC_ATTRIBUTE_FILTER,
+ SLSI_UC_ATTRIBUTE_MAX_NUM,
+ SLSI_UC_ATTRIBUTE_NUM_CHANNELS,
+ SLSI_UC_ATTRIBUTE_CHANNEL_LIST,
+ SLSI_UC_ATTRIBUTE_MAX
+};
+
+enum slsi_uc_iface_mode {
+ SLSI_UC_ITERFACE_STA = 1 << 0,
+ SLSI_UC_ITERFACE_SOFTAP = 1 << 1,
+ SLSI_UC_ITERFACE_IBSS = 1 << 2,
+ SLSI_UC_ITERFACE_P2P_CLIENT = 1 << 3,
+ SLSI_UC_ITERFACE_P2P_GO = 1 << 4,
+ SLSI_UC_ITERFACE_P2P_NAN = 1 << 5,
+ SLSI_UC_ITERFACE_P2P_MESH = 1 << 6,
+ SLSI_UC_ITERFACE_P2P_TDLS = 1 << 7,
+ SLSI_UC_ITERFACE_UNKNOWN = -1,
+};
+
static wifi_error wifi_start_rssi_monitoring(wifi_request_id id, wifi_interface_handle
iface, s8 max_rssi, s8 min_rssi, wifi_rssi_event_handler eh);
static wifi_error wifi_stop_rssi_monitoring(wifi_request_id id, wifi_interface_handle iface);
wifi_error wifi_get_wake_reason_stats(wifi_interface_handle iface, WLAN_DRIVER_WAKE_REASON_CNT *wifi_wake_reason_cnt);
+wifi_error wifi_get_usable_channels(wifi_handle handle, uint32_t band, uint32_t iface_mode, uint32_t filter,
+ uint32_t max_num, uint32_t *num_channels, wifi_usable_channel *channels);
/* Initialize/Cleanup */
@@ -416,6 +474,8 @@ wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn *fn)
fn->wifi_set_packet_filter = wifi_set_packet_filter;
fn->wifi_read_packet_filter = wifi_read_packet_filter;
fn->wifi_set_latency_mode = wifi_set_latency_mode;
+ fn->wifi_set_subsystem_restart_handler = wifi_set_subsystem_restart_handler;
+ fn->wifi_get_usable_channels = wifi_get_usable_channels;
return WIFI_SUCCESS;
}
@@ -453,7 +513,11 @@ wifi_error wifi_initialize(wifi_handle *handle)
free(info);
return WIFI_ERROR_UNKNOWN;
}
-
+ int ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
+ if (ioctl_sock < 0) {
+ ALOGE("Bad socket: %d\n", ioctl_sock);
+ return WIFI_ERROR_UNKNOWN;
+ }
struct nl_cb *cb = nl_socket_get_cb(event_sock);
if (cb == NULL) {
ALOGE("Could not create handle");
@@ -472,7 +536,7 @@ wifi_error wifi_initialize(wifi_handle *handle)
info->event_sock = event_sock;
info->clean_up = false;
info->in_event_loop = false;
-
+ info->ioctl_sock = ioctl_sock;
info->event_cb = (cb_info *)malloc(sizeof(cb_info) * DEFAULT_EVENT_CB_SIZE);
info->alloc_event_cb = DEFAULT_EVENT_CB_SIZE;
info->num_event_cb = 0;
@@ -499,7 +563,7 @@ wifi_error wifi_initialize(wifi_handle *handle)
wifi_add_membership(*handle, "vendor");
wifi_init_interfaces(*handle);
- char intf_name_buff[10 * 10 + 4]; /* Randomly choosen max interface 10. each interface name max 9 + 1(for space) */
+ char intf_name_buff[10 * (IFNAMSIZ+1) + 4];
char *pos = intf_name_buff;
for (int i = 0; i < (info->num_interfaces < 10 ? info->num_interfaces : 10); i++) {
strncpy(pos, info->interfaces[i]->name, sizeof(intf_name_buff) - (pos - intf_name_buff));
@@ -553,25 +617,8 @@ static void internal_cleaned_up_handler(wifi_handle handle)
void wifi_cleanup(wifi_handle handle, wifi_cleaned_up_handler handler)
{
hal_info *info = getHalInfo(handle);
- char buf[64];
info->cleaned_up_handler = handler;
- if (write(info->cleanup_socks[0], "Exit", 4) < 1) {
- ALOGE("could not write to the cleanup socket");
- } else {
- // Listen to the response
- // Hopefully we dont get errors or get hung up
- // Not much can be done in that case, but assume that
- // it has rx'ed the Exit message to exit the thread.
- // As a fallback set the cleanup flag to TRUE
- memset(buf, 0, sizeof(buf));
- int result = read(info->cleanup_socks[0], buf, sizeof(buf));
- ALOGE("%s: Read after POLL returned %d, error no = %d", __FUNCTION__, result, errno);
- if (strncmp(buf, "Done", 4) != 0) {
- ALOGD("Rx'ed %s", buf);
- }
- }
- info->clean_up = true;
pthread_mutex_lock(&info->cb_lock);
int bad_commands = 0;
@@ -598,7 +645,12 @@ void wifi_cleanup(wifi_handle handle, wifi_cleaned_up_handler handler)
ALOGE("Leaked command %p", cmd);
}
pthread_mutex_unlock(&info->cb_lock);
- internal_cleaned_up_handler(handle);
+
+ info->clean_up = true;
+ if (TEMP_FAILURE_RETRY(write(info->cleanup_socks[0], "Exit", 4)) < 1) {
+ ALOGE("could not write to the cleanup socket");
+ }
+ ALOGD("%s: Exit has sent properly. wifi_cleanup done", __FUNCTION__);
}
static int internal_pollin_handler(wifi_handle handle)
@@ -632,13 +684,15 @@ void wifi_event_loop(wifi_handle handle)
do {
int timeout = -1; /* Infinite timeout */
+
pfd[0].revents = 0;
pfd[1].revents = 0;
- int result = poll(pfd, 2, timeout);
+ int result = TEMP_FAILURE_RETRY(poll(pfd, 2, timeout));
if (result < 0) {
+ ALOGE("wifi_event_loop: return %d, error no = %d", result, errno);
} else if (pfd[0].revents & POLLERR) {
int prev_err = (int)errno;
- int result2 = read(pfd[0].fd, buf, sizeof(buf));
+ int result2 = TEMP_FAILURE_RETRY(read(pfd[0].fd, buf, sizeof(buf)));
ALOGE("Poll err:%d | Read after POLL returned %d, error no = %d", prev_err, result2, errno);
} else if (pfd[0].revents & POLLHUP) {
ALOGE("Remote side hung up");
@@ -651,17 +705,16 @@ void wifi_event_loop(wifi_handle handle)
ALOGE("%s: Read after POLL returned %d, error no = %d", __FUNCTION__, result2, errno);
if (strncmp(buf, "Exit", 4) == 0) {
ALOGD("Got a signal to exit!!!");
- if (write(pfd[1].fd, "Done", 4) < 1) {
- ALOGE("could not write to the cleanup socket");
- }
- break;
} else {
ALOGD("Rx'ed %s on the cleanup socket\n", buf);
}
} else {
- ALOGE("Unknown event - %0x, %0x", pfd[0].revents, pfd[1].revents);
+ ALOGE("wifi_event_loop: Unknown event - %0x, %0x", pfd[0].revents, pfd[1].revents);
}
} while (!info->clean_up);
+
+ internal_cleaned_up_handler(handle);
+ ALOGD("wifi_event_loop: end of event loop !!!!!");
}
///////////////////////////////////////////////////////////////////////////////////////
@@ -1095,6 +1148,139 @@ public:
}
};
+class SetSubsystemRestartHandlerCommand : public WifiCommand {
+private:
+ wifi_subsystem_restart_handler mHandler;
+public:
+ SetSubsystemRestartHandlerCommand(int id, wifi_handle handle, wifi_subsystem_restart_handler handler)
+ : WifiCommand(handle, id), mHandler(handler)
+ {
+ }
+
+ int start() {
+ set_reset_in_progress(0);
+ ALOGI("Register Vendor Handler for WIFI_SUBSYSTEM_RESTART_EVENT");
+ registerVendorHandler(GOOGLE_OUI, WIFI_SUBSYSTEM_RESTART_EVENT);
+ return WIFI_SUCCESS;
+ }
+
+ virtual int cancel() {
+ set_reset_in_progress(0);
+ ALOGI("Unregister Vendor Handler for WIFI_SUBSYSTEM_RESTART_EVENT");
+ unregisterVendorHandler(GOOGLE_OUI, WIFI_SUBSYSTEM_RESTART_EVENT);
+ return WIFI_SUCCESS;
+ }
+
+ virtual int handleResponse(WifiEvent& reply) {
+ /* Nothing to do on response! */
+ return NL_SKIP;
+ }
+
+ virtual int handleEvent(WifiEvent& event) {
+
+ nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA);
+ int len = event.get_vendor_data_len();
+
+ if (vendor_data == NULL || len == 0) {
+ ALOGI("Subsystem Restart Handler : No data");
+ return NL_SKIP;
+ }
+ const char* error = (const char*)event.get_vendor_data();
+
+ if (*mHandler.on_subsystem_restart) {
+ set_reset_in_progress(1);
+ (*mHandler.on_subsystem_restart)(error);
+ } else {
+ ALOGW("No Subsystem Restart handler registered");
+ }
+ return NL_SKIP;
+ }
+};
+
+class GetUsableChannelsCommand : public WifiCommand {
+ uint32_t mBand;
+ uint32_t mIfaceMode;
+ uint32_t mFilter;
+ uint32_t mMaxNum;
+ uint32_t *mNumChannels;
+ wifi_usable_channel *mChannels;
+public:
+ GetUsableChannelsCommand(wifi_interface_handle handle, uint32_t band, uint32_t iface_mode, uint32_t filter,
+ uint32_t max_num, uint32_t *ch_num, wifi_usable_channel *channel_buf)
+ : WifiCommand(handle, 0), mBand(band), mIfaceMode(iface_mode), mFilter(filter),
+ mMaxNum(max_num), mNumChannels(ch_num), mChannels(channel_buf) {
+ memset(mChannels, 0, sizeof(wifi_usable_channel) * max_num);
+ }
+
+ virtual int create() {
+ int ret = mMsg.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_GET_USABLE_CHANNELS);
+ if (ret < 0) {
+ return ret;
+ }
+
+ nlattr *data = mMsg.attr_start(NL80211_ATTR_VENDOR_DATA);
+ ret = mMsg.put_u32(SLSI_UC_ATTRIBUTE_BAND, mBand);
+ if (ret < 0) {
+ return ret;
+ }
+
+ ret = mMsg.put_u32(SLSI_UC_ATTRIBUTE_IFACE_MODE, mIfaceMode);
+ if (ret < 0) {
+ return ret;
+ }
+
+ ret = mMsg.put_u32(SLSI_UC_ATTRIBUTE_FILTER, mFilter);
+ if (ret < 0) {
+ return ret;
+ }
+
+ ret = mMsg.put_u32(SLSI_UC_ATTRIBUTE_MAX_NUM, mMaxNum);
+ if (ret < 0) {
+ return ret;
+ }
+
+ mMsg.attr_end(data);
+ return 0;
+ }
+
+protected:
+ virtual int handleResponse(WifiEvent& reply) {
+ if (reply.get_cmd() != NL80211_CMD_VENDOR) {
+ ALOGE("Ignoring reply with cmd = %d", reply.get_cmd());
+ return NL_SKIP;
+ }
+
+ nlattr *vendor_data = reply.get_attribute(NL80211_ATTR_VENDOR_DATA);
+ int len = reply.get_vendor_data_len();
+
+ if (vendor_data == NULL || len == 0) {
+ ALOGE("no vendor data in GetUsableChannel response; ignoring it");
+ return NL_SKIP;
+ }
+
+ int num_channels_to_copy = 0;
+
+ for (nl_iterator it(vendor_data); it.has_next(); it.next()) {
+ if (it.get_type() == SLSI_UC_ATTRIBUTE_NUM_CHANNELS) {
+ num_channels_to_copy = it.get_u32();
+ ALOGD("Got channel list number with %d channels", num_channels_to_copy);
+ if (num_channels_to_copy > mMaxNum)
+ num_channels_to_copy = mMaxNum;
+ *mNumChannels = num_channels_to_copy;
+ } else if (it.get_type() == SLSI_UC_ATTRIBUTE_CHANNEL_LIST && num_channels_to_copy) {
+ memcpy(mChannels, it.get_data(), sizeof(wifi_usable_channel) * num_channels_to_copy);
+ // for (int i = 0 ; i < num_channels_to_copy ; i++)
+ // ALOGD("Got channel list!!!!!!!!![%d] %d", i, channels[i].freq);
+ } else {
+ ALOGD("Ignoring invalid attribute type = %d, size = %d",
+ it.get_type(), it.get_len());
+ }
+ }
+
+ return NL_OK;
+ }
+};
+
static int wifi_get_multicast_id(wifi_handle handle, const char *name, const char *group)
{
GetMulticastIdCommand cmd(handle, name, group);
@@ -1109,7 +1295,8 @@ static int wifi_get_multicast_id(wifi_handle handle, const char *name, const cha
static bool is_wifi_interface(const char *name)
{
- if (strncmp(name, "wlan", 4) != 0 && strncmp(name, "p2p", 3) != 0) {
+ if (strncmp(name, "wlan", 4) != 0 && strncmp(name, "p2p", 3) != 0 && strncmp(name, "wifi", 4) != 0
+ && strncmp(name, "swlan", 5) != 0) {
/* not a wifi interface; ignore it */
return false;
} else {
@@ -1256,5 +1443,38 @@ wifi_error wifi_set_latency_mode(wifi_interface_handle handle, wifi_latency_mode
SetLatencyLockCommand cmd(handle, mode);
return (wifi_error) cmd.requestResponse();
}
+
+wifi_error wifi_set_subsystem_restart_handler(wifi_handle handle,
+ wifi_subsystem_restart_handler handler) {
+ ALOGD("Set Subsystem Restart Handler");
+ int id = 0;
+ SetSubsystemRestartHandlerCommand *cmd = new SetSubsystemRestartHandlerCommand(id, handle, handler);
+ wifi_register_cmd(handle, id, cmd);
+ wifi_error result = (wifi_error)cmd->start();
+ if (result != WIFI_SUCCESS) {
+ wifi_unregister_cmd(handle, id);
+ }
+ return result;
+}
+
+wifi_error wifi_get_usable_channels(wifi_handle handle, uint32_t band, uint32_t iface_mode, uint32_t filter,
+ uint32_t max_num, uint32_t *num_channels, wifi_usable_channel *channels) {
+ wifi_interface_handle *ihandle = NULL;
+ int ihandle_num = 0;
+ wifi_get_ifaces(handle, &ihandle_num, &ihandle);
+ ALOGD("%s: band %d iface %d filter %d max_num %d", __FUNCTION__, band, iface_mode, filter, max_num);
+ if (ihandle_num <= 0)
+ return WIFI_ERROR_UNINITIALIZED;
+
+ if (iface_mode == SLSI_UC_ITERFACE_UNKNOWN || !(iface_mode & SLSI_UC_ITERFACE_SOFTAP))
+ return WIFI_ERROR_NOT_SUPPORTED;
+
+ GetUsableChannelsCommand command(ihandle[0], band, iface_mode, filter, max_num,
+ num_channels, channels);
+
+ int result = command.requestResponse();
+ ALOGD("%s: result %d", __FUNCTION__, result);
+ return (wifi_error)result;
+}
/////////////////////////////////////////////////////////////////////////////
diff --git a/wifi_logger.cpp b/wifi_logger.cpp
index e7ef9da..39cd2ba 100755
--- a/wifi_logger.cpp
+++ b/wifi_logger.cpp
@@ -19,7 +19,7 @@
#define LOG_TAG "WifiHAL"
-#include <utils/Log.h>
+#include <log/log.h>
#include "wifi_hal.h"
#include "common.h"
@@ -45,7 +45,7 @@ typedef enum {
} DEBUG_SUB_COMMAND;
typedef enum {
- ENHANCE_LOGGER_ATTRIBUTE_DRIVER_VER,
+ ENHANCE_LOGGER_ATTRIBUTE_DRIVER_VER = WIFI_HAL_ATTR_START,
ENHANCE_LOGGER_ATTRIBUTE_FW_VER,
ENHANCE_LOGGER_ATTRIBUTE_RING_ID,
ENHANCE_LOGGER_ATTRIBUTE_RING_NAME,
@@ -63,6 +63,7 @@ typedef enum {
ENHANCE_LOGGER_ATTRIBUTE_DRIVER_DUMP_DATA,
ENHANCE_LOGGER_ATTRIBUTE_PKT_FATE_NUM,
ENHANCE_LOGGER_ATTRIBUTE_PKT_FATE_DATA,
+ ENHANCE_LOGGER_ATTRIBUTE_MAX,
//Attributes for data used by wake stats subcmd.
ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_INVALID = 0,
ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_TOTAL_CMD_EVENT_WAKE,
@@ -83,6 +84,7 @@ typedef enum {
ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_ICMP4_RX_MULTICAST_CNT,
ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_ICMP6_RX_MULTICAST_CNT,
ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_OTHER_RX_MULTICAST_CNT,
+ ENHANCE_LOGGER_ATTRIBUTE_WAKE_STATS_MAX
} ENHANCE_LOGGER_ATTRIBUTE;
typedef enum {
diff --git a/wifi_nan.cpp b/wifi_nan.cpp
index 5867749..3bad93c 100755
--- a/wifi_nan.cpp
+++ b/wifi_nan.cpp
@@ -18,7 +18,7 @@
#include "sync.h"
-#include <utils/Log.h>
+#include <log/log.h>
#include "wifi_hal.h"
#include "common.h"
@@ -36,8 +36,10 @@ class NanCommand : public WifiCommand {
int version;
NanCapabilities capabilities;
NanDataCommand datacmd;
+ u8 mac[NAN_MAC_ADDR_LEN];
void registerNanEvents(void) {
+ ALOGD("Registering NAN events");
registerVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_PUBLISH_TERMINATED);
registerVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_MATCH);
registerVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_MATCH_EXPIRED);
@@ -48,9 +50,12 @@ class NanCommand : public WifiCommand {
registerVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_NDP_REQ);
registerVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_NDP_CFM);
registerVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_NDP_END);
+ registerVendorHandler(SAMSUNG_OUI, SLSI_NL80211_VENDOR_NAN_INTERFACE_CREATED);
+ registerVendorHandler(SAMSUNG_OUI, SLSI_NL80211_VENDOR_NAN_INTERFACE_DELETED);
}
void unregisterNanEvents(void) {
+ ALOGD("Unregistering NAN events");
unregisterVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_PUBLISH_TERMINATED);
unregisterVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_MATCH);
unregisterVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_MATCH_EXPIRED);
@@ -61,6 +66,52 @@ class NanCommand : public WifiCommand {
unregisterVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_NDP_REQ);
unregisterVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_NDP_CFM);
unregisterVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_NDP_END);
+ unregisterVendorHandler(SAMSUNG_OUI, SLSI_NL80211_VENDOR_NAN_INTERFACE_CREATED);
+ unregisterVendorHandler(SAMSUNG_OUI, SLSI_NL80211_VENDOR_NAN_INTERFACE_DELETED);
+ }
+
+ static const u8 *getResponseName(int resp) {
+ switch(resp) {
+ case NAN_RESPONSE_ENABLED:
+ return (const u8 *)"ENABLED";
+ case NAN_RESPONSE_DISABLED:
+ return (const u8 *)"DISABLED";
+ case NAN_RESPONSE_PUBLISH:
+ return (const u8 *)"PUBLISH";
+ case NAN_RESPONSE_PUBLISH_CANCEL:
+ return (const u8 *)"PUB-CANCEL";
+ case NAN_RESPONSE_TRANSMIT_FOLLOWUP:
+ return (const u8 *)"TXFOLLOWUP";
+ case NAN_RESPONSE_SUBSCRIBE:
+ return (const u8 *)"SUB";
+ case NAN_RESPONSE_SUBSCRIBE_CANCEL:
+ return (const u8 *)"SUB-CANCEL";
+ case NAN_RESPONSE_STATS:
+ return (const u8 *)"STATS";
+ case NAN_RESPONSE_CONFIG:
+ return (const u8 *)"CONFIG";
+ case NAN_RESPONSE_TCA:
+ return (const u8 *)"TCA";
+ case NAN_RESPONSE_ERROR:
+ return (const u8 *)"ERROR";
+ case NAN_RESPONSE_BEACON_SDF_PAYLOAD:
+ return (const u8 *)"BEACON_SDF_PAYLOAD";
+ case NAN_GET_CAPABILITIES:
+ return (const u8 *)"CAPABILITIES";
+ case NAN_DP_INTERFACE_CREATE:
+ return (const u8 *)"IFCREATE";
+ case NAN_DP_INTERFACE_DELETE:
+ return (const u8 *)"IFDELETE";
+ case NAN_DP_INITIATOR_RESPONSE:
+ return (const u8 *)"NDP_INITIATOR";
+ case NAN_DP_RESPONDER_RESPONSE:
+ return (const u8 *)"NDP_RESPONDER";
+ case NAN_DP_END:
+ return (const u8 *)"NDP_END";
+ default:
+ return (const u8 *)"UNKNOWN response";
+ }
+ return (const u8 *)"UNKNOWN response";
}
static const u8 *getEventName(int event) {
@@ -116,7 +167,10 @@ class NanCommand : public WifiCommand {
response->response_type = NanResponseType(nl_itr.get_u32());
break;
case NAN_REPLY_ATTR_PUBLISH_SUBSCRIBE_TYPE:
- response->body.publish_response.publish_id = nl_itr.get_u16();
+ if (response->response_type == NAN_RESPONSE_SUBSCRIBE)
+ response->body.subscribe_response.subscribe_id = nl_itr.get_u16();
+ else
+ response->body.publish_response.publish_id = nl_itr.get_u16();
break;
case NAN_REPLY_ATTR_NDP_INSTANCE_ID:
response->body.data_request_response.ndp_instance_id = nl_itr.get_u32();
@@ -185,6 +239,9 @@ class NanCommand : public WifiCommand {
case NAN_REPLY_ATTR_HAL_TRANSACTION_ID:
id = nl_itr.get_u16();
break;
+ case NAN_EVT_ATTR_DISCOVERY_ENGINE_MAC_ADDR:
+ memcpy(this->mac, nl_itr.get_data(),NAN_MAC_ADDR_LEN);
+ break;
default :
ALOGE("received unknown type(%d) in response", nl_itr.get_type());
return -1;
@@ -364,6 +421,42 @@ class NanCommand : public WifiCommand {
}
}
+ ALOGD("[NAN][NA][Match][Ind]:Received[pub_sub_id:%d, requestor_instance_id:%d, addr:%02x:*:*:*:%02x:%02x]\n"
+ "[service_specific_info_len:%d, sdfMF_len:%d]\n", ind.publish_subscribe_id, ind.requestor_instance_id,
+ ind.addr[0], ind.addr[4], ind.addr[5], ind.service_specific_info_len, ind.sdf_match_filter_len);
+ wifi_log_hex_buffer_debug("service_specific_info:", NULL,
+ ind.service_specific_info, ind.service_specific_info_len);
+ wifi_log_hex_buffer_debug("sdf_match_filter:", NULL, ind.sdf_match_filter,
+ ind.sdf_match_filter_len);
+ ALOGD("Continued..[match_occured_flag:%d, out_of_resource_flag:%d, rssi:%d, is_ibss:%d, is_wfd:%d]\n"
+ "[is_wfds:%d, is_tdls:%d, is_mesh:%d, wlan_infra_field:%d, num_rx_discovery_attr:%d]\n",
+ ind.match_occured_flag, ind.out_of_resource_flag, ind.rssi_value, ind.conn_capability.is_ibss_supported,
+ ind.conn_capability.is_wfd_supported, ind.conn_capability.is_wfds_supported, ind.conn_capability.is_tdls_supported,
+ ind.conn_capability.is_mesh_supported, ind.conn_capability.wlan_infra_field, ind.num_rx_discovery_attr);
+ ALOGD("Continued..[cluster_attribute_len:%d, sdea_service_specific_info_len:%d, scid_len:%d, config_nan_data_path:%d, ndpType:%d]\n"
+ "[security_cfg:%d, ranging_state:%d, range_report:%d, qos_cfg:%d, range_measurement_mm:%d, ranging_eventType:%d]\n",
+ ind.cluster_attribute_len, ind.sdea_service_specific_info_len, ind.scid_len, ind.peer_sdea_params.config_nan_data_path,
+ ind.peer_sdea_params.ndp_type, ind.peer_sdea_params.security_cfg, ind.peer_sdea_params.ranging_state,
+ ind.peer_sdea_params.range_report,
+ ind.peer_sdea_params.qos_cfg, ind.range_info.range_measurement_mm, ind.range_info.ranging_event_type);
+ wifi_log_hex_buffer_debug("sdea_service_specific_info:", NULL,
+ ind.sdea_service_specific_info, ind.sdea_service_specific_info_len);
+ for (int i = 0; i < disc_idx; i++) {
+ NanReceivePostDiscovery *disc_attr;
+ disc_attr = &ind.discovery_attr[i];
+ ALOGD("Discovery_attr[%d]:[type:%d, role:%d, duration:%d, avail_interval_bitmap:%d, mapId:%d, addr:%02x:*:*:*:%02x:%02x]\n"
+ "[meshId_len:%d, meshId:%d%d%d.., infrastructure_ssid_len:%d, infrastructure_ssid:%.*s]\n",
+ i, disc_attr->type, disc_attr->role, disc_attr->duration, disc_attr->avail_interval_bitmap, disc_attr->mapid,
+ disc_attr->addr[0], disc_attr->addr[4], disc_attr->addr[5],
+ disc_attr->mesh_id_len, disc_attr->mesh_id[0], disc_attr->mesh_id[1], disc_attr->mesh_id[2], disc_attr->infrastructure_ssid_len,
+ disc_attr->infrastructure_ssid_len > 20 ? 20 : disc_attr->infrastructure_ssid_len, disc_attr->infrastructure_ssid_val);
+ }
+ for (int i = 0; i < famchan_idx; i++) {
+ NanFurtherAvailabilityChannel *famchan;
+ famchan = &ind.famchan[i];
+ ALOGD("FAMCHAN_attr[%d]:[entry_control:%d, class:%d, channel:%d, mapId:%d, avail_interval_bitmap:%d]\n",
+ i, famchan->entry_control, famchan->class_val, famchan->channel, famchan->mapid, famchan->avail_interval_bitmap);
+ }
if (this->callbackEventHandler.EventMatch)
this->callbackEventHandler.EventMatch(&ind);
return NL_OK;
@@ -371,9 +464,10 @@ class NanCommand : public WifiCommand {
int processMatchExpiredEvent(WifiEvent &event) {
NanMatchExpiredInd ind;
+ nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA);
memset(&ind,0,sizeof(NanMatchExpiredInd));
- for(nl_iterator nl_itr((struct nlattr *)event.get_vendor_data()); nl_itr.has_next(); nl_itr.next()) {
+ for(nl_iterator nl_itr(vendor_data); nl_itr.has_next(); nl_itr.next()) {
switch(nl_itr.get_type()) {
case NAN_EVT_ATTR_MATCH_PUBLISH_SUBSCRIBE_ID:
ind.publish_subscribe_id = nl_itr.get_u16();
@@ -383,10 +477,10 @@ class NanCommand : public WifiCommand {
break;
default :
ALOGE("processMatchExpiredEvent: unknown attribute(%d)", nl_itr.get_type());
- return NL_SKIP;
}
}
+ ALOGD("[NAN][NA][Match_Expired][Ind]:Received[pub_sub_id:%d, requestor_instance_id:%d]\n", ind.publish_subscribe_id, ind.requestor_instance_id);
if (callbackEventHandler.EventMatchExpired)
callbackEventHandler.EventMatchExpired(&ind);
@@ -414,6 +508,7 @@ class NanCommand : public WifiCommand {
}
}
+ ALOGD("[NAN][NA][PUB-TERMINATED][Ind]:Received[publish_id:%d, reason:%d]\n", ind.publish_id, ind.reason);
if (callbackEventHandler.EventPublishTerminated)
callbackEventHandler.EventPublishTerminated(&ind);
@@ -442,6 +537,7 @@ class NanCommand : public WifiCommand {
}
}
+ ALOGD("[NAN][NA][SUB-TERMINATED][Ind]:Received[subscribe_id:%d, reason:%d]\n", ind.subscribe_id, ind.reason);
if (callbackEventHandler.EventSubscribeTerminated)
callbackEventHandler.EventSubscribeTerminated(&ind);
@@ -485,6 +581,14 @@ class NanCommand : public WifiCommand {
}
}
+ ALOGD("[NAN][NA][FOLLOWUP][Ind]:Received[pub_sub_id:%d, requestor_instance_id:%d, addr:%02x:*:*:*:%02x:%02x, dw_or_faw:%d]\n"
+ "[service_specific_info_len:%d, sdea_service_specific_info_len:%d]\n",
+ ind.publish_subscribe_id, ind.requestor_instance_id, ind.addr[0], ind.addr[4], ind.addr[5], ind.dw_or_faw,
+ ind.service_specific_info_len, ind.sdea_service_specific_info_len);
+ wifi_log_hex_buffer_debug("service_specific_info:", NULL,
+ ind.service_specific_info, ind.service_specific_info_len);
+ wifi_log_hex_buffer_debug("sdea_service_specific_info:", NULL,
+ ind.sdea_service_specific_info, ind.sdea_service_specific_info_len);
if (callbackEventHandler.EventFollowup)
callbackEventHandler.EventFollowup(&ind);
@@ -506,6 +610,7 @@ class NanCommand : public WifiCommand {
}
}
+ ALOGD("[NAN][NA][DISABLED][Ind]:Received[reason:%d]\n", ind.reason);
if (callbackEventHandler.EventDisabled)
callbackEventHandler.EventDisabled(&ind);
@@ -533,14 +638,19 @@ class NanCommand : public WifiCommand {
}
}
if (addr) {
- if (ind.event_type == NAN_EVENT_ID_DISC_MAC_ADDR)
+ if (ind.event_type == NAN_EVENT_ID_DISC_MAC_ADDR) {
memcpy(ind.data.mac_addr.addr, addr, NAN_MAC_ADDR_LEN);
- else
+ memcpy(this->mac, addr, NAN_MAC_ADDR_LEN);
+ } else {
memcpy(ind.data.cluster.addr, addr, NAN_MAC_ADDR_LEN);
+ }
} else {
ALOGE("processNanDiscoveryEvent: No Mac/cluster Address");
}
-
+ ALOGD("[NAN][NA][DISCOVERY][Ind]:Received[eventType:%d, Disc_mac_addr:%02x:*:*:*:%02x:%02x, ClusterAddr:%02x:%02x:%02x:%02x:%02x:%02x]\n",
+ ind.event_type, ind.data.mac_addr.addr[0], ind.data.mac_addr.addr[4], ind.data.mac_addr.addr[5],
+ ind.data.cluster.addr[0], ind.data.cluster.addr[1], ind.data.cluster.addr[2],
+ ind.data.cluster.addr[3],ind.data.cluster.addr[4], ind.data.cluster.addr[5]);
if (callbackEventHandler.EventDiscEngEvent)
callbackEventHandler.EventDiscEngEvent(&ind);
@@ -562,25 +672,71 @@ class NanCommand : public WifiCommand {
}
}
+ ALOGD("[NAN][%d][FOLLOWUP_STATUS][Ind]:Received[reason:%d]\n", ind.id, ind.reason);
if (callbackEventHandler.EventTransmitFollowup)
callbackEventHandler.EventTransmitFollowup(&ind);
return NL_OK;
}
+ int processNanInterfaceDeleted(WifiEvent &event) {
+ NanResponseMsg response;
+ memset(&response, 0, sizeof(response));
+ transaction_id id = 0;
+
+ nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA);
+ for(nl_iterator nl_itr(vendor_data); nl_itr.has_next(); nl_itr.next()) {
+ if (nl_itr.get_type() == NAN_EVT_ATTR_STATUS) {
+ response.status = (NanStatusType)nl_itr.get_u16();
+ } else if(nl_itr.get_type() == NAN_EVT_ATTR_HAL_TRANSACTION_ID) {
+ id = nl_itr.get_u16();
+ }else {
+ ALOGE("processNanINterfaceDeleted : unknown attribute(%d)", nl_itr.get_type());
+ return NL_SKIP;
+ }
+ }
+ response.response_type = NAN_DP_INTERFACE_DELETE;
+ ALOGD("[NAN][Interface Deleted]Event]:Received[Status:%d]\n", response.status);
+ if (callbackEventHandler.NotifyResponse)
+ callbackEventHandler.NotifyResponse(id, &response);
+
+ return NL_OK;
+ }
+
+ int processNanInterfaceCreated(WifiEvent &event) {
+ NanResponseMsg response;
+ memset(&response, 0, sizeof(response));
+ transaction_id id = 0;
+
+ nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA);
+ for(nl_iterator nl_itr(vendor_data); nl_itr.has_next(); nl_itr.next()) {
+ if (nl_itr.get_type() == NAN_EVT_ATTR_STATUS) {
+ response.status = (NanStatusType)nl_itr.get_u16();
+ } else if(nl_itr.get_type() == NAN_EVT_ATTR_HAL_TRANSACTION_ID) {
+ id = nl_itr.get_u16();
+ }else {
+ ALOGE("processNanINterfaceDeleted : unknown attribute(%d)", nl_itr.get_type());
+ return NL_SKIP;
+ }
+ }
+ response.response_type = NAN_DP_INTERFACE_CREATE;
+ ALOGD("[NAN][Interface Created]Event]:Received[Status:%d]\n", response.status);
+ if (callbackEventHandler.NotifyResponse)
+ callbackEventHandler.NotifyResponse(id, &response);
+
+ return NL_OK;
+ }
int putSdeaParams(NanSdeaCtrlParams *sdea_params, WifiRequest *request)
{
int result;
- if (!sdea_params->config_nan_data_path)
- return 0;
-
- result = request->put_u8(NAN_REQ_ATTR_SDEA_PARAM_NDP_TYPE, sdea_params->ndp_type);
- CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put SDEA PARAM ndp_type");
-
- result = request->put_u8(NAN_REQ_ATTR_SDEA_PARAM_SECURITY_CFG, sdea_params->security_cfg);
- CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put SDEA PARAM security_cfg");
+ if (sdea_params->config_nan_data_path) {
+ result = request->put_u8(NAN_REQ_ATTR_SDEA_PARAM_NDP_TYPE, sdea_params->ndp_type);
+ CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put SDEA PARAM ndp_type");
+ result = request->put_u8(NAN_REQ_ATTR_SDEA_PARAM_SECURITY_CFG, sdea_params->security_cfg);
+ CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put SDEA PARAM security_cfg");
+ }
result = request->put_u8(NAN_REQ_ATTR_SDEA_PARAM_RANGING_STATE, sdea_params->ranging_state);
CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put SDEA PARAM ranging_state");
@@ -590,6 +746,8 @@ class NanCommand : public WifiCommand {
result = request->put_u8(NAN_REQ_ATTR_SDEA_PARAM_QOS_CFG, sdea_params->qos_cfg);
CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put SDEA PARAM qos_cfg");
+ ALOGD("Send[Sdea Params: ndpType:%d, security_cfg:%d, ranging_state:%d, range_report:%d, qos_cfg:%d]\n",
+ sdea_params->ndp_type, sdea_params->security_cfg, sdea_params->ranging_state, sdea_params->range_report, sdea_params->qos_cfg);
return result;
}
@@ -609,6 +767,8 @@ class NanCommand : public WifiCommand {
result = request->put_u32(NAN_REQ_ATTR_RANGING_CFG_EGRESS_MM, ranging_cfg->distance_egress_mm);
CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put Ranging CFG distance_egress_mm");
+ ALOGD("Send[Ranging cfg: ranging_interval_msec:%d, config_ranging_indications:%d, distance_ingress_mm:%d, distance_egress_mm:%d]\n",
+ ranging_cfg->ranging_interval_msec, ranging_cfg->config_ranging_indications, ranging_cfg->distance_ingress_mm, ranging_cfg->distance_egress_mm);
return result;
}
@@ -628,6 +788,10 @@ class NanCommand : public WifiCommand {
result = request->put_u16(NAN_REQ_ATTR_RANGE_RESPONSE_CFG_RANGING_RESPONSE, range_resp_cfg->ranging_response);
CHECK_WIFI_STATUS_RETURN_FAIL(result, "Failed to put range response cfg::ranging_response");
+ ALOGD("Send[RangeResponseCfg publish_id:%d, requestor_instance_id:%d, peerAddr:%02x:*:*:*:%02x:%02x, ranging_resp:%d]\n",
+ range_resp_cfg->publish_id, range_resp_cfg->requestor_instance_id, range_resp_cfg->peer_addr[0],
+ range_resp_cfg->peer_addr[4], range_resp_cfg->peer_addr[5],
+ range_resp_cfg->ranging_response);
return result;
}
@@ -644,10 +808,10 @@ public:
version = 0;
memset(&capabilities, 0, sizeof(capabilities));
+ memset(mac, 0, NAN_MAC_ADDR_LEN);
}
int enable(transaction_id id, NanEnableRequest *msg) {
- ALOGD("NAN enable id:%d", id);
WifiRequest request(familyId(), ifaceId());
int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_ENABLE);
@@ -655,7 +819,7 @@ public:
nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
if (!data) {
- ALOGE("enable: request.attr_start fail");
+ ALOGE("NAN enable: request.attr_start fail");
return WIFI_ERROR_OUT_OF_MEMORY;
}
/* Valid master pref values are 2-254 */
@@ -666,6 +830,8 @@ public:
master_pref = 254;
else
master_pref = msg->master_pref;
+ CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "enable:Failed to put transaction id");
+
result = request.put_u8(NAN_REQ_ATTR_MASTER_PREF, master_pref);
CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put master_pref");
@@ -756,30 +922,51 @@ public:
CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_dw.config_5g_dw_band, msg->config_dw.dw_5g_interval_val,
NAN_REQ_ATTR_DW_5G_INTERVAL, request, result, "enable:Failed to put dw_5g_interval_val");
+ CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_disc_mac_addr_randomization, msg->config_disc_mac_addr_randomization,
+ NAN_REQ_ATTR_CONFIG_DISC_MAC_ADDR_RANDOM, request, result, "enable:Failed to put config_disc_mac_addr_rand_interval_sec");
+
CHECK_CONFIG_PUT_32_RETURN_FAIL(msg->config_disc_mac_addr_randomization, msg->disc_mac_addr_rand_interval_sec,
NAN_REQ_ATTR_DISC_MAC_ADDR_RANDOM_INTERVAL, request, result, "enable:Failed to put disc_mac_addr_rand_interval_sec");
CHECK_CONFIG_PUT_32_RETURN_FAIL(msg->config_ndpe_attr, msg->use_ndpe_attr,
NAN_REQ_ATTR_USE_NDPE_ATTR, request, result, "enable:Failed to put use_ndpe_attr");
- CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "enable:Failed to put transaction id");
+ CHECK_CONFIG_PUT_32_RETURN_FAIL(msg->config_discovery_beacon_int, msg->discovery_beacon_interval,
+ NAN_REQ_ATTR_DISCOVERY_BEACON_INT, request, result, "config:Failed to put discovery_beacon_interval");
- request.attr_end(data);
+ CHECK_CONFIG_PUT_32_RETURN_FAIL(msg->config_nss, msg->nss,
+ NAN_REQ_ATTR_NSS, request, result, "config:Failed to put nss");
+
+ CHECK_CONFIG_PUT_32_RETURN_FAIL(msg->config_enable_ranging, msg->enable_ranging,
+ NAN_REQ_ATTR_ENABLE_RANGING, request, result, "config:Failed to put enable_ranging");
+ CHECK_CONFIG_PUT_32_RETURN_FAIL(msg->config_dw_early_termination, msg->enable_dw_termination,
+ NAN_REQ_ATTR_DW_EARLY_TERMINATION, request, result, "config:Failed to put enable_dw_termination");
+
+ request.attr_end(data);
+ ALOGD("[NAN][%d][ENABLE][req]::Sent[Mpref:%d, cluster_low:%d, cluster_high:%d, support5g:%d, sid_beaconl:%d, rssiC24g:%d, rssiM5g:%d, rssiCP5g:%d]\n"
+ "[rssi_window_size:%d, oui:%d, intf_addr:%02x:*:*:*:%02x:%02x, config_cluster_attribute:%d, dwell_time:%d,%d,%d, scan_period:%d,%d,%d, random_factor_force:%d, hop_count_force:%d]\n"
+ "[chan24g:%d, chan5g:%d, subscribe_sid_beacon:%d, dw24gInterval:%d, dw5gInterval:%d, config_disc_mac_addr_randomization:%d, disc_mac_addr_rand_interval_sec:%d, use_ndpe_attr:%d]\n",
+ id, master_pref, msg->cluster_low, msg->cluster_high, msg->support_5g_val, msg->sid_beacon_val, msg->rssi_close_2dot4g_val,
+ msg->rssi_middle_5g_val, msg->rssi_close_proximity_5g_val, msg->rssi_window_size_val, msg->oui_val, msg->intf_addr_val[0],
+ msg->intf_addr_val[4], msg->intf_addr_val[5], msg->config_cluster_attribute_val, msg->scan_params_val.dwell_time[0],
+ msg->scan_params_val.dwell_time[1], msg->scan_params_val.dwell_time[2], msg->scan_params_val.scan_period[0],
+ msg->scan_params_val.scan_period[1], msg->scan_params_val.scan_period[2], msg->random_factor_force_val, msg->hop_count_force_val,
+ msg->channel_24g_val, msg->channel_5g_val, msg->subscribe_sid_beacon_val, msg->config_dw.dw_2dot4g_interval_val,
+ msg->config_dw.dw_5g_interval_val, msg->config_disc_mac_addr_randomization, msg->disc_mac_addr_rand_interval_sec, msg->use_ndpe_attr);
+ ALOGD("Continued..[discovery_beacon_interval:%d, nss:%d, enable_ranging:%d, enable_dw_termination:%d]\n",
+ msg->discovery_beacon_interval, msg->nss, msg->enable_ranging, msg->enable_dw_termination);
registerNanEvents();
result = requestResponse(request);
if (result != WIFI_SUCCESS) {
- ALOGE("failed to NAN; result = %d", result);
+ ALOGE("[NAN][%d][ENABLE][req]::Failed[result:%d]\n", id, result);
unregisterNanEvents();
- } else {
- ALOGD("Start NAN...success");
}
return result;
}
int disable(transaction_id id)
{
- ALOGD("NAN disable id:%d", id);
WifiRequest request(familyId(), ifaceId());
unregisterNanEvents();
@@ -794,13 +981,15 @@ public:
}
CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "disable:Failed to put transaction id");
request.attr_end(data);
+ ALOGD("[NAN][%d][DISABLE][req]:Sent\n", id);
result = requestResponse(request);
- CHECK_WIFI_STATUS_RETURN_FAIL(result, "disable:Failed to requestResponse");
+ if (result != WIFI_SUCCESS) {
+ ALOGE("[NAN][%d][DISABLE][req]::Failed[result:%d]\n", id, result);
+ }
return result;
}
int config(transaction_id id, NanConfigRequest *msg) {
- ALOGD("NAN config id:%d", id);
WifiRequest request(familyId(), ifaceId());
int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_CONFIG);
@@ -812,6 +1001,8 @@ public:
return WIFI_ERROR_OUT_OF_MEMORY;
}
+ CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "config:Failed to put transaction id");
+
CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_sid_beacon, msg->sid_beacon,
NAN_REQ_ATTR_SID_BEACON_VAL, request, result, "config:Failed to put sid_beacon");
@@ -922,20 +1113,69 @@ public:
CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_dw.config_5g_dw_band, msg->config_dw.dw_5g_interval_val,
NAN_REQ_ATTR_DW_5G_INTERVAL, request, result, "config:Failed to put dw_5g_interval_val");
- CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_disc_mac_addr_randomization, msg->disc_mac_addr_rand_interval_sec,
+ CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_disc_mac_addr_randomization, msg->config_disc_mac_addr_randomization,
+ NAN_REQ_ATTR_CONFIG_DISC_MAC_ADDR_RANDOM, request, result, "enable:Failed to put config_disc_mac_addr_rand_interval_sec");
+
+ CHECK_CONFIG_PUT_32_RETURN_FAIL(msg->config_disc_mac_addr_randomization, msg->disc_mac_addr_rand_interval_sec,
NAN_REQ_ATTR_DISC_MAC_ADDR_RANDOM_INTERVAL, request, result, "config:Failed to put disc_mac_addr_rand_interval_sec");
CHECK_CONFIG_PUT_32_RETURN_FAIL(msg->config_ndpe_attr, msg->use_ndpe_attr,
NAN_REQ_ATTR_USE_NDPE_ATTR, request, result, "config:Failed to put use_ndpe_attr");
- CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "config:Failed to put transaction id");
+ CHECK_CONFIG_PUT_32_RETURN_FAIL(msg->config_discovery_beacon_int, msg->discovery_beacon_interval,
+ NAN_REQ_ATTR_DISCOVERY_BEACON_INT, request, result, "config:Failed to put discovery_beacon_interval");
+
+ CHECK_CONFIG_PUT_32_RETURN_FAIL(msg->config_nss, msg->nss,
+ NAN_REQ_ATTR_NSS, request, result, "config:Failed to put nss");
+
+ CHECK_CONFIG_PUT_32_RETURN_FAIL(msg->config_enable_ranging, msg->enable_ranging,
+ NAN_REQ_ATTR_ENABLE_RANGING, request, result, "config:Failed to put enable_ranging");
+
+ CHECK_CONFIG_PUT_32_RETURN_FAIL(msg->config_dw_early_termination, msg->enable_dw_termination,
+ NAN_REQ_ATTR_DW_EARLY_TERMINATION, request, result, "config:Failed to put enable_dw_termination");
+
request.attr_end(data);
+
+ ALOGD("[NAN][%d][CONFIG][req]::Sent[sid_beacon:%d, rssiP:%d, master_pref:%d, rssiCP5g:%d, rssi_window_size:%d]\n"
+ "[config_cluster_attribute:%d, dwell_time:%d,%d,%d, scan_period:%d,%d,%d, random_factor_force:%d, hop_count_force:%d]\n"
+ "[payload_transmit_flag%d, is_wfd:%d, is_wfds:%d, is_tdls:%d, is_ibss:%d, is_mesh:%d, wlan_infra_field:%d]\n"
+ "[num_config_discovery_attr:%d]\n",
+ id, msg->sid_beacon, msg->rssi_proximity, msg->master_pref, msg->rssi_close_proximity_5g_val, msg->rssi_window_size_val,
+ msg->config_cluster_attribute_val, msg->scan_params_val.dwell_time[0], msg->scan_params_val.dwell_time[1],
+ msg->scan_params_val.dwell_time[2], msg->scan_params_val.scan_period[0], msg->scan_params_val.scan_period[1],
+ msg->scan_params_val.scan_period[2], msg->random_factor_force_val, msg->hop_count_force_val, msg->conn_capability_val.payload_transmit_flag,
+ msg->conn_capability_val.is_wfd_supported, msg->conn_capability_val.is_wfds_supported, msg->conn_capability_val.is_tdls_supported,
+ msg->conn_capability_val.is_ibss_supported, msg->conn_capability_val.is_mesh_supported, msg->conn_capability_val.wlan_infra_field,
+ msg->num_config_discovery_attr);
+ if (msg->num_config_discovery_attr)
+ for (int i = 0; i < msg->num_config_discovery_attr; i++) {
+ NanTransmitPostDiscovery *discovery_attr = &msg->discovery_attr_val[i];
+ ALOGD("Continued...Sent[discovery_attr: type:%d, role:%d, transmit_freq:%d, duration:%d, avail_interval_bitmap:%d, addr:%02x:*:*:*:%02x:%02x, meshId_len:%d]\n"
+ "[meshId:%.*s, infrastructure_ssid_len:%d, infrastructure_ssid:%.*s]\n",
+ discovery_attr->type, discovery_attr->role, discovery_attr->transmit_freq, discovery_attr->duration, discovery_attr->avail_interval_bitmap, discovery_attr->addr[0],
+ discovery_attr->addr[4], discovery_attr->addr[5], discovery_attr->mesh_id_len,
+ discovery_attr->mesh_id_len > 20 ? 20 : discovery_attr->mesh_id_len, discovery_attr->mesh_id, discovery_attr->infrastructure_ssid_len,
+ discovery_attr->infrastructure_ssid_len > 20 ? 20 : discovery_attr->infrastructure_ssid_len, discovery_attr->infrastructure_ssid_val);
+ }
+ if (msg->config_fam) {
+ ALOGD("Continued...Sent[numchans:%d]\n", msg->fam_val.numchans);
+ for (int i = 0; i < msg->fam_val.numchans; i++) {
+ NanFurtherAvailabilityChannel *further_avail_chan = &msg->fam_val.famchan[i];
+ ALOGD("[further_avail_chan entry_control:%d, class_val:%d, channel:%d, mapid:%d, avail_interval_bitmap:%d]\n",
+ further_avail_chan->entry_control, further_avail_chan->class_val, further_avail_chan->channel,
+ further_avail_chan->mapid, further_avail_chan->avail_interval_bitmap);
+ }
+ }
+ ALOGD("Continued...Sent[subscribe_sid_beacon:%d, dw24gInterval:%d, dw5gInterval:%d, disc_mac_addr_rand_interval_sec:%d, use_ndpe_attr:%d]\n"
+ "[discovery_beacon_interval:%d, nss:%d, enable_dw_termination:%d, enable_ranging:%d, config_disc_mac_addr_randomization:%d]\n",
+ msg->subscribe_sid_beacon_val, msg->config_dw.dw_2dot4g_interval_val, msg->config_dw.dw_5g_interval_val,
+ msg->disc_mac_addr_rand_interval_sec, msg->use_ndpe_attr, msg->discovery_beacon_interval, msg->nss,
+ msg->enable_dw_termination, msg->enable_ranging, msg->config_disc_mac_addr_randomization);
+
result = requestResponse(request);
if (result != WIFI_SUCCESS) {
- ALOGE("failed to set_config; result = %d", result);
- } else {
- ALOGD("NAN config...success");
+ ALOGE("[NAN][%d][CONFIG][req]::Failed[result:%d]\n", id, result);
}
return result;
}
@@ -951,7 +1191,6 @@ public:
}
int publish(transaction_id id, NanPublishRequest *msg) {
- ALOGD("NAN publish transId:%d publishId:%d publishType:%d", id, msg->publish_id, msg->publish_type);
WifiRequest request(familyId(), ifaceId());
int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_PUBLISH);
@@ -963,6 +1202,8 @@ public:
return WIFI_ERROR_OUT_OF_MEMORY;
}
+ CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "publish:Failed to put transaction id");
+
CHECK_CONFIG_PUT_16_RETURN_FAIL(msg->publish_id, msg->publish_id,
NAN_REQ_ATTR_PUBLISH_ID, request, result, "publish:Failed to put msg->publish_id");
@@ -1039,22 +1280,38 @@ public:
if (result != 0)
return result;
- CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "publish:Failed to put transaction id");
-
request.attr_end(data);
+
+ ALOGD("[NAN][%d][PUB][req]::Sent[pubId:%d pubType:%d, TTL:%d, period:%d, txType:%d, pubCount:%d, service_len:%d, service:%.*s]\n"
+ "[publish_match_indicator:%d, service_specific_info_len:%d, rxMF_len:%d]\n"
+ "[txMF_len:%d, rssi_threshold_flag:%d, connmap:%d, recv_indication_cfg:%d, sdea_service_specific_info_len:%d]\n"
+ "[ranging_auto_response:%d]\n", id, msg->publish_id, msg->publish_type, msg->ttl, msg->period,
+ msg->tx_type, msg->publish_count, msg->service_name_len, msg->service_name_len > 20 ? 20 : msg->service_name_len,
+ msg->service_name, msg->publish_match_indicator, msg->service_specific_info_len,
+ msg->rx_match_filter_len, msg->tx_match_filter_len, msg->rssi_threshold_flag, msg->connmap,
+ msg->recv_indication_cfg, msg->sdea_service_specific_info_len, msg->ranging_auto_response);
+
+ wifi_log_hex_buffer_debug("rx_match_filter:", NULL, msg->rx_match_filter,
+ msg->rx_match_filter_len);
+ wifi_log_hex_buffer_debug("tx_match_filter:", NULL, msg->tx_match_filter,
+ msg->tx_match_filter_len);
+ wifi_log_hex_buffer_debug("service_specific_info:", NULL, msg->service_specific_info,
+ msg->service_specific_info_len);
+ wifi_log_hex_buffer_debug("sdea_service_specific_info:", NULL,
+ msg->sdea_service_specific_info, msg->sdea_service_specific_info_len);
result = requestResponse(request);
if (result != WIFI_SUCCESS) {
- ALOGE("failed to publish; result = %d", result);
- } else {
- ALOGD("NAN publish...success");
+ ALOGE("[NAN][%d][PUB][req]::Failed[result:%d]\n", id, result);
}
return result;
}
int publishCancel(transaction_id id, NanPublishCancelRequest *msg) {
- ALOGD("NAN publishCancel transId:%d, publish_id:%d", id, msg->publish_id);
WifiRequest request(familyId(), ifaceId());
+ if (is_reset_in_progress())
+ return WIFI_SUCCESS;
+
int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_PUBLISHCANCEL);
CHECK_WIFI_STATUS_RETURN_FAIL(result, "publishCancel:Failed to create WifiRequest");
@@ -1064,24 +1321,22 @@ public:
return WIFI_ERROR_OUT_OF_MEMORY;
}
+ CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "publishCancel:Failed to put transaction id");
+
CHECK_CONFIG_PUT_16_RETURN_FAIL(1, msg->publish_id,
NAN_REQ_ATTR_PUBLISH_ID, request, result, "publishCancel:Failed to put msg->publish_id");
- CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "publishCancel:Failed to put transaction id");
-
request.attr_end(data);
+ ALOGD("[NAN][%d][PUB-CANCEL][req]::Sent[pubId:%d]\n", id, msg->publish_id);
result = requestResponse(request);
if (result != WIFI_SUCCESS) {
- ALOGE("failed to publishCancel; result = %d", result);
- } else {
- ALOGD("NAN publishCancel...success");
+ ALOGE("[NAN][%d][PUB-CANCEL][req]::Failed[result:%d]\n", id, result);
}
return result;
}
int subscribe(transaction_id id, NanSubscribeRequest *msg) {
- ALOGD("NAN subscribe trans_id:%d subscribe_id:%d subscribetype:%d", id, msg->subscribe_id, msg->subscribe_type);
WifiRequest request(familyId(), ifaceId());
int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_SUBSCRIBE);
@@ -1093,6 +1348,8 @@ public:
return WIFI_ERROR_OUT_OF_MEMORY;
}
+ CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "subscribe:Failed to put transaction id");
+
CHECK_CONFIG_PUT_16_RETURN_FAIL(msg->subscribe_id, msg->subscribe_id,
NAN_REQ_ATTR_SUBSCRIBE_ID, request, result, "subscribe:Failed to put msg->publish_id");
@@ -1184,23 +1441,40 @@ public:
if (result != 0)
return result;
- CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "subscribe:Failed to put transaction id");
-
request.attr_end(data);
+
+ ALOGD("[NAN][%d][SUB][req]::Sent[subId:%d, subType:%d, TTL:%d, period:%d, serviceRespFilter:%d, serviceRespInclude:%d, useServiceRespFilter:%d, ssiRequiredForMatchIndication:%d, sub_match_indicator:%d]\n"
+ "[subCount:%d, service_len:%d, service:%.*s, service_specific_info_len:%d, rxMF_len:%d]\n"
+ "[txMF_len:%drssi_threshold_flag:%d, connmap:%d, num_intf_addr_present:%d, recv_indication_cfg:%d, sdea_service_specific_info_len:%d]\n"
+ "[ranging_auto_resp:%d]\n", id, msg->subscribe_id, msg->subscribe_type, msg->ttl, msg->period,
+ msg->serviceResponseFilter, msg->serviceResponseInclude, msg->useServiceResponseFilter, msg->ssiRequiredForMatchIndication,
+ msg->subscribe_match_indicator, msg->subscribe_count, msg->service_name_len,
+ msg->service_name_len > 20 ? 20 : msg->service_name_len, msg->service_name, msg->service_specific_info_len,
+ msg->rx_match_filter_len, msg->tx_match_filter_len,
+ msg->rssi_threshold_flag, msg->connmap, msg->num_intf_addr_present, msg->recv_indication_cfg,
+ msg->sdea_service_specific_info_len, msg->ranging_auto_response);
+ wifi_log_hex_buffer_debug("rx_match_filter:", NULL, msg->rx_match_filter,
+ msg->rx_match_filter_len);
+ wifi_log_hex_buffer_debug("tx_match_filter:", NULL, msg->tx_match_filter,
+ msg->tx_match_filter_len);
+ wifi_log_hex_buffer_debug("service_specific_info:", NULL, msg->service_specific_info,
+ msg->service_specific_info_len);
+ wifi_log_hex_buffer_debug("sdea_service_specific_info:", NULL,
+ msg->sdea_service_specific_info, msg->sdea_service_specific_info_len);
result = requestResponse(request);
if (result != WIFI_SUCCESS) {
- ALOGE("failed to subscribe; result = %d", result);
- } else {
- ALOGD("NAN subscribe...success");
+ ALOGE("[NAN][%d][SUB][req]::Failed[result:%d]\n", id, result);
}
return result;
}
int subscribeCancel(transaction_id id, NanSubscribeCancelRequest *msg) {
- ALOGD("NAN subscribeCancel transId:%d subscribeId:%d", id, msg->subscribe_id);
WifiRequest request(familyId(), ifaceId());
+ if (is_reset_in_progress())
+ return WIFI_SUCCESS;
+
int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_SUBSCRIBECANCEL);
CHECK_WIFI_STATUS_RETURN_FAIL(result, "subscribeCancel:Failed to create WifiRequest");
@@ -1210,23 +1484,21 @@ public:
return WIFI_ERROR_OUT_OF_MEMORY;
}
+ CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "subscribeCancel:Failed to put transaction id");
+
CHECK_CONFIG_PUT_16_RETURN_FAIL(1, msg->subscribe_id,
NAN_REQ_ATTR_SUBSCRIBE_ID, request, result, "subscribeCancel:Failed to put msg->subscribe_id");
- CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "subscribeCancel:Failed to put transaction id");
-
request.attr_end(data);
+ ALOGD("[NAN][%d][SUB-CANCEL][req]::Sent[subId:%d]\n", id, msg->subscribe_id);
result = requestResponse(request);
if (result != WIFI_SUCCESS) {
- ALOGE("failed to subscribeCancel; result = %d", result);
- } else {
- ALOGD("NAN subscribeCancel...success");
+ ALOGE("[NAN][%d][SUB-CANCEL][req]::Failed[result:%d]\n", id, result);
}
return result;
}
int followup(transaction_id id, NanTransmitFollowupRequest *msg) {
- ALOGD("NAN followup transid:%d pub/subId:%d reqInstId:%d", id, msg->publish_subscribe_id, msg->requestor_instance_id);
WifiRequest request(familyId(), ifaceId());
int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_TXFOLLOWUP);
@@ -1238,6 +1510,8 @@ public:
return WIFI_ERROR_OUT_OF_MEMORY;
}
+ CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "followup:Failed to put transaction id");
+
CHECK_CONFIG_PUT_16_RETURN_FAIL(1, msg->publish_subscribe_id,
NAN_REQ_ATTR_FOLLOWUP_ID, request, result, "followup:Failed to put msg->publish_subscribe_id");
@@ -1268,21 +1542,25 @@ public:
CHECK_CONFIG_PUT_RETURN_FAIL(msg->sdea_service_specific_info_len, msg->sdea_service_specific_info, msg->sdea_service_specific_info_len,
NAN_REQ_ATTR_PUBLISH_SDEA, request, result, "publish:Failed to put msg->sdea_service_specific_info");
- CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "followup:Failed to put transaction id");
-
request.attr_end(data);
+ ALOGD("[NAN][%d][TXFOLLOWUP][req]::Sent[pub/subId:%d reqInstId:%d, addr:%02x:*:*:*:%02x:%02x, priority:%d, dw_or_faw:%d, service_specific_info_len:%d]\n"
+ "[recv_indication_cfg:%d, sdea_service_specific_info_len:%d]\n",
+ id, msg->publish_subscribe_id, msg->requestor_instance_id, msg->addr[0], msg->addr[4], msg->addr[5],
+ msg->priority, msg->dw_or_faw, msg->service_specific_info_len,
+ msg->recv_indication_cfg, msg->sdea_service_specific_info_len);
+ wifi_log_hex_buffer_debug("service_specific_info:", NULL, msg->service_specific_info,
+ msg->service_specific_info_len);
+ wifi_log_hex_buffer_debug("sdea_service_specific_info:", NULL,
+ msg->sdea_service_specific_info, msg->sdea_service_specific_info_len);
result = requestResponse(request);
if (result != WIFI_SUCCESS) {
- ALOGE("failed to followup; result = %d", result);
- } else {
- ALOGD("NAN followup...success");
+ ALOGE("[NAN][%d][TXFOLLOWUP][req]::Failed[result:%d]\n", id, result);
}
return result;
}
int getCapabilities(transaction_id id) {
- ALOGD("NAN getCapabilities transId:%d", id);
WifiRequest request(familyId(), ifaceId());
int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_CAPABILITIES);
@@ -1295,11 +1573,10 @@ public:
}
CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "getCapabilities:Failed to put transaction id");
request.attr_end(data);
+ ALOGD("[NAN][%d][CAPABILITIES][req]::Sent\n", id);
result = requestResponse(request);
- if (result != WIFI_SUCCESS) {
- ALOGE("failed to getCapabilities; result = %d", result);
- } else {
- ALOGD("NAN getCapabilities...success");
+ if (result != WIFI_SUCCESS) {
+ ALOGE("[NAN][%d][CAPABILITIES][req]::Failed[result:%d]\n", id, result);
}
return result;
}
@@ -1312,11 +1589,8 @@ public:
return NL_SKIP;
}
- int id = event.get_vendor_id();
int subcmd = event.get_vendor_subcmd();
- ALOGI("NAN %s Id = 0x%x, subcmd = %s(0x%x)", __func__, id, getEventName(subcmd), subcmd);
-
switch(subcmd) {
case SLSI_NAN_EVENT_MATCH:
ret = processMatchEvent(event);
@@ -1342,6 +1616,12 @@ public:
case SLSI_NAN_EVENT_TRANSMIT_FOLLOWUP_STATUS:
ret = processNanFollowupStatus(event);
break;
+ case SLSI_NL80211_VENDOR_NAN_INTERFACE_CREATED:
+ ret = processNanInterfaceCreated(event);
+ break;
+ case SLSI_NL80211_VENDOR_NAN_INTERFACE_DELETED:
+ ret = processNanInterfaceDeleted(event);
+ break;
default:
return datacmd.handleEvent(event, callbackEventHandler);
}
@@ -1361,8 +1641,35 @@ public:
transaction_id id = processResponse(reply, &response);
if ( id < 0)
return NL_SKIP;
-
- ALOGD("NAN %s transId:%d status:%d, response:%d", __func__, id, response.status, response.response_type);
+ if (response.response_type == NAN_RESPONSE_PUBLISH) {
+ if (response.status == NAN_STATUS_SUCCESS)
+ ALOGD("[NAN][%d][%s][resp]:SUCCESS[publish_id:%d]", id, getResponseName(response.response_type),
+ response.body.publish_response.publish_id);
+ else
+ ALOGD("[NAN][%d][%s][resp]:FAIL[publish_id:%d status:%d]", id, getResponseName(response.response_type),
+ response.body.publish_response.publish_id, response.status);
+ } else if (response.response_type == NAN_RESPONSE_SUBSCRIBE) {
+ if (response.status == NAN_STATUS_SUCCESS)
+ ALOGD("[NAN][%d][%s][resp]:SUCCESS[subscribe_id:%d]", id, getResponseName(response.response_type),
+ response.body.subscribe_response.subscribe_id);
+ else
+ ALOGD("[NAN][%d][%s][resp]:FAIL[subscribe_id:%d status:%d]", id, getResponseName(response.response_type),
+ response.body.subscribe_response.subscribe_id, response.status);
+ } else {
+ if (response.status == NAN_STATUS_SUCCESS)
+ ALOGD("[NAN][%d][%s][resp]:SUCCESS", id, getResponseName(response.response_type));
+ else
+ ALOGD("[NAN][%d][%s][resp]:FAIL[status:%d]", id, getResponseName(response.response_type),
+ response.status);
+ }
+ if (response.response_type == NAN_RESPONSE_ENABLED) {
+ NanDiscEngEventInd ind;
+ memset(&ind,0,sizeof(ind));
+ ind.event_type = NAN_EVENT_ID_DISC_MAC_ADDR;
+ memcpy(ind.data.mac_addr.addr, this->mac, NAN_MAC_ADDR_LEN);
+ if (callbackEventHandler.EventDiscEngEvent)
+ callbackEventHandler.EventDiscEngEvent(&ind);
+ }
if (callbackEventHandler.NotifyResponse)
callbackEventHandler.NotifyResponse(id, &response);
return NL_OK;
@@ -1372,19 +1679,18 @@ public:
int result;
WifiRequest request(familyId(), ifaceId());
- ALOGI("NAN DATA-PATH req subcmd:%s(0x%x) transaction_id:%d", datacmd.getCmdName(subcmd), subcmd, id);
-
+ ALOGD("[NAN][%d][%s][req]:: Sent", id, datacmd.getCmdName(subcmd));
+ if (subcmd == SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_INTERFACE_DELETE)
+ linuxSetIfaceFlags((char *)data, 0);
result = datacmd.getDataPathNLMsg(id, data, subcmd, request);
if (result != WIFI_SUCCESS) {
return result;
}
result = requestResponse(request);
if (result != WIFI_SUCCESS) {
- ALOGE("NAN DATA-PATH req subcmd:%s(0x%x)...failed(%d)", datacmd.getCmdName(subcmd), subcmd, result);
- unregisterNanEvents();
+ ALOGE("[NAN][%d][%s][req]:: Failed[result:%d]", id, datacmd.getCmdName(subcmd), result);
} else {
datacmd.requestSuccess(id, data, subcmd);
- ALOGD("NAN DATA-PATH req subcmd:%s(0x%x)...success", datacmd.getCmdName(subcmd), subcmd);
}
return result;
}
@@ -1414,7 +1720,7 @@ wifi_error nan_enable_request(transaction_id id,
NanCommand *nanRequest = new NanCommand(iface, id);
if (!nanRequest) {
- ALOGE("nan_enable_request:: Unable to create NanCommand");
+ ALOGE("[NAN][%d][ENABLE][req]:: Failed[Create Command]\n", id);
return WIFI_ERROR_OUT_OF_MEMORY;
}
@@ -1433,6 +1739,7 @@ wifi_error nan_disable_request(transaction_id id, wifi_interface_handle iface) {
wifi_error ret;
if (!nanRequest) {
+ ALOGE("[NAN][%d][DISABLE][req]:: Failed[Create Command]\n", id);
return WIFI_ERROR_OUT_OF_MEMORY;
}
ret = (wifi_error)nanRequest->disable(id);
@@ -1447,6 +1754,7 @@ wifi_error nan_publish_request(transaction_id id,
NanPublishRequest *msg) {
NanCommand *nanRequest = nan_get_object(id, iface);
if (!nanRequest) {
+ ALOGE("[NAN][%d][PUB][req]:: Failed[Create Command]\n", id);
return WIFI_ERROR_OUT_OF_MEMORY;
}
return (wifi_error)nanRequest->publish(id, msg);
@@ -1458,6 +1766,7 @@ wifi_error nan_publish_cancel_request(transaction_id id,
NanPublishCancelRequest *msg) {
NanCommand *nanRequest = nan_get_object(id, iface);
if (!nanRequest) {
+ ALOGE("[NAN][%d][PUB-CANCEL][req]:: Failed[Create Command]\n", id);
return WIFI_ERROR_OUT_OF_MEMORY;
}
return (wifi_error)nanRequest->publishCancel(id, msg);
@@ -1469,6 +1778,7 @@ wifi_error nan_subscribe_request(transaction_id id,
NanSubscribeRequest *msg) {
NanCommand *nanRequest = nan_get_object(id, iface);
if (!nanRequest) {
+ ALOGE("[NAN][%d][SUB][req]:: Failed[Create Command]\n", id);
return WIFI_ERROR_OUT_OF_MEMORY;
}
return (wifi_error)nanRequest->subscribe(id, msg);
@@ -1480,6 +1790,7 @@ wifi_error nan_subscribe_cancel_request(transaction_id id,
NanSubscribeCancelRequest *msg) {
NanCommand *nanRequest = nan_get_object(id, iface);
if (!nanRequest) {
+ ALOGE("[NAN][%d][SUB-CANCEL][req]:: Failed[Create Command]\n", id);
return WIFI_ERROR_OUT_OF_MEMORY;
}
return (wifi_error)nanRequest->subscribeCancel(id, msg);
@@ -1491,6 +1802,7 @@ wifi_error nan_transmit_followup_request(transaction_id id,
NanTransmitFollowupRequest *msg) {
NanCommand *nanRequest = nan_get_object(id, iface);
if (!nanRequest) {
+ ALOGE("[NAN][%d][TXFOLLOWUP][req]:: Failed[Create Command]\n", id);
return WIFI_ERROR_OUT_OF_MEMORY;
}
return (wifi_error)nanRequest->followup(id, msg);
@@ -1502,6 +1814,7 @@ wifi_error nan_config_request(transaction_id id,
NanConfigRequest *msg) {
NanCommand *nanRequest = nan_get_object(id, iface);
if (!nanRequest) {
+ ALOGE("[NAN][%d][CONFIG][req]:: Failed[Create Command]\n", id);
return WIFI_ERROR_OUT_OF_MEMORY;
}
return (wifi_error)nanRequest->config(id, msg);
@@ -1524,6 +1837,7 @@ wifi_error nan_get_capabilities(transaction_id id,
wifi_interface_handle iface) {
NanCommand *nanRequest = nan_get_object(id, iface);
if (!nanRequest) {
+ ALOGE("[NAN][%d][CAPABILITIES][req]:: Failed[Out of memory]\n", id);
return WIFI_ERROR_OUT_OF_MEMORY;
}
return (wifi_error)nanRequest->getCapabilities(id);
@@ -1534,6 +1848,7 @@ wifi_error nan_data_interface_create(transaction_id id,
char* iface_name) {
NanCommand *nanRequest = nan_get_object(id, iface);
if (!nanRequest) {
+ ALOGE("[NAN][%d][DATA_IF_ADD][req]:: Failed[Out of memory]\n", id);
return WIFI_ERROR_OUT_OF_MEMORY;
}
return (wifi_error)nanRequest->dataPathReq(id, iface_name,
@@ -1545,6 +1860,7 @@ wifi_error nan_data_interface_delete(transaction_id id,
char* iface_name) {
NanCommand *nanRequest = nan_get_object(id, iface);
if (!nanRequest) {
+ ALOGE("[NAN][%d][DATA_IF_DEL][req]:: Failed[Out of memory]\n", id);
return WIFI_ERROR_OUT_OF_MEMORY;
}
return (wifi_error)nanRequest->dataPathReq(id, iface_name,
@@ -1557,6 +1873,7 @@ wifi_error nan_data_request_initiator(transaction_id id,
NanDataPathInitiatorRequest* msg) {
NanCommand *nanRequest = nan_get_object(id, iface);
if (!nanRequest) {
+ ALOGE("[NAN][%d][DATA_REQ][req]:: Failed[Out of memory]\n", id);
return WIFI_ERROR_OUT_OF_MEMORY;
}
return (wifi_error)nanRequest->dataPathReq(id, msg,
@@ -1569,6 +1886,7 @@ wifi_error nan_data_indication_response(transaction_id id,
NanDataPathIndicationResponse* msg) {
NanCommand *nanRequest = nan_get_object(id, iface);
if (!nanRequest) {
+ ALOGE("[NAN][%d][DATA_RES][req]:: Failed[Out of memory]\n", id);
return WIFI_ERROR_OUT_OF_MEMORY;
}
return (wifi_error)nanRequest->dataPathReq(id, msg,
@@ -1581,6 +1899,7 @@ wifi_error nan_data_end(transaction_id id,
NanDataPathEndRequest* msg) {
NanCommand *nanRequest = nan_get_object(id, iface);
if (!nanRequest) {
+ ALOGE("[NAN][%d][DATA_END][req]:: Failed[Out of memory]\n", id);
return WIFI_ERROR_OUT_OF_MEMORY;
}
return (wifi_error)nanRequest->dataPathReq(id, msg,
diff --git a/wifi_nan_data_path.cpp b/wifi_nan_data_path.cpp
index 315ac4a..374de2a 100755
--- a/wifi_nan_data_path.cpp
+++ b/wifi_nan_data_path.cpp
@@ -18,7 +18,7 @@
#include "sync.h"
-#include <utils/Log.h>
+#include <log/log.h>
#include "wifi_hal.h"
#include "common.h"
@@ -47,13 +47,15 @@ int NanDataCommand::dataInterfaceCreateDelete(u16 id, char *ifaceName, int subcm
if (!data)
return WIFI_ERROR_OUT_OF_MEMORY;
+ CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "dataInterfacecreateDelete:Failed to put transaction id");
+
result = request.put_u8(NAN_REQ_ATTR_DATA_INTERFACE_NAME_LEN, strlen(ifaceName));
CHECK_WIFI_STATUS_RETURN_FAIL(result, "Failed to put ifaceName_len");
result = request.put(NAN_REQ_ATTR_DATA_INTERFACE_NAME, ifaceName, strlen(ifaceName));
CHECK_WIFI_STATUS_RETURN_FAIL(result, "Failed to put ifaceName");
- CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "dataInterfacecreateDelete:Failed to put transaction id");
request.attr_end(data);
+ ALOGD("Send[IfaceNamelen:%d, IfaceName:%.*s]\n", (int)strlen(ifaceName), strlen(ifaceName) > 20 ? 20 : (int)strlen(ifaceName), ifaceName);
return WIFI_SUCCESS;
}
@@ -62,6 +64,7 @@ int NanDataCommand::dataRequestInitiate(u16 id, NanDataPathInitiatorRequest* msg
nlattr *data = newNlVendorMsg(SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_REQUEST_INITIATOR, request);
if (!data)
return WIFI_ERROR_OUT_OF_MEMORY;
+ CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "dataRequestInitiate:Failed to put transaction id");
result = request.put_u32(NAN_REQ_ATTR_REQ_INSTANCE_ID, msg->requestor_instance_id);
CHECK_WIFI_STATUS_RETURN_FAIL(result, "Failed to put req_instance_id");
result = request.put_u8(NAN_REQ_ATTR_CHAN_REQ_TYPE, msg->channel_request_type);
@@ -91,9 +94,15 @@ int NanDataCommand::dataRequestInitiate(u16 id, NanDataPathInitiatorRequest* msg
CHECK_WIFI_STATUS_RETURN_FAIL(result, "Failed to put req_instance_id");
}
result = putSecurityInfo(msg->cipher_type, &msg->key_info, 0, NULL, &request);
- CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "dataRequestInitiate:Failed to put transaction id");
request.attr_end(data);
+ ALOGD("Send[requestor_instance_id:%d, chan_requestType:%d, channel:%d, peer_disc_mac_addr:%02x:*:*:*:%02x:%02x, ndp_iface:%s, security_cfg:%d]\n"
+ "[qos_cfg:%d, ndp_app_info_len:%d, service_len:%d, service:%.*s]\n",
+ msg->requestor_instance_id, msg->channel_request_type, msg->channel, msg->peer_disc_mac_addr[0],
+ msg->peer_disc_mac_addr[4], msg->peer_disc_mac_addr[5], msg->ndp_iface, msg->ndp_cfg.security_cfg,
+ msg->ndp_cfg.qos_cfg, msg->app_info.ndp_app_info_len,
+ msg->service_name_len, msg->service_name_len > 20 ? 20 : msg->service_name_len, msg->service_name);
+ wifi_log_hex_buffer_debug("ndp_app_info:", NULL, msg->app_info.ndp_app_info, msg->app_info.ndp_app_info_len);
return result;
}
@@ -102,6 +111,8 @@ int NanDataCommand::dataIndicationResponse(u16 id, NanDataPathIndicationResponse
nlattr *data = newNlVendorMsg(SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_INDICATION_RESPONSE, request);
if (!data)
return WIFI_ERROR_OUT_OF_MEMORY;
+ CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "dataIndicationResponse:Failed to put transaction id");
+
result = request.put_u32(NAN_REQ_ATTR_NDP_INSTANCE_ID, msg->ndp_instance_id);
CHECK_WIFI_STATUS_RETURN_FAIL(result, "Failed to put ndp_instance_id");
result = request.put_u8(NAN_REQ_ATTR_DATA_INTERFACE_NAME_LEN, IFNAMSIZ+1);
@@ -127,9 +138,13 @@ int NanDataCommand::dataIndicationResponse(u16 id, NanDataPathIndicationResponse
CHECK_WIFI_STATUS_RETURN_FAIL(result, "Failed to put req_instance_id");
}
result = putSecurityInfo(msg->cipher_type, &msg->key_info, 0, NULL, &request);
- CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "dataIndicationResponse:Failed to put transaction id");
request.attr_end(data);
+ ALOGD("Send[ndp_instance_id:%d, ndp_iface:%s, security_cfg:%d, qos_cfg:%d, ndp_app_info_len:%d]\n"
+ "[rsp_code:%d, service_len:%d, service:%.*s]\n", msg->ndp_instance_id, msg->ndp_iface, msg->ndp_cfg.security_cfg,
+ msg->ndp_cfg.qos_cfg, msg->app_info.ndp_app_info_len,
+ msg->rsp_code, msg->service_name_len, msg->service_name_len > 20 ? 20 : msg->service_name_len, msg->service_name);
+ wifi_log_hex_buffer_debug("ndp_app_info:", NULL, msg->app_info.ndp_app_info, msg->app_info.ndp_app_info_len);
return result;
}
@@ -138,11 +153,13 @@ int NanDataCommand::dataEnd(u16 id, NanDataPathEndRequest* msg, WifiRequest &req
nlattr *data = newNlVendorMsg(SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_END, request);
if (!data)
return WIFI_ERROR_UNKNOWN;
+ CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "dataEnd:Failed to put transaction id");
+
for(i=0; i<msg->num_ndp_instances; i++) {
result = request.put_u32(NAN_REQ_ATTR_NDP_INSTANCE_ID, msg->ndp_instance_id[i]);
CHECK_WIFI_STATUS_RETURN_FAIL(result, "Failed to put ndp_instance_id");
+ ALOGD("Send[ndp_instance_id:%d]\n", msg->ndp_instance_id[i]);
}
- CHECK_CONFIG_PUT_16_RETURN_FAIL(1, id, NAN_REQ_ATTR_HAL_TRANSACTION_ID, request, result, "dataEnd:Failed to put transaction id");
request.attr_end(data);
return result;
@@ -244,6 +261,12 @@ int NanDataCommand::processNdpReqEvent(WifiEvent &event, NanCallbackHandler &cal
}
}
+ ALOGD("[NAN][NA][NDP_REQ][Ind]:Received[service_instance_id:%d, match_addr:%02x:*:*:*:%02x:%02x, ndp_instance_id:%d, security_cfg:%d]\n"
+ "[qos_cfg:%d, ndp_app_info_len:%d]\n",
+ ind.service_instance_id, ind.peer_disc_mac_addr[0],
+ ind.peer_disc_mac_addr[4], ind.peer_disc_mac_addr[5], ind.ndp_instance_id, ind.ndp_cfg.security_cfg, ind.ndp_cfg.qos_cfg,
+ ind.app_info.ndp_app_info_len);
+ wifi_log_hex_buffer_debug("ndp_app_info:", NULL, ind.app_info.ndp_app_info, ind.app_info.ndp_app_info_len);
if(callbackEventHandler.EventDataRequest)
callbackEventHandler.EventDataRequest(&ind);
return NL_OK;
@@ -280,23 +303,48 @@ int NanDataCommand::processNdpCfmEvent(WifiEvent &event, NanCallbackHandler &cal
break;
}
}
+ ALOGD("[NAN][NA][NDP_CFM][Ind]:Received[ndp_instance_id:%d, match_addr:%02x:*:*:*:%02x:%02x, ndp_app_info_len:%d]\n"
+ "[rsp_code:%d, reason_code:%d]\n", ind.ndp_instance_id, ind.peer_ndi_mac_addr[0],
+ ind.peer_ndi_mac_addr[4], ind.peer_ndi_mac_addr[5], ind.app_info.ndp_app_info_len,
+ ind.rsp_code, ind.reason_code);
+ wifi_log_hex_buffer_debug("ndp_app_info:", NULL, ind.app_info.ndp_app_info, ind.app_info.ndp_app_info_len);
+ if (ind.num_channels >= 1 && ind.num_channels <= NAN_MAX_CHANNEL_INFO_SUPPORTED)
+ ALOGD("Continued..[channel:%d, bandwidth:%d, nss:%d]\n", ind.channel_info[ind.num_channels - 1].channel,
+ ind.channel_info[ind.num_channels - 1].bandwidth, ind.channel_info[ind.num_channels - 1].nss);
if(callbackEventHandler.EventDataConfirm)
callbackEventHandler.EventDataConfirm(&ind);
return NL_OK;
}
int NanDataCommand::processNdpEndEvent(WifiEvent &event, NanCallbackHandler &callbackEventHandler) {
- NanDataPathEndInd ind;
- memset(&ind,0,sizeof(NanDataPathEndInd));
+ NanDataPathEndInd *end_ind;
+ char ndp_list_str[SLSI_NAN_MAX_NDP * 6];
+ int slen = 0;
+
+ end_ind = (NanDataPathEndInd *) malloc(sizeof(*end_ind) + (SLSI_NAN_MAX_NDP * sizeof(NanDataPathId)));
+ if (!end_ind) {
+ ALOGE("Could not allocate end_ind");
+ return WIFI_ERROR_UNKNOWN;
+ }
+ memset(end_ind,0,(sizeof(NanDataPathEndInd) + (SLSI_NAN_MAX_NDP * sizeof(NanDataPathId))));
nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA);
+ memset(ndp_list_str, '\0', sizeof(ndp_list_str));
for(nl_iterator nl_itr(vendor_data); nl_itr.has_next(); nl_itr.next()) {
if (nl_itr.get_type() == NAN_EVT_ATTR_NDP_INSTANCE_ID) {
- ind.ndp_instance_id[ind.num_ndp_instances++] = nl_itr.get_u32();
+ end_ind->ndp_instance_id[end_ind->num_ndp_instances] = nl_itr.get_u32();
+ end_ind->num_ndp_instances++;
+ slen = snprintf(ndp_list_str + slen, SLSI_NAN_MAX_NDP * 6 - slen, "%d ",
+ end_ind->ndp_instance_id[end_ind->num_ndp_instances - 1]);
}
}
+ if (end_ind->num_ndp_instances > 0)
+ ALOGD("[NAN][NA][NDP_END][Ind]:Received[ndp_instance_id:%s]\n", ndp_list_str);
+ else
+ ALOGD("[NAN][NA][NDP_END][Ind]:Received[0 ndp_ids]\n");
if(callbackEventHandler.EventDataEnd)
- callbackEventHandler.EventDataEnd(&ind);
+ callbackEventHandler.EventDataEnd(end_ind);
+ free(end_ind);
return NL_OK;
}
@@ -348,6 +396,8 @@ void NanDataCommand::requestSuccess(u16 id, void *data, int subcmd) {
int NanDataCommand::handleEvent(WifiEvent &event, NanCallbackHandler &callbackEventHandler) {
int subcmd = event.get_vendor_subcmd();
+ int id = event.get_vendor_id();
+
switch (subcmd) {
case SLSI_NAN_EVENT_NDP_REQ:
return processNdpReqEvent(event, callbackEventHandler);
@@ -356,6 +406,7 @@ int NanDataCommand::handleEvent(WifiEvent &event, NanCallbackHandler &callbackEv
case SLSI_NAN_EVENT_NDP_END:
return processNdpEndEvent(event, callbackEventHandler);
default:
+ ALOGI("NAN %s, Id = 0x%x, subcmd = Unknown Event(0x%x)", __func__, id, subcmd);
return NL_OK;
}
}
@@ -393,21 +444,27 @@ int NanDataCommand::putSecurityInfo(u32 cipher, NanSecurityKeyInfo *key_info, u3
result = request->put(NAN_REQ_ATTR_SCID, scid, scid_len);
CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put scid");
}
+ if (key_info->key_type == NAN_SECURITY_KEY_INPUT_PMK)
+ ALOGD("Continued...Send[cipher:%d, keyType:PMK, pmk_len:%d, scid_len:%d, scid:%.*s]\n", cipher, key_info->body.pmk_info.pmk_len,
+ scid_len, scid_len > 20 ? 20 : scid_len, scid);
+ else
+ ALOGD("Continued...Send[cipher:%d, keyType:Passphrase, Passphrase_len:%d, scid_len:%d, scid:%.*s]\n", cipher,
+ key_info->body.passphrase_info.passphrase_len, scid_len, scid_len > 20 ? 20 : scid_len, scid);
return result;
}
const u8 *NanDataCommand::getCmdName(int cmd){
switch(cmd) {
case SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_INTERFACE_CREATE:
- return (const u8 *)"SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_INTERFACE_CREATE";
+ return (const u8 *)"IFCREATE";
case SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_INTERFACE_DELETE:
- return (const u8 *)"SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_INTERFACE_DELETE";
+ return (const u8 *)"IFDELETE";
case SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_REQUEST_INITIATOR:
- return (const u8 *)"SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_REQUEST_INITIATOR";
+ return (const u8 *)"NDP_INITIATOR";
case SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_INDICATION_RESPONSE:
- return (const u8 *)"SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_INDICATION_RESPONSE";
+ return (const u8 *)"NDP_RESPONDER";
case SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_END:
- return (const u8 *)"SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_END";
+ return (const u8 *)"NDP_END";
default:
return (const u8 *)"UNKNOWN CMD";
}
diff --git a/wifi_offload.cpp b/wifi_offload.cpp
index f20ce46..2b87ba1 100755
--- a/wifi_offload.cpp
+++ b/wifi_offload.cpp
@@ -20,19 +20,20 @@
#define LOG_TAG "WifiHAL[offload]"
-#include <utils/Log.h>
+#include <log/log.h>
#include "wifi_hal.h"
#include "common.h"
#include "cpp_bindings.h"
typedef enum {
- MKEEP_ALIVE_ATTRIBUTE_ID,
+ MKEEP_ALIVE_ATTRIBUTE_ID = WIFI_HAL_ATTR_START,
MKEEP_ALIVE_ATTRIBUTE_IP_PKT,
MKEEP_ALIVE_ATTRIBUTE_IP_PKT_LEN,
MKEEP_ALIVE_ATTRIBUTE_SRC_MAC_ADDR,
MKEEP_ALIVE_ATTRIBUTE_DST_MAC_ADDR,
- MKEEP_ALIVE_ATTRIBUTE_PERIOD_MSEC
+ MKEEP_ALIVE_ATTRIBUTE_PERIOD_MSEC,
+ MKEEP_ALIVE_ATTRIBUTE_MAX
} WIFI_MKEEP_ALIVE_ATTRIBUTE;
typedef enum {