Commit f2c00012 authored by Joonghwan Lee's avatar Joonghwan Lee Committed by Dan Mihai

Add adapter type parameter to CAcloseSslConnectionAll

Adapter(Transport) type parameter is added to CAcloseSslConnectionAll function
in order to enable sessions related to the only specified transport type to be closed.

Patch 1: Initial upload
Patch 2: Fixed print format

Change-Id: I3bb658cf4c90e0e283a0b052f69f1fa8b593e748
Signed-off-by: default avatarJoonghwan Lee <jh05.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/17139Tested-by: default avatarjenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: default avatarDan Mihai <Daniel.Mihai@microsoft.com>
parent cc6ee8f2
......@@ -246,7 +246,7 @@ CAResult_t CAcloseSslConnection(const CAEndpoint_t *endpoint);
/**
* Close All of DTLS sessions.
*/
void CAcloseSslConnectionAll();
void CAcloseSslConnectionAll(CATransportAdapter_t transportType);
#ifdef __cplusplus
} /* extern "C" */
......
......@@ -1080,7 +1080,7 @@ CAResult_t CAcloseSslConnection(const CAEndpoint_t *endpoint)
return CA_STATUS_OK;
}
void CAcloseSslConnectionAll()
void CAcloseSslConnectionAll(CATransportAdapter_t transportType)
{
OIC_LOG_V(DEBUG, NET_SSL_TAG, "In %s", __func__);
oc_mutex_lock(g_sslContextMutex);
......@@ -1092,15 +1092,24 @@ void CAcloseSslConnectionAll()
}
uint32_t listLength = u_arraylist_length(g_caSslContext->peerList);
OIC_LOG_V(DEBUG, NET_SSL_TAG,
"Required transport [%d], peer count [%u]", transportType, listLength);
for (uint32_t i = listLength; i > 0; i--)
{
SslEndPoint_t *tep = (SslEndPoint_t *)u_arraylist_remove(g_caSslContext->peerList, i - 1);
SslEndPoint_t *tep = (SslEndPoint_t *)u_arraylist_get(g_caSslContext->peerList, i - 1);
if (NULL == tep)
{
continue;
}
OIC_LOG_V(DEBUG, NET_SSL_TAG, "SSL Connection [%s:%d]",
tep->sep.endpoint.addr, tep->sep.endpoint.port);
OIC_LOG_V(DEBUG, NET_SSL_TAG, "SSL Connection [%s:%d], Transport [%d]",
tep->sep.endpoint.addr, tep->sep.endpoint.port, tep->sep.endpoint.adapter);
// check transport matching
if (0 == (tep->sep.endpoint.adapter & transportType))
{
OIC_LOG(DEBUG, NET_SSL_TAG, "Skip the un-matched transport session");
continue;
}
// TODO: need to check below code after socket close is ensured.
/*int ret = 0;
......@@ -1110,6 +1119,8 @@ void CAcloseSslConnectionAll()
}
while (MBEDTLS_ERR_SSL_WANT_WRITE == ret);*/
// delete from list
u_arraylist_remove(g_caSslContext->peerList, i - 1);
DeleteSslEndPoint(tep);
}
oc_mutex_unlock(g_sslContextMutex);
......
......@@ -176,7 +176,7 @@ void CAIPAdapterHandler(CATransportAdapter_t adapter, CANetworkStatus_t status)
OIC_LOG(DEBUG, TAG, "Network status for IP is down");
#ifdef __WITH_DTLS__
OIC_LOG(DEBUG, TAG, "close all ssl session");
CAcloseSslConnectionAll();
CAcloseSslConnectionAll(CA_ADAPTER_IP);
#endif
}
}
......
......@@ -1444,7 +1444,7 @@ void CATCPDisconnectAll()
oc_mutex_unlock(g_mutexObjectList);
#ifdef __WITH_TLS__
CAcloseSslConnectionAll();
CAcloseSslConnectionAll(CA_ADAPTER_TCP);
#endif
}
......
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