CTT1.2.2: changed requestHandle value to a request ID
authorjihwanseo <jihwan.seo@samsung.com>
Thu, 24 Nov 2016 06:41:14 +0000 (15:41 +0900)
committerUze Choi <uzchoi@samsung.com>
Fri, 25 Nov 2016 09:01:02 +0000 (09:01 +0000)
When a request message is delivered to resource server, the address value
of serverRequest get passed as a requestHandle to the application.
However, when duplicated messages are delivered and the application is
doing slow-response on entityHandler, the later messages could have a
invalid address value, which is requestHandle, since the original
serverRequest would be deleted by responding to the first one.

So I made a unique ID for each request message and replace the requestHandle
with it.

Change-Id: I164bfeaea51be863715f7ced60c40b1f16dafdfc
Signed-off-by: Jaewook Jung <jw0213.jung@samsung.com>
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14761
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Tested-by: Uze Choi <uzchoi@samsung.com>
17 files changed:
resource/csdk/routing/src/routingmanagerinterface.c
resource/csdk/security/src/credresource.c
resource/csdk/security/src/dpairingresource.c
resource/csdk/security/src/resourcemanager.c
resource/csdk/stack/include/internal/ocserverrequest.h
resource/csdk/stack/include/octypes.h
resource/csdk/stack/src/occollection.c
resource/csdk/stack/src/ocobserve.c
resource/csdk/stack/src/ocresource.c
resource/csdk/stack/src/ocserverrequest.c
resource/csdk/stack/src/ocstack.c
resource/csdk/stack/src/oicgroup.c
resource/csdk/stack/src/oickeepalive.c
resource/include/OCResourceRequest.h
resource/include/OCResourceResponse.h
resource/unittests/OCResourceResponseTest.cpp
service/resource-encapsulation/src/serverBuilder/unittests/RCSResourceObjectTest.cpp

index e0172fb71aed7f7dcbc1651575b677f964c144d6..ccb9dfb55207bcd85eb03cd3195db8f62d4f6032 100644 (file)
@@ -196,7 +196,7 @@ OCStackResult RMSendResponse(const OCServerRequest *request, const OCResource *r
     OCEntityHandlerResponse response = {.ehResult = OC_EH_OK,
                                         .payload = (OCPayload *)payload,
                                         .persistentBufferFlag = 0,
-                                        .requestHandle = (OCRequestHandle) request,
+                                        .requestHandle = (OCRequestHandle) request->requestId,
                                         .resourceHandle = (OCResourceHandle) resource
                                         };
     OIC_LOG(DEBUG, TAG, "RMSendResponse OUT");
index c47f39fe80ecc82b9afd13ec69d100430c89fa83..6918e1dc7c3d7a5f394d3765d4e15226b214b0b1 100644 (file)
@@ -1837,7 +1837,7 @@ static OCEntityHandlerResult HandlePostRequest(const OCEntityHandlerRequest * eh
             {
                 case SYMMETRIC_PAIR_WISE_KEY:
                 {
-                    OCServerRequest *request = (OCServerRequest *)ehRequest->requestHandle;
+                    OCServerRequest *request = GetServerRequestUsingHandle(ehRequest->requestHandle);
                     if(FillPrivateDataOfOwnerPSK(cred, (CAEndpoint_t *)&request->devAddr, doxm))
                     {
                         if(OC_STACK_RESOURCE_DELETED == RemoveCredential(&cred->subject))
@@ -1954,7 +1954,7 @@ static OCEntityHandlerResult HandlePostRequest(const OCEntityHandlerRequest * eh
             {
                 case SYMMETRIC_PAIR_WISE_KEY:
                 {
-                    OCServerRequest *request = (OCServerRequest *)ehRequest->requestHandle;
+                    OCServerRequest *request = GetServerRequestUsingHandle(ehRequest->requestHandle);
                     if(FillPrivateDataOfSubOwnerPSK(cred, (CAEndpoint_t *)&request->devAddr, doxm, &cred->subject))
                     {
                         if(OC_STACK_RESOURCE_DELETED == RemoveCredential(&cred->subject))
index 81271ab956779cf49042131a43b723cd9fbc111b..fddcf7aed6628d12aa8bfce115386853dacc2d5f 100644 (file)
@@ -547,7 +547,7 @@ static OCEntityHandlerResult HandleDpairingPutRequest (const OCEntityHandlerRequ
         VERIFY_NON_NULL(TAG, pconf, ERROR);
 
 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
-        OCServerRequest * request = (OCServerRequest *)ehRequest->requestHandle;
+        OCServerRequest *request = GetServerRequestUsingHandle(ehRequest->requestHandle);
         VERIFY_SUCCESS(TAG, (request->devAddr.flags | OC_FLAG_SECURE), ERROR);
 
         //Generate new credential
index 221b873d4384ba17c5c3d0de3bc9e122a563ba6a..c4545f396e979e10ec85d696483a15fef3373e2c 100644 (file)
@@ -48,11 +48,11 @@ OCStackResult SendSRMResponse(const OCEntityHandlerRequest *ehRequest,
         OCEntityHandlerResult ehRet, uint8_t *cborPayload, size_t size)
 {
     OIC_LOG(DEBUG, TAG, "SRM sending SRM response");
-    OCEntityHandlerResponse response = {.requestHandle = NULL};
     OCStackResult ret = OC_STACK_ERROR;
 
     if (ehRequest)
     {
+        OCEntityHandlerResponse response = {.requestHandle = 0};
         OCSecurityPayload ocPayload = {.base = {.type = PAYLOAD_TYPE_INVALID}};
 
         response.requestHandle = ehRequest->requestHandle;
index d7f7bae8e29b8a150b86696cb6df98b08e9e91cd..7a1068b97c7e3bb1b9e45607d4642e79fbdaabce 100644 (file)
@@ -58,7 +58,6 @@ typedef struct OCServerRequest
     OCQualityOfService qos;
 
     /** Observe option field.*/
-
     uint32_t observationOption;
 
     /** Observe Result field.*/
@@ -109,6 +108,9 @@ typedef struct OCServerRequest
     /** payload is retrieved from the payload of the received request PDU.*/
     uint8_t payload[1];
 
+    /** The ID of server request*/
+    uint32_t requestId;
+
     // WARNING: Do NOT add attributes after payload as they get overwritten
     // when payload content gets copied over!
 
@@ -175,7 +177,7 @@ OCServerRequest * GetServerRequestUsingToken (const CAToken_t token, uint8_t tok
  * @return
  *     OCServerRequest*
  */
-OCServerRequest * GetServerRequestUsingHandle (const OCServerRequest * handle);
+OCServerRequest * GetServerRequestUsingHandle (const OCRequestHandle handle);
 
 /**
  * Get a server response from the server response list using the specified handle
@@ -185,7 +187,7 @@ OCServerRequest * GetServerRequestUsingHandle (const OCServerRequest * handle);
  * @return
  *     OCServerResponse*
  */
-OCServerResponse * GetServerResponseUsingHandle (const OCServerRequest * handle);
+OCServerResponse * GetServerResponseUsingHandle (const OCRequestHandle handle);
 
 /**
  * Add a server request to the server request list
index 626bca7c76565002d0207457d8bf6e2458c43dbc..86f6b3729c5660aa028d547dfb35b963322d2a44 100644 (file)
@@ -1016,7 +1016,7 @@ typedef void * OCResourceHandle;
 /**
  * Handle to an OCRequest object owned by the OCStack.
  */
-typedef void * OCRequestHandle;
+typedef uint32_t OCRequestHandle;
 
 /**
  * Unique identifier for each observation request. Used when observations are
index 4e20bd7247315e3c707cbf7c477a2466e87759a3..9769a931cdda20b30688249ab9edb2669dbfb493 100755 (executable)
@@ -337,7 +337,12 @@ HandleBatchInterface(OCEntityHandlerRequest *ehRequest)
                 if (ehResult == OC_EH_SLOW)
                 {
                     OIC_LOG(INFO, TAG, "This is a slow resource");
-                    ((OCServerRequest *)ehRequest->requestHandle)->slowFlag = 1;
+                    OCServerRequest *request =
+                            GetServerRequestUsingHandle(ehRequest->requestHandle);
+                    if (request)
+                    {
+                        request->slowFlag = 1;
+                    }
                     stackRet = EntityHandlerCodeToOCStackCode(ehResult);
                 }
             }
@@ -421,15 +426,19 @@ OCStackResult DefaultCollectionEntityHandler (OCEntityHandlerFlag flag,
                     return HandleLinkedListInterface(ehRequest, STACK_RES_DISCOVERY_NOFILTER, NULL);
 
                 case STACK_IF_BATCH:
+                {
                     OIC_LOG(INFO, TAG, "STACK_IF_BATCH");
-                    ((OCServerRequest *)ehRequest->requestHandle)->ehResponseHandler =
-                                                                            HandleAggregateResponse;
-
-                    ((OCServerRequest *)ehRequest->requestHandle)->numResponses =
+                    OCServerRequest *request =
+                            GetServerRequestUsingHandle(ehRequest->requestHandle);
+                    if (request)
+                    {
+                        request->ehResponseHandler = HandleAggregateResponse;
+                        request->numResponses =
                             GetNumOfResourcesInCollection((OCResource *)ehRequest->resource) + 1;
+                    }
 
                     return HandleBatchInterface(ehRequest);
-
+                }
                 case STACK_IF_GROUP:
                     return BuildCollectionGroupActionCBORResponse(OC_REST_GET/*flag*/,
                             (OCResource *) ehRequest->resource, ehRequest);
@@ -450,12 +459,17 @@ OCStackResult DefaultCollectionEntityHandler (OCEntityHandlerFlag flag,
                     return OC_STACK_ERROR;
 
                 case STACK_IF_BATCH:
-                    ((OCServerRequest *)ehRequest->requestHandle)->ehResponseHandler =
-                                                                            HandleAggregateResponse;
-                    ((OCServerRequest *)ehRequest->requestHandle)->numResponses =
+                {
+                    OCServerRequest *request =
+                            GetServerRequestUsingHandle(ehRequest->requestHandle);
+                    if (request)
+                    {
+                        request->ehResponseHandler = HandleAggregateResponse;
+                        request->numResponses =
                             GetNumOfResourcesInCollection((OCResource *)ehRequest->resource) + 1;
+                    }
                     return HandleBatchInterface(ehRequest);
-
+                }
                 case STACK_IF_GROUP:
                     OIC_LOG(INFO, TAG, "IF_COLLECTION PUT with request ::\n");
                     OIC_LOG_PAYLOAD(INFO, ehRequest->payload);
@@ -478,11 +492,17 @@ OCStackResult DefaultCollectionEntityHandler (OCEntityHandlerFlag flag,
                     return OC_STACK_ERROR;
 
                 case STACK_IF_BATCH:
-                    ((OCServerRequest *)ehRequest->requestHandle)->ehResponseHandler =
-                                                                            HandleAggregateResponse;
-                    ((OCServerRequest *)ehRequest->requestHandle)->numResponses =
+                {
+                    OCServerRequest *request =
+                            GetServerRequestUsingHandle(ehRequest->requestHandle);
+                    if (request)
+                    {
+                        request->ehResponseHandler = HandleAggregateResponse;
+                        request->numResponses =
                             GetNumOfResourcesInCollection((OCResource *)ehRequest->resource) + 1;
+                    }
                     return HandleBatchInterface(ehRequest);
+                }
 
                 case STACK_IF_GROUP:
                     OIC_LOG(INFO, TAG, "IF_COLLECTION POST with request ::\n");
index b49b6150977fafe170d8d0b52f7224f62f92c820..6d11070a2368d7415fb02ae39f9fbebff289bc61 100644 (file)
@@ -126,7 +126,7 @@ static OCStackResult SendObserveNotification(ResourceObserver *observer,
         {
             result = FormOCEntityHandlerRequest(
                         &ehRequest,
-                        (OCRequestHandle) request,
+                        (OCRequestHandle) request->requestId,
                         request->method,
                         &request->devAddr,
                         (OCResourceHandle) observer->resource,
@@ -222,7 +222,7 @@ OCStackResult SendAllObserverNotification (OCMethod method, OCResource *resPtr,
                         ehResponse.ehResult = OC_EH_OK;
                         ehResponse.payload = (OCPayload*)presenceResBuf;
                         ehResponse.persistentBufferFlag = 0;
-                        ehResponse.requestHandle = (OCRequestHandle) request;
+                        ehResponse.requestHandle = (OCRequestHandle) request->requestId;
                         ehResponse.resourceHandle = (OCResourceHandle) resPtr;
                         OICStrcpy(ehResponse.resourceUri, sizeof(ehResponse.resourceUri),
                                 resourceObserver->resUri);
@@ -308,7 +308,7 @@ OCStackResult SendListObserverNotification (OCResource * resource,
                         }
                         memcpy(ehResponse.payload, payload, sizeof(*payload));
                         ehResponse.persistentBufferFlag = 0;
-                        ehResponse.requestHandle = (OCRequestHandle) request;
+                        ehResponse.requestHandle = (OCRequestHandle) request->requestId;
                         ehResponse.resourceHandle = (OCResourceHandle) resource;
                         result = OCDoResponse(&ehResponse);
                         if (result == OC_STACK_OK)
index 53509ed794285e96742a21a267f2f4d4ca237751..c6c3a5fa7e4968263ee43855bf187508da6a24bd 100755 (executable)
@@ -711,7 +711,7 @@ OCStackResult SendNonPersistantDiscoveryResponse(OCServerRequest *request, OCRes
     response.ehResult = ehResult;
     response.payload = discoveryPayload;
     response.persistentBufferFlag = 0;
-    response.requestHandle = (OCRequestHandle) request;
+    response.requestHandle = (OCRequestHandle) request->requestId;
     response.resourceHandle = (OCResourceHandle) resource;
 
     return OCDoResponse(&response);
@@ -1031,7 +1031,7 @@ HandleDefaultDeviceEntityHandler (OCServerRequest *request)
 
     OIC_LOG(INFO, TAG, "Entering HandleResourceWithDefaultDeviceEntityHandler");
     result = FormOCEntityHandlerRequest(&ehRequest,
-                                        (OCRequestHandle) request,
+                                        (OCRequestHandle) request->requestId,
                                         request->method,
                                         &request->devAddr,
                                         (OCResourceHandle) NULL, request->query,
@@ -1088,11 +1088,10 @@ HandleResourceWithEntityHandler (OCServerRequest *request,
     if (request && request->resourceUrl && SRMIsSecurityResourceURI(request->resourceUrl))
     {
         type = PAYLOAD_TYPE_SECURITY;
-
     }
 
     result = FormOCEntityHandlerRequest(&ehRequest,
-                                        (OCRequestHandle)request,
+                                        (OCRequestHandle)request->requestId,
                                         request->method,
                                         &request->devAddr,
                                         (OCResourceHandle)resource,
@@ -1236,7 +1235,7 @@ HandleCollectionResourceDefaultEntityHandler (OCServerRequest *request,
     OCEntityHandlerRequest ehRequest = {0};
 
     result = FormOCEntityHandlerRequest(&ehRequest,
-                                        (OCRequestHandle)request,
+                                        (OCRequestHandle)request->requestId,
                                         request->method,
                                         &request->devAddr,
                                         (OCResourceHandle)resource,
index 041c75c67d427935e29bb23d7775bde2d58eee58..a3e96c482e0438c3f14bbb9fd4cfcb3ff339a81a 100644 (file)
@@ -222,12 +222,12 @@ OCServerRequest * GetServerRequestUsingToken (const CAToken_t token, uint8_t tok
  * @return
  *     OCServerRequest*
  */
-OCServerRequest * GetServerRequestUsingHandle (const OCServerRequest * handle)
+OCServerRequest * GetServerRequestUsingHandle (const OCRequestHandle handle)
 {
     OCServerRequest * out = NULL;
     LL_FOREACH (serverRequestList, out)
     {
-        if(out == handle)
+        if(out->requestId == handle)
         {
             return out;
         }
@@ -244,7 +244,7 @@ OCServerRequest * GetServerRequestUsingHandle (const OCServerRequest * handle)
  * @return
  *     OCServerResponse*
  */
-OCServerResponse * GetServerResponseUsingHandle (const OCServerRequest * handle)
+OCServerResponse * GetServerResponseUsingHandle (const OCRequestHandle handle)
 {
     OCServerResponse * out = NULL;
     LL_FOREACH (serverResponseList, out)
@@ -293,6 +293,7 @@ OCStackResult AddServerRequest (OCServerRequest ** request, uint16_t coapID,
     serverRequest->acceptFormat = acceptFormat;
     serverRequest->ehResponseHandler = HandleSingleResponse;
     serverRequest->numResponses = 1;
+    serverRequest->requestId = OCGetRandom();
 
     if(query)
     {
@@ -306,7 +307,7 @@ OCStackResult AddServerRequest (OCServerRequest ** request, uint16_t coapID,
     }
     if(payload && reqTotalSize)
     {
-       // destination is at least 1 greater than the source, so a NULL always exists in the
+        // destination is at least 1 greater than the source, so a NULL always exists in the
         // last character
         memcpy(serverRequest->payload, payload, reqTotalSize);
         serverRequest->payloadSize = reqTotalSize;
@@ -315,15 +316,14 @@ OCStackResult AddServerRequest (OCServerRequest ** request, uint16_t coapID,
     serverRequest->requestComplete = 0;
     if(requestToken)
     {
-        // If tokenLength is zero, the return value depends on the
-        // particular library implementation (it may or may not be a null pointer).
+         // If tokenLength is zero, the return value depends on the
+         // particular library implementation (it may or may not be a null pointer).
         if (tokenLength)
         {
             serverRequest->requestToken = (CAToken_t) OICMalloc(tokenLength);
             VERIFY_NON_NULL(serverRequest->requestToken);
             memcpy(serverRequest->requestToken, requestToken, tokenLength);
         }
-
     }
     serverRequest->tokenLength = tokenLength;
 
@@ -343,6 +343,7 @@ OCStackResult AddServerRequest (OCServerRequest ** request, uint16_t coapID,
 exit:
     if (serverRequest)
     {
+        OICFree(serverRequest->requestToken);
         OICFree(serverRequest);
         serverRequest = NULL;
     }
@@ -511,7 +512,12 @@ OCStackResult HandleSingleResponse(OCEntityHandlerResponse * ehResponse)
         return OC_STACK_ERROR;
     }
 
-    OCServerRequest *serverRequest = (OCServerRequest *)ehResponse->requestHandle;
+    OCServerRequest *serverRequest = GetServerRequestUsingHandle(ehResponse->requestHandle);
+    if (NULL == serverRequest)
+    {
+        OIC_LOG(ERROR, TAG, "No serverRequest matching with ehResponse");
+        return OC_STACK_ERROR;
+    }
 
     CopyDevAddrToEndpoint(&serverRequest->devAddr, &responseEndpoint);
 
@@ -742,10 +748,8 @@ OCStackResult HandleAggregateResponse(OCEntityHandlerResponse * ehResponse)
 
     OIC_LOG(INFO, TAG, "Inside HandleAggregateResponse");
 
-    OCServerRequest *serverRequest = GetServerRequestUsingHandle((OCServerRequest *)
-                                                                 ehResponse->requestHandle);
-    OCServerResponse *serverResponse = GetServerResponseUsingHandle((OCServerRequest *)
-                                                                    ehResponse->requestHandle);
+    OCServerRequest *serverRequest = GetServerRequestUsingHandle(ehResponse->requestHandle);
+    OCServerResponse *serverResponse = GetServerResponseUsingHandle(ehResponse->requestHandle);
 
     OCStackResult stackRet = OC_STACK_ERROR;
     if(serverRequest)
index c41f0e8aa81c7a446c07c2d9f0746ca30380e07e..bd495ca7ec5d7f1dd4e5d6c7f15cb3455919fc57 100644 (file)
@@ -548,7 +548,7 @@ OCStackResult OCStackFeedBack(CAToken_t token, uint8_t tokenLength, uint8_t stat
         if(observer)
         {
             result = FormOCEntityHandlerRequest(&ehRequest,
-                                                (OCRequestHandle)NULL,
+                                                0,
                                                 OC_REST_NOMETHOD,
                                                 &observer->devAddr,
                                                 (OCResourceHandle)NULL,
@@ -600,7 +600,7 @@ OCStackResult OCStackFeedBack(CAToken_t token, uint8_t tokenLength, uint8_t stat
             if(observer->failedCommCount >= MAX_OBSERVER_FAILED_COMM)
             {
                 result = FormOCEntityHandlerRequest(&ehRequest,
-                                                    (OCRequestHandle)NULL,
+                                                    0,
                                                     OC_REST_NOMETHOD,
                                                     &observer->devAddr,
                                                     (OCResourceHandle)NULL,
@@ -4030,7 +4030,7 @@ OCStackResult OCDoResponse(OCEntityHandlerResponse *ehResponse)
 
     // Normal response
     // Get pointer to request info
-    serverRequest = GetServerRequestUsingHandle((OCServerRequest *)ehResponse->requestHandle);
+    serverRequest = GetServerRequestUsingHandle(ehResponse->requestHandle);
     if(serverRequest)
     {
         // response handler in ocserverrequest.c. Usually HandleSingleResponse.
index 660ad8fabeac5afb6e145104a6353a17199ca3f5..9c6bc1f1720a3b347650a28f39f810ccf6198216 100755 (executable)
@@ -926,7 +926,7 @@ OCStackApplicationResult ActionSetCB(void* context, OCDoHandle handle,
         }
 
         // Format the response.  Note this requires some info about the request
-        response.requestHandle = info->ehRequest;
+        response.requestHandle = info->ehRequest->requestId;
         response.resourceHandle = info->collResource;
         response.payload = clientResponse->payload;
         response.numSendVendorSpecificHeaderOptions = 0;
@@ -1317,6 +1317,14 @@ OCStackResult BuildCollectionGroupActionCBORResponse(
                 else
                 {
                     OIC_LOG(INFO, TAG, "Group Action[POST].");
+                    OCServerRequest *request =
+                            GetServerRequestUsingHandle(ehRequest->requestHandle);
+                    if (NULL == request)
+                    {
+                        stackRet = OC_STACK_ERROR;
+                        goto exit;
+                    }
+
                     if (actionset->type == NONE)
                     {
                         OIC_LOG_V(INFO, TAG, "Execute ActionSet : %s",
@@ -1324,13 +1332,11 @@ OCStackResult BuildCollectionGroupActionCBORResponse(
                         unsigned int num = GetNumOfTargetResource(
                                 actionset->head);
 
-                        ((OCServerRequest *) ehRequest->requestHandle)->ehResponseHandler =
-                                HandleAggregateResponse;
-                        ((OCServerRequest *) ehRequest->requestHandle)->numResponses =
-                                num + 1;
+                        request->ehResponseHandler = HandleAggregateResponse;
+                        request->numResponses = num + 1;
+
+                        DoAction(resource, actionset, request);
 
-                        DoAction(resource, actionset,
-                                (OCServerRequest*) ehRequest->requestHandle);
                         stackRet = OC_STACK_OK;
                     }
                     else
@@ -1353,8 +1359,8 @@ OCStackResult BuildCollectionGroupActionCBORResponse(
                             MUTEX_LOCK(&g_scheduledResourceLock);
                             schedule->resource = resource;
                             schedule->actionset = actionset;
-                            schedule->ehRequest =
-                                    (OCServerRequest*) ehRequest->requestHandle;
+                            schedule->ehRequest = request;
+
                             MUTEX_UNLOCK(&g_scheduledResourceLock);
                             if (delay > 0)
                             {
index 08f5a7b89bc9eeaa46c1e7f39885bb414c633880..ecd0f19109d23f6dbeba74b1e673d2aeb0288a83 100644 (file)
@@ -415,9 +415,9 @@ OCStackResult SendKeepAliveResponse(OCServerRequest *request,
         AddResourceInterfaceNameToPayload(payload);
     }
 
-    OCEntityHandlerResponse ehResponse = { .ehResult = result, 
-                                           .payload = (OCPayload*) payload, 
-                                           .requestHandle = request,
+    OCEntityHandlerResponse ehResponse = { .ehResult = result,
+                                           .payload = (OCPayload*) payload,
+                                           .requestHandle = request->requestId,
                                            .resourceHandle = g_keepAliveHandle };
     OICStrcpy(ehResponse.resourceUri, sizeof(ehResponse.resourceUri), KEEPALIVE_RESOURCE_URI);
 
index 6761f5df12139a19044e5bac2acbb8ac066b26bd..8c7e1dcc445bb7b4cc2c3eb628f5d372eee0bae2 100644 (file)
@@ -54,7 +54,7 @@ namespace OC
             m_messageID(0),
             m_representation(OCRepresentation()),
             m_headerOptions(HeaderOptions()),
-            m_requestHandle(nullptr),
+            m_requestHandle(0),
             m_resourceHandle(nullptr)
         {
             m_observationInfo.action = ObserveAction::ObserveRegister;
index b4b8c9f432a66135e80bf908fc77853a5f6e0c74..754f1acb7cc717d36c05273619c4c6ab11393282 100644 (file)
@@ -51,7 +51,7 @@ namespace OC
             m_headerOptions{},
             m_interface{},
             m_representation{},
-            m_requestHandle{nullptr},
+            m_requestHandle{0},
             m_resourceHandle{nullptr},
             m_responseResult{}
         {
index c53c83c6d67e85d79386b92290a724f14842b532..645d2f8a27eecb28b0a25aa089fcd51a9607e05e 100644 (file)
@@ -102,17 +102,18 @@ namespace OCResourceResponseTest
         request.qos = OC_LOW_QOS;
         request.coapID = 0;
         request.delayedResNeeded = 0;
+        request.requestId = 0x1234;
 
-        OCRequestHandle handle = static_cast<OCRequestHandle>(&request);
-        EXPECT_EQ(NULL, response.getRequestHandle());
+        OCRequestHandle handle = request.requestId;
+        EXPECT_EQ(0, response.getRequestHandle());
         EXPECT_NO_THROW(response.setRequestHandle(handle));
-        EXPECT_NE(static_cast<OCRequestHandle>(NULL), response.getRequestHandle());
+        EXPECT_NE(0, response.getRequestHandle());
     }
 
     TEST(RequestHandleTest, SetGetRequestHandleNullHandle)
     {
         OCResourceResponse response;
-        OCRequestHandle handle = nullptr;
+        OCRequestHandle handle = 0;
 
         EXPECT_EQ(NULL, response.getRequestHandle());
         EXPECT_NO_THROW(response.setRequestHandle(handle));
index 8aa958df172b256c73fe8ccaa2a8d78f15c37f5e..dd2e622f7f364a08585f3b1b527d1b7c0eea5191 100644 (file)
@@ -413,8 +413,7 @@ protected:
     }
 };
 
-const OCRequestHandle ResourceObjectHandlingRequestTest::fakeRequestHandle =
-    reinterpret_cast<OCRequestHandle>(0x1234);
+const OCRequestHandle ResourceObjectHandlingRequestTest::fakeRequestHandle = 0x1234;
 const OCResourceHandle  ResourceObjectHandlingRequestTest::fakeResourceHandle =
     reinterpret_cast<OCResourceHandle>(0x4321);