mirror of https://github.com/ARMmbed/mbed-os.git
				
				
				
			Merge commit '9d5a9f5a29d19b2e67402e4e452e13ce75baca7c'
* commit '9d5a9f5a29d19b2e67402e4e452e13ce75baca7c': Squashed 'features/nanostack/FEATURE_NANOSTACK/coap-service/' changes from e125164..d65b6b0pull/4960/head
						commit
						ca15df3db0
					
				| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015-2016 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			@ -45,6 +45,10 @@ extern "C" {
 | 
			
		|||
#define COAP_SERVICE_OPTIONS_VIRTUAL_SOCKET     0x01
 | 
			
		||||
#define COAP_SERVICE_OPTIONS_SECURE 	        0x02
 | 
			
		||||
#define COAP_SERVICE_OPTIONS_EPHEMERAL_PORT     0x04
 | 
			
		||||
/** Coap interface selected as socket interface */
 | 
			
		||||
#define COAP_SERVICE_OPTIONS_SELECT_SOCKET_IF   0x08
 | 
			
		||||
/** Register to COAP multicast groups */
 | 
			
		||||
#define COAP_SERVICE_OPTIONS_MULTICAST_JOIN     0x10
 | 
			
		||||
/** Link-layer security bypass option is set*/
 | 
			
		||||
#define COAP_SERVICE_OPTIONS_SECURE_BYPASS      0x80
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -56,6 +60,10 @@ extern "C" {
 | 
			
		|||
#define COAP_REQUEST_OPTIONS_MULTICAST          0x04 //!< indicates that CoAP library support multicasting
 | 
			
		||||
#define COAP_REQUEST_OPTIONS_SECURE_BYPASS      0x08
 | 
			
		||||
 | 
			
		||||
extern const uint8_t COAP_MULTICAST_ADDR_LINK_LOCAL[16]; //!< ff02::fd, COAP link local multicast address
 | 
			
		||||
extern const uint8_t COAP_MULTICAST_ADDR_ADMIN_LOCAL[16]; //!< ff03::fd, COAP admin-local multicast address
 | 
			
		||||
extern const uint8_t COAP_MULTICAST_ADDR_SITE_LOCAL[16]; //!> ff05::fd, COAP site-local multicast address
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * \brief Service message response receive callback.
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			@ -262,7 +270,45 @@ extern uint16_t coap_service_request_send(int8_t service_id, uint8_t options, co
 | 
			
		|||
 */
 | 
			
		||||
extern int8_t coap_service_response_send(int8_t service_id, uint8_t options, sn_coap_hdr_s *request_ptr, sn_coap_msg_code_e message_code, sn_coap_content_format_e content_type, const uint8_t *payload_ptr,uint16_t payload_len);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * \brief Delete CoAP request transaction
 | 
			
		||||
 *
 | 
			
		||||
 * Removes pending CoAP transaction from service.
 | 
			
		||||
 *
 | 
			
		||||
 * \param service_id       Id number of the current service.
 | 
			
		||||
 * \param msg_id           Message ID number.
 | 
			
		||||
 *
 | 
			
		||||
 * \return -1              For failure
 | 
			
		||||
 *-         0              For success
 | 
			
		||||
 */
 | 
			
		||||
extern int8_t coap_service_request_delete(int8_t service_id, uint16_t msg_id);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * \brief Set DTLS handshake timeout values
 | 
			
		||||
 *
 | 
			
		||||
 * Configures the DTLS handshake timeout values.
 | 
			
		||||
 *
 | 
			
		||||
 * \param service_id       Id number of the current service.
 | 
			
		||||
 * \param min              Initial timeout value.
 | 
			
		||||
 * \param max              Maximum value of timeout.
 | 
			
		||||
 *
 | 
			
		||||
 * \return -1              For failure
 | 
			
		||||
 *-         0              For success
 | 
			
		||||
 */
 | 
			
		||||
extern int8_t coap_service_set_handshake_timeout(int8_t service_id, uint32_t min, uint32_t max);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * \brief Set CoAP duplication message buffer size
 | 
			
		||||
 *
 | 
			
		||||
 * Configures the CoAP duplication message buffer size.
 | 
			
		||||
 *
 | 
			
		||||
 * \param service_id       Id number of the current service.
 | 
			
		||||
 * \param size             Buffer size (messages)
 | 
			
		||||
 *
 | 
			
		||||
 * \return -1              For failure
 | 
			
		||||
 *-         0              For success
 | 
			
		||||
 */
 | 
			
		||||
extern int8_t coap_service_set_duplicate_message_buffer(int8_t service_id, uint8_t size);
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#!/bin/bash
 | 
			
		||||
# Copyright (c) 2015 ARM Limited. All rights reserved.
 | 
			
		||||
# Copyright (c) 2015-2017 ARM Limited. All rights reserved.
 | 
			
		||||
# SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
# Licensed under the Apache License, Version 2.0 (the License); you may
 | 
			
		||||
# not use this file except in compliance with the License.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015-2016 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <string.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -42,6 +42,10 @@ typedef struct internal_socket_s {
 | 
			
		|||
    ns_list_link_t link;
 | 
			
		||||
} internal_socket_t;
 | 
			
		||||
 | 
			
		||||
const uint8_t COAP_MULTICAST_ADDR_LINK_LOCAL[16] = { 0xff, 0x02, [15] = 0xfd }; // ff02::fd, COAP link-local multicast (rfc7390)
 | 
			
		||||
const uint8_t COAP_MULTICAST_ADDR_ADMIN_LOCAL[16] = { 0xff, 0x03, [15] = 0xfd }; // ff02::fd, COAP admin-local multicast (rfc7390)
 | 
			
		||||
const uint8_t COAP_MULTICAST_ADDR_SITE_LOCAL[16] = { 0xff, 0x05, [15] = 0xfd }; // ff05::fd, COAP site-local multicast (rfc7390)
 | 
			
		||||
 | 
			
		||||
static NS_LIST_DEFINE(socket_list, internal_socket_t, link);
 | 
			
		||||
 | 
			
		||||
static void timer_cb(void* param);
 | 
			
		||||
| 
						 | 
				
			
			@ -99,7 +103,6 @@ static secure_session_t *secure_session_find_by_timer_id(int8_t timer_id)
 | 
			
		|||
 | 
			
		||||
static bool is_secure_session_valid(secure_session_t *session)
 | 
			
		||||
{
 | 
			
		||||
    secure_session_t *this = NULL;
 | 
			
		||||
    ns_list_foreach(secure_session_t, cur_ptr, &secure_session_list) {
 | 
			
		||||
        if (cur_ptr == session) {
 | 
			
		||||
            return true;
 | 
			
		||||
| 
						 | 
				
			
			@ -222,9 +225,32 @@ static secure_session_t *secure_session_find(internal_socket_t *parent, const ui
 | 
			
		|||
    return this;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static internal_socket_t *int_socket_create(uint16_t listen_port, bool use_ephemeral_port, bool is_secure, bool real_socket, bool bypassSec)
 | 
			
		||||
static void coap_multicast_group_join_or_leave(int8_t socket_id, uint8_t opt_name, int8_t interface_id)
 | 
			
		||||
{
 | 
			
		||||
    ns_ipv6_mreq_t ns_ipv6_mreq;
 | 
			
		||||
    int8_t ret_val;
 | 
			
		||||
 | 
			
		||||
    // Join or leave COAP multicast groups
 | 
			
		||||
    ns_ipv6_mreq.ipv6mr_interface = interface_id;
 | 
			
		||||
 | 
			
		||||
    memcpy(ns_ipv6_mreq.ipv6mr_multiaddr, COAP_MULTICAST_ADDR_LINK_LOCAL, 16);
 | 
			
		||||
    ret_val = socket_setsockopt(socket_id, SOCKET_IPPROTO_IPV6, opt_name, &ns_ipv6_mreq, sizeof(ns_ipv6_mreq));
 | 
			
		||||
 | 
			
		||||
    memcpy(ns_ipv6_mreq.ipv6mr_multiaddr, COAP_MULTICAST_ADDR_ADMIN_LOCAL, 16);
 | 
			
		||||
    ret_val |= socket_setsockopt(socket_id, SOCKET_IPPROTO_IPV6, opt_name, &ns_ipv6_mreq, sizeof(ns_ipv6_mreq));
 | 
			
		||||
 | 
			
		||||
    memcpy(ns_ipv6_mreq.ipv6mr_multiaddr, COAP_MULTICAST_ADDR_SITE_LOCAL, 16);
 | 
			
		||||
    ret_val |= socket_setsockopt(socket_id, SOCKET_IPPROTO_IPV6, opt_name, &ns_ipv6_mreq, sizeof(ns_ipv6_mreq));
 | 
			
		||||
 | 
			
		||||
    if (ret_val) {
 | 
			
		||||
        tr_error("Multicast group access failed, err=%d, name=%d", ret_val, opt_name);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static internal_socket_t *int_socket_create(uint16_t listen_port, bool use_ephemeral_port, bool is_secure, bool real_socket, bool bypassSec, int8_t socket_interface_selection, bool multicast_registration)
 | 
			
		||||
{
 | 
			
		||||
    internal_socket_t *this = ns_dyn_mem_alloc(sizeof(internal_socket_t));
 | 
			
		||||
 | 
			
		||||
    if (!this) {
 | 
			
		||||
        return NULL;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -266,7 +292,14 @@ static internal_socket_t *int_socket_create(uint16_t listen_port, bool use_ephem
 | 
			
		|||
 | 
			
		||||
        // Set socket option to receive packet info
 | 
			
		||||
        socket_setsockopt(this->socket, SOCKET_IPPROTO_IPV6, SOCKET_IPV6_RECVPKTINFO, &(const bool) {1}, sizeof(bool));
 | 
			
		||||
        if (socket_interface_selection > 0) {
 | 
			
		||||
            // Interface selection requested as socket_interface_selection set
 | 
			
		||||
            socket_setsockopt(this->socket, SOCKET_IPPROTO_IPV6, SOCKET_INTERFACE_SELECT, &socket_interface_selection, sizeof(socket_interface_selection));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (multicast_registration) {
 | 
			
		||||
            coap_multicast_group_join_or_leave(this->socket, SOCKET_IPV6_JOIN_GROUP, socket_interface_selection);
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        this->socket = virtual_socket_id_allocate();
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -773,9 +806,13 @@ coap_conn_handler_t *connection_handler_create(receive_from_socket_cb *recv_from
 | 
			
		|||
 | 
			
		||||
    return handler;
 | 
			
		||||
}
 | 
			
		||||
void connection_handler_destroy(coap_conn_handler_t *handler)
 | 
			
		||||
 | 
			
		||||
void connection_handler_destroy(coap_conn_handler_t *handler, bool multicast_group_leave)
 | 
			
		||||
{
 | 
			
		||||
    if(handler){
 | 
			
		||||
        if (multicast_group_leave) {
 | 
			
		||||
            coap_multicast_group_join_or_leave(handler->socket->socket, SOCKET_IPV6_LEAVE_GROUP, handler->socket_interface_selection);
 | 
			
		||||
        }
 | 
			
		||||
       int_socket_delete(handler->socket);
 | 
			
		||||
       ns_dyn_mem_free(handler);
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -810,7 +847,7 @@ int coap_connection_handler_open_connection(coap_conn_handler_t *handler, uint16
 | 
			
		|||
 | 
			
		||||
    internal_socket_t *current = !use_ephemeral_port?int_socket_find(listen_port, is_secure, is_real_socket, bypassSec):NULL;
 | 
			
		||||
    if (!current) {
 | 
			
		||||
        handler->socket = int_socket_create(listen_port, use_ephemeral_port, is_secure, is_real_socket, bypassSec);
 | 
			
		||||
        handler->socket = int_socket_create(listen_port, use_ephemeral_port, is_secure, is_real_socket, bypassSec, handler->socket_interface_selection, handler->registered_to_multicast);
 | 
			
		||||
        if (!handler->socket) {
 | 
			
		||||
            return -1;
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015-2016 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <string.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -57,6 +57,18 @@ static coap_transaction_t *transaction_find_server(uint16_t msg_id)
 | 
			
		|||
    return this;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static coap_transaction_t *transaction_find_client(uint16_t msg_id)
 | 
			
		||||
{
 | 
			
		||||
    coap_transaction_t *this = NULL;
 | 
			
		||||
    ns_list_foreach(coap_transaction_t, cur_ptr, &request_list) {
 | 
			
		||||
        if (cur_ptr->msg_id == msg_id && cur_ptr->client_request) {
 | 
			
		||||
            this = cur_ptr;
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return this;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static coap_transaction_t *transaction_find_by_address(uint8_t *address_ptr, uint16_t port)
 | 
			
		||||
{
 | 
			
		||||
    coap_transaction_t *this = NULL;
 | 
			
		||||
| 
						 | 
				
			
			@ -168,6 +180,10 @@ coap_msg_handler_t *coap_message_handler_init(void *(*used_malloc_func_ptr)(uint
 | 
			
		|||
        used_free_func_ptr(handle);
 | 
			
		||||
        return NULL;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* Set default buffer size for CoAP duplicate message detection */
 | 
			
		||||
    sn_coap_protocol_set_duplicate_buffer_size(handle->coap, DUPLICATE_MESSAGE_BUFFER_SIZE);
 | 
			
		||||
 | 
			
		||||
    return handle;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -391,6 +407,28 @@ int8_t coap_message_handler_response_send(coap_msg_handler_t *handle, int8_t ser
 | 
			
		|||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int8_t coap_message_handler_request_delete(coap_msg_handler_t *handle, int8_t service_id, uint16_t msg_id)
 | 
			
		||||
{
 | 
			
		||||
    coap_transaction_t *transaction_ptr;
 | 
			
		||||
    (void)service_id;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    tr_debug("Service %d, delete CoAP request %d", service_id, msg_id);
 | 
			
		||||
    if (!handle) {
 | 
			
		||||
        tr_error("invalid params");
 | 
			
		||||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
    sn_coap_protocol_delete_retransmission(handle->coap, msg_id);
 | 
			
		||||
 | 
			
		||||
    transaction_ptr = transaction_find_client(msg_id);
 | 
			
		||||
    if (!transaction_ptr) {
 | 
			
		||||
        tr_error("response transaction not found");
 | 
			
		||||
        return -2;
 | 
			
		||||
    }
 | 
			
		||||
    transaction_delete(transaction_ptr);
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int8_t coap_message_handler_exec(coap_msg_handler_t *handle, uint32_t current_time){
 | 
			
		||||
 | 
			
		||||
    if( !handle ){
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015-2016 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <string.h>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015-2016 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -21,6 +21,7 @@
 | 
			
		|||
#include "net_interface.h"
 | 
			
		||||
#include "coap_service_api_internal.h"
 | 
			
		||||
#include "coap_message_handler.h"
 | 
			
		||||
#include "mbed-coap/sn_coap_protocol.h"
 | 
			
		||||
 | 
			
		||||
static int16_t coap_msg_process_callback(int8_t socket_id, sn_coap_hdr_s *coap_message, coap_transaction_t *transaction_ptr);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -99,6 +100,27 @@ static coap_service_t *service_find_by_uri(uint8_t socket_id, uint8_t *uri_ptr,
 | 
			
		|||
    return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static bool coap_service_can_leave_multicast_group(coap_conn_handler_t *conn_handler)
 | 
			
		||||
{
 | 
			
		||||
    int mc_count = 0;
 | 
			
		||||
    bool current_handler_joined_to_mc_group = false;
 | 
			
		||||
 | 
			
		||||
    ns_list_foreach(coap_service_t, cur_ptr, &instance_list) {
 | 
			
		||||
        if (cur_ptr->conn_handler && cur_ptr->conn_handler->registered_to_multicast) {
 | 
			
		||||
            if (conn_handler == cur_ptr->conn_handler) {
 | 
			
		||||
                current_handler_joined_to_mc_group = true;
 | 
			
		||||
            }
 | 
			
		||||
            mc_count ++;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (mc_count == 1 && current_handler_joined_to_mc_group) {
 | 
			
		||||
        // current handler is the only one joined to multicast group
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *  Coap handling functions
 | 
			
		||||
| 
						 | 
				
			
			@ -280,9 +302,8 @@ static int get_passwd_cb(int8_t socket_id, uint8_t address[static 16], uint16_t
 | 
			
		|||
int8_t coap_service_initialize(int8_t interface_id, uint16_t listen_port, uint8_t service_options,
 | 
			
		||||
                                 coap_service_security_start_cb *start_ptr, coap_service_security_done_cb *coap_security_done_cb)
 | 
			
		||||
{
 | 
			
		||||
    (void) interface_id;
 | 
			
		||||
 | 
			
		||||
    coap_service_t *this = ns_dyn_mem_alloc(sizeof(coap_service_t));
 | 
			
		||||
 | 
			
		||||
    if (!this) {
 | 
			
		||||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -293,6 +314,7 @@ int8_t coap_service_initialize(int8_t interface_id, uint16_t listen_port, uint8_
 | 
			
		|||
    while (service_find(id) && id < 127) {
 | 
			
		||||
        id++;
 | 
			
		||||
    }
 | 
			
		||||
    this->interface_id = interface_id;
 | 
			
		||||
    this->service_id = id;
 | 
			
		||||
    this->service_options = service_options;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -310,10 +332,18 @@ int8_t coap_service_initialize(int8_t interface_id, uint16_t listen_port, uint8_
 | 
			
		|||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (0 > coap_connection_handler_open_connection(this->conn_handler, listen_port, ((this->service_options & COAP_SERVICE_OPTIONS_EPHEMERAL_PORT) == COAP_SERVICE_OPTIONS_EPHEMERAL_PORT),
 | 
			
		||||
                                              ((this->service_options & COAP_SERVICE_OPTIONS_SECURE) == COAP_SERVICE_OPTIONS_SECURE),
 | 
			
		||||
                                              ((this->service_options & COAP_SERVICE_OPTIONS_VIRTUAL_SOCKET) != COAP_SERVICE_OPTIONS_VIRTUAL_SOCKET),
 | 
			
		||||
                                              ((this->service_options & COAP_SERVICE_OPTIONS_SECURE_BYPASS) == COAP_SERVICE_OPTIONS_SECURE_BYPASS))){
 | 
			
		||||
    this->conn_handler->socket_interface_selection = 0; // zero is illegal interface ID
 | 
			
		||||
    if (this->service_options & COAP_SERVICE_OPTIONS_SELECT_SOCKET_IF) {
 | 
			
		||||
        this->conn_handler->socket_interface_selection = this->interface_id;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    this->conn_handler->registered_to_multicast = this->service_options & COAP_SERVICE_OPTIONS_MULTICAST_JOIN;
 | 
			
		||||
 | 
			
		||||
    if (0 > coap_connection_handler_open_connection(this->conn_handler, listen_port,
 | 
			
		||||
            (this->service_options & COAP_SERVICE_OPTIONS_EPHEMERAL_PORT),
 | 
			
		||||
            (this->service_options & COAP_SERVICE_OPTIONS_SECURE),
 | 
			
		||||
            !(this->service_options & COAP_SERVICE_OPTIONS_VIRTUAL_SOCKET),
 | 
			
		||||
            (this->service_options & COAP_SERVICE_OPTIONS_SECURE_BYPASS))) {
 | 
			
		||||
        ns_dyn_mem_free(this->conn_handler);
 | 
			
		||||
        ns_dyn_mem_free(this);
 | 
			
		||||
        return -1;
 | 
			
		||||
| 
						 | 
				
			
			@ -340,7 +370,12 @@ void coap_service_delete(int8_t service_id)
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    if (this->conn_handler){
 | 
			
		||||
        connection_handler_destroy(this->conn_handler);
 | 
			
		||||
        bool leave_multicast_group = false;
 | 
			
		||||
        if (coap_service_can_leave_multicast_group(this->conn_handler)) {
 | 
			
		||||
            // This is the last handler joined to multicast group
 | 
			
		||||
            leave_multicast_group = true;
 | 
			
		||||
        }
 | 
			
		||||
        connection_handler_destroy(this->conn_handler, leave_multicast_group);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //TODO clear all transactions
 | 
			
		||||
| 
						 | 
				
			
			@ -459,6 +494,11 @@ int8_t coap_service_response_send(int8_t service_id, uint8_t options, sn_coap_hd
 | 
			
		|||
    return coap_message_handler_response_send(coap_service_handle, service_id, options, request_ptr, message_code, content_type, payload_ptr, payload_len);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int8_t coap_service_request_delete(int8_t service_id, uint16_t msg_id)
 | 
			
		||||
{
 | 
			
		||||
    return coap_message_handler_request_delete(coap_service_handle, service_id, msg_id);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int8_t coap_service_set_handshake_timeout(int8_t service_id, uint32_t min, uint32_t max)
 | 
			
		||||
{
 | 
			
		||||
    coap_service_t *this = service_find(service_id);
 | 
			
		||||
| 
						 | 
				
			
			@ -469,6 +509,17 @@ int8_t coap_service_set_handshake_timeout(int8_t service_id, uint32_t min, uint3
 | 
			
		|||
    return coap_connection_handler_set_timeout(this->conn_handler, min, max);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int8_t coap_service_set_duplicate_message_buffer(int8_t service_id, uint8_t size)
 | 
			
		||||
{
 | 
			
		||||
    (void) service_id;
 | 
			
		||||
 | 
			
		||||
    if (!coap_service_handle) {
 | 
			
		||||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return sn_coap_protocol_set_duplicate_buffer_size(coap_service_handle->coap, size);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint32_t coap_service_get_internal_timer_ticks(void)
 | 
			
		||||
{
 | 
			
		||||
    return coap_ticks;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			@ -44,6 +44,8 @@ typedef struct coap_conn_handler_s{
 | 
			
		|||
    send_to_socket_cb *_send_cb;
 | 
			
		||||
    get_pw_cb *_get_password_cb;
 | 
			
		||||
    security_done_cb *_security_done_cb;
 | 
			
		||||
    int8_t socket_interface_selection;
 | 
			
		||||
    bool registered_to_multicast;
 | 
			
		||||
} coap_conn_handler_t;
 | 
			
		||||
 | 
			
		||||
coap_conn_handler_t *connection_handler_create(receive_from_socket_cb *recv_from_cb,
 | 
			
		||||
| 
						 | 
				
			
			@ -51,7 +53,7 @@ coap_conn_handler_t *connection_handler_create(receive_from_socket_cb *recv_from
 | 
			
		|||
                                                 get_pw_cb *pw_cb,
 | 
			
		||||
                                                 security_done_cb *done_cb);
 | 
			
		||||
 | 
			
		||||
void connection_handler_destroy( coap_conn_handler_t *handler );
 | 
			
		||||
void connection_handler_destroy( coap_conn_handler_t *handler, bool multicast_group_leave);
 | 
			
		||||
 | 
			
		||||
void connection_handler_close_secure_connection( coap_conn_handler_t *handler, uint8_t destination_addr_ptr[static 16], uint16_t port );
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015-2016 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			@ -24,6 +24,8 @@
 | 
			
		|||
#include "ns_list.h"
 | 
			
		||||
 | 
			
		||||
#define TRANSACTION_LIFETIME 180
 | 
			
		||||
/* Default value for CoAP duplicate message buffer (0 = disabled) */
 | 
			
		||||
#define DUPLICATE_MESSAGE_BUFFER_SIZE 0
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * \brief Service message response receive callback.
 | 
			
		||||
| 
						 | 
				
			
			@ -83,6 +85,8 @@ extern uint16_t coap_message_handler_request_send(coap_msg_handler_t *handle, in
 | 
			
		|||
extern int8_t coap_message_handler_response_send(coap_msg_handler_t *handle, int8_t service_id, uint8_t options, sn_coap_hdr_s *request_ptr, sn_coap_msg_code_e message_code,
 | 
			
		||||
        sn_coap_content_format_e content_type, const uint8_t *payload_ptr, uint16_t payload_len);
 | 
			
		||||
 | 
			
		||||
extern int8_t coap_message_handler_request_delete(coap_msg_handler_t *handle, int8_t service_id, uint16_t msg_id);
 | 
			
		||||
 | 
			
		||||
extern int8_t coap_message_handler_exec(coap_msg_handler_t *handle, uint32_t current_time);
 | 
			
		||||
 | 
			
		||||
extern void transaction_delete(coap_transaction_t *this);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015-2016 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM. All rights reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM. All rights reserved.
 | 
			
		||||
 */
 | 
			
		||||
#include "CppUTest/TestHarness.h"
 | 
			
		||||
#include "test_coap_connection_handler.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM. All rights reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM. All rights reserved.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "CppUTest/CommandLineTestRunner.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015-2016 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
#include "test_coap_connection_handler.h"
 | 
			
		||||
#include <string.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -57,7 +57,7 @@ bool test_connection_handler_destroy()
 | 
			
		|||
    nsdynmemlib_stub.returnCounter = 1;
 | 
			
		||||
    coap_conn_handler_t *handler = connection_handler_create(&receive_from_sock_cb, NULL, NULL, NULL);
 | 
			
		||||
 | 
			
		||||
    connection_handler_destroy(handler);
 | 
			
		||||
    connection_handler_destroy(handler, false);
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -97,8 +97,8 @@ bool test_coap_connection_handler_open_connection()
 | 
			
		|||
    if( 0 != coap_connection_handler_open_connection(handler, 23,false,false,false,false) )
 | 
			
		||||
        return false;
 | 
			
		||||
 | 
			
		||||
    connection_handler_destroy(handler2);
 | 
			
		||||
    connection_handler_destroy(handler);
 | 
			
		||||
    connection_handler_destroy(handler2, false);
 | 
			
		||||
    connection_handler_destroy(handler, false);
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -121,7 +121,7 @@ bool test_coap_connection_handler_send_data()
 | 
			
		|||
    if( -1 != coap_connection_handler_send_data(handler, &addr, ns_in6addr_any, NULL, 0, true))
 | 
			
		||||
        return false;
 | 
			
		||||
 | 
			
		||||
    connection_handler_destroy(handler);
 | 
			
		||||
    connection_handler_destroy(handler, false);
 | 
			
		||||
 | 
			
		||||
    coap_security_handler_stub.sec_obj = coap_security_handler_stub_alloc();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -137,7 +137,7 @@ bool test_coap_connection_handler_send_data()
 | 
			
		|||
    if( -1 != coap_connection_handler_send_data(handler, &addr, ns_in6addr_any, NULL, 0, true))
 | 
			
		||||
        return false;
 | 
			
		||||
 | 
			
		||||
    connection_handler_destroy(handler);
 | 
			
		||||
    connection_handler_destroy(handler, false);
 | 
			
		||||
 | 
			
		||||
    free(coap_security_handler_stub.sec_obj);
 | 
			
		||||
    coap_security_handler_stub.sec_obj = NULL;
 | 
			
		||||
| 
						 | 
				
			
			@ -152,7 +152,7 @@ bool test_coap_connection_handler_send_data()
 | 
			
		|||
 | 
			
		||||
    if( 1 != coap_connection_handler_send_data(handler, &addr, ns_in6addr_any, NULL, 0, true))
 | 
			
		||||
        return false;
 | 
			
		||||
    connection_handler_destroy(handler);
 | 
			
		||||
    connection_handler_destroy(handler ,false);
 | 
			
		||||
 | 
			
		||||
    nsdynmemlib_stub.returnCounter = 1;
 | 
			
		||||
    handler = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, NULL, NULL);
 | 
			
		||||
| 
						 | 
				
			
			@ -163,7 +163,7 @@ bool test_coap_connection_handler_send_data()
 | 
			
		|||
    socket_api_stub.int8_value = 7;
 | 
			
		||||
    if( 7 != coap_connection_handler_send_data(handler, &addr, ns_in6addr_any, NULL, 0, true))
 | 
			
		||||
        return false;
 | 
			
		||||
    connection_handler_destroy(handler);
 | 
			
		||||
    connection_handler_destroy(handler, false);
 | 
			
		||||
 | 
			
		||||
    //<-- NON SECURE HERE
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -209,7 +209,7 @@ bool test_coap_connection_handler_virtual_recv()
 | 
			
		|||
    if( -1 != coap_connection_handler_virtual_recv(handler,buf, 12, &buf, 1) )
 | 
			
		||||
        return false;
 | 
			
		||||
 | 
			
		||||
    connection_handler_destroy(handler);
 | 
			
		||||
    connection_handler_destroy(handler, false);
 | 
			
		||||
 | 
			
		||||
    nsdynmemlib_stub.returnCounter = 1;
 | 
			
		||||
    coap_conn_handler_t *handler2 = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, &get_passwd_cb, &sec_done_cb);
 | 
			
		||||
| 
						 | 
				
			
			@ -235,7 +235,7 @@ bool test_coap_connection_handler_virtual_recv()
 | 
			
		|||
    if( 0 != coap_connection_handler_virtual_recv(handler2,buf, 12, &buf, 1) )
 | 
			
		||||
        return false;
 | 
			
		||||
 | 
			
		||||
    connection_handler_destroy(handler2);
 | 
			
		||||
    connection_handler_destroy(handler2, false);
 | 
			
		||||
 | 
			
		||||
    free(coap_security_handler_stub.sec_obj);
 | 
			
		||||
    coap_security_handler_stub.sec_obj = NULL;
 | 
			
		||||
| 
						 | 
				
			
			@ -250,7 +250,7 @@ bool test_coap_connection_handler_virtual_recv()
 | 
			
		|||
    if( 0 != coap_connection_handler_virtual_recv(handler3,buf, 12, &buf, 1) )
 | 
			
		||||
        return false;
 | 
			
		||||
 | 
			
		||||
    connection_handler_destroy(handler3);
 | 
			
		||||
    connection_handler_destroy(handler3, false);
 | 
			
		||||
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -273,7 +273,7 @@ bool test_coap_connection_handler_socket_belongs_to()
 | 
			
		|||
 | 
			
		||||
    if( false != coap_connection_handler_socket_belongs_to(handler, 3) )
 | 
			
		||||
        return false;
 | 
			
		||||
    connection_handler_destroy(handler);
 | 
			
		||||
    connection_handler_destroy(handler, false);
 | 
			
		||||
 | 
			
		||||
    nsdynmemlib_stub.returnCounter = 0;
 | 
			
		||||
    return true;
 | 
			
		||||
| 
						 | 
				
			
			@ -326,7 +326,7 @@ bool test_timer_callbacks()
 | 
			
		|||
        coap_security_handler_stub.int_value = 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    connection_handler_destroy(handler);
 | 
			
		||||
    connection_handler_destroy(handler, false);
 | 
			
		||||
    free(coap_security_handler_stub.sec_obj);
 | 
			
		||||
    coap_security_handler_stub.sec_obj = NULL;
 | 
			
		||||
    return true;
 | 
			
		||||
| 
						 | 
				
			
			@ -364,7 +364,7 @@ bool test_socket_api_callbacks()
 | 
			
		|||
        socket_api_stub.recv_cb(sckt_data);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    connection_handler_destroy(handler);
 | 
			
		||||
    connection_handler_destroy(handler, false);
 | 
			
		||||
 | 
			
		||||
    nsdynmemlib_stub.returnCounter = 1;
 | 
			
		||||
    coap_conn_handler_t *handler2 = connection_handler_create(&receive_from_sock_cb, &send_to_sock_cb, &get_passwd_cb, &sec_done_cb);
 | 
			
		||||
| 
						 | 
				
			
			@ -401,7 +401,7 @@ bool test_socket_api_callbacks()
 | 
			
		|||
        socket_api_stub.recv_cb(sckt_data);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    connection_handler_destroy(handler2);
 | 
			
		||||
    connection_handler_destroy(handler2, false);
 | 
			
		||||
 | 
			
		||||
    free(coap_security_handler_stub.sec_obj);
 | 
			
		||||
    coap_security_handler_stub.sec_obj = NULL;
 | 
			
		||||
| 
						 | 
				
			
			@ -444,7 +444,7 @@ bool test_security_callbacks()
 | 
			
		|||
        coap_security_handler_stub.receive_cb(0, &buf, 16);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    connection_handler_destroy(handler);
 | 
			
		||||
    connection_handler_destroy(handler, false);
 | 
			
		||||
 | 
			
		||||
    free(coap_security_handler_stub.sec_obj);
 | 
			
		||||
    coap_security_handler_stub.sec_obj = NULL;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM. All rights reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM. All rights reserved.
 | 
			
		||||
 */
 | 
			
		||||
#include "CppUTest/TestHarness.h"
 | 
			
		||||
#include "test_coap_message_handler.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -45,8 +45,14 @@ TEST(coap_message_handler, test_coap_message_handler_response_send)
 | 
			
		|||
    CHECK(test_coap_message_handler_response_send());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST(coap_message_handler, test_coap_message_handler_request_delete)
 | 
			
		||||
{
 | 
			
		||||
    CHECK(test_coap_message_handler_request_delete());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST(coap_message_handler, test_coap_message_handler_exec)
 | 
			
		||||
{
 | 
			
		||||
    CHECK(test_coap_message_handler_exec());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM. All rights reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM. All rights reserved.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "CppUTest/CommandLineTestRunner.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
#include "test_coap_message_handler.h"
 | 
			
		||||
#include <string.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -229,6 +229,39 @@ bool test_coap_message_handler_request_send()
 | 
			
		|||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool test_coap_message_handler_request_delete()
 | 
			
		||||
{
 | 
			
		||||
    retCounter = 1;
 | 
			
		||||
    sn_coap_protocol_stub.expectedCoap = (struct coap_s*)malloc(sizeof(struct coap_s));
 | 
			
		||||
    memset(sn_coap_protocol_stub.expectedCoap, 0, sizeof(struct coap_s));
 | 
			
		||||
    coap_msg_handler_t *handle = coap_message_handler_init(&own_alloc, &own_free, &coap_tx_function);
 | 
			
		||||
 | 
			
		||||
    uint8_t buf[16];
 | 
			
		||||
    memset(&buf, 1, 16);
 | 
			
		||||
    char uri[3];
 | 
			
		||||
    uri[0] = "r";
 | 
			
		||||
    uri[1] = "s";
 | 
			
		||||
    uri[2] = "\0";
 | 
			
		||||
    if( 0 == coap_message_handler_request_delete(NULL, 1, 1))
 | 
			
		||||
        return false;
 | 
			
		||||
 | 
			
		||||
    if( 0 == coap_message_handler_request_delete(handle, 1, 1))
 | 
			
		||||
        return false;
 | 
			
		||||
 | 
			
		||||
    sn_coap_builder_stub.expectedUint16 = 1;
 | 
			
		||||
    nsdynmemlib_stub.returnCounter = 3;
 | 
			
		||||
    if( 2 != coap_message_handler_request_send(handle, 3, 0, buf, 24, 1, 2, &uri, 4, NULL, 0, &resp_recv))
 | 
			
		||||
        return false;
 | 
			
		||||
 | 
			
		||||
    if( 0 != coap_message_handler_request_delete(handle, 1, 2))
 | 
			
		||||
        return false;
 | 
			
		||||
 | 
			
		||||
    free(sn_coap_protocol_stub.expectedCoap);
 | 
			
		||||
    sn_coap_protocol_stub.expectedCoap = NULL;
 | 
			
		||||
    coap_message_handler_destroy(handle);
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool test_coap_message_handler_response_send()
 | 
			
		||||
{
 | 
			
		||||
    if( -1 != coap_message_handler_response_send(NULL, 2, 0, NULL, 1,3,NULL, 0))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			@ -30,6 +30,7 @@ bool test_coap_message_handler_find_transaction();
 | 
			
		|||
bool test_coap_message_handler_coap_msg_process();
 | 
			
		||||
bool test_coap_message_handler_request_send();
 | 
			
		||||
bool test_coap_message_handler_response_send();
 | 
			
		||||
bool test_coap_message_handler_request_delete();
 | 
			
		||||
bool test_coap_message_handler_exec();
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM. All rights reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM. All rights reserved.
 | 
			
		||||
 */
 | 
			
		||||
#include "CppUTest/TestHarness.h"
 | 
			
		||||
#include "test_coap_security_handler.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM. All rights reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM. All rights reserved.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "CppUTest/CommandLineTestRunner.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015-2016 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
#include "test_coap_security_handler.h"
 | 
			
		||||
#include "coap_security_handler.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,7 +17,8 @@ TEST_SRC_FILES = \
 | 
			
		|||
	../stub/eventOS_event_stub.c \
 | 
			
		||||
	../stub/coap_connection_handler_stub.c \
 | 
			
		||||
	../stub/coap_message_handler_stub.c \
 | 
			
		||||
	../stub/common_functions_stub.c
 | 
			
		||||
	../stub/common_functions_stub.c \
 | 
			
		||||
	../stub/sn_coap_protocol_stub.c
 | 
			
		||||
 | 
			
		||||
include ../MakefileWorker.mk
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM. All rights reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM. All rights reserved.
 | 
			
		||||
 */
 | 
			
		||||
#include "CppUTest/TestHarness.h"
 | 
			
		||||
#include "test_coap_service_api.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -50,6 +50,11 @@ TEST(coap_service_api, test_coap_service_request_send)
 | 
			
		|||
    CHECK(test_coap_service_request_send());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST(coap_service_api, test_coap_service_request_delete)
 | 
			
		||||
{
 | 
			
		||||
    CHECK(test_coap_service_request_delete());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST(coap_service_api, test_coap_service_response_send)
 | 
			
		||||
{
 | 
			
		||||
    CHECK(test_coap_service_response_send());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM. All rights reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM. All rights reserved.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "CppUTest/CommandLineTestRunner.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
#include "test_coap_service_api.h"
 | 
			
		||||
#include <string.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -215,6 +215,13 @@ bool test_coap_service_request_send()
 | 
			
		|||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool test_coap_service_request_delete()
 | 
			
		||||
{
 | 
			
		||||
    if( 0 != coap_service_request_delete(NULL,0))
 | 
			
		||||
        return false;
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool test_coap_service_response_send()
 | 
			
		||||
{
 | 
			
		||||
    uint8_t buf[16];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			@ -38,6 +38,8 @@ bool test_coap_service_unregister_uri();
 | 
			
		|||
 | 
			
		||||
bool test_coap_service_request_send();
 | 
			
		||||
 | 
			
		||||
bool test_coap_service_request_delete();
 | 
			
		||||
 | 
			
		||||
bool test_coap_service_response_send();
 | 
			
		||||
 | 
			
		||||
bool test_coap_callbacks();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <string.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -32,7 +32,7 @@ coap_conn_handler_t *connection_handler_create(int (*recv_cb)(int8_t socket_id,
 | 
			
		|||
    return thread_conn_handler_stub.handler_obj;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void connection_handler_destroy(coap_conn_handler_t *handler)
 | 
			
		||||
void connection_handler_destroy( coap_conn_handler_t *handler, bool multicast_group_leave)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015-2016 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "coap_message_handler_stub.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -60,6 +60,11 @@ int8_t coap_message_handler_response_send(coap_msg_handler_t *handle, int8_t ser
 | 
			
		|||
    return coap_message_handler_stub.int8_value;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int8_t coap_message_handler_request_delete(coap_msg_handler_t *handle, int8_t service_id, uint16_t msg_id)
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int8_t coap_message_handler_exec(coap_msg_handler_t *handle, uint32_t current_time)
 | 
			
		||||
{
 | 
			
		||||
    return coap_message_handler_stub.int8_value;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015-2016 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <string.h>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015-2016 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015-2016 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <string.h>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <string.h>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2014-2015 ARM Limited. All rights reserved.
 | 
			
		||||
 * Copyright (c) 2014-2017 ARM Limited. All rights reserved.
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the License); you may
 | 
			
		||||
 * not use this file except in compliance with the License.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "mbedtls_stub.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define NS_LIST_FN extern
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2014-2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2014-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
#include "ns_types.h"
 | 
			
		||||
#include "ns_list.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2014-2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2014-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
#include "nsdynmemLIB_stub.h"
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -10,11 +10,19 @@
 | 
			
		|||
 | 
			
		||||
nsdynmemlib_stub_data_t nsdynmemlib_stub;
 | 
			
		||||
 | 
			
		||||
#if NSDYNMEMLIB_API_VERSION < 2
 | 
			
		||||
typedef int16_t ns_mem_block_size_t;
 | 
			
		||||
typedef int16_t ns_mem_heap_size_t;
 | 
			
		||||
void ns_dyn_mem_init(uint8_t *heap, uint16_t h_size, void (*passed_fptr)(heap_fail_t), mem_stat_t *info_ptr)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
void ns_dyn_mem_init(void *heap, uint16_t h_size, void (*passed_fptr)(heap_fail_t), mem_stat_t *info_ptr)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void *ns_dyn_mem_alloc(int16_t alloc_size)
 | 
			
		||||
void *ns_dyn_mem_alloc(ns_mem_block_size_t alloc_size)
 | 
			
		||||
{
 | 
			
		||||
    if (nsdynmemlib_stub.returnCounter > 0)
 | 
			
		||||
    {
 | 
			
		||||
| 
						 | 
				
			
			@ -27,7 +35,7 @@ void *ns_dyn_mem_alloc(int16_t alloc_size)
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void *ns_dyn_mem_temporary_alloc(int16_t alloc_size)
 | 
			
		||||
void *ns_dyn_mem_temporary_alloc(ns_mem_block_size_t alloc_size)
 | 
			
		||||
{
 | 
			
		||||
    if (nsdynmemlib_stub.returnCounter > 0)
 | 
			
		||||
    {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			@ -31,11 +31,6 @@ typedef struct {
 | 
			
		|||
 | 
			
		||||
extern nsdynmemlib_stub_data_t nsdynmemlib_stub;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void *ns_dyn_mem_alloc(int16_t alloc_size);
 | 
			
		||||
void *ns_dyn_mem_temporary_alloc(int16_t alloc_size);
 | 
			
		||||
void ns_dyn_mem_free(void *block);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2014-2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2014-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2011-2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2011-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2011-2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2011-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2011-2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2011-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
#include "socket_api.h"
 | 
			
		||||
#include "socket_api_stub.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2014-2015 ARM Limited. All Rights Reserved.
 | 
			
		||||
 * Copyright (c) 2014-2017 ARM Limited. All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
#include "ns_types.h"
 | 
			
		||||
#include "timer_sys.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
# Copyright (c) 2015 ARM Limited. All rights reserved.
 | 
			
		||||
# Copyright (c) 2015-2017 ARM Limited. All rights reserved.
 | 
			
		||||
# SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
# Licensed under the Apache License, Version 2.0 (the License); you may
 | 
			
		||||
# not use this file except in compliance with the License.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue