* This function creates list of OCEndpointPayload structure,
* which matches with endpointType from list of CAEndpoint_t.
*
- * @param[in] endpointType Bit combination of type for Endpoint.
+ * @param[in] colResource collection resource for endpointType and resourceProperties
* @param[in] devAddr devAddr Structure pointing to the address.
* @param[in] networkInfo array of CAEndpoint_t
* @param[in] infoSize size of array
* @param[out] listHead pointer to HeadNode pointer
- * @param[out] epSize size of array
+ * @param[out] epSize size of array(set NULL not to use it)
+ * @param[out] selfEp endpoint that matches devAddr for use in anchor(set NULL not to use it)
*
* @return if success return pointer else NULL
*/
-OCEndpointPayload* CreateEndpointPayloadList(OCTpsSchemeFlags endpointType,
+OCEndpointPayload* CreateEndpointPayloadList(const OCResource* colResource,
const OCDevAddr *devAddr, CAEndpoint_t *networkInfo,
- size_t infoSize, OCEndpointPayload **listHead, size_t* epSize);
+ size_t infoSize, OCEndpointPayload **listHead, size_t* epSize, OCEndpointPayload** selfEp);
/*
* This function returns to destroy endpoint payload
OIC_LOG_V(DEBUG, TAG, "Network Information size = %d", (int) networkSize);
OCEndpointPayload *listHead = NULL;
- CreateEndpointPayloadList(((OCResource*)colResourceHandle)->endpointType,
- devAddr, info, networkSize, &listHead, &epSize);
+ CreateEndpointPayloadList((OCResource*)colResourceHandle,
+ devAddr, info, networkSize, &listHead, &epSize, NULL);
OICFree(info);
OIC_LOG_V(DEBUG, TAG, "Result of CreateEndpointPayloadList() = %s",
listHead ? "true":"false");
}
}
-OCEndpointPayload* CreateEndpointPayloadList(OCTpsSchemeFlags endpointType, const OCDevAddr *devAddr,
+OCEndpointPayload* CreateEndpointPayloadList(const OCResource* colResource, const OCDevAddr *devAddr,
CAEndpoint_t *networkInfo, size_t infoSize,
- OCEndpointPayload **listHead, size_t* epSize)
+ 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, 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;
+ if (epSize != NULL) *epSize = 0;
+
+ bool includeSecure = colResource->resourceProperties & OC_SECURE;
+ bool includeNonsecure = colResource->resourceProperties & OC_NONSECURE;
if ((OC_ADAPTER_IP | OC_ADAPTER_TCP) & (devAddr->adapter))
{
goto exit;
}
- if ((endpointType) & matchedTps)
+ bool isSecure = (info->flags & OC_FLAG_SECURE);
+ if (((colResource->endpointType) & matchedTps) &&
+ ((isSecure && includeSecure) || (!isSecure && includeNonsecure)))
{
+ // create payload
OCEndpointPayload* tmpNode = (OCEndpointPayload*)
OICCalloc(1, sizeof(OCEndpointPayload));
if (!tmpNode)
tmpNode->pri = 1;
tmpNode->next = NULL;
+ // remember endpoint that matches devAddr for use in anchor
+ OCTransportFlags infoFlagsSecureFams = (OCTransportFlags)
+ (info->flags & MASK_SECURE_FAMS);
+ if ((selfEp != NULL) &&
+ ((infoFlagsSecureFams & devAddr->flags) == infoFlagsSecureFams))
+ {
+ *selfEp = tmpNode;
+ }
+
// store in list
if (!headNode)
{
OCEndpointPayload *selfEp = NULL;
if (networkInfo && infoSize && devAddr)
{
- if(!CreateEndpointPayloadList(res->endpointType, devAddr, networkInfo, infoSize,
- &(pl->eps), NULL))
+ if(!CreateEndpointPayloadList(res, devAddr, networkInfo, infoSize,
+ &(pl->eps), NULL, &selfEp))
{
return NULL;
}
InitStack(OC_SERVER);
size_t numResources = 0;
- uint8_t parentBitmap = OC_DISCOVERABLE | OC_OBSERVABLE;
- uint8_t inBitmap[2] = { OC_DISCOVERABLE | OC_OBSERVABLE,
- OC_DISCOVERABLE };
+ uint8_t parentBitmap = (OC_DISCOVERABLE | OC_OBSERVABLE) | OC_SECURE;
+ uint8_t inBitmap[2] = {( OC_DISCOVERABLE | OC_OBSERVABLE) | OC_SECURE,
+ OC_DISCOVERABLE | OC_SECURE };
int64_t outBitmap[2] = { 0 };
OCResourceHandle containerHandle;
{
ASSERT_TRUE(OCRepPayloadGetPropObject(linksMap[i], OC_RSRVD_POLICY, &policyMap));
ASSERT_TRUE(OCRepPayloadGetPropInt(policyMap, OC_RSRVD_BITMAP, &outBitmap[i]));
- EXPECT_EQ(inBitmap[i], outBitmap[i]);
+ // check bitmap excluding secure bit
+ EXPECT_EQ(inBitmap[i] & ~OC_MASK_RESOURCE_SECURE, outBitmap[i]);
if (devAddr)
{
{
ASSERT_TRUE(OCRepPayloadGetPropObject(linksMap[i], OC_RSRVD_POLICY, &policyMap));
ASSERT_TRUE(OCRepPayloadGetPropInt(policyMap, OC_RSRVD_BITMAP, &outBitmap[i]));
- EXPECT_EQ(inBitmap[i], outBitmap[i]);
+ // check bitmap excluding secure bit
+ EXPECT_EQ(inBitmap[i] & ~OC_MASK_RESOURCE_SECURE, outBitmap[i]);
size_t epsDim[MAX_REP_ARRAY_DEPTH] = { 0 };
OCRepPayload **epsMap = NULL;
OCRepPayloadDestroy(epsMap[k]);
}
- ASSERT_GE(coap_scheme_cnt[0], (size_t) 1);
-#ifdef __WITH_TLS__
+#ifdef __WITH_DTLS__
ASSERT_GE(coap_scheme_cnt[1], (size_t) 1);
#ifdef TCP_ADAPTER
ASSERT_GE(coap_scheme_cnt[3], (size_t) 1);
#endif
#else
+ ASSERT_GE(coap_scheme_cnt[0], (size_t) 1);
#ifdef TCP_ADAPTER
ASSERT_GE(coap_scheme_cnt[2], (size_t) 1);
#endif