OCStackResult BuildVirtualResourceResponse(const OCResource *resourcePtr, OCDiscoveryPayload *payload, OCDevAddr *devAddr, bool rdResponse) { if (!resourcePtr || !payload) { return OC_STACK_INVALID_PARAM; } uint16_t securePort = 0; if (resourcePtr->resourceProperties & OC_SECURE) { if (GetSecurePortInfo(devAddr, &securePort) != OC_STACK_OK) { securePort = 0; } } if (rdResponse) { securePort = devAddr->port; } uint16_t tcpPort = 0; #ifdef TCP_ADAPTER if (GetTCPPortInfo(devAddr, &tcpPort) != OC_STACK_OK) { tcpPort = 0; } OCDiscoveryPayloadAddResource(payload, resourcePtr, securePort, tcpPort); #else OCDiscoveryPayloadAddResource(payload, resourcePtr, securePort); #endif return OC_STACK_OK; }
OCStackResult BuildVirtualResourceResponse(const OCResource *resourcePtr, OCDiscoveryPayload *payload, OCDevAddr *devAddr) { if (!resourcePtr || !payload) { return OC_STACK_INVALID_PARAM; } uint16_t port = 0; if (resourcePtr->resourceProperties & OC_SECURE) { if (GetSecurePortInfo(devAddr, &port) != OC_STACK_OK) { port = 0; } } OCDiscoveryPayloadAddResource(payload, resourcePtr, port); return OC_STACK_OK; }