From 6f5219a6004230c846bc56b4d2999da795178b4a Mon Sep 17 00:00:00 2001
From: Lionel Gauthier <lionel.gauthier@eurecom.fr>
Date: Tue, 25 Feb 2014 17:53:10 +0000
Subject: [PATCH] Did not compiled for itti, stil problem with MBMS, see
 tomorrow

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5087 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
 openair2/COMMON/mac_rrc_primitives.h          |   2 +-
 openair2/COMMON/platform_types.h              |   2 +-
 openair2/LAYER2/MAC/eNB_scheduler.c           |  12 +-
 openair2/LAYER2/MAC/ue_procedures.c           | 150 +++++++++---------
 openair2/LAYER2/PDCP_v10.1.0/pdcp.c           |  66 ++++----
 openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c        |  24 ++-
 openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_entity.h |  23 +--
 openair2/LAYER2/RLC/TM/rlc_tm.c               |  68 ++++----
 openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_entity.h |  20 +--
 openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c        |  12 +-
 openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_entity.h |  57 ++++---
 openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c    |   2 +-
 openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.h    |   4 +-
 .../LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.c    |   4 +-
 .../LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.h    |   8 +-
 .../LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c     |   4 +-
 .../LAYER2/RLC/UM_v9.3.0/rlc_um_segment.h     |   8 +-
 openair2/RRC/LITE/L2_interface.c              |  76 ++++-----
 openair2/RRC/LITE/rrc_UE.c                    |  28 ++--
 targets/SIMU/USER/oaisim.c                    |  16 +-
 targets/SIMU/USER/oaisim_functions.c          |  33 ++--
 21 files changed, 322 insertions(+), 297 deletions(-)

diff --git a/openair2/COMMON/mac_rrc_primitives.h b/openair2/COMMON/mac_rrc_primitives.h
index 4e83ecc1195..7301ca27069 100644
--- a/openair2/COMMON/mac_rrc_primitives.h
+++ b/openair2/COMMON/mac_rrc_primitives.h
@@ -376,7 +376,7 @@ typedef struct{
 			    );
   unsigned int (*mac_rlc_data_req)(module_id_t, unsigned int, char*);
   void (*mac_rlc_data_ind)(module_id_t, logical_chan_id_t, char*, tb_size_t, num_tb_t, crc_t* );
-  mac_rlc_status_resp_t (*mac_rlc_status_ind)   (module_id_t, logical_chan_id_t, tb_size_t, num_tb_t);
+  mac_rlc_status_resp_t (*mac_rlc_status_ind)     (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, MBMS_flag_t MBMS_flagP, logical_chan_id_t channel_idP, tb_size_t tb_sizeP);
   signed int (*rrc_rlc_data_req)(module_id_t, rb_id_t, mui_t, confirm_t, sdu_size_t, char *);
   void (*rrc_rlc_register_rrc) (void (*rrc_data_indP)(module_id_t , rb_id_t , sdu_size_t , char* ),
 				void  (*rrc_data_confP) (module_id_t , rb_id_t , mui_t ) ) ;
diff --git a/openair2/COMMON/platform_types.h b/openair2/COMMON/platform_types.h
index cee057831a3..751d1914f9b 100755
--- a/openair2/COMMON/platform_types.h
+++ b/openair2/COMMON/platform_types.h
@@ -48,7 +48,7 @@ typedef int                traffic_type_t;
 typedef u32_t              mbms_session_id_t;
 typedef u16_t              mbms_service_id_t;
 typedef u16_t              rnti_t;
-
+typedef u32_t              rlc_buffer_occupancy_t;
 typedef signed int         rlc_op_status_t;
 
 typedef unsigned char      crc8_t;
diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c
index 1778fea3c0f..e16cdb4f938 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler.c
@@ -1453,7 +1453,7 @@ int schedule_MBMS(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP)
           module_idP,frameP,MTCH,TBS,
           TBS-header_len_mcch-header_len_msi-sdu_length_total-header_len_mtch);
 
-      rlc_status = mac_rlc_status_ind(module_idP,frameP,1,RLC_MBMS_YES,MTCH+ (maxDRB + 3) * MAX_MOBILES_PER_RG,
+      rlc_status = mac_rlc_status_ind(module_idP,0,frameP,1,RLC_MBMS_YES,MTCH+ (maxDRB + 3) * MAX_MOBILES_PER_RG,
           TBS-header_len_mcch-header_len_msi-sdu_length_total-header_len_mtch);
       //printf("frameP %d, subframeP %d,  rlc_status.bytes_in_buffer is %d\n",frameP,subframeP, rlc_status.bytes_in_buffer);
 
@@ -1461,7 +1461,7 @@ int schedule_MBMS(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP)
           LOG_I(MAC,"[eNB %d][MBMS USER-PLANE], Frame %d, MTCH->MCH, Requesting %d bytes from RLC (header len mtch %d)\n",
               module_idP,frameP,TBS-header_len_mcch-header_len_msi-sdu_length_total-header_len_mtch,header_len_mtch);
 
-          sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,frameP, 1, RLC_MBMS_YES,
+          sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, 0, frameP, 1, RLC_MBMS_YES,
               MTCH + (maxDRB + 3) * MAX_MOBILES_PER_RG,
               (char*)&mch_buffer[sdu_length_total]);
           //sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,frameP, RLC_MBMS_NO,  MTCH+(MAX_NUM_RB*(NUMBER_OF_UE_MAX+1)), (char*)&mch_buffer[sdu_length_total]);
@@ -1544,7 +1544,7 @@ int schedule_MBMS(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP)
       if (oai_emulation.info.opt_enabled)
         trace_pdu(1, (uint8_t *)eNB_mac_inst[module_idP].MCH_pdu.payload,
             TBS, module_idP, 6, 0xffff,  // M_RNTI = 6 in wirehsark
-            eNB_mac_inst[module_idP].subframeP,0,0);
+            eNB_mac_inst[module_idP].subframe,0,0);
       LOG_D(OPT,"[eNB %d][MCH] Frame %d : MAC PDU with size %d\n",
           module_idP, frameP, TBS);
 #endif
@@ -4324,7 +4324,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,u8 cooperation_flag, frame
           case RRC_MAC_BCCH_DATA_REQ:
             LOG_D(MAC, "Received %s from %s: instance %d, frameP %d, eNB_index %d\n",
                 msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance,
-                RRC_MAC_BCCH_DATA_REQ (msg_p).frameP, RRC_MAC_BCCH_DATA_REQ (msg_p).enb_index);
+                RRC_MAC_BCCH_DATA_REQ (msg_p).frame, RRC_MAC_BCCH_DATA_REQ (msg_p).enb_index);
 
             // TODO process BCCH data req.
             break;
@@ -4332,7 +4332,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,u8 cooperation_flag, frame
           case RRC_MAC_CCCH_DATA_REQ:
             LOG_D(MAC, "Received %s from %s: instance %d, frameP %d, eNB_index %d\n",
                 msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance,
-                RRC_MAC_CCCH_DATA_REQ (msg_p).frameP, RRC_MAC_CCCH_DATA_REQ (msg_p).enb_index);
+                RRC_MAC_CCCH_DATA_REQ (msg_p).frame, RRC_MAC_CCCH_DATA_REQ (msg_p).enb_index);
 
             // TODO process CCCH data req.
             break;
@@ -4341,7 +4341,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,u8 cooperation_flag, frame
           case RRC_MAC_MCCH_DATA_REQ:
             LOG_D(MAC, "Received %s from %s: instance %d, frameP %d, eNB_index %d, mbsfn_sync_area %d\n",
                 msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance,
-                RRC_MAC_MCCH_DATA_REQ (msg_p).frameP, RRC_MAC_MCCH_DATA_REQ (msg_p).enb_index, RRC_MAC_MCCH_DATA_REQ (msg_p).mbsfn_sync_area);
+                RRC_MAC_MCCH_DATA_REQ (msg_p).frame, RRC_MAC_MCCH_DATA_REQ (msg_p).enb_index, RRC_MAC_MCCH_DATA_REQ (msg_p).mbsfn_sync_area);
 
             // TODO process MCCH data req.
             break;
diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c
index 910cd145c6c..adfc54c2575 100644
--- a/openair2/LAYER2/MAC/ue_procedures.c
+++ b/openair2/LAYER2/MAC/ue_procedures.c
@@ -201,7 +201,7 @@ unsigned char *parse_header(unsigned char *mac_header,
   return(mac_header_ptr);
 }
 
-u32 ue_get_SR(module_id_t module_idP,frame_t frame,u8 eNB_id,u16 rnti, sub_frame_t subframe) {
+u32 ue_get_SR(module_id_t module_idP,frame_t frameP,u8 eNB_id,u16 rnti, sub_frame_t subframe) {
 
   // no UL-SCH resources available for this tti && UE has a valid PUCCH resources for SR configuration for this tti
   //  int MGL=6;// measurement gap length in ms
@@ -213,7 +213,7 @@ u32 ue_get_SR(module_id_t module_idP,frame_t frame,u8 eNB_id,u16 rnti, sub_frame
 
   // determin the measurement gap
   LOG_D(MAC,"[UE %d][SR %x] Frame %d subframe %d PHY asks for SR (SR_COUNTER/dsr_TransMax %d/%d), SR_pending %d\n",
-      module_idP,rnti,frame,subframe,
+      module_idP,rnti,frameP,subframe,
       UE_mac_inst[module_idP].scheduling_info.SR_COUNTER,
       (1<<(2+UE_mac_inst[module_idP].physicalConfigDedicated->schedulingRequestConfig->choice.setup.dsr_TransMax)),
       UE_mac_inst[module_idP].scheduling_info.SR_pending);
@@ -230,7 +230,7 @@ u32 ue_get_SR(module_id_t module_idP,frame_t frame,u8 eNB_id,u16 rnti, sub_frame
       }
       T=MGRP/10;
       //check the measurement gap and sr prohibit timer
-      if ((subframe ==  gapOffset %10) && ((frame %T) == (floor(gapOffset/10)))
+      if ((subframe ==  gapOffset %10) && ((frameP %T) == (floor(gapOffset/10)))
           && (UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running =0)){
           UE_mac_inst[module_idP].scheduling_info.SR_pending=1;
           return(0);
@@ -248,7 +248,7 @@ u32 ue_get_SR(module_id_t module_idP,frame_t frame,u8 eNB_id,u16 rnti, sub_frame
       } else
         UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running=0;
       LOG_D(MAC,"[UE %d][SR %x] Frame %d subframe %d send SR_indication (SR_COUNTER/dsr_TransMax %d/%d), SR_pending %d\n",
-          module_idP,rnti,frame,subframe,
+          module_idP,rnti,frameP,subframe,
           UE_mac_inst[module_idP].scheduling_info.SR_COUNTER,
           (1<<(2+UE_mac_inst[module_idP].physicalConfigDedicated->schedulingRequestConfig->choice.setup.dsr_TransMax)),
           UE_mac_inst[module_idP].scheduling_info.SR_pending);
@@ -289,7 +289,7 @@ void ue_send_sdu(module_id_t module_idP,frame_t frameP,u8 *sdu,u16 sdu_len,u8 eN
 
 #ifdef DEBUG_HEADER_PARSING
   LOG_D(MAC,"[UE %d] ue_send_sdu : Frame %d eNB_index %d : num_ce %d num_sdu %d\n",module_idP,
-      frame,eNB_index,num_ce,num_sdu);
+      frameP,eNB_index,num_ce,num_sdu);
 #endif
 
 #if defined(ENABLE_MAC_PAYLOAD_DEBUG)
@@ -305,7 +305,7 @@ void ue_send_sdu(module_id_t module_idP,frame_t frameP,u8 *sdu,u16 sdu_len,u8 eN
       case UE_CONT_RES:
 
         LOG_I(MAC,"[UE %d][RAPROC] Frame %d : received contention resolution msg: %x.%x.%x.%x.%x.%x, Terminating RA procedure\n",
-            module_idP,frame,payload_ptr[0],payload_ptr[1],payload_ptr[2],payload_ptr[3],payload_ptr[4],payload_ptr[5]);
+            module_idP,frameP,payload_ptr[0],payload_ptr[1],payload_ptr[2],payload_ptr[3],payload_ptr[4],payload_ptr[5]);
         if (UE_mac_inst[module_idP].RA_active == 1) {
             LOG_I(MAC,"[UE %d][RAPROC] Frame %d : Clearing RA_active flag\n");
             UE_mac_inst[module_idP].RA_active=0;
@@ -348,7 +348,7 @@ void ue_send_sdu(module_id_t module_idP,frame_t frameP,u8 *sdu,u16 sdu_len,u8 eN
 #endif
       if (rx_lcids[i] == CCCH) {
 
-          LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-CCCH, RRC message (eNB %d, %d bytes)\n",module_idP,frame, eNB_index, rx_lengths[i]);
+          LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-CCCH, RRC message (eNB %d, %d bytes)\n",module_idP,frameP, eNB_index, rx_lengths[i]);
 
 #if defined(ENABLE_MAC_PAYLOAD_DEBUG)
           int j;
@@ -357,16 +357,16 @@ void ue_send_sdu(module_id_t module_idP,frame_t frameP,u8 *sdu,u16 sdu_len,u8 eN
           LOG_T(MAC,"\n");
 #endif      
           mac_rrc_data_ind(module_idP,
-              frame,
+              frameP,
               CCCH,
               (u8 *)payload_ptr,rx_lengths[i],0,eNB_index,0);
 
       }
       else if (rx_lcids[i] == DCCH) {
-          LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DCCH%d, RRC message (eNB %d, %d bytes)\n", module_idP, frame, rx_lcids[i],eNB_index,rx_lengths[i]);
+          LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DCCH%d, RRC message (eNB %d, %d bytes)\n", module_idP, frameP, rx_lcids[i],eNB_index,rx_lengths[i]);
           mac_rlc_data_ind(eNB_index,
               module_idP,
-              frame,
+              frameP,
               0,
               RLC_MBMS_NO,
               DCCH,
@@ -376,10 +376,10 @@ void ue_send_sdu(module_id_t module_idP,frame_t frameP,u8 *sdu,u16 sdu_len,u8 eN
               NULL);
       }
       else if (rx_lcids[i] == DCCH1) {
-          LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DCCH%d, RRC message (eNB %d, %d bytes)\n", module_idP, frame, rx_lcids[i], eNB_index,rx_lengths[i]);
+          LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DCCH%d, RRC message (eNB %d, %d bytes)\n", module_idP, frameP, rx_lcids[i], eNB_index,rx_lengths[i]);
           mac_rlc_data_ind(eNB_index,
               module_idP,
-              frame,
+              frameP,
               0,
               RLC_MBMS_NO,
               DCCH1,
@@ -389,7 +389,7 @@ void ue_send_sdu(module_id_t module_idP,frame_t frameP,u8 *sdu,u16 sdu_len,u8 eN
               NULL);
       }
       else if (rx_lcids[i] == DTCH) {
-          LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DTCH%d (eNB %d, %d bytes)\n", module_idP, frame,rx_lcids[i], eNB_index,rx_lengths[i]);
+          LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DTCH%d (eNB %d, %d bytes)\n", module_idP, frameP,rx_lcids[i], eNB_index,rx_lengths[i]);
 
 #if defined(ENABLE_MAC_PAYLOAD_DEBUG)
           int j;
@@ -400,7 +400,7 @@ void ue_send_sdu(module_id_t module_idP,frame_t frameP,u8 *sdu,u16 sdu_len,u8 eN
 
           mac_rlc_data_ind(eNB_index,
               module_idP,
-              frame,
+              frameP,
               0,
               RLC_MBMS_NO,
               DTCH,
@@ -418,10 +418,10 @@ void ue_decode_si(module_id_t module_idP,frame_t frameP, u8 eNB_index, void *pdu
 
   vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_SI, VCD_FUNCTION_IN);
 
-  LOG_D(MAC,"[UE %d] Frame %d Sending SI to RRC (LCID Id %d,len %d)\n",module_idP,frame,BCCH,len);
+  LOG_D(MAC,"[UE %d] Frame %d Sending SI to RRC (LCID Id %d,len %d)\n",module_idP,frameP,BCCH,len);
 
   mac_rrc_data_ind(module_idP,
-      frame,
+      frameP,
       BCCH,
       (u8 *)pdu,
       len,
@@ -485,7 +485,7 @@ void ue_send_mch_sdu(module_id_t module_idP, frame_t frameP, u8 *sdu, u16 sdu_le
   unsigned short rx_lengths[NB_RB_MAX];
 
   //  vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_MCH_SDU, VCD_FUNCTION_IN);
-  LOG_D(MAC,"[UE %d] Frame %d : process the mch PDU for sync area %d \n",module_idP,frame, sync_area);
+  LOG_D(MAC,"[UE %d] Frame %d : process the mch PDU for sync area %d \n",module_idP,frameP, sync_area);
   LOG_D(MAC,"[UE %d] sdu: %x.%x\n", module_idP,sdu[0], sdu[1]);
   LOG_D(MAC,"[UE %d] parse_mch_header, demultiplex\n",module_idP);
 
@@ -495,7 +495,7 @@ void ue_send_mch_sdu(module_id_t module_idP, frame_t frameP, u8 *sdu, u16 sdu_le
   for (i=0; i<num_sdu; i++) {
       if (rx_lcids[i] == MCH_SCHDL_INFO) {
           if (UE_mac_inst[module_idP].mcch_status==1) {
-              LOG_I(MAC,"[UE %d] Frame %d : MCH->MSI for sync area %d (eNB %d, %d bytes)\n",module_idP,frame, sync_area, eNB_index, rx_lengths[i]);
+              LOG_I(MAC,"[UE %d] Frame %d : MCH->MSI for sync area %d (eNB %d, %d bytes)\n",module_idP,frameP, sync_area, eNB_index, rx_lengths[i]);
               // ??store necessary scheduling info to ue_mac_inst in order to
               // calculate exact position of interested service (for the complex case has >1 mtch)
               // set msi_status to 1
@@ -503,20 +503,20 @@ void ue_send_mch_sdu(module_id_t module_idP, frame_t frameP, u8 *sdu, u16 sdu_le
           }
       }
       else if (rx_lcids[i] == MCCH_LCHANID) {
-          LOG_I(MAC,"[UE %d] Frame %d : SDU %d MCH->MCCH for sync area %d (eNB %d, %d bytes)\n",module_idP,frame, i, sync_area, eNB_index, rx_lengths[i]);
+          LOG_I(MAC,"[UE %d] Frame %d : SDU %d MCH->MCCH for sync area %d (eNB %d, %d bytes)\n",module_idP,frameP, i, sync_area, eNB_index, rx_lengths[i]);
           mac_rrc_data_ind(module_idP,
-              frame,
+              frameP,
               MCCH,
               payload_ptr, rx_lengths[i], 0, eNB_index, sync_area);
       }
       else if (rx_lcids[i] == MTCH) {
           if (UE_mac_inst[module_idP].msi_status==1) {
-              LOG_I(MAC,"[UE %d] Frame %d : MCH->MTCH for sync area %d (eNB %d, %d bytes)\n",module_idP,frame, sync_area, eNB_index, rx_lengths[i]);
+              LOG_I(MAC,"[UE %d] Frame %d : MCH->MTCH for sync area %d (eNB %d, %d bytes)\n",module_idP,frameP, sync_area, eNB_index, rx_lengths[i]);
 
               mac_rlc_data_ind(
-                  0
+                  0,
                   module_idP,
-                  frame,
+                  frameP,
                   0,
                   RLC_MBMS_YES,
                   MTCH + (maxDRB + 3),
@@ -527,7 +527,7 @@ void ue_send_mch_sdu(module_id_t module_idP, frame_t frameP, u8 *sdu, u16 sdu_le
 
           }
       } else {
-          LOG_W(MAC,"[UE %d] Frame %d : unknown sdu %d mcch status %d eNB %d \n",module_idP,frame,rx_lengths[i],
+          LOG_W(MAC,"[UE %d] Frame %d : unknown sdu %d mcch status %d eNB %d \n",module_idP,frameP,rx_lengths[i],
               UE_mac_inst[module_idP].mcch_status, eNB_index);
       }
 
@@ -551,7 +551,7 @@ s8 ue_get_mbsfn_sf_alloction (module_id_t module_idP, u8 mbsfn_sync_area, unsign
   }
 }
 
-int ue_query_mch(module_id_t module_idP, uint32_t frame, uint32_t subframe, uint8_t eNB_index,uint8_t *sync_area, uint8_t *mcch_active) {
+int ue_query_mch(module_id_t module_idP, uint32_t frameP, uint32_t subframe, uint8_t eNB_index,uint8_t *sync_area, uint8_t *mcch_active) {
 
   int i=0, j=0, ii=0, msi_pos=0, mcch_mcs = - 1;
   int mcch_flag=0, mtch_flag=0, msi_flag=0;
@@ -574,7 +574,7 @@ int ue_query_mch(module_id_t module_idP, uint32_t frame, uint32_t subframe, uint
       mcch_period = 32<<(UE_mac_inst[module_idP].mbsfn_AreaInfo[0]->mcch_Config_r9.mcch_RepetitionPeriod_r9);
 
       LOG_D(MAC,"[UE %d] Frame %d subframe %d: Checking MBSFN Sync Area %d/%d with SF allocation %d/%d for MCCH and MTCH (mbsfn period %d, mcch period %d,mac sched period (%d,%d))\n",
-          module_idP,frame, subframe,i,UE_mac_inst[module_idP].num_active_mbsfn_area,
+          module_idP,frameP, subframe,i,UE_mac_inst[module_idP].num_active_mbsfn_area,
           j,UE_mac_inst[module_idP].num_sf_allocation_pattern,mbsfn_period,mcch_period,
           mch_scheduling_period,UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->radioframeAllocationOffset);
 
@@ -594,12 +594,12 @@ int ue_query_mch(module_id_t module_idP, uint32_t frame, uint32_t subframe, uint
         break;
       }
 
-      if (frame % mbsfn_period == UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->radioframeAllocationOffset){ // MBSFN frame
-          if (UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.present == MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame){// one-frame format
+      if (frameP % mbsfn_period == UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->radioframeAllocationOffset){ // MBSFN frameP
+          if (UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.present == MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame){// one-frameP format
 
               if (UE_mac_inst[module_idP].pmch_Config[0]) {
                   //  Find the first subframe in this MCH to transmit MSI
-                  if (frame % mch_scheduling_period == UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->radioframeAllocationOffset ) {
+                  if (frameP % mch_scheduling_period == UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->radioframeAllocationOffset ) {
                       while (ii == 0) {
                           ii = UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & (0x80>>msi_pos);
                           msi_pos++;
@@ -614,7 +614,7 @@ int ue_query_mch(module_id_t module_idP, uint32_t frame, uint32_t subframe, uint
                     if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) {
                         if (msi_pos == 1)
                           msi_flag = 1;
-                        if ( (frame % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
+                        if ( (frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
                             ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) )
                           mcch_flag = 1;
                         mtch_flag = 1;
@@ -627,7 +627,7 @@ int ue_query_mch(module_id_t module_idP, uint32_t frame, uint32_t subframe, uint
                     if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) {
                         if (msi_pos == 2)
                           msi_flag = 1;
-                        if ( (frame % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
+                        if ( (frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
                             ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) )
                           mcch_flag = 1;
                         mtch_flag = 1;
@@ -640,7 +640,7 @@ int ue_query_mch(module_id_t module_idP, uint32_t frame, uint32_t subframe, uint
                     if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) {
                         if (msi_pos == 1)
                           msi_flag = 1;
-                        if ( (frame % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
+                        if ( (frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
                             ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) )
                           mcch_flag = 1;
                         mtch_flag = 1;
@@ -650,7 +650,7 @@ int ue_query_mch(module_id_t module_idP, uint32_t frame, uint32_t subframe, uint
                     if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) {
                         if (msi_pos == 3)
                           msi_flag = 1;
-                        if ((frame % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
+                        if ((frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
                             ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) )
                           mcch_flag = 1;
                         mtch_flag = 1;
@@ -663,7 +663,7 @@ int ue_query_mch(module_id_t module_idP, uint32_t frame, uint32_t subframe, uint
                     if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) {
                         if (msi_pos == 2)
                           msi_flag = 1;
-                        if ((frame % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
+                        if ((frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
                             ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) )
                           mcch_flag = 1;
                         mtch_flag = 1;
@@ -676,7 +676,7 @@ int ue_query_mch(module_id_t module_idP, uint32_t frame, uint32_t subframe, uint
                     if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) {
                         if (msi_pos == 4)
                           msi_flag = 1;
-                        if ((frame % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
+                        if ((frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
                             ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) )
                           mcch_flag = 1;
                         mtch_flag = 1;
@@ -689,7 +689,7 @@ int ue_query_mch(module_id_t module_idP, uint32_t frame, uint32_t subframe, uint
                     if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) {
                         if (msi_pos == 3)
                           msi_flag = 1;
-                        if ((frame % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
+                        if ((frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
                             ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) )
                           mcch_flag = 1;
                         mtch_flag = 1;
@@ -699,7 +699,7 @@ int ue_query_mch(module_id_t module_idP, uint32_t frame, uint32_t subframe, uint
                     if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) {
                         if (msi_pos == 5)
                           msi_flag = 1;
-                        if ((frame % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
+                        if ((frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
                             ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) )
                           mcch_flag = 1;
                         mtch_flag = 1;
@@ -712,7 +712,7 @@ int ue_query_mch(module_id_t module_idP, uint32_t frame, uint32_t subframe, uint
                     if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) {
                         if (msi_pos == 4)
                           msi_flag = 1;
-                        if ( (frame % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
+                        if ( (frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
                             ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) )
                           mcch_flag = 1;
                         mtch_flag = 1;
@@ -722,7 +722,7 @@ int ue_query_mch(module_id_t module_idP, uint32_t frame, uint32_t subframe, uint
                     if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) {
                         if (msi_pos == 6)
                           msi_flag = 1;
-                        if ((frame % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
+                        if ((frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
                             ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) )
                           mcch_flag = 1;
                         mtch_flag = 1;
@@ -735,7 +735,7 @@ int ue_query_mch(module_id_t module_idP, uint32_t frame, uint32_t subframe, uint
                     if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) {
                         if (msi_pos == 5)
                           msi_flag = 1;
-                        if ((frame % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
+                        if ((frameP % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) &&
                             ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) )
                           mcch_flag = 1;
                         mtch_flag = 1;
@@ -746,13 +746,13 @@ int ue_query_mch(module_id_t module_idP, uint32_t frame, uint32_t subframe, uint
               // sf allocation is non-overlapping
               if ((msi_flag==1) || (mcch_flag==1) || (mtch_flag==1)){
                   LOG_D(MAC,"[UE %d] Frame %d Subframe %d: sync area %d SF alloc %d: msi flag %d, mcch flag %d, mtch flag %d\n",
-                      module_idP, frame, subframe,i,j,msi_flag,mcch_flag,mtch_flag);
+                      module_idP, frameP, subframe,i,j,msi_flag,mcch_flag,mtch_flag);
 
                   *sync_area=i;
                   break;
               }
           }
-          else {// four-frame format
+          else {// four-frameP format
           }
       }
   } // end of for
@@ -1012,7 +1012,7 @@ unsigned char generate_ulsch_header(u8 *mac_header,
 
 }
 
-void ue_get_sdu(module_id_t module_idP,frame_t frame,sub_frame_t subframe, u8 eNB_index,u8 *ulsch_buffer,u16 buflen, u8 *access_mode) {
+void ue_get_sdu(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, u8 eNB_index,u8 *ulsch_buffer,u16 buflen, u8 *access_mode) {
 
   mac_rlc_status_resp_t rlc_status;
   u8 dcch_header_len=0,dcch1_header_len=0,dtch_header_len=0;
@@ -1039,16 +1039,16 @@ void ue_get_sdu(module_id_t module_idP,frame_t frame,sub_frame_t subframe, u8 eN
 
 #ifdef CBA
   if (*access_mode==CBA_ACCESS){
-      LOG_D(MAC,"[UE %d] frame %d subframe %d try CBA transmission\n",
-          module_idP, frame, subframe);
+      LOG_D(MAC,"[UE %d] frameP %d subframe %d try CBA transmission\n",
+          module_idP, frameP, subframe);
       //if (UE_mac_inst[module_idP].scheduling_info.LCID_status[DTCH] == LCID_EMPTY)
-      if (use_cba_access(module_idP,frame,subframe,eNB_index)==0){
+      if (use_cba_access(module_idP,frameP,subframe,eNB_index)==0){
           *access_mode=POSTPONED_ACCESS;
           vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT);
           return;
       }
-      LOG_D(MAC,"[UE %d] frame %d subframe %d CBA transmission oppurtunity, tbs %d\n",
-          module_idP, frame, subframe,buflen);
+      LOG_D(MAC,"[UE %d] frameP %d subframe %d CBA transmission oppurtunity, tbs %d\n",
+          module_idP, frameP, subframe,buflen);
   }
 #endif
   dcch_header_len=2;//sizeof(SCH_SUBHEADER_SHORT);
@@ -1080,14 +1080,14 @@ void ue_get_sdu(module_id_t module_idP,frame_t frame,sub_frame_t subframe, u8 eN
 
   if (UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH] == LCID_NOT_EMPTY) {
 
-      rlc_status = mac_rlc_status_ind(0, module_idP,frame,0,RLC_MBMS_NO,
+      rlc_status = mac_rlc_status_ind(0, module_idP,frameP,0,RLC_MBMS_NO,
           DCCH,
           (buflen-dcch_header_len-bsr_len-phr_len));
       LOG_D(MAC, "[UE %d] Frame %d : UL-DCCH -> ULSCH, RRC message has %d bytes to "
           "send (Transport Block size %d, mac header len %d)\n",
-          module_idP,frame, rlc_status.bytes_in_buffer,buflen,dcch_header_len);
+          module_idP,frameP, rlc_status.bytes_in_buffer,buflen,dcch_header_len);
 
-      sdu_lengths[0] += mac_rlc_data_req(0, module_idP,frame,0, RLC_MBMS_NO,
+      sdu_lengths[0] += mac_rlc_data_req(0, module_idP,frameP,0, RLC_MBMS_NO,
           DCCH,
           (char *)&ulsch_buff[sdu_lengths[0]]);
 
@@ -1095,7 +1095,7 @@ void ue_get_sdu(module_id_t module_idP,frame_t frame,sub_frame_t subframe, u8 eN
       sdu_lcids[0] = DCCH;
       LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH\n",module_idP,sdu_lengths[0]);
       num_sdus = 1;
-      update_bsr(module_idP, frame, DCCH, UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]);
+      update_bsr(module_idP, frameP, DCCH, UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]);
       //header_len +=2;
   }
   else {
@@ -1106,22 +1106,22 @@ void ue_get_sdu(module_id_t module_idP,frame_t frame,sub_frame_t subframe, u8 eN
   // DCCH1
   if (UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH1] == LCID_NOT_EMPTY) {
 
-      rlc_status = mac_rlc_status_ind(0, module_idP,frame,0,RLC_MBMS_NO,
+      rlc_status = mac_rlc_status_ind(0, module_idP,frameP,0,RLC_MBMS_NO,
           DCCH1,
           (buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-sdu_length_total));
 
       LOG_D(MAC,"[UE %d] Frame %d : UL-DCCH1 -> ULSCH, RRC message has %d bytes to"
           " send (Transport Block size %d, mac header len %d)\n",
-          module_idP,frame, rlc_status.bytes_in_buffer,buflen,dcch1_header_len);
+          module_idP,frameP, rlc_status.bytes_in_buffer,buflen,dcch1_header_len);
 
-      sdu_lengths[num_sdus] = mac_rlc_data_req(0, module_idP,frame,0,RLC_MBMS_NO,
+      sdu_lengths[num_sdus] = mac_rlc_data_req(0, module_idP,frameP,0,RLC_MBMS_NO,
           DCCH1,
           (char *)&ulsch_buff[sdu_lengths[0]]);
       sdu_length_total += sdu_lengths[num_sdus];
       sdu_lcids[num_sdus] = DCCH1;
       LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH1\n",module_idP,sdu_lengths[num_sdus]);
       num_sdus++;
-      //update_bsr(module_idP, frame, DCCH1);
+      //update_bsr(module_idP, frameP, DCCH1);
       //dcch_header_len +=2; // include dcch1
   }
   else {
@@ -1140,15 +1140,15 @@ void ue_get_sdu(module_id_t module_idP,frame_t frame,sub_frame_t subframe, u8 eN
     else 
       dtch_header_len = 2;//sizeof(SCH_SUBHEADER_SHORT);
        */
-      rlc_status = mac_rlc_status_ind(0, module_idP,frame,0,RLC_MBMS_NO,
+      rlc_status = mac_rlc_status_ind(0, module_idP,frameP,0,RLC_MBMS_NO,
           DTCH,
           buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total);
 
       LOG_D(MAC,"[UE %d] Frame %d : UL-DTCH -> ULSCH, %d bytes to send (Transport Block size %d, mac header len %d, BSR byte[DTCH] %d)\n",
-          module_idP,frame, rlc_status.bytes_in_buffer,buflen,dtch_header_len,
+          module_idP,frameP, rlc_status.bytes_in_buffer,buflen,dtch_header_len,
           UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DTCH]);
 
-      sdu_lengths[num_sdus] = mac_rlc_data_req(0, module_idP,frame, 0, RLC_MBMS_NO,
+      sdu_lengths[num_sdus] = mac_rlc_data_req(0, module_idP,frameP, 0, RLC_MBMS_NO,
           DTCH,
           (char *)&ulsch_buff[sdu_length_total]);
 
@@ -1158,7 +1158,7 @@ void ue_get_sdu(module_id_t module_idP,frame_t frame,sub_frame_t subframe, u8 eN
       sdu_lcids[num_sdus] = DTCH;
       sdu_length_total += sdu_lengths[num_sdus];
       num_sdus++;
-      UE_mac_inst[module_idP].ul_active = update_bsr(module_idP, frame, DTCH, UE_mac_inst[module_idP].scheduling_info.LCGID[DTCH]);
+      UE_mac_inst[module_idP].ul_active = update_bsr(module_idP, frameP, DTCH, UE_mac_inst[module_idP].scheduling_info.LCGID[DTCH]);
   }
   else { // no rlc pdu : generate the dummy header
       dtch_header_len = 0;
@@ -1175,7 +1175,7 @@ void ue_get_sdu(module_id_t module_idP,frame_t frame,sub_frame_t subframe, u8 eN
       bsr_l->Buffer_size1 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1];
       bsr_l->Buffer_size2 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2];
       bsr_l->Buffer_size3 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3];
-      LOG_D(MAC, "[UE %d] Frame %d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", module_idP,frame,
+      LOG_D(MAC, "[UE %d] Frame %d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", module_idP,frameP,
           UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0],
           UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1],
           UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2],
@@ -1185,7 +1185,7 @@ void ue_get_sdu(module_id_t module_idP,frame_t frame,sub_frame_t subframe, u8 eN
       bsr_s->LCGID = lcgid;
       bsr_s->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcgid];
       LOG_D(MAC,"[UE %d] Frame %d report SHORT BSR with level %d for LCGID %d\n",
-          module_idP, frame, UE_mac_inst[module_idP].scheduling_info.BSR[lcgid],lcgid);
+          module_idP, frameP, UE_mac_inst[module_idP].scheduling_info.BSR[lcgid],lcgid);
   } else {
       bsr_s = NULL;
       bsr_l = NULL;
@@ -1196,12 +1196,12 @@ void ue_get_sdu(module_id_t module_idP,frame_t frame,sub_frame_t subframe, u8 eN
       phr_p->PH = get_phr_mapping(module_idP,eNB_index);
       phr_p->R  = 0;
       LOG_D(MAC,"[UE %d] Frame %d report PHR with mapping (%d->%d) for LCID %d\n",
-          module_idP,frame, mac_xface->get_PHR(module_idP,eNB_index), phr_p->PH,POWER_HEADROOM);
+          module_idP,frameP, mac_xface->get_PHR(module_idP,eNB_index), phr_p->PH,POWER_HEADROOM);
       update_phr(module_idP);
   }else
     phr_p=NULL;
 
-  LOG_T(MAC,"[UE %d] Frame %d: bsr s %p bsr_l %p, phr_p %p\n",  module_idP,frame,bsr_s, bsr_l, phr_p);
+  LOG_T(MAC,"[UE %d] Frame %d: bsr s %p bsr_l %p, phr_p %p\n",  module_idP,frameP,bsr_s, bsr_l, phr_p);
 
   // adjust the header length 
   dcch_header_len_tmp = dcch_header_len;
@@ -1255,7 +1255,7 @@ void ue_get_sdu(module_id_t module_idP,frame_t frame,sub_frame_t subframe, u8 eN
   if (oai_emulation.info.opt_enabled)
     trace_pdu(0, ulsch_buffer, buflen, module_idP, 3, UE_mac_inst[module_idP].crnti, subframe, 0, 0);
   LOG_D(OPT,"[UE %d][ULSCH] Frame %d trace pdu for rnti %x  with size %d\n", 
-      module_idP, frame, UE_mac_inst[module_idP].crnti, buflen);
+      module_idP, frameP, UE_mac_inst[module_idP].crnti, buflen);
 #endif
 
   LOG_D(MAC,"[UE %d][SR] Gave SDU to PHY, clearing any scheduling request\n",
@@ -1306,7 +1306,7 @@ UE_L2_STATE_t ue_scheduler(module_id_t module_idP,frame_t frameP, sub_frame_t su
 
           switch (ITTI_MSG_ID(msg_p)) {
           case RRC_MAC_CCCH_DATA_REQ:
-            LOG_I(MAC, "Received %s from %s: instance %d, frame %d, eNB_index %d\n",
+            LOG_I(MAC, "Received %s from %s: instance %d, frameP %d, eNB_index %d\n",
                 msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance,
                 RRC_MAC_CCCH_DATA_REQ (msg_p).frame, RRC_MAC_CCCH_DATA_REQ (msg_p).enb_index);
 
@@ -1325,11 +1325,11 @@ UE_L2_STATE_t ue_scheduler(module_id_t module_idP,frame_t frameP, sub_frame_t su
   } while(msg_p != NULL);
 #endif
 
-  //Mac_rlc_xface->frame=frame;
-  //Rrc_xface->Frame_index=Mac_rlc_xface->frame;
+  //Mac_rlc_xface->frameP=frameP;
+  //Rrc_xface->Frame_index=Mac_rlc_xface->frameP;
   //if (subframe%5 == 0)
 #ifdef EXMIMO
-  pdcp_run(frame, 0, module_idP, eNB_index);
+  pdcp_run(frameP, 0, module_idP, eNB_index);
   /*
   ret = pthread_mutex_trylock (&pdcp_mutex);
   if (ret != 0) {
@@ -1402,7 +1402,7 @@ UE_L2_STATE_t ue_scheduler(module_id_t module_idP,frame_t frameP, sub_frame_t su
           return(RRC_OK);
       }
 
-      LOG_I(MAC,"Frame %d: Contention resolution timer %d/%d\n",frame,UE_mac_inst[module_idP].RA_contention_resolution_cnt,
+      LOG_I(MAC,"Frame %d: Contention resolution timer %d/%d\n",frameP,UE_mac_inst[module_idP].RA_contention_resolution_cnt,
           ((1+rach_ConfigCommon->ra_SupervisionInfo.mac_ContentionResolutionTimer)<<3));
 
       UE_mac_inst[module_idP].RA_contention_resolution_cnt++;
@@ -1438,7 +1438,7 @@ UE_L2_STATE_t ue_scheduler(module_id_t module_idP,frame_t frameP, sub_frame_t su
               else
                 UE_mac_inst[module_idP].scheduling_info.Bj[lcid] = bucketsizeduration;
           }
-          if (update_bsr(module_idP,frame, lcid, UE_mac_inst[module_idP].scheduling_info.LCGID[lcid])) {
+          if (update_bsr(module_idP,frameP, lcid, UE_mac_inst[module_idP].scheduling_info.LCGID[lcid])) {
               UE_mac_inst[module_idP].scheduling_info.SR_pending= 1;
               LOG_D(MAC,"[UE %d][SR] Frame %d subframe %d SR for PUSCH is pending for LCGID %d with BSR level %d (%d bytes in RLC)\n",
                   module_idP, frameP,subframeP,UE_mac_inst[module_idP].scheduling_info.LCGID[lcid],
@@ -1511,11 +1511,11 @@ int use_cba_access(module_id_t module_idP,frame_t frameP,u8 subframe, u8 eNB_ind
       ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]<64)) )
       //  && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive
       && (UE_mac_inst[module_idP].cba_last_access[0] <= 0) ) { // backoff
-      //  LOG_D(MAC,"[UE %d] Frame %d Subframe %d: the current CBA backoff is %d \n", module_idP, frame, subframe,
+      //  LOG_D(MAC,"[UE %d] Frame %d Subframe %d: the current CBA backoff is %d \n", module_idP, frameP, subframe,
       //  UE_mac_inst[module_idP].cba_last_access[0] );
 
       UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,10));
-      LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff  %d UL active state %d \n", module_idP, frame, subframe,
+      LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff  %d UL active state %d \n", module_idP, frameP, subframe,
           UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active);
 
       return 1;
@@ -1527,7 +1527,7 @@ int use_cba_access(module_id_t module_idP,frame_t frameP,u8 subframe, u8 eNB_ind
 
       UE_mac_inst[module_idP].cba_last_access[0]-=1;
       LOG_D(MAC,"[UE %d] Frame %d Subframe %d: CBA backoff is decreased by one to %d UL active state %d \n",
-          module_idP, frame, subframe,
+          module_idP, frameP, subframe,
           UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active);
 
   } /*else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] == 0 ))   &&
@@ -1599,7 +1599,7 @@ int  update_bsr(module_id_t module_idP, frame_t frameP, u8 lcid, u8 lcg_id){
   }
   //  for (lcid =0 ; lcid < MAX_NUM_LCID; lcid++) {
   if (UE_mac_inst[module_idP].scheduling_info.LCGID[lcid] == lcg_id) {
-      rlc_status = mac_rlc_status_ind(0, module_idP,frame,0,RLC_MBMS_NO,
+      rlc_status = mac_rlc_status_ind(0, module_idP,frameP,0,RLC_MBMS_NO,
           lcid,
           0);
       if (rlc_status.bytes_in_buffer > 0 ) {
diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c
index 40b2a43f981..00297d49833 100755
--- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c
+++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c
@@ -88,7 +88,6 @@ BOOL pdcp_data_req(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t fram
   u16                current_sn      = 0;
   mem_block_t       *pdcp_pdu_p      = NULL;
   rlc_op_status_t    rlc_status;
-  rb_id_t            rb_id_rlc       = 0;
 
   AssertError (enb_mod_idP < NUMBER_OF_eNB_MAX, return FALSE, "eNB id is too high (%u/%d) %u %u!\n", enb_mod_idP, NUMBER_OF_eNB_MAX, ue_mod_idP, rb_idP);
   AssertError (ue_mod_idP < NUMBER_OF_UE_MAX, return FALSE, "UE id is too high (%u/%d) %u %u!\n", ue_mod_idP, NUMBER_OF_UE_MAX, enb_mod_idP, rb_idP);
@@ -279,7 +278,7 @@ BOOL pdcp_data_req(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t fram
    */
   /*  
    if (rb_id>=DTCH) {
-    if (eNB_flag == 1) {
+    if (enb_flagP == 1) {
       Pdcp_stats_tx[module_id][(rb_id & RAB_OFFSET2 )>> RAB_SHIFT2][(rb_id & RAB_OFFSET)-DTCH]++;
       Pdcp_stats_tx_bytes[module_id][(rb_id & RAB_OFFSET2 )>> RAB_SHIFT2][(rb_id & RAB_OFFSET)-DTCH] += sdu_buffer_size;
     } else {
@@ -326,13 +325,13 @@ BOOL pdcp_data_ind(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t fram
       pdcp_p = &pdcp_array_ue[ue_mod_idP][rb_idP];
 
       LOG_I(PDCP, "Data indication notification for PDCP entity from eNB %u to UE %u "
-          "and radio bearer ID %d rlc sdu size %d eNB_flag %d\n",
+          "and radio bearer ID %d rlc sdu size %d enb_flagP %d\n",
           ue_mod_idP, enb_mod_idP, rb_idP, sdu_buffer_sizeP, enb_flagP);
   } else {
       pdcp_p = &pdcp_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP];
 
       LOG_I(PDCP, "Data indication notification for PDCP entity from UE %u to eNB %u "
-          "and radio bearer ID %d rlc sdu size %d eNB_flag %d eNB_id %d\n",
+          "and radio bearer ID %d rlc sdu size %d enb_flagP %d eNB_id %d\n",
           enb_mod_idP, ue_mod_idP, rb_idP, sdu_buffer_sizeP, enb_flagP, enb_mod_idP);
   }
   sdu_list_p = &pdcp_sdu_list;
@@ -522,7 +521,7 @@ BOOL pdcp_data_ind(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t fram
 }
 
 //-----------------------------------------------------------------------------
-void pdcp_run (frame_t frameP, eNB_flag_t  eNB_flag, module_id_t ue_mod_idP, module_id_t enb_mod_idP) {
+void pdcp_run (frame_t frameP, eNB_flag_t  enb_flagP, module_id_t ue_mod_idP, module_id_t enb_mod_idP) {
   //-----------------------------------------------------------------------------
 #if defined(ENABLE_ITTI)
   MessageDef   *msg_p;
@@ -536,7 +535,7 @@ void pdcp_run (frame_t frameP, eNB_flag_t  eNB_flag, module_id_t ue_mod_idP, mod
 #if defined(ENABLE_ITTI)
   do {
       // Checks if a message has been sent to PDCP sub-task
-      itti_poll_msg (eNB_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, &msg_p);
+      itti_poll_msg (enb_flagP ? TASK_PDCP_ENB : TASK_PDCP_UE, &msg_p);
 
       if (msg_p != NULL) {
           msg_name = ITTI_MSG_NAME (msg_p);
@@ -544,7 +543,7 @@ void pdcp_run (frame_t frameP, eNB_flag_t  eNB_flag, module_id_t ue_mod_idP, mod
 
           switch (ITTI_MSG_ID(msg_p)) {
           case RRC_DCCH_DATA_REQ:
-            LOG_I(PDCP, "Received %s from %s: instance %d, frame %d, eNB_flag %d, rb_id %d, muiP %d, confirmP %d, mode %d\n",
+            LOG_I(PDCP, "Received %s from %s: instance %d, frame %d, enb_flagP %d, rb_id %d, muiP %d, confirmP %d, mode %d\n",
                 msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance,
                 RRC_DCCH_DATA_REQ (msg_p).frame, RRC_DCCH_DATA_REQ (msg_p).enb_flag, RRC_DCCH_DATA_REQ (msg_p).rb_id,
                 RRC_DCCH_DATA_REQ (msg_p).muip, RRC_DCCH_DATA_REQ (msg_p).confirmp, RRC_DCCH_DATA_REQ (msg_p).mode);
@@ -595,13 +594,13 @@ void pdcp_run (frame_t frameP, eNB_flag_t  eNB_flag, module_id_t ue_mod_idP, mod
 # endif
 #endif
 
-  pdcp_fifo_read_input_sdus_from_otg(frameP, eNB_flag, ue_mod_idP, enb_mod_idP);
+  pdcp_fifo_read_input_sdus_from_otg(frameP, enb_flagP, ue_mod_idP, enb_mod_idP);
 
   // IP/NAS -> PDCP traffic : TX, read the pkt from the upper layer buffer
-  pdcp_fifo_read_input_sdus(frameP, eNB_flag, ue_mod_idP, enb_mod_idP);
+  pdcp_fifo_read_input_sdus(frameP, enb_flagP, ue_mod_idP, enb_mod_idP);
 
   // PDCP -> NAS/IP traffic: RX
-  pdcp_fifo_flush_sdus(frameP, eNB_flag, enb_mod_idP, ue_mod_idP);
+  pdcp_fifo_flush_sdus(frameP, enb_flagP, enb_mod_idP, ue_mod_idP);
 
   vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_RUN, VCD_FUNCTION_OUT);
 }
@@ -841,32 +840,37 @@ BOOL rrc_pdcp_config_asn1_req (module_id_t               enb_mod_idP,
   }
 
 #ifdef Rel10
-  if (pmch_InfoList_r9 != NULL) {
-      for (i=0;i<pmch_InfoList_r9->list.count;i++) {
-          mbms_SessionInfoList_r9 = &(pmch_InfoList_r9->list.array[i]->mbms_SessionInfoList_r9);
-          for (j=0;j<mbms_SessionInfoList_r9->list.count;j++) {
-              MBMS_SessionInfo = mbms_SessionInfoList_r9->list.array[j];
-              //lc_id = MBMS_SessionInfo->logicalChannelIdentity_r9; // lcid
-              lc_id = MBMS_SessionInfo->sessionId_r9->buf[0];
-              mch_id = MBMS_SessionInfo->tmgi_r9.serviceId_r9.buf[2]; //serviceId is 3-octet string
+  if (pmch_InfoList_r9_pP != NULL) {
+      for (i=0;i<pmch_InfoList_r9_pP->list.count;i++) {
+          mbms_SessionInfoList_r9_p = &(pmch_InfoList_r9_pP->list.array[i]->mbms_SessionInfoList_r9);
+          for (j=0;j<mbms_SessionInfoList_r9_p->list.count;j++) {
+              MBMS_SessionInfo_p = mbms_SessionInfoList_r9_p->list.array[j];
+              lc_id = MBMS_SessionInfo_p->sessionId_r9->buf[0];
+              mch_id = MBMS_SessionInfo_p->tmgi_r9.serviceId_r9.buf[2]; //serviceId is 3-octet string
 
               // can set the mch_id = i
-              if (eNB_flag)
+              if (enb_flagP) {
                 rb_id =  (mch_id * maxSessionPerPMCH ) + lc_id;
-              else
+                if (pdcp_mbms_array_eNB[enb_mod_idP][rb_id].instanciated_instance == module_id + 1)
+                  action = ACTION_MBMS_MODIFY;
+                else
+                  action = ACTION_MBMS_ADD;
+              } else {
                 rb_id =  (mch_id * maxSessionPerPMCH ) + lc_id + (maxDRB + 3);
+                if (pdcp_mbms_array_ue[ue_mod_idP][rb_id].instanciated_instance == module_id + 1)
+                  action = ACTION_MBMS_MODIFY;
+                else
+                  action = ACTION_MBMS_ADD;
+              }
+
 
-              if (pdcp_mbms_array[module_id][rb_id].instanciated_instance == module_id + 1)
-                action = ACTION_MBMS_MODIFY;
-              else
-                action = ACTION_MBMS_ADD;
 
               rlc_type = RLC_MODE_UM;
               pdcp_config_req_asn1 (NULL,
                   enb_mod_idP,
                   ue_mod_idP,
                   frameP,
-                  eNB_flag,
+                  enb_flagP,
                   rlc_type,
                   action,
                   lc_id,
@@ -875,10 +879,10 @@ BOOL rrc_pdcp_config_asn1_req (module_id_t               enb_mod_idP,
                   0, // set to deafult
                   0,
                   0,
-                  security_mode,
-                  kRRCenc,
-                  kRRCint,
-                  kUPenc);
+                  security_modeP,
+                  kRRCenc_pP,
+                  kRRCint_pP,
+                  kUPenc_pP);
           }
       }
   }
@@ -1054,7 +1058,7 @@ void pdcp_config_set_security(pdcp_t    *pdcp_pP,
     module_id_t     enb_mod_idP,
     module_id_t     ue_mod_idP,
     frame_t    frameP,
-    eNB_flag_t eNB_flag,
+    eNB_flag_t enb_flagP,
     rb_id_t    rb_idP,
     u16        lc_idP,
     u8         security_modeP,
@@ -1068,7 +1072,7 @@ void pdcp_config_set_security(pdcp_t    *pdcp_pP,
       pdcp_pP->cipheringAlgorithm     = security_modeP & 0x0f;
       pdcp_pP->integrityProtAlgorithm = (security_modeP>>4) & 0xf;
 
-      if (eNB_flag == 0) {
+      if (enb_flagP == 0) {
           LOG_D(PDCP,"[UE %d][RB %02d] Set security mode : ACTION_SET_SECURITY_MODE: "
               "Frame %d  cipheringAlgorithm %d integrityProtAlgorithm %d\n",
               ue_mod_idP, rb_idP, frameP, pdcp_pP->cipheringAlgorithm, pdcp_pP->integrityProtAlgorithm);
diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c
index d3d724f7738..edc2e39c77f 100755
--- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c
+++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c
@@ -709,7 +709,11 @@ rlc_am_mac_data_request (void *rlc_pP, frame_t frameP)
                   msg_p->ittiMsg.rlc_am_data_pdu_req.size = message_string_size;
                   memcpy(&msg_p->ittiMsg.rlc_am_data_pdu_req.text, message_string, message_string_size);
 
-                  itti_send_msg_to_task(TASK_UNKNOWN, l_rlc_p->module_id + NB_eNB_INST, msg_p);
+                  if (l_rlc_p->is_enb) {
+                      itti_send_msg_to_task(TASK_UNKNOWN, l_rlc_p->enb_module_id, msg_p);
+                  } else {
+                      itti_send_msg_to_task(TASK_UNKNOWN, l_rlc_p->ue_module_id + NB_eNB_INST, msg_p);
+                  }
 # else
                   rlc_am_display_data_pdu_infos(l_rlc_p, frameP, &pdu_info);
 # endif
@@ -741,7 +745,11 @@ rlc_am_mac_data_request (void *rlc_pP, frame_t frameP)
                   msg_p->ittiMsg.rlc_am_status_pdu_req.size = message_string_size;
                   memcpy(&msg_p->ittiMsg.rlc_am_status_pdu_req.text, message_string, message_string_size);
 
-                  itti_send_msg_to_task(TASK_UNKNOWN, l_rlc_p->module_id + NB_eNB_INST, msg_p);
+                  if (l_rlc_p->is_enb) {
+                      itti_send_msg_to_task(TASK_UNKNOWN, l_rlc_p->enb_module_id, msg_p);
+                  } else {
+                      itti_send_msg_to_task(TASK_UNKNOWN, l_rlc_p->ue_module_id + NB_eNB_INST, msg_p);
+                  }
 #   endif
               }
           }
@@ -844,7 +852,11 @@ rlc_am_mac_data_indication (void *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP,
                   msg_p->ittiMsg.rlc_am_data_pdu_ind.size = message_string_size;
                   memcpy(&msg_p->ittiMsg.rlc_am_data_pdu_ind.text, message_string, message_string_size);
 
-                  itti_send_msg_to_task(TASK_UNKNOWN, l_rlc_p->module_id + NB_eNB_INST, msg_p);
+                  if (l_rlc_p->is_enb) {
+                      itti_send_msg_to_task(TASK_UNKNOWN, l_rlc_p->enb_module_id, msg_p);
+                  } else {
+                      itti_send_msg_to_task(TASK_UNKNOWN, l_rlc_p->ue_module_id + NB_eNB_INST, msg_p);
+                  }
 # else
                   rlc_am_display_data_pdu_infos(l_rlc_p, frameP, &pdu_info);
 # endif
@@ -875,7 +887,11 @@ rlc_am_mac_data_indication (void *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP,
                   msg_p->ittiMsg.rlc_am_status_pdu_ind.size = message_string_size;
                   memcpy(&msg_p->ittiMsg.rlc_am_status_pdu_ind.text, message_string, message_string_size);
 
-                  itti_send_msg_to_task(TASK_UNKNOWN, l_rlc_p->module_id + NB_eNB_INST, msg_p);
+                  if (l_rlc_p->is_enb) {
+                      itti_send_msg_to_task(TASK_UNKNOWN, l_rlc_p->enb_module_id, msg_p);
+                  } else {
+                      itti_send_msg_to_task(TASK_UNKNOWN, l_rlc_p->ue_module_id + NB_eNB_INST, msg_p);
+                  }
 #   endif
               }
           }
diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_entity.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_entity.h
index 9c7a0e41eb5..57842477f4c 100755
--- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_entity.h
+++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_entity.h
@@ -48,23 +48,24 @@ Address      : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis
 #        include "list.h"
 #        include "rlc_primitives.h"
 #        include "rlc_def_lte.h"
+#        include "rlc_def.h"
 #        include "rlc_am_structs.h"
 #        include "rlc_am_constants.h"
 //-----------------------------------------------------------------------------
 /*! \struct  rlc_am_entity_t
 * \brief Structure containing a RLC AM instance protocol variables, statistic variables, allocation variables, buffers and other miscellaneous variables.
 */
-typedef struct rlc_am_entity {
-  module_id_t       enb_module_id;                      /*!< \brief eNB Virtualization index for this protocol instance, meaningful if is_enb is set. */
+typedef struct rlc_am_entity_s {
+  module_id_t       enb_module_id;                      /*!< \brief eNB Virtualization index for this protocol instance. */
   module_id_t       ue_module_id;                       /*!< \brief UE Virtualization index for this protocol instance. */
   rb_id_t           rb_id;                              /*!< \brief Radio bearer identifier, for statistics and trace purpose. */
   logical_chan_id_t channel_id;                         /*!< \brief Transport channel identifier. */
   boolean_t         is_data_plane;                      /*!< \brief To know if the RLC belongs to a data radio bearer or a signalling radio bearer, for statistics and trace purpose. */
   boolean_t         is_enb;                             /*!< \brief To know if the RLC belongs to a eNB or UE. */
 
-  signed int        sdu_buffer_occupancy;               /*!< \brief Number of bytes of unsegmented SDUs. */
-  signed int        retransmission_buffer_occupancy;    /*!< \brief Number of bytes of PDUs in retransmission buffer waiting for a ACK. */
-  signed int        status_buffer_occupancy;            /*!< \brief Number of bytes of control PDUs waiting for transmission. */
+  rlc_buffer_occupancy_t sdu_buffer_occupancy;               /*!< \brief Number of bytes of unsegmented SDUs. */
+  rlc_buffer_occupancy_t retransmission_buffer_occupancy;    /*!< \brief Number of bytes of PDUs in retransmission buffer waiting for a ACK. */
+  rlc_buffer_occupancy_t status_buffer_occupancy;            /*!< \brief Number of bytes of control PDUs waiting for transmission. */
 
   //---------------------------------------------------------------------
   // TX BUFFERS
@@ -96,7 +97,7 @@ typedef struct rlc_am_entity {
   //---------------------------------------------------------------------
   // PROTOCOL VARIABLES
   //---------------------------------------------------------------------
-  u8_t            protocol_state; /*!< \brief Protocol state, can be RLC_NULL_STATE, RLC_DATA_TRANSFER_READY_STATE. */
+  rlc_protocol_state_t protocol_state; /*!< \brief Protocol state, can be RLC_NULL_STATE, RLC_DATA_TRANSFER_READY_STATE. */
   //-----------------------------
   // TX STATE VARIABLES
   //-----------------------------
@@ -174,18 +175,18 @@ typedef struct rlc_am_entity {
   u16_t             nb_bytes_requested_by_mac;  /*!< \brief Number of bytes requested by lower layer for next transmission. */
   list_t            pdus_to_mac_layer;          /*!< \brief PDUs buffered for transmission to MAC layer. */
   list_t            control_pdu_list;           /*!< \brief Control PDUs buffered for transmission to MAC layer. */
-  s16_t             first_retrans_pdu_sn;       /*!< \brief Lowest sequence number of PDU to be retransmitted. */
+  rlc_sn_t          first_retrans_pdu_sn;       /*!< \brief Lowest sequence number of PDU to be retransmitted. */
   list_t            segmentation_pdu_list;      /*!< \brief List of "freshly" segmented PDUs. */
 
-  u32_t             status_requested;             /*!< \brief Status requested by peer. */
-  u32_t             last_frame_status_indication; /*!< \brief The last frame number a  MAC status indication has been received by RLC. */
+  boolean_t         status_requested;             /*!< \brief Status requested by peer. */
+  frame_t           last_frame_status_indication; /*!< \brief The last frame number a  MAC status indication has been received by RLC. */
   //-----------------------------
   // buffer occupancy measurements sent to MAC
   //-----------------------------
   // note occupancy of other buffers is deducted from nb elements in lists
-  u32_t             buffer_occupancy_retransmission_buffer;   /*!< \brief Number of PDUs. */
+  rlc_buffer_occupancy_t  buffer_occupancy_retransmission_buffer;   /*!< \brief Number of PDUs. */
 
-  u8_t              allocation;                              /*!< \brief Boolean for rlc_am_entity_t struct allocation. */
+  boolean_t               allocation;                              /*!< \brief Boolean for rlc_am_entity_t struct allocation. */
 } rlc_am_entity_t;
 /** @} */
 #    endif
diff --git a/openair2/LAYER2/RLC/TM/rlc_tm.c b/openair2/LAYER2/RLC/TM/rlc_tm.c
index 071b4ee7c79..a6a8f0e5ec2 100755
--- a/openair2/LAYER2/RLC/TM/rlc_tm.c
+++ b/openair2/LAYER2/RLC/TM/rlc_tm.c
@@ -47,16 +47,16 @@ Address      : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis
 //-----------------------------------------------------------------------------
 
 //-----------------------------------------------------------------------------
-void           *rlc_tm_tx (void *argP);
-void            rlc_tm_rx_no_segment (void *argP, struct mac_data_ind data_indP);
-void            rlc_tm_rx_segment (void *argP, struct mac_data_ind data_indP);
+void           *rlc_tm_tx (void *arg_pP);
+void            rlc_tm_rx_no_segment (void *arg_pP, struct mac_data_ind data_indP);
+void            rlc_tm_rx_segment (void *arg_pP, struct mac_data_ind data_indP);
 //-----------------------------------------------------------------------------
 void
-rlc_tm_get_pdus (void *argP)
+rlc_tm_get_pdus (void *arg_pP)
 {
 //-----------------------------------------------------------------------------
 
-  struct rlc_tm_entity *rlc = (struct rlc_tm_entity *) argP;
+  struct rlc_tm_entity *rlc = (struct rlc_tm_entity *) arg_pP;
 
   switch (rlc->protocol_state) {
 
@@ -80,12 +80,12 @@ rlc_tm_get_pdus (void *argP)
 
 //-----------------------------------------------------------------------------
 void
-rlc_tm_rx_no_segment (void *argP, struct mac_data_ind data_indP)
+rlc_tm_rx_no_segment (void *arg_pP, struct mac_data_ind data_indP)
 {
 //-----------------------------------------------------------------------------
 
-  struct rlc_tm_entity *rlc = (struct rlc_tm_entity *) argP;
-  mem_block_t *tb;
+  struct rlc_tm_entity *rlc = (struct rlc_tm_entity *) arg_pP;
+  mem_block_t *tb_p;
   u8_t             *first_byte;
   u8_t              tb_size_in_bytes;
   u8_t              first_bit;
@@ -100,17 +100,17 @@ rlc_tm_rx_no_segment (void *argP, struct mac_data_ind data_indP)
         // Upon reception of a CRLC-CONFIG-Req from upper layer indicating establishment, the RLC entity:
         // -      is created; and
         // -      enters the DATA_TRANSFER_READY state.
-        msg ("[RLC_TM %p] ERROR MAC_DATA_IND IN RLC_NULL_STATE\n", argP);
+        msg ("[RLC_TM %p] ERROR MAC_DATA_IND IN RLC_NULL_STATE\n", arg_pP);
         list_free (&data_indP.data);
         break;
 
       case RLC_DATA_TRANSFER_READY_STATE:
         rlc->output_sdu_size_to_write = 0;      // size of sdu reassemblied
-        while ((tb = list_remove_head (&data_indP.data))) {
-          first_byte = ((struct mac_tb_ind *) (tb->data))->data_ptr;
+        while ((tb_p = list_remove_head (&data_indP.data))) {
+          first_byte = ((struct mac_tb_ind *) (tb_p->data))->data_ptr;
 
           tb_size_in_bytes = (data_indP.tb_size + 7) >> 3;
-          first_bit = ((struct mac_tb_ind *) (tb->data))->first_bit;
+          first_bit = ((struct mac_tb_ind *) (tb_p->data))->first_bit;
           if (first_bit > 0) {
             // shift data of transport_block TO CHECK
             bits_to_shift_last_loop = 0;
@@ -123,18 +123,18 @@ rlc_tm_rx_no_segment (void *argP, struct mac_data_ind data_indP)
             }
           }
 
-          ((struct rlc_tm_rx_pdu_management *) (tb->data))->first_byte = first_byte;
+          ((struct rlc_tm_rx_pdu_management *) (tb_p->data))->first_byte = first_byte;
 
           if (rlc->delivery_of_erroneous_sdu == RLC_TM_DELIVERY_OF_ERRONEOUS_SDU_NO_DETECT) {
             rlc_tm_send_sdu_no_segment (rlc, 0, first_byte, data_indP.tb_size);
           } else if (rlc->delivery_of_erroneous_sdu == RLC_TM_DELIVERY_OF_ERRONEOUS_SDU_YES) {
-            rlc_tm_send_sdu_no_segment (rlc, (((struct mac_tb_ind *) (tb->data))->error_indication), first_byte, data_indP.tb_size);
+            rlc_tm_send_sdu_no_segment (rlc, (((struct mac_tb_ind *) (tb_p->data))->error_indication), first_byte, data_indP.tb_size);
           } else {              //RLC_TM_DELIVERY_OF_ERRONEOUS_SDU_NO
-            if (!(((struct mac_tb_ind *) (tb->data))->error_indication)) {
+            if (!(((struct mac_tb_ind *) (tb_p->data))->error_indication)) {
               rlc_tm_send_sdu_no_segment (rlc, 0, first_byte, data_indP.tb_size);
             }
           }
-          free_mem_block (tb);
+          free_mem_block (tb_p);
         }
         break;
 
@@ -145,22 +145,22 @@ rlc_tm_rx_no_segment (void *argP, struct mac_data_ind data_indP)
 
 //-----------------------------------------------------------------------------
 void
-rlc_tm_rx_segment (void *argP, struct mac_data_ind data_indP)
+rlc_tm_rx_segment (void *arg_pP, struct mac_data_ind data_indP)
 {
 //-----------------------------------------------------------------------------
 
-  struct rlc_tm_entity *rlc = (struct rlc_tm_entity *) argP;
-  mem_block_t *tb;
-  s32_t             tb_size_in_bits;
-  u8_t             *first_byte;
-  u8_t              error_in_sdu;
-  u8_t              tb_size_in_bytes;
-  u8_t              first_bit;
-  u8_t              byte;
+  struct rlc_tm_entity *rlc             = (struct rlc_tm_entity_s *) arg_pP;
+  mem_block_t          *tb_p            = NULL;
+  sdu_size_t            tb_size_in_bits = 0;
+  u8_t                 *first_byte_p    = NULL;
+  u8_t                  error_in_sdu    = 0;
+  sdu_size_t            tb_size_in_bytes= 0;
+  u8_t                  first_bit       = 0;
+  u8_t                  byte            = 0;
 
 
   //just for debug
-  u8_t             *debug;
+  u8_t                 *debug           = NULL;
 
   switch (rlc->protocol_state) {
 
@@ -170,7 +170,7 @@ rlc_tm_rx_segment (void *argP, struct mac_data_ind data_indP)
         // Upon reception of a CRLC-CONFIG-Req from upper layer indicating establishment, the RLC entity:
         // -      is created; and
         // -      enters the DATA_TRANSFER_READY state.
-        msg ("[RLC_TM %p] ERROR MAC_DATA_IND IN RLC_NULL_STATE\n", argP);
+        msg ("[RLC_TM %p] ERROR MAC_DATA_IND IN RLC_NULL_STATE\n", arg_pP);
         list_free (&data_indP.data);
         break;
 
@@ -183,9 +183,9 @@ rlc_tm_rx_segment (void *argP, struct mac_data_ind data_indP)
 
             case RLC_TM_DELIVERY_OF_ERRONEOUS_SDU_YES:
               error_in_sdu = 0;
-              while ((tb = list_remove_head (&data_indP.data))) {
+              while ((tb_p = list_remove_head (&data_indP.data))) {
 
-                if ((((struct mac_tb_ind *) (tb->data))->error_indication)) {
+                if ((((struct mac_tb_ind *) (tb_p->data))->error_indication)) {
                   error_in_sdu = 1;
                 }
               }
@@ -200,16 +200,16 @@ rlc_tm_rx_segment (void *argP, struct mac_data_ind data_indP)
               }
               debug = (u8_t*)&rlc->output_sdu_in_construction->data[0];
 
-              while ((tb = list_remove_head (&data_indP.data))) {
+              while ((tb_p = list_remove_head (&data_indP.data))) {
 
-                if ((((struct mac_tb_ind *) (tb->data))->error_indication) && (error_in_sdu)) {
+                if ((((struct mac_tb_ind *) (tb_p->data))->error_indication) && (error_in_sdu)) {
                   error_in_sdu = 1;
                 } else {
-                  first_byte = ((struct mac_tb_ind *) (tb->data))->data_ptr;
+                  first_byte = ((struct mac_tb_ind *) (tb_p->data))->data_ptr;
 
                   tb_size_in_bytes = (data_indP.tb_size + 7) >> 3;
                   tb_size_in_bits = data_indP.tb_size;
-                  first_bit = ((struct mac_tb_ind *) (tb->data))->first_bit;
+                  first_bit = ((struct mac_tb_ind *) (tb_p->data))->first_bit;
 
                   while (tb_size_in_bits > 0) {
 
@@ -272,7 +272,7 @@ rlc_tm_rx_segment (void *argP, struct mac_data_ind data_indP)
                     }
                   }
                 }
-                free_mem_block (tb);
+                free_mem_block (tb_p);
               }
               if (!(error_in_sdu)) {
                 rlc_tm_send_sdu_segment (rlc, 0);
diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_entity.h b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_entity.h
index 203af010376..cc1ad94c123 100755
--- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_entity.h
+++ b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_entity.h
@@ -47,16 +47,16 @@ Address      : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis
 * \brief Structure containing a RLC TM instance protocol variables, allocation variables, buffers and other miscellaneous variables.
 */
 typedef struct rlc_tm_entity {
-  module_id_t       enb_module_id;                      /*!< \brief eNB Virtualization index for this protocol instance, meaningful if is_enb is set. */
-  module_id_t       ue_module_id;                       /*!< \brief UE Virtualization index for this protocol instance. */
-  u8_t              allocation;      /*!< \brief Boolean for rlc_tm_entity_t struct allocation. */
-  u8_t              protocol_state;  /*!< \brief Protocol state, can be RLC_NULL_STATE, RLC_DATA_TRANSFER_READY_STATE, RLC_LOCAL_SUSPEND_STATE. */
-  boolean_t         is_uplink_downlink; /*!< \brief Is this instance is a transmitter, a receiver or both? */
-  boolean_t         is_data_plane;      /*!< \brief To know if the RLC belongs to a data radio bearer or a signalling radio bearer, for statistics and trace purpose. */
+  module_id_t          enb_module_id;      /*!< \brief eNB Virtualization index for this protocol instance, meaningful if is_enb is set. */
+  module_id_t          ue_module_id;       /*!< \brief UE Virtualization index for this protocol instance, meaningful if is_enb is set. */
+  boolean_t            allocation;         /*!< \brief Boolean for rlc_tm_entity_t struct allocation. */
+  rlc_protocol_state_t protocol_state;     /*!< \brief Protocol state, can be RLC_NULL_STATE, RLC_DATA_TRANSFER_READY_STATE, RLC_LOCAL_SUSPEND_STATE. */
+  boolean_t            is_uplink_downlink; /*!< \brief Is this instance is a transmitter, a receiver or both? */
+  boolean_t            is_data_plane;      /*!< \brief To know if the RLC belongs to a data radio bearer or a signalling radio bearer, for statistics and trace purpose. */
   // for stats and trace purpose :
-  logical_chan_id_t channel_id;        /*!< \brief Transport channel identifier. */
-  rb_id_t           rb_id;             /*!< \brief Radio bearer identifier, for statistics and trace purpose. */
-  boolean_t         is_enb;            /*!< \brief To know if the RLC belongs to a eNB or UE. */
+  logical_chan_id_t    channel_id;         /*!< \brief Transport channel identifier. */
+  rb_id_t              rb_id;              /*!< \brief Radio bearer identifier, for statistics and trace purpose. */
+  boolean_t            is_enb;             /*!< \brief To know if the RLC belongs to a eNB or UE. */
   //-----------------------------
   // tranmission
   //-----------------------------
@@ -69,7 +69,7 @@ typedef struct rlc_tm_entity {
   u16_t             current_sdu_index;       /*!< \brief Current SDU index in input_sdus array to be segmented. */
   list_t            pdus_to_mac_layer;       /*!< \brief PDUs buffered for transmission to MAC layer. */
   sdu_size_t        rlc_pdu_size;
-  u32_t             buffer_occupancy;        /*!< \brief Number of bytes contained in input_sdus buffer.*/
+  rlc_buffer_occupancy_t buffer_occupancy;        /*!< \brief Number of bytes contained in input_sdus buffer.*/
   //-----------------------------
   // receiver
   //-----------------------------
diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c
index 91387c8e048..a43b07aee0c 100755
--- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c
+++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c
@@ -318,7 +318,11 @@ rlc_um_rx (void *argP, frame_t frameP, eNB_flag_t eNB_flagP, struct mac_data_ind
                   msg_p->ittiMsg.rlc_um_data_pdu_ind.size = message_string_size;
                   memcpy(&msg_p->ittiMsg.rlc_um_data_pdu_ind.text, message_string, message_string_size);
 
-                  itti_send_msg_to_task(TASK_UNKNOWN, l_rlc_p->module_id + NB_eNB_INST, msg_p);
+                  if (l_rlc_p->is_enb) {
+                      itti_send_msg_to_task(TASK_UNKNOWN, l_rlc_p->enb_module_id, msg_p);
+                  } else {
+                      itti_send_msg_to_task(TASK_UNKNOWN, l_rlc_p->ue_module_id + NB_eNB_INST, msg_p);
+                  }
 # else
                   LOG_T(RLC, "%s", message_string);
 # endif
@@ -576,7 +580,11 @@ rlc_um_mac_data_request (void *rlc_pP,frame_t frameP)
             msg_p->ittiMsg.rlc_um_data_pdu_req.size = message_string_size;
             memcpy(&msg_p->ittiMsg.rlc_um_data_pdu_req.text, message_string, message_string_size);
 
-            itti_send_msg_to_task(TASK_UNKNOWN, l_rlc_p->module_id + NB_eNB_INST, msg_p);
+            if (l_rlc_p->is_enb) {
+                itti_send_msg_to_task(TASK_UNKNOWN, l_rlc_p->enb_module_id, msg_p);
+            } else {
+                itti_send_msg_to_task(TASK_UNKNOWN, l_rlc_p->ue_module_id + NB_eNB_INST, msg_p);
+            }
 # else
             LOG_T(RLC, "%s", message_string);
 # endif
diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_entity.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_entity.h
index b9039917133..236ca8e0339 100755
--- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_entity.h
+++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_entity.h
@@ -44,7 +44,7 @@ Address      : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis
 #        include "rlc_primitives.h"
 #        include "rlc_def.h"
 
-typedef struct rlc_um_timer {
+typedef struct rlc_um_timer_s {
     u32_t  frame_time_out;/*!< \brief When set, indicate the frame number the timer will time-out. */
     u32_t  frame_start;   /*!< \brief indicate the frame number the timer has been started. */
     u32_t  time_out;      /*!< \brief Configured timer duration in frames. */
@@ -54,33 +54,30 @@ typedef struct rlc_um_timer {
 } rlc_um_timer_t ;
 
 
-/*! \struct  rlc_um_entity_t
+/*! \struct  rlc_um_entity_s
 * \brief Structure containing a RLC UM instance protocol variables, statistic variables, allocation variables, buffers and other miscellaneous variables.
 */
 
-typedef struct rlc_um_entity {
-  module_id_t       enb_module_id;      /*!< \brief eNB Virtualization index for this protocol instance, meaningful if is_enb is set. */
-  module_id_t       ue_module_id;       /*!< \brief UE Virtualization index for this protocol instance. */
-  u8_t              allocation;         /*!< \brief Boolean for rlc_am_entity_t struct allocation. */
-  u8_t              is_uplink_downlink; /*!< \brief Is this instance is a transmitter, a receiver or both? */
-  u8_t              protocol_state;     /*!< \brief Protocol state, can be RLC_NULL_STATE, RLC_DATA_TRANSFER_READY_STATE, RLC_LOCAL_SUSPEND_STATE. */
-  u16_t             is_data_plane;      /*!< \brief To know if the RLC belongs to a data radio bearer or a signalling radio bearer, for statistics and trace purpose. */
-  boolean_t         is_enb;             /*!< \brief To know if the RLC belongs to a eNB or UE. */
-  boolean_t         is_mxch;            /*!< \brief To know if the RLC belongs to a MBMS bearer. */
+typedef struct rlc_um_entity_s {
+  module_id_t          enb_module_id;      /*!< \brief eNB Virtualization index for this protocol instance. */
+  module_id_t          ue_module_id;       /*!< \brief UE Virtualization index for this protocol instance. */
+  boolean_t            allocation;         /*!< \brief Boolean for rlc_am_entity_t struct allocation. */
+  boolean_t            is_uplink_downlink; /*!< \brief Is this instance is a transmitter, a receiver or both? */
+  rlc_protocol_state_t protocol_state;     /*!< \brief Protocol state, can be RLC_NULL_STATE, RLC_DATA_TRANSFER_READY_STATE, RLC_LOCAL_SUSPEND_STATE. */
+  boolean_t            is_data_plane;      /*!< \brief To know if the RLC belongs to a data radio bearer or a signalling radio bearer, for statistics and trace purpose. */
+  boolean_t            is_enb;             /*!< \brief To know if the RLC belongs to a eNB or UE. */
+  boolean_t            is_mxch;            /*!< \brief To know if the RLC belongs to a MBMS bearer. */
   //-----------------------------
   // PROTOCOL VARIABLES
   //-----------------------------
-  u16_t              vt_us; /*!< \brief This state variable holds the value of the SN to be assigned for the next newly generated UMD PDU. It is initially set to 0, and is updated whenever the UM RLC entity delivers an UMD PDU with SN = VT(US). */
-  u16_t              vr_ur; /*!< \brief UM receive state variable. This state variable holds the value of the SN of the earliest UMD PDU that is still considered for reordering. It is initially set to 0. */
-  u16_t              vr_ux; /*!< \brief UM t-Reordering state variable. This state variable holds the value of the SN following the SN of the UMD PDU which triggered t-Reordering. */
-  u16_t              vr_uh; /*!< \brief UM highest received state variable. This state variable holds the value of the SN following the SN of the UMD PDU with the highest SN among received UMD PDUs, and it serves as the higher edge of the reordering window. It is initially set to 0. */
+  rlc_usn_t         vt_us; /*!< \brief This state variable holds the value of the SN to be assigned for the next newly generated UMD PDU. It is initially set to 0, and is updated whenever the UM RLC entity delivers an UMD PDU with SN = VT(US). */
+  rlc_usn_t         vr_ur; /*!< \brief UM receive state variable. This state variable holds the value of the SN of the earliest UMD PDU that is still considered for reordering. It is initially set to 0. */
+  rlc_usn_t         vr_ux; /*!< \brief UM t-Reordering state variable. This state variable holds the value of the SN following the SN of the UMD PDU which triggered t-Reordering. */
+  rlc_usn_t         vr_uh; /*!< \brief UM highest received state variable. This state variable holds the value of the SN following the SN of the UMD PDU with the highest SN among received UMD PDUs, and it serves as the higher edge of the reordering window. It is initially set to 0. */
   //-----------------------------
   // TIMERS
   //-----------------------------
-  struct rlc_um_timer  t_reordering;
-  //signed int        timer_reordering;           /*!< \brief Timer t-Reordering starting time frame, this timer is used by the receiving side of an AM RLC entity and receiving UM RLC entity in order to detect loss of RLC PDUs at lower layer. If t-Reordering is running, t-Reordering shall not be started additionally, i.e. only one t-Reordering per RLC entity is running at a given time. */
-  //signed int        timer_reordering_init;     /*!< \brief Timer t-Reordering initial configuration value. */
-  //signed int        timer_reordering_running;  /*!< \brief Boolean to know if timer t-Reordering is running. */
+  struct rlc_um_timer_s  t_reordering;
   //*****************************************************************************
   // CONFIGURATION PARAMETERS
   //*****************************************************************************
@@ -88,10 +85,10 @@ typedef struct rlc_um_entity {
   u8_t              rx_sn_length;                     /*!< \brief Length of sequence number in bits, can be 5 or 10. */
   u8_t              tx_header_min_length_in_bytes;    /*!< \brief Length of PDU header, can be 1 or 2 bytes. */
   u8_t              rx_header_min_length_in_bytes;    /*!< \brief Length of PDU header, can be 1 or 2 bytes. */
-  signed int        tx_sn_modulo;                     /*!< \brief Module of the sequence number of PDU, can be RLC_UM_SN_5_BITS_MODULO or RLC_UM_SN_10_BITS_MODULO. */
-  signed int        rx_sn_modulo;                     /*!< \brief Module of the sequence number of PDU, can be RLC_UM_SN_5_BITS_MODULO or RLC_UM_SN_10_BITS_MODULO. */
-  signed int        rx_um_window_size;
-  signed int        tx_um_window_size;
+  rlc_sn_t          tx_sn_modulo;                     /*!< \brief Module of the sequence number of PDU, can be RLC_UM_SN_5_BITS_MODULO or RLC_UM_SN_10_BITS_MODULO. */
+  rlc_sn_t          rx_sn_modulo;                     /*!< \brief Module of the sequence number of PDU, can be RLC_UM_SN_5_BITS_MODULO or RLC_UM_SN_10_BITS_MODULO. */
+  rlc_sn_t          rx_um_window_size;
+  rlc_sn_t          tx_um_window_size;
   //-----------------------------
   // tranmission
   //-----------------------------
@@ -102,14 +99,14 @@ typedef struct rlc_um_entity {
   u16_t             nb_sdu;                    /*!< \brief Total number of SDUs in input_sdus[] */
   u16_t             next_sdu_index;            /*!< \brief Next SDU index for a new incomin SDU in input_sdus[]. */
   u16_t             current_sdu_index;         /*!< \brief Current SDU index in input_sdus array to be segmented. */
-  u32_t             buffer_occupancy;          /*!< \brief Number of bytes contained in input_sdus buffer.*/
+  rlc_buffer_occupancy_t buffer_occupancy;          /*!< \brief Number of bytes contained in input_sdus buffer.*/
   u32_t             nb_bytes_requested_by_mac; /*!< \brief Number of bytes requested by lower layer for next transmission. */
   list_t            pdus_to_mac_layer;         /*!< \brief PDUs buffered for transmission to MAC layer. */
   //*****************************************************************************
   // RECEIVER
   //*****************************************************************************
-  mem_block_t    *  output_sdu_in_construction;     /*!< \brief Memory area where a complete SDU is reassemblied before being send to upper layers. */
-  s32_t             output_sdu_size_to_write;       /*!< \brief Size of the reassemblied SDU. */
+  mem_block_t      *output_sdu_in_construction;     /*!< \brief Memory area where a complete SDU is reassemblied before being send to upper layers. */
+  sdu_size_t        output_sdu_size_to_write;       /*!< \brief Size of the reassemblied SDU. */
 
   mem_block_t     **dar_buffer;                     /*!< \brief Array of rx PDUs. */
   mem_block_t      *dar_buffer_alloc;               /*!< \brief Allocated memory for the DAR buffer. */
@@ -117,13 +114,13 @@ typedef struct rlc_um_entity {
 
   logical_chan_id_t channel_id;                     /*!< \brief Transport channel identifier. */
   rb_id_t           rb_id;                          /*!< \brief Radio bearer identifier, for statistics and trace purpose. */
-  u16_t             last_reassemblied_sn;           /*!< \brief Sequence number of the last reassemblied PDU. */
-  u16_t             last_reassemblied_missing_sn;   /*!< \brief Sequence number of the last found missing PDU. */
-  u16_t             reassembly_missing_sn_detected; /*!< \brief Act as a boolean, set if a hole in the sequence numbering of received PDUs has been found. */
+  rlc_usn_t         last_reassemblied_sn;           /*!< \brief Sequence number of the last reassemblied PDU. */
+  rlc_usn_t         last_reassemblied_missing_sn;   /*!< \brief Sequence number of the last found missing PDU. */
+  rlc_usn_t         reassembly_missing_sn_detected; /*!< \brief Act as a boolean, set if a hole in the sequence numbering of received PDUs has been found. */
   //-----------------------------
   // STATISTICS
   //-----------------------------
-  u8_t              first_pdu;                        /*!< \brief Act as a boolean, tells if the next PDU is the first PDU to be received. */
+  boolean_t         first_pdu;                        /*!< \brief Act as a boolean, tells if the next PDU is the first PDU to be received. */
 
   unsigned int stat_tx_pdcp_sdu;                      /*!< \brief Number of SDUs received from upper layers. */
   unsigned int stat_tx_pdcp_bytes;                    /*!< \brief Number of SDU bytes received from upper layers. */
diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c
index a3584dbb37a..9f183c0c630 100755
--- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c
+++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c
@@ -38,7 +38,7 @@ Address      : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis
 
 //-----------------------------------------------------------------------------
 int
-rlc_um_fsm_notify_event (struct rlc_um_entity *rlc_pP, u8_t eventP)
+rlc_um_fsm_notify_event (rlc_um_entity_t *rlc_pP, u8_t eventP)
 {
 //-----------------------------------------------------------------------------
 
diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.h
index 1ae48953169..35b86ed1445 100644
--- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.h
+++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.h
@@ -60,7 +60,7 @@ Address      : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis
 #        include "platform_types.h"
 #        include "rlc_um_entity.h"
 //-----------------------------------------------------------------------------
-/*! \fn int rlc_um_fsm_notify_event (struct rlc_um_entity *rlcP, u8_t eventP)
+/*! \fn int rlc_um_fsm_notify_event (rlc_um_entity_t *rlcP, u8_t eventP)
 * \brief    Send an event to the RLC UM finite state machine.
 * \param[in]  rlcP        RLC UM protocol instance pointer.
 * \param[in]  eventP      Event (#RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_NULL_STATE_EVENT,
@@ -71,6 +71,6 @@ Address      : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis
 * \return     1 if no error was encountered, 0 if the event was not processed.
 * \Note       This FSM is not LTE 9.3.0 compliant, it has to be modified or removed.
 */
-protected_rlc_um_fsm(int      rlc_um_fsm_notify_event (struct rlc_um_entity *rlcP, u8_t eventP));
+protected_rlc_um_fsm(int      rlc_um_fsm_notify_event (rlc_um_entity_t *rlcP, u8_t eventP));
 /** @} */
 #    endif
diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.c
index 59cb7a3f40e..b22315e18d1 100755
--- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.c
+++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.c
@@ -43,7 +43,7 @@ Address      : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis
 #define DEBUG_RLC_UM_RX
 
 //-----------------------------------------------------------------------------
-void rlc_um_display_rx_window(struct rlc_um_entity *rlc_pP)
+void rlc_um_display_rx_window(rlc_um_entity_t *rlc_pP)
 //-----------------------------------------------------------------------------
 {
 /*
@@ -145,7 +145,7 @@ void rlc_um_display_rx_window(struct rlc_um_entity *rlc_pP)
 
 //-----------------------------------------------------------------------------
 void
-rlc_um_receive (struct rlc_um_entity *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP, struct mac_data_ind data_indP)
+rlc_um_receive (rlc_um_entity_t *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP, struct mac_data_ind data_indP)
 {
 //-----------------------------------------------------------------------------
 
diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.h
index b1a465fe208..364f339cf32 100644
--- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.h
+++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.h
@@ -59,19 +59,19 @@ Address      : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis
 #        include "rlc_um_entity.h"
 #        include "mac_primitives.h"
 
-/*! \fn void rlc_um_display_rx_window(struct rlc_um_entity *rlc_pP)
+/*! \fn void rlc_um_display_rx_window(rlc_um_entity_t *rlc_pP)
 * \brief    Display the content of the RX buffer, the output stream is targeted to TTY terminals because of escape sequences.
 * \param[in]  rlc_pP      RLC UM protocol instance pointer.
 */
-protected_rlc_um_receiver( void rlc_um_display_rx_window(struct rlc_um_entity *rlc_pP);)
+protected_rlc_um_receiver( void rlc_um_display_rx_window(rlc_um_entity_t *rlc_pP);)
 
-/*! \fn void rlc_um_receive (struct rlc_um_entity *rlc_pP, frame_t frameP, struct mac_data_ind data_indP)
+/*! \fn void rlc_um_receive (rlc_um_entity_t *rlc_pP, frame_t frameP, struct mac_data_ind data_indP)
 * \brief    Handle the MAC data indication, retreive the transport blocks and send them one by one to the DAR process.
 * \param[in]  rlc_pP      RLC UM protocol instance pointer.
 * \param[in]  frameP      Frame index.
 * \param[in]  eNB_flagP   Flag to indicated eNB (1) or UE (0).
 * \param[in]  data_indP   Data indication structure containing transport block received from MAC layer.
 */
-protected_rlc_um_receiver( void rlc_um_receive (struct rlc_um_entity *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP, struct mac_data_ind data_indP));
+protected_rlc_um_receiver( void rlc_um_receive (rlc_um_entity_t *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP, struct mac_data_ind data_indP));
 /** @} */
 #    endif
diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c
index 91d6f9120a1..487c605d4d7 100755
--- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c
+++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c
@@ -45,7 +45,7 @@ Address      : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis
 //#define TRACE_RLC_UM_SEGMENT 1
 //-----------------------------------------------------------------------------
 void
-rlc_um_segment_10 (struct rlc_um_entity *rlc_pP,frame_t frameP)
+rlc_um_segment_10 (rlc_um_entity_t *rlc_pP,frame_t frameP)
 {
 //-----------------------------------------------------------------------------
     list_t              pdus;
@@ -475,7 +475,7 @@ rlc_um_segment_10 (struct rlc_um_entity *rlc_pP,frame_t frameP)
 }
 //-----------------------------------------------------------------------------
 void
-rlc_um_segment_5 (struct rlc_um_entity *rlc_pP,frame_t frameP)
+rlc_um_segment_5 (rlc_um_entity_t *rlc_pP,frame_t frameP)
 {
 //-----------------------------------------------------------------------------
     list_t              pdus;
diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.h
index 348962435a9..4ceacc188a2 100644
--- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.h
+++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.h
@@ -62,19 +62,19 @@ Address      : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis
 #                define public_rlc_um_segment(x)     extern x
 #            endif
 #        endif
-/*! \fn void rlc_um_segment_10 (struct rlc_um_entity *rlcP,u32_t frame)
+/*! \fn void rlc_um_segment_10 (rlc_um_entity_t *rlcP,frame_t frame)
 * \brief    Segmentation procedure with 10 bits sequence number, segment the first SDU in buffer and create a PDU of the size (nb_bytes_to_transmit) requested by MAC if possible and put it in the list "pdus_to_mac_layer".
 * \param[in]  rlcP        RLC UM protocol instance pointer.
 * \param[in]  frame       Frame Index.
 */
-protected_rlc_um_segment(void rlc_um_segment_10 (struct rlc_um_entity *rlcP,u32_t frame));
+protected_rlc_um_segment(void rlc_um_segment_10 (rlc_um_entity_t *rlcP,frame_t frame));
 
 
-/*! \fn void rlc_um_segment_5 (struct rlc_um_entity *rlcP,u32_t frame)
+/*! \fn void rlc_um_segment_5 (rlc_um_entity_t *rlcP,frame_t frame)
 * \brief    Segmentation procedure with 5 bits sequence number, segment the first SDU in buffer and create a PDU of the size (nb_bytes_to_transmit) requested by MAC if possible and put it in the list "pdus_to_mac_layer".
 * \param[in]  rlcP        RLC UM protocol instance pointer.
 * \param[in]  frame       Frame Index.
 */
-protected_rlc_um_segment(void rlc_um_segment_5 (struct rlc_um_entity *rlcP,u32_t frame));
+protected_rlc_um_segment(void rlc_um_segment_5 (rlc_um_entity_t *rlcP,frame_t frame));
 /** @} */
 #    endif
diff --git a/openair2/RRC/LITE/L2_interface.c b/openair2/RRC/LITE/L2_interface.c
index 0052b292b89..8e6c1ecbef0 100644
--- a/openair2/RRC/LITE/L2_interface.c
+++ b/openair2/RRC/LITE/L2_interface.c
@@ -63,7 +63,7 @@ extern UE_MAC_INST *UE_mac_inst;
 mui_t mui=0;
 
 //-------------------------------------------------------------------------------------------//
-s8 mac_rrc_lite_data_req(module_id_t Mod_idP, frame_t frameP, u16 Srb_id, u8 Nb_tb, u8 *buffer_pP, eNB_flag_t eNB_flagP, u8 eNB_index,
+s8 mac_rrc_lite_data_req(module_id_t Mod_idP, frame_t frameP, u16 Srb_id, u8 Nb_tb, u8 *buffer_pP, eNB_flag_t enb_flagP, u8 eNB_index,
                          u8 mbsfn_sync_area) {
 //-------------------------------------------------------------------------------------------//
   SRB_INFO *Srb_info;
@@ -74,7 +74,7 @@ s8 mac_rrc_lite_data_req(module_id_t Mod_idP, frame_t frameP, u16 Srb_id, u8 Nb_
   LOG_D(RRC,"[eNB %d] mac_rrc_data_req to SRB ID=%d\n",Mod_idP,Srb_id);
 #endif
 
-  if( eNB_flagP == 1){
+  if( enb_flagP == 1){
 
     if((Srb_id & RAB_OFFSET) == BCCH){
       if(eNB_rrc_inst[Mod_idP].SI.Active==0) return 0;
@@ -90,7 +90,7 @@ s8 mac_rrc_lite_data_req(module_id_t Mod_idP, frame_t frameP, u16 Srb_id, u8 Nb_
 #if defined(ENABLE_ITTI)
       {
         MessageDef *message_p;
-        int sib1_size = eNB_rrc_inst[Mod_id].sizeof_SIB1;
+        int sib1_size = eNB_rrc_inst[Mod_idP].sizeof_SIB1;
         int sdu_size = sizeof(RRC_MAC_BCCH_DATA_REQ (message_p).sdu);
 
         if (sib1_size > sdu_size)
@@ -100,13 +100,13 @@ s8 mac_rrc_lite_data_req(module_id_t Mod_idP, frame_t frameP, u16 Srb_id, u8 Nb_
         }
 
         message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_MAC_BCCH_DATA_REQ);
-        RRC_MAC_BCCH_DATA_REQ (message_p).frame = frameP;
+        RRC_MAC_BCCH_DATA_REQ (message_p).frame    = frameP;
         RRC_MAC_BCCH_DATA_REQ (message_p).sdu_size = sib1_size;
         memset (RRC_MAC_BCCH_DATA_REQ (message_p).sdu, 0, sizeof(RRC_MAC_BCCH_DATA_REQ (message_p).sdu));
-        memcpy (RRC_MAC_BCCH_DATA_REQ (message_p).sdu, eNB_rrc_inst[Mod_id].SIB1, sib1_size);
+        memcpy (RRC_MAC_BCCH_DATA_REQ (message_p).sdu, eNB_rrc_inst[Mod_idP].SIB1, sib1_size);
         RRC_MAC_BCCH_DATA_REQ (message_p).enb_index = eNB_index;
 
-        itti_send_msg_to_task (TASK_MAC_ENB, Mod_id, message_p);
+        itti_send_msg_to_task (TASK_MAC_ENB, Mod_idP, message_p);
       }
 #endif
 
@@ -203,7 +203,7 @@ s8 mac_rrc_lite_data_req(module_id_t Mod_idP, frame_t frameP, u16 Srb_id, u8 Nb_
 
 #ifdef Rel10
     if((Srb_id & RAB_OFFSET) == MCCH){
-      if(eNB_rrc_inst[Mod_id].MCCH_MESS[mbsfn_sync_area].Active==0) return 0; // this parameter is set in function init_mcch in rrc_eNB.c                                                                              
+      if(eNB_rrc_inst[Mod_idP].MCCH_MESS[mbsfn_sync_area].Active==0) return 0; // this parameter is set in function init_mcch in rrc_eNB.c
       // this part not needed as it is done in init_mcch 
       /*     if (eNB_rrc_inst[Mod_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area] == 255) {
 	LOG_E(RRC,"[eNB %d] MAC Request for MCCH MESSAGE and MCCH MESSAGE is not initialized\n",Mod_id);
@@ -239,7 +239,7 @@ s8 mac_rrc_lite_data_req(module_id_t Mod_idP, frame_t frameP, u16 Srb_id, u8 Nb_
 	     eNB_rrc_inst[Mod_idP].sizeof_MCCH_MESSAGE[mbsfn_sync_area]);
       
 #ifdef DEBUG_RRC
-      LOG_D(RRC,"[eNB %d] Frame %d : MCCH request => MCCH_MESSAGE \n",Mod_id,frameP);
+      LOG_D(RRC,"[eNB %d] Frame %d : MCCH request => MCCH_MESSAGE \n",Mod_idP,frameP);
       for (i=0;i<eNB_rrc_inst[Mod_idP].sizeof_MCCH_MESSAGE[mbsfn_sync_area];i++)
 	LOG_T(RRC,"%x.",buffer_pP[i]);
       LOG_T(RRC,"\n");
@@ -263,7 +263,7 @@ s8 mac_rrc_lite_data_req(module_id_t Mod_idP, frame_t frameP, u16 Srb_id, u8 Nb_
 #if defined(ENABLE_ITTI)
       {
         MessageDef *message_p;
-        int ccch_size = UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.payload_size;
+        int ccch_size = UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size;
         int sdu_size = sizeof(RRC_MAC_CCCH_DATA_REQ (message_p).sdu);
 
         if (ccch_size > sdu_size) {
@@ -298,14 +298,14 @@ s8 mac_rrc_lite_data_req(module_id_t Mod_idP, frame_t frameP, u16 Srb_id, u8 Nb_
 }
 
 //-------------------------------------------------------------------------------------------//
-s8 mac_rrc_lite_data_ind(module_id_t Mod_idP, frame_t frameP, u16 Srb_id, u8 *Sdu, u16 sdu_size,eNB_flag_t eNB_flagP,u8 eNB_index,u8 mbsfn_sync_area){
+s8 mac_rrc_lite_data_ind(module_id_t Mod_idP, frame_t frameP, u16 Srb_id, u8 *Sdu, u16 sdu_size,eNB_flag_t enb_flagP,u8 eNB_index,u8 mbsfn_sync_area){
 //-------------------------------------------------------------------------------------------//
   SRB_INFO *Srb_info;
   /*
   int si_window;
   */
 
-  if(eNB_flagP == 0){
+  if(enb_flagP == 0){
 
     if(Srb_id == BCCH){
       
@@ -415,7 +415,7 @@ s8 mac_rrc_lite_data_ind(module_id_t Mod_idP, frame_t frameP, u16 Srb_id, u8 *Sd
 #ifdef Rel10
     if ((Srb_id & RAB_OFFSET) == MCCH) {
       LOG_T(RRC,"[UE %d] Frame %d: Received SDU on MBSFN sync area %d for MCCH on SRB %d from eNB %d\n",
-	    Mod_id,frameP, mbsfn_sync_area, Srb_id & RAB_OFFSET,eNB_index);
+          Mod_idP,frameP, mbsfn_sync_area, Srb_id & RAB_OFFSET,eNB_index);
 
 #if defined(ENABLE_ITTI)
       {
@@ -429,17 +429,17 @@ s8 mac_rrc_lite_data_ind(module_id_t Mod_idP, frame_t frameP, u16 Srb_id, u8 *Sd
         }
 
         message_p = itti_alloc_new_message (TASK_MAC_UE, RRC_MAC_MCCH_DATA_IND);
-        RRC_MAC_MCCH_DATA_IND (message_p).frame = frameP;
-        RRC_MAC_MCCH_DATA_IND (message_p).sdu_size = sdu_size;
+        RRC_MAC_MCCH_DATA_IND (message_p).frame           = frameP;
+        RRC_MAC_MCCH_DATA_IND (message_p).sdu_size        = sdu_size;
         memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, sizeof(RRC_MAC_CCCH_DATA_IND (message_p).sdu));
         memcpy (RRC_MAC_MCCH_DATA_IND (message_p).sdu, Sdu, sdu_size);
-        RRC_MAC_MCCH_DATA_IND (message_p).enb_index = eNB_index;
+        RRC_MAC_MCCH_DATA_IND (message_p).enb_index       = eNB_index;
         RRC_MAC_MCCH_DATA_IND (message_p).mbsfn_sync_area = mbsfn_sync_area;
 
         itti_send_msg_to_task (TASK_RRC_UE, Mod_idP + NB_eNB_INST, message_p);
       }
 #else
-      decode_MCCH_Message(Mod_id, frameP, eNB_index, Sdu, sdu_size, mbsfn_sync_area);
+      decode_MCCH_Message(Mod_idP, frameP, eNB_index, Sdu, sdu_size, mbsfn_sync_area);
 #endif
     }
 #endif // Rel10
@@ -490,7 +490,7 @@ void mac_lite_sync_ind(module_id_t Mod_idP,u8 Status){
 }
 
 //-------------------------------------------------------------------------------------------//
-u8 rrc_lite_data_req(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, rb_id_t rb_idP, mui_t muiP, u32 confirmP,
+u8 rrc_lite_data_req(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t enb_flagP, rb_id_t rb_idP, mui_t muiP, u32 confirmP,
                      sdu_size_t sdu_size, u8* buffer_pP, u8 mode) {
 //-------------------------------------------------------------------------------------------//
 #if defined(ENABLE_ITTI)
@@ -499,37 +499,37 @@ u8 rrc_lite_data_req(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t fr
     // Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling).
     u8 *message_buffer;
 
-    message_buffer = itti_malloc (eNB_flag ? TASK_RRC_ENB : TASK_RRC_UE, eNB_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, sdu_size);
+    message_buffer = itti_malloc (enb_flagP ? TASK_RRC_ENB : TASK_RRC_UE, enb_flagP ? TASK_PDCP_ENB : TASK_PDCP_UE, sdu_size);
     memcpy (message_buffer, buffer_pP, sdu_size);
 
-    message_p = itti_alloc_new_message (eNB_flag ? TASK_RRC_ENB : TASK_RRC_UE, RRC_DCCH_DATA_REQ);
-    RRC_DCCH_DATA_REQ (message_p).frame = frameP;
-    RRC_DCCH_DATA_REQ (message_p).enb_flag = eNB_flag;
-    RRC_DCCH_DATA_REQ (message_p).rb_id = rb_id;
-    RRC_DCCH_DATA_REQ (message_p).muip = muiP;
-    RRC_DCCH_DATA_REQ (message_p).confirmp = confirmP;
-    RRC_DCCH_DATA_REQ (message_p).sdu_size = sdu_size;
-    RRC_DCCH_DATA_REQ (message_p).sdu_p = message_buffer;
-    RRC_DCCH_DATA_REQ (message_p).mode = mode;
+    message_p = itti_alloc_new_message (enb_flagP ? TASK_RRC_ENB : TASK_RRC_UE, RRC_DCCH_DATA_REQ);
+    RRC_DCCH_DATA_REQ (message_p).frame     = frameP;
+    RRC_DCCH_DATA_REQ (message_p).enb_flag  = enb_flagP;
+    RRC_DCCH_DATA_REQ (message_p).rb_id     = rb_idP;
+    RRC_DCCH_DATA_REQ (message_p).muip      = muiP;
+    RRC_DCCH_DATA_REQ (message_p).confirmp  = confirmP;
+    RRC_DCCH_DATA_REQ (message_p).sdu_size  = sdu_size;
+    RRC_DCCH_DATA_REQ (message_p).sdu_p     = message_buffer;
+    RRC_DCCH_DATA_REQ (message_p).mode      = mode;
     RRC_DCCH_DATA_REQ (message_p).eNB_index = enb_mod_idP;
-    RRC_DCCH_DATA_REQ (message_p).ue_index = ue_mod_idP;
+    RRC_DCCH_DATA_REQ (message_p).ue_index  = ue_mod_idP;
 
-    itti_send_msg_to_task (eNB_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, eNB_flag ? enb_mod_idP : NB_eNB_INST + ue_mod_idP, message_p);
+    itti_send_msg_to_task (enb_flagP ? TASK_PDCP_ENB : TASK_PDCP_UE, enb_flagP ? enb_mod_idP : NB_eNB_INST + ue_mod_idP, message_p);
     return TRUE; // TODO should be changed to a CNF message later, currently RRC lite does not used the returned value anyway.
 
   }
 #else
-  return pdcp_data_req (enb_mod_idP, ue_mod_idP, frameP, eNB_flagP, rb_idP, muiP, confirmP, sdu_size, buffer_pP, mode);
+  return pdcp_data_req (enb_mod_idP, ue_mod_idP, frameP, enb_flagP, rb_idP, muiP, confirmP, sdu_size, buffer_pP, mode);
 #endif
 }
 
 //-------------------------------------------------------------------------------------------//
-void rrc_lite_data_ind(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP,rb_id_t Srb_id, sdu_size_t sdu_sizeP,u8 *buffer_pP){
+void rrc_lite_data_ind(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t enb_flagP,rb_id_t Srb_id, sdu_size_t sdu_sizeP,u8 *buffer_pP){
 //-------------------------------------------------------------------------------------------//
   u8 DCCH_index = Srb_id;
   u8_t Mod_id;
 
-  if (eNB_flagP == 0) {
+  if (enb_flagP == 0) {
     Mod_id = ue_mod_idP + NB_eNB_INST;
     LOG_N(RRC, "[UE %d] Frame %d: received a DCCH %d message on SRB %d with Size %d from eNB %d\n",
           ue_mod_idP, frameP, DCCH_index,Srb_id-1,sdu_sizeP, enb_mod_idP);
@@ -545,10 +545,10 @@ void rrc_lite_data_ind(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t
     // Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling).
     u8 *message_buffer;
 
-    message_buffer = itti_malloc (eNB_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, eNB_flag ? TASK_RRC_ENB : TASK_RRC_UE, sdu_size);
+    message_buffer = itti_malloc (enb_flagP ? TASK_PDCP_ENB : TASK_PDCP_UE, enb_flagP ? TASK_RRC_ENB : TASK_RRC_UE, sdu_sizeP);
     memcpy (message_buffer, buffer_pP, sdu_sizeP);
 
-    message_p = itti_alloc_new_message (eNB_flagP ? TASK_PDCP_ENB : TASK_PDCP_UE, RRC_DCCH_DATA_IND);
+    message_p = itti_alloc_new_message (enb_flagP ? TASK_PDCP_ENB : TASK_PDCP_UE, RRC_DCCH_DATA_IND);
     RRC_DCCH_DATA_IND (message_p).frame      = frameP;
     RRC_DCCH_DATA_IND (message_p).dcch_index = DCCH_index;
     RRC_DCCH_DATA_IND (message_p).sdu_size   = sdu_sizeP;
@@ -556,10 +556,10 @@ void rrc_lite_data_ind(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t
     RRC_DCCH_DATA_IND (message_p).ue_index   = ue_mod_idP;
     RRC_DCCH_DATA_IND (message_p).eNB_index  = enb_mod_idP;
 
-    itti_send_msg_to_task (eNB_flag ? TASK_RRC_ENB : TASK_RRC_UE, Mod_id, message_p);
+    itti_send_msg_to_task (enb_flagP ? TASK_RRC_ENB : TASK_RRC_UE, Mod_id, message_p);
   }
 #else
-  if (eNB_flagP ==1) {
+  if (enb_flagP ==1) {
     rrc_eNB_decode_dcch(enb_mod_idP,frameP,DCCH_index,ue_mod_idP,buffer_pP,sdu_sizeP);
   }
   else {
@@ -616,9 +616,9 @@ void rrc_lite_out_of_sync_ind(module_id_t Mod_idP, frame_t frameP, u16 eNB_index
 }
 
 //-------------------------------------------------------------------------------------------//
-int mac_get_rrc_lite_status(module_id_t Mod_idP,eNB_flag_t eNB_flag,u8 index){
+int mac_get_rrc_lite_status(module_id_t Mod_idP,eNB_flag_t enb_flagP,u8 index){
 //-------------------------------------------------------------------------------------------//
-  if(eNB_flag == 1)
+  if(enb_flagP == 1)
     return(eNB_rrc_inst[Mod_idP].Info.UE[index].Status);
   else
     return(UE_rrc_inst[Mod_idP].Info[index].State);
diff --git a/openair2/RRC/LITE/rrc_UE.c b/openair2/RRC/LITE/rrc_UE.c
index 3288723eb7e..b9c11c18771 100644
--- a/openair2/RRC/LITE/rrc_UE.c
+++ b/openair2/RRC/LITE/rrc_UE.c
@@ -2468,7 +2468,7 @@ void rrc_ue_generate_MeasurementReport(u8 eNB_id, u8 UE_id, frame_t frameP) {
 }
 
 // Measurement report triggering, described in 36.331 Section 5.5.4.1: called periodically 
-void ue_measurement_report_triggering(module_id_t Mod_id, u32 frameP,u8 eNB_index) {
+void ue_measurement_report_triggering(module_id_t Mod_id, frame_t frameP,u8 eNB_index) {
   u8               i,j;
   Hysteresis_t     hys;
   TimeToTrigger_t  ttt_ms;
@@ -2554,7 +2554,7 @@ void ue_measurement_report_triggering(module_id_t Mod_id, u32 frameP,u8 eNB_inde
 }
 
 //check_trigger_meas_event(Mod_id, frameP, eNB_index, i,j,ofn,ocn,hys,ofs,ocs,a3_offset,ttt_ms)
-u8 check_trigger_meas_event(module_id_t Mod_id,u32 frameP, u8 eNB_index, u8 ue_cnx_index, u8 meas_index,
+u8 check_trigger_meas_event(module_id_t Mod_id,frame_t frameP, u8 eNB_index, u8 ue_cnx_index, u8 meas_index,
     Q_OffsetRange_t ofn, Q_OffsetRange_t ocn, Hysteresis_t hys,
     Q_OffsetRange_t ofs, Q_OffsetRange_t ocs, long a3_offset, TimeToTrigger_t ttt) {
   u8 eNB_offset;
@@ -2591,7 +2591,7 @@ u8 check_trigger_meas_event(module_id_t Mod_id,u32 frameP, u8 eNB_index, u8 ue_c
 }
 
 #ifdef Rel10
-int decode_MCCH_Message(module_id_t Mod_id, u32 frameP, u8 eNB_index, u8 *Sdu, u8 Sdu_len,u8 mbsfn_sync_area) {
+int decode_MCCH_Message(module_id_t Mod_id, frame_t frameP, u8 eNB_index, u8 *Sdu, u8 Sdu_len,u8 mbsfn_sync_area) {
 
   MCCH_Message_t *mcch=NULL;
   MBSFNAreaConfiguration_r9_t **mcch_message=&UE_rrc_inst[Mod_id].mcch_message[eNB_index];
@@ -2635,7 +2635,7 @@ int decode_MCCH_Message(module_id_t Mod_id, u32 frameP, u8 eNB_index, u8 *Sdu, u
   return 0;
 }
 
-void decode_MBSFNAreaConfiguration(module_id_t Mod_id, u8 eNB_index, u32 frameP,u8 mbsfn_sync_area) {
+void decode_MBSFNAreaConfiguration(module_id_t Mod_id, u8 eNB_index, frame_t frameP,u8 mbsfn_sync_area) {
   LOG_D(RRC,"[UE %d] Frame %d : Number of MCH(s) in the MBSFN Sync Area %d  is %d\n", 
       Mod_id, frameP, mbsfn_sync_area, UE_rrc_inst[Mod_id].mcch_message[eNB_index]->pmch_InfoList_r9.list.count);
   //  store to MAC/PHY necessary parameters for receiving MTCHs
@@ -2733,7 +2733,7 @@ void *rrc_ue_task(void *args_p) {
         /* MAC messages */
       case RRC_MAC_IN_SYNC_IND:
         LOG_D(RRC, "[UE %d] Received %s: frameP %d, eNB %d\n", Mod_id, msg_name,
-            RRC_MAC_IN_SYNC_IND (msg_p).frameP, RRC_MAC_IN_SYNC_IND (msg_p).enb_index);
+            RRC_MAC_IN_SYNC_IND (msg_p).frame, RRC_MAC_IN_SYNC_IND (msg_p).enb_index);
 
         UE_rrc_inst[Mod_id].Info[RRC_MAC_IN_SYNC_IND (msg_p).enb_index].N310_cnt = 0;
         if (UE_rrc_inst[Mod_id].Info[RRC_MAC_IN_SYNC_IND (msg_p).enb_index].T310_active == 1)
@@ -2742,16 +2742,16 @@ void *rrc_ue_task(void *args_p) {
 
       case RRC_MAC_OUT_OF_SYNC_IND:
         LOG_I(RRC, "[UE %d] Received %s: frameP %d, eNB %d\n", Mod_id, msg_name,
-            RRC_MAC_OUT_OF_SYNC_IND (msg_p).frameP, RRC_MAC_OUT_OF_SYNC_IND (msg_p).enb_index);
+            RRC_MAC_OUT_OF_SYNC_IND (msg_p).frame, RRC_MAC_OUT_OF_SYNC_IND (msg_p).enb_index);
 
         UE_rrc_inst[Mod_id].Info[RRC_MAC_OUT_OF_SYNC_IND (msg_p).enb_index].N310_cnt ++;
         break;
 
       case RRC_MAC_BCCH_DATA_IND:
         LOG_D(RRC, "[UE %d] Received %s: frameP %d, eNB %d\n", Mod_id, msg_name,
-            RRC_MAC_BCCH_DATA_IND (msg_p).frameP, RRC_MAC_BCCH_DATA_IND (msg_p).enb_index);
+            RRC_MAC_BCCH_DATA_IND (msg_p).frame, RRC_MAC_BCCH_DATA_IND (msg_p).enb_index);
 
-        decode_BCCH_DLSCH_Message (Mod_id, RRC_MAC_BCCH_DATA_IND (msg_p).frameP,
+        decode_BCCH_DLSCH_Message (Mod_id, RRC_MAC_BCCH_DATA_IND (msg_p).frame,
             RRC_MAC_BCCH_DATA_IND (msg_p).enb_index, RRC_MAC_BCCH_DATA_IND (msg_p).sdu,
             RRC_MAC_BCCH_DATA_IND (msg_p).sdu_size,
             RRC_MAC_BCCH_DATA_IND (msg_p).rsrq, RRC_MAC_BCCH_DATA_IND (msg_p).rsrp);
@@ -2767,23 +2767,23 @@ void *rrc_ue_task(void *args_p) {
 
       case RRC_MAC_CCCH_DATA_IND:
         LOG_I(RRC, "[UE %d] Received %s: frameP %d, eNB %d\n", Mod_id, msg_name,
-            RRC_MAC_CCCH_DATA_IND (msg_p).frameP, RRC_MAC_CCCH_DATA_IND (msg_p).enb_index);
+            RRC_MAC_CCCH_DATA_IND (msg_p).frame, RRC_MAC_CCCH_DATA_IND (msg_p).enb_index);
 
         srb_info_p = &UE_rrc_inst[Mod_id].Srb0[RRC_MAC_CCCH_DATA_IND (msg_p).enb_index];
 
         memcpy (srb_info_p->Rx_buffer.Payload, RRC_MAC_CCCH_DATA_IND (msg_p).sdu,
             RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size);
         srb_info_p->Rx_buffer.payload_size = RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size;
-        rrc_ue_decode_ccch (Mod_id, RRC_MAC_CCCH_DATA_IND (msg_p).frameP, srb_info_p,
+        rrc_ue_decode_ccch (Mod_id, RRC_MAC_CCCH_DATA_IND (msg_p).frame, srb_info_p,
             RRC_MAC_CCCH_DATA_IND (msg_p).enb_index);
         break;
 
 # ifdef Rel10
       case RRC_MAC_MCCH_DATA_IND:
         LOG_I(RRC, "[UE %d] Received %s: frameP %d, eNB %d, mbsfn SA %d\n", Mod_id, msg_name,
-            RRC_MAC_MCCH_DATA_IND (msg_p).frameP, RRC_MAC_MCCH_DATA_IND (msg_p).enb_index, RRC_MAC_MCCH_DATA_IND (msg_p).mbsfn_sync_area);
+            RRC_MAC_MCCH_DATA_IND (msg_p).frame, RRC_MAC_MCCH_DATA_IND (msg_p).enb_index, RRC_MAC_MCCH_DATA_IND (msg_p).mbsfn_sync_area);
 
-        decode_MCCH_Message (Mod_id, RRC_MAC_MCCH_DATA_IND (msg_p).frameP, RRC_MAC_MCCH_DATA_IND (msg_p).enb_index,
+        decode_MCCH_Message (Mod_id, RRC_MAC_MCCH_DATA_IND (msg_p).frame, RRC_MAC_MCCH_DATA_IND (msg_p).enb_index,
             RRC_MAC_MCCH_DATA_IND (msg_p).sdu, RRC_MAC_MCCH_DATA_IND (msg_p).sdu_size,
             RRC_MAC_MCCH_DATA_IND (msg_p).mbsfn_sync_area);
         break;
@@ -2792,9 +2792,9 @@ void *rrc_ue_task(void *args_p) {
 /* PDCP messages */
       case RRC_DCCH_DATA_IND:
         LOG_I(RRC, "[UE %d] Received %s: frameP %d, DCCH %d, eNB %d\n", Mod_id, msg_name,
-            RRC_DCCH_DATA_IND (msg_p).frameP, RRC_DCCH_DATA_IND (msg_p).dcch_index, RRC_DCCH_DATA_IND (msg_p).eNB_index);
+            RRC_DCCH_DATA_IND (msg_p).frame, RRC_DCCH_DATA_IND (msg_p).dcch_index, RRC_DCCH_DATA_IND (msg_p).eNB_index);
 
-        rrc_ue_decode_dcch (Mod_id, RRC_DCCH_DATA_IND (msg_p).frameP,
+        rrc_ue_decode_dcch (Mod_id, RRC_DCCH_DATA_IND (msg_p).frame,
             RRC_DCCH_DATA_IND (msg_p).dcch_index, RRC_DCCH_DATA_IND (msg_p).sdu_p,
             RRC_DCCH_DATA_IND (msg_p).eNB_index);
 
diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c
index 62bdf3b89c7..7262342d8ff 100644
--- a/targets/SIMU/USER/oaisim.c
+++ b/targets/SIMU/USER/oaisim.c
@@ -362,7 +362,7 @@ static Data_Flow_Unit omv_data;
 static module_id_t UE_inst  = 0;
 static module_id_t eNB_inst = 0;
 #ifdef Rel10
-static module_id_t RN_inst=0;
+static module_id_t RN_id    = 0;
 #endif
 
 Packet_OTG_List *otg_pdcp_buffer;
@@ -781,21 +781,21 @@ void *l2l1_task(void *args_p) {
                   if ( oai_emulation.info.frame_type == 0) {
                       // RN == UE
                       if (frame>0) {
-                          if (PHY_vars_UE_g[UE_id]->UE_mode[0] != NOT_SYNCHED) {
+                          if (PHY_vars_UE_g[UE_inst]->UE_mode[0] != NOT_SYNCHED) {
                               LOG_D(EMU,"[RN %d] PHY procedures UE %d for frame %d, slot %d (subframe TX %d, RX %d)\n",
-                                  RN_id, UE_id, frame, slot, next_slot >> 1,last_slot>>1);
-                              PHY_vars_UE_g[UE_id]->frame = frame;
-                              phy_procedures_UE_lte (last_slot, next_slot, PHY_vars_UE_g[UE_id], 0, abstraction_flag,normal_txrx,
+                                  RN_id, UE_inst, frame, slot, next_slot >> 1,last_slot>>1);
+                              PHY_vars_UE_g[UE_inst]->frame = frame;
+                              phy_procedures_UE_lte (last_slot, next_slot, PHY_vars_UE_g[UE_inst], 0, abstraction_flag,normal_txrx,
                                   r_type, PHY_vars_RN_g[RN_id]);
                           }
                           else if (last_slot == (LTE_SLOTS_PER_FRAME-2)) {
-                              initial_sync(PHY_vars_UE_g[UE_id],normal_txrx);
+                              initial_sync(PHY_vars_UE_g[UE_inst],normal_txrx);
                           }
                       }
                       // RN == eNB
                       LOG_D(EMU,"[RN %d] PHY procedures eNB %d for frame %d, slot %d (subframe TX %d, RX %d)\n",
-                          RN_id, eNB_id, frame, slot, next_slot >> 1,last_slot>>1);
-                      phy_procedures_eNB_lte (last_slot, next_slot, PHY_vars_eNB_g[eNB_id], abstraction_flag,
+                          RN_id, eNB_inst, frame, slot, next_slot >> 1,last_slot>>1);
+                      phy_procedures_eNB_lte (last_slot, next_slot, PHY_vars_eNB_g[eNB_inst], abstraction_flag,
                           r_type, PHY_vars_RN_g[RN_id]);
                   }
                   else {
diff --git a/targets/SIMU/USER/oaisim_functions.c b/targets/SIMU/USER/oaisim_functions.c
index 2a8575af6ec..e20a0347183 100644
--- a/targets/SIMU/USER/oaisim_functions.c
+++ b/targets/SIMU/USER/oaisim_functions.c
@@ -1030,7 +1030,7 @@ void update_ocm() {
 }
 
 #ifdef OPENAIR2
-void update_otg_eNB(module_id_t module_instP, unsigned int ctime) {
+void update_otg_eNB(module_id_t module_idP, unsigned int ctime) {
 #if defined(USER_MODE) && defined(OAI_EMU)
   if (oai_emulation.info.otg_enabled ==1 ) {
 
@@ -1040,27 +1040,26 @@ void update_otg_eNB(module_id_t module_instP, unsigned int ctime) {
       for (dst_id = 0; dst_id < NUMBER_OF_UE_MAX; dst_id++) {
           for_times += 1;
           // generate traffic if the ue is rrc reconfigured state
-          if (mac_get_rrc_status(module_instP, 1/*eNB_flag*/, dst_id) > 2 /*RRC_CONNECTED*/ ) {
+          if (mac_get_rrc_status(module_idP, 1/*eNB_flag*/, dst_id) > 2 /*RRC_CONNECTED*/ ) {
 
               for (app_id=0; app_id<MAX_NUM_APPLICATION; app_id++){
                   otg_pkt = malloc (sizeof(Packet_otg_elt));
                   if_times += 1;
 
-                  (otg_pkt->otg_pkt).sdu_buffer = (u8*) packet_gen(module_instP, dst_id + NB_eNB_INST, app_id, ctime, &((otg_pkt->otg_pkt).sdu_buffer_size));
+                  (otg_pkt->otg_pkt).sdu_buffer = (u8*) packet_gen(module_idP, dst_id + NB_eNB_INST, app_id, ctime, &((otg_pkt->otg_pkt).sdu_buffer_size));
 
                   if ((otg_pkt->otg_pkt).sdu_buffer != NULL) {
                       otg_times += 1;
                       (otg_pkt->otg_pkt).rb_id = dst_id * NB_RB_MAX + DTCH; // app could be binded to a given DRB
-                      (otg_pkt->otg_pkt).module_id = module_instP;
+                      (otg_pkt->otg_pkt).module_id = module_idP;
                       (otg_pkt->otg_pkt).dst_id = dst_id;
                       (otg_pkt->otg_pkt).is_ue = 0;
                       (otg_pkt->otg_pkt).mode = PDCP_DATA_PDU;
                       //Adding the packet to the OTG-PDCP buffer
-                      pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[module_instP]));
+                      pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[module_idP]));
                       LOG_I(EMU, "[eNB %d] ADD pkt to OTG buffer with size %d for dst %d on rb_id %d for app id %d \n",
                           (otg_pkt->otg_pkt).module_id, otg_pkt->otg_pkt.sdu_buffer_size, (otg_pkt->otg_pkt).dst_id,(otg_pkt->otg_pkt).rb_id, app_id);
                   } else {
-                      //LOG_I(EMU, "OTG returns null \n");
                       free(otg_pkt);
                       otg_pkt=NULL;
                   }
@@ -1078,20 +1077,20 @@ void update_otg_eNB(module_id_t module_instP, unsigned int ctime) {
       for (service_id = 0; service_id < 2 ; service_id++) { //maxServiceCount
           for (session_id = 0; session_id < 2; session_id++) { // maxSessionPerPMCH
               //   LOG_I(OTG,"DUY:frame %d, pdcp_mbms_array[module_id][rb_id].instanciated_instance is %d\n",frame,pdcp_mbms_array[module_id][service_id*maxSessionPerPMCH + session_id].instanciated_instance);
-              if (pdcp_mbms_array[module_instP][service_id*maxSessionPerPMCH + session_id].instanciated_instance == module_instP + 1){ // this service/session is configured
+              if (pdcp_mbms_array[module_idP][service_id*maxSessionPerPMCH + session_id].instanciated_instance == module_idP + 1){ // this service/session is configured
 
                   otg_pkt = malloc (sizeof(Packet_otg_elt));
                   // LOG_T(OTG,"multicast packet gen for (service/mch %d, session/lcid %d, rb_id %d)\n", service_id, session_id, service_id*maxSessionPerPMCH + session_id);
-                  rb_id = pdcp_mbms_array[module_id][service_id*maxSessionPerPMCH + session_id].rb_id;
-                  (otg_pkt->otg_pkt).sdu_buffer = (u8*) packet_gen_multicast(module_instP, session_id, ctime, &((otg_pkt->otg_pkt).sdu_buffer_size));
+                  rb_id = pdcp_mbms_array[module_idP][service_id*maxSessionPerPMCH + session_id].rb_id;
+                  (otg_pkt->otg_pkt).sdu_buffer = (u8*) packet_gen_multicast(module_idP, session_id, ctime, &((otg_pkt->otg_pkt).sdu_buffer_size));
                   if ((otg_pkt->otg_pkt).sdu_buffer != NULL) {
                       (otg_pkt->otg_pkt).rb_id = rb_id;
-                      (otg_pkt->otg_pkt).module_id = module_id;
+                      (otg_pkt->otg_pkt).module_id = module_idP;
                       (otg_pkt->otg_pkt).dst_id = session_id;
                       (otg_pkt->otg_pkt).is_ue = 0;
                       //Adding the packet to the OTG-PDCP buffer
                       (otg_pkt->otg_pkt).mode = PDCP_TM;
-                      pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[module_instP]));
+                      pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[module_idP]));
                       LOG_I(EMU, "[eNB %d] ADD packet (%p) multicast to OTG buffer for dst %d on rb_id %d\n",
                           (otg_pkt->otg_pkt).module_id, otg_pkt, (otg_pkt->otg_pkt).dst_id,(otg_pkt->otg_pkt).rb_id);
                   } else {
@@ -1108,15 +1107,15 @@ void update_otg_eNB(module_id_t module_instP, unsigned int ctime) {
 	      for (service_id = 0; service_id < 2 ; service_id++) { //maxServiceCount
 		for (session_id = 0; session_id < 2; session_id++) { // maxSessionPerPMCH
 		  //   LOG_I(OTG,"DUY:frame %d, pdcp_mbms_array[module_id][rb_id].instanciated_instance is %d\n",frame,pdcp_mbms_array[module_id][service_id*maxSessionPerPMCH + session_id].instanciated_instance);
-		  if ((pdcp_mbms_array[module_id][service_id*maxSessionPerPMCH + session_id].instanciated_instance== module_id + 1) && (eNB_flag == 1)){ // this service/session is configured
+		  if ((pdcp_mbms_array[module_idP][service_id*maxSessionPerPMCH + session_id].instanciated_instance== module_idP + 1) && (eNB_flag == 1)){ // this service/session is configured
 		    // LOG_T(OTG,"multicast packet gen for (service/mch %d, session/lcid %d)\n", service_id, session_id);
 		    // Duy add
 		    LOG_I(OTG, "frame %d, multicast packet gen for (service/mch %d, session/lcid %d, rb_id %d)\n",frame, service_id, session_id,service_id*maxSessionPerPMCH + session_id);
 		    // end Duy add
 		    rb_id = pdcp_mbms_array[module_id][service_id*maxSessionPerPMCH + session_id].rb_id;
-		    otg_pkt=(u8*) packet_gen_multicast(module_id, session_id, ctime, &pkt_size);
+		    otg_pkt=(u8*) packet_gen_multicast(module_idP, session_id, ctime, &pkt_size);
 		    if (otg_pkt != NULL) {
-		      LOG_D(OTG,"[eNB %d] sending a multicast packet from module %d on rab id %d (src %d, dst %d) pkt size %d\n", eNB_index, module_id, rb_id, module_id, session_id, pkt_size);
+		      LOG_D(OTG,"[eNB %d] sending a multicast packet from module %d on rab id %d (src %d, dst %d) pkt size %d\n", eNB_index, module_idP, rb_id, module_idP, session_id, pkt_size);
 		      pdcp_data_req(module_id, frame, eNB_flag, rb_id, RLC_MUI_UNDEFINED, RLC_SDU_CONFIRM_NO, pkt_size, otg_pkt,PDCP_TM);
 		      free(otg_pkt);
 		    }
@@ -1134,7 +1133,7 @@ void update_otg_eNB(module_id_t module_instP, unsigned int ctime) {
       //    } // end multicast traffic
 #endif
 
-      //LOG_I(EMU, "[eNB %d] update OTG nb_elts = %d \n", module_id, otg_pdcp_buffer[module_id].nb_elements);
+      //LOG_I(EMU, "[eNB %d] update OTG nb_elts = %d \n", module_id, otg_pdcp_buffer[module_idP].nb_elements);
 
       //free(otg_pkt);
       //otg_pkt = NULL;
@@ -1149,11 +1148,11 @@ void update_otg_eNB(module_id_t module_instP, unsigned int ctime) {
               if (otg_pkt != NULL) {
                   rb_id = dst_id * NB_RB_MAX + DTCH;
                   (otg_pkt->otg_pkt).rb_id = rb_id;
-                  (otg_pkt->otg_pkt).module_id = module_instP;
+                  (otg_pkt->otg_pkt).module_id = module_idP;
                   (otg_pkt->otg_pkt).is_ue = 0;
                   (otg_pkt->otg_pkt).mode = PDCP_DATA_PDU;
                   //Adding the packet to the OTG-PDCP buffer
-                  pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[module_instP]));
+                  pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[module_idP]));
                   LOG_I(EMU, "[eNB %d] ADD pkt to OTG buffer for dst %d on rb_id %d\n", (otg_pkt->otg_pkt).module_id, (otg_pkt->otg_pkt).dst_id,(otg_pkt->otg_pkt).rb_id);
               } else {
                   //LOG_I(EMU, "OTG returns null \n");
-- 
GitLab