out->flags = CAToOCTransportFlags(in->flags);
OICStrcpy(out->addr, sizeof(out->addr), in->addr);
out->port = in->port;
+ out->interface = in->interface;
}
void CopyDevAddrToEndpoint(const OCDevAddr *in, CAEndpoint_t *out)
out->flags = OCToCATransportFlags(in->flags);
OICStrcpy(out->addr, sizeof(out->addr), in->addr);
out->port = in->port;
-}
-
-static OCStackResult OCCreateEndpoint(OCDevAddr *devAddr, CAEndpoint_t **endpoint)
-{
- VERIFY_NON_NULL(devAddr, FATAL, OC_STACK_INVALID_PARAM);
- VERIFY_NON_NULL(endpoint, FATAL, OC_STACK_INVALID_PARAM);
-
- CAEndpoint_t *ep = (CAEndpoint_t *)OICMalloc(sizeof (CAEndpoint_t));
- if (!ep)
- {
- return OC_STACK_NO_MEMORY;
- }
-
- ep->adapter = (CATransportAdapter_t)devAddr->adapter;
- if (!ep->adapter)
- {
- ep->adapter = CA_ADAPTER_IP;
- }
- ep->flags = OCToCATransportFlags(devAddr->flags);
- OICStrcpy(ep->addr, sizeof(ep->addr), devAddr->addr);
- ep->port = devAddr->port;
-
- *endpoint = ep;
-
- return OC_STACK_OK;
-}
-
-static void OCDestroyEndpoint(CAEndpoint_t *endpoint)
-{
- free(endpoint);
+ out->interface = in->interface;
}
void FixUpClientResponse(OCClientResponse *cr)
uint8_t tokenLength = CA_MAX_TOKEN_LEN;
ClientCB *clientCB = NULL;
OCDoHandle resHandle = NULL;
- CAEndpoint_t *endpoint = NULL;
+ CAEndpoint_t endpoint = {.adapter = CA_DEFAULT_ADAPTER};
OCDevAddr tmpDevAddr = { OC_DEFAULT_ADAPTER };
uint32_t ttl = 0;
OCTransportAdapter adapter;
requestInfo.info.numOptions = numOptions;
}
- // create remote endpoint
- result = OCCreateEndpoint(devAddr, &endpoint);
+ CopyDevAddrToEndpoint(devAddr, &endpoint);
+
if(payload)
{
if((result =
requestInfo.info.payloadSize = 0;
}
-
-
if (result != OC_STACK_OK)
{
OC_LOG(ERROR, TAG, PCF("CACreateEndpoint error"));
if (method == OC_REST_PRESENCE)
{
char *presenceUri = NULL;
- result = OCPreparePresence(endpoint, resourceUri, &presenceUri);
+ result = OCPreparePresence(&endpoint, resourceUri, &presenceUri);
if (OC_STACK_OK != result)
{
goto exit;
resourceType = NULL; // Client CB list entry now owns it
// send request
- caResult = CASendRequest(endpoint, &requestInfo);
+ caResult = CASendRequest(&endpoint, &requestInfo);
if (caResult != CA_STATUS_OK)
{
OC_LOG(ERROR, TAG, PCF("CASendRequest"));
OICFree(devAddr);
OICFree(resourceUri);
OICFree(resourceType);
- OICFree(endpoint);
if (hdrOptionMemAlloc)
{
OICFree(requestInfo.info.options);
* Remove the callback associated on client side.
*/
OCStackResult ret = OC_STACK_OK;
- CAEndpoint_t* endpoint = NULL;
+ CAEndpoint_t endpoint = {.adapter = CA_DEFAULT_ADAPTER};
CAResult_t caResult;
CAInfo_t requestData = {.type = CA_MSG_CONFIRM};
CARequestInfo_t requestInfo = {.method = CA_GET};
requestInfo.method = CA_GET;
requestInfo.info = requestData;
- ret = OCCreateEndpoint(clientCB->devAddr, &endpoint);
- if (ret != OC_STACK_OK)
- {
- OC_LOG(ERROR, TAG, PCF("CACreateEndpoint error"));
- goto Error;
- }
+ CopyDevAddrToEndpoint(clientCB->devAddr, &endpoint);
// send request
- caResult = CASendRequest(endpoint, &requestInfo);
+ caResult = CASendRequest(&endpoint, &requestInfo);
if (caResult != CA_STATUS_OK)
{
OC_LOG(ERROR, TAG, PCF("CASendRequest error"));
}
Error:
- OCDestroyEndpoint(endpoint);
if (requestData.numOptions > 0)
{
OICFree(requestData.options);
{
OICFree (requestData.resourceUri);
}
-
return ret;
}
}
CAResult_t caResult = CA_STATUS_OK;
- CAEndpoint_t* endpoint = NULL;
+ CAEndpoint_t endpoint = {.adapter = CA_DEFAULT_ADAPTER};
CAInfo_t requestData = {.type = CA_MSG_CONFIRM};
CARequestInfo_t requestInfo = {.method = CA_GET};
OC_LOG(DEBUG, TAG, PCF("time to test server presence"));
- result = OCCreateEndpoint(cbNode->devAddr, &endpoint);
- if (result != OC_STACK_OK)
- {
- OC_LOG(ERROR, TAG, PCF("CACreateEndpoint error"));
- goto exit;
- }
+ CopyDevAddrToEndpoint(cbNode->devAddr, &endpoint);
requestData.type = CA_MSG_NONCONFIRM;
requestData.token = cbNode->token;
requestInfo.method = CA_GET;
requestInfo.info = requestData;
- caResult = CASendRequest(endpoint, &requestInfo);
- OCDestroyEndpoint(endpoint);
+ caResult = CASendRequest(&endpoint, &requestInfo);
if (caResult != CA_STATUS_OK)
{
{
OC_LOG(ERROR, TAG, PCF("OCProcessPresence error"));
}
+
return result;
}
#endif // WITH_PRESENCE