List child resource eps instead of parent.
authorTodd Malsbary <todd.malsbary@intel.com>
Wed, 30 Aug 2017 19:10:37 +0000 (12:10 -0700)
committerAshok Babu Channa <ashok.channa@samsung.com>
Fri, 22 Sep 2017 13:41:46 +0000 (13:41 +0000)
Bug: https://jira.iotivity.org/browse/IOT-2658
Change-Id: I90917f5fd965fd0e811326d3674cb751e5ac989e
Signed-off-by: Todd Malsbary <todd.malsbary@intel.com>
resource/csdk/stack/include/internal/ocstackinternal.h
resource/csdk/stack/src/occollection.c
resource/csdk/stack/src/ocpayload.c
resource/csdk/stack/test/stacktests.cpp

index 7f2ae2b..dd43c63 100644 (file)
@@ -367,9 +367,10 @@ OCStackResult GetTCPPortInfo(OCDevAddr *endpoint, uint16_t *port, bool secured);
 
 /**
  * This function creates list of OCEndpointPayload structure,
- *  which matches with endpointType from list of CAEndpoint_t.
+ * which matches with the resource's endpointType from list of
+ * CAEndpoint_t.
  *
- * @param[in] colResource collection resource for endpointType and resourceProperties
+ * @param[in] resource the resource
  * @param[in] devAddr devAddr Structure pointing to the address.
  * @param[in] networkInfo array of CAEndpoint_t
  * @param[in] infoSize size of array
@@ -379,7 +380,7 @@ OCStackResult GetTCPPortInfo(OCDevAddr *endpoint, uint16_t *port, bool secured);
  *
  * @return if success return pointer else NULL
  */
-OCEndpointPayload* CreateEndpointPayloadList(const OCResource* colResource,
+OCEndpointPayload* CreateEndpointPayloadList(const OCResource *resource,
     const OCDevAddr *devAddr, CAEndpoint_t *networkInfo,
     size_t infoSize, OCEndpointPayload **listHead, size_t* epSize, OCEndpointPayload** selfEp);
 
index e7774bc..187290c 100644 (file)
@@ -516,7 +516,7 @@ OCRepPayload** BuildCollectionLinksPayloadArray(const char* resourceUri,
             OIC_LOG_V(DEBUG, TAG, "Network Information size = %d", (int) networkSize);
 
             OCEndpointPayload *listHead = NULL;
-            CreateEndpointPayloadList((OCResource*)colResourceHandle,
+            CreateEndpointPayloadList(iterResource,
                 devAddr, info, networkSize, &listHead, &epSize, NULL);
             OICFree(info);
             OIC_LOG_V(DEBUG, TAG, "Result of CreateEndpointPayloadList() = %s",
index 12e7c3b..7ce6f53 100644 (file)
@@ -1803,21 +1803,21 @@ void OC_CALL OCResourcePayloadAddNewEndpoint(OCResourcePayload* payload, OCEndpo
     }
 }
 
-OCEndpointPayload* CreateEndpointPayloadList(const OCResource* colResource, const OCDevAddr *devAddr,
+OCEndpointPayload* CreateEndpointPayloadList(const OCResource *resource, const OCDevAddr *devAddr,
                                             CAEndpoint_t *networkInfo, size_t infoSize,
                          OCEndpointPayload **listHead, size_t* epSize, OCEndpointPayload** selfEp)
 {
     OCEndpointPayload *headNode = NULL;
     OCEndpointPayload *lastNode = NULL;
 
-    VERIFY_PARAM_NON_NULL(TAG, colResource, "Invalid colResource parameter");
+    VERIFY_PARAM_NON_NULL(TAG, resource, "Invalid resource parameter");
     VERIFY_PARAM_NON_NULL(TAG, devAddr, "Invalid devAddr parameter");
     VERIFY_PARAM_NON_NULL(TAG, networkInfo, "Invalid networkInfo parameter");
     VERIFY_PARAM_NON_NULL(TAG, listHead, "Invalid listHead parameter");
     if (epSize != NULL) *epSize = 0;
 
-    bool includeSecure = colResource->resourceProperties & OC_SECURE;
-    bool includeNonsecure = colResource->resourceProperties & OC_NONSECURE;
+    bool includeSecure = resource->resourceProperties & OC_SECURE;
+    bool includeNonsecure = resource->resourceProperties & OC_NONSECURE;
 
     if ((OC_ADAPTER_IP | OC_ADAPTER_TCP) & (devAddr->adapter))
     {
@@ -1839,7 +1839,7 @@ OCEndpointPayload* CreateEndpointPayloadList(const OCResource* colResource, cons
                 }
 
                 bool isSecure = (info->flags & OC_FLAG_SECURE);
-                if (((colResource->endpointType) & matchedTps) &&
+                if (((resource->endpointType) & matchedTps) &&
                         ((isSecure && includeSecure) || (!isSecure && includeNonsecure)))
                 {
                     // create payload
index 02f08fa..36414e0 100644 (file)
@@ -2970,8 +2970,8 @@ TEST(LinksPayloadArray, BuildCollectionLinksPayloadArray)
     InitStack(OC_SERVER);
 
     size_t numResources = 0;
-    uint8_t parentBitmap = (OC_DISCOVERABLE | OC_OBSERVABLE) | OC_SECURE;
-    uint8_t inBitmap[2] = {( OC_DISCOVERABLE | OC_OBSERVABLE) | OC_SECURE,
+    uint8_t parentBitmap = OC_DISCOVERABLE | OC_OBSERVABLE;
+    uint8_t inBitmap[2] = { OC_DISCOVERABLE | OC_OBSERVABLE | OC_SECURE,
                             OC_DISCOVERABLE | OC_SECURE };
     int64_t outBitmap[2] = { 0 };
 
@@ -3143,14 +3143,18 @@ TEST(LinksPayloadArray, BuildCollectionLinksPayloadArray)
         }
 
 #ifdef __WITH_DTLS__
-        ASSERT_GE(coap_scheme_cnt[1], (size_t) 1);
+        EXPECT_EQ(coap_scheme_cnt[0], (size_t) 0);
+        EXPECT_GE(coap_scheme_cnt[1], (size_t) 1);
 #ifdef TCP_ADAPTER
-        ASSERT_GE(coap_scheme_cnt[3], (size_t) 1);
+        EXPECT_EQ(coap_scheme_cnt[2], (size_t) 0);
+        EXPECT_GE(coap_scheme_cnt[3], (size_t) 1);
 #endif
 #else
-        ASSERT_GE(coap_scheme_cnt[0], (size_t) 1);
+        EXPECT_GE(coap_scheme_cnt[0], (size_t) 1);
+        EXPECT_EQ(coap_scheme_cnt[1], (size_t) 0);
 #ifdef TCP_ADAPTER
-        ASSERT_GE(coap_scheme_cnt[2], (size_t) 1);
+        EXPECT_GE(coap_scheme_cnt[2], (size_t) 1);
+        EXPECT_EQ(coap_scheme_cnt[3], (size_t) 0);
 #endif
 #endif