From 8cf520d283a5e30e3063d2fb4883ff178cd7361f Mon Sep 17 00:00:00 2001
From: Robert Schmidt <robert.schmidt@eurecom.fr>
Date: Mon, 13 May 2019 17:39:43 +0200
Subject: [PATCH] Rename FlexRAN RRC reconfiguration function, simplify
 function

---
 openair2/ENB_APP/flexran_agent_common.c  | 53 +++++-------------------
 openair2/ENB_APP/flexran_agent_common.h  |  2 +-
 openair2/ENB_APP/flexran_agent_handler.c |  2 +-
 3 files changed, 13 insertions(+), 44 deletions(-)

diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c
index e2bd5f8146b..9f932dd3c78 100644
--- a/openair2/ENB_APP/flexran_agent_common.c
+++ b/openair2/ENB_APP/flexran_agent_common.c
@@ -805,66 +805,35 @@ error:
 }
 
 
-int flexran_agent_rrc_measurement(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg) {
-  //protocol_ctxt_t  ctxt;
+int flexran_agent_rrc_reconfiguration(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg) {
   Protocol__FlexranMessage *input = (Protocol__FlexranMessage *)params;
   Protocol__FlexRrcTriggering *triggering = input->rrc_triggering;
-  //agent_reconf_rrc *rrc_reconf = malloc(sizeof(agent_reconf_rrc));
-
-  #if 0
-  reconf_param->trigger_policy = triggering->rrc_trigger;
-  reconf_param->report_interval = 0;
-  reconf_param->report_amount = 0;
-  struct rrc_eNB_ue_context_s   *ue_context_p = NULL;
-  RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[mod_id]->rrc_ue_head)) {
-    PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, mod_id, ENB_FLAG_YES, ue_context_p->ue_context.rnti, flexran_get_current_frame(mod_id), flexran_get_current_subframe (mod_id), mod_id);
-    flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(&ctxt, ue_context_p, 0, reconf_param);
-  }
-  #endif
-
-  // TODO: Step 1 - Verification process
-
-  // Step 2 - Set the proper values using FlexRAN API (protected with mutex ?)
-  int num_ue = 0;
-
-  if (flexran_agent_get_rrc_xface(mod_id))
-     num_ue = flexran_get_rrc_num_ues(mod_id);
-  else if (flexran_agent_get_mac_xface(mod_id))
-     num_ue = flexran_get_mac_num_ues(mod_id);
-
-  if (flexran_agent_get_rrc_xface(mod_id) && flexran_agent_get_mac_xface(mod_id)
-      && flexran_get_rrc_num_ues(mod_id) != flexran_get_mac_num_ues(mod_id)) {
-    const int nrrc = flexran_get_rrc_num_ues(mod_id);
-    const int nmac = flexran_get_mac_num_ues(mod_id);
-    num_ue  = nrrc < nmac ? nrrc : nmac;
-    LOG_E(FLEXRAN_AGENT, "%s(): different numbers of UEs in RRC (%d) and MAC (%d), reporting for %d UEs\n",
-        __func__, nrrc, nmac, num_ue);
+  // Set the proper values using FlexRAN API (protected with mutex ?)
+  if (!flexran_agent_get_rrc_xface(mod_id)) {
+    LOG_E(FLEXRAN_AGENT, "%s(): no RRC present, aborting\n", __func__);
+    return -1;
   }
 
+  int num_ue = flexran_get_rrc_num_ues(mod_id);
   if (num_ue == 0)
     return 0;
 
-  int error = 0;
   rnti_t rntis[num_ue];
   flexran_get_rrc_rnti_list(mod_id, rntis, num_ue);
   for (int i = 0; i < num_ue; i++) {
     const rnti_t rnti = rntis[i];
-    if (flexran_agent_get_rrc_xface(mod_id))
-      error = update_rrc_reconfig(mod_id, rnti, triggering);
+    const int error = update_rrc_reconfig(mod_id, rnti, triggering);
     if (error < 0) {
       LOG_E(FLEXRAN_AGENT, "Error in updating user %d\n", i);
+      continue;
     }
-    else {
-      // Step 3 - Call the proper wrapper in FlexRAN API
-      if (flexran_call_rrc_reconfiguration (mod_id, rnti) <0) {
-        LOG_E(FLEXRAN_AGENT, "Error in reconfiguring user %d\n", i);
-      }
+    // Call the proper wrapper in FlexRAN API
+    if (flexran_call_rrc_reconfiguration (mod_id, rnti) < 0) {
+      LOG_E(FLEXRAN_AGENT, "Error in reconfiguring user %d\n", i);
     }
   }
 
   *msg = NULL;
-  //free(reconf_param);
-  //reconf_param = NULL;
   return 0;
 }
 
diff --git a/openair2/ENB_APP/flexran_agent_common.h b/openair2/ENB_APP/flexran_agent_common.h
index 8419dae62d1..aad77635f2b 100644
--- a/openair2/ENB_APP/flexran_agent_common.h
+++ b/openair2/ENB_APP/flexran_agent_common.h
@@ -137,7 +137,7 @@ int flexran_agent_reconfiguration(mid_t mod_id, const void *params, Protocol__Fl
 int flexran_agent_destroy_agent_reconfiguration(Protocol__FlexranMessage *msg);
 
 /* rrc triggering measurement message constructor and destructor */
-int flexran_agent_rrc_measurement(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg);
+int flexran_agent_rrc_reconfiguration(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg);
 int flexran_agent_destroy_rrc_measurement(Protocol__FlexranMessage *msg);
 
 
diff --git a/openair2/ENB_APP/flexran_agent_handler.c b/openair2/ENB_APP/flexran_agent_handler.c
index 6c2e6429eb5..7112d1fe36d 100644
--- a/openair2/ENB_APP/flexran_agent_handler.c
+++ b/openair2/ENB_APP/flexran_agent_handler.c
@@ -55,7 +55,7 @@ flexran_agent_message_decoded_callback agent_messages_callback[][3] = {
   {0, 0, 0}, /*PROTOCOL__FLEXRAN_MESSAGE__MSG_UE_STATE_CHANGE_MSG*/
   {flexran_agent_control_delegation, 0, 0}, /*PROTOCOL__FLEXRAN_MESSAGE__MSG_CONTROL_DELEGATION_MSG*/
   {flexran_agent_reconfiguration, 0, 0}, /*PROTOCOL__FLEXRAN_MESSAGE__MSG_AGENT_RECONFIGURATION_MSG*/
-  {flexran_agent_rrc_measurement, 0, 0}, /*PROTOCOL__FLEXRAN_MESSAGE__MSG_RRC_TRIGGERING_MSG*/
+  {flexran_agent_rrc_reconfiguration, 0, 0}, /*PROTOCOL__FLEXRAN_MESSAGE__MSG_RRC_TRIGGERING_MSG*/
 };
 
 flexran_agent_message_destruction_callback message_destruction_callback[] = {
-- 
GitLab