Skip to content

Commit 9dfc6f9

Browse files
author
Tero Heinonen
authored
Support for setting source address to socket (#40)
When receiving data, destination (own) address is stored and given to socket when sending reply to make sure respone comes always from same address where request was sent. This commit supports only real socket to real socket messages, not virtual socket, or DTLS handshake messages.
1 parent 9c88fcd commit 9dfc6f9

19 files changed

+272
-158
lines changed

source/coap_connection_handler.c

Lines changed: 177 additions & 90 deletions
Large diffs are not rendered by default.

source/coap_message_handler.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,15 @@ coap_transaction_t *coap_message_handler_find_transaction(uint8_t *address_ptr,
177177
return transaction_find_by_address( address_ptr, port );
178178
}
179179

180-
int16_t coap_message_handler_coap_msg_process(coap_msg_handler_t *handle, int8_t socket_id, uint8_t source_addr_ptr[static 16], uint16_t port,
180+
int16_t coap_message_handler_coap_msg_process(coap_msg_handler_t *handle, int8_t socket_id, const uint8_t source_addr_ptr[static 16], uint16_t port, const uint8_t dst_addr_ptr[static 16],
181181
uint8_t *data_ptr, uint16_t data_len, int16_t (cb)(int8_t, sn_coap_hdr_s *, coap_transaction_t *))
182182
{
183-
if( !cb || !handle ){
183+
if (!cb || !handle) {
184184
return -1;
185185
}
186186
sn_nsdl_addr_s src_addr;
187187
sn_coap_hdr_s *coap_message;
188-
src_addr.addr_ptr = source_addr_ptr;
188+
src_addr.addr_ptr = (uint8_t *)source_addr_ptr;
189189
src_addr.addr_len = 16;
190190
src_addr.type = SN_NSDL_ADDRESS_TYPE_IPV6;
191191
src_addr.port = port;
@@ -209,6 +209,7 @@ int16_t coap_message_handler_coap_msg_process(coap_msg_handler_t *handle, int8_t
209209
transaction_ptr->service_id = coap_service_id_find_by_socket(socket_id);
210210
transaction_ptr->msg_id = coap_message->msg_id;
211211
transaction_ptr->client_request = false;// this is server transaction
212+
memcpy(transaction_ptr->local_address, dst_addr_ptr, 16);
212213
memcpy(transaction_ptr->remote_address, source_addr_ptr, 16);
213214
transaction_ptr->remote_port = port;
214215

@@ -219,13 +220,13 @@ int16_t coap_message_handler_coap_msg_process(coap_msg_handler_t *handle, int8_t
219220
transaction_delete(transaction_ptr);
220221
return -1;
221222
}
222-
}else{
223+
} else {
223224
//TODO: handle error case
224225
}
225226
/* Response received */
226227
} else {
227228
coap_transaction_t *this = NULL;
228-
if( coap_message->token_ptr ){
229+
if (coap_message->token_ptr) {
229230
this = transaction_find_client_by_token(coap_message->token_ptr);
230231
}
231232
if (!this) {
@@ -235,7 +236,7 @@ int16_t coap_message_handler_coap_msg_process(coap_msg_handler_t *handle, int8_t
235236
}
236237
tr_debug("Service %d, response received", this->service_id);
237238
if (this->resp_cb) {
238-
this->resp_cb(this->service_id, source_addr_ptr, port, coap_message);
239+
this->resp_cb(this->service_id, (uint8_t *)source_addr_ptr, port, coap_message);
239240
}
240241
sn_coap_parser_release_allocated_coap_msg_mem(handle->coap, coap_message);
241242
transaction_delete(this);

source/coap_security_handler.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "coap_security_handler.h"
1919
#include "randLIB.h"
2020
#include "mbedtls/ssl_ciphersuites.h"
21+
#include "socket_api.h"
2122

2223
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
2324
const int ECJPAKE_SUITES[] = {
@@ -92,21 +93,21 @@ static void coap_security_handler_reset(coap_security_t *sec){
9293
}
9394

9495

95-
coap_security_t *coap_security_create(int8_t socket_id, int8_t timer_id, uint8_t *address_ptr, uint16_t port, SecureConnectionMode mode,
96-
send_cb *send_cb,
97-
receive_cb *receive_cb,
98-
start_timer_cb *start_timer_cb,
99-
timer_status_cb *timer_status_cb)
96+
coap_security_t *coap_security_create(int8_t socket_id, int8_t timer_id, const uint8_t *address_ptr, uint16_t port, SecureConnectionMode mode,
97+
send_cb *socket_cb,
98+
receive_cb *receive_data_cb,
99+
start_timer_cb *timer_start_cb,
100+
timer_status_cb *timer_stat_cb)
100101
{
101-
if( !address_ptr || send_cb == NULL || receive_cb == NULL || start_timer_cb == NULL || timer_status_cb == NULL){
102+
if (!address_ptr || socket_cb == NULL || receive_data_cb == NULL || timer_start_cb == NULL || timer_stat_cb == NULL) {
102103
return NULL;
103104
}
104105
coap_security_t *this = ns_dyn_mem_alloc(sizeof(coap_security_t));
105106
if( !this ){
106107
return NULL;
107108
}
108109
memset(this, 0, sizeof(coap_security_t));
109-
if( -1 == coap_security_handler_init(this) ){
110+
if (-1 == coap_security_handler_init(this)) {
110111
ns_dyn_mem_free(this);
111112
return NULL;
112113
}
@@ -117,10 +118,10 @@ coap_security_t *coap_security_create(int8_t socket_id, int8_t timer_id, uint8_t
117118
this->_pw_len = 0;
118119
this->_socket_id = socket_id;
119120
this->_timer_id = timer_id;
120-
this->_send_cb = send_cb;
121-
this->_receive_cb = receive_cb;
122-
this->_start_timer_cb = start_timer_cb;
123-
this->_timer_status_cb = timer_status_cb;
121+
this->_send_cb = socket_cb;
122+
this->_receive_cb = receive_data_cb;
123+
this->_start_timer_cb = timer_start_cb;
124+
this->_timer_status_cb = timer_stat_cb;
124125

125126
return this;
126127
}
@@ -551,7 +552,7 @@ static int get_timer(void *sec_obj)
551552

552553
int f_send( void *ctx, const unsigned char *buf, size_t len){
553554
coap_security_t *sec = (coap_security_t *)ctx;
554-
return sec->_send_cb(sec->_socket_id, sec->_remote_address, sec->_remote_port, buf, len);
555+
return sec->_send_cb(sec->_socket_id, sec->_remote_address, sec->_remote_port, ns_in6addr_any, buf, len);
555556
}
556557

557558
int f_recv(void *ctx, unsigned char *buf, size_t len){

source/coap_service_api.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "coap_service_api_internal.h"
2424
#include "coap_message_handler.h"
2525

26-
static int16_t coap_service_coap_msg_process(int8_t socket_id, uint8_t source_addr_ptr[static 16], uint16_t port, uint8_t *data_ptr, uint16_t data_len);
2726
static int16_t coap_msg_process_callback(int8_t socket_id, sn_coap_hdr_s *coap_message, coap_transaction_t *transaction_ptr);
2827

2928
typedef struct uri_registration {
@@ -142,7 +141,8 @@ static uint8_t coap_tx_function(uint8_t *data_ptr, uint16_t data_len, sn_nsdl_ad
142141
dest_addr.identifier = address_ptr->port;
143142
dest_addr.type = ADDRESS_IPV6;
144143

145-
if( -2 == coap_connection_handler_send_data(this->conn_handler, &dest_addr, data_ptr, data_len, (this->service_options & COAP_SERVICE_OPTIONS_SECURE_BYPASS) == COAP_SERVICE_OPTIONS_SECURE_BYPASS) ){
144+
if (-2 == coap_connection_handler_send_data(this->conn_handler, &dest_addr, transaction_ptr->local_address,
145+
data_ptr, data_len, (this->service_options & COAP_SERVICE_OPTIONS_SECURE_BYPASS) == COAP_SERVICE_OPTIONS_SECURE_BYPASS)) {
146146
transaction_ptr->data_ptr = ns_dyn_mem_alloc(data_len);
147147
if (!transaction_ptr->data_ptr) {
148148
tr_debug("coap tx out of memory");
@@ -151,7 +151,7 @@ static uint8_t coap_tx_function(uint8_t *data_ptr, uint16_t data_len, sn_nsdl_ad
151151
}
152152
memcpy(transaction_ptr->data_ptr, data_ptr, data_len);
153153
transaction_ptr->data_len = data_len;
154-
} else if (transaction_ptr->resp_cb == NULL ){
154+
} else if (transaction_ptr->resp_cb == NULL ) {
155155
transaction_delete(transaction_ptr);
156156
}
157157

@@ -207,37 +207,36 @@ static int16_t coap_msg_process_callback(int8_t socket_id, sn_coap_hdr_s *coap_m
207207
return -1;
208208
}
209209

210-
static int16_t coap_service_coap_msg_process(int8_t socket_id, uint8_t source_addr_ptr[static 16], uint16_t port, uint8_t *data_ptr, uint16_t data_len)
211-
{
212-
return coap_message_handler_coap_msg_process( coap_service_handle, socket_id, source_addr_ptr, port, data_ptr, data_len, &coap_msg_process_callback);
213-
}
214-
215-
static int recv_cb(int8_t socket_id, uint8_t address[static 16], uint16_t port, unsigned char *data, int len)
210+
static int recv_cb(int8_t socket_id, uint8_t src_address[static 16], uint16_t port, const uint8_t dst_address[static 16], unsigned char *data, int len)
216211
{
217212
uint8_t *data_ptr = NULL;
218213
uint16_t data_len = 0;
219214

215+
if (!data || !len) {
216+
return -1;
217+
}
218+
220219
data_ptr = own_alloc(len);
221220

222-
if (!data_ptr || len < 1) {
221+
if (!data_ptr) {
223222
return -1;
224223
}
225224
memcpy(data_ptr, data, len);
226225
data_len = len;
227226
tr_debug("service recv socket data len %d ", data_len);
228227

229228
//parse coap message what CoAP to use
230-
int ret = coap_service_coap_msg_process(socket_id, address, port, data_ptr, data_len);
229+
int ret = coap_message_handler_coap_msg_process(coap_service_handle, socket_id, src_address, port, dst_address, data_ptr, data_len, &coap_msg_process_callback);
231230
own_free(data_ptr);
232231
return ret;
233232
}
234233

235-
static int send_cb(int8_t socket_id, uint8_t address[static 16], uint16_t port, const unsigned char *data_ptr, int data_len)
234+
static int send_cb(int8_t socket_id, const uint8_t address[static 16], uint16_t port, const void *data_ptr, int data_len)
236235
{
237236
coap_service_t *this = service_find_by_socket(socket_id);
238237
if (this && this->virtual_socket_send_cb) {
239238
tr_debug("send to virtual socket");
240-
return this->virtual_socket_send_cb(this->service_id, address, port, data_ptr, data_len);
239+
return this->virtual_socket_send_cb(this->service_id, (uint8_t*)address, port, data_ptr, data_len);
241240
}
242241
return -1;
243242
}
@@ -259,7 +258,8 @@ static void sec_done_cb(int8_t socket_id, uint8_t address[static 16], uint16_t p
259258
dest_addr.identifier = port;
260259
dest_addr.type = ADDRESS_IPV6;
261260

262-
coap_connection_handler_send_data(this->conn_handler, &dest_addr, transaction_ptr->data_ptr, transaction_ptr->data_len, (this->service_options & COAP_SERVICE_OPTIONS_SECURE_BYPASS) == COAP_SERVICE_OPTIONS_SECURE_BYPASS);
261+
coap_connection_handler_send_data(this->conn_handler, &dest_addr, transaction_ptr->local_address,
262+
transaction_ptr->data_ptr, transaction_ptr->data_len, (this->service_options & COAP_SERVICE_OPTIONS_SECURE_BYPASS) == COAP_SERVICE_OPTIONS_SECURE_BYPASS);
263263
ns_dyn_mem_free(transaction_ptr->data_ptr);
264264
transaction_ptr->data_ptr = NULL;
265265
transaction_ptr->data_len = 0;

source/include/coap_connection_handler.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232

3333
struct internal_socket_s;
3434

35-
typedef int send_to_socket_cb(int8_t socket_id, uint8_t address[static 16], uint16_t port, const unsigned char *, int);
36-
typedef int receive_from_socket_cb(int8_t socket_id, uint8_t address[static 16], uint16_t port, unsigned char *, int);
35+
typedef int send_to_socket_cb(int8_t socket_id, const uint8_t address[static 16], uint16_t port, const void *, int);
36+
typedef int receive_from_socket_cb(int8_t socket_id, uint8_t src_address[static 16], uint16_t port, const uint8_t dst_address[static 16], unsigned char *, int);
3737
typedef int get_pw_cb(int8_t socket_id, uint8_t address[static 16], uint16_t port, uint8_t *pw_ptr, uint8_t *pw_len);
3838
typedef void security_done_cb(int8_t socket_id, uint8_t address[static 16], uint16_t port, uint8_t keyblock[static 40]);
3939

@@ -58,7 +58,7 @@ void connection_handler_close_secure_connection( coap_conn_handler_t *handler, u
5858
int coap_connection_handler_open_connection(coap_conn_handler_t *handler, uint16_t listen_port, bool use_ephemeral_port, bool is_secure, bool real_socket, bool bypassSec);
5959

6060
//If returns -2, it means security was started and data was not send
61-
int coap_connection_handler_send_data(coap_conn_handler_t *handler, ns_address_t *dest_addr, uint8_t *data_ptr, uint16_t data_len, bool bypass_link_sec);
61+
int coap_connection_handler_send_data(coap_conn_handler_t *handler, const ns_address_t *dest_addr, const uint8_t src_address[static 16], uint8_t *data_ptr, uint16_t data_len, bool bypass_link_sec);
6262

6363
int coap_connection_handler_virtual_recv(coap_conn_handler_t *handler, uint8_t address[static 16], uint16_t port, uint8_t *data_ptr, uint16_t data_len);
6464

source/include/coap_message_handler.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ typedef struct coap_msg_handler_s {
4949

5050
typedef struct coap_transaction {
5151
uint8_t remote_address[16];
52+
uint8_t local_address[16];
5253
uint8_t token[4];
5354
uint32_t create_time;
5455
uint16_t remote_port;
@@ -73,7 +74,7 @@ extern coap_transaction_t *coap_message_handler_transaction_valid(coap_transacti
7374

7475
extern coap_transaction_t *coap_message_handler_find_transaction(uint8_t *address_ptr, uint16_t port);
7576

76-
extern int16_t coap_message_handler_coap_msg_process(coap_msg_handler_t *handle, int8_t socket_id, uint8_t source_addr_ptr[static 16], uint16_t port,
77+
extern int16_t coap_message_handler_coap_msg_process(coap_msg_handler_t *handle, int8_t socket_id, const uint8_t source_addr_ptr[static 16], uint16_t port, const uint8_t dst_addr_ptr[static 16],
7778
uint8_t *data_ptr, uint16_t data_len, int16_t (cb)(int8_t, sn_coap_hdr_s *, coap_transaction_t *));
7879

7980
extern uint16_t coap_message_handler_request_send(coap_msg_handler_t *handle, int8_t service_id, uint8_t options, const uint8_t destination_addr[static 16],

source/include/coap_security_handler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ typedef struct key_block {
3838
unsigned char value[KEY_BLOCK_LEN];
3939
} key_block_t;
4040

41-
typedef int send_cb(int8_t socket_id, uint8_t *address_ptr, uint16_t port, const unsigned char *, size_t);
41+
typedef int send_cb(int8_t socket_id, const uint8_t *address_ptr, uint16_t port, const uint8_t source_addr[static 16], const void *, size_t);
4242
typedef int receive_cb(int8_t socket_id, unsigned char *, size_t);
4343
typedef void start_timer_cb(int8_t timer_id, uint32_t min, uint32_t fin);
4444
typedef int timer_status_cb(int8_t timer_id);
@@ -99,7 +99,7 @@ typedef struct coap_security_s {
9999

100100
} coap_security_t;
101101

102-
coap_security_t *coap_security_create(int8_t socket_id, int8_t timer_id, uint8_t *address_ptr, uint16_t port,
102+
coap_security_t *coap_security_create(int8_t socket_id, int8_t timer_id, const uint8_t *address_ptr, uint16_t port,
103103
SecureConnectionMode mode,
104104
send_cb *send_cb,
105105
receive_cb *receive_cb,

test/coap-service/unittest/coap_connection_handler/test_coap_connection_handler.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ bool test_coap_connection_handler_open_connection()
105105
bool test_coap_connection_handler_send_data()
106106
{
107107
coap_security_handler_stub.counter = -1;
108-
if( -1 != coap_connection_handler_send_data(NULL, NULL, NULL, 0, false))
108+
if( -1 != coap_connection_handler_send_data(NULL, NULL, ns_in6addr_any, NULL, 0, false))
109109
return false;
110110

111111
ns_address_t addr;
@@ -118,7 +118,7 @@ bool test_coap_connection_handler_send_data()
118118
if( 0 != coap_connection_handler_open_connection(handler, 22,false,true,false,false) )
119119
return false;
120120

121-
if( -1 != coap_connection_handler_send_data(handler, &addr, NULL, 0, true))
121+
if( -1 != coap_connection_handler_send_data(handler, &addr, ns_in6addr_any, NULL, 0, true))
122122
return false;
123123

124124
connection_handler_destroy(handler);
@@ -134,10 +134,10 @@ bool test_coap_connection_handler_send_data()
134134
if( 0 != coap_connection_handler_open_connection(handler, 22,false,true,false,false) )
135135
return false;
136136

137-
if( -1 != coap_connection_handler_send_data(handler, &addr, NULL, 0, true))
137+
if( -1 != coap_connection_handler_send_data(handler, &addr, ns_in6addr_any, NULL, 0, true))
138138
return false;
139139

140-
if( -1 != coap_connection_handler_send_data(handler, &addr, NULL, 0, true))
140+
if( -1 != coap_connection_handler_send_data(handler, &addr, ns_in6addr_any, NULL, 0, true))
141141
return false;
142142

143143
connection_handler_destroy(handler);
@@ -153,7 +153,7 @@ bool test_coap_connection_handler_send_data()
153153
return false;
154154

155155

156-
if( 1 != coap_connection_handler_send_data(handler, &addr, NULL, 0, true))
156+
if( 1 != coap_connection_handler_send_data(handler, &addr, ns_in6addr_any, NULL, 0, true))
157157
return false;
158158
connection_handler_destroy(handler);
159159

@@ -164,7 +164,7 @@ bool test_coap_connection_handler_send_data()
164164
return false;
165165

166166
socket_api_stub.int8_value = 7;
167-
if( 7 != coap_connection_handler_send_data(handler, &addr, NULL, 0, true))
167+
if( 7 != coap_connection_handler_send_data(handler, &addr, ns_in6addr_any, NULL, 0, true))
168168
return false;
169169
connection_handler_destroy(handler);
170170

test/coap-service/unittest/coap_message_handler/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ TEST_SRC_FILES = \
1717
../stub/nsdynmemLIB_stub.c \
1818
../stub/ns_list_stub.c \
1919
../stub/randLIB_stub.c \
20-
../stub/coap_service_api_stub.c
20+
../stub/coap_service_api_stub.c \
21+
../stub/socket_api_stub.c \
2122

2223
include ../MakefileWorker.mk
2324

test/coap-service/unittest/coap_message_handler/test_coap_message_handler.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "nsdynmemLIB_stub.h"
99
#include "sn_coap_builder_stub.h"
1010
#include "sn_coap_parser_stub.h"
11+
#include "socket_api.h"
1112

1213
int retCounter = 0;
1314
int retValue = 0;
@@ -118,7 +119,7 @@ bool test_coap_message_handler_coap_msg_process()
118119
{
119120
uint8_t buf[16];
120121
memset(&buf, 1, 16);
121-
if( -1 != coap_message_handler_coap_msg_process(NULL, 0, buf, 22, NULL, 0, NULL))
122+
if( -1 != coap_message_handler_coap_msg_process(NULL, 0, buf, 22, ns_in6addr_any, NULL, 0, NULL))
122123
return false;
123124

124125
retCounter = 1;
@@ -127,34 +128,34 @@ bool test_coap_message_handler_coap_msg_process()
127128
coap_msg_handler_t *handle = coap_message_handler_init(&own_alloc, &own_free, &coap_tx_function);
128129

129130
sn_coap_protocol_stub.expectedHeader = NULL;
130-
if( -1 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, NULL, 0, process_cb))
131+
if( -1 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, ns_in6addr_any, NULL, 0, process_cb))
131132
return false;
132133

133134
sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s));
134135
memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s));
135136
sn_coap_protocol_stub.expectedHeader->coap_status = 66;
136-
if( -1 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, NULL, 0, process_cb))
137+
if( -1 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, ns_in6addr_any, NULL, 0, process_cb))
137138
return false;
138139

139140
sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s));
140141
memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s));
141142
sn_coap_protocol_stub.expectedHeader->coap_status = COAP_STATUS_OK;
142143
sn_coap_protocol_stub.expectedHeader->msg_code = 1;
143144
retValue = 0;
144-
if( 0 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, NULL, 0, process_cb))
145+
if( 0 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, ns_in6addr_any, NULL, 0, process_cb))
145146
return false;
146147

147148
nsdynmemlib_stub.returnCounter = 1;
148149
retValue = -1;
149-
if( -1 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, NULL, 0, process_cb))
150+
if( -1 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, ns_in6addr_any, NULL, 0, process_cb))
150151
return false;
151152

152153
sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s));
153154
memset(sn_coap_protocol_stub.expectedHeader, 0, sizeof(sn_coap_hdr_s));
154155
sn_coap_protocol_stub.expectedHeader->coap_status = COAP_STATUS_OK;
155156
sn_coap_protocol_stub.expectedHeader->msg_code = 333;
156157

157-
if( -1 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, NULL, 0, process_cb))
158+
if( -1 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, ns_in6addr_any, NULL, 0, process_cb))
158159
return false;
159160

160161
sn_coap_protocol_stub.expectedHeader = (sn_coap_hdr_s *)malloc(sizeof(sn_coap_hdr_s));
@@ -175,7 +176,7 @@ bool test_coap_message_handler_coap_msg_process()
175176
sn_coap_protocol_stub.expectedHeader->msg_id = 2;
176177
// sn_coap_protocol_stub.expectedHeader->token_ptr = (uint8_t*)malloc(4);
177178
// memset(sn_coap_protocol_stub.expectedHeader->token_ptr, 1, 4);
178-
if( -1 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, NULL, 0, process_cb))
179+
if( -1 != coap_message_handler_coap_msg_process(handle, 0, buf, 22, ns_in6addr_any, NULL, 0, process_cb))
179180
return false;
180181

181182
// free(sn_coap_protocol_stub.expectedHeader->token_ptr);

test/coap-service/unittest/coap_security_handler/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ TEST_SRC_FILES = \
1616
../stub/mbedtls_stub.c \
1717
../stub/randLIB_stub.c \
1818
../stub/nsdynmemLIB_stub.c \
19+
../stub/socket_api_stub.c \
1920

2021
include ../MakefileWorker.mk
2122

0 commit comments

Comments
 (0)