Commit 9bd16bcf authored by Dmitriy Zhuravlev's avatar Dmitriy Zhuravlev Committed by Randeep

[IOT-2156] Fix secure client stack sample

Update sample to use IoTivity 1.3 OCEndpointPayload format

Change-Id: I5094d504f3dfe69622eecb767039480c27ab03df
Signed-off-by: default avatarDmitriy Zhuravlev <d.zhuravlev@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/19365Reviewed-by: default avatarAndrii Shtompel <a.shtompel@samsung.com>
Reviewed-by: default avatarKevin Kane <kkane@microsoft.com>
Tested-by: default avatarjenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Randeep's avatarRandeep Singh <randeep.s@samsung.com>
parent 63e74d89
......@@ -63,8 +63,14 @@ static OCConnectivityType ocConnType;
//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";
const char *OIC_RSRC_PSTAT_URI = "/oic/sec/pstat";
//Standard uri prefix for secure virtual resources
const char * OIC_STD_URI_PREFIX = "/oic/";
const char * COAPS_STR = "coaps";
#ifdef __WITH_TLS__
const char * COAPS_TCP_STR = "coaps+tcp";
#endif
int gQuitFlag = 0;
......@@ -458,41 +464,51 @@ int parseClientResponse(OCClientResponse *clientResponse)
{
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 (0 == strcmp(coapServerResource.c_str(), OIC_RSRC_PSTAT_URI))
if (0 == strncmp(coapServerResource.c_str(), OIC_STD_URI_PREFIX, strlen(OIC_STD_URI_PREFIX)))
{
OIC_LOG(INFO, TAG, "Skip: pstat is secure virtual resource");
OIC_LOG(INFO, TAG, "Skip resource");
res = res->next;
continue;
}
OCDevAddr *endpoint = &clientResponse->devAddr;
if (WithTcp)
if (res && res->eps)
{
#ifdef TCP_ADAPTER
endpoint->adapter = OC_ADAPTER_TCP;
#endif
}
if (res->secure)
{
endpoint->flags = (OCTransportFlags)(endpoint->flags | OC_SECURE);
if (WithTcp)
endpoint->port = 0;
OCEndpointPayload* eps = res->eps;
while (NULL != eps)
{
#ifdef TCP_ADAPTER
OIC_LOG_V(INFO, TAG, "SECUREPORT tcp: %d", res->tcpPort);
endpoint->port = res->tcpPort;
if (eps->family & OC_FLAG_SECURE)
{
#ifdef __WITH_TLS__
if (WithTcp && 0 == strcmp(eps->tps, COAPS_TCP_STR))
{
strncpy(endpoint->addr, eps->addr, sizeof(endpoint->addr));
endpoint->port = eps->port;
endpoint->flags = (OCTransportFlags)(eps->family | OC_SECURE);
endpoint->adapter = OC_ADAPTER_TCP;
coapSecureResource = 1;
OIC_LOG_V(INFO, TAG, "TLS port: %d", endpoint->port);
break;
}
#endif
if (!WithTcp && 0 == strcmp(eps->tps, COAPS_STR))
{
strncpy(endpoint->addr, eps->addr, sizeof(endpoint->addr));
endpoint->port = eps->port;
endpoint->flags = (OCTransportFlags)(eps->family | OC_SECURE);
endpoint->adapter = OC_ADAPTER_IP;
coapSecureResource = 1;
OIC_LOG_V(INFO, TAG, "DTLS port: %d", endpoint->port);
}
}
eps = eps->next;
}
else
if (!endpoint->port)
{
OIC_LOG_V(INFO, TAG, "SECUREPORT udp: %d", res->port);
endpoint->port = res->port;
OIC_LOG(INFO, TAG, "Can not find secure port information.");
}
coapSecureResource = 1;
}
OIC_LOG_V(INFO, TAG, "Secure -- %s", coapSecureResource == 1 ? "YES" : "NO");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment