// Internal functions
//-----------------------------------------------------------------------------
+bool checkProxyUri(OCHeaderOption *options, uint8_t numOptions)
+{
+ if (!options || 0 == numOptions)
+ {
+ OIC_LOG (INFO, TAG, "No options present");
+ return false;
+ }
+
+ for (uint8_t i = 0; i < numOptions; i++)
+ {
+ if (options[i].protocolID == OC_COAP_ID && options[i].optionID == OC_RSRVD_PROXY_OPTION_ID)
+ {
+ OIC_LOG(DEBUG, TAG, "Proxy URI is present");
+ return true;
+ }
+ }
+ return false;
+}
+
uint32_t GetTicks(uint32_t afterMilliSeconds)
{
coap_tick_t now;
cbNode->method == OC_REST_OBSERVE_ALL ||
cbNode->method == OC_REST_DELETE)
{
- char targetUri[MAX_URI_LENGTH];
- snprintf(targetUri, MAX_URI_LENGTH, "%s?rt=%s", OC_RSRVD_RD_URI,
- OC_RSRVD_RESOURCE_TYPE_RDPUBLISH);
- if (strcmp(targetUri, cbNode->requestUri) == 0)
- {
- type = PAYLOAD_TYPE_RD;
- }
- else if (strcmp(OC_RSRVD_PLATFORM_URI, cbNode->requestUri) == 0)
- {
- type = PAYLOAD_TYPE_PLATFORM;
- }
- else if (strcmp(OC_RSRVD_DEVICE_URI, cbNode->requestUri) == 0)
+ if (cbNode->requestUri)
{
- type = PAYLOAD_TYPE_DEVICE;
+ char targetUri[MAX_URI_LENGTH];
+ snprintf(targetUri, MAX_URI_LENGTH, "%s?rt=%s", OC_RSRVD_RD_URI,
+ OC_RSRVD_RESOURCE_TYPE_RDPUBLISH);
+ if (strcmp(targetUri, cbNode->requestUri) == 0)
+ {
+ type = PAYLOAD_TYPE_RD;
+ }
+ else if (strcmp(OC_RSRVD_PLATFORM_URI, cbNode->requestUri) == 0)
+ {
+ type = PAYLOAD_TYPE_PLATFORM;
+ }
+ else if (strcmp(OC_RSRVD_DEVICE_URI, cbNode->requestUri) == 0)
+ {
+ type = PAYLOAD_TYPE_DEVICE;
+ }
+ if (type == PAYLOAD_TYPE_INVALID)
+ {
+ OIC_LOG_V(INFO, TAG, "Assuming PAYLOAD_TYPE_REPRESENTATION: %d %s",
+ cbNode->method, cbNode->requestUri);
+ type = PAYLOAD_TYPE_REPRESENTATION;
+ }
}
- if (type == PAYLOAD_TYPE_INVALID)
+ else
{
- OIC_LOG_V(INFO, TAG, "Assuming PAYLOAD_TYPE_REPRESENTATION: %d %s",
- cbNode->method, cbNode->requestUri);
+ OIC_LOG(INFO, TAG, "No Request URI, PROXY URI");
type = PAYLOAD_TYPE_REPRESENTATION;
}
}
// Validate input parameters
VERIFY_NON_NULL(cbData, FATAL, OC_STACK_INVALID_CALLBACK);
VERIFY_NON_NULL(cbData->cb, FATAL, OC_STACK_INVALID_CALLBACK);
- VERIFY_NON_NULL(requestUri , FATAL, OC_STACK_INVALID_URI);
OCStackResult result = OC_STACK_ERROR;
CAResult_t caResult;
adapter = (OCTransportAdapter)(connectivityType >> CT_ADAPTER_SHIFT);
flags = (OCTransportFlags)(connectivityType & CT_MASK_FLAGS);
- result = ParseRequestUri(requestUri, adapter, flags, &devAddr, &resourceUri, &resourceType);
- if (result != OC_STACK_OK)
+ if (requestUri)
+ {
+ result = ParseRequestUri(requestUri, adapter, flags, &devAddr, &resourceUri, &resourceType);
+ if (result != OC_STACK_OK)
+ {
+ OIC_LOG_V(DEBUG, TAG, "Unable to parse uri: %s", requestUri);
+ goto exit;
+ }
+ }
+ else if (!checkProxyUri(options, numOptions))
{
- OIC_LOG_V(DEBUG, TAG, "Unable to parse uri: %s", requestUri);
+ OIC_LOG(ERROR, TAG, "Request doesn't contain RequestURI/Proxy URI");
goto exit;
}
}
}
+#ifdef WITH_CHPROXY
+OCStackResult OCSetProxyURI(const char *uri)
+{
+ return CAResultToOCResult(CASetProxyUri(uri));
+}
+#endif
+
#if defined(RD_CLIENT) || defined(RD_SERVER)
OCStackResult OCBindResourceInsToResource(OCResourceHandle handle, uint8_t ins)
{