static void printStoragedResources(OCRDStorePublishResources *payload)
{
- OC_LOG(DEBUG, TAG, "Print Storage Resources ... ");
+ OIC_LOG(DEBUG, TAG, "Print Storage Resources ... ");
for (OCRDStorePublishResources *temp = payload; temp; temp = temp->next)
{
if (temp->publishedResource)
OCResourceCollectionPayload *storeResource = (OCResourceCollectionPayload *)OICCalloc(1, sizeof(OCResourceCollectionPayload));
if (!storeResource)
{
- OC_LOG(ERROR, TAG, "Failed allocating memory for OCRDStorePublishResources.");
+ OIC_LOG(ERROR, TAG, "Failed allocating memory for OCRDStorePublishResources.");
return OC_STACK_NO_MEMORY;
}
- OC_LOG_V(DEBUG, TAG, "Storing Resources for %s:%u", address->addr, address->port);
-
- char rdPubAddr[MAX_ADDR_STR_SIZE];
- snprintf(rdPubAddr, MAX_ADDR_STR_SIZE, "%s:%d", address->addr, address->port);
+ OIC_LOG_V(DEBUG, TAG, "Storing Resources for %s:%u", address->addr, address->port);
OCTagsPayload *tags = payload->tags;
- storeResource->tags = OCCopyTagsResources(tags->n.deviceName, tags->di.id, rdPubAddr,
+ storeResource->tags = OCCopyTagsResources(tags->n.deviceName, tags->di.id, tags->baseURI,
tags->bitmap, address->port, tags->ins, tags->rts, tags->drel, tags->ttl);
if (!storeResource->tags)
{
- OC_LOG(ERROR, TAG, "Failed allocating memory for tags.");
+ OIC_LOG(ERROR, TAG, "Failed allocating memory for tags.");
OCFreeCollectionResource(storeResource);
return OC_STACK_NO_MEMORY;
}
links->rel, links->obs, links->title, links->uri, links->ins, links->mt);
if (!storeResource->setLinks)
{
- OC_LOG(ERROR, TAG, "Failed allocating memory for links.");
+ OIC_LOG(ERROR, TAG, "Failed allocating memory for links.");
OCFreeCollectionResource(storeResource);
return OC_STACK_NO_MEMORY;
}
links->obs, links->title, links->uri, links->ins, links->mt);
if (!temp->next)
{
- OC_LOG(ERROR, TAG, "Failed allocating memory for links.");
+ OIC_LOG(ERROR, TAG, "Failed allocating memory for links.");
OCFreeCollectionResource(storeResource);
return OC_STACK_NO_MEMORY;
}
return OC_STACK_NO_MEMORY;
}
resources->publishedResource = storeResource;
+ resources->devAddr = *address;
pthread_mutex_lock(&storageMutex);
if (g_rdStorage)
}
OCStackResult OCRDCheckPublishedResource(const char *interfaceType, const char *resourceType,
- OCResourceCollectionPayload **payload)
+ OCResourceCollectionPayload **payload, OCDevAddr *devAddr)
{
// ResourceType and InterfaceType if both are NULL it will return. If either is
// not null it will continue execution.
if (!resourceType && !interfaceType)
{
- OC_LOG(DEBUG, TAG, "Missing resource type and interace type.");
+ OIC_LOG(DEBUG, TAG, "Missing resource type or interace type.");
return OC_STACK_INVALID_PARAM;
}
- OC_LOG(DEBUG, TAG, "Check Resource in RD");
+ OIC_LOG(DEBUG, TAG, "Check Resource in RD");
if (g_rdStorage && g_rdStorage->publishedResource)
{
for (OCRDStorePublishResources *pResource = g_rdStorage;
// If either rt or itf are NULL, it should skip remaining code execution.
if (!tLinks->rt || !tLinks->itf)
{
- OC_LOG(DEBUG, TAG, "Either resource type and interface type are missing.");
+ OIC_LOG(DEBUG, TAG, "Either resource type or interface type is missing.");
continue;
}
if (resourceType)
OCStringLL *temp = tLinks->rt;
while(temp)
{
- OC_LOG_V(DEBUG, TAG, "Resource Type: %s %s", resourceType, temp->value);
+ OIC_LOG_V(DEBUG, TAG, "Resource Type: %s %s", resourceType, temp->value);
if (strcmp(resourceType, temp->value) == 0)
{
OCTagsPayload *tag = pResource->publishedResource->tags;
OCFreeLinksResource(links);
return OC_STACK_NO_MEMORY;
}
+ memcpy(devAddr, &pResource->devAddr, sizeof(*devAddr));
return OC_STACK_OK;
}
temp = temp->next;
OCStringLL *temp = tLinks->itf;
while (temp)
{
- OC_LOG_V(DEBUG, TAG, "Interface Type: %s %s", interfaceType, temp->value);
+ OIC_LOG_V(DEBUG, TAG, "Interface Type: %s %s", interfaceType, temp->value);
if (strcmp(interfaceType, temp->value) == 0)
{
OCTagsPayload *tag = pResource->publishedResource->tags;
OCFreeLinksResource(links);
return OC_STACK_NO_MEMORY;
}
+ devAddr = &pResource->devAddr;
return OC_STACK_OK;
}
temp = temp->next;