From 00065b7fcacd4dbd5cf15300c5204ad810de82de Mon Sep 17 00:00:00 2001 From: KIM JungYong Date: Sun, 4 Sep 2016 13:49:44 +0900 Subject: [PATCH] Update parse logic of introspectProvider result. When received introspect provider result, consumer service expect to get provider policy as type of boolean. But, policy is integer type although provider side set boolean type. So, parse logic of policy is updated to parse for given type by received payload. Change-Id: I695e81179172376499345f9b1f6323a04325a015 Signed-off-by: KIM JungYong Reviewed-on: https://gerrit.iotivity.org/gerrit/11383 Tested-by: jenkins-iotivity Reviewed-by: Hun-je Yeon Reviewed-by: Uze Choi --- .../src/consumer/NSConsumerDiscovery.c | 30 +++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/service/notification/src/consumer/NSConsumerDiscovery.c b/service/notification/src/consumer/NSConsumerDiscovery.c index 1b21230..98951b3 100644 --- a/service/notification/src/consumer/NSConsumerDiscovery.c +++ b/service/notification/src/consumer/NSConsumerDiscovery.c @@ -190,10 +190,17 @@ NSProvider_internal * NSGetProvider(OCClientResponse * clientResponse) NS_LOG(DEBUG, "create NSProvider"); NS_VERIFY_NOT_NULL(clientResponse->payload, NULL); + OCRepPayloadPropType accepterType = OCREP_PROP_BOOL; + OCRepPayload * payload = (OCRepPayload *)clientResponse->payload; while (payload) { NS_LOG_V(DEBUG, "Payload Key : %s", payload->values->name); + NS_LOG_V(DEBUG, "Payload Type : %d", (int) payload->values->type); + if (!strcmp(payload->values->name, NS_ATTRIBUTE_POLICY)) + { + accepterType = payload->values->type; + } payload = payload->next; } @@ -203,11 +210,20 @@ NSProvider_internal * NSGetProvider(OCClientResponse * clientResponse) char * messageUri = NULL; char * syncUri = NULL; char * topicUri = NULL; - int64_t accepter = 0; + bool bAccepter = 0; + int16_t iAccepter = 0; NSProviderConnectionInfo * connection = NULL; NS_LOG(DEBUG, "get information of accepter"); - bool getResult = OCRepPayloadGetPropBool(payload, NS_ATTRIBUTE_POLICY, & accepter); + bool getResult = false; + if (accepterType == OCREP_PROP_BOOL) + { + getResult = OCRepPayloadGetPropBool(payload, NS_ATTRIBUTE_POLICY, & bAccepter); + } + else if (accepterType == OCREP_PROP_INT) + { + getResult = OCRepPayloadGetPropInt(payload, NS_ATTRIBUTE_POLICY, (int64_t*) & iAccepter); + } NS_VERIFY_NOT_NULL(getResult == true ? (void *) 1 : NULL, NULL); NS_LOG(DEBUG, "get provider ID"); @@ -246,7 +262,15 @@ NSProvider_internal * NSGetProvider(OCClientResponse * clientResponse) { newProvider->topicUri = topicUri; } - newProvider->accessPolicy = (NSSelector)accepter; + if (accepterType == OCREP_PROP_BOOL) + { + newProvider->accessPolicy = (NSSelector)bAccepter; + } + else if (accepterType == OCREP_PROP_INT) + { + newProvider->accessPolicy = (NSSelector)iAccepter; + } + newProvider->connection = connection; newProvider->topicLL = NULL; newProvider->state = NS_DISCOVERED; -- 2.7.4