From adec4e39df7dcb692c4c4ce27bc6703d2a68ca60 Mon Sep 17 00:00:00 2001
From: Robert Schmidt <robert.schmidt@eurecom.fr>
Date: Mon, 12 Feb 2018 14:38:44 +0100
Subject: [PATCH] remove all conditional FlexRAN-related compilation directives

---
 common/ran_context.h                      |  4 ----
 openair2/ENB_APP/enb_config.c             |  2 --
 openair2/ENB_APP/enb_config.h             |  2 --
 openair2/LAYER2/MAC/eNB_scheduler.c       |  6 ------
 openair2/LAYER2/MAC/eNB_scheduler_dlsch.c |  2 --
 openair2/LAYER2/MAC/eNB_scheduler_ulsch.c |  2 --
 openair2/RRC/LITE/L2_interface.c          |  4 ----
 openair2/RRC/LITE/proto.h                 |  6 ------
 openair2/RRC/LITE/rrc_eNB.c               | 13 -------------
 targets/RT/USER/lte-softmodem.c           |  3 +--
 targets/RT/USER/lte-softmodem.h           |  6 ++----
 targets/SIMU/USER/oaisim.c                |  4 +---
 12 files changed, 4 insertions(+), 50 deletions(-)

diff --git a/common/ran_context.h b/common/ran_context.h
index d5e2a1f1729..f59fd8a79c4 100644
--- a/common/ran_context.h
+++ b/common/ran_context.h
@@ -40,9 +40,7 @@
 #include "PHY/impl_defs_top.h"
 #include "PHY/impl_defs_lte.h"
 #include "RRC/LITE/defs.h"
-#ifdef FLEXRAN_AGENT_SB_IF
 #include "flexran_agent_defs.h"
-#endif
 
 #include "gtpv1u.h"
 #include "NwGtpv1u.h"
@@ -67,10 +65,8 @@ typedef struct {
   int *nb_L1_CC;
   /// Number of RU instances in this node
   int nb_RU;
-#ifdef FLEXRAN_AGENT_SB_IF
   /// FlexRAN context variables
   flexran_agent_info_t **flexran;
-#endif
   /// eNB context variables
   struct PHY_VARS_eNB_s ***eNB;
   /// RRC context variables
diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c
index d6f676b83a0..1bf2807e815 100644
--- a/openair2/ENB_APP/enb_config.c
+++ b/openair2/ENB_APP/enb_config.c
@@ -98,7 +98,6 @@ static int enb_check_band_frequencies(char* lib_config_file_name_pP,
   return errors;
 }
 
-#ifdef FLEXRAN_AGENT_SB_IF
 void RCconfig_flexran()
 {
   int i;
@@ -134,7 +133,6 @@ void RCconfig_flexran()
 
   /* TODO: show FlexRAN config now? */
 }
-#endif
 
 void RCconfig_L1(void) {
   int               i,j;
diff --git a/openair2/ENB_APP/enb_config.h b/openair2/ENB_APP/enb_config.h
index 4e4434ad70c..42bef9c4e99 100644
--- a/openair2/ENB_APP/enb_config.h
+++ b/openair2/ENB_APP/enb_config.h
@@ -94,9 +94,7 @@ typedef struct ru_config_s {
 } ru_config_t;
 
 extern void RCconfig_RU(void);
-#ifdef FLEXRAN_AGENT_SB_IF
 extern void RCconfig_flexran(void);
-#endif
 extern void RCconfig_L1(void);
 extern void RCconfig_macrlc(void);
 extern int  RCconfig_gtpu(void );
diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c
index 0e2f84b25be..45c1a422dd7 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler.c
@@ -52,11 +52,9 @@
 //#include "LAYER2/MAC/pre_processor.c"
 #include "pdcp.h"
 
-#if defined(FLEXRAN_AGENT_SB_IF)
 //Agent-related headers
 #include "flexran_agent_extern.h"
 #include "flexran_agent_mac.h"
-#endif
 
 #if defined(ENABLE_ITTI)
 #include "intertask_interface.h"
@@ -419,12 +417,10 @@ check_ul_failure(module_id_t module_idP, int CC_id, int UE_id,
   }				// ul_failure_timer>0
 
   //Inform the controller about the UE deactivation. Should be moved to RRC agent in the future
-#if defined(FLEXRAN_AGENT_SB_IF)
   if (rrc_agent_registered[module_idP]) {
     agent_rrc_xface[module_idP]->flexran_agent_notify_ue_state_change(module_idP,
         rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED);
   }
-#endif
 
   UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer++;
   if(UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer > (U_PLANE_INACTIVITY_VALUE*subframe_num(&RC.eNB[module_idP][CC_id]->frame_parms))){
@@ -661,9 +657,7 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP,
   // This schedules DLSCH in subframeP
   schedule_dlsch(module_idP, frameP, subframeP, mbsfn_status);
 
-#if defined(FLEXRAN_AGENT_SB_IF)
   flexran_agent_send_update_stats(module_idP);
-#endif
   
   // Allocate CCEs for good after scheduling is done
   for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++)
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
index fb123134f80..0936a9d0efd 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
@@ -57,12 +57,10 @@
 #include "intertask_interface.h"
 #endif
 
-#if defined FLEXRAN_AGENT_SB_IF
 #include "ENB_APP/flexran_agent_defs.h"
 #include "flexran_agent_ran_api.h"
 #include "header.pb-c.h"
 #include "flexran.pb-c.h"
-#endif
 #include <dlfcn.h>
 
 #include "T.h"
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
index 2403ec2d137..47b6a075cfc 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
@@ -57,13 +57,11 @@
 #include "intertask_interface.h"
 #endif
 
-#if defined FLEXRAN_AGENT_SB_IF
 #include "ENB_APP/flexran_agent_defs.h"
 #include "flexran_agent_ran_api.h"
 #include "header.pb-c.h"
 #include "flexran.pb-c.h"
 #include "flexran_agent_mac.h"
-#endif
 #include <dlfcn.h>
 
 #include "T.h"
diff --git a/openair2/RRC/LITE/L2_interface.c b/openair2/RRC/LITE/L2_interface.c
index f2853308542..91834d9c9d6 100644
--- a/openair2/RRC/LITE/L2_interface.c
+++ b/openair2/RRC/LITE/L2_interface.c
@@ -53,9 +53,7 @@ extern UE_MAC_INST *UE_mac_inst;
 # include "intertask_interface.h"
 #endif
 
-#if defined(FLEXRAN_AGENT_SB_IF)
 #include "flexran_agent_extern.h"
-#endif
 
 //#define RRC_DATA_REQ_DEBUG
 //#define DEBUG_RRC 1
@@ -470,13 +468,11 @@ void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP,
   else {
     LOG_W(RRC,"Frame %d, Subframe %d: UL failure: UE %x unknown \n",frameP,subframeP,rntiP);
   }
-#if defined(FLEXRAN_AGENT_SB_IF)
   if (rrc_agent_registered[Mod_instP]) {
     agent_rrc_xface[Mod_instP]->flexran_agent_notify_ue_state_change(Mod_instP,
 								     rntiP,
 								     PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED);
   }
-#endif
 //  rrc_mac_remove_ue(Mod_instP,rntiP);
 }
 
diff --git a/openair2/RRC/LITE/proto.h b/openair2/RRC/LITE/proto.h
index 0f5ccdef1b9..9ece5bcfdd7 100644
--- a/openair2/RRC/LITE/proto.h
+++ b/openair2/RRC/LITE/proto.h
@@ -33,9 +33,7 @@
 
 #include "RRC/LITE/defs.h"
 
-#if defined(FLEXRAN_AGENT_SB_IF)
 #include "flexran_agent_extern.h"
-#endif
 
 //main.c
 int rrc_init_global_param(void);
@@ -274,8 +272,6 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(
 );
 
 
-#if defined(FLEXRAN_AGENT_SB_IF)
-
 void
 flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(
 							     const protocol_ctxt_t* const ctxt_pP,
@@ -284,8 +280,6 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(
 							     agent_reconf_rrc * trig_param
 							     );
 
-#endif
-
 int freq_to_arfcn10(int band, unsigned long freq);
 
 void
diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c
index c49b9283e21..2c8be5cfc6f 100644
--- a/openair2/RRC/LITE/rrc_eNB.c
+++ b/openair2/RRC/LITE/rrc_eNB.c
@@ -871,12 +871,10 @@ rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s*
         }
       }
 
-#if defined(FLEXRAN_AGENT_SB_IF)
       if (rrc_agent_registered[enb_mod_idP]) {
         agent_rrc_xface[enb_mod_idP]->flexran_agent_notify_ue_state_change(enb_mod_idP,
                               rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED);
       }
-#endif
 
       for(j = 0; j < 10; j++){
         ul_req_tmp = &eNB_MAC->UL_req_tmp[CC_id][j].ul_config_request_body;
@@ -3361,7 +3359,6 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons
 	       PDCP_TRANSMISSION_MODE_CONTROL);
 }
 
-#if defined(FLEXRAN_AGENT_SB_IF)
 //-----------------------------------------------------------------------------
 void
 flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* const ctxt_pP,
@@ -3952,8 +3949,6 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt
          PDCP_TRANSMISSION_MODE_CONTROL);
 }
 
-#endif
-
 
 //-----------------------------------------------------------------------------
 int
@@ -6294,13 +6289,11 @@ rrc_eNB_decode_ccch(
 
         } else {
           // no context available
-#if defined(FLEXRAN_AGENT_SB_IF)
 	  if (rrc_agent_registered[ctxt_pP->module_id]) {
 	    agent_rrc_xface[ctxt_pP->module_id]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id,
 										      ctxt_pP->rnti,
 										      PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED);
 	  }
-#endif
           LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Can't create new context for UE random UE identity (0x%" PRIx64 ")\n",
                 PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
                 random_value);
@@ -6562,14 +6555,12 @@ rrc_eNB_decode_dcch(
           ue_context_p,
 	  ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier);
 
-#if defined(FLEXRAN_AGENT_SB_IF)
 	//WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future
 	if (rrc_agent_registered[ctxt_pP->module_id]) {
 	  agent_rrc_xface[ctxt_pP->eNB_index]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id,
 										ue_context_p->ue_id_rnti,
 										PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_UPDATED);
 	}
-#endif
       }
 #if defined(ENABLE_ITTI)
 #   if defined(ENABLE_USE_MME)
@@ -6704,14 +6695,12 @@ if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) {
               ul_dcch_msg->message.choice.c1.choice.rrcConnectionReestablishmentComplete.rrc_TransactionIdentifier,
               &ul_dcch_msg->message.choice.c1.choice.rrcConnectionReestablishmentComplete.criticalExtensions.choice.rrcConnectionReestablishmentComplete_r8);
 
-#if defined(FLEXRAN_AGENT_SB_IF)
           //WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future
           if (mac_agent_registered[ctxt_pP->module_id]) {
             agent_rrc_xface[ctxt_pP->eNB_index]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id,
                                                                                       ue_context_p->ue_id_rnti,
                                                                                       PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_ACTIVATED);
           }
-#endif
         }
         //ue_context_p->ue_context.ue_release_timer = 0;
         ue_context_p->ue_context.ue_reestablishment_timer = 1;
@@ -6761,14 +6750,12 @@ if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) {
           LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_CONNECTED \n",
                 PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
 	  
-#if defined(FLEXRAN_AGENT_SB_IF)
 	  //WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future
 	  if (rrc_agent_registered[ctxt_pP->module_id]) {
 	    agent_rrc_xface[ctxt_pP->eNB_index]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id,
 										  ue_context_p->ue_id_rnti,
 										  PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_ACTIVATED);
 	  }
-#endif
         }
       }
 
diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c
index 42a4a7c9505..f6789086b4e 100644
--- a/targets/RT/USER/lte-softmodem.c
+++ b/targets/RT/USER/lte-softmodem.c
@@ -1319,12 +1319,11 @@ int main( int argc, char **argv )
   }
 #endif
 
-#ifdef FLEXRAN_AGENT_SB_IF
+  /* Start the agent. If it is turned off in the configuration, it won't start */
   RCconfig_flexran();
   for (i = 0; i < RC.nb_L1_inst; i++) {
     flexran_agent_start(i);
   }
-#endif
 
   // init UE_PF_PO and mutex lock
   pthread_mutex_init(&ue_pf_po_mutex, NULL);
diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h
index d8f6e3c7e9b..5cc4d5fea2d 100644
--- a/targets/RT/USER/lte-softmodem.h
+++ b/targets/RT/USER/lte-softmodem.h
@@ -31,6 +31,8 @@
 #include "PHY/defs.h"
 #include "SIMULATION/ETH_TRANSPORT/proto.h"
 
+#include "flexran_agent.h"
+
 #if defined(ENABLE_ITTI)
 #if defined(ENABLE_USE_MME)
 #include "s1ap_eNB.h"
@@ -271,8 +273,4 @@ void init_eNB_afterRU(void);
 extern int stop_L1L2(module_id_t enb_id);
 extern int restart_L1L2(module_id_t enb_id);
 
-#ifdef FLEXRAN_AGENT_SB_IF
-#include "flexran_agent.h"
-#endif
-
 #endif
diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c
index 7d8b33f12c0..302b77b60fd 100644
--- a/targets/SIMU/USER/oaisim.c
+++ b/targets/SIMU/USER/oaisim.c
@@ -76,9 +76,7 @@ uint8_t config_smbv = 0;
 char smbv_ip[16];
 #endif
 
-#if defined(FLEXRAN_AGENT_SB_IF)
-#   include "flexran_agent.h"
-#endif
+#include "flexran_agent.h"
 
 
 #include "oaisim_functions.h"
-- 
GitLab