#include "dtls.h"
#include "uarraylist.h"
-#include "camutex.h"
+#include "octhread.h"
#include "caadapterutils.h"
-#include "ocsecurityconfig.h"
#include "cainterface.h"
#include "cacommon.h"
/**
- * Currently DTLS supported adapters(2) WIFI and ETHENET for linux platform.
+ * Currently DTLS supported adapters(3) WIFI, ETHENET and BLE for linux platform.
*/
-#define MAX_SUPPORTED_ADAPTERS 2
+#define MAX_SUPPORTED_ADAPTERS 3
-/**
- * The implementation will be provided by OIC RI layer.
- */
-extern void OCGetDtlsPskCredentials(CADtlsPskCredsBlob_t **credInfo);
-
-typedef void (*CAPacketReceivedCallback)(const CAEndpoint_t *endpoint,
- const void *data, uint32_t dataLength);
+typedef void (*CAPacketReceivedCallback)(const CASecureEndpoint_t *sep,
+ const void *data, size_t dataLength);
typedef void (*CAPacketSendCallback)(CAEndpoint_t *endpoint,
- const void *data, uint32_t dataLength);
+ const void *data, size_t dataLength);
/**
* Data structure for holding the send and recv callbacks.
typedef struct
{
socklen_t size; /**< Size of address. */
+#ifdef _MSC_VER
+ __declspec(align(8))
+#endif
union
{
struct sockaddr sa;
CATransportAdapter_t type);
/**
- * Register callback to get DTLS PSK credentials.
- * @param[in] credCallback callback to get DTLS credentials.
+ * Register callback to deliver the result of DTLS handshake
+ * @param[in] dtlsHandshakeCallback Callback to receive the result of DTLS handshake.
*/
-void CADTLSSetCredentialsCallback(CAGetDTLSCredentialsHandler credCallback);
+void CADTLSSetHandshakeCallback(CAErrorCallback dtlsHandshakeCallback);
/**
* Select the cipher suite for dtls handshake
* @retval ::CA_STATUS_FAILED Operation failed.
*
*/
-CAResult_t CAAdapterNetDtlsDecrypt(const CAEndpoint_t *endpoint,
+CAResult_t CAAdapterNetDtlsDecrypt(const CASecureEndpoint_t *sep,
uint8_t *data,
uint32_t dataLen);
+
+/**
+ * API to get a secure connected peer information
+ * NOTE : This API use the mutex lock to access 'g_caDtlsContext',
+ * Please do not invoke this API for internal function of dtls adapter
+ *
+ * @param[in] peer peer information includs IP address and port.
+ *
+ * @ return secure connected peer information on success, otherwise NULL
+ */
+CASecureEndpoint_t *CAGetSecurePeerInfo(const CAEndpoint_t *peer);
+
#endif /* CA_ADAPTER_NET_DTLS_H_ */