uint16_t securePort; /**< secure port **/
#ifdef WITH_TCP
uint16_t tcpPort; /**< tcp port **/
+ uint16_t tcpSecurePort; /**< secure tcp port **/
#endif
char secVer[OIC_SEC_MAX_VER_LEN]; /**< security version **/
DeviceStatus devStatus; /**< status of device **/
lst->connType |= CT_ADAPTER_TCP; //set TCP flag
lst->endpoint.adapter = OC_ADAPTER_TCP;
lst->endpoint.port = lst->tcpPort;
- lst->securePort = lst->tcpPort;
+ lst->securePort = lst->tcpSecurePort;
}
lst = lst->next;
}
#ifdef WITH_TCP
else if (CA_ADAPTER_TCP == endpoint.adapter)
{
- endpoint.port = selectedDeviceInfo->tcpPort;
+ endpoint.port = selectedDeviceInfo->tcpSecurePort;
}
#endif
#ifdef WITH_TCP
else if (CA_ADAPTER_TCP == endpoint.adapter)
{
- endpoint.port = selectedDeviceInfo->tcpPort;
+ endpoint.port = selectedDeviceInfo->tcpSecurePort;
}
#endif
#ifdef WITH_TCP
else if (CA_ADAPTER_TCP == endpoint.adapter)
{
- endpoint.port = deviceInfo->tcpPort;
+ endpoint.port = deviceInfo->tcpSecurePort;
}
#endif
#ifdef WITH_TCP
else if (CA_ADAPTER_TCP == endpoint.adapter)
{
- endpoint.port = selDevInfo->tcpPort;
+ endpoint.port = selDevInfo->tcpSecurePort;
}
#endif
#ifdef WITH_TCP
else if (CA_ADAPTER_TCP == endpoint.adapter)
{
- endpoint.port = selDevInfo->tcpPort;
+ endpoint.port = selDevInfo->tcpSecurePort;
}
#endif
#ifdef WITH_TCP
else if (CA_ADAPTER_TCP == endpoint.adapter)
{
- endpoint.port = selDevInfo->tcpPort;
+ endpoint.port = selDevInfo->tcpSecurePort;
}
#endif
#ifdef WITH_TCP
else if (CA_ADAPTER_TCP == endpoint.adapter)
{
- endpoint.port = selDevInfo->tcpPort;
+ endpoint.port = selDevInfo->tcpSecurePort;
}
#endif
uint16_t port, uint16_t securePort
#ifdef __WITH_TLS__
,uint16_t tcpPort
+ ,uint16_t tcpSecurePort
#endif
)
{
#ifdef __WITH_TLS__
ptr->tcpPort = tcpPort;
+ ptr->tcpSecurePort = tcpSecurePort;
#endif
return OC_STACK_OK;
}
uint16_t securePort = 0;
+#ifdef __WITH_TLS__
+ uint16_t tcpPort = 0;
+ uint16_t tcpSecurePort = 0;
+#endif
OCResourcePayload* resPayload = ((OCDiscoveryPayload*)clientResponse->payload)->resources;
// Use seure port of doxm for OTM and Provision.
}
eps = eps->next;
}
+#ifdef __WITH_TLS__
+ eps = resPayload->eps;
+ while (eps != NULL)
+ {
+ if ((eps->family & OC_FLAG_SECURE) &&
+ ((OC_IP_USE_V6 == clientResponse->devAddr.flags &&
+ strchr(eps->addr, ':')) ||
+ (OC_IP_USE_V4 == clientResponse->devAddr.flags &&
+ strchr(eps->addr, '.'))) &&
+ 0 == strncmp(eps->tps, COAPS_TCP_PREFIX, strlen(COAPS_TCP_PREFIX)-3))
+ {
+ tcpSecurePort = eps->port;
+ break;
+ }
+ eps = eps->next;
+ }
+ eps = resPayload->eps;
+ while (eps != NULL)
+ {
+ if(((OC_IP_USE_V6 == clientResponse->devAddr.flags && strchr(eps->addr, ':')) ||
+ (OC_IP_USE_V4 == clientResponse->devAddr.flags && strchr(eps->addr, '.'))) &&
+ 0 == strncmp(eps->tps, COAP_TCP_PREFIX, strlen(COAP_TCP_PREFIX)-3)
+ )
+ {
+ tcpPort = eps->port;
+ break;
+ }
+ eps = eps->next;
+ }
+#endif
if (!securePort)
{
OIC_LOG(INFO, TAG, "Can not find secure port information.");
return OC_STACK_DELETE_TRANSACTION;
}
+ else
+ {
+ OIC_LOG_V(INFO, TAG, "%s: secure port: %d", __func__, securePort);
+ }
}
else
{
clientResponse->devAddr.port,
securePort
#ifdef __WITH_TLS__
- ,resPayload->tcpPort
+ ,tcpPort
+ ,tcpSecurePort
#endif
);
if (OC_STACK_OK != res)
// Set the value of context->resourceUri, based on the context->requestInfo.
static void SetResourceUriAndType(SRMRequestContext_t *context)
{
+ if (NULL == context || NULL == context->requestInfo ||
+ NULL == context->requestInfo->info.resourceUri)
+ {
+ OIC_LOG_V(INFO, TAG, "%s : %s is NULL", __func__,
+ (NULL == context) ? "context" :
+ (NULL == context->requestInfo) ? "context->requestInfo" :
+ "context->requestInfo->info.resourceUri");
+ return;
+ }
+
char *uri = strstr(context->requestInfo->info.resourceUri, "?");
size_t position = 0;