diff --git a/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c index b2723f718126973f96d972a3284b995c5e99c3e2..34f3f414cca2b980374a62e5ffeef4d0d71a1884 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c +++ b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c @@ -28,12 +28,6 @@ #include "flexran_agent_pdcp.h" - -/*Trigger boolean for PDCP measurement*/ -bool triggered_pdcp = false; -/*Flags showing if a pdcp agent has already been registered*/ -unsigned int pdcp_agent_registered[NUM_MAX_ENB]; - /*Array containing the Agent-PDCP interfaces*/ AGENT_PDCP_xface *agent_pdcp_xface[NUM_MAX_ENB]; @@ -144,28 +138,41 @@ int flexran_agent_pdcp_stats_reply(mid_t mod_id, -int flexran_agent_register_pdcp_xface(mid_t mod_id, AGENT_PDCP_xface *xface) { - if (pdcp_agent_registered[mod_id]) { - LOG_E(PDCP, "PDCP agent for eNB %d is already registered\n", mod_id); +int flexran_agent_register_pdcp_xface(mid_t mod_id) +{ + if (agent_pdcp_xface[mod_id]) { + LOG_E(FLEXRAN_AGENT, "PDCP agent CM for eNB %d is already registered\n", mod_id); + return -1; + } + AGENT_PDCP_xface *xface = malloc(sizeof(AGENT_PDCP_xface)); + if (!xface) { + LOG_E(FLEXRAN_AGENT, "could not allocate memory for PDCP agent xface %d\n", mod_id); return -1; } //xface->flexran_pdcp_stats_measurement = NULL; - pdcp_agent_registered[mod_id] = 1; agent_pdcp_xface[mod_id] = xface; return 0; } -int flexran_agent_unregister_pdcp_xface(mid_t mod_id, AGENT_PDCP_xface *xface) { - +int flexran_agent_unregister_pdcp_xface(mid_t mod_id) +{ + if (!agent_pdcp_xface[mod_id]) { + LOG_E(FLEXRAN_AGENT, "PDCP agent CM for eNB %d is not registered\n", mod_id); + return -1; + } //xface->agent_ctxt = NULL; //xface->flexran_pdcp_stats_measurement = NULL; - - pdcp_agent_registered[mod_id] = 0; + free(agent_pdcp_xface[mod_id]); agent_pdcp_xface[mod_id] = NULL; return 0; } + +AGENT_PDCP_xface *flexran_agent_get_pdcp_xface(mid_t mod_id) +{ + return agent_pdcp_xface[mod_id]; +} diff --git a/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.h b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.h index 83aac45406e17b5f5526898e45a5212475cd2e9b..be952326e87a5e67aded4458cc6fdf0691df3dba 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.h +++ b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.h @@ -39,6 +39,8 @@ #include "flexran_agent_defs.h" #include "flexran_agent_pdcp_defs.h" #include "flexran_agent_ran_api.h" +// for flexran_agent_get_pdcp_xface() +#include "flexran_agent_extern.h" /********************************** * FlexRAN agent - technology PDCP API @@ -56,9 +58,9 @@ void flexran_agent_pdcp_aggregate_stats(const mid_t mod_id, Protocol__FlexPdcpStats *pdcp_aggr_stats); /*Register technology specific interface callbacks*/ -int flexran_agent_register_pdcp_xface(mid_t mod_id, AGENT_PDCP_xface *xface); +int flexran_agent_register_pdcp_xface(mid_t mod_id); /*Unregister technology specific callbacks*/ -int flexran_agent_unregister_pdcp_xface(mid_t mod_id, AGENT_PDCP_xface*xface); +int flexran_agent_unregister_pdcp_xface(mid_t mod_id); #endif diff --git a/openair2/ENB_APP/flexran_agent.c b/openair2/ENB_APP/flexran_agent.c index d7c7785e51779803f6d8eaa04dc531ba8ce66906..30f2e278954618a55c69dac26aee8bfd8f64e692 100644 --- a/openair2/ENB_APP/flexran_agent.c +++ b/openair2/ENB_APP/flexran_agent.c @@ -236,8 +236,7 @@ int flexran_agent_start(mid_t mod_id) flexran_agent_register_rrc_xface(mod_id); - AGENT_PDCP_xface *pdcp_agent_xface = (AGENT_PDCP_xface *) malloc(sizeof(AGENT_PDCP_xface)); - flexran_agent_register_pdcp_xface(mod_id, pdcp_agent_xface); + flexran_agent_register_pdcp_xface(mod_id); /* * initilize a timer diff --git a/openair2/ENB_APP/flexran_agent_extern.h b/openair2/ENB_APP/flexran_agent_extern.h index bc5b64a311f9b16e09ccea3c02cabcda5565f195..f80532be93657a95023da80b969d6edbff9b28f8 100644 --- a/openair2/ENB_APP/flexran_agent_extern.h +++ b/openair2/ENB_APP/flexran_agent_extern.h @@ -42,10 +42,7 @@ AGENT_MAC_xface *flexran_agent_get_mac_xface(mid_t mod_id); AGENT_RRC_xface *flexran_agent_get_rrc_xface(mid_t mod_id); /* Control module interface for the communication of the RRC Control Module with the agent */ -extern AGENT_PDCP_xface *agent_pdcp_xface[NUM_MAX_ENB]; - -/* Flag indicating whether the VSFs for the RRC control module have been registered */ -extern unsigned int pdcp_agent_registered[NUM_MAX_ENB]; +AGENT_PDCP_xface *flexran_agent_get_pdcp_xface(mid_t mod_id); /* Requried to know which UEs had a harq updated over some subframe */ extern int harq_pid_updated[NUM_MAX_UE][8];