if (0 < securePort) //Set the remote endpoint secure details and send response
{
LOGI("This is secure resource...");
- char *uri = NULL;
- uint32_t length = 0;
-
- length = COAPS_PREFIX_LEN; //length of "coaps://"
- // length of "ipaddress:port"
- length += strlen(object->addr) + PORT_LENGTH;
- length += strlen(requestInfo->info.resourceUri) + 1;
-
- uri = calloc(1, sizeof(char) * length);
- if (!uri)
- {
- LOGE("Failed to create new uri");
- free(uri);
- return;
- }
- sprintf(uri, "%s%s:%d/%s", COAPS_PREFIX, object->addr,
- securePort, requestInfo->info.resourceUri);
CAEndpoint_t *endpoint = NULL;
if (CA_STATUS_OK != CACreateEndpoint(CA_SECURE,
object->adapter, object->addr, securePort, &endpoint))
{
LOGE("Failed to create duplicate of remote endpoint!");
- free(uri);
return;
}
object = endpoint;
-
- free(uri);
}
}
}
{
printf("This is secure resource...\n");
- //length of "coaps://"
- size_t length = COAPS_PREFIX_LEN;
-
- // length of "ipaddress:port"
- length += strlen(object->addr) + PORT_LENGTH;
- length += 1;
-
- char *uri = calloc(1, sizeof(char) * length);
- if (!uri)
- {
- printf("Failed to create new uri\n");
- return;
- }
- sprintf(uri, "%s%s:%d/", COAPS_PREFIX, object->addr,
- object->port);
-
CAEndpoint_t *endpoint = NULL;
if (CA_STATUS_OK != CACreateEndpoint(0, object->adapter, object->addr,
object->port, &endpoint))
{
printf("Failed to create duplicate of remote endpoint!\n");
- free(uri);
return;
}
endpoint->flags = CA_SECURE;
object = endpoint;
-
- free(uri);
}
}
{
printf("This is secure resource...\n");
- //length of "coaps://"
- size_t length = sizeof(SECURE_COAPS_PREFIX) - 1;
-
- // length of "ipaddress:port"
- length += strlen(object->addr) + PORT_LENGTH;
- length += 1;
-
- printf("%s%s:%d/", SECURE_COAPS_PREFIX, object->addr,
- object->port);
-
CAEndpoint_t *endpoint = NULL;
if (CA_STATUS_OK != CACreateEndpoint(0, object->adapter, object->addr,
object->port, &endpoint))