From b707feff7bf267e5a9a6b1395e6d247c713f79c7 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Mon, 8 Jul 2019 16:24:38 +0200 Subject: [PATCH] mesh: extract mesh_upper_transport_pdu_free --- src/mesh/mesh_upper_transport.c | 30 +++++++++++++++++------------- src/mesh/mesh_upper_transport.h | 3 ++- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/mesh/mesh_upper_transport.c b/src/mesh/mesh_upper_transport.c index 7baee2556..82a9cc84c 100644 --- a/src/mesh/mesh_upper_transport.c +++ b/src/mesh/mesh_upper_transport.c @@ -489,9 +489,24 @@ void mesh_upper_transport_message_received(mesh_pdu_t * pdu){ mesh_transport_run(); } -void mesh_upper_transport_pdu_handler(mesh_transport_callback_type_t callback_type, mesh_transport_status_t status, mesh_pdu_t * pdu){ +void mesh_upper_transport_pdu_free(mesh_pdu_t * pdu){ mesh_network_pdu_t * network_pdu; mesh_transport_pdu_t * transport_pdu; + switch (pdu->pdu_type) { + case MESH_PDU_TYPE_NETWORK: + network_pdu = (mesh_network_pdu_t *) pdu; + mesh_network_pdu_free(network_pdu); + break; + case MESH_PDU_TYPE_TRANSPORT: + transport_pdu = (mesh_transport_pdu_t *) pdu; + mesh_transport_pdu_free(transport_pdu); + break; + default: + break; + } +} + +void mesh_upper_transport_pdu_handler(mesh_transport_callback_type_t callback_type, mesh_transport_status_t status, mesh_pdu_t * pdu){ switch (callback_type){ case MESH_TRANSPORT_PDU_RECEIVED: mesh_upper_transport_message_received(pdu); @@ -501,18 +516,7 @@ void mesh_upper_transport_pdu_handler(mesh_transport_callback_type_t callback_ty if (higher_layer_handler){ higher_layer_handler(callback_type, status, pdu); } else { - switch (pdu->pdu_type) { - case MESH_PDU_TYPE_NETWORK: - network_pdu = (mesh_network_pdu_t *) pdu; - mesh_network_pdu_free(network_pdu); - break; - case MESH_PDU_TYPE_TRANSPORT: - transport_pdu = (mesh_transport_pdu_t *) pdu; - mesh_transport_pdu_free(transport_pdu); - break; - default: - break; - } + mesh_upper_transport_pdu_free(pdu); } break; default: diff --git a/src/mesh/mesh_upper_transport.h b/src/mesh/mesh_upper_transport.h index 956b60b2a..27debf392 100644 --- a/src/mesh/mesh_upper_transport.h +++ b/src/mesh/mesh_upper_transport.h @@ -48,7 +48,8 @@ extern "C" #include #include "mesh/mesh_network.h" - +#include "mesh/mesh_lower_transport.h" + void mesh_upper_transport_init(); void mesh_upper_transport_set_primary_element_address(uint16_t primary_element_address);