mirror of https://github.com/ARMmbed/mbed-os.git
Delete all transactions when secure session is closed (#41)
When handshake fails, or DTLS session is closed, all transactions must be removed from coap protocol retransmission queue. Otherwise coap retransmission will start new handshake.pull/3240/head
parent
b4b5041223
commit
115aa3eee2
|
@ -95,6 +95,7 @@ static secure_session_t *secure_session_find_by_timer_id(int8_t timer_id)
|
|||
static void secure_session_delete(secure_session_t *this)
|
||||
{
|
||||
if (this) {
|
||||
transactions_delete_all(this->parent->dest_addr.address, this->parent->dest_addr.identifier);
|
||||
ns_list_remove(&secure_session_list, this);
|
||||
if( this->sec_handler ){
|
||||
coap_security_destroy(this->sec_handler);
|
||||
|
@ -529,6 +530,7 @@ static void secure_recv_sckt_msg(void *cb_res)
|
|||
internal_socket_t *sock = int_socket_find_by_socket_id(sckt_data->socket_id);
|
||||
ns_address_t src_address;
|
||||
uint8_t dst_address[16];
|
||||
memset(&src_address, 0, sizeof(ns_address_t));
|
||||
|
||||
if (sock && read_data(sckt_data, sock, &src_address, dst_address) == 0) {
|
||||
secure_session_t *session = secure_session_find(sock, src_address.address, src_address.identifier);
|
||||
|
|
|
@ -93,6 +93,17 @@ void transaction_delete(coap_transaction_t *this)
|
|||
return;
|
||||
}
|
||||
|
||||
void transactions_delete_all(uint8_t *address_ptr, uint16_t port)
|
||||
{
|
||||
coap_transaction_t *transaction = transaction_find_by_address(address_ptr, port);
|
||||
|
||||
while (transaction) {
|
||||
sn_coap_protocol_delete_retransmission(coap_service_handle->coap, transaction->msg_id);
|
||||
transaction_delete(transaction);
|
||||
transaction = transaction_find_by_address(address_ptr, port);
|
||||
}
|
||||
}
|
||||
|
||||
static int8_t coap_rx_function(sn_coap_hdr_s *resp_ptr, sn_nsdl_addr_s *address_ptr, void *param)
|
||||
{
|
||||
coap_transaction_t *this = NULL;
|
||||
|
|
|
@ -88,4 +88,6 @@ extern int8_t coap_message_handler_exec(coap_msg_handler_t *handle, uint32_t cur
|
|||
|
||||
extern void transaction_delete(coap_transaction_t *this);
|
||||
|
||||
extern void transactions_delete_all(uint8_t *address_ptr, uint16_t port);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -19,6 +19,10 @@
|
|||
#ifndef __COAP_SERVICE_API_INTERNAL_H__
|
||||
#define __COAP_SERVICE_API_INTERNAL_H__
|
||||
|
||||
#include "coap_message_handler.h"
|
||||
|
||||
|
||||
extern coap_msg_handler_t *coap_service_handle;
|
||||
|
||||
uint32_t coap_service_get_internal_timer_ticks(void);
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ TEST_SRC_FILES = \
|
|||
../stub/socket_api_stub.c \
|
||||
../stub/coap_security_handler_stub.c \
|
||||
../stub/coap_service_api_stub.c \
|
||||
../stub/coap_message_handler_stub.c \
|
||||
|
||||
include ../MakefileWorker.mk
|
||||
|
||||
|
|
|
@ -22,6 +22,10 @@ void transaction_delete(coap_transaction_t *this)
|
|||
|
||||
}
|
||||
|
||||
void transactions_delete_all(uint8_t *address_ptr, uint16_t port)
|
||||
{
|
||||
|
||||
}
|
||||
int8_t coap_message_handler_destroy(coap_msg_handler_t *handle)
|
||||
{
|
||||
return coap_message_handler_stub.int8_value;
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
#include "common_functions.h"
|
||||
#include "net_interface.h"
|
||||
|
||||
coap_msg_handler_t *coap_service_handle = NULL;
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -94,3 +94,7 @@ coap_send_msg_s *sn_coap_protocol_allocate_mem_for_msg(struct coap_s *handle, sn
|
|||
return sn_coap_protocol_stub.expectedSendMsg;
|
||||
}
|
||||
|
||||
int8_t sn_coap_protocol_delete_retransmission(struct coap_s *handle, uint16_t msg_id)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue