From 1fc631e2a4d6c5aa1e67f5c17d52b5a00b87ce6d Mon Sep 17 00:00:00 2001
From: Robert Schmidt <robert.schmidt@eurecom.fr>
Date: Thu, 25 Oct 2018 19:22:23 +0200
Subject: [PATCH] RAN API RRC part: Change interface to RNTI, change
 flexran_get_aperiodic_cqi_rep_mode()

* the RAN API RRC part now takes rnti and does not look it up in the MAC every
  time again
* the function flexran_get_aperiodic_cqi_rep_mode() has been changed to return
  a proper protobuf variable, not OAI typedef
---
 .../CONTROL_MODULES/MAC/flexran_agent_mac.c   |   6 +-
 .../CONTROL_MODULES/RRC/flexran_agent_rrc.c   | 166 ++++++++--------
 .../ENB_APP/MESSAGES/V2/config_common.proto   |   5 +-
 openair2/ENB_APP/flexran_agent_common.c       | 103 +++++-----
 openair2/ENB_APP/flexran_agent_handler.c      |   2 +-
 openair2/ENB_APP/flexran_agent_ran_api.c      | 180 ++++++------------
 openair2/ENB_APP/flexran_agent_ran_api.h      |  74 +++----
 7 files changed, 235 insertions(+), 301 deletions(-)

diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c
index d857953184..162e5b0590 100644
--- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c
+++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c
@@ -911,7 +911,7 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle
       if(dl_info[i] == NULL)
 	goto error;
       protocol__flex_dl_info__init(dl_info[i]);
-      dl_info[i]->rnti = flexran_get_ue_crnti(mod_id, UE_id);
+      dl_info[i]->rnti = flexran_get_mac_ue_crnti(mod_id, UE_id);
       dl_info[i]->has_rnti = 1;
       /*Fill in the right id of this round's HARQ process for this UE*/
       //      uint8_t harq_id;
@@ -959,7 +959,7 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle
       if(ul_info[i] == NULL)
 	goto error;
       protocol__flex_ul_info__init(ul_info[i]);
-      ul_info[i]->rnti = flexran_get_ue_crnti(mod_id, i);
+      ul_info[i]->rnti = flexran_get_mac_ue_crnti(mod_id, i);
       ul_info[i]->has_rnti = 1;
       /* Fill in the Tx power control command for this UE (if available),
        * primary carrier */
@@ -1375,7 +1375,7 @@ void flexran_agent_fill_mac_cell_config(mid_t mod_id, uint8_t cc_id,
 void flexran_agent_fill_mac_lc_ue_config(mid_t mod_id, mid_t ue_id,
     Protocol__FlexLcUeConfig *lc_ue_conf)
 {
-  lc_ue_conf->rnti = flexran_get_ue_crnti(mod_id, ue_id);
+  lc_ue_conf->rnti = flexran_get_mac_ue_crnti(mod_id, ue_id);
   lc_ue_conf->has_rnti = 1;
 
   lc_ue_conf->n_lc_config = flexran_get_num_ue_lcs(mod_id, ue_id);
diff --git a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c
index edaaf6980b..02180cc756 100644
--- a/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c
+++ b/openair2/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c
@@ -74,20 +74,22 @@ void flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_ch
     config->rnti = rnti;
   } else if (state_change == PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_UPDATED
        || state_change == PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_ACTIVATED) {
-        int i = find_UE_id(mod_id, rnti);
+    // TODO this goes into the MAC CM */
+        //int i = find_UE_id(mod_id, rnti);
       config->has_rnti = 1;
       config->rnti = rnti;
-        if(flexran_get_time_alignment_timer(mod_id,i) != -1) {
-          config->time_alignment_timer = flexran_get_time_alignment_timer(mod_id,i);
+      /* RNTI correct */
+        if(flexran_get_time_alignment_timer(mod_id, rnti) != -1) {
+          config->time_alignment_timer = flexran_get_time_alignment_timer(mod_id, rnti);
           config->has_time_alignment_timer = 1;
         }
-        if(flexran_get_meas_gap_config(mod_id,i) != -1){
-          config->meas_gap_config_pattern = flexran_get_meas_gap_config(mod_id,i);
+        if(flexran_get_meas_gap_config(mod_id, rnti) != -1){
+          config->meas_gap_config_pattern = flexran_get_meas_gap_config(mod_id, rnti);
             config->has_meas_gap_config_pattern = 1;
         }
         if(config->has_meas_gap_config_pattern == 1 &&
          config->meas_gap_config_pattern != PROTOCOL__FLEX_MEAS_GAP_CONFIG_PATTERN__FLMGCP_OFF) {
-        config->meas_gap_config_sf_offset = flexran_get_meas_gap_config_offset(mod_id,i);
+        config->meas_gap_config_sf_offset = flexran_get_meas_gap_config_offset(mod_id, rnti);
         config->has_meas_gap_config_sf_offset = 1;
         }
         //TODO: Set the SPS configuration (Optional)
@@ -99,107 +101,104 @@ void flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_ch
         //TODO: Set the CQI configuration (Optional)
         //We do not set it for now
       
-      if(flexran_get_ue_transmission_mode(mod_id,i) != -1) {
-          config->transmission_mode = flexran_get_ue_transmission_mode(mod_id,i);
+      if(flexran_get_ue_transmission_mode(mod_id, rnti) != -1) {
+          config->transmission_mode = flexran_get_ue_transmission_mode(mod_id, rnti);
           config->has_transmission_mode = 1;
         }
 
-      config->ue_aggregated_max_bitrate_ul = flexran_get_ue_aggregated_max_bitrate_ul(mod_id,i);
-        config->has_ue_aggregated_max_bitrate_ul = 1;
+      /* TODO into MAC CM */
+      //config->ue_aggregated_max_bitrate_ul = flexran_get_ue_aggregated_max_bitrate_ul(mod_id,i);
+      //config->has_ue_aggregated_max_bitrate_ul = 1;
 
-      config->ue_aggregated_max_bitrate_dl = flexran_get_ue_aggregated_max_bitrate_dl(mod_id,i);
-        config->has_ue_aggregated_max_bitrate_dl = 1;
+      /* TODO into MAC CM */
+      //config->ue_aggregated_max_bitrate_dl = flexran_get_ue_aggregated_max_bitrate_dl(mod_id,i);
+      //config->has_ue_aggregated_max_bitrate_dl = 1;
 
-        //TODO: Set the UE capabilities
         Protocol__FlexUeCapabilities *c_capabilities;
         c_capabilities = malloc(sizeof(Protocol__FlexUeCapabilities));
         protocol__flex_ue_capabilities__init(c_capabilities);
-        //TODO: Set half duplex (FDD operation)
-        c_capabilities->has_half_duplex = 0;
-        c_capabilities->half_duplex = 1;//flexran_get_half_duplex(i);
-        //TODO: Set intra-frame hopping flag
-        c_capabilities->has_intra_sf_hopping = 0;
-        c_capabilities->intra_sf_hopping = 1;//flexran_get_intra_sf_hopping(i);
-        //TODO: Set support for type 2 hopping with n_sb > 1
-        c_capabilities->has_type2_sb_1 = 0;
-        c_capabilities->type2_sb_1 = 1;//flexran_get_type2_sb_1(i);
-        //TODO: Set ue category
-        c_capabilities->has_ue_category = 0;
-        c_capabilities->ue_category = 1;//flexran_get_ue_category(i);
-        //TODO: Set UE support for resource allocation type 1
-        c_capabilities->has_res_alloc_type1 = 0;
-        c_capabilities->res_alloc_type1 = 1;//flexran_get_res_alloc_type1(i);
-        //Set the capabilites to the message
+
+        c_capabilities->has_half_duplex = 1;
+        c_capabilities->half_duplex = flexran_get_half_duplex(mod_id, rnti);
+
+        c_capabilities->has_intra_sf_hopping = 1;
+        c_capabilities->intra_sf_hopping = flexran_get_intra_sf_hopping(mod_id, rnti);
+
+        c_capabilities->has_type2_sb_1 = 1;
+        c_capabilities->type2_sb_1 = flexran_get_type2_sb_1(mod_id, rnti);
+
+        c_capabilities->has_ue_category = 1;
+        c_capabilities->ue_category = flexran_get_ue_category(mod_id, rnti);
+
+        c_capabilities->has_res_alloc_type1 = 1;
+        c_capabilities->res_alloc_type1 = flexran_get_res_alloc_type1(mod_id, rnti);
+
         config->capabilities = c_capabilities;
       
-        if(flexran_get_ue_transmission_antenna(mod_id,i) != -1) {
+        if(flexran_get_ue_transmission_antenna(mod_id, rnti) != -1) {
         config->has_ue_transmission_antenna = 1;
-        config->ue_transmission_antenna = flexran_get_ue_transmission_antenna(mod_id,i);
+          config->ue_transmission_antenna = flexran_get_ue_transmission_antenna(mod_id, rnti);
         }
 
-        if(flexran_get_tti_bundling(mod_id,i) != -1) {
+        if (flexran_get_tti_bundling(mod_id, rnti) != -1) {
         config->has_tti_bundling = 1;
-        config->tti_bundling = flexran_get_tti_bundling(mod_id,i);
+          config->tti_bundling = flexran_get_tti_bundling(mod_id, rnti);
         }
 
-        if(flexran_get_maxHARQ_TX(mod_id,i) != -1){
+        if(flexran_get_maxHARQ_TX(mod_id, rnti) != -1){
         config->has_max_harq_tx = 1;
-        config->max_harq_tx = flexran_get_maxHARQ_TX(mod_id,i);
+        config->max_harq_tx = flexran_get_maxHARQ_TX(mod_id, rnti);
         }
 
-        if(flexran_get_beta_offset_ack_index(mod_id,i) != -1) {
+        if(flexran_get_beta_offset_ack_index(mod_id, rnti) != -1) {
         config->has_beta_offset_ack_index = 1;
-        config->beta_offset_ack_index = flexran_get_beta_offset_ack_index(mod_id,i);
+        config->beta_offset_ack_index = flexran_get_beta_offset_ack_index(mod_id, rnti);
         }
 
-        if(flexran_get_beta_offset_ri_index(mod_id,i) != -1) {
+        if(flexran_get_beta_offset_ri_index(mod_id, rnti) != -1) {
         config->has_beta_offset_ri_index = 1;
-        config->beta_offset_ri_index = flexran_get_beta_offset_ri_index(mod_id,i);
+        config->beta_offset_ri_index = flexran_get_beta_offset_ri_index(mod_id, rnti);
         }
 
-        if(flexran_get_beta_offset_cqi_index(mod_id,i) != -1) {
+        if(flexran_get_beta_offset_cqi_index(mod_id, rnti) != -1) {
         config->has_beta_offset_cqi_index = 1;
-        config->beta_offset_cqi_index = flexran_get_beta_offset_cqi_index(mod_id,i);
+        config->beta_offset_cqi_index = flexran_get_beta_offset_cqi_index(mod_id, rnti);
         }
 
         /* assume primary carrier */
-        if(flexran_get_ack_nack_simultaneous_trans(mod_id,i,0) != -1) {
+        if(flexran_get_ack_nack_simultaneous_trans(mod_id,0) != -1) {
         config->has_ack_nack_simultaneous_trans = 1;
-        config->ack_nack_simultaneous_trans = flexran_get_ack_nack_simultaneous_trans(mod_id,i,0);
+        config->ack_nack_simultaneous_trans = flexran_get_ack_nack_simultaneous_trans(mod_id,0);
         }
 
-        if(flexran_get_simultaneous_ack_nack_cqi(mod_id,i) != -1) {
+        if(flexran_get_simultaneous_ack_nack_cqi(mod_id, rnti) != -1) {
         config->has_simultaneous_ack_nack_cqi = 1;
-        config->simultaneous_ack_nack_cqi = flexran_get_simultaneous_ack_nack_cqi(mod_id,i);
+        config->simultaneous_ack_nack_cqi = flexran_get_simultaneous_ack_nack_cqi(mod_id, rnti);
         }
 
-        if(flexran_get_aperiodic_cqi_rep_mode(mod_id,i) != -1) {
+        if(flexran_get_aperiodic_cqi_rep_mode(mod_id, rnti) != -1) {
         config->has_aperiodic_cqi_rep_mode = 1;
-        int mode = flexran_get_aperiodic_cqi_rep_mode(mod_id,i);
-        if (mode > 4) {
-          config->aperiodic_cqi_rep_mode = PROTOCOL__FLEX_APERIODIC_CQI_REPORT_MODE__FLACRM_NONE;
-        } else {
-          config->aperiodic_cqi_rep_mode = mode;
-        }
+          config->aperiodic_cqi_rep_mode = flexran_get_aperiodic_cqi_rep_mode(mod_id, rnti);
         }
 
-        if(flexran_get_tdd_ack_nack_feedback_mode(mod_id, i) != -1) {
+        if(flexran_get_tdd_ack_nack_feedback_mode(mod_id, rnti) != -1) {
         config->has_tdd_ack_nack_feedback = 1;
-        config->tdd_ack_nack_feedback = flexran_get_tdd_ack_nack_feedback_mode(mod_id,i);
+          config->tdd_ack_nack_feedback = flexran_get_tdd_ack_nack_feedback_mode(mod_id, rnti);
         }
 
-        if(flexran_get_ack_nack_repetition_factor(mod_id, i) != -1) {
+        if(flexran_get_ack_nack_repetition_factor(mod_id, rnti) != -1) {
         config->has_ack_nack_repetition_factor = 1;
-        config->ack_nack_repetition_factor = flexran_get_ack_nack_repetition_factor(mod_id,i);
+          config->ack_nack_repetition_factor = flexran_get_ack_nack_repetition_factor(mod_id, rnti);
         }
 
-        if(flexran_get_extended_bsr_size(mod_id, i) != -1) {
+        if(flexran_get_extended_bsr_size(mod_id, rnti) != -1) {
         config->has_extended_bsr_size = 1;
-        config->extended_bsr_size = flexran_get_extended_bsr_size(mod_id,i);
+          config->extended_bsr_size = flexran_get_extended_bsr_size(mod_id, rnti);
         }
 
-      config->has_pcell_carrier_index = 1;
-      config->pcell_carrier_index = UE_PCCID(mod_id, i);
+        // TODO this goes into the MAC CM
+      //config->has_pcell_carrier_index = 1;
+      //config->pcell_carrier_index = UE_PCCID(mod_id, i);
         //TODO: Set carrier aggregation support (boolean)
         config->has_ca_support = 0;
         config->ca_support = 0;
@@ -261,24 +260,25 @@ int flexran_agent_destroy_ue_state_change(Protocol__FlexranMessage *msg) {
 /* this is called by RRC as a part of rrc xface  . The controller previously requested  this*/ 
 void flexran_trigger_rrc_measurements (mid_t mod_id, MeasResults_t*  measResults) {
 
-  int i;
   // int                   priority = 0; // Warning Preventing
   // void                  *data;
   // int                   size;
   // err_code_t             err_code = -100;
   triggered_rrc = true;
-  int num;
 
-  num = flexran_get_mac_num_ues (mod_id);
+  int num = flexran_get_rrc_num_ues (mod_id);
+  rnti_t rntis[num];
+  flexran_get_rrc_rnti_list(mod_id, rntis, num);
 
   meas_stats = malloc(sizeof(rrc_meas_stats) * num); 
 
-  for (i = 0; i < num; i++){
-    meas_stats[i].rnti = flexran_get_ue_crnti(mod_id, i);
-    meas_stats[i].meas_id = flexran_get_rrc_pcell_measid(mod_id,i);
-    meas_stats[i].rsrp =  flexran_get_rrc_pcell_rsrp(mod_id,i) - 140;
+  for (int i = 0; i < num; i++){
+    const rnti_t rnti = rntis[i];
+    meas_stats[i].rnti = rnti;
+    meas_stats[i].meas_id = flexran_get_rrc_pcell_measid(mod_id, rnti);
+    meas_stats[i].rsrp =  flexran_get_rrc_pcell_rsrp(mod_id, rnti) - 140;
     // measResults->measResultPCell.rsrpResult - 140;
-    meas_stats[i].rsrq =  flexran_get_rrc_pcell_rsrq(mod_id,i)/2 - 20;
+    meas_stats[i].rsrq =  flexran_get_rrc_pcell_rsrq(mod_id, rnti)/2 - 20;
     // (measResults->measResultPCell.rsrqResult)/2 - 20;                          
     
   }
@@ -489,14 +489,12 @@ int flexran_agent_rrc_stats_reply(mid_t mod_id,
            Protocol__FlexUeStatsReport **ue_report,
            Protocol__FlexCellStatsReport **cell_report) {
 
-
-  // Protocol__FlexHeader *header;
-  int i,j;
-
-  /* Allocate memory for list of UE reports */
   if (report_config->nr_ue > 0) {
+    rnti_t rntis[report_config->nr_ue];
+    flexran_get_rrc_rnti_list(mod_id, rntis, report_config->nr_ue);
 
-    for (i = 0; i < report_config->nr_ue; i++) {
+    for (int i = 0; i < report_config->nr_ue; i++) {
+      const rnti_t rnti = rntis[i];
       
       /* Check flag for creation of buffer status report */
       if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_RRC_MEASUREMENTS) {
@@ -508,13 +506,13 @@ int flexran_agent_rrc_stats_reply(mid_t mod_id,
       	  goto error;
       	protocol__flex_rrc_measurements__init(rrc_measurements);
       	
-      	rrc_measurements->measid = flexran_get_rrc_pcell_measid(mod_id,i);
+        rrc_measurements->measid = flexran_get_rrc_pcell_measid(mod_id, rnti);
       	rrc_measurements->has_measid = 1;
       	
-      	rrc_measurements->pcell_rsrp = flexran_get_rrc_pcell_rsrp(mod_id,i);
+        rrc_measurements->pcell_rsrp = flexran_get_rrc_pcell_rsrp(mod_id, rnti);
       	rrc_measurements->has_pcell_rsrp = 1;
       	
-      	rrc_measurements->pcell_rsrq = flexran_get_rrc_pcell_rsrq(mod_id,i);
+        rrc_measurements->pcell_rsrq = flexran_get_rrc_pcell_rsrq(mod_id, rnti);
       	rrc_measurements->has_pcell_rsrq = 1 ;
 
         
@@ -526,7 +524,7 @@ int flexran_agent_rrc_stats_reply(mid_t mod_id,
         protocol__flex_neigh_cells_measurements__init(neigh_meas);
          
         
-        neigh_meas->n_eutra_meas = flexran_get_rrc_num_ncell(mod_id, i);
+        neigh_meas->n_eutra_meas = flexran_get_rrc_num_ncell(mod_id, rnti);
 
         Protocol__FlexEutraMeasurements **eutra_meas = NULL;
 
@@ -536,7 +534,7 @@ int flexran_agent_rrc_stats_reply(mid_t mod_id,
           if (eutra_meas == NULL)
             goto error;
           
-          for (j = 0; j < neigh_meas->n_eutra_meas; j++ ){
+          for (int j = 0; j < neigh_meas->n_eutra_meas; j++ ){
 
               eutra_meas[j] = malloc(sizeof(Protocol__FlexEutraMeasurements));
               if (eutra_meas[j] == NULL)
@@ -544,7 +542,7 @@ int flexran_agent_rrc_stats_reply(mid_t mod_id,
 
               protocol__flex_eutra_measurements__init(eutra_meas[j]);
 
-              eutra_meas[j]->phys_cell_id = flexran_get_rrc_neigh_phy_cell_id(mod_id, i, j);
+              eutra_meas[j]->phys_cell_id = flexran_get_rrc_neigh_phy_cell_id(mod_id, rnti, j);
               eutra_meas[j]->has_phys_cell_id = 1;
 
 
@@ -555,10 +553,10 @@ int flexran_agent_rrc_stats_reply(mid_t mod_id,
 
               protocol__flex_eutra_ref_signal_meas__init(meas_result);     
 
-              meas_result->rsrp = flexran_get_rrc_neigh_rsrp(mod_id, i, eutra_meas[j]->phys_cell_id);
+              meas_result->rsrp = flexran_get_rrc_neigh_rsrp(mod_id, rnti, eutra_meas[j]->phys_cell_id);
               meas_result->has_rsrp = 1;
 
-              meas_result->rsrq = flexran_get_rrc_neigh_rsrq(mod_id, i, eutra_meas[j]->phys_cell_id);
+              meas_result->rsrq = flexran_get_rrc_neigh_rsrq(mod_id, rnti, eutra_meas[j]->phys_cell_id);
               meas_result->has_rsrq = 1;
 
               eutra_meas[j]->meas_result = meas_result;
@@ -620,10 +618,10 @@ int flexran_agent_rrc_stats_reply(mid_t mod_id,
 
  error:
 
-  for (i = 0; i < report_config->nr_ue; i++){
+  for (int i = 0; i < report_config->nr_ue; i++){
 
       if (ue_report[i]->rrc_measurements->neigh_meas != NULL){
-          for (j = 0; j < flexran_get_rrc_num_ncell(mod_id, i); j++){
+          for (int j = 0; j < ue_report[i]->rrc_measurements->neigh_meas->n_eutra_meas; j++){
 
              free(ue_report[i]->rrc_measurements->neigh_meas->eutra_meas[j]);
         }
diff --git a/openair2/ENB_APP/MESSAGES/V2/config_common.proto b/openair2/ENB_APP/MESSAGES/V2/config_common.proto
index 7b392b6b3b..1ee758fafd 100644
--- a/openair2/ENB_APP/MESSAGES/V2/config_common.proto
+++ b/openair2/ENB_APP/MESSAGES/V2/config_common.proto
@@ -137,6 +137,9 @@ enum flex_aperiodic_cqi_report_mode {
      FLACRM_RM30 = 3;
      FLACRM_RM31 = 4;
      FLACRM_NONE = 5;
+     FLACRM_RM32_v1250 = 6;
+     FLACRM_RM10_v1310 = 7;
+     FLACRM_RM11_v1310 = 8;
 }
 
 enum flex_tdd_ack_nack_feedback_mode {
@@ -177,4 +180,4 @@ enum flex_ue_state_change_type {
      FLUESC_ACTIVATED = 1;
      FLUESC_DEACTIVATED = 2;
      FLUESC_MOVED = 3;
-}
\ No newline at end of file
+}
diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c
index 112382ce29..df61a03cde 100644
--- a/openair2/ENB_APP/flexran_agent_common.c
+++ b/openair2/ENB_APP/flexran_agent_common.c
@@ -527,7 +527,7 @@ int flexran_agent_ue_config_reply(mid_t mod_id, const void *params, Protocol__Fl
 
   ue_config_reply_msg->header = header;
 
-  ue_config_reply_msg->n_ue_config = flexran_get_mac_num_ues(mod_id);
+  ue_config_reply_msg->n_ue_config = flexran_get_rrc_num_ues(mod_id);
 
   Protocol__FlexUeConfig **ue_config;
   if (ue_config_reply_msg->n_ue_config > 0) {
@@ -535,30 +535,34 @@ int flexran_agent_ue_config_reply(mid_t mod_id, const void *params, Protocol__Fl
     if (ue_config == NULL) {
       goto error;
     }
+    rnti_t rntis[ue_config_reply_msg->n_ue_config];
+    flexran_get_rrc_rnti_list(mod_id, rntis, ue_config_reply_msg->n_ue_config);
     for (i = 0; i < ue_config_reply_msg->n_ue_config; i++) {
+      const rnti_t rnti = rntis[i];
       ue_config[i] = malloc(sizeof(Protocol__FlexUeConfig));
       protocol__flex_ue_config__init(ue_config[i]);
 
-      ue_config[i]->rnti = flexran_get_ue_crnti(mod_id,i);
+      /* correct RNTI */
+      ue_config[i]->rnti = rnti;
       ue_config[i]->has_rnti = 1;
-      ue_config[i]->imsi = flexran_get_ue_imsi(mod_id, i);
+      ue_config[i]->imsi = flexran_get_ue_imsi(mod_id, rnti);
       ue_config[i]->has_imsi = 1;
       //TODO: Set the DRX configuration (optional)
       //Not supported for now, so we do not set it
 
-      if (flexran_get_time_alignment_timer(mod_id,i) != -1) {
-    	  ue_config[i]->time_alignment_timer = flexran_get_time_alignment_timer(mod_id,i);
+      if (flexran_get_time_alignment_timer(mod_id, rnti) != -1) {
+          ue_config[i]->time_alignment_timer = flexran_get_time_alignment_timer(mod_id, rnti);
     	  ue_config[i]->has_time_alignment_timer = 1;
       }
 
-      if (flexran_get_meas_gap_config(mod_id,i) != -1) {
-    	  ue_config[i]->meas_gap_config_pattern = flexran_get_meas_gap_config(mod_id,i);
+      if (flexran_get_meas_gap_config(mod_id, rnti) != -1) {
+          ue_config[i]->meas_gap_config_pattern = flexran_get_meas_gap_config(mod_id, rnti);
     	  ue_config[i]->has_meas_gap_config_pattern = 1;
       }
  
       if (ue_config[i]->has_meas_gap_config_pattern == 1 &&
-	 ue_config[i]->meas_gap_config_pattern != PROTOCOL__FLEX_MEAS_GAP_CONFIG_PATTERN__FLMGCP_OFF) {
-	ue_config[i]->meas_gap_config_sf_offset = flexran_get_meas_gap_config_offset(mod_id,i);
+         ue_config[i]->meas_gap_config_pattern != PROTOCOL__FLEX_MEAS_GAP_CONFIG_PATTERN__FLMGCP_OFF) {
+        ue_config[i]->meas_gap_config_sf_offset = flexran_get_meas_gap_config_offset(mod_id, rnti);
 	ue_config[i]->has_meas_gap_config_sf_offset = 1;
       }
       //TODO: Set the SPS configuration (Optional)
@@ -570,104 +574,101 @@ int flexran_agent_ue_config_reply(mid_t mod_id, const void *params, Protocol__Fl
       //TODO: Set the CQI configuration (Optional)
       //We do not set it for now
 
-      if (flexran_get_ue_transmission_mode(mod_id,i) != -1) {
-	ue_config[i]->transmission_mode = flexran_get_ue_transmission_mode(mod_id,i);
+      if (flexran_get_ue_transmission_mode(mod_id, rnti) != -1) {
+        ue_config[i]->transmission_mode = flexran_get_ue_transmission_mode(mod_id, rnti);
 	ue_config[i]->has_transmission_mode = 1;
       }
 
-      ue_config[i]->ue_aggregated_max_bitrate_ul = flexran_get_ue_aggregated_max_bitrate_ul(mod_id,i);
-      ue_config[i]->has_ue_aggregated_max_bitrate_ul = 1;
+      /* into MAC CM */
+      //ue_config[i]->ue_aggregated_max_bitrate_ul = flexran_get_ue_aggregated_max_bitrate_ul(mod_id,i);
+      //ue_config[i]->has_ue_aggregated_max_bitrate_ul = 1;
 
-      ue_config[i]->ue_aggregated_max_bitrate_dl = flexran_get_ue_aggregated_max_bitrate_dl(mod_id,i);
-      ue_config[i]->has_ue_aggregated_max_bitrate_dl = 1;
+      //ue_config[i]->ue_aggregated_max_bitrate_dl = flexran_get_ue_aggregated_max_bitrate_dl(mod_id,i);
+      //ue_config[i]->has_ue_aggregated_max_bitrate_dl = 1;
 
       Protocol__FlexUeCapabilities *capabilities;
       capabilities = malloc(sizeof(Protocol__FlexUeCapabilities));
       protocol__flex_ue_capabilities__init(capabilities);
       capabilities->has_half_duplex = 1;
-      capabilities->half_duplex = flexran_get_half_duplex(mod_id, i);
+      capabilities->half_duplex = flexran_get_half_duplex(mod_id, rnti);
       capabilities->has_intra_sf_hopping = 1;
-      capabilities->intra_sf_hopping = flexran_get_intra_sf_hopping(mod_id, i);
+      capabilities->intra_sf_hopping = flexran_get_intra_sf_hopping(mod_id, rnti);
       capabilities->has_type2_sb_1 = 1;
-      capabilities->type2_sb_1 = flexran_get_type2_sb_1(mod_id, i);
+      capabilities->type2_sb_1 = flexran_get_type2_sb_1(mod_id, rnti);
       capabilities->has_ue_category = 1;
-      capabilities->ue_category = flexran_get_ue_category(mod_id, i);
+      capabilities->ue_category = flexran_get_ue_category(mod_id, rnti);
       capabilities->has_res_alloc_type1 = 1;
-      capabilities->res_alloc_type1 = flexran_get_res_alloc_type1(mod_id, i);
+      capabilities->res_alloc_type1 = flexran_get_res_alloc_type1(mod_id, rnti);
       //Set the capabilites to the message
       ue_config[i]->capabilities = capabilities;
 
-      if (flexran_get_ue_transmission_antenna(mod_id,i) != -1) {
+      if (flexran_get_ue_transmission_antenna(mod_id, rnti) != -1) {
 	ue_config[i]->has_ue_transmission_antenna = 1;
-	ue_config[i]->ue_transmission_antenna = flexran_get_ue_transmission_antenna(mod_id,i);
+	ue_config[i]->ue_transmission_antenna = flexran_get_ue_transmission_antenna(mod_id, rnti);
       }
 
-      if (flexran_get_tti_bundling(mod_id,i) != -1) {
+      if (flexran_get_tti_bundling(mod_id, rnti) != -1) {
 	ue_config[i]->has_tti_bundling = 1;
-	ue_config[i]->tti_bundling = flexran_get_tti_bundling(mod_id,i);
+        ue_config[i]->tti_bundling = flexran_get_tti_bundling(mod_id, rnti);
       }
 
-      if (flexran_get_maxHARQ_TX(mod_id,i) != -1) {
+      if (flexran_get_maxHARQ_TX(mod_id, rnti) != -1) {
 	ue_config[i]->has_max_harq_tx = 1;
-	ue_config[i]->max_harq_tx = flexran_get_maxHARQ_TX(mod_id,i);
+	ue_config[i]->max_harq_tx = flexran_get_maxHARQ_TX(mod_id, rnti);
       }
 
-      if (flexran_get_beta_offset_ack_index(mod_id,i) != -1) {
+      if (flexran_get_beta_offset_ack_index(mod_id, rnti) != -1) {
 	ue_config[i]->has_beta_offset_ack_index = 1;
-	ue_config[i]->beta_offset_ack_index = flexran_get_beta_offset_ack_index(mod_id,i);
+	ue_config[i]->beta_offset_ack_index = flexran_get_beta_offset_ack_index(mod_id, rnti);
       }
 
-      if (flexran_get_beta_offset_ri_index(mod_id,i) != -1) {
+      if (flexran_get_beta_offset_ri_index(mod_id, rnti) != -1) {
 	ue_config[i]->has_beta_offset_ri_index = 1;
-    	  ue_config[i]->beta_offset_ri_index = flexran_get_beta_offset_ri_index(mod_id,i);
+        ue_config[i]->beta_offset_ri_index = flexran_get_beta_offset_ri_index(mod_id, rnti);
       }
 
-      if (flexran_get_beta_offset_cqi_index(mod_id,i) != -1) {
+      if (flexran_get_beta_offset_cqi_index(mod_id, rnti) != -1) {
 	ue_config[i]->has_beta_offset_cqi_index = 1;
-	ue_config[i]->beta_offset_cqi_index = flexran_get_beta_offset_cqi_index(mod_id,i);
+	ue_config[i]->beta_offset_cqi_index = flexran_get_beta_offset_cqi_index(mod_id, rnti);
       }
       
       /* assume primary carrier */
-      if (flexran_get_ack_nack_simultaneous_trans(mod_id, i, 0) != -1) {
+      if (flexran_get_ack_nack_simultaneous_trans(mod_id, 0) != -1) {
 	ue_config[i]->has_ack_nack_simultaneous_trans = 1;
-	ue_config[i]->ack_nack_simultaneous_trans = flexran_get_ack_nack_simultaneous_trans(mod_id, i, 0);
+	ue_config[i]->ack_nack_simultaneous_trans = flexran_get_ack_nack_simultaneous_trans(mod_id, 0);
       }
       
-      if (flexran_get_simultaneous_ack_nack_cqi(mod_id,i) != -1) {
+      if (flexran_get_simultaneous_ack_nack_cqi(mod_id, rnti) != -1) {
 	ue_config[i]->has_simultaneous_ack_nack_cqi = 1;
-	ue_config[i]->simultaneous_ack_nack_cqi = flexran_get_simultaneous_ack_nack_cqi(mod_id,i);
+	ue_config[i]->simultaneous_ack_nack_cqi = flexran_get_simultaneous_ack_nack_cqi(mod_id, rnti);
       }
       
-      if (flexran_get_aperiodic_cqi_rep_mode(mod_id,i) != -1) {
+      if (flexran_get_aperiodic_cqi_rep_mode(mod_id, rnti) != -1) {
 	ue_config[i]->has_aperiodic_cqi_rep_mode = 1;
-	int mode = flexran_get_aperiodic_cqi_rep_mode(mod_id,i);
-	if (mode > 4) {
-	  ue_config[i]->aperiodic_cqi_rep_mode = PROTOCOL__FLEX_APERIODIC_CQI_REPORT_MODE__FLACRM_NONE;
-	} else {
-	  ue_config[i]->aperiodic_cqi_rep_mode = mode;
-	}
+        ue_config[i]->aperiodic_cqi_rep_mode = flexran_get_aperiodic_cqi_rep_mode(mod_id, rnti);
       }
       
-      if (flexran_get_tdd_ack_nack_feedback_mode(mod_id, i) != -1) {
+      if (flexran_get_tdd_ack_nack_feedback_mode(mod_id, rnti) != -1) {
 	ue_config[i]->has_tdd_ack_nack_feedback = 1;
-	ue_config[i]->tdd_ack_nack_feedback = flexran_get_tdd_ack_nack_feedback_mode(mod_id,i);
+	ue_config[i]->tdd_ack_nack_feedback = flexran_get_tdd_ack_nack_feedback_mode(mod_id, rnti);
       }
       
-      if(flexran_get_ack_nack_repetition_factor(mod_id, i) != -1) {
+      if(flexran_get_ack_nack_repetition_factor(mod_id, rnti) != -1) {
 	ue_config[i]->has_ack_nack_repetition_factor = 1;
-	ue_config[i]->ack_nack_repetition_factor = flexran_get_ack_nack_repetition_factor(mod_id,i);
+	ue_config[i]->ack_nack_repetition_factor = flexran_get_ack_nack_repetition_factor(mod_id, rnti);
       }
       
-      if (flexran_get_extended_bsr_size(mod_id, i) != -1) {
+      if (flexran_get_extended_bsr_size(mod_id, rnti) != -1) {
 	ue_config[i]->has_extended_bsr_size = 1;
-	ue_config[i]->extended_bsr_size = flexran_get_extended_bsr_size(mod_id,i);
+	ue_config[i]->extended_bsr_size = flexran_get_extended_bsr_size(mod_id, rnti);
       }
       //TODO: Set carrier aggregation support (boolean)
       ue_config[i]->has_ca_support = 0;
       ue_config[i]->ca_support = 0;
 
-      ue_config[i]->has_pcell_carrier_index = 1;
-      ue_config[i]->pcell_carrier_index = UE_PCCID(mod_id, i);
+      /* into MAC CM */
+      //ue_config[i]->has_pcell_carrier_index = 1;
+      //ue_config[i]->pcell_carrier_index = UE_PCCID(mod_id, i);
       if(ue_config[i]->has_ca_support){
 	//TODO: Set cross carrier scheduling support (boolean)
 	ue_config[i]->has_cross_carrier_sched_support = 0;
diff --git a/openair2/ENB_APP/flexran_agent_handler.c b/openair2/ENB_APP/flexran_agent_handler.c
index a5e7713a47..dd8a569dc0 100644
--- a/openair2/ENB_APP/flexran_agent_handler.c
+++ b/openair2/ENB_APP/flexran_agent_handler.c
@@ -249,7 +249,7 @@ int flexran_agent_handle_stats(mid_t mod_id, const void *params, Protocol__Flexr
   goto error;
       }
       for (i = 0; i < report_config.nr_ue; i++) {
-  report_config.ue_report_type[i].ue_rnti = flexran_get_ue_crnti(enb_id, i); //eNB_UE_list->eNB_UE_stats[UE_PCCID(enb_id,i)][i].crnti;
+  report_config.ue_report_type[i].ue_rnti = flexran_get_mac_ue_crnti(enb_id, i);
   report_config.ue_report_type[i].ue_report_flags = ue_flags;
       }
       //Set the number of CCs and create a list with the cell stats configs
diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c
index 15532e086b..45976559e4 100644
--- a/openair2/ENB_APP/flexran_agent_ran_api.c
+++ b/openair2/ENB_APP/flexran_agent_ran_api.c
@@ -118,7 +118,7 @@ int flexran_get_num_ue_lcs(mid_t mod_id, mid_t ue_id)
 {
   if (!mac_is_present(mod_id)) return 0;
   // Not sure whether this is needed: if (!rrc_is_present(mod_id)) return 0;
-  const rnti_t rnti = flexran_get_ue_crnti(mod_id, ue_id);
+  const rnti_t rnti = flexran_get_mac_ue_crnti(mod_id, ue_id);
   const int s = mac_eNB_get_rrc_status(mod_id, rnti);
   if (s < RRC_CONNECTED)
     return 0;
@@ -128,7 +128,7 @@ int flexran_get_num_ue_lcs(mid_t mod_id, mid_t ue_id)
     return 3;
 }
 
-rnti_t flexran_get_ue_crnti(mid_t mod_id, mid_t ue_id)
+rnti_t flexran_get_mac_ue_crnti(mid_t mod_id, mid_t ue_id)
 {
   if (!mac_is_present(mod_id)) return 0;
   return UE_RNTI(mod_id, ue_id);
@@ -155,7 +155,7 @@ uint8_t flexran_get_ue_wcqi(mid_t mod_id, mid_t ue_id)
 rlc_buffer_occupancy_t flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id)
 {
   if (!mac_is_present(mod_id)) return 0;
-  rnti_t rnti = flexran_get_ue_crnti(mod_id, ue_id);
+  rnti_t rnti = flexran_get_mac_ue_crnti(mod_id, ue_id);
   frame_t frame = flexran_get_current_frame(mod_id);
   sub_frame_t subframe = flexran_get_current_subframe(mod_id);
   mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id,rnti, mod_id, frame, subframe, ENB_FLAG_YES,MBMS_FLAG_NO, channel_id, 0
@@ -169,7 +169,7 @@ rlc_buffer_occupancy_t flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logi
 rlc_buffer_occupancy_t flexran_get_num_pdus_buffer(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id)
 {
   if (!mac_is_present(mod_id)) return 0;
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
+  rnti_t rnti = flexran_get_mac_ue_crnti(mod_id,ue_id);
   frame_t frame = flexran_get_current_frame(mod_id);
   sub_frame_t subframe = flexran_get_current_subframe(mod_id);
   mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id,rnti, mod_id, frame, subframe, ENB_FLAG_YES,MBMS_FLAG_NO, channel_id, 0
@@ -183,7 +183,7 @@ rlc_buffer_occupancy_t flexran_get_num_pdus_buffer(mid_t mod_id, mid_t ue_id, lo
 frame_t flexran_get_hol_delay(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id)
 {
   if (!mac_is_present(mod_id)) return 0;
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
+  rnti_t rnti = flexran_get_mac_ue_crnti(mod_id,ue_id);
   frame_t frame = flexran_get_current_frame(mod_id);
   sub_frame_t subframe = flexran_get_current_subframe(mod_id);
   mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id, rnti, mod_id, frame, subframe, ENB_FLAG_YES, MBMS_FLAG_NO, channel_id, 0
@@ -457,7 +457,7 @@ int flexran_get_harq(mid_t       mod_id,
   
   if (mac_xface_not_ready()) return 0 ;
 
-  uint16_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
+  uint16_t rnti = flexran_get_mac_ue_crnti(mod_id,ue_id);
   if (harq_flag == openair_harq_DL){
 
       mac_xface->get_ue_active_harq_pid(mod_id,CC_id,rnti,frame,subframe,&harq_pid,&harq_round,openair_harq_DL);
@@ -777,25 +777,19 @@ int flexran_get_rrc_rnti_list(mid_t mod_id, rnti_t *list, int max_list)
   return n;
 }
 
-TimeAlignmentTimer_t flexran_get_time_alignment_timer(mid_t mod_id, mid_t ue_id)
+TimeAlignmentTimer_t flexran_get_time_alignment_timer(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.mac_MainConfig) return -1;
   return ue_context_p->ue_context.mac_MainConfig->timeAlignmentTimerDedicated;
 }
 
-Protocol__FlexMeasGapConfigPattern flexran_get_meas_gap_config(mid_t mod_id, mid_t ue_id)
+Protocol__FlexMeasGapConfigPattern flexran_get_meas_gap_config(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.measGapConfig) return -1;
   if (ue_context_p->ue_context.measGapConfig->present != MeasGapConfig_PR_setup) return -1;
@@ -810,13 +804,10 @@ Protocol__FlexMeasGapConfigPattern flexran_get_meas_gap_config(mid_t mod_id, mid
 }
 
 
-long flexran_get_meas_gap_config_offset(mid_t mod_id, mid_t ue_id)
+long flexran_get_meas_gap_config_offset(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.measGapConfig) return -1;
   if (ue_context_p->ue_context.measGapConfig->present != MeasGapConfig_PR_setup) return -1;
@@ -830,13 +821,10 @@ long flexran_get_meas_gap_config_offset(mid_t mod_id, mid_t ue_id)
   }
 }
 
-uint8_t flexran_get_rrc_status(mid_t mod_id, mid_t ue_id)
+uint8_t flexran_get_rrc_status(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return 0;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id, ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return RRC_INACTIVE;
   return ue_context_p->ue_context.Status;
 }
@@ -853,13 +841,10 @@ uint64_t flexran_get_ue_aggregated_max_bitrate_ul(mid_t mod_id, mid_t ue_id)
   return RC.mac[mod_id]->UE_list.UE_sched_ctrl[ue_id].ue_AggregatedMaximumBitrateUL;
 }
 
-int flexran_get_half_duplex(mid_t mod_id, mid_t ue_id)
+int flexran_get_half_duplex(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.UE_Capability) return -1;
   SupportedBandListEUTRA_t *bands = &ue_context_p->ue_context.UE_Capability->rf_Parameters.supportedBandListEUTRA;
@@ -869,13 +854,10 @@ int flexran_get_half_duplex(mid_t mod_id, mid_t ue_id)
   return 0;
 }
 
-int flexran_get_intra_sf_hopping(mid_t mod_id, mid_t ue_id)
+int flexran_get_intra_sf_hopping(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.UE_Capability) return -1;
   if (!ue_context_p->ue_context.UE_Capability->featureGroupIndicators) return -1;
@@ -887,13 +869,10 @@ int flexran_get_intra_sf_hopping(mid_t mod_id, mid_t ue_id)
   return (buf >> 7) & 1;
 }
 
-int flexran_get_type2_sb_1(mid_t mod_id, mid_t ue_id)
+int flexran_get_type2_sb_1(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.UE_Capability) return -1;
   if (!ue_context_p->ue_context.UE_Capability->featureGroupIndicators) return -1;
@@ -906,25 +885,19 @@ int flexran_get_type2_sb_1(mid_t mod_id, mid_t ue_id)
   return (buf >> 3) & 1;
 }
 
-long flexran_get_ue_category(mid_t mod_id, mid_t ue_id)
+long flexran_get_ue_category(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.UE_Capability) return -1;
   return ue_context_p->ue_context.UE_Capability->ue_Category;
 }
 
-int flexran_get_res_alloc_type1(mid_t mod_id, mid_t ue_id)
+int flexran_get_res_alloc_type1(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.UE_Capability) return -1;
   if (!ue_context_p->ue_context.UE_Capability->featureGroupIndicators) return -1;
@@ -936,24 +909,19 @@ int flexran_get_res_alloc_type1(mid_t mod_id, mid_t ue_id)
   return (buf >> 6) & 1;
 }
 
-long flexran_get_ue_transmission_mode(mid_t mod_id, mid_t ue_id)
+long flexran_get_ue_transmission_mode(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.physicalConfigDedicated) return -1;
   if (!ue_context_p->ue_context.physicalConfigDedicated->antennaInfo) return -1;
   return ue_context_p->ue_context.physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode;
 }
 
-BOOLEAN_t flexran_get_tti_bundling(mid_t mod_id, mid_t ue_id)
+BOOLEAN_t flexran_get_tti_bundling(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.mac_MainConfig) return -1;
@@ -961,65 +929,50 @@ BOOLEAN_t flexran_get_tti_bundling(mid_t mod_id, mid_t ue_id)
   return ue_context_p->ue_context.mac_MainConfig->ul_SCH_Config->ttiBundling;
 }
 
-long flexran_get_maxHARQ_TX(mid_t mod_id, mid_t ue_id)
+long flexran_get_maxHARQ_TX(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.mac_MainConfig) return -1;
   if (!ue_context_p->ue_context.mac_MainConfig->ul_SCH_Config) return -1;
   return *(ue_context_p->ue_context.mac_MainConfig->ul_SCH_Config->maxHARQ_Tx);
 }
 
-long flexran_get_beta_offset_ack_index(mid_t mod_id, mid_t ue_id)
+long flexran_get_beta_offset_ack_index(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.physicalConfigDedicated) return -1;
   if (!ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated) return -1;
   return ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_ACK_Index;
 }
 
-long flexran_get_beta_offset_ri_index(mid_t mod_id, mid_t ue_id)
+long flexran_get_beta_offset_ri_index(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.physicalConfigDedicated) return -1;
   if (!ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated) return -1;
   return ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_RI_Index;
 }
 
-long flexran_get_beta_offset_cqi_index(mid_t mod_id, mid_t ue_id)
+long flexran_get_beta_offset_cqi_index(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.physicalConfigDedicated) return -1;
   if (!ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated) return -1;
   return ue_context_p->ue_context.physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_CQI_Index;
 }
 
-BOOLEAN_t flexran_get_simultaneous_ack_nack_cqi(mid_t mod_id, mid_t ue_id)
+BOOLEAN_t flexran_get_simultaneous_ack_nack_cqi(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.physicalConfigDedicated) return -1;
   if (!ue_context_p->ue_context.physicalConfigDedicated->cqi_ReportConfig) return -1;
@@ -1027,33 +980,46 @@ BOOLEAN_t flexran_get_simultaneous_ack_nack_cqi(mid_t mod_id, mid_t ue_id)
   return ue_context_p->ue_context.physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.simultaneousAckNackAndCQI;
 }
 
-BOOLEAN_t flexran_get_ack_nack_simultaneous_trans(mid_t mod_id, mid_t ue_id, uint8_t cc_id)
+BOOLEAN_t flexran_get_ack_nack_simultaneous_trans(mid_t mod_id, uint8_t cc_id)
 {
   if (!rrc_is_present(mod_id)) return -1;
   if (!RC.rrc[mod_id]->carrier[cc_id].sib2) return -1;
   return RC.rrc[mod_id]->carrier[cc_id].sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.ackNackSRS_SimultaneousTransmission;
 }
 
-CQI_ReportModeAperiodic_t flexran_get_aperiodic_cqi_rep_mode(mid_t mod_id,mid_t ue_id)
+Protocol__FlexAperiodicCqiReportMode flexran_get_aperiodic_cqi_rep_mode(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.physicalConfigDedicated) return -1;
   if (!ue_context_p->ue_context.physicalConfigDedicated->cqi_ReportConfig) return -1;
-  return *ue_context_p->ue_context.physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic;
+  switch (*ue_context_p->ue_context.physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic) {
+  case CQI_ReportModeAperiodic_rm12:
+    return PROTOCOL__FLEX_APERIODIC_CQI_REPORT_MODE__FLACRM_RM12;
+  case CQI_ReportModeAperiodic_rm20:
+    return PROTOCOL__FLEX_APERIODIC_CQI_REPORT_MODE__FLACRM_RM20;
+  case CQI_ReportModeAperiodic_rm22:
+    return PROTOCOL__FLEX_APERIODIC_CQI_REPORT_MODE__FLACRM_RM22;
+  case CQI_ReportModeAperiodic_rm30:
+    return PROTOCOL__FLEX_APERIODIC_CQI_REPORT_MODE__FLACRM_RM30;
+  case CQI_ReportModeAperiodic_rm31:
+    return PROTOCOL__FLEX_APERIODIC_CQI_REPORT_MODE__FLACRM_RM31;
+  case CQI_ReportModeAperiodic_rm32_v1250:
+    return PROTOCOL__FLEX_APERIODIC_CQI_REPORT_MODE__FLACRM_RM32_v1250;
+  case CQI_ReportModeAperiodic_rm10_v1310:
+    return PROTOCOL__FLEX_APERIODIC_CQI_REPORT_MODE__FLACRM_RM10_v1310;
+  case CQI_ReportModeAperiodic_rm11_v1310:
+    return PROTOCOL__FLEX_APERIODIC_CQI_REPORT_MODE__FLACRM_RM11_v1310;
+  default:
+    return PROTOCOL__FLEX_APERIODIC_CQI_REPORT_MODE__FLACRM_NONE;
+  }
 }
 
-long flexran_get_tdd_ack_nack_feedback_mode(mid_t mod_id, mid_t ue_id)
+long flexran_get_tdd_ack_nack_feedback_mode(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.physicalConfigDedicated) return -1;
   if (!ue_context_p->ue_context.physicalConfigDedicated->pucch_ConfigDedicated) return -1;
@@ -1061,26 +1027,20 @@ long flexran_get_tdd_ack_nack_feedback_mode(mid_t mod_id, mid_t ue_id)
   return *(ue_context_p->ue_context.physicalConfigDedicated->pucch_ConfigDedicated->tdd_AckNackFeedbackMode);
 }
 
-long flexran_get_ack_nack_repetition_factor(mid_t mod_id, mid_t ue_id)
+long flexran_get_ack_nack_repetition_factor(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.physicalConfigDedicated) return -1;
   if (!ue_context_p->ue_context.physicalConfigDedicated->pucch_ConfigDedicated) return -1;
   return ue_context_p->ue_context.physicalConfigDedicated->pucch_ConfigDedicated->ackNackRepetition.choice.setup.repetitionFactor;
 }
 
-long flexran_get_extended_bsr_size(mid_t mod_id, mid_t ue_id)
+long flexran_get_extended_bsr_size(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.mac_MainConfig) return -1;
   if (!ue_context_p->ue_context.mac_MainConfig->ext2) return -1;
@@ -1088,13 +1048,10 @@ long flexran_get_extended_bsr_size(mid_t mod_id, mid_t ue_id)
   return *(ue_context_p->ue_context.mac_MainConfig->ext2->mac_MainConfig_v1020->extendedBSR_Sizes_r10);
 }
 
-int flexran_get_ue_transmission_antenna(mid_t mod_id, mid_t ue_id)
+int flexran_get_ue_transmission_antenna(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.physicalConfigDedicated) return -1;
   if (!ue_context_p->ue_context.physicalConfigDedicated->antennaInfo) return -1;
@@ -1108,16 +1065,12 @@ int flexran_get_ue_transmission_antenna(mid_t mod_id, mid_t ue_id)
   }
 }
 
-uint64_t flexran_get_ue_imsi(mid_t mod_id, mid_t ue_id)
+uint64_t flexran_get_ue_imsi(mid_t mod_id, rnti_t rnti)
 {
   uint64_t imsi;
   if (!rrc_is_present(mod_id)) return 0;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return 0;
-
   imsi  = ue_context_p->ue_context.imsi.digit15;
   imsi += ue_context_p->ue_context.imsi.digit14 * 10;              // pow(10, 1)
   imsi += ue_context_p->ue_context.imsi.digit13 * 100;             // pow(10, 2)
@@ -1371,50 +1324,38 @@ uint32_t flexran_get_pdcp_rx_oo(const mid_t mod_id,  const mid_t ue_id, const lc
 
 /******************** RRC *****************************/
 
-MeasId_t flexran_get_rrc_pcell_measid(mid_t mod_id, mid_t ue_id)
+MeasId_t flexran_get_rrc_pcell_measid(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.measResults) return -1;
   return ue_context_p->ue_context.measResults->measId;
 }
 
-float flexran_get_rrc_pcell_rsrp(mid_t mod_id, mid_t ue_id)
+float flexran_get_rrc_pcell_rsrp(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.measResults) return -1;
   return RSRP_meas_mapping[ue_context_p->ue_context.measResults->measResultPCell.rsrpResult];
 }
 
-float flexran_get_rrc_pcell_rsrq(mid_t mod_id, mid_t ue_id)
+float flexran_get_rrc_pcell_rsrq(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.measResults) return -1;
   return RSRQ_meas_mapping[ue_context_p->ue_context.measResults->measResultPCell.rsrqResult];
 }
 
 /*Number of neighbouring cells for specific UE*/
-int flexran_get_rrc_num_ncell(mid_t mod_id, mid_t ue_id)
+int flexran_get_rrc_num_ncell(mid_t mod_id, rnti_t rnti)
 {
   if (!rrc_is_present(mod_id)) return 0;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return 0;
   if (!ue_context_p->ue_context.measResults) return 0;
   if (!ue_context_p->ue_context.measResults->measResultNeighCells) return 0;
@@ -1422,13 +1363,10 @@ int flexran_get_rrc_num_ncell(mid_t mod_id, mid_t ue_id)
   return ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.count;
 }
 
-PhysCellId_t flexran_get_rrc_neigh_phy_cell_id(mid_t mod_id, mid_t ue_id, int cell_id)
+long flexran_get_rrc_neigh_phy_cell_id(mid_t mod_id, rnti_t rnti, long cell_id)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.measResults) return -1;
   if (!ue_context_p->ue_context.measResults->measResultNeighCells) return -1;
@@ -1437,13 +1375,10 @@ PhysCellId_t flexran_get_rrc_neigh_phy_cell_id(mid_t mod_id, mid_t ue_id, int ce
   return ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->physCellId;
 }
 
-float flexran_get_rrc_neigh_rsrp(mid_t mod_id, mid_t ue_id, int cell_id)
+float flexran_get_rrc_neigh_rsrp(mid_t mod_id, rnti_t rnti, long cell_id)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.measResults) return -1;
   if (!ue_context_p->ue_context.measResults->measResultNeighCells) return -1;
@@ -1453,13 +1388,10 @@ float flexran_get_rrc_neigh_rsrp(mid_t mod_id, mid_t ue_id, int cell_id)
   return RSRP_meas_mapping[*(ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[cell_id]->measResult.rsrpResult)];
 }
 
-float flexran_get_rrc_neigh_rsrq(mid_t mod_id, mid_t ue_id, int cell_id)
+float flexran_get_rrc_neigh_rsrq(mid_t mod_id, rnti_t rnti, long cell_id)
 {
   if (!rrc_is_present(mod_id)) return -1;
-
-  rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id);
   struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[mod_id], rnti);
-
   if (!ue_context_p) return -1;
   if (!ue_context_p->ue_context.measResults) return -1;
   if (!ue_context_p->ue_context.measResults->measResultNeighCells) return -1;
diff --git a/openair2/ENB_APP/flexran_agent_ran_api.h b/openair2/ENB_APP/flexran_agent_ran_api.h
index ada2cbd30c..766b9bc3b7 100644
--- a/openair2/ENB_APP/flexran_agent_ran_api.h
+++ b/openair2/ENB_APP/flexran_agent_ran_api.h
@@ -77,8 +77,8 @@ int flexran_get_mac_num_ues(mid_t mod_id);
  * dedicated bearers yet */
 int flexran_get_num_ue_lcs(mid_t mod_id, mid_t ue_id);
 
-/* Get the rnti of a UE with id ue_id */
-rnti_t flexran_get_ue_crnti(mid_t mod_id, mid_t ue_id);
+/* Get the rnti of a UE with id ue_id from MAC */
+rnti_t flexran_get_mac_ue_crnti(mid_t mod_id, mid_t ue_id);
 
 /* Get the RLC buffer status report in bytes of a ue for a designated
  * logical channel id */
@@ -318,13 +318,13 @@ int flexran_get_rrc_rnti_list(mid_t mod_id, rnti_t *list, int max_list);
 /* Get timer in subframes. Controls the synchronization
    status of the UE, not the actual timing 
    advance procedure. See TS 36.321 */
-TimeAlignmentTimer_t flexran_get_time_alignment_timer(mid_t mod_id, mid_t ue_id);
+TimeAlignmentTimer_t flexran_get_time_alignment_timer(mid_t mod_id, rnti_t rnti);
 
 /* Get measurement gap configuration. See TS 36.133 */
-Protocol__FlexMeasGapConfigPattern flexran_get_meas_gap_config(mid_t mod_id, mid_t ue_id);
+Protocol__FlexMeasGapConfigPattern flexran_get_meas_gap_config(mid_t mod_id, rnti_t rnti);
 
 /* Get measurement gap configuration offset if applicable */
-long flexran_get_meas_gap_config_offset(mid_t mod_id, mid_t ue_id);
+long flexran_get_meas_gap_config_offset(mid_t mod_id, rnti_t rnti);
 
 /* DL aggregated bit-rate of non-gbr bearer
    per UE. See TS 36.413 */
@@ -335,62 +335,62 @@ uint64_t flexran_get_ue_aggregated_max_bitrate_dl(mid_t mod_id, mid_t ue_id);
 uint64_t flexran_get_ue_aggregated_max_bitrate_ul(mid_t mod_id, mid_t ue_id);
 
 /* Only half-duplex support. FDD operation. Boolean value */
-int flexran_get_half_duplex(mid_t mod_id, mid_t ue_id);
+int flexran_get_half_duplex(mid_t mod_id, rnti_t rnti);
 
 /* Support of intra-subframe hopping.  Boolean value */
-int flexran_get_intra_sf_hopping(mid_t mod_id, mid_t ue_id);
+int flexran_get_intra_sf_hopping(mid_t mod_id, rnti_t rnti);
 
 /* UE support for type 2 hopping with n_sb>1 */
-int flexran_get_type2_sb_1(mid_t mod_id, mid_t ue_id);
+int flexran_get_type2_sb_1(mid_t mod_id, rnti_t rnti);
 
 /* Get the UE category */
-long flexran_get_ue_category(mid_t mod_id, mid_t ue_id);
+long flexran_get_ue_category(mid_t mod_id, rnti_t rnti);
 
 /* UE support for resource allocation type 1 */
-int flexran_get_res_alloc_type1(mid_t mod_id, mid_t ue_id);
+int flexran_get_res_alloc_type1(mid_t mod_id, rnti_t rnti);
 
 /* Get UE transmission mode */
-long flexran_get_ue_transmission_mode(mid_t mod_id, mid_t ue_id);
+long flexran_get_ue_transmission_mode(mid_t mod_id, rnti_t rnti);
 
 /* Boolean value. See TS 36.321 */
-BOOLEAN_t flexran_get_tti_bundling(mid_t mod_id, mid_t ue_id);
+BOOLEAN_t flexran_get_tti_bundling(mid_t mod_id, rnti_t rnti);
 
 /* The max HARQ retransmission for UL.
    See TS 36.321 */
-long flexran_get_maxHARQ_TX(mid_t mod_id, mid_t ue_id);
+long flexran_get_maxHARQ_TX(mid_t mod_id, rnti_t rnti);
 
 /* See TS 36.213 */
-long flexran_get_beta_offset_ack_index(mid_t mod_id, mid_t ue_id);
+long flexran_get_beta_offset_ack_index(mid_t mod_id, rnti_t rnti);
 
 /* See TS 36.213 */
-long flexran_get_beta_offset_ri_index(mid_t mod_id, mid_t ue_id);
+long flexran_get_beta_offset_ri_index(mid_t mod_id, rnti_t rnti);
 
 /* See TS 36.213 */
-long flexran_get_beta_offset_cqi_index(mid_t mod_id, mid_t ue_id);
+long flexran_get_beta_offset_cqi_index(mid_t mod_id, rnti_t rnti);
 
 /* Boolean. See TS36.213, Section 10.1 */
-BOOLEAN_t flexran_get_simultaneous_ack_nack_cqi(mid_t mod_id, mid_t ue_id);
+BOOLEAN_t flexran_get_simultaneous_ack_nack_cqi(mid_t mod_id, rnti_t rnti);
 
 /* Boolean. See TS 36.213, Section 8.2 */
-BOOLEAN_t flexran_get_ack_nack_simultaneous_trans(mid_t mod_id, mid_t ue_id, uint8_t cc_id);
+BOOLEAN_t flexran_get_ack_nack_simultaneous_trans(mid_t mod_id, uint8_t cc_id);
 
 /* Get aperiodic CQI report mode */
-CQI_ReportModeAperiodic_t flexran_get_aperiodic_cqi_rep_mode(mid_t mod_id,mid_t ue_id);
+Protocol__FlexAperiodicCqiReportMode flexran_get_aperiodic_cqi_rep_mode(mid_t mod_id, rnti_t rnti);
 
 /* Get ACK/NACK feedback mode. TDD only */
-long flexran_get_tdd_ack_nack_feedback_mode(mid_t mod_id, mid_t ue_id);
+long flexran_get_tdd_ack_nack_feedback_mode(mid_t mod_id, rnti_t rnti);
 
 /* See TS36.213, section 10.1 */
-long flexran_get_ack_nack_repetition_factor(mid_t mod_id, mid_t ue_id);
+long flexran_get_ack_nack_repetition_factor(mid_t mod_id, rnti_t rnti);
 
 /* Boolean. Extended buffer status report size */
-long flexran_get_extended_bsr_size(mid_t mod_id, mid_t ue_id);
+long flexran_get_extended_bsr_size(mid_t mod_id, rnti_t rnti);
 
 /* Get number of UE transmission antennas */
-int flexran_get_ue_transmission_antenna(mid_t mod_id, mid_t ue_id);
+int flexran_get_ue_transmission_antenna(mid_t mod_id, rnti_t rnti);
 
 /* Get the IMSI of UE */
-uint64_t flexran_get_ue_imsi(mid_t mod_id, mid_t ue_id);
+uint64_t flexran_get_ue_imsi(mid_t mod_id, rnti_t rnti);
 
 /* Get logical channel group of a channel with id lc_id */
 long flexran_get_lcg(mid_t mod_id, mid_t ue_id, mid_t lc_id);
@@ -429,7 +429,7 @@ void flexran_agent_set_operating_bandwidth(mid_t mod_id, uint8_t cc_id, uint8_t
 void flexran_agent_set_operating_frame_type(mid_t mod_id, uint8_t cc_id, lte_frame_type_t frame_type);
 
 /*RRC status flexRAN*/
-uint8_t flexran_get_rrc_status(mid_t mod_id, mid_t ue_id);
+uint8_t flexran_get_rrc_status(mid_t mod_id, rnti_t rnti);
 
 
 /***************************** PDCP ***********************/
@@ -491,33 +491,33 @@ uint32_t flexran_get_pdcp_rx_oo(const mid_t mod_id,  const mid_t ue_id, const lc
 
 /*********************RRC**********************/
 /*Get primary cell measuremeant id flexRAN*/
-MeasId_t flexran_get_rrc_pcell_measid(mid_t mod_id, mid_t ue_id);
+MeasId_t flexran_get_rrc_pcell_measid(mid_t mod_id, rnti_t rnti);
 
 /*Get primary cell RSRP measurement flexRAN*/  
-float flexran_get_rrc_pcell_rsrp(mid_t mod_id, mid_t ue_id);
+float flexran_get_rrc_pcell_rsrp(mid_t mod_id, rnti_t rnti);
 
 /*Get primary cell RSRQ measurement flexRAN*/
-float flexran_get_rrc_pcell_rsrq(mid_t mod_id, mid_t ue_id);
+float flexran_get_rrc_pcell_rsrq(mid_t mod_id, rnti_t rnti);
 
 /* Get RRC neighbouring measurement */
-int flexran_get_rrc_num_ncell(mid_t mod_id, mid_t ue_id);
+int flexran_get_rrc_num_ncell(mid_t mod_id, rnti_t rnti);
 
-/*Get physical cell id*/
-PhysCellId_t flexran_get_rrc_neigh_phy_cell_id(mid_t mod_id, mid_t ue_id, int cell_id);
+/* Get physical cell id */
+long flexran_get_rrc_neigh_phy_cell_id(mid_t mod_id, rnti_t rnti, long cell_id);
 
-/*Get RSRP of neighbouring Cell*/
-float flexran_get_rrc_neigh_rsrp(mid_t mod_id, mid_t ue_id, int cell_id);
+/* Get RSRP of neighbouring Cell */
+float flexran_get_rrc_neigh_rsrp(mid_t mod_id, rnti_t rnti, long cell_id);
 
-/*Get RSRQ of neighbouring Cell*/
-float flexran_get_rrc_neigh_rsrq(mid_t mod_id, mid_t ue_id, int cell_id);
+/* Get RSRQ of neighbouring Cell */
+float flexran_get_rrc_neigh_rsrq(mid_t mod_id, rnti_t rnti, long cell_id);
 
 /*Get MCC PLMN identity neighbouring Cell*/
 /* currently not implemented
-int flexran_get_rrc_neigh_plmn_mcc(mid_t mod_id, mid_t ue_id, int cell_id); */
+int flexran_get_rrc_neigh_plmn_mcc(mid_t mod_id, rnti_t rnti, int cell_id); */
 
 /*Get MNC PLMN identity neighbouring Cell*/
 /* currently not implemented
-int flexran_get_rrc_neigh_plmn_mnc(mid_t mod_id, mid_t ue_id, int cell_id); */
+int flexran_get_rrc_neigh_plmn_mnc(mid_t mod_id, rnti_t rnti, int cell_id); */
 
 /********************* general information *****************/
 /* get an ID for this BS (or part of a BS) */
-- 
GitLab