diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/coap-service/coap_service_api.h b/features/nanostack/FEATURE_NANOSTACK/coap-service/coap-service/coap_service_api.h index 8a9a1fd754..14a7d39ec6 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/coap-service/coap_service_api.h +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/coap-service/coap_service_api.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 * @@ -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 diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/run_unit_tests.sh b/features/nanostack/FEATURE_NANOSTACK/coap-service/run_unit_tests.sh index b29b0a963e..ad3b53acd6 100755 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/run_unit_tests.sh +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/run_unit_tests.sh @@ -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. diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/source/coap_connection_handler.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/source/coap_connection_handler.c index b04e127d51..722a05c15c 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/source/coap_connection_handler.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/source/coap_connection_handler.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016 ARM Limited. All Rights Reserved. + * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved. */ #include @@ -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; } diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/source/coap_message_handler.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/source/coap_message_handler.c index 72c9e86af5..2bd05770d4 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/source/coap_message_handler.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/source/coap_message_handler.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016 ARM Limited. All Rights Reserved. + * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved. */ #include @@ -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 ){ diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/source/coap_security_handler.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/source/coap_security_handler.c index 6113cf96ae..5e920208b9 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/source/coap_security_handler.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/source/coap_security_handler.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016 ARM Limited. All Rights Reserved. + * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved. */ #include diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/source/coap_service_api.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/source/coap_service_api.c index 3341615131..50fdef713b 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/source/coap_service_api.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/source/coap_service_api.c @@ -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; diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/source/include/coap_connection_handler.h b/features/nanostack/FEATURE_NANOSTACK/coap-service/source/include/coap_connection_handler.h index d5ed73e252..179fb24119 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/source/include/coap_connection_handler.h +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/source/include/coap_connection_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 * @@ -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 ); diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/source/include/coap_message_handler.h b/features/nanostack/FEATURE_NANOSTACK/coap-service/source/include/coap_message_handler.h index 6cd4d8f7d6..9cfa6a4e3e 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/source/include/coap_message_handler.h +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/source/include/coap_message_handler.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 * @@ -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); diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/source/include/coap_security_handler.h b/features/nanostack/FEATURE_NANOSTACK/coap-service/source/include/coap_security_handler.h index 525f3c38d6..f02167e028 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/source/include/coap_security_handler.h +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/source/include/coap_security_handler.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 * diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_connection_handler/coap_connection_handlertest.cpp b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_connection_handler/coap_connection_handlertest.cpp index 383d42b6b8..4fba1d58aa 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_connection_handler/coap_connection_handlertest.cpp +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_connection_handler/coap_connection_handlertest.cpp @@ -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" diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_connection_handler/main.cpp b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_connection_handler/main.cpp index c04ec8b369..79821a9641 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_connection_handler/main.cpp +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_connection_handler/main.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 ARM. All rights reserved. + * Copyright (c) 2015-2017 ARM. All rights reserved. */ #include "CppUTest/CommandLineTestRunner.h" diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_connection_handler/test_coap_connection_handler.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_connection_handler/test_coap_connection_handler.c index 98225a201e..fb691ee41e 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_connection_handler/test_coap_connection_handler.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_connection_handler/test_coap_connection_handler.c @@ -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 @@ -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; diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_connection_handler/test_coap_connection_handler.h b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_connection_handler/test_coap_connection_handler.h index f13725af58..421489130b 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_connection_handler/test_coap_connection_handler.h +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_connection_handler/test_coap_connection_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 * diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_message_handler/coap_message_handlertest.cpp b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_message_handler/coap_message_handlertest.cpp index e36d92667d..7f86bdfe2f 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_message_handler/coap_message_handlertest.cpp +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_message_handler/coap_message_handlertest.cpp @@ -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()); } + diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_message_handler/main.cpp b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_message_handler/main.cpp index f042e6bdeb..3b01cc3532 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_message_handler/main.cpp +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_message_handler/main.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 ARM. All rights reserved. + * Copyright (c) 2015-2017 ARM. All rights reserved. */ #include "CppUTest/CommandLineTestRunner.h" diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_message_handler/test_coap_message_handler.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_message_handler/test_coap_message_handler.c index 510c103315..a1b7ffd748 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_message_handler/test_coap_message_handler.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_message_handler/test_coap_message_handler.c @@ -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 @@ -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)) diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_message_handler/test_coap_message_handler.h b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_message_handler/test_coap_message_handler.h index 93a18f1ccd..cd6f147927 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_message_handler/test_coap_message_handler.h +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_message_handler/test_coap_message_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 * @@ -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 diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_security_handler/coap_security_handlertest.cpp b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_security_handler/coap_security_handlertest.cpp index a649a0fb96..2269895a3b 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_security_handler/coap_security_handlertest.cpp +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_security_handler/coap_security_handlertest.cpp @@ -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" diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_security_handler/main.cpp b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_security_handler/main.cpp index e657503fd1..5ff09722fd 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_security_handler/main.cpp +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_security_handler/main.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 ARM. All rights reserved. + * Copyright (c) 2015-2017 ARM. All rights reserved. */ #include "CppUTest/CommandLineTestRunner.h" diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_security_handler/test_coap_security_handler.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_security_handler/test_coap_security_handler.c index 9d777ca242..160d4dfac7 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_security_handler/test_coap_security_handler.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_security_handler/test_coap_security_handler.c @@ -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" diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_security_handler/test_coap_security_handler.h b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_security_handler/test_coap_security_handler.h index 1b06bed343..e2002056de 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_security_handler/test_coap_security_handler.h +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_security_handler/test_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 * diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_service_api/Makefile b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_service_api/Makefile index e0ba84a4fb..cc8c0a3cce 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_service_api/Makefile +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_service_api/Makefile @@ -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 diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_service_api/coap_service_apitest.cpp b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_service_api/coap_service_apitest.cpp index 9054de6313..412ef3e6d7 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_service_api/coap_service_apitest.cpp +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_service_api/coap_service_apitest.cpp @@ -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()); diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_service_api/main.cpp b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_service_api/main.cpp index e050cec95f..437d37bbae 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_service_api/main.cpp +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_service_api/main.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 ARM. All rights reserved. + * Copyright (c) 2015-2017 ARM. All rights reserved. */ #include "CppUTest/CommandLineTestRunner.h" diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_service_api/test_coap_service_api.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_service_api/test_coap_service_api.c index 68eead7a92..052d51693a 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_service_api/test_coap_service_api.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_service_api/test_coap_service_api.c @@ -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 @@ -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]; diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_service_api/test_coap_service_api.h b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_service_api/test_coap_service_api.h index 94916476c3..01600c4921 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_service_api/test_coap_service_api.h +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/coap_service_api/test_coap_service_api.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 * @@ -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(); diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_connection_handler_stub.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_connection_handler_stub.c index 0d0ae063d3..23e5e881dd 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_connection_handler_stub.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_connection_handler_stub.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 ARM Limited. All Rights Reserved. + * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved. */ #include @@ -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) { } diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_connection_handler_stub.h b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_connection_handler_stub.h index 7a575bbd21..f8b361bd62 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_connection_handler_stub.h +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_connection_handler_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 * diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_message_handler_stub.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_message_handler_stub.c index 00652259f0..54d4759a60 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_message_handler_stub.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_message_handler_stub.c @@ -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; diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_message_handler_stub.h b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_message_handler_stub.h index 5cbb974160..4c40ca4811 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_message_handler_stub.h +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_message_handler_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 * diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_security_handler_stub.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_security_handler_stub.c index 3e68d37706..d814a1d1ba 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_security_handler_stub.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_security_handler_stub.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016 ARM Limited. All Rights Reserved. + * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved. */ #include diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_security_handler_stub.h b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_security_handler_stub.h index cbd0f7a132..cf71579138 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_security_handler_stub.h +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_security_handler_stub.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 * diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_service_api_stub.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_service_api_stub.c index 29d6c59a3b..dec482f0cb 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_service_api_stub.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/coap_service_api_stub.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016 ARM Limited. All Rights Reserved. + * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved. */ #include diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/eventOS_event_stub.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/eventOS_event_stub.c index e2a532e01d..594d26b973 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/eventOS_event_stub.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/eventOS_event_stub.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 ARM Limited. All Rights Reserved. + * Copyright (c) 2015-2017 ARM Limited. All Rights Reserved. */ #include diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/eventOS_event_stub.h b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/eventOS_event_stub.h index fb2a9fc83f..b904c238eb 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/eventOS_event_stub.h +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/eventOS_event_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 * diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/mbed_trace_stub.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/mbed_trace_stub.c index 34dae55225..84b86b9048 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/mbed_trace_stub.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/mbed_trace_stub.c @@ -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. diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/mbedtls_stub.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/mbedtls_stub.c index d6d88e6acb..c73e4b9b00 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/mbedtls_stub.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/mbedtls_stub.c @@ -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" diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/mbedtls_stub.h b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/mbedtls_stub.h index 52402bd74f..536d6f9277 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/mbedtls_stub.h +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/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 * diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/ns_list_stub.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/ns_list_stub.c index 2d5e650d96..ce6e928088 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/ns_list_stub.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/ns_list_stub.c @@ -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 diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/ns_timer_stub.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/ns_timer_stub.c index f543d941b0..81e2fefe9a 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/ns_timer_stub.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/ns_timer_stub.c @@ -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" diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/ns_timer_stub.h b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/ns_timer_stub.h index 5db49ded5b..108e7c335e 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/ns_timer_stub.h +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/ns_timer_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 * diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/nsdynmemLIB_stub.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/nsdynmemLIB_stub.c index e3f16f2e6e..951c199fb4 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/nsdynmemLIB_stub.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/nsdynmemLIB_stub.c @@ -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 @@ -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) { diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/nsdynmemLIB_stub.h b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/nsdynmemLIB_stub.h index 46e5fc0e43..9ef61be6c8 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/nsdynmemLIB_stub.h +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/nsdynmemLIB_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 * @@ -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 diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/randLIB_stub.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/randLIB_stub.c index 29f22e1086..224a82e3b6 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/randLIB_stub.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/randLIB_stub.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2015 ARM Limited. All Rights Reserved. + * Copyright (c) 2014-2017 ARM Limited. All Rights Reserved. */ #include #include diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_builder_stub.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_builder_stub.c index 1d30a79cbc..7ed6a06dd7 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_builder_stub.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_builder_stub.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015 ARM Limited. All Rights Reserved. + * Copyright (c) 2011-2017 ARM Limited. All Rights Reserved. */ /** diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_builder_stub.h b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_builder_stub.h index 7ddc9c1944..32ceefebfc 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_builder_stub.h +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_builder_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 * diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_parser_stub.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_parser_stub.c index a1365aa9cb..a07dd2824e 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_parser_stub.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_parser_stub.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015 ARM Limited. All Rights Reserved. + * Copyright (c) 2011-2017 ARM Limited. All Rights Reserved. */ /** diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_parser_stub.h b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_parser_stub.h index 72be957164..b605e9977f 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_parser_stub.h +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_parser_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 * diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_protocol_stub.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_protocol_stub.c index a7f87e7931..cf6d210032 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_protocol_stub.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_protocol_stub.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015 ARM Limited. All Rights Reserved. + * Copyright (c) 2011-2017 ARM Limited. All Rights Reserved. */ diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_protocol_stub.h b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_protocol_stub.h index 0f8a67260d..77a073d32b 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_protocol_stub.h +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/sn_coap_protocol_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 * diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/socket_api_stub.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/socket_api_stub.c index 8fa094f49d..8daf0bd385 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/socket_api_stub.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/socket_api_stub.c @@ -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" diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/socket_api_stub.h b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/socket_api_stub.h index bc7dacf4a1..a942e48fb7 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/socket_api_stub.h +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/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 * diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/system_timer_stub.c b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/system_timer_stub.c index 7de1ab64f9..05c4ae29d0 100644 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/system_timer_stub.c +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/test/coap-service/unittest/stub/system_timer_stub.c @@ -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" diff --git a/features/nanostack/FEATURE_NANOSTACK/coap-service/xsl_script.sh b/features/nanostack/FEATURE_NANOSTACK/coap-service/xsl_script.sh index d5320b42b8..1581827ef5 100755 --- a/features/nanostack/FEATURE_NANOSTACK/coap-service/xsl_script.sh +++ b/features/nanostack/FEATURE_NANOSTACK/coap-service/xsl_script.sh @@ -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.