uint16_t securePort = 0;
OCResourcePayload* resPayload = ((OCDiscoveryPayload*)clientResponse->payload)->resources;
+ // Use seure port of doxm for OTM and Provision.
+ while (resPayload)
+ {
+ if (0 == strncmp(resPayload->uri, OIC_RSRC_DOXM_URI, sizeof(OIC_RSRC_DOXM_URI)))
+ {
+ OIC_LOG_V(INFO,TAG,"resPaylod->uri:%s",resPayload->uri);
+ OIC_LOG(INFO, TAG, "Found doxm resource.");
+ break;
+ }
+ else
+ {
+ resPayload = resPayload->next;
+ }
+ }
+ if (NULL == resPayload)
+ {
+ OIC_LOG(ERROR, TAG, "Can not find doxm resource.");
+ return OC_STACK_DELETE_TRANSACTION;
+ }
if (resPayload && resPayload->secure)
{
securePort = resPayload->port;
{
return OC_STACK_INVALID_PARAM;
}
-
- char rsrc_uri[MAX_URI_LENGTH+1] = {0};
- int wr_len = snprintf(rsrc_uri, sizeof(rsrc_uri), "%s?%s=%s",
- OC_RSRVD_WELL_KNOWN_URI, OC_RSRVD_RESOURCE_TYPE, OIC_RSRC_TYPE_SEC_DOXM);
- if(wr_len <= 0 || (size_t)wr_len >= sizeof(rsrc_uri))
- {
- OIC_LOG(ERROR, TAG, "rsrc_uri_string_print failed");
- return OC_STACK_ERROR;
- }
//Try to the unicast discovery to getting secure port
char query[MAX_URI_LENGTH+MAX_QUERY_LENGTH+1] = {0};
if(!PMGenerateQuery(false,
clientResponse->devAddr.addr, clientResponse->devAddr.port,
clientResponse->connType,
- query, sizeof(query), rsrc_uri))
+ query, sizeof(query), OC_RSRVD_WELL_KNOWN_URI))
{
OIC_LOG(ERROR, TAG, "SecurePortDiscovery : Failed to generate query");
return OC_STACK_ERROR;
//of other devices which the client trusts
static char CRED_FILE_DEVOWNER[] = "oic_svr_db_client_devowner.dat";
static char CRED_FILE_NONDEVOWNER[] = "oic_svr_db_client_nondevowner.dat";
-
+const char * OIC_RSRC_DOXM_URI = "/oic/sec/doxm";
int gQuitFlag = 0;
{
coapServerResource.assign(res->uri);
OIC_LOG_V(INFO, TAG, "Uri -- %s", coapServerResource.c_str());
-
+ if (0 == strcmp(coapServerResource.c_str(),OIC_RSRC_DOXM_URI))
+ {
+ OIC_LOG(INFO,TAG,"Skip: doxm is secure virtual resource");
+ res = res->next;
+ continue;
+ }
if (res->secure)
{
+ OIC_LOG_V(INFO,TAG,"SECUREPORT: %d",res->port);
endpoint.port = res->port;
coapSecureResource = 1;
}