summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmarnath Hullur Subramanyam <amarnath@codeaurora.org>2014-12-10 07:12:07 -0800
committerAmarnath Hullur Subramanyam <amarnath@codeaurora.org>2014-12-15 10:21:49 -0800
commit5f275940ebff858c4077c955dcbd564634f6cb96 (patch)
tree9519bae83a83da931b5a7011958de2519be6c024
parent4ed262a2076a1c4573984d8fa944916c1a572400 (diff)
downloadandroid_hardware_qcom_wlan-5f275940ebff858c4077c955dcbd564634f6cb96.tar.gz
android_hardware_qcom_wlan-5f275940ebff858c4077c955dcbd564634f6cb96.tar.bz2
android_hardware_qcom_wlan-5f275940ebff858c4077c955dcbd564634f6cb96.zip
Adding support for passing userdata in nan_register_handler
This commit is to enhance nan_register_handler to accept a userdata pointer which will be returned back as part of the nan response or nan event. This can be used by the upper layer to pass a context or object pointer which it can get back when the callback from nan is called Change-Id: I572a3f094226f4f5fd77530745451d65c20a892b CRs-Fixed: 769281
-rw-r--r--qcwcn/wifi_hal/nan.cpp10
-rw-r--r--qcwcn/wifi_hal/nan.h36
-rw-r--r--qcwcn/wifi_hal/nan_ind.cpp28
-rw-r--r--qcwcn/wifi_hal/nan_rsp.cpp2
-rw-r--r--qcwcn/wifi_hal/nancommand.h4
5 files changed, 53 insertions, 27 deletions
diff --git a/qcwcn/wifi_hal/nan.cpp b/qcwcn/wifi_hal/nan.cpp
index 9cfa779..944d6f1 100644
--- a/qcwcn/wifi_hal/nan.cpp
+++ b/qcwcn/wifi_hal/nan.cpp
@@ -38,7 +38,8 @@ NanCommand* NanCommand::mNanCommandInstance = NULL;
//Implementation of the functions exposed in nan.h
wifi_error nan_register_handler(wifi_handle handle,
- NanCallbackHandler handlers)
+ NanCallbackHandler handlers,
+ void* userdata)
{
// Obtain the singleton instance
int ret = 0;
@@ -49,7 +50,7 @@ wifi_error nan_register_handler(wifi_handle handle,
ALOGE("%s: Error NanCommand NULL", __func__);
return WIFI_ERROR_UNKNOWN;
}
- ret = nCommand->setCallbackHandler(handlers);
+ ret = nCommand->setCallbackHandler(handlers, userdata);
return (wifi_error)ret;
}
@@ -409,6 +410,7 @@ NanCommand::NanCommand(wifi_handle handle, int id, u32 vendor_id, u32 subcmd)
mNanVendorEvent = NULL;
mNanDataLen = 0;
mStaParam = NULL;
+ mUserData = NULL;
}
NanCommand* NanCommand::instance(wifi_handle handle)
@@ -452,10 +454,12 @@ int NanCommand::handleResponse(WifiEvent reply){
return NL_SKIP;
}
-int NanCommand::setCallbackHandler(NanCallbackHandler nHandler)
+int NanCommand::setCallbackHandler(NanCallbackHandler nHandler,
+ void *pUserData)
{
int res = 0;
mHandler = nHandler;
+ mUserData = pUserData;
res = registerVendorHandler(mVendor_id, mSubcmd);
if (res != 0) {
//error case should not happen print log
diff --git a/qcwcn/wifi_hal/nan.h b/qcwcn/wifi_hal/nan.h
index 324d630..688a8b5 100644
--- a/qcwcn/wifi_hal/nan.h
+++ b/qcwcn/wifi_hal/nan.h
@@ -1667,18 +1667,29 @@ typedef struct {
/* Response and Event Callbacks */
typedef struct {
/* NotifyResponse invoked to notify the status of the Request */
- void (*NotifyResponse)(NanResponseMsg* rsp_data);
+ void (*NotifyResponse)(NanResponseMsg* rsp_data,
+ void* userdata);
/* Various Events Callback */
- void (*EventPublishReplied)(NanPublishRepliedInd* event);
- void (*EventPublishTerminated)(NanPublishTerminatedInd* event);
- void (*EventMatch) (NanMatchInd* event);
- void (*EventUnMatch) (NanUnmatchInd* event);
- void (*EventSubscribeTerminated) (NanSubscribeTerminatedInd* event);
- void (*EventFollowup) (NanFollowupInd* event);
- void (*EventDiscEngEvent) (NanDiscEngEventInd* event);
- void (*EventDisabled) (NanDisabledInd* event);
- void (*EventTca) (NanTCAInd* event);
- void (*EventSdfPayload) (NanBeaconSdfPayloadInd* event);
+ void (*EventPublishReplied)(NanPublishRepliedInd* event,
+ void* userdata);
+ void (*EventPublishTerminated)(NanPublishTerminatedInd* event,
+ void* userdata);
+ void (*EventMatch) (NanMatchInd* event,
+ void* userdata);
+ void (*EventUnMatch) (NanUnmatchInd* event,
+ void* userdata);
+ void (*EventSubscribeTerminated) (NanSubscribeTerminatedInd* event,
+ void* userdata);
+ void (*EventFollowup) (NanFollowupInd* event,
+ void* userdata);
+ void (*EventDiscEngEvent) (NanDiscEngEventInd* event,
+ void* userdata);
+ void (*EventDisabled) (NanDisabledInd* event,
+ void* userdata);
+ void (*EventTca) (NanTCAInd* event,
+ void* userdata);
+ void (*EventSdfPayload) (NanBeaconSdfPayloadInd* event,
+ void* userdata);
} NanCallbackHandler;
@@ -1751,7 +1762,8 @@ wifi_error nan_get_sta_parameter(wifi_request_id id,
/* Function to register NAN callback */
wifi_error nan_register_handler(wifi_handle handle,
- NanCallbackHandler handlers);
+ NanCallbackHandler handlers,
+ void* userdata);
/* Function to get version of the NAN HAL */
wifi_error nan_get_version(wifi_handle handle,
diff --git a/qcwcn/wifi_hal/nan_ind.cpp b/qcwcn/wifi_hal/nan_ind.cpp
index f69e718..41fb0f0 100644
--- a/qcwcn/wifi_hal/nan_ind.cpp
+++ b/qcwcn/wifi_hal/nan_ind.cpp
@@ -42,7 +42,8 @@ int NanCommand::handleNanIndication()
memset(&publishRepliedInd, 0, sizeof(publishRepliedInd));
res = getNanPublishReplied(&publishRepliedInd);
if (!res && mHandler.EventPublishReplied) {
- (*mHandler.EventPublishReplied)(&publishRepliedInd);
+ (*mHandler.EventPublishReplied)(&publishRepliedInd,
+ mUserData);
}
break;
@@ -51,7 +52,8 @@ int NanCommand::handleNanIndication()
memset(&publishTerminatedInd, 0, sizeof(publishTerminatedInd));
res = getNanPublishTerminated(&publishTerminatedInd);
if (!res && mHandler.EventPublishTerminated) {
- (*mHandler.EventPublishTerminated)(&publishTerminatedInd);
+ (*mHandler.EventPublishTerminated)(&publishTerminatedInd,
+ mUserData);
}
break;
@@ -60,7 +62,7 @@ int NanCommand::handleNanIndication()
memset(&matchInd, 0, sizeof(matchInd));
res = getNanMatch(&matchInd);
if (!res && mHandler.EventMatch) {
- (*mHandler.EventMatch)(&matchInd);
+ (*mHandler.EventMatch)(&matchInd, mUserData);
}
break;
@@ -69,7 +71,7 @@ int NanCommand::handleNanIndication()
memset(&unMatchInd, 0, sizeof(unMatchInd));
res = getNanUnMatch(&unMatchInd);
if (!res && mHandler.EventUnMatch) {
- (*mHandler.EventUnMatch)(&unMatchInd);
+ (*mHandler.EventUnMatch)(&unMatchInd, mUserData);
}
break;
@@ -78,7 +80,8 @@ int NanCommand::handleNanIndication()
memset(&subscribeTerminatedInd, 0, sizeof(subscribeTerminatedInd));
res = getNanSubscribeTerminated(&subscribeTerminatedInd);
if (!res && mHandler.EventSubscribeTerminated) {
- (*mHandler.EventSubscribeTerminated)(&subscribeTerminatedInd);
+ (*mHandler.EventSubscribeTerminated)(&subscribeTerminatedInd,
+ mUserData);
}
break;
@@ -87,7 +90,8 @@ int NanCommand::handleNanIndication()
memset(&discEngEventInd, 0, sizeof(discEngEventInd));
res = getNanDiscEngEvent(&discEngEventInd);
if (!res && mHandler.EventDiscEngEvent) {
- (*mHandler.EventDiscEngEvent)(&discEngEventInd);
+ (*mHandler.EventDiscEngEvent)(&discEngEventInd,
+ mUserData);
}
break;
@@ -96,7 +100,8 @@ int NanCommand::handleNanIndication()
memset(&followupInd, 0, sizeof(followupInd));
res = getNanFollowup(&followupInd);
if (!res && mHandler.EventFollowup) {
- (*mHandler.EventFollowup)(&followupInd);
+ (*mHandler.EventFollowup)(&followupInd,
+ mUserData);
}
break;
@@ -105,7 +110,8 @@ int NanCommand::handleNanIndication()
memset(&disabledInd, 0, sizeof(disabledInd));
res = getNanDisabled(&disabledInd);
if (!res && mHandler.EventDisabled) {
- (*mHandler.EventDisabled)(&disabledInd);
+ (*mHandler.EventDisabled)(&disabledInd,
+ mUserData);
}
break;
@@ -114,7 +120,8 @@ int NanCommand::handleNanIndication()
memset(&tcaInd, 0, sizeof(tcaInd));
res = getNanTca(&tcaInd);
if (!res && mHandler.EventTca) {
- (*mHandler.EventTca)(&tcaInd);
+ (*mHandler.EventTca)(&tcaInd,
+ mUserData);
}
break;
@@ -123,7 +130,8 @@ int NanCommand::handleNanIndication()
memset(&beaconSdfPayloadInd, 0, sizeof(beaconSdfPayloadInd));
res = getNanBeaconSdfPayload(&beaconSdfPayloadInd);
if (!res && mHandler.EventSdfPayload) {
- (*mHandler.EventSdfPayload)(&beaconSdfPayloadInd);
+ (*mHandler.EventSdfPayload)(&beaconSdfPayloadInd,
+ mUserData);
}
break;
diff --git a/qcwcn/wifi_hal/nan_rsp.cpp b/qcwcn/wifi_hal/nan_rsp.cpp
index 8dde3d6..4e01edf 100644
--- a/qcwcn/wifi_hal/nan_rsp.cpp
+++ b/qcwcn/wifi_hal/nan_rsp.cpp
@@ -270,7 +270,7 @@ int NanCommand::handleNanResponse()
}
//Call the NotifyResponse Handler
if (ret == 0 && mHandler.NotifyResponse) {
- (*mHandler.NotifyResponse)(&rsp_data);
+ (*mHandler.NotifyResponse)(&rsp_data, mUserData);
}
return ret;
}
diff --git a/qcwcn/wifi_hal/nancommand.h b/qcwcn/wifi_hal/nancommand.h
index a9929bb..dabc115 100644
--- a/qcwcn/wifi_hal/nancommand.h
+++ b/qcwcn/wifi_hal/nancommand.h
@@ -28,6 +28,7 @@ private:
char *mNanVendorEvent;
u32 mNanDataLen;
NanStaParameter *mStaParam;
+ void *mUserData;
//Function to check the initial few bytes of data to
//determine whether NanResponse or NanEvent
@@ -96,7 +97,8 @@ public:
virtual int requestEvent();
virtual int handleResponse(WifiEvent reply);
virtual int handleEvent(WifiEvent &event);
- int setCallbackHandler(NanCallbackHandler nHandler);
+ int setCallbackHandler(NanCallbackHandler nHandler,
+ void *pUserData);
//Functions to fill the vendor data appropriately