CA_NOT_SUPPORTED, /**< Not supported */
CA_STATUS_NOT_INITIALIZED, /**< Not Initialized*/
CA_DTLS_AUTHENTICATION_FAILURE, /**< Decryption error in DTLS */
+ CA_CONTINUE_OPERATION, /**< Error happens but current operation should continue */
+ CA_HANDLE_ERROR_OTHER_MODULE, /**< Error happens but it should be handled in other module */
CA_STATUS_FAILED =255 /**< Failure */
/* Result code - END HERE */
} CAResult_t;
const CAErrorInfo_t *errorInfo);
/**
+ * Callback function type for error.
+ * @param[out] object remote device information.
+ * @param[out] result error information.
+ */
+typedef CAResult_t (*CAHandshakeErrorCallback)(const CAEndpoint_t *object,
+ const CAErrorInfo_t *errorInfo);
+
+/**
* Callback function type for network status changes delivery from CA common logic.
* @param[out] info Endpoint object from which the network status is changed.
* It contains endpoint address based on the connectivity type.
* @param[in] tlsHandshakeCallback callback for get tls handshake result
* @return ::CA_STATUS_OK
*/
-CAResult_t CAregisterSslHandshakeCallback(CAErrorCallback tlsHandshakeCallback);
+CAResult_t CAregisterSslHandshakeCallback(CAHandshakeErrorCallback tlsHandshakeCallback);
/**
* Register callback to get TLS PSK credentials.
#include "caadapterutils.h"
#include "cainterface.h"
+#include "caadapterinterface.h"
/**
* Currently TLS supported adapters(3) WIFI, ETHENET and BLE for linux platform.
CAResult_t CAsetTlsCipherSuite(const uint32_t cipher);
/**
- * Used set send and recv callbacks for different adapters(WIFI,EtherNet).
+ * Used set send,recv and error callbacks for different adapters(WIFI,EtherNet).
*
* @param[in] recvCallback packet received callback.
* @param[in] sendCallback packet sent callback.
+ * @param[in] errorCallback packet error callback.
* @param[in] type type of adapter.
*
*/
void CAsetSslAdapterCallbacks(CAPacketReceivedCallback recvCallback,
CAPacketSendCallback sendCallback,
+ CAErrorHandleCallback errorCallback,
CATransportAdapter_t type);
/**
* Register callback to deliver the result of TLS handshake
* @param[in] tlsHandshakeCallback Callback to receive the result of TLS handshake.
*/
-void CAsetSslHandshakeCallback(CAErrorCallback tlsHandshakeCallback);
+void CAsetSslHandshakeCallback(CAHandshakeErrorCallback tlsHandshakeCallback);
/**
* Generate ownerPSK using PRF
(ret) = mbedtls_ssl_close_notify(&(peer)->ssl); \
} while (MBEDTLS_ERR_SSL_WANT_WRITE == (ret))
-/**@def SSL_RES(peer, status)
- *
- * Sets SSL result for callback.
- *
- * @param[in] peer remote peer
- */
-#define SSL_RES(peer, status) \
-do \
-{ \
- oc_mutex_assert_owner(g_sslContextMutex, true); \
- if (g_sslCallback) \
- { \
- CAErrorInfo_t errorInfo; \
- errorInfo.result = (status); \
- g_sslCallback(&(peer)->sep.endpoint, &errorInfo); \
- } \
-} while(false)
-
/* OCF-defined EKU value indicating an identity certificate, that can be used for
* TLS client and server authentication. This is the DER encoding of the OID
* 1.3.6.1.4.1.44924.1.6.
{
CAPacketReceivedCallback recvCallback; /**< Callback used to send data to upper layer. */
CAPacketSendCallback sendCallback; /**< Callback used to send data to socket layer. */
+ CAErrorHandleCallback errorCallback; /**< Callback used to pass error to upper layer. */
} SslCallbacks_t;
/**
* @var g_sslCallback
* @brief callback to deliver the TLS handshake result
*/
-static CAErrorCallback g_sslCallback = NULL;
+static CAHandshakeErrorCallback g_sslCallback = NULL;
/**
* Data structure for holding the data to be received.
OIC_LOG_V(DEBUG, NET_SSL_TAG, "Out %s", __func__);
}
+/**
+ * Sets SSL result for callback.
+ *
+ * @param[in] peer remote peer
+ */
+static CAResult_t notifySubscriber(SslEndPoint_t* peer, CAResult_t status)
+{
+ CAResult_t result = CA_STATUS_OK;
+ oc_mutex_assert_owner(g_sslContextMutex, true);
+ if (g_sslCallback)
+ {
+ CAErrorInfo_t errorInfo;
+ errorInfo.result = status;
+ result = g_sslCallback(&peer->sep.endpoint, &errorInfo);
+ }
+ return result;
+}
+
static int GetAdapterIndex(CATransportAdapter_t adapter)
{
switch (adapter)
return -1;
}
}
+
+static void SendCacheMessages(SslEndPoint_t * tep, CAResult_t errorCode);
+
/**
* Write callback.
*
OIC_LOG_V(DEBUG, NET_SSL_TAG, "Out %s", __func__);
}
+
+static CAResult_t ConvertMbedtlsCodesToCAResult(int code)
+{
+ //TODO:properly implement
+ switch (code)
+ {
+ case 0: return CA_STATUS_OK;
+ default: return CA_DTLS_AUTHENTICATION_FAILURE;
+ }
+}
+
/**
* Deletes endpoint with session.
*
OIC_LOG_V(ERROR, NET_SSL_TAG, "%s: -0x%x", (str), -ret);
// Make a copy of the endpoint, because the callback might
- // free the peer object, during SSL_RES() below.
+ // free the peer object, during notifySubscriber() below.
CAEndpoint_t removedEndpoint = (peer)->sep.endpoint;
oc_mutex_lock(g_sslContextMutex);
if (MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO != ret)
{
- SSL_RES((peer), CA_DTLS_AUTHENTICATION_FAILURE);
+ CAResult_t result = notifySubscriber(peer, CA_DTLS_AUTHENTICATION_FAILURE);
+
+ //return an error to app layer
+ if (MBEDTLS_SSL_IS_CLIENT == peer->ssl.conf->endpoint)
+ {
+ if (CA_STATUS_OK == result)
+ {
+ result = ConvertMbedtlsCodesToCAResult(ret);
+ }
+
+ SendCacheMessages(peer, result);
+ }
}
RemovePeerFromList(&removedEndpoint);
*
* @param[in] tep remote address with session info
*/
-static void SendCacheMessages(SslEndPoint_t * tep)
+static void SendCacheMessages(SslEndPoint_t * tep, CAResult_t errorCode)
{
OIC_LOG_V(DEBUG, NET_SSL_TAG, "In %s", __func__);
VERIFY_NON_NULL_VOID(tep, NET_SSL_TAG, "Param tep is NULL");
+ CAErrorHandleCallback sendError = NULL;
+ if (errorCode != CA_STATUS_OK)
+ {
+ int adapterIndex = GetAdapterIndex(tep->sep.endpoint.adapter);
+ if (adapterIndex >= 0)
+ {
+ sendError = g_caSslContext->adapterCallbacks[adapterIndex].errorCallback;
+ }
+ }
+
size_t listIndex = 0;
size_t listLength = 0;
listLength = u_arraylist_length(tep->cacheList);
SslCacheMessage_t * msg = (SslCacheMessage_t *) u_arraylist_get(tep->cacheList, listIndex);
if (NULL != msg && NULL != msg->data && 0 != msg->len)
{
- unsigned char *dataBuf = (unsigned char *)msg->data;
- size_t written = 0;
-
- do
+ if (CA_STATUS_OK == errorCode)
{
- ret = mbedtls_ssl_write(&tep->ssl, dataBuf, msg->len - written);
- if (ret < 0)
+ unsigned char *dataBuf = (unsigned char *)msg->data;
+ size_t written = 0;
+
+ do
{
- if (MBEDTLS_ERR_SSL_WANT_WRITE != ret)
+ ret = mbedtls_ssl_write(&tep->ssl, dataBuf, msg->len - written);
+ if (ret < 0)
{
- OIC_LOG_V(ERROR, NET_SSL_TAG, "mbedTLS write failed! returned -0x%x", -ret);
- break;
+ if (MBEDTLS_ERR_SSL_WANT_WRITE != ret)
+ {
+ OIC_LOG_V(ERROR, NET_SSL_TAG, "mbedTLS write failed! returned -0x%x", -ret);
+ break;
+ }
+ continue;
}
- continue;
- }
- OIC_LOG_V(DEBUG, NET_SSL_TAG, "mbedTLS write returned with sent bytes[%d]", ret);
+ OIC_LOG_V(DEBUG, NET_SSL_TAG, "mbedTLS write returned with sent bytes[%d]", ret);
- dataBuf += ret;
- written += ret;
- } while (msg->len > written);
+ dataBuf += ret;
+ written += ret;
+ } while (msg->len > written);
+ }
+ else if (NULL != sendError)
+ {
+ //send error info via error callback to app layer
+ sendError(&tep->sep.endpoint, (uint8_t *)msg->data, msg->len, errorCode);
+ }
if (u_arraylist_remove(tep->cacheList, listIndex))
{
OIC_LOG_V(DEBUG, NET_SSL_TAG, "Out %s", __func__);
}
-void CAsetSslHandshakeCallback(CAErrorCallback tlsHandshakeCallback)
+void CAsetSslHandshakeCallback(CAHandshakeErrorCallback tlsHandshakeCallback)
{
OIC_LOG_V(DEBUG, NET_SSL_TAG, "In %s(%p)", __func__, tlsHandshakeCallback);
if (MBEDTLS_SSL_HANDSHAKE_OVER == peer->ssl.state)
{
- SSL_RES(peer, CA_STATUS_OK);
+ CAResult_t result = notifySubscriber(peer, CA_STATUS_OK);
+
if (MBEDTLS_SSL_IS_CLIENT == peer->ssl.conf->endpoint)
{
- SendCacheMessages(peer);
+ SendCacheMessages(peer, result);
}
int selectedCipher = peer->ssl.session->ciphersuite;
return CA_STATUS_OK;
}
- if (0 > ret)
+ int adapterIndex = GetAdapterIndex(peer->sep.endpoint.adapter);
+ if (adapterIndex >= 0)
{
- OIC_LOG_V(ERROR, NET_SSL_TAG, "mbedtls_ssl_read returned -0x%x", -ret);
- //SSL_RES(peer, CA_STATUS_FAILED);
- RemovePeerFromList(&peer->sep.endpoint);
- oc_mutex_unlock(g_sslContextMutex);
- return CA_STATUS_FAILED;
- }
- else if (0 < ret)
- {
- int adapterIndex = GetAdapterIndex(peer->sep.endpoint.adapter);
- if (0 <= adapterIndex && MAX_SUPPORTED_ADAPTERS > adapterIndex)
- {
- g_caSslContext->adapterCallbacks[adapterIndex].recvCallback(&peer->sep, decryptBuffer, ret);
- }
- else
+ if (0 > ret)
{
- OIC_LOG(ERROR, NET_SSL_TAG, "Unsuported adapter");
+ OIC_LOG_V(ERROR, NET_SSL_TAG, "mbedtls_ssl_read returned -0x%x", -ret);
+ g_caSslContext->adapterCallbacks[adapterIndex].errorCallback(&peer->sep.endpoint, peer->recBuf.buff, peer->recBuf.len, CA_STATUS_FAILED);
RemovePeerFromList(&peer->sep.endpoint);
oc_mutex_unlock(g_sslContextMutex);
return CA_STATUS_FAILED;
}
+ else if (0 < ret)
+ {
+ g_caSslContext->adapterCallbacks[adapterIndex].recvCallback(&peer->sep, decryptBuffer, ret);
+ }
+ }
+ else
+ {
+ OIC_LOG(ERROR, NET_SSL_TAG, "Unsuported adapter");
+ RemovePeerFromList(&peer->sep.endpoint);
+ oc_mutex_unlock(g_sslContextMutex);
+ return CA_STATUS_FAILED;
}
}
void CAsetSslAdapterCallbacks(CAPacketReceivedCallback recvCallback,
CAPacketSendCallback sendCallback,
+ CAErrorHandleCallback errorCallback,
CATransportAdapter_t type)
{
OIC_LOG_V(DEBUG, NET_SSL_TAG, "In %s", __func__);
VERIFY_NON_NULL_VOID(sendCallback, NET_SSL_TAG, "sendCallback is NULL");
VERIFY_NON_NULL_VOID(recvCallback, NET_SSL_TAG, "recvCallback is NULL");
+ VERIFY_NON_NULL_VOID(errorCallback, NET_SSL_TAG, "errorCallback is NULL");
+
oc_mutex_lock(g_sslContextMutex);
if (NULL == g_caSslContext)
{
return;
}
- switch (type)
+ int index = GetAdapterIndex(type);
+ if (index >= 0)
{
- case CA_ADAPTER_IP:
- g_caSslContext->adapterCallbacks[0].recvCallback = recvCallback;
- g_caSslContext->adapterCallbacks[0].sendCallback = sendCallback;
- break;
- case CA_ADAPTER_TCP:
- g_caSslContext->adapterCallbacks[1].recvCallback = recvCallback;
- g_caSslContext->adapterCallbacks[1].sendCallback = sendCallback;
- break;
- case CA_ADAPTER_GATT_BTLE:
- g_caSslContext->adapterCallbacks[2].recvCallback = recvCallback;
- g_caSslContext->adapterCallbacks[2].sendCallback = sendCallback;
- break;
- default:
- OIC_LOG_V(ERROR, NET_SSL_TAG, "Unsupported adapter: %d", type);
+ g_caSslContext->adapterCallbacks[index].recvCallback = recvCallback;
+ g_caSslContext->adapterCallbacks[index].sendCallback = sendCallback;
+ g_caSslContext->adapterCallbacks[index].errorCallback = errorCallback;
}
oc_mutex_unlock(g_sslContextMutex);
}
#endif
+static void CALEErrorHandlerInternal(const CAEndpoint_t *endpoint,
+ const void *data, size_t dataLen,
+ CAResult_t result)
+{
+ g_errorHandler(endpoint, data, dataLen, result);
+}
+
CAResult_t CAInitializeLE(CARegisterConnectivityCallback registerCallback,
CANetworkPacketReceivedCallback reqRespCallback,
CAAdapterChangeCallback netCallback,
}
else
{
- CAsetSslAdapterCallbacks(CALESecureReceiveDataCB, CALESecureSendDataCB, CA_ADAPTER_GATT_BTLE);
+ CAsetSslAdapterCallbacks(CALESecureReceiveDataCB, CALESecureSendDataCB, CALEErrorHandlerInternal, CA_ADAPTER_GATT_BTLE);
}
#endif
#endif
#ifdef __WITH_DTLS__
- CAsetSslAdapterCallbacks(NULL, NULL, CA_ADAPTER_GATT_BTLE);
+ CAsetSslAdapterCallbacks(NULL, NULL, NULL, CA_ADAPTER_GATT_BTLE);
#endif
CATerminateLEAdapterMutex();
remoteAddress,
0);
- // if required, will be used to build remote endpoint
- g_errorHandler(rep, data, dataLen, result);
+ CALEErrorHandlerInternal(rep, data, dataLen, result);
CAFreeEndpoint(rep);
return success;
}
-CAResult_t CAregisterSslHandshakeCallback(CAErrorCallback tlsHandshakeCallback)
+CAResult_t CAregisterSslHandshakeCallback(CAHandshakeErrorCallback tlsHandshakeCallback)
{
OIC_LOG(DEBUG, TAG, "CAregisterSslHandshakeCallback");
return;
}
+#ifdef WITH_TCP
+ if (CAIsSupportedCoAPOverTCP(endpoint->adapter))
+ {
+ OIC_LOG(INFO, TAG, "retransmission is not supported");
+ }
+ else
+#endif
+ {
+ //Fix up CoAP message to adjust it to current retransmission implementation
+ coap_hdr_t *hdr = (coap_hdr_t *)(pdu->transport_hdr);
+ hdr->type = CA_MSG_RESET;
+ hdr->code = CA_EMPTY;
+
+ // for retransmission
+ void *retransmissionPdu = NULL;
+ CARetransmissionReceivedData(&g_retransmissionContext, cadata->remoteEndpoint,
+ pdu->transport_hdr, pdu->length, &retransmissionPdu);
+
+ // get token from saved data in retransmission list
+ if (retransmissionPdu && cadata->errorInfo)
+ {
+ CAInfo_t *info = &cadata->errorInfo->info;
+ CAResult_t res = CAGetTokenFromPDU((const coap_hdr_transport_t *)retransmissionPdu,
+ info, endpoint);
+ if (CA_STATUS_OK != res)
+ {
+ OIC_LOG(ERROR, TAG, "fail to get Token from retransmission list");
+ OICFree(info->token);
+ info->tokenLength = 0;
+ }
+ }
+ OICFree(retransmissionPdu);
+ }
+
cadata->errorInfo->result = result;
CAQueueingThreadAddData(&g_receiveThread, cadata, sizeof(CAData_t));
}
else
{
- CAsetSslAdapterCallbacks(CAIPPacketReceivedCB, CAIPPacketSendCB, CA_ADAPTER_IP);
+ CAsetSslAdapterCallbacks(CAIPPacketReceivedCB, CAIPPacketSendCB, CAIPErrorHandler, CA_ADAPTER_IP);
}
#endif
void CATerminateIP()
{
#ifdef __WITH_DTLS__
- CAsetSslAdapterCallbacks(NULL, NULL, CA_ADAPTER_IP);
+ CAsetSslAdapterCallbacks(NULL, NULL, NULL, CA_ADAPTER_IP);
#endif
CAIPSetPacketReceiveCallback(NULL);
}
else
{
- CAsetSslAdapterCallbacks(CATCPPacketReceivedCB, CATCPPacketSendCB, CA_ADAPTER_TCP);
+ CAsetSslAdapterCallbacks(CATCPPacketReceivedCB, CATCPPacketSendCB, CATCPErrorHandler, CA_ADAPTER_TCP);
}
#endif
void CATerminateTCP()
{
+#ifdef __WITH_TLS__
+ CAsetSslAdapterCallbacks(NULL, NULL, NULL, CA_ADAPTER_TCP);
+#endif
CAStopTCP();
CATCPSetPacketReceiveCallback(NULL);
msglen = dataLength;
}
+static void CATCPPacketErrorCB(const CAEndpoint_t *, const void *, size_t, CAResult_t)
+{
+}
+
static void PacketReceive(unsigned char *data, int * datalen)
{
int n;
msglen = dataLength;
}
+static void CATCPPacketErrorCB_server(const CAEndpoint_t *, const void *, size_t, CAResult_t)
+{
+}
+
static void PacketReceive_server(unsigned char *data, int * datalen)
{
int n;
return 1;
}
- CAsetSslAdapterCallbacks(CATCPPacketReceivedCB, CATCPPacketSendCB, (CATransportAdapter_t)0);
- if (g_caSslContext->adapterCallbacks[0].recvCallback == NULL &&
- g_caSslContext->adapterCallbacks[0].sendCallback == NULL &&
- g_caSslContext->adapterCallbacks[1].recvCallback == NULL &&
- g_caSslContext->adapterCallbacks[1].sendCallback == NULL)
+ CAsetSslAdapterCallbacks(CATCPPacketReceivedCB, CATCPPacketSendCB, CATCPPacketErrorCB, (CATransportAdapter_t)0);
+ if (g_caSslContext->adapterCallbacks[0].recvCallback == NULL &&
+ g_caSslContext->adapterCallbacks[0].sendCallback == NULL &&
+ g_caSslContext->adapterCallbacks[0].errorCallback == NULL &&
+ g_caSslContext->adapterCallbacks[1].recvCallback == NULL &&
+ g_caSslContext->adapterCallbacks[1].sendCallback == NULL &&
+ g_caSslContext->adapterCallbacks[1].errorCallback == NULL)
{
ret = 0;
}
{
ret = 1;
}
- CAsetSslAdapterCallbacks(CATCPPacketReceivedCB, CATCPPacketSendCB, CA_ADAPTER_IP);
- CAsetSslAdapterCallbacks(CATCPPacketReceivedCB, CATCPPacketSendCB, CA_ADAPTER_TCP);
- if (g_caSslContext->adapterCallbacks[0].recvCallback == CATCPPacketReceivedCB &&
- g_caSslContext->adapterCallbacks[0].sendCallback == CATCPPacketSendCB &&
- g_caSslContext->adapterCallbacks[1].recvCallback == CATCPPacketReceivedCB &&
- g_caSslContext->adapterCallbacks[1].sendCallback == CATCPPacketSendCB)
+ CAsetSslAdapterCallbacks(CATCPPacketReceivedCB, CATCPPacketSendCB, CATCPPacketErrorCB, CA_ADAPTER_IP);
+ CAsetSslAdapterCallbacks(CATCPPacketReceivedCB, CATCPPacketSendCB, CATCPPacketErrorCB, CA_ADAPTER_TCP);
+ if (g_caSslContext->adapterCallbacks[0].recvCallback == CATCPPacketReceivedCB &&
+ g_caSslContext->adapterCallbacks[0].sendCallback == CATCPPacketSendCB &&
+ g_caSslContext->adapterCallbacks[0].errorCallback == CATCPPacketErrorCB &&
+ g_caSslContext->adapterCallbacks[1].recvCallback == CATCPPacketReceivedCB &&
+ g_caSslContext->adapterCallbacks[1].sendCallback == CATCPPacketSendCB &&
+ g_caSslContext->adapterCallbacks[1].errorCallback == CATCPPacketErrorCB)
{
ret += 0;
}
CAinitSslAdapter();
- CAsetSslAdapterCallbacks(CATCPPacketReceivedCB, CATCPPacketSendCB, CA_ADAPTER_TCP);
+ CAsetSslAdapterCallbacks(CATCPPacketReceivedCB, CATCPPacketSendCB, CATCPPacketErrorCB, CA_ADAPTER_TCP);
CAsetPkixInfoCallback(infoCallback_that_loads_x509);
CAinitSslAdapter();
- CAsetSslAdapterCallbacks(CATCPPacketReceivedCB, CATCPPacketSendCB, CA_ADAPTER_TCP);
+ CAsetSslAdapterCallbacks(CATCPPacketReceivedCB, CATCPPacketSendCB, CATCPPacketErrorCB, CA_ADAPTER_TCP);
CAsetPkixInfoCallback(infoCallback_that_loads_x509);
CAinitSslAdapter();
- CAsetSslAdapterCallbacks(CATCPPacketReceivedCB, CATCPPacketSendCB, CA_ADAPTER_TCP);
+ CAsetSslAdapterCallbacks(CATCPPacketReceivedCB, CATCPPacketSendCB, CATCPPacketErrorCB, CA_ADAPTER_TCP);
CAsetPkixInfoCallback(infoCallback_that_loads_x509);
CAinitSslAdapter();
- CAsetSslAdapterCallbacks(CATCPPacketReceivedCB_server, CATCPPacketSendCB_server, CA_ADAPTER_TCP);
+ CAsetSslAdapterCallbacks(CATCPPacketReceivedCB_server, CATCPPacketSendCB_server, CATCPPacketErrorCB_server, CA_ADAPTER_TCP);
CAsetPkixInfoCallback(infoCallback_that_loads_x509);
CAsetCredentialTypesCallback(clutch);
mbedtls_x509_crl_init(&g_caSslContext->crl);
oc_mutex_unlock(g_sslContextMutex);
- CAsetSslAdapterCallbacks(CATCPPacketReceivedCB, CATCPPacketSendCB, CA_ADAPTER_TCP);
+ CAsetSslAdapterCallbacks(CATCPPacketReceivedCB, CATCPPacketSendCB, CATCPPacketErrorCB, CA_ADAPTER_TCP);
CAsetPkixInfoCallback(infoCallback_that_loads_x509);
*/
OC_STACK_AUTHENTICATION_FAILURE,
OC_STACK_NOT_ALLOWED_OXM,
+ OC_STACK_CONTINUE_OPERATION,
/** Request come from endpoint which is not mapped to the resource. */
OC_STACK_BAD_ENDPOINT,
* @param[out] object remote device information.
* @param[out] errorInfo CA Error information.
*/
-void MultipleOwnerDTLSHandshakeCB(const CAEndpoint_t *object,
- const CAErrorInfo_t *errorInfo);
+CAResult_t MultipleOwnerDTLSHandshakeCB(const CAEndpoint_t *object,
+ const CAErrorInfo_t *errorInfo);
#endif //__WITH_DTLS__ && MULTIPLE_OWNER
/**
const CAResponseInfo_t *responseInfo);
/**
- * Function to register provisoning API's response callback.
- *
- * @param respHandler response handler callback.
- */
-void SRMRegisterProvisioningResponseHandler(SPResponseCallback respHandler);
-
-/**
* Check the security resource URI.
* @param uri Pointers to security resource URI.
* @return true if the URI is one of security resources, otherwise false.
* @param errorInfo [IN] Error information from the endpoint.
* @return NONE
*/
-static void MOTDtlsHandshakeCB(const CAEndpoint_t *endpoint, const CAErrorInfo_t *info)
+static CAResult_t MOTDtlsHandshakeCB(const CAEndpoint_t *endpoint, const CAErrorInfo_t *info)
{
OIC_LOG_V(DEBUG, TAG, "IN %s", __func__);
}
exit:
- OIC_LOG_V(DEBUG, TAG, "OUT %s", __func__);
+ OIC_LOG_V(INFO, TAG, "Out %s", __func__);
+ return CA_STATUS_OK;
}
/**
}
}
+static uint16_t getSecurePort(const OCProvisionDev_t *device)
+{
+ uint16_t port = 0;
+
+ if (NULL == device)
+ {
+ return port;
+ }
+
+ if (OC_ADAPTER_IP == device->endpoint.adapter)
+ {
+ port = device->securePort;
+ }
+#ifdef WITH_TCP
+ else if (OC_ADAPTER_TCP == device->endpoint.adapter)
+ {
+ port = device->tcpSecurePort;
+ }
+#endif
+
+ return port;
+}
+
/**
* Internal API to close the secure Ownership Transfer session.
*/
CAEndpoint_t endpoint;
CopyDevAddrToEndpoint(&selectedDeviceInfo->endpoint, &endpoint);
- endpoint.port = selectedDeviceInfo->securePort;
+ endpoint.port = getSecurePort(selectedDeviceInfo);
CAResult_t caResult = CAcloseSslConnection(&endpoint);
if (CA_STATUS_OK != caResult)
//If OTM Context was removed from previous response handler, just exit the current OTM process.
if(NULL == GetOTMContext(otmCtx->selectedDeviceInfo->endpoint.addr,
- otmCtx->selectedDeviceInfo->securePort))
+ getSecurePort(otmCtx->selectedDeviceInfo)))
{
OIC_LOG(WARNING, TAG, "Current OTM Process has already ended.");
}
{
//Remove the current OTM Context from OTM queue
RemoveOTMContext(otmCtx->selectedDeviceInfo->endpoint.addr,
- otmCtx->selectedDeviceInfo->securePort);
+ getSecurePort(otmCtx->selectedDeviceInfo));
//If there is a request being performed, cancel it to prevent retransmission.
if(otmCtx->ocDoHandle)
{
OIC_LOG_V(DEBUG, TAG, "OCCancel - %s : %d",
otmCtx->selectedDeviceInfo->endpoint.addr,
- otmCtx->selectedDeviceInfo->securePort);
+ getSecurePort(otmCtx->selectedDeviceInfo));
if(OC_STACK_OK != OCCancel(otmCtx->ocDoHandle, OC_HIGH_QOS, NULL, 0))
{
OIC_LOG(WARNING, TAG, "Failed to remove registered callback");
OIC_LOG(DEBUG, TAG, "OUT SetResult");
}
-static void OwnershipTransferSessionEstablished(const CAEndpoint_t *endpoint,
+static CAResult_t OwnershipTransferSessionEstablished(const CAEndpoint_t *endpoint,
OicSecDoxm_t *newDevDoxm, OTMContext_t *otmCtx)
{
OIC_LOG_V(DEBUG, TAG, "IN %s", __func__);
+ CAResult_t result = CA_STATUS_OK;
OCStackResult res = OC_STACK_ERROR;
+ OC_UNUSED(otmCtx);
//In case of Mutual Verified Just-Works, display mutualVerifNum
if (OIC_MV_JUST_WORKS == newDevDoxm->oxmSel)
if (OC_STACK_OK != res)
{
OIC_LOG(ERROR, TAG, "Error while retrieving Owner's device ID");
- SetResult(otmCtx, res);
+ result = CA_HANDLE_ERROR_OTHER_MODULE;
goto exit;
}
CAResult_t pskRet = CAGenerateOwnerPSK(endpoint,
if (CA_STATUS_OK != pskRet)
{
OIC_LOG(WARNING, TAG, "CAGenerateOwnerPSK failed");
- SetResult(otmCtx, OC_STACK_ERROR);
+ result = CA_HANDLE_ERROR_OTHER_MODULE;
goto exit;
}
if (OC_STACK_OK != res)
{
OIC_LOG(ERROR, TAG, "Error while displaying mutualVerifNum");
- SetResult(otmCtx, res);
+ result = CA_HANDLE_ERROR_OTHER_MODULE;
goto exit;
}
}
if (OC_STACK_OK != res)
{
OIC_LOG(ERROR, TAG, "Error while displaying message");
- SetResult(otmCtx, res);
+ result = CA_HANDLE_ERROR_OTHER_MODULE;
goto exit;
}
}
- //This is a secure session.
- otmCtx->selectedDeviceInfo->connType |= CT_FLAG_SECURE;
-
- //Send request : GET /oic/sec/doxm. Then verify that the property values obtained this way
- //are the same as those already-stored in the otmCtx.
- res = GetAndVerifyDoxmResource(otmCtx);
- if(OC_STACK_OK != res)
- {
- OIC_LOG(ERROR, TAG, "Failed to get doxm information after establishing secure connection");
- SetResult(otmCtx, res);
- }
-
exit:
OIC_LOG_V(DEBUG, TAG, "OUT %s", __func__);
+ return result;
}
-static void OwnershipTransferSessionFailed(const CAEndpoint_t *endpoint,
+static CAResult_t OwnershipTransferSessionFailed(const CAEndpoint_t *endpoint,
const CAErrorInfo_t *info, OicSecDoxm_t *newDevDoxm, OTMContext_t *otmCtx, bool emptyOwnerUuid)
{
OC_UNUSED(endpoint);
+ CAResult_t result = CA_STATUS_OK;
OIC_LOG_V(DEBUG, TAG, "IN %s", __func__);
{
OIC_LOG(WARNING, TAG, "Failed to remove the invalid owner credential");
}
- SetResult(otmCtx, OC_STACK_AUTHENTICATION_FAILURE);
+ result = CA_HANDLE_ERROR_OTHER_MODULE;
goto exit;
}
newDevDoxm->owned = false;
otmCtx->attemptCnt++;
- RemoveOTMContext(otmCtx->selectedDeviceInfo->endpoint.addr,
- otmCtx->selectedDeviceInfo->securePort);
-
// In order to re-start ownership transfer, device information should be deleted from PDM.
OCStackResult res = PDMDeleteDevice(&(otmCtx->selectedDeviceInfo->doxm->deviceID));
if (OC_STACK_OK != res)
{
OIC_LOG(ERROR, TAG, "Failed to PDMDeleteDevice");
- SetResult(otmCtx, res);
+ result = CA_HANDLE_ERROR_OTHER_MODULE;
}
else
{
- if(WRONG_PIN_MAX_ATTEMP > otmCtx->attemptCnt)
+ if (WRONG_PIN_MAX_ATTEMP > otmCtx->attemptCnt)
{
+ otmCtx->selectedDeviceInfo->connType &= ~CT_FLAG_SECURE;
+
res = StartOwnershipTransfer(otmCtx, otmCtx->selectedDeviceInfo);
- if(OC_STACK_OK != res)
+ if (OC_STACK_OK != res)
{
OIC_LOG(ERROR, TAG, "Failed to Re-StartOwnershipTransfer");
- SetResult(otmCtx, res);
+ result = CA_HANDLE_ERROR_OTHER_MODULE;
+ }
+ else
+ {
+ result = CA_CONTINUE_OPERATION;
}
}
else
{
OIC_LOG(ERROR, TAG, "User has exceeded the number of authentication attempts.");
- SetResult(otmCtx, OC_STACK_AUTHENTICATION_FAILURE);
+ result = CA_HANDLE_ERROR_OTHER_MODULE;
}
}
goto exit;
}
OIC_LOG(ERROR, TAG, "Failed to establish secure session.");
- SetResult(otmCtx, OC_STACK_AUTHENTICATION_FAILURE);
exit:
OIC_LOG_V(DEBUG, TAG, "OUT %s", __func__);
+ return result;
}
/**
* @param errorInfo [IN] Error information from the endpoint.
* @return NONE
*/
-void DTLSHandshakeCB(const CAEndpoint_t *endpoint, const CAErrorInfo_t *info)
+CAResult_t DTLSHandshakeCB(const CAEndpoint_t *endpoint, const CAErrorInfo_t *info)
{
OIC_LOG_V(DEBUG, TAG, "In %s(endpoint = %p, info = %p)", __func__, endpoint, info);
+ CAResult_t result = CA_STATUS_OK;
+
if (NULL == endpoint || NULL == info)
{
goto exit;
//Make sure the address matches.
bool matching = (0 == strncmp(otmCtx->selectedDeviceInfo->endpoint.addr,
endpoint->addr, sizeof(endpoint->addr)));
- matching = (matching && (otmCtx->selectedDeviceInfo->securePort == endpoint->port));
+ matching = (matching && (getSecurePort(otmCtx->selectedDeviceInfo) == endpoint->port));
if (!matching)
{
OIC_LOG_V(ERROR, TAG, "Mismatched: expected address %s:%u",
- otmCtx->selectedDeviceInfo->endpoint.addr, otmCtx->selectedDeviceInfo->securePort);
+ otmCtx->selectedDeviceInfo->endpoint.addr, getSecurePort(otmCtx->selectedDeviceInfo));
goto exit;
}
OicUuid_t emptyUuid = {.id={0}};
bool emptyOwnerUuid = (memcmp(&(newDevDoxm->owner), &emptyUuid, sizeof(OicUuid_t)) == 0);
- //If temporal secure sesstion established successfully
+ //If temporal secure session established successfully
if ((CA_STATUS_OK == info->result) && !newDevDoxm->owned && emptyOwnerUuid)
{
- OwnershipTransferSessionEstablished(endpoint, newDevDoxm, otmCtx);
+ result = OwnershipTransferSessionEstablished(endpoint, newDevDoxm, otmCtx);
}
else
{
- OwnershipTransferSessionFailed(endpoint, info, newDevDoxm, otmCtx, emptyOwnerUuid);
+ result = OwnershipTransferSessionFailed(endpoint, info, newDevDoxm, otmCtx, emptyOwnerUuid);
}
exit:
OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
+ return result;
}
/**
CAEndpoint_t endpoint;
CopyDevAddrToEndpoint(&selectedDeviceInfo->endpoint, &endpoint);
-
- if (CA_ADAPTER_IP == endpoint.adapter)
- {
- endpoint.port = selectedDeviceInfo->securePort;
- }
-#ifdef WITH_TCP
- else if (CA_ADAPTER_TCP == endpoint.adapter)
- {
- endpoint.port = selectedDeviceInfo->tcpSecurePort;
- }
-#endif
+ endpoint.port = getSecurePort(selectedDeviceInfo);
OicUuid_t ownerDeviceID = {.id={0}};
if (OC_STACK_OK != GetDoxmDeviceID(&ownerDeviceID))
//Save the current context, that will be used by the DTLS handshake callback
if(OC_STACK_OK != AddOTMContext(otmCtx,
otmCtx->selectedDeviceInfo->endpoint.addr,
- otmCtx->selectedDeviceInfo->securePort))
+ getSecurePort(otmCtx->selectedDeviceInfo)))
{
OIC_LOG(ERROR, TAG, "OwnerTransferModeHandler : Failed to add OTM Context into list");
SetResult(otmCtx, res);
SetResult(otmCtx, res);
return OC_STACK_DELETE_TRANSACTION;
}
+
+ //This is a secure session.
+ otmCtx->selectedDeviceInfo->connType |= CT_FLAG_SECURE;
+
+ //Send request : GET /oic/sec/doxm. Then verify that the property values obtained this way
+ //are the same as those already-stored in the otmCtx.
+ res = GetAndVerifyDoxmResource(otmCtx);
+ if(OC_STACK_OK != res)
+ {
+ OIC_LOG(ERROR, TAG, "Failed to get doxm information after establishing secure connection");
+ SetResult(otmCtx, res);
+ }
}
}
else
otmCtx->ocDoHandle = NULL;
(void)UNUSED;
- if (OC_STACK_OK != clientResponse->result)
+ if (OC_STACK_CONTINUE_OPERATION == clientResponse->result)
+ {
+ OIC_LOG(INFO, TAG, "Skipping error handling until pass all random pin tries");
+ }
+ else if (OC_STACK_OK != clientResponse->result)
{
OIC_LOG_V(WARNING, TAG, "%s : Client response is incorrect : %d",
__func__, clientResponse->result);
assert(deviceInfo->connType & CT_FLAG_SECURE);
if(!PMGenerateQuery(true,
- deviceInfo->endpoint.addr, deviceInfo->securePort,
+ deviceInfo->endpoint.addr, getSecurePort(deviceInfo),
deviceInfo->connType,
query, sizeof(query), OIC_RSRC_CRED_URI))
{
OicSecAcl_t* ownerAcl = NULL;
assert(deviceInfo->connType & CT_FLAG_SECURE);
- CAEndpoint_t endpoint;
- CopyDevAddrToEndpoint(&deviceInfo->endpoint, &endpoint);
-
- if (CA_ADAPTER_IP == endpoint.adapter)
- {
- endpoint.port = deviceInfo->securePort;
- }
-#ifdef WITH_TCP
- else if (CA_ADAPTER_TCP == endpoint.adapter)
- {
- endpoint.port = deviceInfo->tcpSecurePort;
- }
-#endif
-
- if (CA_STATUS_OK != CAInitiateHandshake(&endpoint))
- {
- OIC_LOG(ERROR, TAG, "Failed to pass ssl handshake");
- return OC_STACK_ERROR;
- }
-
if(!PMGenerateQuery(true,
- deviceInfo->endpoint.addr, deviceInfo->securePort,
+ deviceInfo->endpoint.addr, getSecurePort(deviceInfo),
deviceInfo->connType,
query, sizeof(query), aclUri))
{
assert(deviceInfo->connType & CT_FLAG_SECURE);
if(!PMGenerateQuery(true,
- deviceInfo->endpoint.addr, deviceInfo->securePort,
+ deviceInfo->endpoint.addr, getSecurePort(deviceInfo),
deviceInfo->connType,
query, sizeof(query), OIC_RSRC_PSTAT_URI))
{
assert(deviceInfo->connType & CT_FLAG_SECURE);
if(!PMGenerateQuery(true,
- deviceInfo->endpoint.addr, deviceInfo->securePort,
+ deviceInfo->endpoint.addr, getSecurePort(deviceInfo),
deviceInfo->connType,
query, sizeof(query), OIC_RSRC_DOXM_URI))
{
assert(deviceInfo->connType & CT_FLAG_SECURE);
if(!PMGenerateQuery(true,
- deviceInfo->endpoint.addr, deviceInfo->securePort,
+ deviceInfo->endpoint.addr, getSecurePort(deviceInfo),
deviceInfo->connType,
query, sizeof(query), OIC_RSRC_DOXM_URI))
{
assert(deviceInfo->connType & CT_FLAG_SECURE);
if(!PMGenerateQuery(true,
- deviceInfo->endpoint.addr, deviceInfo->securePort,
+ deviceInfo->endpoint.addr, getSecurePort(deviceInfo),
deviceInfo->connType,
query, sizeof(query), OIC_RSRC_PSTAT_URI))
{
assert(deviceInfo->connType & CT_FLAG_SECURE);
if(!PMGenerateQuery(true,
- deviceInfo->endpoint.addr, deviceInfo->securePort,
+ deviceInfo->endpoint.addr, getSecurePort(deviceInfo),
deviceInfo->connType,
query, sizeof(query), OIC_RSRC_DOXM_URI))
{
if(!PMGenerateQuery(true,
otmCtx->selectedDeviceInfo->endpoint.addr,
- otmCtx->selectedDeviceInfo->securePort,
+ getSecurePort(otmCtx->selectedDeviceInfo),
otmCtx->selectedDeviceInfo->connType,
query, sizeof(query), OIC_RSRC_PSTAT_URI))
{
if(!PMGenerateQuery(true,
otmCtx->selectedDeviceInfo->endpoint.addr,
- otmCtx->selectedDeviceInfo->securePort,
+ getSecurePort(otmCtx->selectedDeviceInfo),
otmCtx->selectedDeviceInfo->connType,
query, sizeof(query), OIC_RSRC_PSTAT_URI))
{
}
OIC_LOG(INFO, TAG, "TLS_ECDH_anon_WITH_AES_128_CBC_SHA256 cipher suite selected.");
- CAEndpoint_t endpoint;
- OCProvisionDev_t *selDevInfo = otmCtx->selectedDeviceInfo;
- CopyDevAddrToEndpoint(&selDevInfo->endpoint, &endpoint);
-
- if (CA_ADAPTER_IP == endpoint.adapter)
- {
- endpoint.port = selDevInfo->securePort;
- }
-#ifdef WITH_TCP
- else if (CA_ADAPTER_TCP == endpoint.adapter)
- {
- endpoint.port = selDevInfo->tcpSecurePort;
- }
-#endif
-
- caresult = CAInitiateHandshake(&endpoint);
- if (CA_STATUS_OK != caresult)
- {
- OIC_LOG_V(ERROR, TAG, "DTLS/TLS handshake failure.");
- return OC_STACK_ERROR;
- }
-
OIC_LOG(INFO, TAG, "OUT CreateSecureSessionJustWorksCallback");
+
return OC_STACK_OK;
}
}
OIC_LOG(INFO, TAG, "MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 cipher suite selected.");
- CAEndpoint_t endpoint;
- OCProvisionDev_t* selDevInfo = otmCtx->selectedDeviceInfo;
- CopyDevAddrToEndpoint(&selDevInfo->endpoint, &endpoint);
-
- if (CA_ADAPTER_IP == endpoint.adapter)
- {
- endpoint.port = selDevInfo->securePort;
- }
-#ifdef WITH_TCP
- else if (CA_ADAPTER_TCP == endpoint.adapter)
- {
- endpoint.port = selDevInfo->tcpSecurePort;
- }
-#endif
-
- caresult = CAInitiateHandshake(&endpoint);
- if (CA_STATUS_OK != caresult)
- {
- OIC_LOG_V(ERROR, TAG, "DTLS handshake failure.");
- return OC_STACK_ERROR;
- }
-
OIC_LOG(INFO, TAG, "OUT CreateSecureSessionMCertificateCallback");
return OC_STACK_OK;
}
OIC_LOG(INFO, TAG, "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 cipher suite selected.");
- CAEndpoint_t endpoint;
- OCProvisionDev_t* selDevInfo = otmCtx->selectedDeviceInfo;
- CopyDevAddrToEndpoint(&selDevInfo->endpoint, &endpoint);
-
- if (CA_ADAPTER_IP == endpoint.adapter)
- {
- endpoint.port = selDevInfo->securePort;
- }
-#ifdef WITH_TCP
- else if (CA_ADAPTER_TCP == endpoint.adapter)
- {
- endpoint.port = selDevInfo->tcpSecurePort;
- }
-#endif
-
- caresult = CAInitiateHandshake(&endpoint);
- if (CA_STATUS_OK != caresult)
- {
- OIC_LOG_V(ERROR, TAG, "DTLS handshake failure.");
- return OC_STACK_ERROR;
- }
-
OIC_LOG(INFO, TAG, "OUT CreateSecureSessionPreconfigPinCallback");
return OC_STACK_OK;
}
OIC_LOG(INFO, TAG, "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 cipher suite selected.");
- CAEndpoint_t endpoint;
- OCProvisionDev_t* selDevInfo = otmCtx->selectedDeviceInfo;
- CopyDevAddrToEndpoint(&selDevInfo->endpoint, &endpoint);
-
- if (CA_ADAPTER_IP == endpoint.adapter)
- {
- endpoint.port = selDevInfo->securePort;
- }
-#ifdef WITH_TCP
- else if (CA_ADAPTER_TCP == endpoint.adapter)
- {
- endpoint.port = selDevInfo->tcpSecurePort;
- }
-#endif
-
- caresult = CAInitiateHandshake(&endpoint);
- if (CA_STATUS_OK != caresult)
- {
- OIC_LOG_V(ERROR, TAG, "DTLS handshake failure.");
- return OC_STACK_ERROR;
- }
-
OIC_LOG(INFO, TAG, "OUT CreateSecureSessionRandomPinCallbak");
return OC_STACK_OK;
* @param errorInfo [IN] Error information from the endpoint.
* @return NONE
*/
-void DirectPairingDTLSHandshakeCB(const CAEndpoint_t *endpoint, const CAErrorInfo_t *info)
+CAResult_t DirectPairingDTLSHandshakeCB(const CAEndpoint_t *endpoint, const CAErrorInfo_t *info)
{
OIC_LOG(INFO, TAG, "IN DirectPairingDTLSHandshakeCB");
-
+ CAResult_t result = CA_STATUS_OK;
if(g_dp_proceed_ctx && g_dp_proceed_ctx->peer && endpoint && info)
{
if(OC_STACK_OK != res)
{
OIC_LOG(ERROR, TAG, "Failed to finalize direct-pairing");
- resultCallback(g_dp_proceed_ctx->userCtx, peer, res);
+ result = CA_HANDLE_ERROR_OTHER_MODULE;
}
}
else if(CA_DTLS_AUTHENTICATION_FAILURE == info->result)
{
OIC_LOG(INFO, TAG, "DirectPairingDTLSHandshakeCB - Authentication failed");
- resultCallback(g_dp_proceed_ctx->userCtx, peer, OC_STACK_AUTHENTICATION_FAILURE);
+ result = CA_HANDLE_ERROR_OTHER_MODULE;
}
#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
}
OIC_LOG(INFO, TAG, "OUT DirectPairingDTLSHandshakeCB");
+ return result;
}
/**
* @param[out] object remote device information.
* @param[out] errorInfo CA Error information.
*/
-void MultipleOwnerDTLSHandshakeCB(const CAEndpoint_t *object,
- const CAErrorInfo_t *errorInfo)
+CAResult_t MultipleOwnerDTLSHandshakeCB(const CAEndpoint_t *object,
+ const CAErrorInfo_t *errorInfo)
{
OIC_LOG(DEBUG, TAG, "IN MultipleOwnerDTLSHandshakeCB");
if (!gDoxm)
{
OIC_LOG_V(WARNING, TAG, "%s: gDoxm is NULL", __func__);
- return;
+ return CA_HANDLE_ERROR_OTHER_MODULE;
}
if (0 == memcmp(authenticationSubOwnerInfo.identity.id, gDoxm->owner.id,
authenticationSubOwnerInfo.identity.id_length))
{
OIC_LOG(WARNING, TAG, "Super owner tried MOT, this request will be ignored.");
- return;
+ return CA_HANDLE_ERROR_OTHER_MODULE;
}
OicSecSubOwner_t* subOwnerInst = NULL;
if (sizeof(subOwnerInst->uuid.id) < authenticationSubOwnerInfo.identity.id_length)
{
OIC_LOG(ERROR, TAG, "Identity id is too long");
- return;
+ return CA_HANDLE_ERROR_OTHER_MODULE;
}
memcpy(subOwnerInst->uuid.id, authenticationSubOwnerInfo.identity.id,
authenticationSubOwnerInfo.identity.id_length);
if(OC_STACK_OK != ConvertUuidToStr(&subOwnerInst->uuid, &strUuid))
{
OIC_LOG(ERROR, TAG, "Failed to allocate memory.");
- return;
+ return CA_HANDLE_ERROR_OTHER_MODULE;
}
OIC_LOG_V(DEBUG, TAG, "Adding New SubOwner(%s)", strUuid);
OICFree(strUuid);
}
OIC_LOG(DEBUG, TAG, "OUT MultipleOwnerDTLSHandshakeCB");
+ return CA_STATUS_OK;
}
#endif //MULTIPLE_OWNER
#endif // defined(__WITH_DTLS__) || defined (__WITH_TLS__)
}
#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
-static void DoxmDTLSHandshakeCB(const CAEndpoint_t *endpoint, const CAErrorInfo_t *info)
+static CAResult_t DoxmDTLSHandshakeCB(const CAEndpoint_t *endpoint, const CAErrorInfo_t *info)
{
OIC_LOG_V(DEBUG, TAG, "In %s(%p, %p)", __func__, endpoint, info);
}
OIC_LOG_V(DEBUG, TAG, "Out %s(%p, %p)", __func__, endpoint, info);
+ return CA_STATUS_OK;
}
-static void RegisterOTMSslHandshakeCallback(CAErrorCallback callback)
+static void RegisterOTMSslHandshakeCallback(CAHandshakeErrorCallback callback)
{
OC_VERIFY(CA_STATUS_OK == CAregisterSslHandshakeCallback(callback));
}
* @param errorInfo [IN] Error information from the endpoint.
* @return NONE
*/
-void DPairingDTLSHandshakeCB(const CAEndpoint_t *endpoint, const CAErrorInfo_t *info)
+CAResult_t DPairingDTLSHandshakeCB(const CAEndpoint_t *endpoint, const CAErrorInfo_t *info)
{
OIC_LOG(INFO, TAG, "IN DPairingDTLSHandshakeCB");
}
OIC_LOG(INFO, TAG, "OUT DPairingDTLSHandshakeCB");
+ return CA_STATUS_OK;
}
static OCEntityHandlerResult HandleDpairingPostRequest (const OCEntityHandlerRequest * ehRequest)
static CAResponseCallback gResponseHandler = NULL;
//Error Callback handler
static CAErrorCallback gErrorHandler = NULL;
-//Provisioning response callback
-static SPResponseCallback gSPResponseHandler = NULL;
/**
* A single global Request context will suffice as long
*/
SRMRequestContext_t g_requestContext;
-/**
- * Function to register provisoning API's response callback.
- * @param respHandler response handler callback.
- */
-void SRMRegisterProvisioningResponseHandler(SPResponseCallback respHandler)
-{
- gSPResponseHandler = respHandler;
-}
-
void SetRequestedResourceType(SRMRequestContext_t *context)
{
context->resourceType = GetSvrTypeFromUri(context->resourceUri);
{
OIC_LOG(DEBUG, TAG, "Received response from remote device");
- // isProvResponse flag is to check whether response is catered by provisioning APIs or not.
- // When token sent by CA response matches with token generated by provisioning request,
- // gSPResponseHandler returns true and response is not sent to RI layer. In case
- // gSPResponseHandler is null and isProvResponse is false response then the response is for
- // RI layer.
- bool isProvResponse = false;
-
- if (gSPResponseHandler)
- {
- isProvResponse = gSPResponseHandler(endPoint, responseInfo);
- }
- if (!isProvResponse && gResponseHandler)
+ if (gResponseHandler)
{
gResponseHandler(endPoint, responseInfo);
}
return OC_STACK_ERROR;
case CA_NOT_SUPPORTED:
return OC_STACK_NOTIMPL;
+ case CA_HANDLE_ERROR_OTHER_MODULE:
+ return OC_STACK_COMM_ERROR;
+ case CA_CONTINUE_OPERATION:
+ return OC_STACK_CONTINUE_OPERATION;
default:
return OC_STACK_ERROR;
}