[APR-2987]wlbt: NAN R2 fix NDP terminate
[GitHub/MotorolaMobilityLLC/hardware-samsung_slsi-scsc_wifibt-wifi_hal.git] / wifi_nan_data_path.cpp
index de4686a607316867b278268d2c9f3ae90cb85ee1..a5a31bf4b7b277d754a6ccbd7d5b3d5ca01c4945 100755 (executable)
@@ -132,11 +132,11 @@ int NanDataCommand::dataEnd(NanDataPathEndRequest* msg, WifiRequest &request) {
     nlattr *data = newNlVendorMsg(SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_END, request);
     if (!data)
         return WIFI_ERROR_UNKNOWN;
-
-    for(i=0; i<SLSI_NAN_MAX_NDP; i++) {
+    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");
     }
+
     request.attr_end(data);
     return result;
 }
@@ -302,19 +302,25 @@ NanDataCommand::NanDataCommand() {
     memset(transaction_id, 0, sizeof(transaction_id));
 }
 
-int NanDataCommand::getDataPathNLMsg(void *data, int subcmd, WifiRequest &request) {
+int NanDataCommand::getDataPathNLMsg(u16 id, void *data, int subcmd, WifiRequest &request) {
     switch (subcmd) {
     case SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_INTERFACE_CREATE:
+        transaction_id[idx_iface_create] = id;
+        return dataInterfaceCreateDelete((char *)data, subcmd, request);
     case SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_INTERFACE_DELETE:
+        transaction_id[idx_iface_delete] = id;
         return dataInterfaceCreateDelete((char *)data, subcmd, request);
     case SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_REQUEST_INITIATOR:
+        transaction_id[idx_ndp_initiator] = id;
         return dataRequestInitiate((NanDataPathInitiatorRequest *)data, request);
     case SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_INDICATION_RESPONSE:
+        transaction_id[idx_ndp_responder] = id;
         return dataIndicationResponse((NanDataPathIndicationResponse *)data, request);
     case SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_END:
+        transaction_id[idx_ndp_end] = id;
         return dataEnd((NanDataPathEndRequest *)data, request);
     default:
-        ALOGE("unknown subcmd :%d", subcmd);
+        ALOGE("unknown subcmd :0x%x", subcmd);
     }
     return WIFI_ERROR_UNKNOWN;
 }
@@ -322,23 +328,18 @@ int NanDataCommand::getDataPathNLMsg(void *data, int subcmd, WifiRequest &reques
 void NanDataCommand::requestSuccess(u16 id, void *data, int subcmd) {
     switch (subcmd) {
     case SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_INTERFACE_CREATE:
-        transaction_id[idx_iface_create] = id;
         dataInterfaceCreated((char *)data);
         break;
     case SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_INTERFACE_DELETE:
-        transaction_id[idx_iface_delete] = id;
         dataInterfaceDeleted((char *)data);
         break;
     case SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_REQUEST_INITIATOR:
-        transaction_id[idx_ndp_initiator] = id;
         dataRequestInitiateSuccess((NanDataPathInitiatorRequest *)data);
         break;
     case SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_INDICATION_RESPONSE:
-        transaction_id[idx_ndp_responder] = id;
         dataIndicationResponseSuccess((NanDataPathIndicationResponse *)data);
         break;
     case SLSI_NL80211_VENDOR_SUBCMD_NAN_DATA_END:
-        transaction_id[idx_ndp_end] = id;
         dataEndSuccess((NanDataPathEndRequest *)data);
         break;
     }