From b9cf840a10c6212cd75d0a422a4f1094258ac700 Mon Sep 17 00:00:00 2001 From: Xenofon Foukas Date: Mon, 28 Dec 2015 15:25:27 +0200 Subject: [PATCH] Created callback mechanism for destruction of protocol messages sent by the agent --- openair2/ENB_APP/enb_agent_common.c | 2 +- openair2/ENB_APP/enb_agent_common.h | 4 ++++ openair2/ENB_APP/enb_agent_handler.c | 11 ++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/openair2/ENB_APP/enb_agent_common.c b/openair2/ENB_APP/enb_agent_common.c index a8ac24144b..848c10b6fa 100644 --- a/openair2/ENB_APP/enb_agent_common.c +++ b/openair2/ENB_APP/enb_agent_common.c @@ -134,7 +134,7 @@ int enb_agent_hello(uint32_t xid, const void *params, Protocol__ProgranMessage * } -int enb_agent_destroy_hello_message(Protocol__ProgranMessage *msg) { +int enb_agent_destroy_hello(Protocol__ProgranMessage *msg) { if(msg->msg_case != PROTOCOL__PROGRAN_MESSAGE__MSG_HELLO_MSG) goto error; diff --git a/openair2/ENB_APP/enb_agent_common.h b/openair2/ENB_APP/enb_agent_common.h index 5aac604c1e..3bb6596f2e 100644 --- a/openair2/ENB_APP/enb_agent_common.h +++ b/openair2/ENB_APP/enb_agent_common.h @@ -53,6 +53,10 @@ typedef int (*enb_agent_message_decoded_callback)( Protocol__ProgranMessage **msg ); +typedef int (*enb_agent_message_destruction_callback)( + Protocol__ProgranMessage *msg +); + typedef int32_t err_code_t; int enb_agent_serialize_message(Protocol__ProgranMessage *msg, void **buf, int *size); diff --git a/openair2/ENB_APP/enb_agent_handler.c b/openair2/ENB_APP/enb_agent_handler.c index 9a37d01fc1..5049e669e9 100644 --- a/openair2/ENB_APP/enb_agent_handler.c +++ b/openair2/ENB_APP/enb_agent_handler.c @@ -50,6 +50,15 @@ enb_agent_message_decoded_callback messages_callback[][3] = { }; +enb_agent_message_destruction_callback message_destruction_callback[] = { + enb_agent_destroy_hello, + enb_agent_destroy_echo_request, + enb_agent_destroy_echo_reply, + 0, /*No stats request message is created in the agent. No need for a callback*/ + enb_agent_mac_destroy_stats_reply, + +}; + static const char *enb_agent_direction2String[] = { "", /* not_set */ "originating message", /* originating message */ @@ -114,7 +123,7 @@ void * enb_agent_send_message(uint32_t xid, // free the msg --> later keep this in the data struct and just update the values //TODO call proper destroy function - // enb_agent_mac_destroy_stats_reply(msg); + err_code = ((*message_destruction_callback[msg->msg_case-1])(msg)); DevAssert(buffer !=NULL);