Check validity of transaction pointer when sending data

pull/3240/head
Mika Tervonen 2016-06-16 14:46:47 +03:00
parent 7a11be1ccb
commit f903edb347
3 changed files with 15 additions and 3 deletions

View File

@ -160,6 +160,16 @@ int8_t coap_message_handler_destroy(coap_msg_handler_t *handle){
return 0;
}
coap_transaction_t *coap_message_handler_transaction_valid(coap_transaction_t *tr_ptr)
{
ns_list_foreach(coap_transaction_t, cur_ptr, &request_list) {
if (cur_ptr == tr_ptr) {
return tr_ptr;
}
}
return NULL;
}
coap_transaction_t *coap_message_handler_find_transaction(uint8_t *address_ptr, uint16_t port)
{
if( !address_ptr )

View File

@ -123,18 +123,18 @@ static void own_free(void *ptr)
static uint8_t coap_tx_function(uint8_t *data_ptr, uint16_t data_len, sn_nsdl_addr_s *address_ptr, void *param)
{
coap_service_t *this;
coap_transaction_t *transaction_ptr = param;
coap_transaction_t *transaction_ptr = coap_message_handler_transaction_valid(param);
ns_address_t dest_addr;
if (!transaction_ptr || !data_ptr) {
return 0;
return -1;
}
tr_debug("Service %d, CoAP TX Function", transaction_ptr->service_id);
this = service_find(transaction_ptr->service_id);
if (!this) {
return 0;
return -1;
}
memcpy(&(dest_addr.address), address_ptr->addr_ptr, 16);

View File

@ -65,6 +65,8 @@ extern coap_msg_handler_t *coap_message_handler_init(void *(*used_malloc_func_pt
extern int8_t coap_message_handler_destroy(coap_msg_handler_t *handle);
extern coap_transaction_t *coap_message_handler_transaction_valid(coap_transaction_t *tr_ptr);
extern coap_transaction_t *coap_message_handler_find_transaction(uint8_t *address_ptr, uint16_t port);
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,