Commit 193ac144 authored by hyuna0213.jo's avatar hyuna0213.jo Committed by Jon A. Cruz

merge master code to build iotivity

current cloud-interface branch code failed to build iotivity stack.
so I merge latest master code that the build issue is resolved 
to build full source code.

Change-Id: I6f6393806f3d4b5c5b861fe61941cea13bb45904
Signed-off-by: default avatarhyuna0213.jo <hyuna0213.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2265Reviewed-by: default avatarJaehong Jo <jaehong.jo@samsung.com>
Reviewed-by: default avatarJon A. Cruz <jonc@osg.samsung.com>
Tested-by: default avatarJon A. Cruz <jonc@osg.samsung.com>
parent 4d2c8162
......@@ -63,27 +63,41 @@ function build_android()
# Note: for android, as oic-resource uses C++11 feature stoi and to_string,
# it requires gcc-4.9, currently only android-ndk-r10(for linux)
# and windows android-ndk-r10(64bit target version) support these features.
echo "*********** Build Boost for android ***********"
# disable parallel build for android as gradle depends on scons to finish first
export SCONSFLAGS="-Q"
# Parallel builds for android are disabled as gradle depends on
# scons to finish first
SCONSFLAGS="-Q" build_android_x86 $1 $2
SCONSFLAGS="-Q" build_android_armeabi $1 $2
}
function build_android_x86()
{
echo "*********** Build for android x86 *************"
scons TARGET_OS=android TARGET_ARCH=x86 RELEASE=$1 TARGET_TRANSPORT=IP $2
scons TARGET_OS=android TARGET_ARCH=x86 RELEASE=$1 TARGET_TRANSPORT=BT $2
scons TARGET_OS=android TARGET_ARCH=x86 RELEASE=$1 TARGET_TRANSPORT=BLE $2
<<<<<<< HEAD
echo "*********** Build for android x86_64 *************"
scons TARGET_OS=android TARGET_ARCH=x86_64 RELEASE=$1 TARGET_TRANSPORT=IP $2
scons TARGET_OS=android TARGET_ARCH=x86_64 RELEASE=$1 TARGET_TRANSPORT=BT $2
scons TARGET_OS=android TARGET_ARCH=x86_64 RELEASE=$1 TARGET_TRANSPORT=BLE $2
=======
}
>>>>>>> origin/master
function build_android_armeabi()
{
echo "*********** Build for android armeabi *************"
scons TARGET_OS=android TARGET_ARCH=armeabi RELEASE=$1 TARGET_TRANSPORT=IP $2
scons TARGET_OS=android TARGET_ARCH=armeabi RELEASE=$1 TARGET_TRANSPORT=BT $2
scons TARGET_OS=android TARGET_ARCH=armeabi RELEASE=$1 TARGET_TRANSPORT=BLE $2
<<<<<<< HEAD
# enable parallel build
export SCONSFLAGS="-Q -j 4"
=======
>>>>>>> origin/master
}
function build_arduino()
......@@ -191,6 +205,14 @@ then
then
build_android true
build_android false
elif [ $1 = 'android_x86' ]
then
build_android_x86 true
build_android_x86 false
elif [ $1 = 'android_armeabi' ]
then
build_android_armeabi true
build_android_armeabi false
elif [ $1 = 'arduino' ]
then
build_arduino true
......
......@@ -58,6 +58,9 @@ else:
env.AppendUnique(CCFLAGS = ['-g'])
env.AppendUnique(LINKFLAGS = ['-g'])
if env.get('LOGGING'):
env.AppendUnique(CPPDEFINES = ['-DTB_LOG'])
if target_os == 'darwin':
sys_root = tc_path + '/Platforms/MacOSX.platform/Developer/SDKs/MacOSX' + sys_version + '.sdk/'
else:
......
......@@ -58,6 +58,7 @@
#include "sha2/sha2.h"
#include "prng.h"
#include "netq.h"
#include "hmac.h"
#ifndef WITH_CONTIKI
#include <pthread.h>
......@@ -329,6 +330,7 @@ dtls_ccm_decrypt(aes128_t *ccm_ctx, const unsigned char *src,
static size_t
dtls_cbc_encrypt(aes128_t *aes_ctx,
unsigned char *key, size_t keylen,
const unsigned char *iv,
const unsigned char *src, size_t srclen,
unsigned char *buf) {
......@@ -336,18 +338,35 @@ dtls_cbc_encrypt(aes128_t *aes_ctx,
unsigned char cbc[DTLS_BLK_LENGTH];
unsigned char tmp[DTLS_BLK_LENGTH];
unsigned char *pos;
dtls_hash_ctx shactx;
const unsigned char *dtls_hdr = NULL;
int i, j;
int blocks;
dtls_hmac_context_t* hmac_ctx = NULL;
int paddinglen = 0;
pos = buf;
dtls_hash_init(&shactx);
dtls_hash_update(&shactx, src, srclen);
dtls_hash_finalize(pos + srclen, &shactx);
dtls_hdr = src - DTLS_CBC_IV_LENGTH - sizeof(dtls_record_header_t);
//Calculate MAC : Append the MAC code to end of content
hmac_ctx = dtls_hmac_new(key, keylen);
dtls_mac(hmac_ctx,
dtls_hdr,
src, srclen,
buf + srclen);
dtls_hmac_free(hmac_ctx);
dtls_debug_dump("[MAC]",
buf + srclen,
DTLS_HMAC_DIGEST_SIZE);
paddinglen = DTLS_BLK_LENGTH - ((srclen + DTLS_HMAC_DIGEST_SIZE) % DTLS_BLK_LENGTH);
//TLS padding
memset(buf + (srclen + DTLS_HMAC_DIGEST_SIZE), paddinglen - 1, paddinglen);
memcpy(cbc, iv, DTLS_BLK_LENGTH);
blocks = (srclen + SHA256_DIGEST_LENGTH) / DTLS_BLK_LENGTH;
blocks = (srclen + DTLS_HMAC_DIGEST_SIZE + paddinglen) / DTLS_BLK_LENGTH;
for (i = 0; i < blocks; i++) {
for (j = 0; j < DTLS_BLK_LENGTH; j++) {
......@@ -360,14 +379,17 @@ dtls_cbc_encrypt(aes128_t *aes_ctx,
pos += DTLS_BLK_LENGTH;
}
dtls_debug_dump("Encrypted Data:", buf, srclen + SHA256_DIGEST_LENGTH);
return srclen + SHA256_DIGEST_LENGTH;
dtls_debug_dump("[Encrypted Data]",
buf,
srclen + DTLS_HMAC_DIGEST_SIZE + paddinglen);
return srclen + DTLS_HMAC_DIGEST_SIZE + paddinglen;
}
static size_t
dtls_cbc_decrypt(aes128_t *aes_ctx,
unsigned char *key, size_t keylen,
const unsigned char *iv,
const unsigned char *src, size_t srclen,
unsigned char *buf) {
......@@ -375,14 +397,17 @@ dtls_cbc_decrypt(aes128_t *aes_ctx,
unsigned char cbc[DTLS_BLK_LENGTH];
unsigned char tmp[DTLS_BLK_LENGTH];
unsigned char tmp2[DTLS_BLK_LENGTH];
unsigned char msg_hash[SHA256_DIGEST_LENGTH];
unsigned char mac_buf[DTLS_HMAC_DIGEST_SIZE] = {0,};
const unsigned char *dtls_hdr = NULL;
unsigned char *pos;
dtls_hash_ctx shactx;
int i, j;
int blocks;
int depaddinglen = 0;
dtls_hmac_context_t* hmac_ctx = NULL;
pos = buf;
memcpy(pos, src, srclen);
dtls_hdr = src - DTLS_CBC_IV_LENGTH - sizeof(dtls_record_header_t);
memcpy(cbc, iv, DTLS_BLK_LENGTH);
blocks = srclen / DTLS_BLK_LENGTH;
......@@ -401,19 +426,46 @@ dtls_cbc_decrypt(aes128_t *aes_ctx,
pos += DTLS_BLK_LENGTH;
}
dtls_hash_init(&shactx);
dtls_hash_update(&shactx, buf, srclen - SHA256_DIGEST_LENGTH);
dtls_hash_finalize(msg_hash, &shactx);
dtls_debug_dump("decrypted data:", buf, srclen);
//de-padding
depaddinglen = buf[srclen -1];
if(memcmp(msg_hash, buf + (srclen - SHA256_DIGEST_LENGTH), SHA256_DIGEST_LENGTH) != 0)
//Calculate MAC
hmac_ctx = dtls_hmac_new(key, keylen);
if(!hmac_ctx) {
return -1;
}
dtls_mac(hmac_ctx, dtls_hdr, buf,
srclen - DTLS_HMAC_DIGEST_SIZE - depaddinglen - 1,
mac_buf);
dtls_hmac_free(hmac_ctx);
dtls_debug_dump("[MAC]",
mac_buf,
DTLS_HMAC_DIGEST_SIZE);
dtls_debug_dump("[Decrypted data]",
buf,
srclen - DTLS_HMAC_DIGEST_SIZE - depaddinglen - 1);
//verify the MAC
if(memcmp(mac_buf,
buf + (srclen - DTLS_HMAC_DIGEST_SIZE - depaddinglen - 1),
DTLS_HMAC_DIGEST_SIZE) != 0)
{
dtls_warn("message is broken\n");
dtls_crit("Failed to verification of MAC\n");
return -1;
}
return srclen - SHA256_DIGEST_LENGTH;
//verify the padding bytes
for (i =0; i < depaddinglen; i++)
{
if (buf[srclen - depaddinglen - 1 + i] != depaddinglen)
{
dtls_crit("Failed to verify padding bytes\n");
return -1;
}
}
return srclen - DTLS_HMAC_DIGEST_SIZE - depaddinglen - 1;
}
#ifdef DTLS_PSK
......@@ -523,8 +575,6 @@ void
dtls_ecdsa_create_sig_hash(const unsigned char *priv_key, size_t key_size,
const unsigned char *sign_hash, size_t sign_hash_size,
uint32_t point_r[9], uint32_t point_s[9]) {
int ret;
uint8_t privateKey[32];
uint8_t hashValue[32];
uint8_t sign[64];
......@@ -591,6 +641,41 @@ dtls_ecdsa_verify_sig(const unsigned char *pub_key_x,
}
#endif /* DTLS_ECC */
#if defined(DTLS_PSK) && defined(DTLS_ECC)
int dtls_ecdhe_psk_pre_master_secret(unsigned char *psk, size_t psklen,
unsigned char *ecc_priv_key,
unsigned char *ecc_pub_key_x,
unsigned char *ecc_pub_key_y,
size_t ecc_key_size,
unsigned char *result,
size_t result_len)
{
uint8_t eccPublicKey[64];
uint8_t eccPrivateKey[32];
unsigned char *p = result;
if (result_len < uECC_BYTES + psklen + (sizeof(uint16) * 2)) {
return -1;
}
dtls_int_to_uint16(p, uECC_BYTES);
p += sizeof(uint16);
memcpy(eccPublicKey, ecc_pub_key_x, 32);
memcpy(eccPublicKey + 32, ecc_pub_key_y, 32);
memcpy(eccPrivateKey, ecc_priv_key, 32);
uECC_shared_secret(eccPublicKey, eccPrivateKey, p);
p += uECC_BYTES;
dtls_int_to_uint16(p, psklen);
p += sizeof(uint16);
memcpy(p, psk, psklen);
return uECC_BYTES + psklen + (sizeof(uint16) * 2);
}
#endif /* defined(DTLS_PSK) && defined(DTLS_ECC) */
int
dtls_encrypt(const unsigned char *src, size_t length,
unsigned char *buf,
......@@ -615,7 +700,8 @@ dtls_encrypt(const unsigned char *src, size_t length,
memmove(buf, src, length);
ret = dtls_ccm_encrypt(&ctx->data, src, length, buf, nounce, aad, la);
}
if(cipher == TLS_ECDH_anon_WITH_AES_128_CBC_SHA) {
if(cipher == TLS_ECDH_anon_WITH_AES_128_CBC_SHA_256 ||
cipher == TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA_256) {
ret = rijndael_set_key(&ctx->data.ctx, key, 8 * keylen);
if (ret < 0) {
/* cleanup everything in case the key has the wrong size */
......@@ -625,7 +711,7 @@ dtls_encrypt(const unsigned char *src, size_t length,
if (src != buf)
memmove(buf, src, length);
ret = dtls_cbc_encrypt(&ctx->data, nounce, src, length, buf);
ret = dtls_cbc_encrypt(&ctx->data, key, keylen, nounce, src, length, buf);
}
error:
......@@ -658,7 +744,8 @@ dtls_decrypt(const unsigned char *src, size_t length,
ret = dtls_ccm_decrypt(&ctx->data, src, length, buf, nounce, aad, la);
}
if(cipher == TLS_ECDH_anon_WITH_AES_128_CBC_SHA) {
if(cipher == TLS_ECDH_anon_WITH_AES_128_CBC_SHA_256 ||
cipher == TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA_256) {
ret = rijndael_set_key(&ctx->data.ctx, key, 8 * keylen);
if (ret < 0) {
/* cleanup everything in case the key has the wrong size */
......@@ -668,7 +755,7 @@ dtls_decrypt(const unsigned char *src, size_t length,
if (src != buf)
memmove(buf, src, length);
ret = dtls_cbc_decrypt(&ctx->data, nounce, src, length, buf);
ret = dtls_cbc_decrypt(&ctx->data, key, keylen, nounce, src, length, buf);
}
error:
......
......@@ -39,6 +39,7 @@
#include "numeric.h"
#include "hmac.h"
#include "ccm.h"
#include "ecc/ecc.h"
/* TLS_PSK_WITH_AES_128_CCM_8 */
#define DTLS_MAC_KEY_LENGTH 0
......@@ -46,6 +47,7 @@
#define DTLS_BLK_LENGTH 16 /* AES-128 */
#define DTLS_MAC_LENGTH DTLS_HMAC_DIGEST_SIZE
#define DTLS_IV_LENGTH 4 /* length of nonce_explicit */
#define DTLS_CBC_IV_LENGTH 16
/**
* Maximum size of the generated keyblock. Note that MAX_KEYBLOCK_LENGTH must
......@@ -128,6 +130,13 @@ typedef struct {
dtls_compression_t compression; /**< compression method */
dtls_cipher_t cipher; /**< cipher type */
unsigned int do_client_auth:1;
#ifdef DTLS_ECC && DTLS_PSK
struct keyx_t {
dtls_handshake_parameters_ecc_t ecc;
dtls_handshake_parameters_psk_t psk;
} keyx;
#else /* DTLS_ECC && DTLS_PSK */
union {
#ifdef DTLS_ECC
dtls_handshake_parameters_ecc_t ecc;
......@@ -136,6 +145,7 @@ typedef struct {
dtls_handshake_parameters_psk_t psk;
#endif /* DTLS_PSK */
} keyx;
#endif /* DTLS_ECC && DTLS_PSK */
} dtls_handshake_parameters_t;
/* The following macros provide access to the components of the
......
This diff is collapsed.
......@@ -238,7 +238,7 @@ typedef struct dtls_context_t {
dtls_handler_t *h; /**< callback handlers */
dtls_cipher_enable_t is_anon_ecdh_eabled; /**< enable/disable the TLS_ECDH_anon_WITH_AES_128_CBC_SHA */
dtls_cipher_enable_t is_anon_ecdh_eabled; /**< enable/disable the TLS_ECDH_anon_WITH_AES_128_CBC_SHA_256 */
dtls_cipher_t selected_cipher; /**< selected ciper suite for handshake */
......@@ -268,7 +268,7 @@ static inline void dtls_set_handler(dtls_context_t *ctx, dtls_handler_t *h) {
}
/**
* @brief Enabling the TLS_ECDH_anon_WITH_AES_128_CBC_SHA
* @brief Enabling the TLS_ECDH_anon_WITH_AES_128_CBC_SHA_256
*
* @param ctx The DTLS context to use.
* @param is_enable DTLS_CIPHER_ENABLE(1) or DTLS_CIPHER_DISABLE(0)
......@@ -279,7 +279,7 @@ void dtls_enables_anon_ecdh(dtls_context_t* ctx, dtls_cipher_enable_t is_enable)
* @brief Select the cipher suite for handshake
*
* @param ctx The DTLS context to use.
* @param cipher TLS_ECDH_anon_WITH_AES_128_CBC_SHA (0xC018)
* @param cipher TLS_ECDH_anon_WITH_AES_128_CBC_SHA_256 (0xC018)
* TLS_PSK_WITH_AES_128_CCM_8 (0xX0A8)
* TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 (0xC0AE)
*/
......
......@@ -73,8 +73,9 @@ typedef unsigned char uint48[6];
/** Known cipher suites.*/
typedef enum {
TLS_NULL_WITH_NULL_NULL = 0x0000, /**< NULL cipher */
TLS_ECDH_anon_WITH_AES_128_CBC_SHA = 0xC018, /**< see RFC 4492 */
TLS_ECDH_anon_WITH_AES_128_CBC_SHA_256 = 0xC018, /**< see RFC 4492 */
TLS_PSK_WITH_AES_128_CCM_8 = 0xC0A8, /**< see RFC 6655 */
TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA_256 = 0xC037, /**< see RFC 5489 */
TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 = 0xC0AE /**< see RFC 7251 */
} dtls_cipher_t;
......
......@@ -309,9 +309,10 @@ usage( const char *program, const char *version) {
"\t-p port\t\tlisten on specified port (default is %d)\n"
"\t-v num\t\tverbosity level (default: 3)\n"
"\t-c num\t\tcipher suite (default: 1)\n"
"\t\t\t1: TLS_ECDH_anon_WITH_AES_128_CBC_SHA \n"
"\t\t\t1: TLS_ECDH_anon_WITH_AES_128_CBC_SHA_256 \n"
"\t\t\t2: TLS_PSK_WITH_AES_128_CCM_8\n"
"\t\t\t3: TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8\n",
"\t\t\t3: TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8\n"
"\t\t\t4: TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA_256\n",
program, version, program, DEFAULT_PORT);
}
......@@ -347,7 +348,7 @@ main(int argc, char **argv) {
log_t log_level = DTLS_LOG_WARN;
int fd, result;
int on = 1;
dtls_cipher_t selected_cipher = TLS_ECDH_anon_WITH_AES_128_CBC_SHA;
dtls_cipher_t selected_cipher = TLS_NULL_WITH_NULL_NULL;
dtls_cipher_enable_t ecdh_anon_enalbe = DTLS_CIPHER_ENABLE;
int opt, res;
session_t dst;
......@@ -417,7 +418,7 @@ main(int argc, char **argv) {
case 'c':
if( strcmp(optarg, "1") == 0)
{
selected_cipher = TLS_ECDH_anon_WITH_AES_128_CBC_SHA;
selected_cipher = TLS_ECDH_anon_WITH_AES_128_CBC_SHA_256;
ecdh_anon_enalbe = DTLS_CIPHER_ENABLE;
}
else if( strcmp(optarg, "2") == 0)
......@@ -430,6 +431,11 @@ main(int argc, char **argv) {
selected_cipher = TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 ;
ecdh_anon_enalbe = DTLS_CIPHER_DISABLE;
}
else if( strcmp(optarg, "4") == 0)
{
selected_cipher = TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA_256;
ecdh_anon_enalbe = DTLS_CIPHER_DISABLE;
}
break;
default:
usage(argv[0], dtls_package_version());
......@@ -500,7 +506,7 @@ main(int argc, char **argv) {
/* select cipher suite */
dtls_select_cipher(dtls_context, selected_cipher);
/* enable/disable tls_ecdh_anon_with_aes_128_cbc_sha */
/* enable/disable tls_ecdh_anon_with_aes_128_cbc_sha_256 */
dtls_enables_anon_ecdh(dtls_context, ecdh_anon_enalbe);
dtls_set_handler(dtls_context, &cb);
......
......@@ -254,8 +254,8 @@ usage(const char *program, const char *version) {
"\t-p port\t\tlisten on specified port (default is %d)\n"
"\t-v num\t\tverbosity level (default: 3)\n"
"\t-a enable|disable\t(default: disable)\n"
"\t\t\t\tenable:enable TLS_ECDH_anon_with_AES_128_CBC_SHA\n"
"\t\t\t\tdisable:disable TLS_ECDH_anon_with_AES_128_CBC_SHA\n",
"\t\t\t\tenable:enable TLS_ECDH_anon_with_AES_128_CBC_SHA_256\n"
"\t\t\t\tdisable:disable TLS_ECDH_anon_with_AES_128_CBC_SHA_256\n",
program, version, program, DEFAULT_PORT);
}
......@@ -280,7 +280,7 @@ main(int argc, char **argv) {
struct timeval timeout;
int fd, opt, result;
int on = 1;
int ecdh_anon_enalbe = DTLS_CIPHER_DISABLE;
dtls_cipher_enable_t ecdh_anon_enalbe = DTLS_CIPHER_DISABLE;
struct sockaddr_in6 listen_addr;
memset(&listen_addr, 0, sizeof(struct sockaddr_in6));
......@@ -356,7 +356,7 @@ main(int argc, char **argv) {
the_context = dtls_new_context(&fd);
/* enable/disable tls_ecdh_anon_with_aes_128_cbc_sha */
/* enable/disable tls_ecdh_anon_with_aes_128_cbc_sha_256 */
dtls_enables_anon_ecdh(the_context, ecdh_anon_enalbe);
dtls_set_handler(the_context, &cb);
......
......@@ -391,6 +391,7 @@ typedef struct
{
CAResponseResult_t result; /**< Result for response by resource model */
CAInfo_t info; /**< Information of the response */
bool isMulticast;
} CAResponseInfo_t;
/**
......
......@@ -129,6 +129,7 @@ CAResponseInfo_t *CACloneResponseInfo(const CAResponseInfo_t *rep)
return NULL;
}
clone->isMulticast = rep->isMulticast;
clone->result = rep->result;
return clone;
}
......
......@@ -74,7 +74,7 @@ static const char *LEVEL[] =
static android_LogPriority LEVEL[] =
{ ANDROID_LOG_DEBUG, ANDROID_LOG_INFO, ANDROID_LOG_WARN, ANDROID_LOG_ERROR, ANDROID_LOG_FATAL};
#endif
#elif defined __linux__
#elif defined (__linux__) || defined (__APPLE__)
static const char *LEVEL[] __attribute__ ((unused)) =
{ "DEBUG", "INFO", "WARNING", "ERROR", "FATAL"};
#elif defined ARDUINO
......@@ -116,7 +116,7 @@ void OICLogInit()
void OICLogShutdown()
{
#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
if (logCtx && logCtx->destroy)
{
logCtx->destroy(logCtx);
......@@ -147,7 +147,7 @@ void OICLog(LogLevel level, const char *tag, const char *logStr)
__android_log_write(LEVEL[level], tag, logStr);
#endif
#elif defined __linux__
#elif defined __linux__ || defined __APPLE__
if (logCtx && logCtx->write_level)
{
logCtx->write_level(logCtx, LEVEL_XTABLE[level], logStr);
......@@ -158,7 +158,7 @@ void OICLog(LogLevel level, const char *tag, const char *logStr)
int min = 0;
int sec = 0;
int ms = 0;
#ifdef _POSIX_TIMERS
#if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0
struct timespec when = { 0, 0 };
clockid_t clk = CLOCK_REALTIME;
#ifdef CLOCK_REALTIME_COARSE
......
......@@ -138,7 +138,7 @@ void CADTLSSetCredentialsCallback(CAGetDTLSCredentialsHandler credCallback);
* Select the cipher suite for dtls handshake
*
* @param[in] cipher cipher suite
* 0xC018 : TLS_ECDH_anon_WITH_AES_128_CBC_SHA
* 0xC018 : TLS_ECDH_anon_WITH_AES_128_CBC_SHA_256
* 0xC0A8 : TLS_PSK_WITH_AES_128_CCM_8
* 0xC0AE : TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8
*
......
......@@ -193,18 +193,18 @@ int CAGetPollingInterval(int interval);
void CAWakeUpForChange();
/**
* @brief Initializes network monitor.
* Start network monitor.
*
* @return ::CA_STATUS_OK or Appropriate error code.
*/
CAResult_t CAIPInitializeNetworkMonitor();
CAResult_t CAIPStartNetworkMonitor();
/**
* @brief Terminates network monitor.
* Stops network monitor.
*
* @return ::CA_STATUS_OK or Appropriate error code.
*/
CAResult_t CAIPTerminateNetworkMonitor();
CAResult_t CAIPStopNetworkMonitor();
/**
* @brief Set callback for error handling.
......
......@@ -118,9 +118,10 @@ static CAResult_t CAAddIdToPeerInfoList(const char *peerAddr, uint32_t port,
{
OIC_LOG(ERROR, NET_DTLS_TAG, "u_arraylist_add failed!");
OICFree(peer);
return CA_STATUS_FAILED;
}
return result;
return CA_STATUS_OK;
}
static void CAFreePeerInfoList()
......@@ -302,10 +303,11 @@ static CAResult_t CADtlsCacheMsg(stCACacheMessage_t *msg)
if (!result)
{
OIC_LOG(ERROR, NET_DTLS_TAG, "u_arraylist_add failed!");
return CA_STATUS_FAILED;
}
OIC_LOG(DEBUG, NET_DTLS_TAG, "OUT");
return result;
return CA_STATUS_OK;
}
......@@ -437,11 +439,13 @@ static int32_t CASendSecureData(dtls_context_t *context,
stCADtlsAddrInfo_t *addrInfo = (stCADtlsAddrInfo_t *)session;
CAEndpoint_t endpoint;
CAEndpoint_t endpoint = {.adapter = CA_DEFAULT_ADAPTER};
CAConvertAddrToName(&(addrInfo->addr.st), endpoint.addr, &endpoint.port);
endpoint.flags = addrInfo->addr.st.ss_family == AF_INET ? CA_IPV4 : CA_IPV6;
endpoint.flags |= CA_SECURE;
endpoint.adapter = CA_ADAPTER_IP;
endpoint.interface = session->ifindex;
int type = 0;
//Mutex is not required for g_caDtlsContext. It will be called in same thread.
......@@ -644,7 +648,7 @@ CAResult_t CADtlsEnableAnonECDHCipherSuite(const bool enable)
dtls_enables_anon_ecdh(g_caDtlsContext->dtlsContext,
enable == true ? DTLS_CIPHER_ENABLE : DTLS_CIPHER_DISABLE);
ca_mutex_unlock(g_dtlsContextMutex);
OIC_LOG_V(DEBUG, NET_DTLS_TAG, "TLS_ECDH_anon_WITH_AES_128_CBC_SHA is %s",
OIC_LOG_V(DEBUG, NET_DTLS_TAG