[APR-1563][9610][7885] wlbt: NAN R2 Discovery changes
[GitHub/MotorolaMobilityLLC/hardware-samsung_slsi-scsc_wifibt-wifi_hal.git] / wifi_nan.cpp
index 4c1a2080879e21bc612d3bfec5917d195014b74e..deca61fe152cb661d759359be0543a2abf62be83 100755 (executable)
@@ -178,25 +178,54 @@ typedef enum {
     NAN_REQ_ATTR_FOLLOWUP_SERVICE_NAME,
     NAN_REQ_ATTR_FOLLOWUP_TX_WINDOW,
     NAN_REQ_ATTR_FOLLOWUP_RECV_IND_CFG,
+    NAN_REQ_ATTR_SUBSCRIBE_SID_BEACON_VAL,
+    NAN_REQ_ATTR_DW_2G4_INTERVAL,
+    NAN_REQ_ATTR_DW_5G_INTERVAL,
+    NAN_REQ_ATTR_DISC_MAC_ADDR_RANDOM_INTERVAL,
+    NAN_REQ_ATTR_PUBLISH_SDEA_LEN,
+    NAN_REQ_ATTR_PUBLISH_SDEA,
+
+    NAN_REQ_ATTR_RANGING_AUTO_RESPONSE,
+    NAN_REQ_ATTR_SDEA_PARAM_NDP_TYPE,
+    NAN_REQ_ATTR_SDEA_PARAM_SECURITY_CFG,
+    NAN_REQ_ATTR_SDEA_PARAM_RANGING_STATE,
+    NAN_REQ_ATTR_SDEA_PARAM_RANGE_REPORT,
+    NAN_REQ_ATTR_SDEA_PARAM_QOS_CFG,
+    NAN_REQ_ATTR_RANGING_CFG_INTERVAL,
+    NAN_REQ_ATTR_RANGING_CFG_INDICATION,
+    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,
+    NAN_REQ_ATTR_SECURITY_KEY_TYPE,
+    NAN_REQ_ATTR_SECURITY_PMK_LEN,
+    NAN_REQ_ATTR_SECURITY_PMK,
+    NAN_REQ_ATTR_SECURITY_PASSPHRASE_LEN,
+    NAN_REQ_ATTR_SECURITY_PASSPHRASE,
+    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_ATTRIBUTES;
 
 typedef enum {
-       NAN_REPLY_ATTR_STATUS_TYPE,
-       NAN_REPLY_ATTR_VALUE,
-       NAN_REPLY_ATTR_RESPONSE_TYPE,
-       NAN_REPLY_ATTR_PUBLISH_SUBSCRIBE_TYPE,
-       NAN_REPLY_ATTR_CAP_MAX_CONCURRENT_CLUSTER,
-       NAN_REPLY_ATTR_CAP_MAX_PUBLISHES,
-       NAN_REPLY_ATTR_CAP_MAX_SUBSCRIBES,
-       NAN_REPLY_ATTR_CAP_MAX_SERVICE_NAME_LEN,
-       NAN_REPLY_ATTR_CAP_MAX_MATCH_FILTER_LEN,
-       NAN_REPLY_ATTR_CAP_MAX_TOTAL_MATCH_FILTER_LEN,
-       NAN_REPLY_ATTR_CAP_MAX_SERVICE_SPECIFIC_INFO_LEN,
-       NAN_REPLY_ATTR_CAP_MAX_VSA_DATA_LEN,
-       NAN_REPLY_ATTR_CAP_MAX_MESH_DATA_LEN,
-       NAN_REPLY_ATTR_CAP_MAX_NDI_INTERFACES,
-       NAN_REPLY_ATTR_CAP_MAX_NDP_SESSIONS,
-       NAN_REPLY_ATTR_CAP_MAX_APP_INFO_LEN,
+    NAN_REPLY_ATTR_STATUS_TYPE,
+    NAN_REPLY_ATTR_VALUE,
+    NAN_REPLY_ATTR_RESPONSE_TYPE,
+    NAN_REPLY_ATTR_PUBLISH_SUBSCRIBE_TYPE,
+    NAN_REPLY_ATTR_CAP_MAX_CONCURRENT_CLUSTER,
+    NAN_REPLY_ATTR_CAP_MAX_PUBLISHES,
+    NAN_REPLY_ATTR_CAP_MAX_SUBSCRIBES,
+    NAN_REPLY_ATTR_CAP_MAX_SERVICE_NAME_LEN,
+    NAN_REPLY_ATTR_CAP_MAX_MATCH_FILTER_LEN,
+    NAN_REPLY_ATTR_CAP_MAX_TOTAL_MATCH_FILTER_LEN,
+    NAN_REPLY_ATTR_CAP_MAX_SERVICE_SPECIFIC_INFO_LEN,
+    NAN_REPLY_ATTR_CAP_MAX_VSA_DATA_LEN,
+    NAN_REPLY_ATTR_CAP_MAX_MESH_DATA_LEN,
+    NAN_REPLY_ATTR_CAP_MAX_NDI_INTERFACES,
+    NAN_REPLY_ATTR_CAP_MAX_NDP_SESSIONS,
+    NAN_REPLY_ATTR_CAP_MAX_APP_INFO_LEN,
 } NAN_RESP_ATTRIBUTES;
 
 typedef enum {
@@ -252,10 +281,21 @@ typedef enum {
     NAN_EVT_ATTR_FOLLOWUP_DW_OR_FAW,
     NAN_EVT_ATTR_FOLLOWUP_SERVICE_SPECIFIC_INFO_LEN,
     NAN_EVT_ATTR_FOLLOWUP_SERVICE_SPECIFIC_INFO,
-    NAN_EVT_ATTR_DISCOVERY_ENGINE_EVT_TYPE     ,
+    NAN_EVT_ATTR_DISCOVERY_ENGINE_EVT_TYPE    ,
     NAN_EVT_ATTR_DISCOVERY_ENGINE_MAC_ADDR,
-    NAN_EVT_ATTR_DISCOVERY_ENGINE_CLUSTER
-
+    NAN_EVT_ATTR_DISCOVERY_ENGINE_CLUSTER,
+    NAN_EVT_ATTR_SDEA,
+    NAN_EVT_ATTR_SDEA_LEN,
+    NAN_EVT_ATTR_SCID,
+    NAN_EVT_ATTR_SCID_LEN,
+    NAN_EVT_ATTR_SDEA_PARAM_CONFIG_NAN_DATA_PATH,
+    NAN_EVT_ATTR_SDEA_PARAM_NDP_TYPE,
+    NAN_EVT_ATTR_SDEA_PARAM_SECURITY_CONFIG,
+    NAN_EVT_ATTR_SDEA_PARAM_RANGE_STATE,
+    NAN_EVT_ATTR_SDEA_PARAM_RANGE_REPORT,
+    NAN_EVT_ATTR_SDEA_PARAM_QOS_CFG,
+    NAN_EVT_ATTR_RANGE_MEASUREMENT_MM,
+    NAN_EVT_ATTR_RANGEING_EVENT_TYPE
 } NAN_EVT_ATTRIBUTES;
 
 class NanCommand : public WifiCommand {
@@ -287,7 +327,6 @@ class NanCommand : public WifiCommand {
     int processResponse(WifiEvent &reply, NanResponseMsg *response) {
         NanCapabilities *capabilities = &response->body.nan_capabilities;
         nlattr *vendor_data = reply.get_attribute(NL80211_ATTR_VENDOR_DATA);
-        //int len = reply.get_vendor_data_len();
         unsigned int val;
 
         for(nl_iterator nl_itr(vendor_data); nl_itr.has_next(); nl_itr.next()) {
@@ -476,15 +515,52 @@ class NanCommand : public WifiCommand {
                         break;
                     }
                 }
+                break;
             case NAN_EVT_ATTR_MATCH_CLUSTER_ATTRIBUTE_LEN:
                 ind.cluster_attribute_len = nl_itr.get_u8();
                 break;
             case NAN_EVT_ATTR_MATCH_CLUSTER_ATTRIBUTE:
                 memcpy(ind.cluster_attribute, nl_itr.get_data(), ind.cluster_attribute_len);
                 break;
+            case NAN_EVT_ATTR_SDEA_LEN:
+                ind.sdea_service_specific_info_len = nl_itr.get_u16();
+                break;
+            case NAN_EVT_ATTR_SDEA:
+                memcpy(ind.sdea_service_specific_info, nl_itr.get_data(), ind.sdea_service_specific_info_len);
+                break;
+            case NAN_EVT_ATTR_SCID_LEN:
+                ind.scid_len = nl_itr.get_u32();
+                break;
+            case NAN_EVT_ATTR_SCID:
+                memcpy(ind.scid, nl_itr.get_data(), ind.scid_len);
+                break;
+            case NAN_EVT_ATTR_SDEA_PARAM_CONFIG_NAN_DATA_PATH:
+                ind.peer_sdea_params.config_nan_data_path = nl_itr.get_u8();
+                break;
+            case NAN_EVT_ATTR_SDEA_PARAM_NDP_TYPE:
+                ind.peer_sdea_params.ndp_type = (NdpType)nl_itr.get_u8();
+                break;
+            case NAN_EVT_ATTR_SDEA_PARAM_SECURITY_CONFIG:
+                ind.peer_sdea_params.security_cfg = (NanDataPathSecurityCfgStatus)nl_itr.get_u8();
+                break;
+            case NAN_EVT_ATTR_SDEA_PARAM_RANGE_STATE:
+                ind.peer_sdea_params.ranging_state = (NanRangingState)nl_itr.get_u8();
+                break;
+            case NAN_EVT_ATTR_SDEA_PARAM_RANGE_REPORT:
+                ind.peer_sdea_params.range_report = (NanRangeReport)nl_itr.get_u8();
+                break;
+            case NAN_EVT_ATTR_SDEA_PARAM_QOS_CFG:
+                ind.peer_sdea_params.qos_cfg = (NanQosCfgStatus)nl_itr.get_u8();
+                break;
+            case NAN_EVT_ATTR_RANGE_MEASUREMENT_MM:
+                ind.range_info.range_measurement_mm = nl_itr.get_u32();
+                break;
+            case NAN_EVT_ATTR_RANGEING_EVENT_TYPE:
+                ind.range_info.ranging_event_type = nl_itr.get_u32();
+                break;
             }
         }
-        
+
         if (this->callbackEventHandler.EventMatch)
             this->callbackEventHandler.EventMatch(&ind);
         return NL_OK;
@@ -565,9 +641,10 @@ class NanCommand : public WifiCommand {
 
     int processFollowupEvent(WifiEvent &event) {
         NanFollowupInd ind;
+        nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA);
         memset(&ind,0,sizeof(ind));
 
-        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_FOLLOWUP_PUBLISH_SUBSCRIBE_ID:
                 ind.publish_subscribe_id = nl_itr.get_u16();
@@ -587,6 +664,12 @@ class NanCommand : public WifiCommand {
             case NAN_EVT_ATTR_FOLLOWUP_SERVICE_SPECIFIC_INFO:
                 memcpy(ind.service_specific_info, nl_itr.get_data(), ind.service_specific_info_len);
                 break;
+            case NAN_EVT_ATTR_SDEA_LEN:
+                ind.sdea_service_specific_info_len = nl_itr.get_u16();
+                break;
+            case NAN_EVT_ATTR_SDEA:
+                memcpy(ind.sdea_service_specific_info, nl_itr.get_data(), ind.sdea_service_specific_info_len);
+                break;
             default :
                 ALOGE("processNanDisabledEvent: unknown attribute(%d)", nl_itr.get_type());
                 return NL_SKIP;
@@ -602,8 +685,8 @@ class NanCommand : public WifiCommand {
     int processNanDisabledEvent(WifiEvent &event) {
         NanDisabledInd ind;
         memset(&ind,0,sizeof(ind));
-
-        for(nl_iterator nl_itr((struct nlattr *)event.get_vendor_data()); nl_itr.has_next(); nl_itr.next()) {
+        nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA);
+        for(nl_iterator nl_itr(vendor_data); nl_itr.has_next(); nl_itr.next()) {
             switch(nl_itr.get_type()) {
             case NAN_EVT_ATTR_DISABLED_REASON:
                 ind.reason = (NanStatusType)nl_itr.get_u32();
@@ -624,8 +707,8 @@ class NanCommand : public WifiCommand {
         NanDiscEngEventInd ind;
         memset(&ind,0,sizeof(ind));
         u8 *addr = NULL;
-
-        for(nl_iterator nl_itr((struct nlattr *)event.get_vendor_data()); nl_itr.has_next(); nl_itr.next()) {
+        nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA);
+        for(nl_iterator nl_itr(vendor_data); nl_itr.has_next(); nl_itr.next()) {
             switch(nl_itr.get_type()) {
             case NAN_EVT_ATTR_DISCOVERY_ENGINE_EVT_TYPE:
                 ind.event_type = (NanDiscEngEventType)nl_itr.get_u16();
@@ -653,6 +736,101 @@ class NanCommand : public WifiCommand {
         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");
+
+        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");
+
+        result = request->put_u8(NAN_REQ_ATTR_SDEA_PARAM_RANGE_REPORT, sdea_params->range_report);
+        CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put SDEA PARAM range_report");
+
+        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");
+
+        return result;
+    }
+
+    int putRangingCfg(NanRangingCfg *ranging_cfg, WifiRequest *request)
+    {
+        int result;
+
+        result = request->put_u32(NAN_REQ_ATTR_RANGING_CFG_INTERVAL, ranging_cfg->ranging_interval_msec);
+        CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put Ranging CFG ranging_interval_msec");
+
+        result = request->put_u32(NAN_REQ_ATTR_RANGING_CFG_INDICATION, ranging_cfg->config_ranging_indications);
+        CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put Ranging CFG config_ranging_indications");
+
+        result = request->put_u32(NAN_REQ_ATTR_RANGING_CFG_INGRESS_MM, ranging_cfg->distance_ingress_mm);
+        CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put Ranging CFG distance_ingress_mm");
+
+        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");
+
+        return result;
+    }
+
+    int putRangeResponseCfg(NanRangeResponseCfg *range_resp_cfg, WifiRequest *request)
+    {
+        int result;
+
+        result = request->put_u16(NAN_REQ_ATTR_RANGE_RESPONSE_CFG_PUBLISH_ID, range_resp_cfg->publish_id);
+        CHECK_WIFI_STATUS_RETURN_FAIL(result, "Failed to put range response cfg::publish_id");
+
+        result = request->put_u32(NAN_REQ_ATTR_RANGE_RESPONSE_CFG_REQUESTOR_ID, range_resp_cfg->requestor_instance_id);
+        CHECK_WIFI_STATUS_RETURN_FAIL(result, "Failed to put range response cfg::requestor_instance_id");
+
+        result = request->put_addr(NAN_REQ_ATTR_RANGE_RESPONSE_CFG_PEER_ADDR, range_resp_cfg->peer_addr);
+        CHECK_WIFI_STATUS_RETURN_FAIL(result, "Failed to put range response cfg::peer_addr");
+
+        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");
+
+        return result;
+    }
+
+    int putSecurityInfo(u32 cipher, NanSecurityKeyInfo *key_info, u32 scid_len, u8 *scid, WifiRequest *request)
+    {
+        int result;
+
+        result = request->put_u32(NAN_REQ_ATTR_CIPHER_TYPE, cipher);
+        CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put cipher_type");
+
+        result = request->put_u32(NAN_REQ_ATTR_SECURITY_KEY_TYPE, key_info->key_type);
+        CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put cipher_type");
+
+        if (key_info->key_type == NAN_SECURITY_KEY_INPUT_PMK) {
+            result = request->put_u32(NAN_REQ_ATTR_SECURITY_PMK_LEN, key_info->body.pmk_info.pmk_len);
+            CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put key_info->body.pmk_info.pmk_len");
+            result = request->put(NAN_REQ_ATTR_SECURITY_PMK, key_info->body.pmk_info.pmk, key_info->body.pmk_info.pmk_len);
+            CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put key_info->body.pmk_info.pmk");
+        } else {
+            result = request->put_u32(NAN_REQ_ATTR_SECURITY_PASSPHRASE_LEN, key_info->body.passphrase_info.passphrase_len);
+            CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put key_info->body.passphrase_info.passphrase_len");
+            result = request->put(NAN_REQ_ATTR_SECURITY_PASSPHRASE, key_info->body.passphrase_info.passphrase,
+                                key_info->body.passphrase_info.passphrase_len);
+            CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put key_info->body.passphrase_info.passphrase");
+        }
+
+        result = request->put_u32(NAN_REQ_ATTR_SCID_LEN, scid_len);
+        CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put scid_len");
+        if (scid_len) {
+            result = request->put(NAN_REQ_ATTR_SCID, scid, scid_len);
+            CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put scid");
+        }
+        return result;
+    }
+
 public:
     NanCommand(wifi_interface_handle iface, int id)
         : WifiCommand(iface, id)
@@ -679,7 +857,15 @@ public:
             ALOGE("enable: request.attr_start fail");
             return WIFI_ERROR_OUT_OF_MEMORY;
         }
-        result = request.put_u8(NAN_REQ_ATTR_MASTER_PREF, msg->master_pref);
+        /* Valid master pref values are 2-254 */
+        int master_pref;
+        if (msg->master_pref < 2)
+            master_pref = 2;
+        else if (msg->master_pref > 254)
+            master_pref = 254;
+        else
+            master_pref = msg->master_pref;
+        result = request.put_u8(NAN_REQ_ATTR_MASTER_PREF, master_pref);
         CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put master_pref");
 
         result = request.put_u16(NAN_REQ_ATTR_CLUSTER_LOW, msg->cluster_low);
@@ -760,6 +946,18 @@ public:
         CHECK_CONFIG_PUT_32_RETURN_FAIL(msg->config_5g_channel, msg->channel_5g_val,
                     NAN_REQ_ATTR_CHANNEL_5G_MHZ_VAL, request, result, "enable:Failed to put channel_5g_val");
 
+        CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_subscribe_sid_beacon, msg->subscribe_sid_beacon_val,
+                    NAN_REQ_ATTR_SUBSCRIBE_SID_BEACON_VAL, request, result, "enable:Failed to put subscribe_sid_beacon_val");
+
+        CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_dw.config_2dot4g_dw_band, msg->config_dw.dw_2dot4g_interval_val,
+                    NAN_REQ_ATTR_DW_2G4_INTERVAL, request, result, "enable:Failed to put dw_2dot4g_interval_val");
+
+        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->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");
+
         request.attr_end(data);
 
         registerNanEvents();
@@ -789,7 +987,7 @@ public:
     }
 
     int config(NanConfigRequest *msg) {
-        ALOGD("config...");
+        ALOGD("NAN config...");
         WifiRequest request(familyId(), ifaceId());
 
         int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_CONFIG);
@@ -902,12 +1100,24 @@ public:
             }
         }
 
+        CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_subscribe_sid_beacon, msg->subscribe_sid_beacon_val,
+                    NAN_REQ_ATTR_SUBSCRIBE_SID_BEACON_VAL, request, result, "config:Failed to put subscribe_sid_beacon_val");
+
+        CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_dw.config_2dot4g_dw_band, msg->config_dw.dw_2dot4g_interval_val,
+                    NAN_REQ_ATTR_DW_2G4_INTERVAL, request, result, "config:Failed to put dw_2dot4g_interval_val");
+
+        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,
+                    NAN_REQ_ATTR_DISC_MAC_ADDR_RANDOM_INTERVAL, request, result, "config:Failed to put disc_mac_addr_rand_interval_sec");
+
         request.attr_end(data);
         result = requestResponse(request);
         if (result != WIFI_SUCCESS) {
             ALOGE("failed to set_config; result = %d", result);
         } else {
-            ALOGD("config...success");
+            ALOGD("NAN config...success");
         }
         return result;
     }
@@ -923,7 +1133,7 @@ public:
     }
 
     int publish(NanPublishRequest *msg) {
-        ALOGD("publish...");
+        ALOGD("NAN publish...");
         WifiRequest request(familyId(), ifaceId());
 
         int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_PUBLISH);
@@ -989,18 +1199,40 @@ public:
         CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->recv_indication_cfg,
                 NAN_REQ_ATTR_PUBLISH_RECV_IND_CFG, request, result, "publish:Failed to put msg->recv_indication_cfg");
 
+        CHECK_CONFIG_PUT_16_RETURN_FAIL(1, msg->sdea_service_specific_info_len,
+                NAN_REQ_ATTR_PUBLISH_SDEA_LEN, request, result, "publish:Failed to put msg->sdea_service_specific_info_len");
+
+        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");
+
+        result = request.put_u8(NAN_REQ_ATTR_RANGING_AUTO_RESPONSE, msg->ranging_auto_response);
+        CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put ranging_auto_response");
+
+        result = putSdeaParams(&msg->sdea_params, &request);
+        if (result != 0)
+            return result;
+        result = putRangingCfg(&msg->ranging_cfg, &request);
+        if (result != 0)
+            return result;
+        result = putSecurityInfo(msg->cipher_type, &msg->key_info, msg->scid_len, msg->scid, &request);
+        if (result != 0)
+            return result;
+        result = putRangeResponseCfg(&msg->range_response_cfg, &request);
+        if (result != 0)
+            return result;
+
         request.attr_end(data);
         result = requestResponse(request);
         if (result != WIFI_SUCCESS) {
             ALOGE("failed to publish; result = %d", result);
         } else {
-            ALOGD("publish...success");
+            ALOGD("NAN publish...success");
         }
         return result;
     }
 
     int publishCancel(NanPublishCancelRequest *msg) {
-        ALOGD("publishCancel...");
+        ALOGD("NAN publishCancel...");
         WifiRequest request(familyId(), ifaceId());
 
         int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_PUBLISHCANCEL);
@@ -1020,14 +1252,14 @@ public:
         if (result != WIFI_SUCCESS) {
             ALOGE("failed to publishCancel; result = %d", result);
         } else {
-            ALOGD("publishCancel...success");
+            ALOGD("NAN publishCancel...success");
         }
         return result;
 
     }
 
     int subscribe(NanSubscribeRequest *msg) {
-        ALOGD("subscribe...");
+        ALOGD("NAN subscribe...");
         WifiRequest request(familyId(), ifaceId());
 
         int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_SUBSCRIBE);
@@ -1108,19 +1340,41 @@ public:
         CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->recv_indication_cfg,
                 NAN_REQ_ATTR_SUBSCRIBE_RECV_IND_CFG, request, result, "subscribe:Failed to put msg->recv_indication_cfg");
 
+        CHECK_CONFIG_PUT_16_RETURN_FAIL(1, msg->sdea_service_specific_info_len,
+                NAN_REQ_ATTR_PUBLISH_SDEA_LEN, request, result, "subscribe:Failed to put msg->sdea_service_specific_info_len");
+
+        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, "subscribe:Failed to put msg->sdea_service_specific_info");
+
+        result = request.put_u8(NAN_REQ_ATTR_RANGING_AUTO_RESPONSE, msg->ranging_auto_response);
+        CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put ranging_auto_response");
+
+        result = putSdeaParams(&msg->sdea_params, &request);
+        if (result != 0)
+            return result;
+        result = putRangingCfg(&msg->ranging_cfg, &request);
+        if (result != 0)
+            return result;
+        result = putSecurityInfo(msg->cipher_type, &msg->key_info, msg->scid_len, msg->scid, &request);
+        if (result != 0)
+            return result;
+        result = putRangeResponseCfg(&msg->range_response_cfg, &request);
+        if (result != 0)
+            return result;
+
         request.attr_end(data);
         result = requestResponse(request);
         if (result != WIFI_SUCCESS) {
             ALOGE("failed to subscribe; result = %d", result);
         } else {
-            ALOGD("subscribe...success");
+            ALOGD("NAN subscribe...success");
         }
         return result;
 
     }
 
     int subscribeCancel(NanSubscribeCancelRequest *msg) {
-        ALOGD("subscribeCancel...");
+        ALOGD("NAN subscribeCancel...");
         WifiRequest request(familyId(), ifaceId());
 
         int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_SUBSCRIBECANCEL);
@@ -1140,13 +1394,13 @@ public:
         if (result != WIFI_SUCCESS) {
             ALOGE("failed to subscribeCancel; result = %d", result);
         } else {
-            ALOGD("subscribeCancel...success");
+            ALOGD("NAN subscribeCancel...success");
         }
         return result;
     }
 
     int followup(NanTransmitFollowupRequest *msg) {
-        ALOGD("followup...");
+        ALOGD("NAN followup...");
         WifiRequest request(familyId(), ifaceId());
 
         int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_TXFOLLOWUP);
@@ -1182,19 +1436,25 @@ public:
         CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->recv_indication_cfg,
             NAN_REQ_ATTR_FOLLOWUP_RECV_IND_CFG, request, result, "followup:Failed to put msg->recv_indication_cfg");
 
+        CHECK_CONFIG_PUT_16_RETURN_FAIL(1, msg->sdea_service_specific_info_len,
+                NAN_REQ_ATTR_PUBLISH_SDEA_LEN, request, result, "publish:Failed to put msg->sdea_service_specific_info_len");
+
+        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");
+
         request.attr_end(data);
         result = requestResponse(request);
         if (result != WIFI_SUCCESS) {
             ALOGE("failed to followup; result = %d", result);
         } else {
-            ALOGD("followup...success");
+            ALOGD("NAN followup...success");
         }
         return result;
 
     }
 
     int getCapabilities(void) {
-        ALOGD("getCapabilities...");
+        ALOGD("NAN getCapabilities...");
         WifiRequest request(familyId(), ifaceId());
 
         int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_CAPABILITIES);
@@ -1204,14 +1464,14 @@ public:
         if (result != WIFI_SUCCESS) {
             ALOGE("failed to getCapabilities; result = %d", result);
         } else {
-            ALOGD("getCapabilities...success");
+            ALOGD("NAN getCapabilities...success");
         }
         return result;
     }
 
     int handleEvent(WifiEvent &event) {
         int ret;
-        ALOGD("handleEvent...");
+        ALOGD("NAN handleEvent...");
 
         if (event.get_cmd() != NL80211_CMD_VENDOR) {
             ALOGD("Ignoring event with cmd = %d", event.get_cmd());
@@ -1252,18 +1512,13 @@ public:
     }
 
     int handleResponse(WifiEvent &reply) {
-        ALOGD("handleResponse...");
+        ALOGD("NAN handleResponse...");
 
         if (reply.get_cmd() != NL80211_CMD_VENDOR) {
             ALOGD("Ignoring reply with cmd = %d", reply.get_cmd());
             return NL_SKIP;
         }
 
-        int vendorId = reply.get_vendor_id();
-        int subcmd = reply.get_vendor_subcmd();
-
-        ALOGI("Id = %0x, subcmd = %d", vendorId, subcmd);
-
         NanResponseMsg response;
         memset(&response, 0, sizeof(response));