Commit 80c1ca83 authored by Joonghwan Lee's avatar Joonghwan Lee Committed by Randeep

Added CAcloseSslConnectionAll() in ssl adapter

added api to close all of ssl connections

Change-Id: I2bcd1890a70ba64fd7f4cc33e6a1dfcbf6590050
Signed-off-by: default avatarJoonghwan Lee <jh05.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/13953Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarJihun Ha <jihun.ha@samsung.com>
Reviewed-by: default avatarChul Lee <chuls.lee@samsung.com>
Reviewed-by: Randeep's avatarRandeep Singh <randeep.s@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14357
parent ce1a6187
......@@ -239,6 +239,12 @@ CAResult_t CAinitiateSslHandshake(const CAEndpoint_t *endpoint);
*/
CAResult_t CAcloseSslConnection(const CAEndpoint_t *endpoint);
/**
* Close All of DTLS sessions.
*/
void CAcloseSslConnectionAll();
#ifdef __cplusplus
} /* extern "C" */
#endif
......
......@@ -958,6 +958,44 @@ CAResult_t CAcloseSslConnection(const CAEndpoint_t *endpoint)
OIC_LOG_V(DEBUG, NET_SSL_TAG, "Out %s", __func__);
return CA_STATUS_OK;
}
void CAcloseSslConnectionAll()
{
OIC_LOG_V(DEBUG, NET_SSL_TAG, "In %s", __func__);
oc_mutex_lock(g_sslContextMutex);
if (NULL == g_caSslContext)
{
OIC_LOG(ERROR, NET_SSL_TAG, "Context is NULL");
oc_mutex_unlock(g_sslContextMutex);
return;
}
uint32_t listLength = u_arraylist_length(g_caSslContext->peerList);
for (uint32_t i = listLength; i > 0; i--)
{
SslEndPoint_t *tep = (SslEndPoint_t *)u_arraylist_remove(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);
// TODO: need to check below code after socket close is ensured.
/*int ret = 0;
do
{
ret = mbedtls_ssl_close_notify(&tep->ssl);
}
while (MBEDTLS_ERR_SSL_WANT_WRITE == ret);*/
DeleteSslEndPoint(tep);
}
oc_mutex_unlock(g_sslContextMutex);
OIC_LOG_V(DEBUG, NET_SSL_TAG, "Out %s", __func__);
return;
}
/**
* Creates session for endpoint.
*
......
......@@ -1203,16 +1203,12 @@ void CATCPDisconnectAll()
{
oc_mutex_lock(g_mutexObjectList);
uint32_t length = u_arraylist_length(caglobals.tcp.svrlist);
CATCPSessionInfo_t *svritem = NULL;
for (size_t i = 0; i < length; i++)
{
svritem = (CATCPSessionInfo_t *) u_arraylist_get(caglobals.tcp.svrlist, i);
if (svritem && svritem->fd >= 0)
{
#ifdef __WITH_TLS__
CAcloseSslConnection(&svritem->sep.endpoint);
#endif
shutdown(svritem->fd, SHUT_RDWR);
close(svritem->fd);
OICFree(svritem->data);
......@@ -1228,6 +1224,11 @@ void CATCPDisconnectAll()
u_arraylist_destroy(caglobals.tcp.svrlist);
caglobals.tcp.svrlist = NULL;
oc_mutex_unlock(g_mutexObjectList);
#ifdef __WITH_TLS__
CAcloseSslConnectionAll();
#endif
}
CATCPSessionInfo_t *CAGetTCPSessionInfoFromEndpoint(const CAEndpoint_t *endpoint, size_t *index)
......
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