+ strcpy(*requestUri, uri);
+ return OC_STACK_OK;
+}
+
+/**
+ * Discover or Perform requests on a specified resource
+ */
+OCStackResult OCDoResource(OCDoHandle *handle,
+ OCMethod method,
+ const char *requestUri,
+ const OCDevAddr *destination,
+ OCPayload* payload,
+ OCConnectivityType connectivityType,
+ OCQualityOfService qos,
+ OCCallbackData *cbData,
+ OCHeaderOption *options,
+ uint8_t numOptions)
+{
+ OC_LOG(INFO, TAG, PCF("Entering OCDoResource"));
+
+ // 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;
+ CAToken_t token = NULL;
+ uint8_t tokenLength = CA_MAX_TOKEN_LEN;
+ ClientCB *clientCB = NULL;
+ OCDoHandle resHandle = NULL;
+ CAEndpoint_t *endpoint = NULL;
+ OCDevAddr tmpDevAddr = { OC_DEFAULT_ADAPTER };
+ uint32_t ttl = 0;
+ OCTransportAdapter adapter;
+ OCTransportFlags flags;
+ // the request contents are put here
+ CARequestInfo_t requestInfo = { CA_GET };
+ // requestUri will be parsed into the following three variables
+ OCDevAddr *devAddr = NULL;
+ char *resourceUri = NULL;
+ char *resourceType = NULL;
+
+ // To track if memory is allocated for additional header options
+ uint8_t hdrOptionMemAlloc = 0;
+
+ // This validation is broken, but doesn't cause harm
+ size_t uriLen = strlen(requestUri );
+ if ((result = verifyUriQueryLength(requestUri , uriLen)) != OC_STACK_OK)