X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=resource%2Fcsdk%2Fconnectivity%2Fsrc%2Fbt_le_adapter%2Fcaleadapter.c;h=5f4904cd045adfb456016fa665e60e94193dd50e;hb=refs%2Ftags%2Fsubmit%2Ftizen%2F20171214.102437;hp=6c9d09ed55917f248bd6c61e708e6eea5edf06eb;hpb=55283efd23d570e22010e2a403adea20d16210b9;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c b/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c index 6c9d09e..5f4904c 100755 --- a/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c +++ b/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c @@ -170,7 +170,7 @@ static CANetworkPacketReceivedCallback g_networkPacketReceivedCallback = NULL; static CAErrorHandleCallback g_errorHandler = NULL; #ifdef __WITH_DTLS__ -static void CALESecureReceiveDataCB(const CASecureEndpoint_t *endpoint, +static CAResult_t CALESecureReceiveDataCB(const CASecureEndpoint_t *endpoint, const void *data, size_t dataLength); static ssize_t CALESecureSendDataCB(CAEndpoint_t *endpoint, @@ -1245,8 +1245,8 @@ static void CALEServerSendDataThread(void *threadData) "CAGenerateVariableForFragmentation failed, result [%d]", result); if (g_errorHandler) { - g_errorHandler(bleData->remoteEndpoint, bleData->data, bleData->dataLen, result); - } + g_errorHandler(bleData->remoteEndpoint, bleData->data, bleData->dataLen, result); + } return; } @@ -1519,7 +1519,7 @@ static void CALEClientSendDataThread(void *threadData) CALEADAPTER_TAG, "CALEClientSendNegotiationMessage has failed, result [%d]", res); - if (g_errorHandler) + if (g_errorHandler) { g_errorHandler(bleData->remoteEndpoint, bleData->data, @@ -1725,7 +1725,7 @@ static void CALEClientSendDataThread(void *threadData) CALEADAPTER_TAG, "Update characteristics failed, result [%d]", result); - if (g_errorHandler) + if (g_errorHandler) { g_errorHandler(bleData->remoteEndpoint, bleData->data, bleData->dataLen, result); } @@ -2653,13 +2653,13 @@ static ssize_t CALESecureSendDataCB(CAEndpoint_t *endpoint, const void *data, si return ret; } -void CALESecureReceiveDataCB(const CASecureEndpoint_t *sep, const void *data, +CAResult_t CALESecureReceiveDataCB(const CASecureEndpoint_t *sep, const void *data, size_t dataLen) { OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "%s", __func__); - VERIFY_NON_NULL_VOID(sep, CALEADAPTER_TAG, "sep is NULL"); - VERIFY_NON_NULL_VOID(data, CALEADAPTER_TAG, "data is NULL"); + VERIFY_NON_NULL(sep, CALEADAPTER_TAG, "sep is NULL"); + VERIFY_NON_NULL(data, CALEADAPTER_TAG, "data is NULL"); OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "Secure Data Receive - decrypted datalen = %d", dataLen); @@ -2667,11 +2667,12 @@ void CALESecureReceiveDataCB(const CASecureEndpoint_t *sep, const void *data, if (dataLen <= 0) { OIC_LOG(ERROR, CALEADAPTER_TAG, "incorrect dataLen, derecypt fail !"); - return; + return CA_STATUS_INVALID_PARAM; } OIC_LOG_BUFFER(DEBUG, CALEADAPTER_TAG, data, dataLen); + CAResult_t res = CA_STATUS_OK; if (g_networkPacketReceivedCallback) { OIC_LOG_V(DEBUG, CALEADAPTER_TAG, @@ -2679,8 +2680,13 @@ void CALESecureReceiveDataCB(const CASecureEndpoint_t *sep, const void *data, sep->endpoint.flags, sep->endpoint.flags); OIC_LOG(DEBUG, CALEADAPTER_TAG, "[CALESecureReceiveDataCB] Received data up !"); - g_networkPacketReceivedCallback(sep, data, dataLen); + res = g_networkPacketReceivedCallback(sep, data, dataLen); + if (CA_STATUS_OK != res) + { + OIC_LOG_V(ERROR, CALEADAPTER_TAG, "Error parsing CoAP data, res = %d", res); + } } + return res; } #endif @@ -3002,7 +3008,7 @@ static int32_t CASendLEUnicastData(const CAEndpoint_t *endpoint, g_dataType = dataType; oc_mutex_unlock(g_bleIsServerMutex); - result = CAencryptSsl(endpoint, data, dataLen); + result = CAencryptSsl(endpoint, (void *)data, dataLen); if (CA_STATUS_OK != result) { OIC_LOG(ERROR, CALEADAPTER_TAG, "caadapternetdtlsencrypt failed!"); @@ -3044,7 +3050,7 @@ static int32_t CASendLEUnicastData(const CAEndpoint_t *endpoint, g_dataType = dataType; oc_mutex_unlock(g_bleIsServerMutex); - result = CAencryptSsl(endpoint, data, dataLen); + result = CAencryptSsl(endpoint, (void *)data, dataLen); if (CA_STATUS_OK != result) { OIC_LOG(ERROR, CALEADAPTER_TAG, "caadapternetdtlsencrypt failed!");