diff --git a/ci-scripts/conf_files/enb.band13.tm1.50PRB.emtc.conf b/ci-scripts/conf_files/enb.band13.tm1.50PRB.emtc.conf
new file mode 100644
index 0000000000000000000000000000000000000000..e3d3402c1c64bd95503f5ad712f91c1772457da7
--- /dev/null
+++ b/ci-scripts/conf_files/enb.band13.tm1.50PRB.emtc.conf
@@ -0,0 +1,443 @@
+Active_eNBs = ( "eNB_Eurecom_LTEBox");
+# Asn1_verbosity, choice in: none, info, annoying
+Asn1_verbosity = "none";
+
+eNBs =
+(
+ {
+    ////////// Identification parameters:
+    eNB_ID    =  0xe00;
+
+    cell_type =  "CELL_MACRO_ENB";
+
+    eNB_name  =  "eNB_Eurecom_LTEBox";
+
+    // Tracking area code, 0x0000 and 0xfffe are reserved values
+    tracking_area_code  =  "1";
+
+    plmn_list = ( { mcc = 208; mnc = 93; mnc_length = 2;} );
+
+    tr_s_preference     = "local_mac"
+
+    ////////// Physical parameters:
+
+    component_carriers = (
+    {
+      node_function                             = "3GPP_eNodeB";
+      node_timing                               = "synch_to_ext_device";
+      node_synch_ref                            = 0;
+      frame_type                                = "FDD";
+      tdd_config                                = 3;
+      tdd_config_s                              = 0;
+      prefix_type                               = "NORMAL";
+      eutra_band                                = 13;
+      downlink_frequency                        = 751000000L;
+      uplink_frequency_offset                   = 31000000;
+      Nid_cell                                  = 0;
+      N_RB_DL                                   = 50;
+      Nid_cell_mbsfn                            = 0;
+      nb_antenna_ports                          = 1;
+      nb_antennas_tx                            = 1;
+      nb_antennas_rx                            = 1;
+      tx_gain                                   = 90;
+      rx_gain                                   = 110;
+      pbch_repetition                           = "FALSE";
+      prach_root                                = 0;
+      prach_config_index                        = 0;
+      prach_high_speed                          = "DISABLE";
+      prach_zero_correlation                    = 1;
+      prach_freq_offset                         = 1;
+      pucch_delta_shift                         = 1;
+      pucch_nRB_CQI                             = 1;
+      pucch_nCS_AN                              = 0;    
+      pucch_n1_AN                               = 32;
+      pdsch_referenceSignalPower                = -27;
+      pdsch_p_b                                 = 0;
+      pusch_n_SB                                = 1;
+      pusch_enable64QAM                         = "DISABLE";
+      pusch_hoppingMode                         = "interSubFrame";
+      pusch_hoppingOffset                       = 0; 
+      pusch_groupHoppingEnabled                 = "ENABLE";
+      pusch_groupAssignment                     = 0;
+      pusch_sequenceHoppingEnabled              = "DISABLE";
+      pusch_nDMRS1                              = 1;
+      phich_duration                            = "NORMAL";
+      phich_resource                            = "ONESIXTH";
+      srs_enable                                = "DISABLE"; 
+      /*  srs_BandwidthConfig                   =; 
+      srs_SubframeConfig                        =;
+      srs_ackNackST                             =;
+      srs_MaxUpPts                              =;*/
+
+      pusch_p0_Nominal                          = -96;
+      pusch_alpha                               = "AL1";
+      pucch_p0_Nominal                          = -104;
+      msg3_delta_Preamble                       = 6;
+      pucch_deltaF_Format1                      = "deltaF2";             
+      pucch_deltaF_Format1b                     = "deltaF3";            
+      pucch_deltaF_Format2                      = "deltaF0";            
+      pucch_deltaF_Format2a                     = "deltaF0";            
+      pucch_deltaF_Format2b                     = "deltaF0";            
+
+      rach_numberOfRA_Preambles                 = "n64"; #64 
+      rach_preamblesGroupAConfig                = "DISABLE"; 
+      /*
+      rach_sizeOfRA_PreamblesGroupA             = ;
+      rach_messageSizeGroupA                    = ;
+      rach_messagePowerOffsetGroupB             = ;
+      */
+      rach_powerRampingStep                     = 4;
+      rach_preambleInitialReceivedTargetPower   = -108;
+      rach_preambleTransMax                     = 10;
+      rach_raResponseWindowSize                 = 10;
+      rach_macContentionResolutionTimer         = 48;
+      rach_maxHARQ_Msg3Tx                       = 4;
+
+      pcch_default_PagingCycle                  = "rf128"; #128
+      pcch_nB                                   = "oneT";
+      bcch_modificationPeriodCoeff              = 2;
+      ue_TimersAndConstants_t300                = "ms1000";
+      ue_TimersAndConstants_t301                = "ms1000";
+      ue_TimersAndConstants_t310                = "ms1000";
+      ue_TimersAndConstants_t311                = "ms10000";
+      ue_TimersAndConstants_n310                = "n20";
+      ue_TimersAndConstants_n311                = "n1";
+      ue_TransmissionMode                       = "tm1";
+
+      # eMTC Parameters
+      emtc_parameters : 
+      {
+          eMTC_configured                       = 1;
+          #hyperSFN_r13                               = 0;
+          #eDRX_Allowed_r13                           = 0;
+          #q_QualMinRSRQ_CE_r13                       = ;
+
+          #SIB1
+          schedulingInfoSIB1_BR_r13                   = 4;
+
+          #system_info_value_tag_SI = 
+          #(
+          #    {
+          #        systemInfoValueTagSi_r13 = 0;
+          #    }
+          #);
+
+          cellSelectionInfoCE_r13                     = "ENABLE";
+          q_RxLevMinCE_r13                            = -70;
+          bandwidthReducedAccessRelatedInfo_r13       = "ENABLE"   
+          si_WindowLength_BR_r13                      = "ms20";    #0
+          si_RepetitionPattern_r13                    = "everyRF"; #0
+
+          scheduling_info_br =
+          (
+              {
+                  si_Narrowband_r13 = 8;
+                  si_TBS_r13        = 5;
+              }
+         );
+
+          fdd_DownlinkOrTddSubframeBitmapBR_r13     = "subframePattern40-r13"; 
+          fdd_DownlinkOrTddSubframeBitmapBR_val_r13 = 0xFFFFFFFFFF;
+          startSymbolBR_r13                           = 2;
+          si_HoppingConfigCommon_r13                  = "off"; #1; # Note: 1==OFF !
+          si_ValidityTime_r13                         = "true"; #0
+
+          freqHoppingParametersDL_r13                 = "DISABLE"
+          mpdcch_pdsch_HoppingNB_r13                  = "nb2"; #0
+          interval_DLHoppingConfigCommonModeA_r13     = "interval-FDD-r13"
+          interval_DLHoppingConfigCommonModeA_r13_val = 0;
+          interval_DLHoppingConfigCommonModeB_r13     = "interval-FDD-r13"
+          interval_DLHoppingConfigCommonModeB_r13_val = 0;
+          mpdcch_pdsch_HoppingOffset_r13              = 1;
+
+
+          # SIB23
+          frame_type                                = "FDD";
+          preambleTransMax_CE_r13                   = 10; #6
+
+          rach_numberOfRA_Preambles                 = 60; #14
+          rach_powerRampingStep                     = 4;
+          rach_preambleInitialReceivedTargetPower   = -110;           
+          rach_preambleTransMax                     = 10;
+          rach_raResponseWindowSize                 = 10;
+          rach_macContentionResolutionTimer         = 64;
+          rach_maxHARQ_Msg3Tx                       = 4;
+
+          # max size for this array is 4
+          rach_CE_LevelInfoList_r13 = 
+          (
+              {
+                  firstPreamble_r13                 = 60;
+                  lastPreamble_r13                  = 63;
+                  ra_ResponseWindowSize_r13         = 20; #0
+                  mac_ContentionResolutionTimer_r13 = 80; #0
+                  rar_HoppingConfig_r13             = "off";  #1;
+              }
+          );
+
+          # BCCH CONFIG          
+          bcch_modificationPeriodCoeff              = 2;
+
+          #PCCH Config
+          pcch_default_PagingCycle                  = "rf128"; #128
+          pcch_nB                                   = "oneT";
+
+          #PRACH Config
+          prach_root                                = 89;
+          prach_config_index                        = 0;
+          prach_high_speed                          = "DISABLE";
+          prach_zero_correlation                    = 1;
+          prach_freq_offset                         = 1;
+
+          #PDSCH Config Common          
+          pdsch_referenceSignalPower                = -27
+          pdsch_p_b                                 = 0;
+
+
+          # PUSCH Config Common
+          pusch_n_SB                                = 1;
+          pusch_hoppingMode                         = "interSubFrame";
+          pusch_hoppingOffset                       = 0;
+          pusch_enable64QAM                         = "DISABLE";
+          pusch_groupHoppingEnabled                 = "ENABLE";
+          pusch_groupAssignment                     = 0;
+          pusch_sequenceHoppingEnabled              = "DISABLE";
+          pusch_nDMRS1                              = 1;
+
+          # PUCCH Config Common
+          pucch_delta_shift                         = 1;
+          pucch_nRB_CQI                             = 0;
+          pucch_nCS_AN                              = 0;
+          pucch_n1_AN                               = 32;
+
+          pusch_p0_Nominal                          = -96;
+          pusch_alpha                               = "AL1";
+          pucch_p0_Nominal                          = -104;
+          pucch_deltaF_Format1                      = "deltaF0"; 
+          pucch_deltaF_Format1b                     = "deltaF3";            
+          pucch_deltaF_Format2                      = "deltaF0";           
+          pucch_deltaF_Format2a                     = "deltaF0";            
+          pucch_deltaF_Format2b                     = "deltaF0";
+
+          msg3_delta_Preamble                       = 6;
+
+
+          prach_ConfigCommon_v1310                  = "ENABLE";
+ 
+          mpdcch_startSF_CSS_RA_r13                 = "fdd-r13";
+          mpdcch_startSF_CSS_RA_r13_val             = "v1"; #0
+          prach_HoppingOffset_r13                   = 0;
+
+         
+          pdsch_maxNumRepetitionCEmodeA_r13         = "r16"; #0
+          #pdsch_maxNumRepetitionCEmodeB_r13         = "r384"; # NULL - 2
+
+          pusch_maxNumRepetitionCEmodeA_r13         = "r8"; #0
+          #pusch_maxNumRepetitionCEmodeB_r13         = "r768"; #4 #NULL
+          #pusch_HoppingOffset_v1310                 = 5; #NULL
+
+          # max size for this array is 3
+          rsrp_range_list =
+          (
+              {
+                  rsrp_range_br = 0;
+              }
+          );
+
+          # max size for this array is 4
+          prach_parameters_ce_r13 = 
+          (
+              {
+                  prach_config_index_br                     = 3;
+                  prach_freq_offset_br                      = 2;
+                  prach_StartingSubframe_r13                = 2;
+                  maxNumPreambleAttemptCE_r13               = 10; #6
+                  numRepetitionPerPreambleAttempt_r13       = 1;  #0
+                  mpdcch_NumRepetition_RA_r13               = 1;  #0
+                  prach_HoppingConfig_r13                   = 0;  #1
+                  max_available_narrow_band                 = [3]; 
+             }
+          );
+
+          n1PUCCH_AN_InfoList_r13 = 
+          (
+              {
+                  pucch_info_value = 0;
+              }
+          );
+          
+
+          ue_TimersAndConstants_t300                = "ms1000";
+          ue_TimersAndConstants_t301                = "ms400";
+          ue_TimersAndConstants_t310                = "ms50";
+          ue_TimersAndConstants_t311                = "ms30000";
+          ue_TimersAndConstants_n310                = "n1";
+          ue_TimersAndConstants_n311                = "n10";
+          ue_TransmissionMode                       = "tm1";
+
+          pcch_config_v1310 :
+          {
+              paging_narrowbands_r13           = 1;
+              mpdcch_numrepetition_paging_r13  = "r1";         #0
+              #nb_v1310                        = "one256thT";  #2
+          }
+
+
+          pucch_NumRepetitionCE_Msg4_Level0_r13      = "n1";  #0 
+          #pucch_NumRepetitionCE_Msg4_Level1_r13     = "n2";  #1
+          #pucch_NumRepetitionCE_Msg4_Level2_r13     = "n16"; #2
+          #pucch_NumRepetitionCE_Msg4_Level3_r13     = "n32"; #3
+
+          sib2_freq_hoppingParameters_r13 : 
+          {
+             #sib2_mpdcch_pdsch_hoppingNB_r13                   = "nb2"; #0
+             #sib2_interval_DLHoppingConfigCommonModeA_r13      = "FDD"; # choice -> (0, FDD) (1, TDD)
+             #sib2_interval_DLHoppingConfigCommonModeA_r13_val  = "int1";          
+             #sib2_interval_DLHoppingConfigCommonModeB_r13      = "FDD"; # choice -> (0, FDD) (1, TDD)
+             #sib2_interval_DLHoppingConfigCommonModeB_r13_val  = "int2";        
+
+             sib2_interval_ULHoppingConfigCommonModeA_r13      = "FDD";  # choice -> (0, FDD) (1, TDD)
+             sib2_interval_ULHoppingConfigCommonModeA_r13_val  = "int4"; #2          
+#            sib2_interval_ULHoppingConfigCommonModeB_r13      = "FDD";  # choice -> (0, FDD) (1, TDD)
+#            sib2_interval_ULHoppingConfigCommonModeB_r13_val  = "int2"; #0
+
+#             sib2_mpdcch_pdsch_hoppingOffset_r13               = 1;
+          }
+
+          rach_preamblesGroupAConfig                = "DISABLE";
+          
+          phich_duration                            = "NORMAL";
+          phich_resource                            = "ONESIXTH";
+          srs_enable                                = "DISABLE";
+          
+      }
+
+
+
+}
+
+
+
+
+    );
+
+
+    srb1_parameters :
+    {
+        # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500]
+        timer_poll_retransmit    = 80;
+
+        # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200]
+        timer_reordering         = 35;
+
+        # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500]
+        timer_status_prohibit    = 0;
+
+        # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)]
+        poll_pdu                 =  4;
+
+        # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)]
+        poll_byte                =  99999;
+
+        # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32]
+        max_retx_threshold       =  4;
+    }
+
+    # ------- SCTP definitions
+    SCTP :
+    {
+        # Number of streams to use in input/output
+        SCTP_INSTREAMS  = 2;
+        SCTP_OUTSTREAMS = 2;
+    };
+
+
+    ////////// MME parameters:
+    mme_ip_address      = ( { ipv4       = "CI_MME_IP_ADDR";
+                              ipv6       = "192:168:30::17";
+                              active     = "yes";
+                              preference = "ipv4";
+                            }
+                          );
+
+    NETWORK_INTERFACES :
+    {
+        ENB_INTERFACE_NAME_FOR_S1_MME            = "eth0";
+        ENB_IPV4_ADDRESS_FOR_S1_MME              = "CI_ENB_IP_ADDR";
+        ENB_INTERFACE_NAME_FOR_S1U               = "eth0";
+        ENB_IPV4_ADDRESS_FOR_S1U                 = "CI_ENB_IP_ADDR";
+        ENB_PORT_FOR_S1U                         = 2152; # Spec 2152
+        ENB_IPV4_ADDRESS_FOR_X2C                 = "CI_ENB_IP_ADDR";
+        ENB_PORT_FOR_X2C                         = 36422; # Spec 36422
+    };
+
+    log_config :
+    {
+      global_log_level                      ="info";
+      global_log_verbosity                  ="medium";
+      hw_log_level                          ="info";
+      hw_log_verbosity                      ="medium";
+      phy_log_level                         ="info";
+      phy_log_verbosity                     ="medium";
+      mac_log_level                         ="info";
+      mac_log_verbosity                     ="high";
+      rlc_log_level                         ="info";
+      rlc_log_verbosity                     ="medium";
+      pdcp_log_level                        ="info";
+      pdcp_log_verbosity                    ="medium";
+      rrc_log_level                         ="info";
+      rrc_log_verbosity                     ="medium";
+   };
+  }
+);
+
+MACRLCs = (
+        {	
+        num_cc	 = 1;
+        tr_s_preference = "local_L1";
+        tr_n_preference = "local_RRC";
+	phy_test_mode = 0;
+        puSch10xSnr     =  200;
+        puCch10xSnr     =  200;
+        }  
+);
+
+L1s = (
+      {
+      num_cc = 1;
+      tr_n_preference = "local_mac";
+      }  
+);
+
+RUs = (
+    {     
+        local_rf       = "yes"
+        nb_tx          = 1
+        nb_rx          = 1
+        att_tx         = 0
+        att_rx         = 0;
+        bands          = [13];
+        max_pdschReferenceSignalPower = -27;
+        max_rxgain                    = 125;
+        eNB_instances  = [0];
+    }
+);  
+
+log_config :
+     {
+       global_log_level                      ="info";
+       global_log_verbosity                  ="medium";
+       hw_log_level                          ="info";
+       hw_log_verbosity                      ="medium";
+       phy_log_level                         ="info";
+       phy_log_verbosity                     ="medium";
+       mac_log_level                         ="info";
+       mac_log_verbosity                     ="high";
+       rlc_log_level                         ="info";
+       rlc_log_verbosity                     ="medium";
+       pdcp_log_level                        ="info";
+       pdcp_log_verbosity                    ="medium";
+       rrc_log_level                         ="info";
+       rrc_log_verbosity                     ="medium";
+    };
+
diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt
index 8f6396f8298d0084b30ea8b49dec0bd554e36183..ecb9b314f25f4918490333fe0dffe690f97011be 100644
--- a/cmake_targets/CMakeLists.txt
+++ b/cmake_targets/CMakeLists.txt
@@ -1372,6 +1372,8 @@ set (MAC_SRC_UE
 set (ENB_APP_SRC
   ${OPENAIR2_DIR}/ENB_APP/enb_app.c
   ${OPENAIR2_DIR}/ENB_APP/enb_config.c
+  ${OPENAIR2_DIR}/ENB_APP/enb_config_SL.c
+  ${OPENAIR2_DIR}/ENB_APP/enb_config_eMTC.c
   ${OPENAIR2_DIR}/ENB_APP/RRC_config_tools.c
   )
 
diff --git a/cmake_targets/at_commands/CMakeLists.txt b/cmake_targets/at_commands/CMakeLists.txt
old mode 100755
new mode 100644
diff --git a/cmake_targets/build_ue b/cmake_targets/build_ue
old mode 100644
new mode 100755
diff --git a/cmake_targets/tools/exmimo2_2brxg.lime b/cmake_targets/tools/exmimo2_2brxg.lime
old mode 100755
new mode 100644
diff --git a/cmake_targets/tools/run_ue_s1 b/cmake_targets/tools/run_ue_s1
old mode 100644
new mode 100755
diff --git a/common/utils/collection/queue.h b/common/utils/collection/queue.h
old mode 100755
new mode 100644
diff --git a/common/utils/collection/tree.h b/common/utils/collection/tree.h
old mode 100755
new mode 100644
diff --git a/openair1/PHY/CODING/crc_byte.c b/openair1/PHY/CODING/crc_byte.c
index f2f7e4e5c7d213e53c3fab1c392fc042c37d3715..06a43fdb79242eed9636c489c00d6ef9c55758d3 100644
--- a/openair1/PHY/CODING/crc_byte.c
+++ b/openair1/PHY/CODING/crc_byte.c
@@ -32,21 +32,6 @@
 
 #include "PHY/types.h"
 
-// For initialization && verification purposes, bit by bit implementation with any polynomial
-// The first bit is in the MSB of each byte
-
-// Reference 38.212 V15.1.1 Section 5.1 (36-212 v8.6.0 , pp 8-9)
-// The highest degree is set by default
-/** 1000 0110 0100 1100 1111 1011  D^24 + D^23 + D^18 + D^17 + D^14 + D^11 + D^10 + D^7 + D^6 + D^5 + D^4 + D^3 + D + 1 */
-static const uint32_t poly24a = 0x864cfb00;
-/** 1000 0000 0000 0000 0110 0011  D^24 + D^23 + D^6 + D^5 + D + 1 */
-static const uint32_t poly24b = 0x80006300;
-/** 0001 0000 0010 0001            D^16 + D^12 + D^5 + 1 */
-static const uint32_t poly16  = 0x10210000;
-/** 1000 0000 1111                 D^12 + D^11 + D^3 + D^2 + D + 1 */
-static const uint32_t poly12  = 0x80F00000;
-/** 1001 1011                      D^8  + D^7  + D^4 + D^3 + D + 1 */
-static const uint32_t poly8   = 0x9B000000;
 
 // The following arrays are generated with the function 'crcTableInit'
 /** Encoding table for CRC 24A */
@@ -96,6 +81,24 @@ uint32_t crcbit (uint8_t * inputptr, int32_t octetlen, uint32_t poly)
 // CRC table initialization
 
 /*
+  RK: Note that this should be brought back and use crcTableInit instead of static declaration
+      Commented out to remove warning
+  // For initialization && verification purposes, bit by bit implementation with any polynomial
+  // The first bit is in the MSB of each byte
+
+ // Reference 38.212 V15.1.1 Section 5.1 (36-212 v8.6.0 , pp 8-9)
+// The highest degree is set by default
+// 1000 0110 0100 1100 1111 1011  D^24 + D^23 + D^18 + D^17 + D^14 + D^11 + D^10 + D^7 + D^6 + D^5 + D^4 + D^3 + D + 1 
+static const uint32_t poly24a = 0x864cfb00;
+// 1000 0000 0000 0000 0110 0011  D^24 + D^23 + D^6 + D^5 + D + 1 
+static const uint32_t poly24b = 0x80006300;
+// 0001 0000 0010 0001            D^16 + D^12 + D^5 + 1 
+static const uint32_t poly16  = 0x10210000;
+// 1000 0000 1111                 D^12 + D^11 + D^3 + D^2 + D + 1 
+static const uint32_t poly12  = 0x80F00000;
+// 1001 1011                      D^8  + D^7  + D^4 + D^3 + D + 1 
+static const uint32_t poly8   = 0x9B000000;
+ 
 void crcTableInit (void)
 {
     uint8_t c = 0;
diff --git a/openair1/PHY/CODING/lte_rate_matching.c b/openair1/PHY/CODING/lte_rate_matching.c
index faa763b5d3876c1d82a5eb86412101019392d3e3..f850d475494e2ed7eb47fbb05546527ebc83db97 100644
--- a/openair1/PHY/CODING/lte_rate_matching.c
+++ b/openair1/PHY/CODING/lte_rate_matching.c
@@ -492,7 +492,7 @@ uint32_t lte_rate_matching_turbo(uint32_t RTC,
   Gp = G/Nl/Qm;
   GpmodC = Gp%C;
 #ifdef RM_DEBUG
-  printf("lte_rate_matching_turbo: Ncb %d, Kw %d, Nir/C %d, rvidx %d, G %d, Qm %d, Nl%d, r %d\n",Ncb,3*(RTC<<5),Nir/C,rvidx, G, Qm,Nl,r);
+  LOG_D(PHY,"lte_rate_matching_turbo: Ncb %d, Kw %d, Nir/C %d, rvidx %d, G %d, Qm %d, Nl%d, r %d\n",Ncb,3*(RTC<<5),Nir/C,rvidx, G, Qm,Nl,r);
 #endif
 
   if (r < (C-(GpmodC)))
diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c
index 93a43e48ebd30adeac2eb46e0f9cc5a9a084d6f9..6a062abcaee94bf06cbb217259be716eb3107c65 100644
--- a/openair1/PHY/INIT/lte_init.c
+++ b/openair1/PHY/INIT/lte_init.c
@@ -40,12 +40,14 @@ extern int32_t get_uldl_offset(int eutra_bandP);
 
 extern uint16_t prach_root_sequence_map0_3[838];
 extern uint16_t prach_root_sequence_map4[138];
-uint8_t dmrs1_tab[8] = {0,2,3,4,6,8,9,10};
+uint8_t         dmrs1_tab[8] = { 0, 2, 3, 4, 6, 8, 9, 10 };
 
 
-int N_RB_DL_array[6] = {6,15,25,50,75,100};
+int             N_RB_DL_array[6] = { 6, 15, 25, 50, 75, 100 };
 
-int l1_north_init_eNB() {
+int
+l1_north_init_eNB ()
+{
 
   int i,j;
 
@@ -85,8 +87,8 @@ int l1_north_init_eNB() {
 
 void phy_config_request(PHY_Config_t *phy_config) {
 
-  uint8_t Mod_id              = phy_config->Mod_id;
-  int CC_id                   = phy_config->CC_id;
+  uint8_t         Mod_id = phy_config->Mod_id;
+  int             CC_id = phy_config->CC_id;
   nfapi_config_request_t *cfg = phy_config->cfg;
 
 
@@ -105,9 +107,9 @@ void phy_config_request(PHY_Config_t *phy_config) {
 	cfg->phich_config.phich_resource.value,
 	cfg->phich_config.phich_duration.value);
 
-  AssertFatal(RC.eNB != NULL, "PHY instance pointer doesn't exist\n");
-  AssertFatal(RC.eNB[Mod_id] != NULL, "PHY instance %d doesn't exist\n",Mod_id);
-  AssertFatal(RC.eNB[Mod_id][CC_id] != NULL, "PHY instance %d, CCid %d doesn't exist\n",Mod_id,CC_id);
+  AssertFatal (RC.eNB != NULL, "PHY instance pointer doesn't exist\n");
+  AssertFatal (RC.eNB[Mod_id] != NULL, "PHY instance %d doesn't exist\n", Mod_id);
+  AssertFatal (RC.eNB[Mod_id][CC_id] != NULL, "PHY instance %d, CCid %d doesn't exist\n", Mod_id, CC_id);
 
 
   if (RC.eNB[Mod_id][CC_id]->configured == 1)
@@ -116,7 +118,7 @@ void phy_config_request(PHY_Config_t *phy_config) {
     return;
   }
 
-  RC.eNB[Mod_id][CC_id]->mac_enabled     = 1;
+  RC.eNB[Mod_id][CC_id]->mac_enabled = 1;
 
   fp = &RC.eNB[Mod_id][CC_id]->frame_parms;
 
@@ -129,164 +131,157 @@ void phy_config_request(PHY_Config_t *phy_config) {
   fp->Ncp_UL                             = Ncp;
   fp->nb_antenna_ports_eNB               = p_eNB;
 
-  fp->threequarter_fs                    = 0;
+  fp->threequarter_fs = 0;
 
-  AssertFatal(cfg->phich_config.phich_resource.value<4, "Illegal phich_Resource\n");
+  AssertFatal (cfg->phich_config.phich_resource.value < 4, "Illegal phich_Resource\n");
 
   fp->phich_config_common.phich_resource = phich_resource_table[cfg->phich_config.phich_resource.value];
   fp->phich_config_common.phich_duration = cfg->phich_config.phich_duration.value;
   // Note: "from_earfcn" has to be in a common library with MACRLC
-  fp->dl_CarrierFreq                     = from_earfcn(eutra_band,dl_CarrierFreq);
-  fp->ul_CarrierFreq                     = fp->dl_CarrierFreq - (get_uldl_offset(eutra_band)*100000);
+  fp->dl_CarrierFreq = from_earfcn (eutra_band, dl_CarrierFreq);
+  fp->ul_CarrierFreq = fp->dl_CarrierFreq - (get_uldl_offset (eutra_band) * 100000);
 
-  fp->tdd_config                         = 0;
-  fp->tdd_config_S                       = 0;
+  fp->tdd_config = 0;
+  fp->tdd_config_S = 0;
 
-  if (fp->dl_CarrierFreq==fp->ul_CarrierFreq)
+  if (fp->dl_CarrierFreq == fp->ul_CarrierFreq)
     fp->frame_type = TDD;
   else
     fp->frame_type = FDD;
 
-  init_frame_parms(fp,1);
-  init_lte_top(fp);
+  init_frame_parms (fp, 1);
+  init_lte_top (fp);
 
   if (cfg->subframe_config.duplex_mode.value == 0) {
-    fp->tdd_config    = cfg->tdd_frame_structure_config.subframe_assignment.value;
-    fp->tdd_config_S  = cfg->tdd_frame_structure_config.special_subframe_patterns.value;
-    fp->frame_type    = TDD;
-  }
-  else {
-    fp->frame_type    = FDD;
+    fp->tdd_config = cfg->tdd_frame_structure_config.subframe_assignment.value;
+    fp->tdd_config_S = cfg->tdd_frame_structure_config.special_subframe_patterns.value;
+    fp->frame_type = TDD;
+  } else {
+    fp->frame_type = FDD;
   }
 
-  fp->prach_config_common.rootSequenceIndex                          = cfg->prach_config.root_sequence_index.value;
-  LOG_I(PHY,"prach_config_common.rootSequenceIndex = %d\n",cfg->prach_config.root_sequence_index.value);
+  fp->prach_config_common.rootSequenceIndex = cfg->prach_config.root_sequence_index.value;
+  LOG_I (PHY, "prach_config_common.rootSequenceIndex = %d\n", cfg->prach_config.root_sequence_index.value);
 
-  fp->prach_config_common.prach_Config_enabled=1;
+  fp->prach_config_common.prach_Config_enabled = 1;
 
-  fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex          =cfg->prach_config.configuration_index.value;
-  LOG_I(PHY,"prach_config_common.prach_ConfigInfo.prach_ConfigIndex = %d\n",cfg->prach_config.configuration_index.value);
+  fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex = cfg->prach_config.configuration_index.value;
+  LOG_I (PHY, "prach_config_common.prach_ConfigInfo.prach_ConfigIndex = %d\n", cfg->prach_config.configuration_index.value);
 
-  fp->prach_config_common.prach_ConfigInfo.highSpeedFlag              =cfg->prach_config.high_speed_flag.value;
-  LOG_I(PHY,"prach_config_common.prach_ConfigInfo.highSpeedFlag = %d\n",cfg->prach_config.high_speed_flag.value);
-  fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig  =cfg->prach_config.zero_correlation_zone_configuration.value;
-  LOG_I(PHY,"prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig = %d\n",cfg->prach_config.zero_correlation_zone_configuration.value);
-  fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset           =cfg->prach_config.frequency_offset.value;
-  LOG_I(PHY,"prach_config_common.prach_ConfigInfo.prach_FreqOffset = %d\n",cfg->prach_config.frequency_offset.value);
+  fp->prach_config_common.prach_ConfigInfo.highSpeedFlag = cfg->prach_config.high_speed_flag.value;
+  LOG_I (PHY, "prach_config_common.prach_ConfigInfo.highSpeedFlag = %d\n", cfg->prach_config.high_speed_flag.value);
+  fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig = cfg->prach_config.zero_correlation_zone_configuration.value;
+  LOG_I (PHY, "prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig = %d\n", cfg->prach_config.zero_correlation_zone_configuration.value);
+  fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset = cfg->prach_config.frequency_offset.value;
+  LOG_I (PHY, "prach_config_common.prach_ConfigInfo.prach_FreqOffset = %d\n", cfg->prach_config.frequency_offset.value);
+
+  init_prach_tables (839);
+  compute_prach_seq (fp->prach_config_common.rootSequenceIndex,
+                     fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex,
+                     fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig, fp->prach_config_common.prach_ConfigInfo.highSpeedFlag, fp->frame_type, RC.eNB[Mod_id][CC_id]->X_u);
 
-  init_prach_tables(839);
-  compute_prach_seq(fp->prach_config_common.rootSequenceIndex,
-		    fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex,
-		    fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig,
-		    fp->prach_config_common.prach_ConfigInfo.highSpeedFlag,
-		    fp->frame_type,
-                    RC.eNB[Mod_id][CC_id]->X_u);
 
 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
-  fp->prach_emtc_config_common.prach_Config_enabled=1;
-
-  fp->prach_emtc_config_common.rootSequenceIndex                                         = cfg->emtc_config.prach_catm_root_sequence_index.value;
-
-  fp->prach_emtc_config_common.prach_ConfigInfo.highSpeedFlag                            = cfg->emtc_config.prach_catm_high_speed_flag.value;
-  fp->prach_emtc_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig                = cfg->emtc_config.prach_catm_zero_correlation_zone_configuration.value;
-
-  // CE Level 3 parameters
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[3]                  = cfg->emtc_config.prach_ce_level_3_enable.value;
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_starting_subframe_periodicity[3]   = cfg->emtc_config.prach_ce_level_3_starting_subframe_periodicity.value;
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[3] = cfg->emtc_config.prach_ce_level_3_number_of_repetitions_per_attempt.value;
-  AssertFatal(fp->prach_emtc_config_common.prach_ConfigInfo.prach_starting_subframe_periodicity[3]>=fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[3],
-	      "prach_starting_subframe_periodicity[3] < prach_numPetitionPerPreambleAttempt[3]\n");
-
-
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[3]                     = cfg->emtc_config.prach_ce_level_3_configuration_index.value;
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_FreqOffset[3]                      = cfg->emtc_config.prach_ce_level_3_frequency_offset.value;
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_hopping_enable[3]                  = cfg->emtc_config.prach_ce_level_3_hopping_enable.value;
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_hopping_offset[3]                  = cfg->emtc_config.prach_ce_level_3_hopping_offset.value;
-  if (fp->prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[3] == 1)
-    compute_prach_seq(fp->prach_emtc_config_common.rootSequenceIndex,
-		      fp->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[3],
-		      fp->prach_emtc_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig,
-		      fp->prach_emtc_config_common.prach_ConfigInfo.highSpeedFlag,
-		      fp->frame_type,
-		      RC.eNB[Mod_id][CC_id]->X_u_br[3]);
-
-  // CE Level 2 parameters
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[2]                  = cfg->emtc_config.prach_ce_level_2_enable.value;
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_starting_subframe_periodicity[2]   = cfg->emtc_config.prach_ce_level_2_starting_subframe_periodicity.value;
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[2] = cfg->emtc_config.prach_ce_level_2_number_of_repetitions_per_attempt.value;
-  AssertFatal(fp->prach_emtc_config_common.prach_ConfigInfo.prach_starting_subframe_periodicity[2]>=fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[2],
-	      "prach_starting_subframe_periodicity[2] < prach_numPetitionPerPreambleAttempt[2]\n");
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[2]                     = cfg->emtc_config.prach_ce_level_2_configuration_index.value;
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_FreqOffset[2]                      = cfg->emtc_config.prach_ce_level_2_frequency_offset.value;
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_hopping_enable[2]                  = cfg->emtc_config.prach_ce_level_2_hopping_enable.value;
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_hopping_offset[2]                  = cfg->emtc_config.prach_ce_level_2_hopping_offset.value;
-  if (fp->prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[2] == 1)
-    compute_prach_seq(fp->prach_emtc_config_common.rootSequenceIndex,
-		      fp->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[3],
-		      fp->prach_emtc_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig,
-		      fp->prach_emtc_config_common.prach_ConfigInfo.highSpeedFlag,
-		      fp->frame_type,
-		      RC.eNB[Mod_id][CC_id]->X_u_br[2]);
-
-  // CE Level 1 parameters
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[1]                  = cfg->emtc_config.prach_ce_level_1_enable.value;
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_starting_subframe_periodicity[1]   = cfg->emtc_config.prach_ce_level_1_starting_subframe_periodicity.value;
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[1] = cfg->emtc_config.prach_ce_level_1_number_of_repetitions_per_attempt.value;
-  AssertFatal(fp->prach_emtc_config_common.prach_ConfigInfo.prach_starting_subframe_periodicity[1]>=fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[1],
-	      "prach_starting_subframe_periodicity[1] < prach_numPetitionPerPreambleAttempt[1]\n");
-
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[1]                     = cfg->emtc_config.prach_ce_level_1_configuration_index.value;
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_FreqOffset[1]                      = cfg->emtc_config.prach_ce_level_1_frequency_offset.value;
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_hopping_enable[1]                  = cfg->emtc_config.prach_ce_level_1_hopping_enable.value;
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_hopping_offset[1]                  = cfg->emtc_config.prach_ce_level_1_hopping_offset.value;
-  if (fp->prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[1] == 1)
-    compute_prach_seq(fp->prach_emtc_config_common.rootSequenceIndex,
-		      fp->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[3],
-		      fp->prach_emtc_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig,
-		      fp->prach_emtc_config_common.prach_ConfigInfo.highSpeedFlag,
-		      fp->frame_type,
-		      RC.eNB[Mod_id][CC_id]->X_u_br[1]);
-  
-  // CE Level 0 parameters
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[0]                  = cfg->emtc_config.prach_ce_level_0_enable.value;
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_starting_subframe_periodicity[0]   = cfg->emtc_config.prach_ce_level_0_starting_subframe_periodicity.value;
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[0] = cfg->emtc_config.prach_ce_level_0_number_of_repetitions_per_attempt.value;
-  AssertFatal(fp->prach_emtc_config_common.prach_ConfigInfo.prach_starting_subframe_periodicity[0]>=fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[0],
-	      "prach_starting_subframe_periodicity[0] %d < prach_numPetitionPerPreambleAttempt[0] %d\n",
-	      fp->prach_emtc_config_common.prach_ConfigInfo.prach_starting_subframe_periodicity[0],
-	      fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[0]);
-
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[0]                     = cfg->emtc_config.prach_ce_level_0_configuration_index.value;
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_FreqOffset[0]                      = cfg->emtc_config.prach_ce_level_0_frequency_offset.value;
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_hopping_enable[0]                = cfg->emtc_config.prach_ce_level_0_hopping_enable.value;
-  fp->prach_emtc_config_common.prach_ConfigInfo.prach_hopping_offset[0]                = cfg->emtc_config.prach_ce_level_0_hopping_offset.value;
-  if (fp->prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[0] == 1)
-    compute_prach_seq(fp->prach_emtc_config_common.rootSequenceIndex,
-		      fp->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[3],
-		      fp->prach_emtc_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig,
-		      fp->prach_emtc_config_common.prach_ConfigInfo.highSpeedFlag,
-		      fp->frame_type,
-		      RC.eNB[Mod_id][CC_id]->X_u_br[0]);
+  if (cfg->emtc_config.prach_ce_level_0_enable.value == 1) {
+    fp->prach_emtc_config_common.prach_Config_enabled = 1;
+
+    fp->prach_emtc_config_common.rootSequenceIndex = cfg->emtc_config.prach_catm_root_sequence_index.value;
+
+    fp->prach_emtc_config_common.prach_ConfigInfo.highSpeedFlag = cfg->emtc_config.prach_catm_high_speed_flag.value;
+    fp->prach_emtc_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig = cfg->emtc_config.prach_catm_zero_correlation_zone_configuration.value;
+
+    // CE Level 3 parameters
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[3] = cfg->emtc_config.prach_ce_level_3_enable.value;
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_starting_subframe_periodicity[3] = cfg->emtc_config.prach_ce_level_3_starting_subframe_periodicity.value;
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[3] = cfg->emtc_config.prach_ce_level_3_number_of_repetitions_per_attempt.value;
+    AssertFatal (fp->prach_emtc_config_common.prach_ConfigInfo.prach_starting_subframe_periodicity[3] >= fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[3],
+                 "prach_starting_subframe_periodicity[3] < prach_numPetitionPerPreambleAttempt[3]\n");
+
+
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[3] = cfg->emtc_config.prach_ce_level_3_configuration_index.value;
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_FreqOffset[3] = cfg->emtc_config.prach_ce_level_3_frequency_offset.value;
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_hopping_enable[3] = cfg->emtc_config.prach_ce_level_3_hopping_enable.value;
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_hopping_offset[3] = cfg->emtc_config.prach_ce_level_3_hopping_offset.value;
+    if (fp->prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[3] == 1)
+      compute_prach_seq (fp->prach_emtc_config_common.rootSequenceIndex,
+                         fp->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[3],
+                         fp->prach_emtc_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig,
+                         fp->prach_emtc_config_common.prach_ConfigInfo.highSpeedFlag, fp->frame_type, RC.eNB[Mod_id][CC_id]->X_u_br[3]);
+
+    // CE Level 2 parameters
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[2] = cfg->emtc_config.prach_ce_level_2_enable.value;
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_starting_subframe_periodicity[2] = cfg->emtc_config.prach_ce_level_2_starting_subframe_periodicity.value;
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[2] = cfg->emtc_config.prach_ce_level_2_number_of_repetitions_per_attempt.value;
+    AssertFatal (fp->prach_emtc_config_common.prach_ConfigInfo.prach_starting_subframe_periodicity[2] >= fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[2],
+                 "prach_starting_subframe_periodicity[2] < prach_numPetitionPerPreambleAttempt[2]\n");
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[2] = cfg->emtc_config.prach_ce_level_2_configuration_index.value;
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_FreqOffset[2] = cfg->emtc_config.prach_ce_level_2_frequency_offset.value;
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_hopping_enable[2] = cfg->emtc_config.prach_ce_level_2_hopping_enable.value;
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_hopping_offset[2] = cfg->emtc_config.prach_ce_level_2_hopping_offset.value;
+    if (fp->prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[2] == 1)
+      compute_prach_seq (fp->prach_emtc_config_common.rootSequenceIndex,
+                         fp->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[3],
+                         fp->prach_emtc_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig,
+                         fp->prach_emtc_config_common.prach_ConfigInfo.highSpeedFlag, fp->frame_type, RC.eNB[Mod_id][CC_id]->X_u_br[2]);
+
+    // CE Level 1 parameters
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[1] = cfg->emtc_config.prach_ce_level_1_enable.value;
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_starting_subframe_periodicity[1] = cfg->emtc_config.prach_ce_level_1_starting_subframe_periodicity.value;
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[1] = cfg->emtc_config.prach_ce_level_1_number_of_repetitions_per_attempt.value;
+    AssertFatal (fp->prach_emtc_config_common.prach_ConfigInfo.prach_starting_subframe_periodicity[1] >= fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[1],
+                 "prach_starting_subframe_periodicity[1] < prach_numPetitionPerPreambleAttempt[1]\n");
+
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[1] = cfg->emtc_config.prach_ce_level_1_configuration_index.value;
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_FreqOffset[1] = cfg->emtc_config.prach_ce_level_1_frequency_offset.value;
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_hopping_enable[1] = cfg->emtc_config.prach_ce_level_1_hopping_enable.value;
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_hopping_offset[1] = cfg->emtc_config.prach_ce_level_1_hopping_offset.value;
+    if (fp->prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[1] == 1)
+      compute_prach_seq (fp->prach_emtc_config_common.rootSequenceIndex,
+                         fp->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[3],
+                         fp->prach_emtc_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig,
+                         fp->prach_emtc_config_common.prach_ConfigInfo.highSpeedFlag, fp->frame_type, RC.eNB[Mod_id][CC_id]->X_u_br[1]);
+
+    // CE Level 0 parameters
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[0] = cfg->emtc_config.prach_ce_level_0_enable.value;
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_starting_subframe_periodicity[0] = cfg->emtc_config.prach_ce_level_0_starting_subframe_periodicity.value;
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[0] = cfg->emtc_config.prach_ce_level_0_number_of_repetitions_per_attempt.value;
+    AssertFatal (fp->prach_emtc_config_common.prach_ConfigInfo.prach_starting_subframe_periodicity[0] >= fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[0],
+                 "prach_starting_subframe_periodicity[0] %d < prach_numPetitionPerPreambleAttempt[0] %d\n",
+                 fp->prach_emtc_config_common.prach_ConfigInfo.prach_starting_subframe_periodicity[0], fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[0]);
+    AssertFatal (fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[0] > 0, "prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[0]==0\n");
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[0] = cfg->emtc_config.prach_ce_level_0_configuration_index.value;
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_FreqOffset[0] = cfg->emtc_config.prach_ce_level_0_frequency_offset.value;
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_hopping_enable[0] = cfg->emtc_config.prach_ce_level_0_hopping_enable.value;
+    fp->prach_emtc_config_common.prach_ConfigInfo.prach_hopping_offset[0] = cfg->emtc_config.prach_ce_level_0_hopping_offset.value;
+    if (fp->prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[0] == 1) {
+      compute_prach_seq (fp->prach_emtc_config_common.rootSequenceIndex,
+                         fp->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[3],
+                         fp->prach_emtc_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig,
+                         fp->prach_emtc_config_common.prach_ConfigInfo.highSpeedFlag, fp->frame_type, RC.eNB[Mod_id][CC_id]->X_u_br[0]);
+      init_mpdcch(RC.eNB[Mod_id][CC_id]);
+    }
+  }
+
 #endif
 
 
 
-  fp->pucch_config_common.deltaPUCCH_Shift = 1+cfg->pucch_config.delta_pucch_shift.value;
-  fp->pucch_config_common.nRB_CQI          = cfg->pucch_config.n_cqi_rb.value;
-  fp->pucch_config_common.nCS_AN           = cfg->pucch_config.n_an_cs.value;
-  fp->pucch_config_common.n1PUCCH_AN       = cfg->pucch_config.n1_pucch_an.value;
+  fp->pucch_config_common.deltaPUCCH_Shift = 1 + cfg->pucch_config.delta_pucch_shift.value;
+  fp->pucch_config_common.nRB_CQI = cfg->pucch_config.n_cqi_rb.value;
+  fp->pucch_config_common.nCS_AN = cfg->pucch_config.n_an_cs.value;
+  fp->pucch_config_common.n1PUCCH_AN = cfg->pucch_config.n1_pucch_an.value;
 
-  fp->pdsch_config_common.referenceSignalPower                         = cfg->rf_config.reference_signal_power.value;
-  fp->pdsch_config_common.p_b                                          = cfg->subframe_config.pb.value;
+  fp->pdsch_config_common.referenceSignalPower = cfg->rf_config.reference_signal_power.value;
+  fp->pdsch_config_common.p_b = cfg->subframe_config.pb.value;
 
-  fp->pusch_config_common.n_SB                                         = cfg->pusch_config.number_of_subbands.value;
-  LOG_I(PHY,"pusch_config_common.n_SB = %d\n",fp->pusch_config_common.n_SB );
+  fp->pusch_config_common.n_SB = cfg->pusch_config.number_of_subbands.value;
+  LOG_I (PHY, "pusch_config_common.n_SB = %d\n", fp->pusch_config_common.n_SB);
 
-  fp->pusch_config_common.hoppingMode                                  = cfg->pusch_config.hopping_mode.value;
-  LOG_I(PHY,"pusch_config_common.hoppingMode = %d\n",fp->pusch_config_common.hoppingMode);
+  fp->pusch_config_common.hoppingMode = cfg->pusch_config.hopping_mode.value;
+  LOG_I (PHY, "pusch_config_common.hoppingMode = %d\n", fp->pusch_config_common.hoppingMode);
 
-  fp->pusch_config_common.pusch_HoppingOffset                          = cfg->pusch_config.hopping_offset.value;
-  LOG_I(PHY,"pusch_config_common.pusch_HoppingOffset = %d\n",fp->pusch_config_common.pusch_HoppingOffset);
+  fp->pusch_config_common.pusch_HoppingOffset = cfg->pusch_config.hopping_offset.value;
+  LOG_I (PHY, "pusch_config_common.pusch_HoppingOffset = %d\n", fp->pusch_config_common.pusch_HoppingOffset);
 
   fp->pusch_config_common.enable64QAM                                  = 0;//radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.enable64QAM;
   LOG_I(PHY,"pusch_config_common.enable64QAM = %d\n",fp->pusch_config_common.enable64QAM );
@@ -300,29 +295,30 @@ void phy_config_request(PHY_Config_t *phy_config) {
   fp->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH   =  cfg->uplink_reference_signal_config.group_assignment.value;
   LOG_I(PHY,"pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = %d\n",fp->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH);
 
-  LOG_I(PHY,"pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = %d\n",fp->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled);
+  LOG_I (PHY, "pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = %d\n", fp->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled);
 
-  fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift            = dmrs1_tab[cfg->uplink_reference_signal_config.cyclic_shift_1_for_drms.value];
-  LOG_I(PHY,"pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift = %d\n",fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift);
+  fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift = dmrs1_tab[cfg->uplink_reference_signal_config.cyclic_shift_1_for_drms.value];
+  LOG_I (PHY, "pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift = %d\n", fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift);
 
-  init_ul_hopping(fp);
+  init_ul_hopping (fp);
 
-  fp->soundingrs_ul_config_common.enabled_flag                        = 0;// 1; Don't know how to turn this off in NFAPI
-  fp->soundingrs_ul_config_common.srs_BandwidthConfig                 = cfg->srs_config.bandwidth_configuration.value;
-  fp->soundingrs_ul_config_common.srs_SubframeConfig                  = cfg->srs_config.srs_subframe_configuration.value;
+  fp->soundingrs_ul_config_common.enabled_flag = 0;     // 1; Don't know how to turn this off in NFAPI
+  fp->soundingrs_ul_config_common.srs_BandwidthConfig = cfg->srs_config.bandwidth_configuration.value;
+  fp->soundingrs_ul_config_common.srs_SubframeConfig = cfg->srs_config.srs_subframe_configuration.value;
   fp->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission = cfg->srs_config.srs_acknack_srs_simultaneous_transmission.value;
-  fp->soundingrs_ul_config_common.srs_MaxUpPts                        = cfg->srs_config.max_up_pts.value;
+  fp->soundingrs_ul_config_common.srs_MaxUpPts = cfg->srs_config.max_up_pts.value;
 
   fp->num_MBSFN_config = 0;
 
-  init_ncs_cell(fp,RC.eNB[Mod_id][CC_id]->ncs_cell);
+  init_ncs_cell (fp, RC.eNB[Mod_id][CC_id]->ncs_cell);
 
 
-  init_ul_hopping(fp);
-  RC.eNB[Mod_id][CC_id]->configured                                   = 1;
-  LOG_I(PHY,"eNB %d/%d configured\n",Mod_id,CC_id);
+  init_ul_hopping (fp);
+  RC.eNB[Mod_id][CC_id]->configured = 1;
+  LOG_I (PHY, "eNB %d/%d configured\n", Mod_id, CC_id);
 }
 
+
 /*
 void phy_config_sib2_eNB(uint8_t Mod_id,
                          int CC_id,
@@ -406,9 +402,9 @@ void phy_config_sib2_eNB(uint8_t Mod_id,
     fp->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission = radioResourceConfigCommon->soundingRS_UL_ConfigCommon.choice.setup.ackNackSRS_SimultaneousTransmission;
 
     if (radioResourceConfigCommon->soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts)
-      fp->soundingrs_ul_config_common.srs_MaxUpPts                      = 1;
+      fp->soundingrs_ul_config_common.srs_MaxUpPts = 1;
     else
-      fp->soundingrs_ul_config_common.srs_MaxUpPts                      = 0;
+      fp->soundingrs_ul_config_common.srs_MaxUpPts = 0;
   }
 
 
@@ -438,16 +434,15 @@ void phy_config_sib2_eNB(uint8_t Mod_id,
   if (mbsfn_SubframeConfigList != NULL) {
     fp->num_MBSFN_config = mbsfn_SubframeConfigList->list.count;
 
-    for (i=0; i<mbsfn_SubframeConfigList->list.count; i++) {
+    for (i = 0; i < mbsfn_SubframeConfigList->list.count; i++) {
       fp->MBSFN_config[i].radioframeAllocationPeriod = mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationPeriod;
       fp->MBSFN_config[i].radioframeAllocationOffset = mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationOffset;
 
       if (mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.present == MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame) {
         fp->MBSFN_config[i].fourFrames_flag = 0;
-        fp->MBSFN_config[i].mbsfn_SubframeConfig = mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[0]; // 6-bit subframe configuration
-        LOG_I(PHY, "[CONFIG] MBSFN_SubframeConfig[%d] pattern is  %d\n", i,
-              fp->MBSFN_config[i].mbsfn_SubframeConfig);
-      } else if (mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.present == MBSFN_SubframeConfig__subframeAllocation_PR_fourFrames) { // 24-bit subframe configuration
+        fp->MBSFN_config[i].mbsfn_SubframeConfig = mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[0];  // 6-bit subframe configuration
+        LOG_I (PHY, "[CONFIG] MBSFN_SubframeConfig[%d] pattern is  %d\n", i, fp->MBSFN_config[i].mbsfn_SubframeConfig);
+      } else if (mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.present == MBSFN_SubframeConfig__subframeAllocation_PR_fourFrames) {       // 24-bit subframe configuration
         fp->MBSFN_config[i].fourFrames_flag = 1;
         fp->MBSFN_config[i].mbsfn_SubframeConfig =
           mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[2]|
@@ -466,6 +461,7 @@ void phy_config_sib2_eNB(uint8_t Mod_id,
 }
 */
 
+
 void phy_config_sib13_eNB(module_id_t Mod_id,int CC_id,int mbsfn_Area_idx,
                           long mbsfn_AreaId_r9)
 {
@@ -473,41 +469,43 @@ void phy_config_sib13_eNB(module_id_t Mod_id,int CC_id,int mbsfn_Area_idx,
   LTE_DL_FRAME_PARMS *fp = &RC.eNB[Mod_id][CC_id]->frame_parms;
 
 
-  LOG_I(PHY,"[eNB%d] Applying MBSFN_Area_id %ld for index %d\n",Mod_id,mbsfn_AreaId_r9,mbsfn_Area_idx);
+  LOG_I (PHY, "[eNB%d] Applying MBSFN_Area_id %ld for index %d\n", Mod_id, mbsfn_AreaId_r9, mbsfn_Area_idx);
 
   if (mbsfn_Area_idx == 0) {
     fp->Nid_cell_mbsfn = (uint16_t)mbsfn_AreaId_r9;
     LOG_I(PHY,"Fix me: only called when mbsfn_Area_idx == 0)\n");
   }
 
-  lte_gold_mbsfn(fp,RC.eNB[Mod_id][CC_id]->lte_gold_mbsfn_table,fp->Nid_cell_mbsfn);
+  lte_gold_mbsfn (fp, RC.eNB[Mod_id][CC_id]->lte_gold_mbsfn_table, fp->Nid_cell_mbsfn);
 }
 
 
-void phy_config_dedicated_eNB_step2(PHY_VARS_eNB *eNB)
+void
+phy_config_dedicated_eNB_step2 (PHY_VARS_eNB * eNB)
 {
   uint16_t UE_id;
+
   struct LTE_PhysicalConfigDedicated *physicalConfigDedicated;
-  LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
+  LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
 
-  for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
+  for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) {
     physicalConfigDedicated = eNB->physicalConfigDedicated[UE_id];
 
     if (physicalConfigDedicated != NULL) {
-      LOG_I(PHY,"[eNB %d] Sent physicalConfigDedicated=%p for UE %d\n",eNB->Mod_id,physicalConfigDedicated,UE_id);
-      LOG_D(PHY,"------------------------------------------------------------------------\n");
+      LOG_I (PHY, "[eNB %d] Sent physicalConfigDedicated=%p for UE %d\n", eNB->Mod_id, physicalConfigDedicated, UE_id);
+      LOG_D (PHY, "------------------------------------------------------------------------\n");
 
       if (physicalConfigDedicated->pdsch_ConfigDedicated) {
-        eNB->pdsch_config_dedicated[UE_id].p_a=physicalConfigDedicated->pdsch_ConfigDedicated->p_a;
-        LOG_D(PHY,"pdsch_config_dedicated.p_a %d\n",eNB->pdsch_config_dedicated[UE_id].p_a);
-        LOG_D(PHY,"\n");
+        eNB->pdsch_config_dedicated[UE_id].p_a = physicalConfigDedicated->pdsch_ConfigDedicated->p_a;
+        LOG_D (PHY, "pdsch_config_dedicated.p_a %d\n", eNB->pdsch_config_dedicated[UE_id].p_a);
+        LOG_D (PHY, "\n");
       }
 
       if (physicalConfigDedicated->pucch_ConfigDedicated) {
         if (physicalConfigDedicated->pucch_ConfigDedicated->ackNackRepetition.present==LTE_PUCCH_ConfigDedicated__ackNackRepetition_PR_release)
           eNB->pucch_config_dedicated[UE_id].ackNackRepetition=0;
         else {
-          eNB->pucch_config_dedicated[UE_id].ackNackRepetition=1;
+          eNB->pucch_config_dedicated[UE_id].ackNackRepetition = 1;
         }
 
         if (fp->frame_type == FDD) {
@@ -519,10 +517,10 @@ void phy_config_dedicated_eNB_step2(PHY_VARS_eNB *eNB)
             eNB->pucch_config_dedicated[UE_id].tdd_AckNackFeedbackMode = bundling;
         }
 
-        if ( eNB->pucch_config_dedicated[UE_id].tdd_AckNackFeedbackMode == multiplexing)
-          LOG_D(PHY,"pucch_config_dedicated.tdd_AckNackFeedbackMode = multiplexing\n");
+        if (eNB->pucch_config_dedicated[UE_id].tdd_AckNackFeedbackMode == multiplexing)
+          LOG_D (PHY, "pucch_config_dedicated.tdd_AckNackFeedbackMode = multiplexing\n");
         else
-          LOG_D(PHY,"pucch_config_dedicated.tdd_AckNackFeedbackMode = bundling\n");
+          LOG_D (PHY, "pucch_config_dedicated.tdd_AckNackFeedbackMode = bundling\n");
 
       }
 
@@ -542,38 +540,38 @@ void phy_config_dedicated_eNB_step2(PHY_VARS_eNB *eNB)
       if (physicalConfigDedicated->uplinkPowerControlDedicated) {
 
         eNB->ul_power_control_dedicated[UE_id].p0_UE_PUSCH = physicalConfigDedicated->uplinkPowerControlDedicated->p0_UE_PUSCH;
-        eNB->ul_power_control_dedicated[UE_id].deltaMCS_Enabled= physicalConfigDedicated->uplinkPowerControlDedicated->deltaMCS_Enabled;
-        eNB->ul_power_control_dedicated[UE_id].accumulationEnabled= physicalConfigDedicated->uplinkPowerControlDedicated->accumulationEnabled;
-        eNB->ul_power_control_dedicated[UE_id].p0_UE_PUCCH= physicalConfigDedicated->uplinkPowerControlDedicated->p0_UE_PUCCH;
-        eNB->ul_power_control_dedicated[UE_id].pSRS_Offset= physicalConfigDedicated->uplinkPowerControlDedicated->pSRS_Offset;
-        eNB->ul_power_control_dedicated[UE_id].filterCoefficient= *physicalConfigDedicated->uplinkPowerControlDedicated->filterCoefficient;
-        LOG_D(PHY,"ul_power_control_dedicated.p0_UE_PUSCH %d\n",eNB->ul_power_control_dedicated[UE_id].p0_UE_PUSCH);
-        LOG_D(PHY,"ul_power_control_dedicated.deltaMCS_Enabled %d\n",eNB->ul_power_control_dedicated[UE_id].deltaMCS_Enabled);
-        LOG_D(PHY,"ul_power_control_dedicated.accumulationEnabled %d\n",eNB->ul_power_control_dedicated[UE_id].accumulationEnabled);
-        LOG_D(PHY,"ul_power_control_dedicated.p0_UE_PUCCH %d\n",eNB->ul_power_control_dedicated[UE_id].p0_UE_PUCCH);
-        LOG_D(PHY,"ul_power_control_dedicated.pSRS_Offset %d\n",eNB->ul_power_control_dedicated[UE_id].pSRS_Offset);
-        LOG_D(PHY,"ul_power_control_dedicated.filterCoefficient %d\n",eNB->ul_power_control_dedicated[UE_id].filterCoefficient);
-        LOG_D(PHY,"\n");
+        eNB->ul_power_control_dedicated[UE_id].deltaMCS_Enabled = physicalConfigDedicated->uplinkPowerControlDedicated->deltaMCS_Enabled;
+        eNB->ul_power_control_dedicated[UE_id].accumulationEnabled = physicalConfigDedicated->uplinkPowerControlDedicated->accumulationEnabled;
+        eNB->ul_power_control_dedicated[UE_id].p0_UE_PUCCH = physicalConfigDedicated->uplinkPowerControlDedicated->p0_UE_PUCCH;
+        eNB->ul_power_control_dedicated[UE_id].pSRS_Offset = physicalConfigDedicated->uplinkPowerControlDedicated->pSRS_Offset;
+        eNB->ul_power_control_dedicated[UE_id].filterCoefficient = *physicalConfigDedicated->uplinkPowerControlDedicated->filterCoefficient;
+        LOG_D (PHY, "ul_power_control_dedicated.p0_UE_PUSCH %d\n", eNB->ul_power_control_dedicated[UE_id].p0_UE_PUSCH);
+        LOG_D (PHY, "ul_power_control_dedicated.deltaMCS_Enabled %d\n", eNB->ul_power_control_dedicated[UE_id].deltaMCS_Enabled);
+        LOG_D (PHY, "ul_power_control_dedicated.accumulationEnabled %d\n", eNB->ul_power_control_dedicated[UE_id].accumulationEnabled);
+        LOG_D (PHY, "ul_power_control_dedicated.p0_UE_PUCCH %d\n", eNB->ul_power_control_dedicated[UE_id].p0_UE_PUCCH);
+        LOG_D (PHY, "ul_power_control_dedicated.pSRS_Offset %d\n", eNB->ul_power_control_dedicated[UE_id].pSRS_Offset);
+        LOG_D (PHY, "ul_power_control_dedicated.filterCoefficient %d\n", eNB->ul_power_control_dedicated[UE_id].filterCoefficient);
+        LOG_D (PHY, "\n");
       }
 
       if (physicalConfigDedicated->antennaInfo) {
-        eNB->transmission_mode[UE_id] = 1+(physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode);
-        LOG_D(PHY,"Transmission Mode (phy_config_dedicated_eNB_step2) %d\n",eNB->transmission_mode[UE_id]);
-        LOG_D(PHY,"\n");
+        eNB->transmission_mode[UE_id] = 1 + (physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode);
+        LOG_D (PHY, "Transmission Mode (phy_config_dedicated_eNB_step2) %d\n", eNB->transmission_mode[UE_id]);
+        LOG_D (PHY, "\n");
       }
 
       if (physicalConfigDedicated->schedulingRequestConfig) {
         if (physicalConfigDedicated->schedulingRequestConfig->present == LTE_SchedulingRequestConfig_PR_setup) {
           eNB->scheduling_request_config[UE_id].sr_PUCCH_ResourceIndex = physicalConfigDedicated->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex;
-          eNB->scheduling_request_config[UE_id].sr_ConfigIndex=physicalConfigDedicated->schedulingRequestConfig->choice.setup.sr_ConfigIndex;
-          eNB->scheduling_request_config[UE_id].dsr_TransMax=physicalConfigDedicated->schedulingRequestConfig->choice.setup.dsr_TransMax;
+          eNB->scheduling_request_config[UE_id].sr_ConfigIndex = physicalConfigDedicated->schedulingRequestConfig->choice.setup.sr_ConfigIndex;
+          eNB->scheduling_request_config[UE_id].dsr_TransMax = physicalConfigDedicated->schedulingRequestConfig->choice.setup.dsr_TransMax;
 
-          LOG_D(PHY,"scheduling_request_config.sr_PUCCH_ResourceIndex %d\n",eNB->scheduling_request_config[UE_id].sr_PUCCH_ResourceIndex);
-          LOG_D(PHY,"scheduling_request_config.sr_ConfigIndex %d\n",eNB->scheduling_request_config[UE_id].sr_ConfigIndex);
-          LOG_D(PHY,"scheduling_request_config.dsr_TransMax %d\n",eNB->scheduling_request_config[UE_id].dsr_TransMax);
+          LOG_D (PHY, "scheduling_request_config.sr_PUCCH_ResourceIndex %d\n", eNB->scheduling_request_config[UE_id].sr_PUCCH_ResourceIndex);
+          LOG_D (PHY, "scheduling_request_config.sr_ConfigIndex %d\n", eNB->scheduling_request_config[UE_id].sr_ConfigIndex);
+          LOG_D (PHY, "scheduling_request_config.dsr_TransMax %d\n", eNB->scheduling_request_config[UE_id].dsr_TransMax);
         }
 
-        LOG_D(PHY,"------------------------------------------------------------\n");
+        LOG_D (PHY, "------------------------------------------------------------\n");
 
       }
 
@@ -587,14 +585,14 @@ void phy_config_dedicated_eNB_step2(PHY_VARS_eNB *eNB)
           eNB->soundingrs_ul_config_dedicated[UE_id].srs_Bandwidth        = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth;
           eNB->soundingrs_ul_config_dedicated[UE_id].srs_ConfigIndex      = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex;
           eNB->soundingrs_ul_config_dedicated[UE_id].srs_HoppingBandwidth = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth;
-          eNB->soundingrs_ul_config_dedicated[UE_id].transmissionComb     = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb;
+          eNB->soundingrs_ul_config_dedicated[UE_id].transmissionComb = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb;
 
 
-          LOG_D(PHY,"soundingrs_ul_config_dedicated.srs_ConfigIndex %d\n",eNB->soundingrs_ul_config_dedicated[UE_id].srs_ConfigIndex);
+          LOG_D (PHY, "soundingrs_ul_config_dedicated.srs_ConfigIndex %d\n", eNB->soundingrs_ul_config_dedicated[UE_id].srs_ConfigIndex);
 
         }
 
-        LOG_D(PHY,"------------------------------------------------------------\n");
+        LOG_D (PHY, "------------------------------------------------------------\n");
 
       }
 
@@ -651,7 +649,7 @@ void phy_config_dedicated_eNB(uint8_t Mod_id,
 	eNB->transmission_mode[UE_id] = 7;
 	break;
       default:
-        LOG_E(PHY,"Unknown transmission mode!\n");
+        LOG_E (PHY, "Unknown transmission mode!\n");
         break;
       }
       LOG_I(PHY,"Transmission Mode (phy_config_dedicated_eNB) %d\n",eNB->transmission_mode[UE_id]);
@@ -667,6 +665,7 @@ void phy_config_dedicated_eNB(uint8_t Mod_id,
 }
 */
 
+
 /*
 void phy_config_dedicated_scell_eNB(uint8_t Mod_id,
                                     uint16_t rnti,
@@ -716,8 +715,6 @@ void phy_config_dedicated_scell_eNB(uint8_t Mod_id,
 }
 */
 
-
-
 int phy_init_lte_eNB(PHY_VARS_eNB *eNB,
                      unsigned char is_secondary_eNB,
                      unsigned char abstraction_flag)
@@ -732,16 +729,14 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB,
 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
   LTE_eNB_PRACH* const prach_vars_br = &eNB->prach_vars_br;
 #endif
-  int i, UE_id; 
+  int             i, UE_id;
 
   LOG_I(PHY,"[eNB %d] %s() About to wait for eNB to be configured", eNB->Mod_id, __FUNCTION__);
 
   eNB->total_dlsch_bitrate = 0;
   eNB->total_transmitted_bits = 0;
   eNB->total_system_throughput = 0;
-  eNB->check_for_MUMIMO_transmissions=0;
- 
-  while(eNB->configured == 0) usleep(10000);
+  eNB->check_for_MUMIMO_transmissions = 0;
 
   LOG_I(PHY,"[eNB %"PRIu8"] Initializing DL_FRAME_PARMS : N_RB_DL %"PRIu8", PHICH Resource %d, PHICH Duration %d nb_antennas_tx:%u nb_antennas_rx:%u nb_antenna_ports_eNB:%u PRACH[rootSequenceIndex:%u prach_Config_enabled:%u configIndex:%u highSpeed:%u zeroCorrelationZoneConfig:%u freqOffset:%u]\n",
         eNB->Mod_id,
@@ -757,18 +752,21 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB,
         );
   LOG_D(PHY,"[MSC_NEW][FRAME 00000][PHY_eNB][MOD %02"PRIu8"][]\n", eNB->Mod_id);
 
+  LOG_I (PHY, "[eNB %" PRIu8 "] Initializing DL_FRAME_PARMS : N_RB_DL %" PRIu8 ", PHICH Resource %d, PHICH Duration %d\n",
+         eNB->Mod_id, fp->N_RB_DL, fp->phich_config_common.phich_resource, fp->phich_config_common.phich_duration);
+  LOG_D (PHY, "[MSC_NEW][FRAME 00000][PHY_eNB][MOD %02" PRIu8 "][]\n", eNB->Mod_id);
 
-  lte_gold(fp,eNB->lte_gold_table,fp->Nid_cell);
-  generate_pcfich_reg_mapping(fp);
-  generate_phich_reg_mapping(fp);
 
-  for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
-    eNB->first_run_timing_advance[UE_id] =
-      1; ///This flag used to be static. With multiple eNBs this does no longer work, hence we put it in the structure. However it has to be initialized with 1, which is performed here.
-    
+  lte_gold (fp, eNB->lte_gold_table, fp->Nid_cell);
+  generate_pcfich_reg_mapping (fp);
+  generate_phich_reg_mapping (fp);
+
+  for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) {
+    eNB->first_run_timing_advance[UE_id] = 1;   ///This flag used to be static. With multiple eNBs this does no longer work, hence we put it in the structure. However it has to be initialized with 1, which is performed here.
+
     // clear whole structure
-    bzero( &eNB->UE_stats[UE_id], sizeof(LTE_eNB_UE_stats) );
-    
+    bzero (&eNB->UE_stats[UE_id], sizeof (LTE_eNB_UE_stats));
+
     eNB->physicalConfigDedicated[UE_id] = NULL;
   }
   
@@ -791,51 +789,53 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB,
 	    i,common_vars->txdataF[i],
 	    fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t));
     }
-  }  
-  
-  
+  }
+
+
   // Channel estimates for SRS
-  for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
-    
-    srs_vars[UE_id].srs_ch_estimates      = (int32_t**)malloc16( 64*sizeof(int32_t*) );
-    srs_vars[UE_id].srs_ch_estimates_time = (int32_t**)malloc16( 64*sizeof(int32_t*) );
-    
-    for (i=0; i<64; i++) {
-      srs_vars[UE_id].srs_ch_estimates[i]      = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size );
-      srs_vars[UE_id].srs_ch_estimates_time[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2 );
+  for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) {
+
+    srs_vars[UE_id].srs_ch_estimates = (int32_t **) malloc16 (64 * sizeof (int32_t *));
+    srs_vars[UE_id].srs_ch_estimates_time = (int32_t **) malloc16 (64 * sizeof (int32_t *));
+
+    for (i = 0; i < 64; i++) {
+      srs_vars[UE_id].srs_ch_estimates[i] = (int32_t *) malloc16_clear (sizeof (int32_t) * fp->ofdm_symbol_size);
+      srs_vars[UE_id].srs_ch_estimates_time[i] = (int32_t *) malloc16_clear (sizeof (int32_t) * fp->ofdm_symbol_size * 2);
     }
-  } //UE_id
+  }                             //UE_id
 
 
-  generate_ul_ref_sigs_rx();
-  
-  init_ulsch_power_LUT();
+  generate_ul_ref_sigs_rx ();
+
+  init_ulsch_power_LUT ();
 
   // SRS
-  for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
-    srs_vars[UE_id].srs = (int32_t*)malloc16_clear(2*fp->ofdm_symbol_size*sizeof(int32_t));
+  for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) {
+    srs_vars[UE_id].srs = (int32_t *) malloc16_clear (2 * fp->ofdm_symbol_size * sizeof (int32_t));
   }
 
   // PRACH
-  prach_vars->prachF = (int16_t*)malloc16_clear( 1024*2*sizeof(int16_t) );
+  prach_vars->prachF = (int16_t *) malloc16_clear (1024 * 2 * sizeof (int16_t));
 
   // assume maximum of 64 RX antennas for PRACH receiver
-  prach_vars->prach_ifft[0]    = (int32_t**)malloc16_clear(64*sizeof(int32_t*)); 
-  for (i=0;i<64;i++) prach_vars->prach_ifft[0][i]    = (int32_t*)malloc16_clear(1024*2*sizeof(int32_t)); 
+  prach_vars->prach_ifft[0] = (int32_t **) malloc16_clear (64 * sizeof (int32_t *));
+  for (i = 0; i < 64; i++)
+    prach_vars->prach_ifft[0][i] = (int32_t *) malloc16_clear (1024 * 2 * sizeof (int32_t));
 
-  prach_vars->rxsigF[0]        = (int16_t**)malloc16_clear(64*sizeof(int16_t*));
+  prach_vars->rxsigF[0] = (int16_t **) malloc16_clear (64 * sizeof (int16_t *));
   // PRACH BR
 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
   prach_vars_br->prachF = (int16_t*)malloc16_clear( 1024*2*sizeof(int32_t) );
 
   // assume maximum of 64 RX antennas for PRACH receiver
-  for (int ce_level=0;ce_level<4;ce_level++) {
-    prach_vars_br->prach_ifft[ce_level] = (int32_t**)malloc16_clear(64*sizeof(int32_t*));
-    for (i=0;i<64;i++) prach_vars_br->prach_ifft[ce_level][i] = (int32_t*)malloc16_clear(1024*2*sizeof(int32_t));
-    prach_vars->rxsigF[ce_level]        = (int16_t**)malloc16_clear(64*sizeof(int16_t*));
+  for (int ce_level = 0; ce_level < 4; ce_level++) {
+    prach_vars_br->prach_ifft[ce_level] = (int32_t **) malloc16_clear (64 * sizeof (int32_t *));
+    for (i = 0; i < 64; i++)
+      prach_vars_br->prach_ifft[ce_level][i] = (int32_t *) malloc16_clear (1024 * 2 * sizeof (int32_t));
+    prach_vars->rxsigF[ce_level] = (int16_t **) malloc16_clear (64 * sizeof (int16_t *));
   }
 #endif
-  
+
   /* number of elements of an array X is computed as sizeof(X) / sizeof(X[0]) 
   AssertFatal(fp->nb_antennas_rx <= sizeof(prach_vars->rxsigF) / sizeof(prach_vars->rxsigF[0]),
               "nb_antennas_rx too large");
@@ -847,20 +847,20 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB,
   for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
     
     //FIXME
-    pusch_vars[UE_id] = (LTE_eNB_PUSCH*)malloc16_clear( NUMBER_OF_UE_MAX*sizeof(LTE_eNB_PUSCH) );
-    
-    pusch_vars[UE_id]->rxdataF_ext      = (int32_t**)malloc16( 2*sizeof(int32_t*) );
-    pusch_vars[UE_id]->rxdataF_ext2     = (int32_t**)malloc16( 2*sizeof(int32_t*) );
-    pusch_vars[UE_id]->drs_ch_estimates = (int32_t**)malloc16( 2*sizeof(int32_t*) );
-    pusch_vars[UE_id]->drs_ch_estimates_time = (int32_t**)malloc16( 2*sizeof(int32_t*) );
-    pusch_vars[UE_id]->rxdataF_comp     = (int32_t**)malloc16( 2*sizeof(int32_t*) );
-    pusch_vars[UE_id]->ul_ch_mag  = (int32_t**)malloc16( 2*sizeof(int32_t*) );
-    pusch_vars[UE_id]->ul_ch_magb = (int32_t**)malloc16( 2*sizeof(int32_t*) );
-    
-    AssertFatal(fp->ofdm_symbol_size > 127, "fp->ofdm_symbol_size %d<128\n",fp->ofdm_symbol_size);
-    AssertFatal(fp->symbols_per_tti > 11, "fp->symbols_per_tti %d < 12\n",fp->symbols_per_tti);
-    AssertFatal(fp->N_RB_UL > 5, "fp->N_RB_UL %d < 6\n",fp->N_RB_UL);
-    for (i=0; i<2; i++) {
+    pusch_vars[UE_id] = (LTE_eNB_PUSCH *) malloc16_clear (NUMBER_OF_UE_MAX * sizeof (LTE_eNB_PUSCH));
+
+    pusch_vars[UE_id]->rxdataF_ext = (int32_t **) malloc16 (2 * sizeof (int32_t *));
+    pusch_vars[UE_id]->rxdataF_ext2 = (int32_t **) malloc16 (2 * sizeof (int32_t *));
+    pusch_vars[UE_id]->drs_ch_estimates = (int32_t **) malloc16 (2 * sizeof (int32_t *));
+    pusch_vars[UE_id]->drs_ch_estimates_time = (int32_t **) malloc16 (2 * sizeof (int32_t *));
+    pusch_vars[UE_id]->rxdataF_comp = (int32_t **) malloc16 (2 * sizeof (int32_t *));
+    pusch_vars[UE_id]->ul_ch_mag = (int32_t **) malloc16 (2 * sizeof (int32_t *));
+    pusch_vars[UE_id]->ul_ch_magb = (int32_t **) malloc16 (2 * sizeof (int32_t *));
+
+    AssertFatal (fp->ofdm_symbol_size > 127, "fp->ofdm_symbol_size %d<128\n", fp->ofdm_symbol_size);
+    AssertFatal (fp->symbols_per_tti > 11, "fp->symbols_per_tti %d < 12\n", fp->symbols_per_tti);
+    AssertFatal (fp->N_RB_UL > 5, "fp->N_RB_UL %d < 6\n", fp->N_RB_UL);
+    for (i = 0; i < 2; i++) {
       // RK 2 times because of output format of FFT!
       // FIXME We should get rid of this
       pusch_vars[UE_id]->rxdataF_ext[i]      = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti );
@@ -875,12 +875,12 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB,
     pusch_vars[UE_id]->llr = (int16_t*)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) );
   } //UE_id
 
-    
-  for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++)
+
+  for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++)
     eNB->UE_stats_ptr[UE_id] = &eNB->UE_stats[UE_id];
-  
-  eNB->pdsch_config_dedicated->p_a = dB0; //defaul value until overwritten by RRCConnectionReconfiguration
-  
+
+  eNB->pdsch_config_dedicated->p_a = dB0;       //defaul value until overwritten by RRCConnectionReconfiguration
+
 
   return (0);
 
diff --git a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c
index 206ba8b15f93626d9d3624d401efed8247a38180..cb50b7b5d3fcc5495baf34481e1bfdf8aa9df8d7 100644
--- a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c
+++ b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c
@@ -46,12 +46,12 @@ int32_t lte_ul_channel_estimation(PHY_VARS_eNB *eNB,
   int32_t **ul_ch_estimates_time=  pusch_vars->drs_ch_estimates_time;
   int32_t **rxdataF_ext=  pusch_vars->rxdataF_ext;
   int subframe = proc->subframe_rx;
-  uint8_t harq_pid = subframe2harq_pid(frame_parms,proc->frame_rx,subframe);
+  uint8_t harq_pid; 
   int16_t delta_phase = 0;
   int16_t *ru1 = ru_90;
   int16_t *ru2 = ru_90;
   int16_t current_phase1,current_phase2;
-  uint16_t N_rb_alloc = eNB->ulsch[UE_id]->harq_processes[harq_pid]->nb_rb;
+
   uint16_t aa,Msc_RS,Msc_RS_idx;
   uint16_t * Msc_idx_ptr;
   int k,pilot_pos1 = 3 - frame_parms->Ncp, pilot_pos2 = 10 - 2*frame_parms->Ncp;
@@ -65,7 +65,7 @@ int32_t lte_ul_channel_estimation(PHY_VARS_eNB *eNB,
   uint32_t alpha_ind;
   uint32_t u=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[Ns+(subframe<<1)];
   uint32_t v=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[Ns+(subframe<<1)];
-  int32_t tmp_estimates[N_rb_alloc*12] __attribute__((aligned(16)));
+
 
   int symbol_offset,i;
 
@@ -83,7 +83,19 @@ int32_t lte_ul_channel_estimation(PHY_VARS_eNB *eNB,
   int32x4_t mmtmp0,mmtmp1,mmtmp_re,mmtmp_im;
 #endif
 
-int32_t temp_in_ifft_0[2048*2] __attribute__((aligned(32)));
+  int32_t temp_in_ifft_0[2048*2] __attribute__((aligned(32)));
+
+
+#ifdef Rel14
+  if (eNB->ulsch[UE_id]->ue_type > 0) harq_pid = 0;
+  else
+#endif
+    {
+      harq_pid = subframe2harq_pid(frame_parms,proc->frame_rx,subframe);
+    }
+
+  uint16_t N_rb_alloc = eNB->ulsch[UE_id]->harq_processes[harq_pid]->nb_rb;
+  int32_t tmp_estimates[N_rb_alloc*12] __attribute__((aligned(16)));
 
   Msc_RS = N_rb_alloc*12;
 
diff --git a/openair1/PHY/LTE_TRANSPORT/dci.c b/openair1/PHY/LTE_TRANSPORT/dci.c
old mode 100755
new mode 100644
index a7131ad1fbf1a963a941a3d37faa043c7cbb0170..6b5863edc96e0acbb620272b0e583f9b2ae0f231
--- a/openair1/PHY/LTE_TRANSPORT/dci.c
+++ b/openair1/PHY/LTE_TRANSPORT/dci.c
@@ -98,43 +98,25 @@ void dci_encoding(uint8_t *a,
 #endif
   RCC = sub_block_interleaving_cc(D,d+96,w);
 
-#ifdef DEBUG_DCI_ENCODING
-  printf("Doing DCI rate matching for %d channel bits, RCC %d, e %p\n",E,RCC,e);
-#endif
+  //#ifdef DEBUG_DCI_ENCODING
+  if (E>1000) printf("Doing DCI rate matching for %d channel bits, RCC %d, e %p\n",E,RCC,e);
+  //#endif
   lte_rate_matching_cc(RCC,E,w,e);
 
 
+
 }
 
 
 uint8_t *generate_dci0(uint8_t *dci,
                        uint8_t *e,
                        uint8_t DCI_LENGTH,
-                       uint8_t aggregation_level,
+		       uint16_t coded_bits,
                        uint16_t rnti)
 {
 
-  uint16_t coded_bits;
   uint8_t dci_flip[8];
 
-  AssertFatal((aggregation_level==1) ||
-	      (aggregation_level==2) ||
-	      (aggregation_level==4) ||
-	      (aggregation_level==8)
-#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) // Added for EPDCCH/MPDCCH
-	      ||
-	      (aggregation_level==16) ||
-	      (aggregation_level==24) ||
-	      (aggregation_level==32)
-#endif
-	      ,
-	      "generate_dci FATAL, illegal aggregation_level %d\n",aggregation_level);
-
-
-  coded_bits = 72 * aggregation_level;
-
-
-
   #ifdef DEBUG_DCI_ENCODING
   for (int i=0;i<1+((DCI_LENGTH+16)/8);i++)
     printf("i %d : %x\n",i,dci[i]);
@@ -387,7 +369,7 @@ uint8_t generate_dci_top(uint8_t num_pdcch_symbols,
           e_ptr = generate_dci0(dci_alloc[i].dci_pdu,
                                 e+(72*dci_alloc[i].firstCCE),
                                 dci_alloc[i].dci_length,
-                                dci_alloc[i].L,
+                                72*dci_alloc[i].L,
                                 dci_alloc[i].rnti);
         }
       }
diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c
index f003b7f36a416ac4d50ba12b85437971c6959e13..36cc48b14467c213548e9ae8a2ee0a0289946c88 100644
--- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c
+++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c
@@ -42,12 +42,17 @@
 //#define DEBUG_HARQ
 
 
+
+
 #include "LAYER2/MAC/mac.h"
 
 //#define DEBUG_DCI
 #include "dci_tools_common_extern.h"
 #include "transport_proto.h"
 
+//#undef LOG_D
+//#define LOG_D(A,B...) printf(B)
+
 int16_t find_dlsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type)
 {
   uint16_t i;
@@ -62,12 +67,14 @@ int16_t find_dlsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type)
         (eNB->dlsch[i][0]->rnti==rnti))       return i;
     else if ((eNB->dlsch[i][0]->harq_mask == 0) && (first_free_index==-1)) first_free_index=i;
   }
-  if (type == SEARCH_EXIST) return -1;
+  if (type == SEARCH_EXIST)
+    return -1;
   if (first_free_index != -1)
     eNB->dlsch[first_free_index][0]->rnti = 0;
   return first_free_index;
 }
 
+
 int16_t find_ulsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type)
 {
   uint16_t i;
@@ -80,7 +87,8 @@ int16_t find_ulsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type)
         (eNB->ulsch[i]->rnti==rnti))       return i;
     else if ((eNB->ulsch[i]->harq_mask == 0) && (first_free_index==-1)) first_free_index=i;
   }
-  if (type == SEARCH_EXIST) return -1;
+  if (type == SEARCH_EXIST)
+    return -1;
   if (first_free_index != -1)
     eNB->ulsch[first_free_index]->rnti = 0;
   return first_free_index;
@@ -92,23 +100,23 @@ int16_t find_ulsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type)
 
 void fill_pdcch_order(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,DCI_ALLOC_t *dci_alloc,nfapi_dl_config_dci_dl_pdu *pdu)
 {
-  LTE_DL_FRAME_PARMS                *fp      = &eNB->frame_parms;
-  uint8_t                           *dci_pdu = &dci_alloc->dci_pdu[0];
-  nfapi_dl_config_dci_dl_pdu_rel8_t *rel8    = &pdu->dci_dl_pdu_rel8;
+  LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
+  uint8_t        *dci_pdu = &dci_alloc->dci_pdu[0];
+  nfapi_dl_config_dci_dl_pdu_rel8_t *rel8 = &pdu->dci_dl_pdu_rel8;
 
   dci_alloc->firstCCE = rel8->cce_idx;
-  dci_alloc->L        = rel8->aggregation_level;
-  dci_alloc->rnti     = rel8->rnti;
+  dci_alloc->L = rel8->aggregation_level;
+  dci_alloc->rnti = rel8->rnti;
   dci_alloc->harq_pid = rel8->harq_process;
-  dci_alloc->ra_flag  = 0;
-  dci_alloc->format   = format1A;
+  dci_alloc->ra_flag = 0;
+  dci_alloc->format = format1A;
 
-  LOG_D(PHY,"NFAPI: DCI format %d, nCCE %d, L %d, rnti %x,harq_pid %d\n",
-        rel8->dci_format,rel8->cce_idx,rel8->aggregation_level,rel8->rnti,rel8->harq_process);
+  LOG_D (PHY, "NFAPI: DCI format %d, nCCE %d, L %d, rnti %x,harq_pid %d\n", rel8->dci_format, rel8->cce_idx, rel8->aggregation_level, rel8->rnti, rel8->harq_process);
 
   switch (fp->N_RB_DL) {
   case 6:
     if (fp->frame_type == TDD) {
+
       dci_alloc->dci_length                         = sizeof_DCI1A_1_5MHz_TDD_1_6_t;
       ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->type     = 1;
       ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->vrb_type = rel8->virtual_resource_block_assignment_flag;
@@ -131,11 +139,13 @@ void fill_pdcch_order(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,DCI_ALLOC_t *dci_al
       ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->TPC          = rel8->tpc;
       ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->harq_pid     = rel8->harq_process;
       ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->padding      = 0;
+
       //      printf("FDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB);
     }
     break;
   case 25:
     if (fp->frame_type == TDD) {
+
       dci_alloc->dci_length                         = sizeof_DCI1A_5MHz_TDD_1_6_t;
       ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->type       = 1;
       ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->vrb_type   = rel8->virtual_resource_block_assignment_flag;
@@ -164,6 +174,7 @@ void fill_pdcch_order(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,DCI_ALLOC_t *dci_al
     break;
   case 50:
     if (fp->frame_type == TDD) {
+
       dci_alloc->dci_length                         = sizeof_DCI1A_10MHz_TDD_1_6_t;
       ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->type      = 1;
       ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->vrb_type  = rel8->virtual_resource_block_assignment_flag;
@@ -187,11 +198,13 @@ void fill_pdcch_order(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,DCI_ALLOC_t *dci_al
       ((DCI1A_10MHz_FDD_t *)dci_pdu)->TPC           = rel8->tpc;
       ((DCI1A_10MHz_FDD_t *)dci_pdu)->harq_pid      = rel8->harq_process;
       ((DCI1A_10MHz_FDD_t *)dci_pdu)->padding       = 0;
+
       //      printf("FDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB);
     }
     break;
   case 100:
     if (fp->frame_type == TDD) {
+
       dci_alloc->dci_length                         = sizeof_DCI1A_20MHz_TDD_1_6_t;
       ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->type      = 1;
       ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->vrb_type  = rel8->virtual_resource_block_assignment_flag;
@@ -220,6 +233,7 @@ void fill_pdcch_order(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,DCI_ALLOC_t *dci_al
     break;
   }
 
+
   LOG_T(PHY,"%d.%d: DCI 1A: rnti %x, PDCCH order to do PRACH\n",
         proc->frame_tx, proc->subframe_tx, rel8->rnti);
 }
@@ -227,23 +241,33 @@ void fill_pdcch_order(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,DCI_ALLOC_t *dci_al
 void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t *proc,DCI_ALLOC_t *dci_alloc,nfapi_dl_config_dci_dl_pdu *pdu)
 {
   LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
-  uint8_t *dci_pdu = &dci_alloc->dci_pdu[0];
+  uint8_t        *dci_pdu = &dci_alloc->dci_pdu[0];
   nfapi_dl_config_dci_dl_pdu_rel8_t *rel8 = &pdu->dci_dl_pdu_rel8;
 
   /* check if this is a DCI 1A PDCCH order for RAPROC */
   if (rel8->dci_format == NFAPI_DL_DCI_FORMAT_1A && rel8->rnti_type == 1) {
-    int full_rb;
+    int             full_rb;
     switch (fp->N_RB_DL) {
-    case 6:   full_rb = 63;   break;
-    case 25:  full_rb = 511;  break;
-    case 50:  full_rb = 2047; break;
-    case 100: full_rb = 8191; break;
-    default:  abort();
+    case 6:
+      full_rb = 63;
+      break;
+    case 25:
+      full_rb = 511;
+      break;
+    case 50:
+      full_rb = 2047;
+      break;
+    case 100:
+      full_rb = 8191;
+      break;
+    default:
+      abort ();
     }
     if (rel8->resource_block_coding == full_rb)
-      return fill_pdcch_order(eNB, proc, dci_alloc, pdu);
+      return fill_pdcch_order (eNB, proc, dci_alloc, pdu);
   }
 
+
   LTE_eNB_DLSCH_t *dlsch0=NULL,*dlsch1=NULL;
   LTE_DL_eNB_HARQ_t *dlsch0_harq=NULL,*dlsch1_harq=NULL;
   int beamforming_mode = 0;
@@ -254,11 +278,13 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
   uint16_t DL_pmi_single=0; // This should be taken from DLSCH parameters for PUSCH precoding
   uint8_t I_mcs = 0;
  
+
   dci_alloc->firstCCE = rel8->cce_idx;
-  dci_alloc->L        = rel8->aggregation_level;
-  dci_alloc->rnti     = rel8->rnti;
+  dci_alloc->L = rel8->aggregation_level;
+  dci_alloc->rnti = rel8->rnti;
   dci_alloc->harq_pid = rel8->harq_process;
-  dci_alloc->ra_flag  = 0;
+  dci_alloc->ra_flag = 0;
+
 
   LOG_D(PHY,"NFAPI: SFN/SF:%04d%d proc:TX:[SFN/SF:%04d%d] DCI format %d, nCCE %d, L %d, rnti %x, harq_pid %d\n",
 	frame,subframe,proc->frame_tx,proc->subframe_tx,rel8->dci_format,rel8->cce_idx,rel8->aggregation_level,rel8->rnti,rel8->harq_process);
@@ -293,15 +319,15 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
     dlsch0_harq->round=0;
     dlsch0->harq_mask=0;
   }
-  if ((dlsch0->harq_mask & (1<<rel8->harq_process)) > 0 ) {
+  if ((dlsch0->harq_mask & (1 << rel8->harq_process)) > 0) {
     if (rel8->new_data_indicator_1 != dlsch0_harq->ndi)
-      dlsch0_harq->round=0;
-  }
-  else  { // process is inactive, so activate and set round to 0
-    dlsch0_harq->round=0;
+      dlsch0_harq->round = 0;
+  } else {                      // process is inactive, so activate and set round to 0
+    dlsch0_harq->round = 0;
   }
   dlsch0_harq->ndi = rel8->new_data_indicator_1;
 
+
 #ifdef PHY_TX_THREAD
   dlsch0->active[subframe]        = 1;
 #else
@@ -320,16 +346,16 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
 
   case NFAPI_DL_DCI_FORMAT_1A:
 
-      AssertFatal(rel8->resource_block_coding < 8192, "SFN/SF:%04d%d proc:TX:SFN/SF:%04d%d: rel8->resource_block_coding (%p) %u >= 8192 (rnti %x, rnti_type %d, format %d, harq_id %d\n",
+    AssertFatal(rel8->resource_block_coding < 8192, "SFN/SF:%04d%d proc:TX:SFN/SF:%04d%d: rel8->resource_block_coding (%p) %u >= 8192 (rnti %x, rnti_type %d, format %d, harq_id %d\n",
                 frame,subframe,proc->frame_tx,subframe,
                 &rel8->resource_block_coding,rel8->resource_block_coding,rel8->rnti,rel8->rnti_type,rel8->dci_format,rel8->harq_process);
   
-
-    dci_alloc->format     = format1A;
-
+    dci_alloc->format = format1A;
+    
     switch (fp->N_RB_DL) {
     case 6:
       if (fp->frame_type == TDD) {
+
 	dci_alloc->dci_length                         = sizeof_DCI1A_1_5MHz_TDD_1_6_t; 
         ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->type     = 1;
         ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->vrb_type = rel8->virtual_resource_block_assignment_flag;
@@ -353,12 +379,13 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
         ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->TPC          = rel8->tpc;
         ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->harq_pid     = rel8->harq_process;
         ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->padding      = 0;
+
         //      printf("FDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB);
       }
-      AssertFatal(rel8->virtual_resource_block_assignment_flag==LOCALIZED,"Distributed RB allocation not done yet\n");
-      dlsch0_harq->rb_alloc[0]    = localRIV2alloc_LUT6[rel8->resource_block_coding];
-      dlsch0_harq->vrb_type           =  rel8->virtual_resource_block_assignment_flag;
-      dlsch0_harq->nb_rb          = RIV2nb_rb_LUT6[rel8->resource_block_coding];//NPRB;
+      AssertFatal (rel8->virtual_resource_block_assignment_flag == LOCALIZED, "Distributed RB allocation not done yet\n");
+      dlsch0_harq->rb_alloc[0] = localRIV2alloc_LUT6[rel8->resource_block_coding];
+      dlsch0_harq->vrb_type = rel8->virtual_resource_block_assignment_flag;
+      dlsch0_harq->nb_rb = RIV2nb_rb_LUT6[rel8->resource_block_coding]; //NPRB;
       break;
     case 25:
       if (fp->frame_type == TDD) {
@@ -387,13 +414,14 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
         ((DCI1A_5MHz_FDD_t *)dci_pdu)->padding        = 0;
         //      printf("FDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB);
       }
-      AssertFatal(rel8->virtual_resource_block_assignment_flag==LOCALIZED,"Distributed RB allocation not done yet\n");
-      dlsch0_harq->rb_alloc[0]    = localRIV2alloc_LUT25[rel8->resource_block_coding];
-      dlsch0_harq->vrb_type           =  rel8->virtual_resource_block_assignment_flag;
-      dlsch0_harq->nb_rb          = RIV2nb_rb_LUT25[rel8->resource_block_coding];//NPRB;
+      AssertFatal (rel8->virtual_resource_block_assignment_flag == LOCALIZED, "Distributed RB allocation not done yet\n");
+      dlsch0_harq->rb_alloc[0] = localRIV2alloc_LUT25[rel8->resource_block_coding];
+      dlsch0_harq->vrb_type = rel8->virtual_resource_block_assignment_flag;
+      dlsch0_harq->nb_rb = RIV2nb_rb_LUT25[rel8->resource_block_coding];        //NPRB;
       break;
     case 50:
       if (fp->frame_type == TDD) {
+
 	dci_alloc->dci_length                         = sizeof_DCI1A_10MHz_TDD_1_6_t; 
         ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->type      = 1;
         ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->vrb_type  = rel8->virtual_resource_block_assignment_flag;
@@ -419,14 +447,15 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
         ((DCI1A_10MHz_FDD_t *)dci_pdu)->padding       = 0;
 	//      printf("FDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB);
       }
-      AssertFatal(rel8->virtual_resource_block_assignment_flag==LOCALIZED,"Distributed RB allocation not done yet\n");
-      dlsch0_harq->rb_alloc[0]     = localRIV2alloc_LUT50_0[rel8->resource_block_coding];
-      dlsch0_harq->rb_alloc[1]     = localRIV2alloc_LUT50_1[rel8->resource_block_coding];
-      dlsch0_harq->vrb_type           =  rel8->virtual_resource_block_assignment_flag;
-      dlsch0_harq->nb_rb              = RIV2nb_rb_LUT50[rel8->resource_block_coding];//NPRB;
+      AssertFatal (rel8->virtual_resource_block_assignment_flag == LOCALIZED, "Distributed RB allocation not done yet\n");
+      dlsch0_harq->rb_alloc[0] = localRIV2alloc_LUT50_0[rel8->resource_block_coding];
+      dlsch0_harq->rb_alloc[1] = localRIV2alloc_LUT50_1[rel8->resource_block_coding];
+      dlsch0_harq->vrb_type = rel8->virtual_resource_block_assignment_flag;
+      dlsch0_harq->nb_rb = RIV2nb_rb_LUT50[rel8->resource_block_coding];        //NPRB;
       break;
     case 100:
       if (fp->frame_type == TDD) {
+
 	dci_alloc->dci_length                         = sizeof_DCI1A_20MHz_TDD_1_6_t; 
         ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->type      = 1;
         ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->vrb_type  = rel8->virtual_resource_block_assignment_flag;
@@ -452,20 +481,21 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
         ((DCI1A_20MHz_FDD_t *)dci_pdu)->padding       = 0;
 	//      printf("FDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB);
       }
-      AssertFatal(rel8->virtual_resource_block_assignment_flag==LOCALIZED,"Distributed RB allocation not done yet\n");
-      dlsch0_harq->rb_alloc[0]      = localRIV2alloc_LUT100_0[rel8->resource_block_coding];
-      dlsch0_harq->rb_alloc[1]      = localRIV2alloc_LUT100_1[rel8->resource_block_coding];
-      dlsch0_harq->rb_alloc[2]      = localRIV2alloc_LUT100_2[rel8->resource_block_coding];
-      dlsch0_harq->rb_alloc[3]      = localRIV2alloc_LUT100_3[rel8->resource_block_coding];
-      dlsch0_harq->vrb_type         =  rel8->virtual_resource_block_assignment_flag;
-      dlsch0_harq->nb_rb            = RIV2nb_rb_LUT100[rel8->resource_block_coding];//NPRB;
+      AssertFatal (rel8->virtual_resource_block_assignment_flag == LOCALIZED, "Distributed RB allocation not done yet\n");
+      dlsch0_harq->rb_alloc[0] = localRIV2alloc_LUT100_0[rel8->resource_block_coding];
+      dlsch0_harq->rb_alloc[1] = localRIV2alloc_LUT100_1[rel8->resource_block_coding];
+      dlsch0_harq->rb_alloc[2] = localRIV2alloc_LUT100_2[rel8->resource_block_coding];
+      dlsch0_harq->rb_alloc[3] = localRIV2alloc_LUT100_3[rel8->resource_block_coding];
+      dlsch0_harq->vrb_type = rel8->virtual_resource_block_assignment_flag;
+      dlsch0_harq->nb_rb = RIV2nb_rb_LUT100[rel8->resource_block_coding];       //NPRB;
       break;
     }
 
-    if (rel8->rnti_type == 2 ) {
+    if (rel8->rnti_type == 2) {
       // see 36-212 V8.6.0 p. 45
-      NPRB      = (rel8->tpc&1)+2;
+      NPRB = (rel8->tpc & 1) + 2;
       // 36-213 sec.7.1.7.2 p.26
+
       I_mcs     = rel8->mcs_1;
     }
     else {
@@ -491,10 +521,11 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
 #endif
     dlsch0->rnti                 = rel8->rnti;
     //dlsch0->harq_ids[subframe]   = rel8->harq_process;
+
     if (dlsch0_harq->round == 0)
       dlsch0_harq->status = ACTIVE;
 
-    dlsch0->harq_mask            |= (1<<rel8->harq_process);
+    dlsch0->harq_mask |= (1 << rel8->harq_process);
 
     if (rel8->rnti_type == 1) LOG_I(PHY,"DCI 1A: round %d, mcs %d, rballoc %x, rv %d, rnti %x, harq process %d\n",dlsch0_harq->round,rel8->mcs_1,rel8->resource_block_coding,rel8->redundancy_version_1,rel8->rnti,rel8->harq_process);
 
@@ -513,6 +544,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
     switch (fp->N_RB_DL) {
     case 6:
       if (fp->frame_type == TDD) {
+
 	dci_alloc->dci_length                     = sizeof_DCI1_1_5MHz_TDD_t; 
         ((DCI1_1_5MHz_TDD_t *)dci_pdu)->rah       = rel8->resource_allocation_type;
         ((DCI1_1_5MHz_TDD_t *)dci_pdu)->mcs       = rel8->mcs_1;
@@ -539,6 +571,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
       break;
     case 25:
       if (fp->frame_type == TDD) {
+
 	dci_alloc->dci_length                      = sizeof_DCI1_5MHz_TDD_t; 
         ((DCI1_5MHz_TDD_t *)dci_pdu)->rah      = rel8->resource_allocation_type;
         ((DCI1_5MHz_TDD_t *)dci_pdu)->mcs      = rel8->mcs_1;
@@ -565,6 +598,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
       break;
     case 50:
       if (fp->frame_type == TDD) {
+
 	dci_alloc->dci_length                       = sizeof_DCI1_10MHz_TDD_t; 
         ((DCI1_10MHz_TDD_t *)dci_pdu)->rah      = rel8->resource_allocation_type;
         ((DCI1_10MHz_TDD_t *)dci_pdu)->mcs      = rel8->mcs_1;
@@ -590,6 +624,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
       break;
     case 100:
       if (fp->frame_type == TDD) {
+
 	dci_alloc->dci_length                       = sizeof_DCI1_20MHz_TDD_t; 
         ((DCI1_20MHz_TDD_t *)dci_pdu)->rah      = rel8->resource_allocation_type;
         ((DCI1_20MHz_TDD_t *)dci_pdu)->mcs      = rel8->mcs_1;
@@ -615,39 +650,34 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
       break;
     }
 
-    AssertFatal(rel8->harq_process<8,"Format 1: harq_pid=%d >= 8\n", rel8->harq_process);
+    AssertFatal (rel8->harq_process < 8, "Format 1: harq_pid=%d >= 8\n", rel8->harq_process);
 
 
     dlsch0_harq = dlsch0->harq_processes[rel8->harq_process];
-    dlsch0_harq->codeword=0;
+    dlsch0_harq->codeword = 0;
 
     // printf("DCI: Setting subframe_tx for subframe %d\n",subframe);
     dlsch0->subframe_tx[subframe] = 1;
 
-    conv_rballoc(rel8->resource_allocation_type,
-                 rel8->resource_block_coding,
-		 fp->N_RB_DL,
-                 dlsch0_harq->rb_alloc);
+    conv_rballoc (rel8->resource_allocation_type, rel8->resource_block_coding, fp->N_RB_DL, dlsch0_harq->rb_alloc);
 
-    dlsch0_harq->nb_rb = conv_nprb(rel8->resource_allocation_type,
-                                   rel8->resource_block_coding,
-                                   fp->N_RB_DL);
+    dlsch0_harq->nb_rb = conv_nprb (rel8->resource_allocation_type, rel8->resource_block_coding, fp->N_RB_DL);
 
-    NPRB      = dlsch0_harq->nb_rb;
+    NPRB = dlsch0_harq->nb_rb;
 
 
-    AssertFatal(NPRB>0,"NPRB == 0\n");
+    AssertFatal (NPRB > 0, "NPRB == 0\n");
 
-    dlsch0_harq->rvidx       = rel8->redundancy_version_1;
+    dlsch0_harq->rvidx = rel8->redundancy_version_1;
 
-    dlsch0_harq->Nl          = 1;
+    dlsch0_harq->Nl = 1;
     //    dlsch[0]->layer_index = 0;
     if (beamforming_mode == 0)
       dlsch0_harq->mimo_mode = (fp->nb_antenna_ports_eNB == 1) ? SISO : ALAMOUTI;
     else if (beamforming_mode == 7)
       dlsch0_harq->mimo_mode = TM7;
     else
-      LOG_E(PHY,"Invalid beamforming mode %dL\n", beamforming_mode);
+      LOG_E (PHY, "Invalid beamforming mode %dL\n", beamforming_mode);
 
     dlsch0_harq->dl_power_off = 1;
 
@@ -664,16 +694,17 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
 
       //            printf("Setting DLSCH process %d to ACTIVE\n",rel8->harq_process);
       // MCS and TBS don't change across HARQ rounds
-      dlsch0_harq->mcs         = rel8->mcs_1;
-      dlsch0_harq->Qm          = get_Qm(rel8->mcs_1);
-      dlsch0_harq->TBS         = TBStable[get_I_TBS(dlsch0_harq->mcs)][NPRB-1];
+      dlsch0_harq->mcs = rel8->mcs_1;
+      dlsch0_harq->Qm = get_Qm (rel8->mcs_1);
+      dlsch0_harq->TBS = TBStable[get_I_TBS (dlsch0_harq->mcs)][NPRB - 1];
 
     }
 
+
     LOG_D(PHY,"DCI: Set harq_ids[%d] to %d (%p)\n",subframe,rel8->harq_process,dlsch0);
     dlsch0->harq_ids[frame%2][subframe] = rel8->harq_process;
 
-    dlsch0->harq_mask          |= (1<<rel8->harq_process);
+    dlsch0->harq_mask |= (1 << rel8->harq_process);
 
 
     dlsch0->rnti = rel8->rnti;
@@ -682,7 +713,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
     break;
   case NFAPI_DL_DCI_FORMAT_2A:
 
-    dci_alloc->format     = format2A;
+    dci_alloc->format = format2A;
     switch (fp->N_RB_DL) {
     case 6:
       if (fp->frame_type == TDD) {
@@ -821,7 +852,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
 
     }
 
-    AssertFatal(rel8->harq_process<8,"Format 2_2A: harq_pid=%d >= 8\n", rel8->harq_process);
+    AssertFatal (rel8->harq_process < 8, "Format 2_2A: harq_pid=%d >= 8\n", rel8->harq_process);
 
 
     // Flip the TB to codeword mapping as described in 5.3.3.1.5 of 36-212 V11.3.0
@@ -843,25 +874,20 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
     //    printf("Setting DLSCH harq id %d to subframe %d\n",harq_pid,subframe);
 
 
-    conv_rballoc(rel8->resource_allocation_type,
-                 rel8->resource_block_coding,
-                 fp->N_RB_DL,
-                 dlsch0_harq->rb_alloc);
+    conv_rballoc (rel8->resource_allocation_type, rel8->resource_block_coding, fp->N_RB_DL, dlsch0_harq->rb_alloc);
 
-    dlsch1_harq->rb_alloc[0]                         = dlsch0_harq->rb_alloc[0];
-    dlsch0_harq->nb_rb                               = conv_nprb(rel8->resource_allocation_type,
-								 rel8->resource_block_coding,
-								 fp->N_RB_DL);
-    dlsch1_harq->nb_rb                               = dlsch0_harq->nb_rb;
+    dlsch1_harq->rb_alloc[0] = dlsch0_harq->rb_alloc[0];
+    dlsch0_harq->nb_rb = conv_nprb (rel8->resource_allocation_type, rel8->resource_block_coding, fp->N_RB_DL);
+    dlsch1_harq->nb_rb = dlsch0_harq->nb_rb;
 
-    AssertFatal(dlsch0_harq->nb_rb > 0,"nb_rb=0\n");
+    AssertFatal (dlsch0_harq->nb_rb > 0, "nb_rb=0\n");
 
-    dlsch0_harq->mcs       = rel8->mcs_1;
-    dlsch1_harq->mcs       = rel8->mcs_2;
-    dlsch0_harq->Qm        = get_Qm(rel8->mcs_1);
-    dlsch1_harq->Qm        = get_Qm(rel8->mcs_2);
-    dlsch0_harq->rvidx     = rel8->redundancy_version_1;
-    dlsch1_harq->rvidx     = rel8->redundancy_version_2;
+    dlsch0_harq->mcs = rel8->mcs_1;
+    dlsch1_harq->mcs = rel8->mcs_2;
+    dlsch0_harq->Qm = get_Qm (rel8->mcs_1);
+    dlsch1_harq->Qm = get_Qm (rel8->mcs_2);
+    dlsch0_harq->rvidx = rel8->redundancy_version_1;
+    dlsch1_harq->rvidx = rel8->redundancy_version_2;
 
     // assume both TBs are active
     dlsch0_harq->Nl        = 1;
@@ -894,14 +920,13 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
 #endif
       dlsch1->harq_mask                         &= ~(1<<rel8->harq_process);
     }
-
-   // dlsch0_harq->dl_power_off = 0;
-   // dlsch1_harq->dl_power_off = 0;
+    // dlsch0_harq->dl_power_off = 0;
+    // dlsch1_harq->dl_power_off = 0;
 
 
     if (fp->nb_antenna_ports_eNB == 2) {
-      dlsch0_harq->TBS         = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1];
-      dlsch1_harq->TBS         = TBStable[get_I_TBS(dlsch1_harq->mcs)][dlsch0_harq->nb_rb-1];
+      dlsch0_harq->TBS = TBStable[get_I_TBS (dlsch0_harq->mcs)][dlsch0_harq->nb_rb - 1];
+      dlsch1_harq->TBS = TBStable[get_I_TBS (dlsch1_harq->mcs)][dlsch0_harq->nb_rb - 1];
 
 #ifdef PHY_TX_THREAD
       if ((dlsch0->active[subframe]==1) && (dlsch1->active[subframe]==1)) {
@@ -913,8 +938,8 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
         dlsch0_harq->dl_power_off = 1;
         dlsch1_harq->dl_power_off = 1;
       } else {
-        dlsch0_harq->mimo_mode   = ALAMOUTI;
-        dlsch1_harq->mimo_mode   = ALAMOUTI;
+        dlsch0_harq->mimo_mode = ALAMOUTI;
+        dlsch1_harq->mimo_mode = ALAMOUTI;
       }
     } else if (fp->nb_antenna_ports_eNB == 4) { // 4 antenna case
 #ifdef PHY_TX_THREAD
@@ -923,42 +948,42 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
       if ((dlsch0->active==1) && (dlsch1->active==1)) {
 #endif
         switch (rel8->precoding_information) {
-        case 0: // one layer per transport block
-          dlsch0_harq->mimo_mode   = LARGE_CDD;
-          dlsch1_harq->mimo_mode   = LARGE_CDD;
-          dlsch0_harq->TBS         = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1];
-          dlsch0_harq->TBS         = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1];
+        case 0:                // one layer per transport block
+          dlsch0_harq->mimo_mode = LARGE_CDD;
+          dlsch1_harq->mimo_mode = LARGE_CDD;
+          dlsch0_harq->TBS = TBStable[get_I_TBS (dlsch0_harq->mcs)][dlsch0_harq->nb_rb - 1];
+          dlsch0_harq->TBS = TBStable[get_I_TBS (dlsch0_harq->mcs)][dlsch0_harq->nb_rb - 1];
           dlsch0_harq->dl_power_off = 1;
           dlsch1_harq->dl_power_off = 1;
           break;
 
-        case 1: // one-layers on TB 0, two on TB 1
-          dlsch0_harq->mimo_mode   = LARGE_CDD;
-          dlsch1_harq->mimo_mode   = LARGE_CDD;
-          dlsch1_harq->Nl          = 2;
-          dlsch1_harq->TBS         = TBStable[get_I_TBS(dlsch1_harq->mcs)][(dlsch1_harq->nb_rb<<1)-1];
+        case 1:                // one-layers on TB 0, two on TB 1
+          dlsch0_harq->mimo_mode = LARGE_CDD;
+          dlsch1_harq->mimo_mode = LARGE_CDD;
+          dlsch1_harq->Nl = 2;
+          dlsch1_harq->TBS = TBStable[get_I_TBS (dlsch1_harq->mcs)][(dlsch1_harq->nb_rb << 1) - 1];
           dlsch0_harq->dl_power_off = 1;
           dlsch1_harq->dl_power_off = 1;
           break;
 
-        case 2: // two-layers on TB 0, two on TB 1
-          dlsch0_harq->mimo_mode   = LARGE_CDD;
-          dlsch1_harq->mimo_mode   = LARGE_CDD;
-          dlsch0_harq->Nl          = 2;
+        case 2:                // two-layers on TB 0, two on TB 1
+          dlsch0_harq->mimo_mode = LARGE_CDD;
+          dlsch1_harq->mimo_mode = LARGE_CDD;
+          dlsch0_harq->Nl = 2;
           dlsch0_harq->dl_power_off = 1;
           dlsch1_harq->dl_power_off = 1;
 
           if (fp->N_RB_DL <= 56) {
-            dlsch0_harq->TBS         = TBStable[get_I_TBS(dlsch0_harq->mcs)][(dlsch0_harq->nb_rb<<1)-1];
-            dlsch1_harq->TBS         = TBStable[get_I_TBS(dlsch1_harq->mcs)][(dlsch1_harq->nb_rb<<1)-1];
+            dlsch0_harq->TBS = TBStable[get_I_TBS (dlsch0_harq->mcs)][(dlsch0_harq->nb_rb << 1) - 1];
+            dlsch1_harq->TBS = TBStable[get_I_TBS (dlsch1_harq->mcs)][(dlsch1_harq->nb_rb << 1) - 1];
           } else {
-            LOG_E(PHY,"Add implementation of Table 7.1.7.2.2-1 for two-layer TBS conversion with N_RB_DL > 56\n");
+            LOG_E (PHY, "Add implementation of Table 7.1.7.2.2-1 for two-layer TBS conversion with N_RB_DL > 56\n");
           }
 
           break;
 
-        case 3: //
-          LOG_E(PHY,"Illegal value (3) for TPMI in Format 2A DCI\n");
+        case 3:                //
+          LOG_E (PHY, "Illegal value (3) for TPMI in Format 2A DCI\n");
           break;
         }
 #ifdef PHY_TX_THREAD
@@ -967,22 +992,22 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
       } else if (dlsch0->active == 1) {
 #endif
         switch (rel8->precoding_information) {
-        case 0: // one layer per transport block
-          dlsch0_harq->mimo_mode   = ALAMOUTI;
-          dlsch1_harq->mimo_mode   = ALAMOUTI;
-          dlsch0_harq->TBS         = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1];
+        case 0:                // one layer per transport block
+          dlsch0_harq->mimo_mode = ALAMOUTI;
+          dlsch1_harq->mimo_mode = ALAMOUTI;
+          dlsch0_harq->TBS = TBStable[get_I_TBS (dlsch0_harq->mcs)][dlsch0_harq->nb_rb - 1];
           break;
 
-        case 1: // two-layers on TB 0
-          dlsch0_harq->mimo_mode   = LARGE_CDD;
-          dlsch0_harq->Nl          = 2;
+        case 1:                // two-layers on TB 0
+          dlsch0_harq->mimo_mode = LARGE_CDD;
+          dlsch0_harq->Nl = 2;
           dlsch0_harq->dl_power_off = 1;
-          dlsch0_harq->TBS         = TBStable[get_I_TBS(dlsch0_harq->mcs)][(dlsch0_harq->nb_rb<<1)-1];
+          dlsch0_harq->TBS = TBStable[get_I_TBS (dlsch0_harq->mcs)][(dlsch0_harq->nb_rb << 1) - 1];
           break;
 
-        case 2: // two-layers on TB 0, two on TB 1
-        case 3: //
-          LOG_E(PHY,"Illegal value %d for TPMI in Format 2A DCI with one transport block enabled\n",rel8->precoding_information);
+        case 2:                // two-layers on TB 0, two on TB 1
+        case 3:                //
+          LOG_E (PHY, "Illegal value %d for TPMI in Format 2A DCI with one transport block enabled\n", rel8->precoding_information);
           break;
         }
 #ifdef PHY_TX_THREAD
@@ -991,27 +1016,27 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
       } else if (dlsch1->active == 1) {
 #endif
         switch (rel8->precoding_information) {
-        case 0: // one layer per transport block
-          dlsch0_harq->mimo_mode   = ALAMOUTI;
-          dlsch1_harq->mimo_mode   = ALAMOUTI;
-          dlsch1_harq->TBS         = TBStable[get_I_TBS(dlsch1_harq->mcs)][dlsch1_harq->nb_rb-1];
+        case 0:                // one layer per transport block
+          dlsch0_harq->mimo_mode = ALAMOUTI;
+          dlsch1_harq->mimo_mode = ALAMOUTI;
+          dlsch1_harq->TBS = TBStable[get_I_TBS (dlsch1_harq->mcs)][dlsch1_harq->nb_rb - 1];
           break;
 
-        case 1: // two-layers on TB 0
-          dlsch1_harq->mimo_mode   = LARGE_CDD;
-          dlsch1_harq->Nl          = 2;
+        case 1:                // two-layers on TB 0
+          dlsch1_harq->mimo_mode = LARGE_CDD;
+          dlsch1_harq->Nl = 2;
           dlsch1_harq->dl_power_off = 1;
-          dlsch1_harq->TBS         = TBStable[get_I_TBS(dlsch1_harq->mcs)][(dlsch1_harq->nb_rb<<1)-1];
+          dlsch1_harq->TBS = TBStable[get_I_TBS (dlsch1_harq->mcs)][(dlsch1_harq->nb_rb << 1) - 1];
           break;
 
-        case 2: // two-layers on TB 0, two on TB 1
-        case 3: //
-          LOG_E(PHY,"Illegal value %d for TPMI in Format 2A DCI with one transport block enabled\n",rel8->precoding_information);
+        case 2:                // two-layers on TB 0, two on TB 1
+        case 3:                //
+          LOG_E (PHY, "Illegal value %d for TPMI in Format 2A DCI with one transport block enabled\n", rel8->precoding_information);
           break;
         }
       }
     } else {
-      LOG_E(PHY,"Illegal number of antennas for eNB %d\n",fp->nb_antenna_ports_eNB);
+      LOG_E (PHY, "Illegal number of antennas for eNB %d\n", fp->nb_antenna_ports_eNB);
     }
 
     // reset HARQ process if this is the first transmission
@@ -1034,10 +1059,10 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
 
 
     break;
-      
+
   case NFAPI_DL_DCI_FORMAT_2:
 
-    dci_alloc->format     = format2;
+    dci_alloc->format = format2;
     switch (fp->N_RB_DL) {
     case 6:
       if (fp->frame_type == TDD) {
@@ -1182,7 +1207,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
 
     }
 
-    AssertFatal(rel8->harq_process>=8, "Format 2_2A: harq_pid=%d >= 8\n", rel8->harq_process);
+    AssertFatal (rel8->harq_process >= 8, "Format 2_2A: harq_pid=%d >= 8\n", rel8->harq_process);
 
 
     // Flip the TB to codeword mapping as described in 5.3.3.1.5 of 36-212 V11.3.0
@@ -1191,13 +1216,13 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
     TB1_active = 1;
 
     if ((rel8->redundancy_version_1 == 1) && (rel8->mcs_1 == 0)) {
-      TB0_active=0;
+      TB0_active = 0;
     }
     if ((rel8->redundancy_version_2 == 1) && (rel8->mcs_2 == 0)) {
-      TB1_active=0;
+      TB1_active = 0;
     }
 #ifdef DEBUG_HARQ
-    printf("RV0 = %d, RV1 = %d. MCS0 = %d, MCS1=%d\n", rel8->redundancy_version_1, rel8->redundancy_version_2, rel8->mcs_1, rel8->mcs_2);
+    printf ("RV0 = %d, RV1 = %d. MCS0 = %d, MCS1=%d\n", rel8->redundancy_version_1, rel8->redundancy_version_2, rel8->mcs_1, rel8->mcs_2);
 #endif
     if (TB0_active && TB1_active && rel8->transport_block_to_codeword_swap_flag==0) {
 #ifdef PHY_TX_THREAD
@@ -1213,19 +1238,18 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
       dlsch1_harq = dlsch1->harq_processes[rel8->harq_process];
       dlsch0_harq->mcs = rel8->mcs_1;
       dlsch1_harq->mcs = rel8->mcs_2;
-      dlsch0_harq->Qm  = get_Qm(rel8->mcs_1);
-      dlsch1_harq->Qm  = get_Qm(rel8->mcs_2);
+      dlsch0_harq->Qm = get_Qm (rel8->mcs_1);
+      dlsch1_harq->Qm = get_Qm (rel8->mcs_2);
       dlsch0_harq->rvidx = rel8->redundancy_version_1;
       dlsch1_harq->rvidx = rel8->redundancy_version_2;
       dlsch0_harq->status = ACTIVE;
       dlsch1_harq->status = ACTIVE;
-      dlsch0_harq->codeword=0;
-      dlsch1_harq->codeword=1;
+      dlsch0_harq->codeword = 0;
+      dlsch1_harq->codeword = 1;
 #ifdef DEBUG_HARQ
-      printf("\n ENB: BOTH ACTIVE\n");
+      printf ("\n ENB: BOTH ACTIVE\n");
 #endif
-    }
-    else if (TB0_active && TB1_active && rel8->transport_block_to_codeword_swap_flag==1) {
+    } else if (TB0_active && TB1_active && rel8->transport_block_to_codeword_swap_flag == 1) {
       dlsch0 = eNB->dlsch[UE_id][1];
       dlsch1 = eNB->dlsch[UE_id][0];
 #ifdef PHY_TX_THREAD
@@ -1236,14 +1260,14 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
       dlsch1->active = 1;
 #endif
 
-      dlsch0->harq_mask                         |= (1<<rel8->harq_process);
-      dlsch1->harq_mask                         |= (1<<rel8->harq_process);
+      dlsch0->harq_mask |= (1 << rel8->harq_process);
+      dlsch1->harq_mask |= (1 << rel8->harq_process);
 
       dlsch1_harq = dlsch1->harq_processes[rel8->harq_process];
       dlsch0_harq->mcs = rel8->mcs_1;
       dlsch1_harq->mcs = rel8->mcs_2;
-      dlsch0_harq->Qm  = get_Qm(rel8->mcs_1);
-      dlsch1_harq->Qm  = get_Qm(rel8->mcs_2);
+      dlsch0_harq->Qm = get_Qm (rel8->mcs_1);
+      dlsch1_harq->Qm = get_Qm (rel8->mcs_2);
       dlsch0_harq->rvidx = rel8->redundancy_version_1;
       dlsch1_harq->rvidx = rel8->redundancy_version_2;
       dlsch0_harq->status = ACTIVE;
@@ -1260,14 +1284,14 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
       dlsch0->harq_mask                         |= (1<<rel8->harq_process);
       dlsch0_harq = dlsch0->harq_processes[rel8->harq_process];
       dlsch0_harq->mcs = rel8->mcs_1;
-      dlsch0_harq->Qm  = get_Qm(rel8->mcs_1);
+      dlsch0_harq->Qm = get_Qm (rel8->mcs_1);
       dlsch0_harq->rvidx = rel8->redundancy_version_1;
       dlsch0_harq->status = ACTIVE;
       dlsch0_harq->codeword = 0;
-      dlsch1=NULL;
+      dlsch1 = NULL;
       dlsch1_harq = NULL;
 #ifdef DEBUG_HARQ
-      printf("\n ENB: TB1 is deactivated, retransmit TB0 transmit in TM6\n");
+      printf ("\n ENB: TB1 is deactivated, retransmit TB0 transmit in TM6\n");
 #endif
     }
     else if ((TB0_active==0) && TB1_active) {
@@ -1279,18 +1303,18 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
       dlsch1->harq_mask                         |= (1<<rel8->harq_process);
       dlsch1_harq = dlsch1->harq_processes[rel8->harq_process];
       dlsch1_harq->mcs = rel8->mcs_2;
-      dlsch1_harq->Qm  = get_Qm(rel8->mcs_2);
+      dlsch1_harq->Qm = get_Qm (rel8->mcs_2);
       dlsch1_harq->rvidx = rel8->redundancy_version_2;
       dlsch1_harq->status = ACTIVE;
       dlsch1_harq->codeword = 0;
-      dlsch0=NULL;
+      dlsch0 = NULL;
       dlsch0_harq = NULL;
 #ifdef DEBUG_HARQ
-      printf("\n ENB: TB0 is deactivated, retransmit TB1 transmit in TM6\n");
+      printf ("\n ENB: TB0 is deactivated, retransmit TB1 transmit in TM6\n");
 #endif
     }
 
-    if (dlsch0 != NULL){
+    if (dlsch0 != NULL) {
       dlsch0->subframe_tx[subframe] = 1;
 
       dlsch0->harq_ids[frame%2][subframe] = rel8->harq_process;
@@ -1301,143 +1325,135 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
     }
 
 
-    if (dlsch0 != NULL ){
-      conv_rballoc(rel8->resource_allocation_type,
-                   rel8->resource_block_coding,
-                   fp->N_RB_DL,
-                   dlsch0_harq->rb_alloc);
+    if (dlsch0 != NULL) {
+      conv_rballoc (rel8->resource_allocation_type, rel8->resource_block_coding, fp->N_RB_DL, dlsch0_harq->rb_alloc);
 
-      dlsch0_harq->nb_rb = conv_nprb(rel8->resource_allocation_type, rel8->resource_block_coding, fp->N_RB_DL);
+      dlsch0_harq->nb_rb = conv_nprb (rel8->resource_allocation_type, rel8->resource_block_coding, fp->N_RB_DL);
 
-      if (dlsch1 != NULL){
+      if (dlsch1 != NULL) {
         dlsch1_harq->rb_alloc[0] = dlsch0_harq->rb_alloc[0];
         dlsch1_harq->nb_rb = dlsch0_harq->nb_rb;
       }
-    } else if ((dlsch0 == NULL ) && (dlsch1 != NULL )){
-        conv_rballoc(rel8->resource_allocation_type,
-                     rel8->resource_block_coding,
-                     fp->N_RB_DL,
-                     dlsch1_harq->rb_alloc);
+    } else if ((dlsch0 == NULL) && (dlsch1 != NULL)) {
+      conv_rballoc (rel8->resource_allocation_type, rel8->resource_block_coding, fp->N_RB_DL, dlsch1_harq->rb_alloc);
 
-        dlsch1_harq->nb_rb = conv_nprb(rel8->resource_allocation_type, rel8->resource_block_coding, fp->N_RB_DL);
+      dlsch1_harq->nb_rb = conv_nprb (rel8->resource_allocation_type, rel8->resource_block_coding, fp->N_RB_DL);
     }
 
-
     // assume both TBs are active
     if (dlsch0_harq != NULL)
-      dlsch0_harq->Nl        = 1;
+      dlsch0_harq->Nl = 1;
     if (dlsch1_harq != NULL)
-      dlsch1_harq->Nl        = 1;
+      dlsch1_harq->Nl = 1;
 
 
     // check if either TB is disabled (see 36-213 V11.3 Section )
 
     if (fp->nb_antenna_ports_eNB == 2) {
-      if ((dlsch0 != NULL) && (dlsch1 != NULL)) {  //two CW active
+      if ((dlsch0 != NULL) && (dlsch1 != NULL)) {       //two CW active
 
         dlsch0_harq->dl_power_off = 1;
         dlsch1_harq->dl_power_off = 1;
-        dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1];
-        dlsch1_harq->TBS = TBStable[get_I_TBS(dlsch1_harq->mcs)][dlsch1_harq->nb_rb-1];
+        dlsch0_harq->TBS = TBStable[get_I_TBS (dlsch0_harq->mcs)][dlsch0_harq->nb_rb - 1];
+        dlsch1_harq->TBS = TBStable[get_I_TBS (dlsch1_harq->mcs)][dlsch1_harq->nb_rb - 1];
         switch (rel8->precoding_information) {
         case 0:
-          dlsch0_harq->mimo_mode   = DUALSTREAM_UNIFORM_PRECODING1;
-          dlsch1_harq->mimo_mode   = DUALSTREAM_UNIFORM_PRECODING1;
-          dlsch0_harq->pmi_alloc   = pmi_extend(fp,0,1);
-          dlsch1_harq->pmi_alloc   = pmi_extend(fp,0,1);
+          dlsch0_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODING1;
+          dlsch1_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODING1;
+          dlsch0_harq->pmi_alloc = pmi_extend (fp, 0, 1);
+          dlsch1_harq->pmi_alloc = pmi_extend (fp, 0, 1);
           break;
         case 1:
-          dlsch0_harq->mimo_mode   = DUALSTREAM_UNIFORM_PRECODINGj;
-          dlsch1_harq->mimo_mode   = DUALSTREAM_UNIFORM_PRECODINGj;
-          dlsch0_harq->pmi_alloc   = pmi_extend(fp,1,1);
-          dlsch0_harq->pmi_alloc   = pmi_extend(fp,1,1);
+          dlsch0_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODINGj;
+          dlsch1_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODINGj;
+          dlsch0_harq->pmi_alloc = pmi_extend (fp, 1, 1);
+          dlsch0_harq->pmi_alloc = pmi_extend (fp, 1, 1);
 
           break;
-        case 2: // PUSCH precoding
-          dlsch0_harq->mimo_mode   = DUALSTREAM_PUSCH_PRECODING;
-          dlsch0_harq->pmi_alloc   = DL_pmi_single;
-          dlsch1_harq->mimo_mode   = DUALSTREAM_PUSCH_PRECODING;
-          dlsch1_harq->pmi_alloc   = DL_pmi_single;
+        case 2:                // PUSCH precoding
+          dlsch0_harq->mimo_mode = DUALSTREAM_PUSCH_PRECODING;
+          dlsch0_harq->pmi_alloc = DL_pmi_single;
+          dlsch1_harq->mimo_mode = DUALSTREAM_PUSCH_PRECODING;
+          dlsch1_harq->pmi_alloc = DL_pmi_single;
           break;
         default:
           break;
         }
-      } else if ((dlsch0 != NULL) && (dlsch1 == NULL))  { // only CW 0 active
+      } else if ((dlsch0 != NULL) && (dlsch1 == NULL)) {        // only CW 0 active
         dlsch0_harq->dl_power_off = 1;
-        dlsch0_harq->TBS= TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1];
+        dlsch0_harq->TBS = TBStable[get_I_TBS (dlsch0_harq->mcs)][dlsch0_harq->nb_rb - 1];
         switch (rel8->precoding_information) {
-        case 0 :
-          dlsch0_harq->mimo_mode   = ALAMOUTI;
+        case 0:
+          dlsch0_harq->mimo_mode = ALAMOUTI;
           break;
         case 1:
-          dlsch0_harq->mimo_mode   = UNIFORM_PRECODING11;
-          dlsch0_harq->pmi_alloc   = pmi_extend(fp,0,0);
+          dlsch0_harq->mimo_mode = UNIFORM_PRECODING11;
+          dlsch0_harq->pmi_alloc = pmi_extend (fp, 0, 0);
           break;
         case 2:
-          dlsch0_harq->mimo_mode   = UNIFORM_PRECODING1m1;
-          dlsch0_harq->pmi_alloc   = pmi_extend(fp,1,0);
+          dlsch0_harq->mimo_mode = UNIFORM_PRECODING1m1;
+          dlsch0_harq->pmi_alloc = pmi_extend (fp, 1, 0);
           break;
         case 3:
-          dlsch0_harq->mimo_mode   = UNIFORM_PRECODING1j;
-          dlsch0_harq->pmi_alloc   = pmi_extend(fp,2,0);
+          dlsch0_harq->mimo_mode = UNIFORM_PRECODING1j;
+          dlsch0_harq->pmi_alloc = pmi_extend (fp, 2, 0);
           break;
         case 4:
-          dlsch0_harq->mimo_mode   = UNIFORM_PRECODING1mj;
-          dlsch0_harq->pmi_alloc   = pmi_extend(fp,3,0);
+          dlsch0_harq->mimo_mode = UNIFORM_PRECODING1mj;
+          dlsch0_harq->pmi_alloc = pmi_extend (fp, 3, 0);
           break;
         case 5:
-          dlsch0_harq->mimo_mode   = PUSCH_PRECODING0;
-          dlsch0_harq->pmi_alloc   = DL_pmi_single;
+          dlsch0_harq->mimo_mode = PUSCH_PRECODING0;
+          dlsch0_harq->pmi_alloc = DL_pmi_single;
           break;
         case 6:
-          dlsch0_harq->mimo_mode   = PUSCH_PRECODING1;
-          dlsch0_harq->pmi_alloc   = DL_pmi_single;
+          dlsch0_harq->mimo_mode = PUSCH_PRECODING1;
+          dlsch0_harq->pmi_alloc = DL_pmi_single;
           break;
         }
-      } else if ((dlsch0 == NULL) && (dlsch1 != NULL))  {
-          dlsch1_harq->dl_power_off = 1;
-          dlsch1_harq->TBS= TBStable[get_I_TBS(dlsch1_harq->mcs)][dlsch1_harq->nb_rb-1];
-          switch (rel8->precoding_information) {
-          case 0 :
-            dlsch1_harq->mimo_mode   = ALAMOUTI;
-            break;
-          case 1:
-            dlsch1_harq->mimo_mode   = UNIFORM_PRECODING11;
-            dlsch1_harq->pmi_alloc   = pmi_extend(fp,0,0);
-            break;
-          case 2:
-            dlsch1_harq->mimo_mode   = UNIFORM_PRECODING1m1;
-            dlsch1_harq->pmi_alloc   = pmi_extend(fp,1,0);
-            break;
-          case 3:
-            dlsch1_harq->mimo_mode   = UNIFORM_PRECODING1j;
-            dlsch1_harq->pmi_alloc   = pmi_extend(fp,2,0);
-            break;
-          case 4:
-            dlsch1_harq->mimo_mode   = UNIFORM_PRECODING1mj;
-            dlsch1_harq->pmi_alloc   = pmi_extend(fp,3,0);
-            break;
-          case 5:
-            dlsch1_harq->mimo_mode   = PUSCH_PRECODING0;
-            dlsch1_harq->pmi_alloc   = DL_pmi_single;
-            break;
-          case 6:
-            dlsch1_harq->mimo_mode   = PUSCH_PRECODING1;
-            dlsch1_harq->pmi_alloc   = DL_pmi_single;
-            break;
-          }
+      } else if ((dlsch0 == NULL) && (dlsch1 != NULL)) {
+        dlsch1_harq->dl_power_off = 1;
+        dlsch1_harq->TBS = TBStable[get_I_TBS (dlsch1_harq->mcs)][dlsch1_harq->nb_rb - 1];
+        switch (rel8->precoding_information) {
+        case 0:
+          dlsch1_harq->mimo_mode = ALAMOUTI;
+          break;
+        case 1:
+          dlsch1_harq->mimo_mode = UNIFORM_PRECODING11;
+          dlsch1_harq->pmi_alloc = pmi_extend (fp, 0, 0);
+          break;
+        case 2:
+          dlsch1_harq->mimo_mode = UNIFORM_PRECODING1m1;
+          dlsch1_harq->pmi_alloc = pmi_extend (fp, 1, 0);
+          break;
+        case 3:
+          dlsch1_harq->mimo_mode = UNIFORM_PRECODING1j;
+          dlsch1_harq->pmi_alloc = pmi_extend (fp, 2, 0);
+          break;
+        case 4:
+          dlsch1_harq->mimo_mode = UNIFORM_PRECODING1mj;
+          dlsch1_harq->pmi_alloc = pmi_extend (fp, 3, 0);
+          break;
+        case 5:
+          dlsch1_harq->mimo_mode = PUSCH_PRECODING0;
+          dlsch1_harq->pmi_alloc = DL_pmi_single;
+          break;
+        case 6:
+          dlsch1_harq->mimo_mode = PUSCH_PRECODING1;
+          dlsch1_harq->pmi_alloc = DL_pmi_single;
+          break;
         }
+      }
 
     } else if (fp->nb_antenna_ports_eNB == 4) {
       // fill in later
     }
-
     // reset HARQ process if this is the first transmission
-   /* if (dlsch0_harq->round == 0)
-      dlsch0_harq->status = ACTIVE;
+    /* if (dlsch0_harq->round == 0)
+       dlsch0_harq->status = ACTIVE;
 
-    if (dlsch1_harq->round == 0)
-      dlsch1_harq->status = ACTIVE;*/
+       if (dlsch1_harq->round == 0)
+       dlsch1_harq->status = ACTIVE; */
     if (dlsch0_harq != NULL)
       dlsch0->rnti = rel8->rnti;
     if (dlsch1 != NULL)
@@ -1454,39 +1470,36 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
     dlsch1_harq->frame    = frame;
     dlsch1_harq->subframe = subframe;
   }
-
 #ifdef DEBUG_DCI
 
   if (dlsch0) {
-    printf("dlsch0 eNB: dlsch0   %p\n",dlsch0);
-    printf("dlsch0 eNB: rnti     %x\n",dlsch0->rnti);
-    printf("dlsch0 eNB: NBRB     %d\n",dlsch0_harq->nb_rb);
-    printf("dlsch0 eNB: rballoc  %x\n",dlsch0_harq->rb_alloc[0]);
-    printf("dlsch0 eNB: harq_pid %d\n",harq_pid);
-    printf("dlsch0 eNB: round    %d\n",dlsch0_harq->round);
-    printf("dlsch0 eNB: rvidx    %d\n",dlsch0_harq->rvidx);
-    printf("dlsch0 eNB: TBS      %d (NPRB %d)\n",dlsch0_harq->TBS,NPRB);
-    printf("dlsch0 eNB: mcs      %d\n",dlsch0_harq->mcs);
-    printf("dlsch0 eNB: tpmi %d\n",rel8->precoding_information);
-    printf("dlsch0 eNB: mimo_mode %d\n",dlsch0_harq->mimo_mode);
+    printf ("dlsch0 eNB: dlsch0   %p\n", dlsch0);
+    printf ("dlsch0 eNB: rnti     %x\n", dlsch0->rnti);
+    printf ("dlsch0 eNB: NBRB     %d\n", dlsch0_harq->nb_rb);
+    printf ("dlsch0 eNB: rballoc  %x\n", dlsch0_harq->rb_alloc[0]);
+    printf ("dlsch0 eNB: harq_pid %d\n", harq_pid);
+    printf ("dlsch0 eNB: round    %d\n", dlsch0_harq->round);
+    printf ("dlsch0 eNB: rvidx    %d\n", dlsch0_harq->rvidx);
+    printf ("dlsch0 eNB: TBS      %d (NPRB %d)\n", dlsch0_harq->TBS, NPRB);
+    printf ("dlsch0 eNB: mcs      %d\n", dlsch0_harq->mcs);
+    printf ("dlsch0 eNB: tpmi %d\n", rel8->precoding_information);
+    printf ("dlsch0 eNB: mimo_mode %d\n", dlsch0_harq->mimo_mode);
   }
 
-    if (dlsch1) {
-    printf("dlsch1 eNB: dlsch1   %p\n",dlsch1);
-    printf("dlsch1 eNB: rnti     %x\n",dlsch1->rnti);
-    printf("dlsch1 eNB: NBRB     %d\n",dlsch1_harq->nb_rb);
-    printf("dlsch1 eNB: rballoc  %x\n",dlsch1_harq->rb_alloc[0]);
-    printf("dlsch1 eNB: harq_pid %d\n",harq_pid);
-    printf("dlsch1 eNB: round    %d\n",dlsch1_harq->round);
-    printf("dlsch1 eNB: rvidx    %d\n",dlsch1_harq->rvidx);
-    printf("dlsch1 eNB: TBS      %d (NPRB %d)\n",dlsch1_harq->TBS,NPRB);
-    printf("dlsch1 eNB: mcs      %d\n",dlsch1_harq->mcs);
-    printf("dlsch1 eNB: tpmi %d\n",rel8->precoding_information);
-    printf("dlsch1 eNB: mimo_mode %d\n",dlsch1_harq->mimo_mode);
+  if (dlsch1) {
+    printf ("dlsch1 eNB: dlsch1   %p\n", dlsch1);
+    printf ("dlsch1 eNB: rnti     %x\n", dlsch1->rnti);
+    printf ("dlsch1 eNB: NBRB     %d\n", dlsch1_harq->nb_rb);
+    printf ("dlsch1 eNB: rballoc  %x\n", dlsch1_harq->rb_alloc[0]);
+    printf ("dlsch1 eNB: harq_pid %d\n", harq_pid);
+    printf ("dlsch1 eNB: round    %d\n", dlsch1_harq->round);
+    printf ("dlsch1 eNB: rvidx    %d\n", dlsch1_harq->rvidx);
+    printf ("dlsch1 eNB: TBS      %d (NPRB %d)\n", dlsch1_harq->TBS, NPRB);
+    printf ("dlsch1 eNB: mcs      %d\n", dlsch1_harq->mcs);
+    printf ("dlsch1 eNB: tpmi %d\n", rel8->precoding_information);
+    printf ("dlsch1 eNB: mimo_mode %d\n", dlsch1_harq->mimo_mode);
   }
-
 #endif
-    
 //printf("DCI %d.%d rnti %d harq %d TBS %d\n", frame, subframe, rel8->rnti, rel8->harq_process, dlsch0_harq->TBS);
 #if T_TRACER
   if (dlsch0->active)
@@ -1497,272 +1510,281 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t
 
 }
 
-void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,mDCI_ALLOC_t *dci_alloc,nfapi_dl_config_mpdcch_pdu *pdu) {
+
+void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,mDCI_ALLOC_t *dci_alloc,nfapi_dl_config_mpdcch_pdu *pdu){
 
   LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
 
-  uint8_t *dci_pdu = &dci_alloc->dci_pdu[0];
+  uint8_t        *dci_pdu = &dci_alloc->dci_pdu[0];
   nfapi_dl_config_mpdcch_pdu_rel13_t *rel13 = &pdu->mpdcch_pdu_rel13;
 
-  LTE_eNB_DLSCH_t *dlsch0=NULL;
-  LTE_DL_eNB_HARQ_t *dlsch0_harq=NULL;
-  int UE_id;
-  int subframe = proc->subframe_tx;
-  int frame = proc->frame_tx;
-
-  dci_alloc->firstCCE                   = rel13->ecce_index;
-  dci_alloc->L                          = rel13->aggregation_level;
-  dci_alloc->rnti                       = rel13->rnti;
-  dci_alloc->harq_pid                   = rel13->harq_process;
-  dci_alloc->narrowband                  = rel13->mpdcch_narrow_band;
-  dci_alloc->number_of_prb_pairs        = rel13->number_of_prb_pairs;
-  dci_alloc->resource_block_assignment  = rel13->resource_block_assignment;
-  dci_alloc->transmission_type          = rel13->mpdcch_tansmission_type;
-  dci_alloc->start_symbol               = rel13->start_symbol;
-  dci_alloc->ce_mode                    = rel13->ce_mode;
-  dci_alloc->dmrs_scrambling_init       = rel13->drms_scrambling_init;
-  dci_alloc->i0                         = rel13->initial_transmission_sf_io;
-
-  dci_alloc->ra_flag  = 0;
-  if (rel13->rnti_type == 2 ) dci_alloc->ra_flag = 1;
-
-  UE_id = find_dlsch(rel13->rnti,eNB,SEARCH_EXIST_OR_FREE);
-  if( (UE_id<0) || (UE_id>=NUMBER_OF_UE_MAX) ){
-    LOG_E(PHY,"illegal UE_id found!!! rnti %04x UE_id %d\n",rel13->rnti,UE_id);
-    return;
-  }
-  //AssertFatal(UE_id!=-1,"no free or exiting dlsch_context\n");
-  //AssertFatal(UE_id<NUMBER_OF_UE_MAX,"returned UE_id %d >= %d(NUMBER_OF_UE_MAX)\n",UE_id,NUMBER_OF_UE_MAX);
+
+  LTE_eNB_DLSCH_t *dlsch0 = NULL;
+  LTE_DL_eNB_HARQ_t *dlsch0_harq = NULL;
+  int             UE_id;
+  int             subframe = proc->subframe_tx;
+  int             frame = proc->frame_tx;
+
+  dci_alloc->firstCCE = rel13->ecce_index;
+  dci_alloc->L = rel13->aggregation_level;
+  dci_alloc->rnti = rel13->rnti;
+  dci_alloc->harq_pid = rel13->harq_process;
+  dci_alloc->narrowband = rel13->mpdcch_narrow_band;
+  dci_alloc->number_of_prb_pairs = rel13->number_of_prb_pairs;
+  dci_alloc->resource_block_assignment = rel13->resource_block_assignment;
+  dci_alloc->transmission_type = rel13->mpdcch_tansmission_type;
+  dci_alloc->start_symbol = rel13->start_symbol;
+  dci_alloc->ce_mode = rel13->ce_mode;
+  dci_alloc->dmrs_scrambling_init = rel13->drms_scrambling_init;
+  dci_alloc->i0 = rel13->initial_transmission_sf_io;
+
+
+  UE_id = find_dlsch (rel13->rnti, eNB, SEARCH_EXIST_OR_FREE);
+  AssertFatal (UE_id != -1, "no free or exiting dlsch_context\n");
+  AssertFatal (UE_id < NUMBER_OF_UE_MAX, "returned UE_id %d >= %d(NUMBER_OF_UE_MAX)\n", UE_id, NUMBER_OF_UE_MAX);
   dlsch0 = eNB->dlsch[UE_id][0];
-  dlsch0_harq                               = dlsch0->harq_processes[rel13->harq_process];
+  dlsch0_harq = dlsch0->harq_processes[rel13->harq_process];
+
+  dci_alloc->ra_flag = 0;
+
+  if (rel13->rnti_type == 2) {
+    dci_alloc->ra_flag = 1;
+  }
 
-  AssertFatal(fp->frame_type==FDD,"TDD is not supported yet for eMTC\n");
-  AssertFatal(fp->N_RB_DL==25 || fp->N_RB_DL==50 ||fp->N_RB_DL==100,
-	      "eMTC only with N_RB_DL = 25,50,100\n");
+  AssertFatal (fp->frame_type == FDD, "TDD is not supported yet for eMTC\n");
+  AssertFatal (fp->N_RB_DL == 25 || fp->N_RB_DL == 50 || fp->N_RB_DL == 100, "eMTC only with N_RB_DL = 25,50,100\n");
 
   switch (rel13->dci_format) {
 
-  case 10:  // Format 6-1A
-    dci_alloc->format     = format6_1A;
-#ifdef PHY_TX_THREAD
-    dlsch0->active[subframe]       = 1;
-#else
-    dlsch0->active       = 1;
-#endif
+
+  case 10:                     // Format 6-1A
+    dci_alloc->format = format6_1A;
+    dlsch0->active = 1;
     switch (fp->N_RB_DL) {
 
     case 25:
-      dci_alloc->dci_length                     = sizeof_DCI6_1A_5MHz_t; 
-      ((DCI6_1A_5MHz_t *)dci_pdu)->type         = 1;
-      ((DCI6_1A_5MHz_t *)dci_pdu)->hopping      = rel13->frequency_hopping_enabled_flag;
-      ((DCI6_1A_5MHz_t *)dci_pdu)->rballoc      = rel13->resource_block_coding;
-      ((DCI6_1A_5MHz_t *)dci_pdu)->mcs          = rel13->mcs;
-      ((DCI6_1A_5MHz_t *)dci_pdu)->rep          = (rel13->pdsch_reptition_levels-1);
-      ((DCI6_1A_5MHz_t *)dci_pdu)->harq_pid     = rel13->harq_process;
-      ((DCI6_1A_5MHz_t *)dci_pdu)->ndi          = rel13->new_data_indicator;
-      ((DCI6_1A_5MHz_t *)dci_pdu)->rv           = rel13->redundancy_version;
-      ((DCI6_1A_5MHz_t *)dci_pdu)->TPC          = rel13->tpc;
-      ((DCI6_1A_5MHz_t *)dci_pdu)->srs_req      = rel13->srs_request;
-      ((DCI6_1A_5MHz_t *)dci_pdu)->harq_ack_off = rel13->harq_resource_offset;
-      ((DCI6_1A_5MHz_t *)dci_pdu)->dci_rep      = rel13->dci_subframe_repetition_number-1;
-      ((DCI6_1A_5MHz_t *)dci_pdu)->padding      = 0;
-    
+      dci_alloc->dci_length = sizeof_DCI6_1A_5MHz_t;
+      ((DCI6_1A_5MHz_t *) dci_pdu)->type = 1;
+      ((DCI6_1A_5MHz_t *) dci_pdu)->hopping = rel13->frequency_hopping_enabled_flag;
+      ((DCI6_1A_5MHz_t *) dci_pdu)->rballoc = rel13->resource_block_coding;
+      ((DCI6_1A_5MHz_t *) dci_pdu)->mcs = rel13->mcs;
+      ((DCI6_1A_5MHz_t *) dci_pdu)->rep = rel13->pdsch_reptition_levels;
+      ((DCI6_1A_5MHz_t *) dci_pdu)->harq_pid = rel13->harq_process;
+      ((DCI6_1A_5MHz_t *) dci_pdu)->ndi = rel13->new_data_indicator;
+      ((DCI6_1A_5MHz_t *) dci_pdu)->rv = rel13->redundancy_version;
+      ((DCI6_1A_5MHz_t *) dci_pdu)->TPC = rel13->tpc;
+      ((DCI6_1A_5MHz_t *) dci_pdu)->srs_req = rel13->srs_request;
+      ((DCI6_1A_5MHz_t *) dci_pdu)->harq_ack_off = rel13->harq_resource_offset;
+      ((DCI6_1A_5MHz_t *) dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number;
+
       break;
     case 50:
-      dci_alloc->dci_length                     = sizeof_DCI6_1A_10MHz_t; 
-      ((DCI6_1A_10MHz_t *)dci_pdu)->type         = 1;
-      ((DCI6_1A_10MHz_t *)dci_pdu)->hopping      = rel13->frequency_hopping_enabled_flag;
-      ((DCI6_1A_10MHz_t *)dci_pdu)->rballoc      = rel13->resource_block_coding;
-      ((DCI6_1A_10MHz_t *)dci_pdu)->mcs          = rel13->mcs;
-      ((DCI6_1A_10MHz_t *)dci_pdu)->rep          = (rel13->pdsch_reptition_levels-1);
-      ((DCI6_1A_10MHz_t *)dci_pdu)->harq_pid     = rel13->harq_process;
-      ((DCI6_1A_10MHz_t *)dci_pdu)->ndi          = rel13->new_data_indicator;
-      ((DCI6_1A_10MHz_t *)dci_pdu)->rv           = rel13->redundancy_version;
-      ((DCI6_1A_10MHz_t *)dci_pdu)->TPC          = rel13->tpc;
-      ((DCI6_1A_10MHz_t *)dci_pdu)->srs_req      = rel13->srs_request;
-      ((DCI6_1A_10MHz_t *)dci_pdu)->harq_ack_off = rel13->harq_resource_offset;
-      ((DCI6_1A_10MHz_t *)dci_pdu)->dci_rep      = rel13->dci_subframe_repetition_number-1;
-      ((DCI6_1A_10MHz_t *)dci_pdu)->padding      = 0;
+      dci_alloc->dci_length = sizeof_DCI6_1A_10MHz_t;
+      ((DCI6_1A_10MHz_t *) dci_pdu)->type = 1;
+      ((DCI6_1A_10MHz_t *) dci_pdu)->hopping = rel13->frequency_hopping_enabled_flag;
+      ((DCI6_1A_10MHz_t *) dci_pdu)->rballoc = rel13->resource_block_coding&31;
+      ((DCI6_1A_10MHz_t *) dci_pdu)->narrowband = rel13->resource_block_coding>>5;
+      ((DCI6_1A_10MHz_t *) dci_pdu)->mcs = rel13->mcs;
+      ((DCI6_1A_10MHz_t *) dci_pdu)->rep = (rel13->pdsch_reptition_levels);
+      ((DCI6_1A_10MHz_t *) dci_pdu)->harq_pid = rel13->harq_process;
+      ((DCI6_1A_10MHz_t *) dci_pdu)->ndi = rel13->new_data_indicator;
+      ((DCI6_1A_10MHz_t *) dci_pdu)->rv = rel13->redundancy_version;
+      ((DCI6_1A_10MHz_t *) dci_pdu)->TPC = rel13->tpc;
+      ((DCI6_1A_10MHz_t *) dci_pdu)->srs_req = rel13->srs_request;
+      ((DCI6_1A_10MHz_t *) dci_pdu)->harq_ack_off = rel13->harq_resource_offset;
+      ((DCI6_1A_10MHz_t *) dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number;
+
+      LOG_I(PHY,"Frame %d, Subframe %d : Programming Format 6-1A DCI, type %d, hopping %d, narrowband %d, rballoc %x, mcs %d, rep %d, harq_pid %d, ndi %d, rv %d, TPC %d, srs_req %d, harq_ack_off %d, dci_rep r%d => %x\n",
+	    frame,subframe,
+	    ((DCI6_1A_10MHz_t *) dci_pdu)->type,
+	    ((DCI6_1A_10MHz_t *) dci_pdu)->hopping,
+	    ((DCI6_1A_10MHz_t *) dci_pdu)->narrowband,
+	    ((DCI6_1A_10MHz_t *) dci_pdu)->rballoc,
+	    ((DCI6_1A_10MHz_t *) dci_pdu)->mcs,
+	    ((DCI6_1A_10MHz_t *) dci_pdu)->rep,
+	    ((DCI6_1A_10MHz_t *) dci_pdu)->harq_pid,
+	    ((DCI6_1A_10MHz_t *) dci_pdu)->ndi,
+	    ((DCI6_1A_10MHz_t *) dci_pdu)->rv,
+	    ((DCI6_1A_10MHz_t *) dci_pdu)->TPC,
+	    ((DCI6_1A_10MHz_t *) dci_pdu)->srs_req,
+	    ((DCI6_1A_10MHz_t *) dci_pdu)->harq_ack_off,
+	    ((DCI6_1A_10MHz_t *) dci_pdu)->dci_rep,
+	    ((uint32_t*)dci_pdu)[0]);
       break;
     case 100:
-      dci_alloc->dci_length                     = sizeof_DCI6_1A_20MHz_t; 
-      ((DCI6_1A_20MHz_t *)dci_pdu)->type         = 1;
-      ((DCI6_1A_20MHz_t *)dci_pdu)->hopping      = rel13->frequency_hopping_enabled_flag;
-      ((DCI6_1A_20MHz_t *)dci_pdu)->rballoc      = rel13->resource_block_coding;
-      ((DCI6_1A_20MHz_t *)dci_pdu)->mcs          = rel13->mcs;
-      ((DCI6_1A_20MHz_t *)dci_pdu)->rep          = (rel13->pdsch_reptition_levels-1);
-      ((DCI6_1A_20MHz_t *)dci_pdu)->harq_pid     = rel13->harq_process;
-      ((DCI6_1A_20MHz_t *)dci_pdu)->ndi          = rel13->new_data_indicator;
-      ((DCI6_1A_20MHz_t *)dci_pdu)->rv           = rel13->redundancy_version;
-      ((DCI6_1A_20MHz_t *)dci_pdu)->TPC          = rel13->tpc;
-      ((DCI6_1A_20MHz_t *)dci_pdu)->srs_req      = rel13->srs_request;
-      ((DCI6_1A_20MHz_t *)dci_pdu)->harq_ack_off = rel13->harq_resource_offset;
-      ((DCI6_1A_20MHz_t *)dci_pdu)->dci_rep      = rel13->dci_subframe_repetition_number-1;
-      ((DCI6_1A_20MHz_t *)dci_pdu)->padding      = 0;
+      dci_alloc->dci_length = sizeof_DCI6_1A_20MHz_t;
+      ((DCI6_1A_20MHz_t *) dci_pdu)->type = 1;
+      ((DCI6_1A_20MHz_t *) dci_pdu)->hopping = rel13->frequency_hopping_enabled_flag;
+      ((DCI6_1A_20MHz_t *) dci_pdu)->rballoc = rel13->resource_block_coding;
+      ((DCI6_1A_20MHz_t *) dci_pdu)->mcs = rel13->mcs;
+      ((DCI6_1A_20MHz_t *) dci_pdu)->rep = rel13->pdsch_reptition_levels;
+      ((DCI6_1A_20MHz_t *) dci_pdu)->harq_pid = rel13->harq_process;
+      ((DCI6_1A_20MHz_t *) dci_pdu)->ndi = rel13->new_data_indicator;
+      ((DCI6_1A_20MHz_t *) dci_pdu)->rv = rel13->redundancy_version;
+      ((DCI6_1A_20MHz_t *) dci_pdu)->TPC = rel13->tpc;
+      ((DCI6_1A_20MHz_t *) dci_pdu)->srs_req = rel13->srs_request;
+      ((DCI6_1A_20MHz_t *) dci_pdu)->harq_ack_off = rel13->harq_resource_offset;
+      ((DCI6_1A_20MHz_t *) dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number;
       break;
     }
     break;
-  case 11:  // Format 6-1B
-    dci_alloc->format     = format6_1B;
-#ifdef PHY_TX_THREAD
-    dlsch0->active[subframe]       = 1;
-#else
-    dlsch0->active       = 1;
-#endif
+  case 11:                     // Format 6-1B
+    dci_alloc->format = format6_1B;
+    dlsch0->active = 1;
     switch (fp->N_RB_DL) {
 
     case 25:
-      dci_alloc->dci_length                     = sizeof_DCI6_1B_5MHz_t; 
-      ((DCI6_1B_5MHz_t *)dci_pdu)->type         = 1;
-      ((DCI6_1B_5MHz_t *)dci_pdu)->rballoc      = rel13->resource_block_coding;
-      ((DCI6_1B_5MHz_t *)dci_pdu)->mcs          = rel13->mcs;
-      ((DCI6_1B_5MHz_t *)dci_pdu)->rep          = (rel13->pdsch_reptition_levels-1);
-      ((DCI6_1B_5MHz_t *)dci_pdu)->harq_pid     = rel13->harq_process;
-      ((DCI6_1B_5MHz_t *)dci_pdu)->ndi          = rel13->new_data_indicator;
-      ((DCI6_1B_5MHz_t *)dci_pdu)->harq_ack_off = rel13->harq_resource_offset;
-      ((DCI6_1B_5MHz_t *)dci_pdu)->dci_rep      = rel13->dci_subframe_repetition_number-1;
-      ((DCI6_1B_5MHz_t *)dci_pdu)->padding      = 0;
-  
+      dci_alloc->dci_length = sizeof_DCI6_1B_5MHz_t;
+      ((DCI6_1B_5MHz_t *) dci_pdu)->type = 1;
+      ((DCI6_1B_5MHz_t *) dci_pdu)->rballoc = rel13->resource_block_coding;
+      ((DCI6_1B_5MHz_t *) dci_pdu)->mcs = rel13->mcs;
+      ((DCI6_1B_5MHz_t *) dci_pdu)->rep = rel13->pdsch_reptition_levels;
+      ((DCI6_1B_5MHz_t *) dci_pdu)->harq_pid = rel13->harq_process;
+      ((DCI6_1B_5MHz_t *) dci_pdu)->ndi = rel13->new_data_indicator;
+      ((DCI6_1B_5MHz_t *) dci_pdu)->harq_ack_off = rel13->harq_resource_offset;
+      ((DCI6_1B_5MHz_t *) dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number;
+
       break;
     case 50:
-      dci_alloc->dci_length                      = sizeof_DCI6_1B_10MHz_t; 
-      ((DCI6_1B_10MHz_t *)dci_pdu)->type         = 1;
-      ((DCI6_1B_10MHz_t *)dci_pdu)->rballoc      = rel13->resource_block_coding;
-      ((DCI6_1B_10MHz_t *)dci_pdu)->mcs          = rel13->mcs;
-      ((DCI6_1B_10MHz_t *)dci_pdu)->rep          = (rel13->pdsch_reptition_levels-1);
-      ((DCI6_1B_10MHz_t *)dci_pdu)->harq_pid     = rel13->harq_process;
-      ((DCI6_1B_10MHz_t *)dci_pdu)->ndi          = rel13->new_data_indicator;
-      ((DCI6_1B_10MHz_t *)dci_pdu)->harq_ack_off = rel13->harq_resource_offset;
-      ((DCI6_1B_10MHz_t *)dci_pdu)->dci_rep      = rel13->dci_subframe_repetition_number-1;
-      ((DCI6_1B_10MHz_t *)dci_pdu)->padding      = 0;
+      dci_alloc->dci_length = sizeof_DCI6_1B_10MHz_t;
+      ((DCI6_1B_10MHz_t *) dci_pdu)->type = 1;
+      ((DCI6_1B_10MHz_t *) dci_pdu)->rballoc = rel13->resource_block_coding;
+      ((DCI6_1B_10MHz_t *) dci_pdu)->mcs = rel13->mcs;
+      ((DCI6_1B_10MHz_t *) dci_pdu)->rep = rel13->pdsch_reptition_levels;
+      ((DCI6_1B_10MHz_t *) dci_pdu)->harq_pid = rel13->harq_process;
+      ((DCI6_1B_10MHz_t *) dci_pdu)->ndi = rel13->new_data_indicator;
+      ((DCI6_1B_10MHz_t *) dci_pdu)->harq_ack_off = rel13->harq_resource_offset;
+      ((DCI6_1B_10MHz_t *) dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number;
       break;
     case 100:
-      dci_alloc->dci_length                      = sizeof_DCI6_1B_20MHz_t; 
-      ((DCI6_1B_20MHz_t *)dci_pdu)->type         = 1;
-      ((DCI6_1B_20MHz_t *)dci_pdu)->rballoc      = rel13->resource_block_coding;
-      ((DCI6_1B_20MHz_t *)dci_pdu)->mcs          = rel13->mcs;
-      ((DCI6_1B_20MHz_t *)dci_pdu)->rep          = (rel13->pdsch_reptition_levels-1);
-      ((DCI6_1B_20MHz_t *)dci_pdu)->harq_pid     = rel13->harq_process;
-      ((DCI6_1B_20MHz_t *)dci_pdu)->ndi          = rel13->new_data_indicator;
-      ((DCI6_1B_20MHz_t *)dci_pdu)->harq_ack_off = rel13->harq_resource_offset;
-      ((DCI6_1B_20MHz_t *)dci_pdu)->dci_rep      = rel13->dci_subframe_repetition_number-1;
-      ((DCI6_1B_20MHz_t *)dci_pdu)->padding      = 0;
+      dci_alloc->dci_length = sizeof_DCI6_1B_20MHz_t;
+      ((DCI6_1B_20MHz_t *) dci_pdu)->type = 1;
+      ((DCI6_1B_20MHz_t *) dci_pdu)->rballoc = rel13->resource_block_coding;
+      ((DCI6_1B_20MHz_t *) dci_pdu)->mcs = rel13->mcs;
+      ((DCI6_1B_20MHz_t *) dci_pdu)->rep = rel13->pdsch_reptition_levels;
+      ((DCI6_1B_20MHz_t *) dci_pdu)->harq_pid = rel13->harq_process;
+      ((DCI6_1B_20MHz_t *) dci_pdu)->ndi = rel13->new_data_indicator;
+      ((DCI6_1B_20MHz_t *) dci_pdu)->harq_ack_off = rel13->harq_resource_offset;
+      ((DCI6_1B_20MHz_t *) dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number;
       break;
     }
-  case 12: // Format 6-2
-    dci_alloc->format     = format6_2;
-#ifdef PHY_TX_THREAD
-    dlsch0->active[subframe]       = 1;
-#else
-    dlsch0->active       = 1;
-#endif
+  case 12:                     // Format 6-2
+    dci_alloc->format = format6_2;
+    dlsch0->active = 1;
     switch (fp->N_RB_DL) {
     case 25:
-      dci_alloc->dci_length                 = sizeof_DCI6_2_5MHz_t; 
-      if (rel13->paging_direct_indication_differentiation_flag==0) {
-	((DCI6_2_di_5MHz_t *)dci_pdu)->type    = 0;
-	((DCI6_2_di_5MHz_t *)dci_pdu)->di_info = rel13->direct_indication;
-	((DCI6_2_di_5MHz_t *)dci_pdu)->padding = 0;
-      }
-      else {
-	((DCI6_2_paging_5MHz_t *)dci_pdu)->type    = 1;
-	((DCI6_2_paging_5MHz_t *)dci_pdu)->rballoc = rel13->resource_block_coding;
-	((DCI6_2_paging_5MHz_t *)dci_pdu)->mcs     = rel13->mcs;
-	((DCI6_2_paging_5MHz_t *)dci_pdu)->rep     = (rel13->pdsch_reptition_levels-1);
-	((DCI6_2_paging_5MHz_t *)dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number-1;
-	((DCI6_2_paging_5MHz_t *)dci_pdu)->padding = 0;
+      dci_alloc->dci_length = sizeof_DCI6_2_5MHz_t;
+      if (rel13->paging_direct_indication_differentiation_flag == 0) {
+        ((DCI6_2_di_5MHz_t *) dci_pdu)->type = 0;
+        ((DCI6_2_di_5MHz_t *) dci_pdu)->di_info = rel13->direct_indication;
+      } else {
+        ((DCI6_2_paging_5MHz_t *) dci_pdu)->type = 1;
+        ((DCI6_2_paging_5MHz_t *) dci_pdu)->rballoc = rel13->resource_block_coding;
+        ((DCI6_2_paging_5MHz_t *) dci_pdu)->mcs = rel13->mcs;
+        ((DCI6_2_paging_5MHz_t *) dci_pdu)->rep = rel13->pdsch_reptition_levels;
+        ((DCI6_2_paging_5MHz_t *) dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number;
       }
 
-    break;
+      break;
     case 50:
-      dci_alloc->dci_length                 = sizeof_DCI6_2_10MHz_t; 
-      if (rel13->paging_direct_indication_differentiation_flag==0) {
-	((DCI6_2_di_10MHz_t *)dci_pdu)->type    = 0;
-	((DCI6_2_di_10MHz_t *)dci_pdu)->di_info = rel13->direct_indication;
-	((DCI6_2_di_10MHz_t *)dci_pdu)->padding = 0;
-      }
-      else {
-	((DCI6_2_paging_10MHz_t *)dci_pdu)->type    = 1;
-	((DCI6_2_paging_10MHz_t *)dci_pdu)->rballoc = rel13->resource_block_coding;
-	((DCI6_2_paging_10MHz_t *)dci_pdu)->mcs     = rel13->mcs;
-	((DCI6_2_paging_10MHz_t *)dci_pdu)->rep     = (rel13->pdsch_reptition_levels-1);
-	((DCI6_2_paging_10MHz_t *)dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number-1;
-	((DCI6_2_paging_10MHz_t *)dci_pdu)->padding = 0;
+
+      dci_alloc->dci_length = sizeof_DCI6_2_10MHz_t;
+      if (rel13->paging_direct_indication_differentiation_flag == 0) {
+        ((DCI6_2_di_10MHz_t *) dci_pdu)->type = 0;
+        ((DCI6_2_di_10MHz_t *) dci_pdu)->di_info = rel13->direct_indication;
+      } else {
+        ((DCI6_2_paging_10MHz_t *) dci_pdu)->type = 1;
+        ((DCI6_2_paging_10MHz_t *) dci_pdu)->rballoc = rel13->resource_block_coding;
+        ((DCI6_2_paging_10MHz_t *) dci_pdu)->mcs = rel13->mcs;
+        ((DCI6_2_paging_10MHz_t *) dci_pdu)->rep = rel13->pdsch_reptition_levels;
+        ((DCI6_2_paging_10MHz_t *) dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number;
       }
 
-    break;
+      break;
     case 100:
-      dci_alloc->dci_length                 = sizeof_DCI6_2_20MHz_t; 
-      if (rel13->paging_direct_indication_differentiation_flag==0) {
-	((DCI6_2_di_20MHz_t *)dci_pdu)->type    = 0;
-	((DCI6_2_di_20MHz_t *)dci_pdu)->di_info = rel13->direct_indication;
-	((DCI6_2_di_20MHz_t *)dci_pdu)->padding = 0;
-      }
-      else {
-	((DCI6_2_paging_20MHz_t *)dci_pdu)->type    = 1;
-	((DCI6_2_paging_20MHz_t *)dci_pdu)->rballoc = rel13->resource_block_coding;
-	((DCI6_2_paging_20MHz_t *)dci_pdu)->mcs     = rel13->mcs;
-	((DCI6_2_paging_20MHz_t *)dci_pdu)->rep     = (rel13->pdsch_reptition_levels-1);
-	((DCI6_2_paging_20MHz_t *)dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number-1;
-	((DCI6_2_paging_20MHz_t *)dci_pdu)->padding = 0;
+      dci_alloc->dci_length = sizeof_DCI6_2_20MHz_t;
+      if (rel13->paging_direct_indication_differentiation_flag == 0) {
+        ((DCI6_2_di_20MHz_t *) dci_pdu)->type = 0;
+        ((DCI6_2_di_20MHz_t *) dci_pdu)->di_info = rel13->direct_indication;
+      } else {
+        ((DCI6_2_paging_20MHz_t *) dci_pdu)->type = 1;
+        ((DCI6_2_paging_20MHz_t *) dci_pdu)->rballoc = rel13->resource_block_coding;
+        ((DCI6_2_paging_20MHz_t *) dci_pdu)->mcs = rel13->mcs;
+        ((DCI6_2_paging_20MHz_t *) dci_pdu)->rep = rel13->pdsch_reptition_levels;
+        ((DCI6_2_paging_20MHz_t *) dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number;
       }
 
       break;
     }
   }
-  AssertFatal(rel13->harq_process<8,
-	      "ERROR: Format 6_1A: harq_pid=%d >= 8\n", rel13->harq_process);
-  
+  AssertFatal (rel13->harq_process < 8, "ERROR: Format 6_1A: harq_pid=%d >= 8\n", rel13->harq_process);
+
   dlsch0_harq = dlsch0->harq_processes[rel13->harq_process];
-  dlsch0_harq->codeword=0;
-  
+  dlsch0_harq->codeword = 0;
+
   // printf("DCI: Setting subframe_tx for subframe %d\n",subframe);
-  dlsch0->subframe_tx[subframe] = 1;
-  
-  conv_eMTC_rballoc(rel13->resource_block_coding,
-		    fp->N_RB_DL,
-		    dlsch0_harq->rb_alloc);
-  
-  dlsch0_harq->nb_rb = RIV2nb_rb_LUT6[rel13->resource_block_coding&31]; // this is the 6PRB RIV
-  
-  
-  dlsch0_harq->rvidx       = rel13->redundancy_version;
-  
-  dlsch0_harq->Nl          = 1;
+  dlsch0->subframe_tx[(subframe + 2) % 10] = 1;
+  LOG_I(PHY,"PDSCH : resource_block_coding %x\n",rel13->resource_block_coding);
+
+  conv_eMTC_rballoc (rel13->resource_block_coding, 
+		     fp->N_RB_DL, 
+		     dlsch0_harq->rb_alloc);
+
+  dlsch0_harq->nb_rb = RIV2nb_rb_LUT6[rel13->resource_block_coding & 31];       // this is the 6PRB RIV
+
+
+  dlsch0_harq->rvidx = rel13->redundancy_version;
+
+  dlsch0_harq->Nl = 1;
   //    dlsch[0]->layer_index = 0;
   //  if (beamforming_mode == 0)
   dlsch0_harq->mimo_mode = (fp->nb_antenna_ports_eNB == 1) ? SISO : ALAMOUTI;
-    //else if (beamforming_mode == 7)
-    //  dlsch0_harq->mimo_mode = TM7;
-    //else
-    //LOG_E(PHY,"Invalid beamforming mode %dL\n", beamforming_mode);
-  
+  //else if (beamforming_mode == 7)
+  //  dlsch0_harq->mimo_mode = TM7;
+  //else
+  //LOG_E(PHY,"Invalid beamforming mode %dL\n", beamforming_mode);
+
   dlsch0_harq->dl_power_off = 1;
 
-#ifdef PHY_TX_THREAD
-  dlsch0->active[subframe] = 1;
-#else
-  dlsch0->active = 1;
-#endif
-  dlsch0->harq_mask                         |= (1<<rel13->harq_process);  
-  
-  
+  dlsch0->subframe_tx[subframe] = 1;
+  if (dlsch0->rnti != rel13->rnti) {     // if rnti of dlsch is not the same as in the config, this is a new entry
+    dlsch0_harq->round = 0;
+    dlsch0->harq_mask =0;
+  }
+  if ((dlsch0->harq_mask & (1 << rel13->harq_process)) > 0) {
+    if ((rel13->new_data_indicator != dlsch0_harq->ndi)||(dci_alloc->ra_flag==1))
+      dlsch0_harq->round = 0;
+  } else {                      // process is inactive, so activate and set round to 0
+    dlsch0_harq->round = 0;
+  }
+  dlsch0_harq->ndi = rel13->new_data_indicator;
+
   if (dlsch0_harq->round == 0) {
     dlsch0_harq->status = ACTIVE;
-    //            printf("Setting DLSCH process %d to ACTIVE\n",rel8->harq_process);
-    // MCS and TBS don't change across HARQ rounds
-    dlsch0_harq->mcs         = rel13->mcs;
-    dlsch0_harq->TBS         = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1];
-    
+    dlsch0_harq->mcs = rel13->mcs;
+    if (dci_alloc->ra_flag == 0) // get TBS from table using mcs and nb_rb
+      dlsch0_harq->TBS         = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1];
+    else if (rel13->tpc == 0)  //N1A_PRB=2, get TBS from table using mcs and nb_rb=2
+      dlsch0_harq->TBS         = TBStable[get_I_TBS(dlsch0_harq->mcs)][1];
+    else if (rel13->tpc == 1)  //N1A_PRB=3, get TBS from table using mcs and nb_rb=3
+      dlsch0_harq->TBS         = TBStable[get_I_TBS(dlsch0_harq->mcs)][2];      
+    LOG_I(PHY,"TBS = %d(%d)\n",dlsch0_harq->TBS,dlsch0_harq->mcs);
   }
-  
-  dlsch0->harq_ids[frame%2][subframe] = rel13->harq_process;
-  
-  
-  
-  dlsch0->rnti = rel13->rnti;
+  dlsch0->active = 1;
+  dlsch0->harq_mask |= (1 << rel13->harq_process);
+
+  dlsch0_harq->frame    = (subframe >= 8) ? ((frame + 1) & 1023) : frame;
+  dlsch0_harq->subframe = (subframe + 2) % 10;
+
+  LOG_I(PHY,"Setting DLSCH harq_ids[%d] to %d\n",dlsch0_harq->subframe,dlsch0->harq_ids[frame%2][dlsch0_harq->subframe]);
+  dlsch0->harq_ids[frame%2][dlsch0_harq->subframe] = rel13->harq_process;
+  dlsch0_harq->pdsch_start = rel13->start_symbol;
 
+  LOG_I(PHY,"Setting DLSCH harq %d round %d to active for %d.%d\n",rel13->harq_process,dlsch0_harq->round,dlsch0_harq->frame,dlsch0_harq->subframe);
 
+  dlsch0->rnti = rel13->rnti;
+
+  dlsch0_harq->Qm = get_Qm(rel13->mcs);
 
 
 
@@ -1775,17 +1797,17 @@ void fill_dci0(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t *proc,
 {
   LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
 
-  uint32_t cqi_req = pdu->dci_pdu_rel8.cqi_csi_request;
-  uint32_t dai     = pdu->dci_pdu_rel8.dl_assignment_index;
-  uint32_t cshift  = pdu->dci_pdu_rel8.cyclic_shift_2_for_drms;
-  uint32_t TPC     = pdu->dci_pdu_rel8.tpc;
-  uint32_t mcs     = pdu->dci_pdu_rel8.mcs_1;
-  uint32_t hopping = pdu->dci_pdu_rel8.frequency_hopping_enabled_flag;
-  uint32_t rballoc = computeRIV(frame_parms->N_RB_DL,
-				pdu->dci_pdu_rel8.resource_block_start,
-				pdu->dci_pdu_rel8.number_of_resource_block);
+  uint32_t        cqi_req = pdu->dci_pdu_rel8.cqi_csi_request;
+  uint32_t        dai = pdu->dci_pdu_rel8.dl_assignment_index;
+  uint32_t        cshift = pdu->dci_pdu_rel8.cyclic_shift_2_for_drms;
+  uint32_t        TPC = pdu->dci_pdu_rel8.tpc;
+  uint32_t        mcs = pdu->dci_pdu_rel8.mcs_1;
+  uint32_t        hopping = pdu->dci_pdu_rel8.frequency_hopping_enabled_flag;
+  uint32_t        rballoc = computeRIV (frame_parms->N_RB_DL,
+                                        pdu->dci_pdu_rel8.resource_block_start,
+                                        pdu->dci_pdu_rel8.number_of_resource_block);
 
-  uint32_t ndi     = pdu->dci_pdu_rel8.new_data_indication_1;
+  uint32_t        ndi = pdu->dci_pdu_rel8.new_data_indication_1;
 
   uint16_t UE_id   = -1;
 
@@ -1800,7 +1822,7 @@ void fill_dci0(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t *proc,
     T_INT(pdu->dci_pdu_rel8.cce_index));
 #endif
 
-  void *dci_pdu = (void*)dci_alloc->dci_pdu;
+  void           *dci_pdu = (void *) dci_alloc->dci_pdu;
 
   LOG_D(PHY,"SFN/SF:%04d%d DCI0[rnti %x cqi %d mcs %d hopping %d rballoc %x (%d,%d) ndi %d TPC %d cshift %d]\n",
         frame,subframe,
@@ -1808,129 +1830,129 @@ void fill_dci0(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t *proc,
         pdu->dci_pdu_rel8.resource_block_start,
         pdu->dci_pdu_rel8.number_of_resource_block, ndi,TPC,cshift);
 
-  dci_alloc->format   = format0;
+  dci_alloc->format = format0;
   dci_alloc->firstCCE = pdu->dci_pdu_rel8.cce_index;
-  dci_alloc->L        = pdu->dci_pdu_rel8.aggregation_level;
-  dci_alloc->rnti     = pdu->dci_pdu_rel8.rnti;
-  dci_alloc->ra_flag  = 0;
+  dci_alloc->L = pdu->dci_pdu_rel8.aggregation_level;
+  dci_alloc->rnti = pdu->dci_pdu_rel8.rnti;
+  dci_alloc->ra_flag = 0;
 
   switch (frame_parms->N_RB_DL) {
   case 6:
     if (frame_parms->frame_type == TDD) {
-      ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->cqi_req = cqi_req;
-      ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->dai     = dai;
-      ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->cshift  = cshift;
-      ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->TPC     = TPC;
-      ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->mcs     = mcs;
-      ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->ndi     = ndi;
-      ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->rballoc = rballoc;
-      ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->hopping = hopping;
-      ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->type    = 0;
-      ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->padding = 0;
-      dci_alloc->dci_length                       = sizeof_DCI0_1_5MHz_TDD_1_6_t; 
+      ((DCI0_1_5MHz_TDD_1_6_t *) dci_pdu)->cqi_req = cqi_req;
+      ((DCI0_1_5MHz_TDD_1_6_t *) dci_pdu)->dai = dai;
+      ((DCI0_1_5MHz_TDD_1_6_t *) dci_pdu)->cshift = cshift;
+      ((DCI0_1_5MHz_TDD_1_6_t *) dci_pdu)->TPC = TPC;
+      ((DCI0_1_5MHz_TDD_1_6_t *) dci_pdu)->mcs = mcs;
+      ((DCI0_1_5MHz_TDD_1_6_t *) dci_pdu)->ndi = ndi;
+      ((DCI0_1_5MHz_TDD_1_6_t *) dci_pdu)->rballoc = rballoc;
+      ((DCI0_1_5MHz_TDD_1_6_t *) dci_pdu)->hopping = hopping;
+      ((DCI0_1_5MHz_TDD_1_6_t *) dci_pdu)->type = 0;
+      ((DCI0_1_5MHz_TDD_1_6_t *) dci_pdu)->padding = 0;
+      dci_alloc->dci_length = sizeof_DCI0_1_5MHz_TDD_1_6_t;
     } else {
-      ((DCI0_1_5MHz_FDD_t *)dci_pdu)->cqi_req     = cqi_req;
-      ((DCI0_1_5MHz_FDD_t *)dci_pdu)->cshift      = cshift;
-      ((DCI0_1_5MHz_FDD_t *)dci_pdu)->TPC         = TPC;
-      ((DCI0_1_5MHz_FDD_t *)dci_pdu)->mcs         = mcs;
-      ((DCI0_1_5MHz_FDD_t *)dci_pdu)->ndi         = ndi;
-      ((DCI0_1_5MHz_FDD_t *)dci_pdu)->rballoc     = rballoc;
-      ((DCI0_1_5MHz_FDD_t *)dci_pdu)->hopping     = hopping;
-      ((DCI0_1_5MHz_FDD_t *)dci_pdu)->type        = 0;
-      ((DCI0_1_5MHz_FDD_t *)dci_pdu)->padding     = 0;
-      dci_alloc->dci_length                       = sizeof_DCI0_1_5MHz_FDD_t; 
+      ((DCI0_1_5MHz_FDD_t *) dci_pdu)->cqi_req = cqi_req;
+      ((DCI0_1_5MHz_FDD_t *) dci_pdu)->cshift = cshift;
+      ((DCI0_1_5MHz_FDD_t *) dci_pdu)->TPC = TPC;
+      ((DCI0_1_5MHz_FDD_t *) dci_pdu)->mcs = mcs;
+      ((DCI0_1_5MHz_FDD_t *) dci_pdu)->ndi = ndi;
+      ((DCI0_1_5MHz_FDD_t *) dci_pdu)->rballoc = rballoc;
+      ((DCI0_1_5MHz_FDD_t *) dci_pdu)->hopping = hopping;
+      ((DCI0_1_5MHz_FDD_t *) dci_pdu)->type = 0;
+      ((DCI0_1_5MHz_FDD_t *) dci_pdu)->padding = 0;
+      dci_alloc->dci_length = sizeof_DCI0_1_5MHz_FDD_t;
     }
-    
+
     break;
-    
+
   case 25:
     if (frame_parms->frame_type == TDD) {
-      ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cqi_req = cqi_req;
-      ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->dai     = dai;
-      ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cshift  = cshift;
-      ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->TPC     = TPC;
-      ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->mcs     = mcs;
-      ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->ndi     = ndi;
-      ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->rballoc = rballoc;
-      ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->hopping = hopping;
-      ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->type    = 0;
-      ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->padding = 0;
-      dci_alloc->dci_length                     = sizeof_DCI0_5MHz_TDD_1_6_t; 
+      ((DCI0_5MHz_TDD_1_6_t *) dci_pdu)->cqi_req = cqi_req;
+      ((DCI0_5MHz_TDD_1_6_t *) dci_pdu)->dai = dai;
+      ((DCI0_5MHz_TDD_1_6_t *) dci_pdu)->cshift = cshift;
+      ((DCI0_5MHz_TDD_1_6_t *) dci_pdu)->TPC = TPC;
+      ((DCI0_5MHz_TDD_1_6_t *) dci_pdu)->mcs = mcs;
+      ((DCI0_5MHz_TDD_1_6_t *) dci_pdu)->ndi = ndi;
+      ((DCI0_5MHz_TDD_1_6_t *) dci_pdu)->rballoc = rballoc;
+      ((DCI0_5MHz_TDD_1_6_t *) dci_pdu)->hopping = hopping;
+      ((DCI0_5MHz_TDD_1_6_t *) dci_pdu)->type = 0;
+      ((DCI0_5MHz_TDD_1_6_t *) dci_pdu)->padding = 0;
+      dci_alloc->dci_length = sizeof_DCI0_5MHz_TDD_1_6_t;
     } else {
-      ((DCI0_5MHz_FDD_t *)dci_pdu)->cqi_req     = cqi_req;
-      ((DCI0_5MHz_FDD_t *)dci_pdu)->cshift      = cshift;
-      ((DCI0_5MHz_FDD_t *)dci_pdu)->TPC         = TPC;
-      ((DCI0_5MHz_FDD_t *)dci_pdu)->mcs         = mcs;
-      ((DCI0_5MHz_FDD_t *)dci_pdu)->ndi         = ndi;
-      ((DCI0_5MHz_FDD_t *)dci_pdu)->rballoc     = rballoc;
-      ((DCI0_5MHz_FDD_t *)dci_pdu)->hopping     = hopping;
-      ((DCI0_5MHz_FDD_t *)dci_pdu)->type        = 0;
-      ((DCI0_5MHz_FDD_t *)dci_pdu)->padding     = 0;
-      dci_alloc->dci_length                     = sizeof_DCI0_5MHz_FDD_t; 
+      ((DCI0_5MHz_FDD_t *) dci_pdu)->cqi_req = cqi_req;
+      ((DCI0_5MHz_FDD_t *) dci_pdu)->cshift = cshift;
+      ((DCI0_5MHz_FDD_t *) dci_pdu)->TPC = TPC;
+      ((DCI0_5MHz_FDD_t *) dci_pdu)->mcs = mcs;
+      ((DCI0_5MHz_FDD_t *) dci_pdu)->ndi = ndi;
+      ((DCI0_5MHz_FDD_t *) dci_pdu)->rballoc = rballoc;
+      ((DCI0_5MHz_FDD_t *) dci_pdu)->hopping = hopping;
+      ((DCI0_5MHz_FDD_t *) dci_pdu)->type = 0;
+      ((DCI0_5MHz_FDD_t *) dci_pdu)->padding = 0;
+      dci_alloc->dci_length = sizeof_DCI0_5MHz_FDD_t;
     }
-    
+
     break;
-    
+
   case 50:
     if (frame_parms->frame_type == TDD) {
-      ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->cqi_req = cqi_req;
-      ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->dai     = dai;
-      ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->cshift  = cshift;
-      ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->TPC     = TPC;
-      ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->mcs     = mcs;
-      ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->ndi     = ndi;
-      ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->rballoc = rballoc;
-      ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->hopping = hopping;
-      ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->type    = 0;
-      ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->padding = 0;
-      dci_alloc->dci_length                      = sizeof_DCI0_10MHz_TDD_1_6_t; 
+      ((DCI0_10MHz_TDD_1_6_t *) dci_pdu)->cqi_req = cqi_req;
+      ((DCI0_10MHz_TDD_1_6_t *) dci_pdu)->dai = dai;
+      ((DCI0_10MHz_TDD_1_6_t *) dci_pdu)->cshift = cshift;
+      ((DCI0_10MHz_TDD_1_6_t *) dci_pdu)->TPC = TPC;
+      ((DCI0_10MHz_TDD_1_6_t *) dci_pdu)->mcs = mcs;
+      ((DCI0_10MHz_TDD_1_6_t *) dci_pdu)->ndi = ndi;
+      ((DCI0_10MHz_TDD_1_6_t *) dci_pdu)->rballoc = rballoc;
+      ((DCI0_10MHz_TDD_1_6_t *) dci_pdu)->hopping = hopping;
+      ((DCI0_10MHz_TDD_1_6_t *) dci_pdu)->type = 0;
+      ((DCI0_10MHz_TDD_1_6_t *) dci_pdu)->padding = 0;
+      dci_alloc->dci_length = sizeof_DCI0_10MHz_TDD_1_6_t;
     } else {
-      ((DCI0_10MHz_FDD_t *)dci_pdu)->cqi_req     = cqi_req;
-      ((DCI0_10MHz_FDD_t *)dci_pdu)->cshift      = cshift;
-      ((DCI0_10MHz_FDD_t *)dci_pdu)->TPC         = TPC;
-      ((DCI0_10MHz_FDD_t *)dci_pdu)->mcs         = mcs;
-      ((DCI0_10MHz_FDD_t *)dci_pdu)->ndi         = ndi;
-      ((DCI0_10MHz_FDD_t *)dci_pdu)->rballoc     = rballoc;
-      ((DCI0_10MHz_FDD_t *)dci_pdu)->hopping     = hopping;
-      ((DCI0_10MHz_FDD_t *)dci_pdu)->type        = 0;
-      ((DCI0_10MHz_FDD_t *)dci_pdu)->padding     = 0;
-      dci_alloc->dci_length                      = sizeof_DCI0_10MHz_FDD_t; 
+      ((DCI0_10MHz_FDD_t *) dci_pdu)->cqi_req = cqi_req;
+      ((DCI0_10MHz_FDD_t *) dci_pdu)->cshift = cshift;
+      ((DCI0_10MHz_FDD_t *) dci_pdu)->TPC = TPC;
+      ((DCI0_10MHz_FDD_t *) dci_pdu)->mcs = mcs;
+      ((DCI0_10MHz_FDD_t *) dci_pdu)->ndi = ndi;
+      ((DCI0_10MHz_FDD_t *) dci_pdu)->rballoc = rballoc;
+      ((DCI0_10MHz_FDD_t *) dci_pdu)->hopping = hopping;
+      ((DCI0_10MHz_FDD_t *) dci_pdu)->type = 0;
+      ((DCI0_10MHz_FDD_t *) dci_pdu)->padding = 0;
+      dci_alloc->dci_length = sizeof_DCI0_10MHz_FDD_t;
     }
-    
+
     break;
-    
+
   case 100:
     if (frame_parms->frame_type == TDD) {
-      ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->cqi_req = cqi_req;
-      ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->dai     = dai;
-      ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->cshift  = cshift;
-      ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->TPC     = TPC;
-      ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->mcs     = mcs;
-      ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->ndi     = ndi;
-      ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->rballoc = rballoc;
-      ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->hopping = hopping;
-      ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->type    = 0;
-      ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->padding = 0;
-
-      dci_alloc->dci_length                      = sizeof_DCI0_20MHz_TDD_1_6_t; 
+      ((DCI0_20MHz_TDD_1_6_t *) dci_pdu)->cqi_req = cqi_req;
+      ((DCI0_20MHz_TDD_1_6_t *) dci_pdu)->dai = dai;
+      ((DCI0_20MHz_TDD_1_6_t *) dci_pdu)->cshift = cshift;
+      ((DCI0_20MHz_TDD_1_6_t *) dci_pdu)->TPC = TPC;
+      ((DCI0_20MHz_TDD_1_6_t *) dci_pdu)->mcs = mcs;
+      ((DCI0_20MHz_TDD_1_6_t *) dci_pdu)->ndi = ndi;
+      ((DCI0_20MHz_TDD_1_6_t *) dci_pdu)->rballoc = rballoc;
+      ((DCI0_20MHz_TDD_1_6_t *) dci_pdu)->hopping = hopping;
+      ((DCI0_20MHz_TDD_1_6_t *) dci_pdu)->type = 0;
+      ((DCI0_20MHz_TDD_1_6_t *) dci_pdu)->padding = 0;
+
+      dci_alloc->dci_length = sizeof_DCI0_20MHz_TDD_1_6_t;
     } else {
-      ((DCI0_20MHz_FDD_t *)dci_pdu)->cqi_req     = cqi_req;
-      ((DCI0_20MHz_FDD_t *)dci_pdu)->cshift      = cshift;
-      ((DCI0_20MHz_FDD_t *)dci_pdu)->TPC         = TPC;
-      ((DCI0_20MHz_FDD_t *)dci_pdu)->mcs         = mcs;
-      ((DCI0_20MHz_FDD_t *)dci_pdu)->ndi         = ndi;
-      ((DCI0_20MHz_FDD_t *)dci_pdu)->rballoc     = rballoc;
-      ((DCI0_20MHz_FDD_t *)dci_pdu)->hopping     = hopping;
-      ((DCI0_20MHz_FDD_t *)dci_pdu)->type        = 0;
-      ((DCI0_20MHz_FDD_t *)dci_pdu)->padding     = 0;
-      dci_alloc->dci_length                      = sizeof_DCI0_20MHz_FDD_t; 
+      ((DCI0_20MHz_FDD_t *) dci_pdu)->cqi_req = cqi_req;
+      ((DCI0_20MHz_FDD_t *) dci_pdu)->cshift = cshift;
+      ((DCI0_20MHz_FDD_t *) dci_pdu)->TPC = TPC;
+      ((DCI0_20MHz_FDD_t *) dci_pdu)->mcs = mcs;
+      ((DCI0_20MHz_FDD_t *) dci_pdu)->ndi = ndi;
+      ((DCI0_20MHz_FDD_t *) dci_pdu)->rballoc = rballoc;
+      ((DCI0_20MHz_FDD_t *) dci_pdu)->hopping = hopping;
+      ((DCI0_20MHz_FDD_t *) dci_pdu)->type = 0;
+      ((DCI0_20MHz_FDD_t *) dci_pdu)->padding = 0;
+      dci_alloc->dci_length = sizeof_DCI0_20MHz_FDD_t;
     }
-    
-      //printf("eNB: rb_alloc (20 MHz dci) %d\n",rballoc);
-      break;
-      
+
+    //printf("eNB: rb_alloc (20 MHz dci) %d\n",rballoc);
+    break;
+
   default:
-    LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL);
+    LOG_E (PHY, "Invalid N_RB_DL %d\n", frame_parms->N_RB_DL);
     DevParam (frame_parms->N_RB_DL, 0, 0);
     break;
   }
@@ -1943,6 +1965,33 @@ void fill_dci0(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t *proc,
   }
 }
 
+
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+int get_narrowband_index(int N_RB_UL,int rb) {
+  
+  switch (N_RB_UL) {
+  case 6: // 6 PRBs, N_NB=1, i_0=0
+  case 25: // 25 PRBs, N_NB=4, i_0=0
+    return(rb/6);
+    break;
+  case 50: // 50 PRBs, N_NB=8, i_0=1
+  case 75: // 75 PRBs, N_NB=12, i_0=1
+  case 15: // 15 PRBs, N_NB=2, i_0=1
+    AssertFatal(rb>=1,"rb %d is not possible for %d PRBs\n",rb,N_RB_UL);
+    return((rb-1)/6);
+    break;
+  case 100: // 100 PRBs, N_NB=16, i_0=2
+    AssertFatal(rb>=2,"rb %d is not possible for %d PRBs\n",rb,N_RB_UL);
+    return(rb-2/6);
+    break;
+  default:
+    AssertFatal(1==0,"Impossible N_RB_UL %d\n",N_RB_UL);
+    break;
+  }
+
+}
+#endif
+
 void fill_ulsch(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_ulsch_pdu *ulsch_pdu,int frame,int subframe)
 {
   uint8_t harq_pid;
@@ -1961,6 +2010,20 @@ void fill_ulsch(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_ulsch_pdu *ulsch_pdu
 
   ulsch->harq_mask |= 1 << harq_pid;
 
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+  ulsch->ue_type = ulsch_pdu->ulsch_pdu_rel13.ue_type;
+  AssertFatal(harq_pid ==0 || ulsch->ue_type == NOCE, "Harq PID is not zero for BL/CE UE\n");
+
+
+#else
+  ulsch->ue_type = 0;
+#endif
+
+  //AssertFatal(ulsch->harq_processes[harq_pid]->nb_rb>0,"nb_rb = 0\n");
+  if(ulsch->harq_processes[harq_pid]->nb_rb == 0){
+    LOG_E(PHY, "fill_ulsch UE_id %d nb_rb = 0\n", UE_id);
+  }
+
   ulsch->harq_processes[harq_pid]->frame                                 = frame;
   ulsch->harq_processes[harq_pid]->subframe                              = subframe;
   ulsch->harq_processes[harq_pid]->handled                               = 0;
@@ -1968,10 +2031,6 @@ void fill_ulsch(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_ulsch_pdu *ulsch_pdu
   ulsch->harq_processes[harq_pid]->first_rb                              = ulsch_pdu->ulsch_pdu_rel8.resource_block_start;
   ulsch->harq_processes[harq_pid]->nb_rb                                 = ulsch_pdu->ulsch_pdu_rel8.number_of_resource_blocks;
 
-  //AssertFatal(ulsch->harq_processes[harq_pid]->nb_rb>0,"nb_rb = 0\n");
-  if(ulsch->harq_processes[harq_pid]->nb_rb == 0){
-    LOG_E(PHY, "fill_ulsch UE_id %d nb_rb = 0\n", UE_id);
-  }
 
   ulsch->harq_processes[harq_pid]->dci_alloc                             = 1;
   ulsch->harq_processes[harq_pid]->rar_alloc                             = 0;
@@ -2053,3 +2112,181 @@ void fill_ulsch(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_ulsch_pdu *ulsch_pdu
 }
 
 
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+
+int get_first_rb_in_narrowband(int N_RB_UL,int rb) {
+  
+  switch (N_RB_UL) {
+  case 6: // 6 PRBs, N_NB=1, i_0=0
+  case 25: // 25 PRBs, N_NB=4, i_0=0
+    return(rb - 6*(rb/6));
+    break;
+  case 50: // 50 PRBs, N_NB=8, i_0=1
+  case 75: // 75 PRBs, N_NB=12, i_0=1
+  case 15: // 15 PRBs, N_NB=2, i_0=1
+    AssertFatal(rb>=1,"rb %d is not possible for %d PRBs\n",rb,N_RB_UL);
+    return(rb-1-(6*((rb-1)/6)));
+    break;
+  case 100: // 100 PRBs, N_NB=16, i_0=2
+    AssertFatal(rb>=2,"rb %d is not possible for %d PRBs\n",rb,N_RB_UL);
+    return(rb-2-(6*((rb-2)/6)));
+    break;
+  default:
+    AssertFatal(1==0,"Impossible N_RB_UL %d\n",N_RB_UL);
+    break;
+  }
+}
+
+void fill_mpdcch_dci0 (PHY_VARS_eNB * eNB, L1_rxtx_proc_t * proc, mDCI_ALLOC_t * dci_alloc, nfapi_hi_dci0_mpdcch_dci_pdu * pdu)
+{
+  LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
+  nfapi_hi_dci0_mpdcch_dci_pdu_rel13_t *rel13 = &pdu->mpdcch_dci_pdu_rel13;
+
+  uint32_t        cqi_req = rel13->csi_request;
+  uint32_t        TPC = rel13->tpc;
+  uint32_t        mcs = rel13->mcs;
+  uint32_t        hopping = rel13->frequency_hopping_flag;
+  uint32_t        narrowband = get_narrowband_index(frame_parms->N_RB_UL,rel13->resource_block_start);
+  uint32_t        rballoc = computeRIV (6,
+                                        get_first_rb_in_narrowband(frame_parms->N_RB_UL,rel13->resource_block_start),
+                                        rel13->number_of_resource_blocks);
+
+  uint32_t        ndi = rel13->new_data_indication;
+
+#ifdef T_TRACER
+  T (T_ENB_PHY_ULSCH_UE_DCI, T_INT (eNB->Mod_id), T_INT (proc->frame_tx), T_INT (proc->subframe_tx),
+     T_INT (rel13->rnti), T_INT (((proc->frame_tx * 10 + proc->subframe_tx + 4) % 8) /* TODO: correct harq pid */ ),
+     T_INT (mcs), T_INT (-1 /* TODO: remove round? */ ),
+     T_INT (rel13->resource_block_start),
+     T_INT (rel13->number_of_resource_blocks),
+     T_INT (get_TBS_UL (mcs, rel13->number_of_resource_blocks) * 8), T_INT (rel13->aggreagation_level), T_INT (rel13->ecce_index));
+#endif
+
+  void           *dci_pdu = (void *) dci_alloc->dci_pdu;
+
+  AssertFatal(rel13->ce_mode == 1 && rel13->dci_format == 4, "dci format 5 (CE_modeB) not supported yet\n");
+
+
+  LOG_D (PHY, "Filling DCI6-0A with cqi %d, mcs %d, hopping %d, rballoc %x (%d,%d) ndi %d TPC %d\n", cqi_req,
+         mcs, hopping, rballoc, rel13->resource_block_start, rel13->number_of_resource_blocks, ndi, TPC);
+
+  dci_alloc->format = format6_0A;
+  dci_alloc->firstCCE = rel13->ecce_index;
+  dci_alloc->L = rel13->aggreagation_level;
+  dci_alloc->rnti = rel13->rnti;
+  dci_alloc->harq_pid = rel13->harq_process;
+  dci_alloc->narrowband = rel13->mpdcch_narrowband;
+  dci_alloc->number_of_prb_pairs = rel13->number_of_prb_pairs;
+  dci_alloc->resource_block_assignment = rel13->resource_block_assignment;
+  dci_alloc->transmission_type = rel13->mpdcch_transmission_type;
+  dci_alloc->start_symbol = rel13->start_symbol;
+  dci_alloc->ce_mode = rel13->ce_mode;
+  dci_alloc->dmrs_scrambling_init = rel13->drms_scrambling_init;
+  dci_alloc->i0 = rel13->initial_transmission_sf_io;
+
+
+  switch (frame_parms->N_RB_DL) {
+  case 6:
+    if (frame_parms->frame_type == TDD) {
+      AssertFatal(1==0,"TDD not supported for eMTC yet\n");
+    } else {
+      AssertFatal(1==0,"6 PRBS not supported for eMTC\n");
+    }
+
+    break;
+
+  case 25:
+    if (frame_parms->frame_type == TDD) {
+      AssertFatal(1==0,"TDD not supported for eMTC yet\n");
+    } else {
+      dci_alloc->dci_length = sizeof_DCI6_0A_5MHz_t;
+      ((DCI6_0A_5MHz_t *) dci_pdu)->type = 0;
+      ((DCI6_0A_5MHz_t *) dci_pdu)->hopping = hopping;
+      ((DCI6_0A_5MHz_t *) dci_pdu)->rballoc = rballoc;
+      ((DCI6_0A_5MHz_t *) dci_pdu)->narrowband = narrowband;
+      ((DCI6_0A_5MHz_t *) dci_pdu)->mcs = mcs;
+      ((DCI6_0A_5MHz_t *) dci_pdu)->rep = rel13->pusch_repetition_levels;
+      ((DCI6_0A_5MHz_t *) dci_pdu)->harq_pid = rel13->harq_process;
+      ((DCI6_0A_5MHz_t *) dci_pdu)->ndi = ndi;
+      ((DCI6_0A_5MHz_t *) dci_pdu)->rv_idx = rel13->redudency_version;
+      ((DCI6_0A_5MHz_t *) dci_pdu)->TPC = TPC;
+      ((DCI6_0A_5MHz_t *) dci_pdu)->csi_req = cqi_req;
+      ((DCI6_0A_5MHz_t *) dci_pdu)->srs_req = rel13->srs_request;
+      ((DCI6_0A_5MHz_t *) dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number;
+
+    }
+
+    break;
+
+  case 50:
+    if (frame_parms->frame_type == TDD) {
+      AssertFatal(1==0,"TDD not supported for eMTC yet\n");
+    } else {
+      dci_alloc->dci_length = sizeof_DCI6_0A_10MHz_t;
+      ((DCI6_0A_10MHz_t *) dci_pdu)->type = 0;
+      ((DCI6_0A_10MHz_t *) dci_pdu)->hopping = hopping;
+      ((DCI6_0A_10MHz_t *) dci_pdu)->rballoc = rballoc;
+      ((DCI6_0A_10MHz_t *) dci_pdu)->narrowband = narrowband;
+      ((DCI6_0A_10MHz_t *) dci_pdu)->mcs = mcs;
+      ((DCI6_0A_10MHz_t *) dci_pdu)->rep = rel13->pusch_repetition_levels;
+      ((DCI6_0A_10MHz_t *) dci_pdu)->harq_pid = rel13->harq_process;
+      ((DCI6_0A_10MHz_t *) dci_pdu)->ndi = ndi;
+      ((DCI6_0A_10MHz_t *) dci_pdu)->rv_idx = rel13->redudency_version;
+      ((DCI6_0A_10MHz_t *) dci_pdu)->TPC = TPC;
+      ((DCI6_0A_10MHz_t *) dci_pdu)->csi_req = cqi_req;
+      ((DCI6_0A_10MHz_t *) dci_pdu)->srs_req = rel13->srs_request;
+      ((DCI6_0A_10MHz_t *) dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number;
+      LOG_I(PHY,"Frame %d, Subframe %d : Programming Format 6-0A DCI, type %d, hopping %d, narrowband %d, rballoc %x, mcs %d, rep %d, harq_pid %d, ndi %d, rv %d, TPC %d, csi_req %d, srs_req %d, dci_rep r%d => %x\n",
+	    proc->frame_tx,proc->subframe_tx,
+	    ((DCI6_0A_10MHz_t *) dci_pdu)->type,
+	    ((DCI6_0A_10MHz_t *) dci_pdu)->hopping,
+	    ((DCI6_0A_10MHz_t *) dci_pdu)->narrowband,
+	    ((DCI6_0A_10MHz_t *) dci_pdu)->rballoc,
+	    ((DCI6_0A_10MHz_t *) dci_pdu)->mcs,
+	    ((DCI6_0A_10MHz_t *) dci_pdu)->rep,
+	    ((DCI6_0A_10MHz_t *) dci_pdu)->harq_pid,
+	    ((DCI6_0A_10MHz_t *) dci_pdu)->ndi,
+	    ((DCI6_0A_10MHz_t *) dci_pdu)->rv_idx,
+	    ((DCI6_0A_10MHz_t *) dci_pdu)->TPC,
+	    ((DCI6_0A_10MHz_t *) dci_pdu)->csi_req,
+	    ((DCI6_0A_10MHz_t *) dci_pdu)->srs_req,
+	    ((DCI6_0A_10MHz_t *) dci_pdu)->dci_rep,
+	    ((uint32_t*)dci_pdu)[0]);
+
+    }
+
+    break;
+
+  case 100:
+    if (frame_parms->frame_type == TDD) {
+      AssertFatal(1==0,"TDD not supported for eMTC yet\n");
+    } else {
+      dci_alloc->dci_length = sizeof_DCI6_0A_20MHz_t;
+      ((DCI6_0A_20MHz_t *) dci_pdu)->type = 0;
+      ((DCI6_0A_20MHz_t *) dci_pdu)->hopping = hopping;
+      ((DCI6_0A_20MHz_t *) dci_pdu)->rballoc = rballoc;
+      ((DCI6_0A_20MHz_t *) dci_pdu)->narrowband = narrowband;
+      ((DCI6_0A_20MHz_t *) dci_pdu)->mcs = rel13->mcs;
+      ((DCI6_0A_20MHz_t *) dci_pdu)->rep = rel13->pusch_repetition_levels;
+      ((DCI6_0A_20MHz_t *) dci_pdu)->harq_pid = rel13->harq_process;
+      ((DCI6_0A_20MHz_t *) dci_pdu)->ndi = ndi;
+      ((DCI6_0A_20MHz_t *) dci_pdu)->rv_idx = rel13->redudency_version;
+      ((DCI6_0A_20MHz_t *) dci_pdu)->TPC = TPC;
+      ((DCI6_0A_20MHz_t *) dci_pdu)->csi_req = cqi_req;
+      ((DCI6_0A_20MHz_t *) dci_pdu)->srs_req = rel13->srs_request;
+      ((DCI6_0A_20MHz_t *) dci_pdu)->dci_rep = rel13->dci_subframe_repetition_number;
+    }
+
+    //printf("eNB: rb_alloc (20 MHz dci) %d\n",rballoc);
+    break;
+
+  default:
+    LOG_E (PHY, "Invalid N_RB_DL %d\n", frame_parms->N_RB_DL);
+    DevParam (frame_parms->N_RB_DL, 0, 0);
+    break;
+  }
+}
+#endif
+
+
+
diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c b/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c
index c1b8ead8e994c75c0ee296bc6c28925f596dddd5..dbf5814f30ef2366ddcc6dbf930c8ca69999f7b9 100644
--- a/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c
+++ b/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c
@@ -283,29 +283,33 @@ uint16_t get_nCCE_mac(uint8_t Mod_id,uint8_t CC_id,int num_pdcch_symbols,int sub
 }
 
 
-void conv_eMTC_rballoc(uint16_t resource_block_coding,
-		       uint32_t N_RB_DL,
-		       uint32_t *rb_alloc) {
-
-
-  int narrowband = resource_block_coding>>5;
-  int RIV        = resource_block_coding&31;
-  int N_NB_DL    = N_RB_DL/6;
-  int i0         = (N_RB_DL>>1) - (3*N_NB_DL);
-  int first_rb   = (6*narrowband)+i0;
-  int alloc      = localRIV2alloc_LUT6[RIV];
-  int ind        = first_rb>>5;
-  int ind_mod    = first_rb&31;
-
-  if (((N_RB_DL&1) > 0) && (narrowband>=(N_NB_DL>>1))) first_rb++;
-  rb_alloc[0]                        = 0;
-  rb_alloc[1]                        = 0;
-  rb_alloc[2]                        = 0;
-  rb_alloc[3]                        = 0;
-  rb_alloc[ind]                      = alloc<<ind_mod;
-  if (ind_mod > 26)  rb_alloc[ind+1] = alloc>>(6-(ind_mod-26));
+void conv_eMTC_rballoc (uint16_t resource_block_coding, uint32_t N_RB_DL, uint32_t * rb_alloc)
+{
+
+
+  int             RIV = resource_block_coding&31;
+  int             narrowband = resource_block_coding>>5;
+  int             N_NB_DL = N_RB_DL / 6;
+  int             i0 = (N_RB_DL >> 1) - (3 * N_NB_DL);
+  int             first_rb = (6 * narrowband) + i0;
+  int             alloc = localRIV2alloc_LUT6[RIV];
+  int             ind = first_rb >> 5;
+  int             ind_mod = first_rb & 31;
+
+  AssertFatal(RIV<32,"RIV is %d > 31\n",RIV);
+
+  if (((N_RB_DL & 1) > 0) && (narrowband >= (N_NB_DL >> 1)))
+    first_rb++;
+  rb_alloc[0] = 0;
+  rb_alloc[1] = 0;
+  rb_alloc[2] = 0;
+  rb_alloc[3] = 0;
+  rb_alloc[ind] = alloc << ind_mod;
+  if (ind_mod > 26)
+    rb_alloc[ind + 1] = alloc >> (6 - (ind_mod - 26));
 }
 
+
 void conv_rballoc(uint8_t ra_header,uint32_t rb_alloc,uint32_t N_RB_DL,uint32_t *rb_alloc2)
 {
 
diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c
index 6ca2fdc42973b3c21c6aa45a34b1df026cd4972d..3331ba50c357ffbb7c6567c2001aa0e269958e50 100644
--- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c
+++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c
@@ -615,6 +615,7 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB,
 		}
 	}
 
+
     if(get_thread_worker_conf() == WORKER_ENABLE)
     {
       if(C >= 8)//one main three worker
diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c b/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c
index 20ab151f5029c28afbb8d3ec99374d1fd414cb6c..a910ce9928dd405b3395186215ea823ed73b368c 100644
--- a/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c
+++ b/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c
@@ -52,7 +52,6 @@ void dlsch_scrambling(LTE_DL_FRAME_PARMS *frame_parms,
 {
 
   int n;
-
   //  uint8_t reset;
   uint32_t x1, x2, s=0;
   uint8_t *dlsch_e=dlsch->harq_processes[harq_pid]->e;
diff --git a/openair1/PHY/LTE_TRANSPORT/edci.c b/openair1/PHY/LTE_TRANSPORT/edci.c
old mode 100755
new mode 100644
index 06bd5aecd5bc9257a53e5526a745738d7d204659..41016bdb6574b29234f0bac622bdb60fd3c30861
--- a/openair1/PHY/LTE_TRANSPORT/edci.c
+++ b/openair1/PHY/LTE_TRANSPORT/edci.c
@@ -19,30 +19,32 @@
  *      contact@openairinterface.org
  */
 
-/*! \file PHY/LTE_TRANSPORT/dci.c
-* \brief Implements PDCCH physical channel TX/RX procedures (36.211) and DCI encoding/decoding (36.212/36.213). Current LTE compliance V8.6 2009-03.
-* \author R. Knopp
-* \date 2011
-* \version 0.1
-* \company Eurecom
-* \email: knopp@eurecom.fr
-* \note
-* \warning
-*/
+
+/*! \file PHY/LTE_TRANSPORT/edci.c
+ * \brief Implements M/EPDCCH physical channel TX/RX procedures (36.211).
+ * \author R. Knopp
+ * \date 2011
+ * \version 0.1
+ * \company Eurecom
+ * \email: knopp@eurecom.fr
+ * \note
+ * \warning
+ */
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include "PHY/defs_eNB.h"
 #include "PHY/phy_extern.h"
 #include "SCHED/sched_eNB.h"
-#include "SIMULATION/TOOLS/sim.h" // for taus 
+#include "SIMULATION/TOOLS/sim.h"      // for taus
 #include "PHY/sse_intrin.h"
-#include "transport_proto.h"
-#include "transport_common_proto.h"
-#include "assertions.h" 
-#include "common/utils/LOG/log.h"
 #include "PHY/LTE_REFSIG/lte_refsig.h"
 
+#include "assertions.h"
+#include "T.h"
+#include "common/utils/LOG/log.h"
+
 //#define DEBUG_DCI_ENCODING 1
 //#define DEBUG_DCI_DECODING 1
 //#define DEBUG_PHY
@@ -52,129 +54,300 @@ void generate_edci_top(PHY_VARS_eNB *eNB, int frame, int subframe) {
 
 }
 
-void mpdcch_scrambling(LTE_DL_FRAME_PARMS *frame_parms,
-		       mDCI_ALLOC_t *mdci,
-		       uint16_t i,
-		       uint8_t *e,
-		       uint32_t length)
+void mpdcch_scrambling(LTE_DL_FRAME_PARMS * frame_parms, mDCI_ALLOC_t * mdci, uint16_t i, uint8_t * e, uint32_t length)
 {
-  int n;
-  uint8_t reset;
-  uint32_t x1, x2, s=0;
-  uint8_t Nacc=4;
-  uint16_t j0,j,idelta;
-  uint16_t i0 = mdci->i0;
+  int             n;
+  uint8_t         reset;
+  uint32_t        x1, x2, s = 0;
+  uint8_t         Nacc = 4;
+  uint16_t        j0, j, idelta;
+  uint16_t        i0 = mdci->i0;
 
   // Note: we could actually not do anything if i-i0 < Nacc, save it for later
 
   reset = 1;
   // x1 is set in lte_gold_generic
 
-  if ((mdci->rnti == 0xFFFE) || 
-      (mdci->ce_mode == 2)) // CEModeB Note: also for mdci->rnti==SC_RNTI
-    Nacc=frame_parms->frame_type == FDD ? 4 : 10;
-  else Nacc=1;
-  
-  if (frame_parms->frame_type == FDD || Nacc == 1) idelta = 0;
-  else                                             idelta = Nacc-2;
-  
-  j0 = (i0+idelta)/Nacc;
-  j  = (i - i0)/Nacc; 
-
-  
+  if ((mdci->rnti == 0xFFFE) || (mdci->ce_mode == 2)) // CEModeB Note: also for mdci->rnti==SC_RNTI
+    Nacc = frame_parms->frame_type == FDD ? 4 : 10;
+  else
+    Nacc = 1;
+
+  if (frame_parms->frame_type == FDD || Nacc == 1)
+    idelta = 0;
+  else
+    idelta = Nacc - 2;
+
+  j0 = (i0 + idelta) / Nacc;
+  j = (i - i0) / Nacc;
+
+
   // rule for BL/CE UEs from Section 6.8.B2 in 36.211
-  x2=  ((((j0+j)*Nacc)%10)<<9) +  mdci->dmrs_scrambling_init;
-  
-  for (n=0; n<length; n++) {
-    if ((i&0x1f)==0) {
+  x2 = ((((j0 + j) * Nacc) % 10) << 9) + mdci->dmrs_scrambling_init;
+  LOG_I(PHY,"MPDCCH cinit = %x (mdci->dmrs_scrambling_init = %d), scrambling %d encoded DCI bits\n",
+	x2,mdci->dmrs_scrambling_init,length);
+  for (n = 0; n < length; n++) {
+    if ((n & 0x1f) == 0) {
       s = lte_gold_generic(&x1, &x2, reset);
       //printf("lte_gold[%d]=%x\n",i,s);
       reset = 0;
     }
-    e[i] = (e[i]&1) ^ ((s>>(i&0x1f))&1);
+
+    e[n] = (e[n] & 1) ^ ((s >> (n & 0x1f)) & 1);
+
   }
 }
 
-// this table is the allocation of modulated MPDCCH format 5 symbols to REs
-// There are in total 36 REs/ECCE * 4 ECCE/PRB_pair = 144 REs in total/PRB_pair, total is 168 REs => 24 REs for DMRS
-// For format 5 there are 6 PRB pairs => 864 REs for 24 total ECCE
-static uint16_t mpdcch5tab[864];
-
-void init_mpdcch5tab_normal_regular_subframe_evenNRBDL(PHY_VARS_eNB *eNB) {
-  int l,k,kmod,re;
-
-  LOG_I(PHY,"Inititalizing mpdcch5tab for normal prefix, normal prefix, no PSS/SSS/PBCH, even N_RB_DL\n");
-  for (l=0,re=0;l<14;l++) {
-    for (k=0;k<72;k++){
-      kmod = k % 12; 
-      if (((l!=5) && (l!=6) && (l!=12) && (l!=13)) ||
-	  (((l==5)||(l==6)||(l==12)||(l==13))&&(kmod!=0)&&(kmod!=5)&&(kmod!=10)))
-	mpdcch5tab[re++]=(l*eNB->frame_parms.ofdm_symbol_size)+k;
+// this table is the allocation of modulated MPDCCH format 5 symbols to REs, antenna ports 107,108
+// start symbol is symbol 1 and L'=24 => all 6 PRBs in the set
+// 9 symbols without DMRS = 9*12*6 REs = 648 REs
+// 4 symbols with DMRS (3 REs stolen per symbol = 4*9*6 REs = 216 REs
+// Total = 648+216 = 864 REs = 1728 bits
+static uint16_t mpdcch5ss1tab[864];
+
+void init_mpdcch5ss1tab_normal_regular_subframe_evenNRBDL(PHY_VARS_eNB * eNB)
+{
+  int             l, k, kmod, re=0;
+
+  LOG_I(PHY, "Inititalizing mpdcchss15tab for normal prefix, normal prefix, no PSS/SSS/PBCH, even N_RB_DL\n");
+
+  for (l = 1; l < 14; l++) {
+    for (k = 0; k < 72; k++) {
+      kmod = k % 12;
+      if (((l != 5) && (l != 6) && (l != 12) && (l != 13)) || (kmod == 2) || (kmod == 3) || (kmod == 4) || (kmod == 7) || (kmod == 8) || (kmod == 9)) {
+	mpdcch5ss1tab[re] = (l * eNB->frame_parms.ofdm_symbol_size) + k;
+	re++;
+	printf("l %d, k %d (kmod %d) => re %d\n", l, k, kmod, re);
+      } else if ((kmod == 0) || (kmod == 5) || (kmod == 10)) {
+	mpdcch5ss1tab[re++] = (l * eNB->frame_parms.ofdm_symbol_size) + k;
+      }
     }
   }
-  AssertFatal(re==864,"RE count not equal to 864\n");
+  AssertFatal(re == 864, "RE count not equal to 864 (%d)\n", re);
 }
 
-extern uint8_t *generate_dci0(uint8_t *dci,
-			      uint8_t *e,
-			      uint8_t DCI_LENGTH,
-			      uint8_t aggregation_level,
-			      uint16_t rnti);
+// this table is the allocation of modulated MPDCCH format 5 symbols to REs, antenna ports 107,108
+// start symbol is symbol 2 and L'=24 => all 6 PRBs in the set
+// 8 symbols without DMRS = 8*12*6 REs = 576 REs
+// 4 symbols with DMRS (3 REs stolen per symbol = 4*9*6 REs = 216 REs
+// Total = 576+216 = 792 REs = 1584 bits
+static uint16_t mpdcch5ss2tab[792];
 
-void generate_mdci_top(PHY_VARS_eNB *eNB, int frame, int subframe,int16_t amp,int32_t **txdataF) {
+void init_mpdcch5ss2tab_normal_regular_subframe_evenNRBDL(PHY_VARS_eNB * eNB)
+{
+  int             l, k, kmod, re=0;
+  int nushift = eNB->frame_parms.Nid_cell % 6;
+  int nushiftp3 = (eNB->frame_parms.Nid_cell+3) % 6;
+  // NOTE : THIS IS FOR TM1 ONLY FOR NOW!!!!!!!
+  LOG_I(PHY, "Inititalizing mpdcch5ss2tab for normal prefix, normal prefix, no PSS/SSS/PBCH, even N_RB_DL\n");
+  for (l = 2; l < 14; l++) {
+    for (k = 0; k < 72; k++) {
+      kmod = k % 12;
+      if ((((l == 4)||(l==11)) && (kmod != nushiftp3) && (kmod != (nushiftp3+6))) || 
+	  ((l == 7) && (kmod != nushift) &&(kmod != (nushift+6)))) {  // CS RS
+	mpdcch5ss2tab[re] = (l * eNB->frame_parms.ofdm_symbol_size) + k;
+	re++;
+      }
+      if (((l!=4)&&(l!=7)&&(l!=11)) && 
+	  (((l != 5) && (l != 6) && (l != 12) && (l != 13)) || (kmod == 2) || (kmod == 3) || (kmod == 4) || (kmod == 7) || (kmod == 8) || (kmod == 9))) {
+	mpdcch5ss2tab[re] = (l * eNB->frame_parms.ofdm_symbol_size) + k;
+	re++;
+      }
+    }
+  }
+  AssertFatal(re == 684, "RE count not equal to 684\n");
+}
 
-  LTE_eNB_MPDCCH *mpdcch= &eNB->mpdcch_vars[subframe&2];
-  mDCI_ALLOC_t *mdci;
-  int coded_bits;
-  LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
-  int i;
-  int gain_lin_QPSK;
+// this table is the allocation of modulated MPDCCH format 5 symbols to REs, antenna ports 107,108
+// start symbol is symbol 3 and L'=24 => all 6 PRBs in the set
+// 7 symbols without DMRS = 7*12*6 REs = 504 REs
+// 4 symbols with DMRS (3 REs stolen per symbol = 4*9*6 REs = 216 REs
+// Total = 504+216 = 720 REs = 1440 bits
+static uint16_t mpdcch5ss3tab[720];
+void init_mpdcch5ss3tab_normal_regular_subframe_evenNRBDL(PHY_VARS_eNB * eNB)
+{
+  int             l, k, kmod, re=0;
+
+  LOG_I(PHY, "Inititalizing mpdcch5ss3tab for normal prefix, normal prefix, no PSS/SSS/PBCH, even N_RB_DL\n");
+  for (l = 3; l < 14; l++) {
+    for (k = 0; k < 72; k++) {
+      kmod = k % 12;
+      if (((l != 5) && (l != 6) && (l != 12) && (l != 13)) || (kmod == 2) || (kmod == 3) || (kmod == 4) || (kmod == 7) || (kmod == 8) || (kmod == 9)) {
+	mpdcch5ss3tab[re] = (l * eNB->frame_parms.ofdm_symbol_size) + k;
+	re++;
+      } else if ((kmod == 0) || (kmod == 5) || (kmod == 10)) {
+	mpdcch5ss3tab[re++] = (l * eNB->frame_parms.ofdm_symbol_size) + k;
+      }
+    }
+  }
+  AssertFatal(re == 720, "RE count not equal to 792\n");
+}
 
-  for (i=0;i<mpdcch->num_dci;i++) {
-    mdci = &mpdcch->mdci_alloc[i];
+// this table is the allocation of modulated MPDCCH format 3 symbols to REs, antenna ports 107,108
+// with start symbol 1, using L'=16 => first 4 PRBs in the set
+// 8 symbols without DMRS = 9*12*4 REs = 432 REs
+// 4 symbols with DMRS (3 REs stolen per symbol = 4*9*4 REs = 144 REs
+// Total = 432+144 = 576 = 16CCE*36RE/CCE
+static uint16_t mpdcch3ss1tab[576];
+
+void init_mpdcch3ss1tab_normal_regular_subframe_evenNRBDL(PHY_VARS_eNB * eNB)
+{
+  int             l, k, kmod, re=0;
+
+  LOG_I(PHY, "Inititalizing mpdcch3ss1tab for normal prefix, normal prefix, no PSS/SSS/PBCH, even N_RB_DL\n");
+  for (l = 1, re = 0; l < 14; l++) {
+    for (k = 0; k < 48; k++) {
+      kmod = k % 12;
+      if (((l != 5) && (l != 6) && (l != 12) && (l != 13)) || (((l == 5) || (l == 6) || (l == 12) || (l == 13)) && (kmod != 0) && (kmod != 5) && (kmod != 10))) {
+	mpdcch3ss1tab[re] = (l * eNB->frame_parms.ofdm_symbol_size) + k;
+	re++;
+      }
+    }
+  }
+  AssertFatal(re == 576, "RE count not equal to 864\n");
+}
+
+// this table is the allocation of modulated MPDCCH format 2 symbols to REs, antenna ports 107,108
+// with start symbol 1, using L'=8 => last 2 PRBs in the set
+// 8 symbols without DMRS = 9*12*2 REs = 216 REs
+// 4 symbols with DMRS (3 REs stolen per symbol = 4*9*2 REs = 72 REs
+// Total = 216+72 = 288 = 8CCE*36RE/CCE
+static uint16_t mpdcch2ss1tab[288];
+
+void init_mpdcch2ss1tab_normal_regular_subframe_evenNRBDL(PHY_VARS_eNB * eNB)
+{
+  int             l, k, kmod, re=0;
+
+  LOG_I(PHY, "Inititalizing mpdcch2ss1tab for normal prefix, normal prefix, no PSS/SSS/PBCH, even N_RB_DL\n");
+  for (l = 1, re = 0; l < 14; l++) {
+    for (k = 0; k < 24; k++) {
+      kmod = k % 12;
+      if (((l != 5) && (l != 6) && (l != 12) && (l != 13)) || (((l == 5) || (l == 6) || (l == 12) || (l == 13)) && (kmod != 0) && (kmod != 5) && (kmod != 10))) {
+	mpdcch2ss1tab[re] = (l * eNB->frame_parms.ofdm_symbol_size) + k;
+	re++;
+      }
+    }
+  }
+  AssertFatal(re == 288, "RE count not equal to 288\n");
+}
 
 
-    AssertFatal(fp->frame_type==FDD,"TDD is not yet supported for MPDCCH\n");
-    AssertFatal(fp->Ncp == NORMAL,"Extended Prefix not yet supported for MPDCCH\n");
-    AssertFatal(mdci->L<=24,"L is %d\n",mdci->L);
-    AssertFatal(fp->N_RB_DL==50 || fp->N_RB_DL==100,"Only N_RB_DL=50,100 for MPDCCH\n");
-    // Force MPDDCH format 5
-    AssertFatal(mdci->number_of_prb_pairs==6,"2 or 4 PRB pairs not support yet for MPDCCH\n");
-    AssertFatal(mdci->reps>0,"mdci->reps==0\n");
 
-    // 9 REs/EREG * 4 EREG/ECCE => 36 REs/ECCE => 72 bits/ECCE, so same as regular PDCCH channel encoding
+
+extern uint8_t *generate_dci0(uint8_t * dci, uint8_t * e, uint8_t DCI_LENGTH, uint16_t coded_bits, uint16_t rnti);
+
+
+uint16_t        mpdcch_dmrs_tab[12 * 6];
+
+void init_mpdcch_dmrs_tab(uint16_t oss)
+{
+
+  int             re = 5 * oss;
+  int             pos = 0;
+
+  for (int symb = 0; symb < 4; symb++) {
+    for (int prb = 0; prb < 6; prb++, re += 12) {
+      mpdcch_dmrs_tab[pos++] = re;
+      mpdcch_dmrs_tab[pos++] = re + 5;
+      mpdcch_dmrs_tab[pos++] = re + 10;
+    }
+    if (symb == 0)
+      re = 6 * oss;
+    else if (symb == 1)
+      re = 12 * oss;
+    else if (symb == 2)
+      re = 13 * oss;
+  }
+
+}
+
+void generate_mdci_top(PHY_VARS_eNB * eNB, int frame, int subframe, int16_t amp, int32_t ** txdataF)
+{
+
+  LTE_eNB_MPDCCH *mpdcch = &eNB->mpdcch_vars[subframe & 1];
+  mDCI_ALLOC_t   *mdci;
+  int             coded_bits;
+  LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
+  int             i;
+  int             gain_lin_QPSK;
+  uint16_t       *mpdcchtab;
+
+  uint32_t        x1, x2, s = 0;
+  uint8_t         Nacc = 4;
+  uint16_t        j0, j, idelta;
+  uint16_t        i0;
+
+  int             off=0;
+
+  // Assumption: only handle a single MPDCCH per narrowband
+
+  int nsymb = (fp->Ncp==0) ? 14:12;
+
+  int symbol_offset = (uint32_t)fp->ofdm_symbol_size*(subframe*nsymb);
+
+  int wp[2][4] = {{1,1,1,1},{1,-1,1,-1}};
+  int *w;
+
+  LOG_I(PHY, "generate_mdci_top: num_dci %d\n", mpdcch->num_dci);
+
+  for (i = 0; i < mpdcch->num_dci; i++) {
+    mdci = &mpdcch->mdci_alloc[i];
+
+    AssertFatal(fp->frame_type == FDD, "TDD is not yet supported for MPDCCH\n");
+    AssertFatal(fp->Ncp == NORMAL, "Extended Prefix not yet supported for MPDCCH\n");
+    AssertFatal(mdci->L <= 24, "L is %d\n", mdci->L);
+    AssertFatal(fp->N_RB_DL == 50 || fp->N_RB_DL == 100, "Only N_RB_DL=50,100 for MPDCCH\n");
+    // Force MPDDCH format 5
+    AssertFatal(mdci->number_of_prb_pairs == 6, "2 or 4 PRB pairs not support yet for MPDCCH\n");
+
+    // These are to avoid unimplemented things
+    AssertFatal(mdci->ce_mode == 1, "CE mode (%d) B not activated yet\n", mdci->ce_mode);
+    AssertFatal(mdci->L == 24, "Only 2+4 and aggregation 24 for now\n");
+    int     a_index=mdci->rnti & 3;
+
+    i0 = mdci->i0;
+    // antenna index
+
+    if (mdci->start_symbol == 1)  {
+      mpdcchtab = mpdcch5ss1tab;
+      coded_bits = 756*2;
+    } else if (mdci->start_symbol == 2) {
+      mpdcchtab = mpdcch5ss2tab;
+      coded_bits=684*2;
+    } else if (mdci->start_symbol == 3) {
+      mpdcchtab = mpdcch5ss3tab;
+      coded_bits = 612*2;
+    } else
+      AssertFatal(1 == 0, "Illegal combination start_symbol %d, a_index %d\n", mdci->start_symbol, a_index);
+
+    LOG_I(PHY, "mdci %d, length %d: rnti %x, L %d, prb_pairs %d, ce_mode %d, transmission type %s, i0 %d, ss %d ,coded_bits %d\n", 
+	  i, mdci->dci_length,mdci->rnti, 
+	  mdci->L, mdci->number_of_prb_pairs, 
+	  mdci->ce_mode, 
+	  mdci->transmission_type == 1? "dist" : "loc",
+	  mdci->i0, mdci->start_symbol,
+	  coded_bits);
 
     // Note: We only have to run this every Nacc subframes during repetitions, data and scrambling are constant, but we do it for now to simplify during testing
 
-    generate_dci0(mdci->dci_pdu,
-		  mpdcch->e+(72*mdci->firstCCE),
-		  mdci->dci_length,
-		  mdci->L,
-		  mdci->rnti);
+    generate_dci0(mdci->dci_pdu, mpdcch->e, mdci->dci_length, coded_bits, mdci->rnti);
 
-    
-    coded_bits = 72 * mdci->L;
 
-    // scrambling
-    uint16_t absSF = (frame*10)+subframe; 
 
-    AssertFatal(absSF < 1024,
-		"Absolute subframe %d = %d*10 + %d > 1023\n",
-		absSF,frame,subframe);
+    // scrambling
+    uint16_t        absSF = (frame * 10) + subframe;
 
-    mpdcch_scrambling(fp,
-		      mdci,
-		      absSF,
-		      mpdcch->e+(72*mdci->firstCCE),
-		      coded_bits);
+    AssertFatal(absSF < 10240, "Absolute subframe %d = %d*10 + %d > 10239\n", absSF, frame, subframe);
 
+    mpdcch_scrambling(fp, mdci, absSF, mpdcch->e, coded_bits);
+    
     // Modulation for PDCCH
-    if (fp->nb_antenna_ports_eNB==1)
-      gain_lin_QPSK = (int16_t)((amp*ONE_OVER_SQRT2_Q15)>>15);
+    if (fp->nb_antenna_ports_eNB == 1)
+      gain_lin_QPSK = (int16_t) ((amp * ONE_OVER_SQRT2_Q15) >> 15);
     else
-      gain_lin_QPSK = amp/2;
+      gain_lin_QPSK = amp / 2;
 
-    uint8_t *e_ptr = mpdcch->e;
+    uint8_t        *e_ptr = mpdcch->e;
 
     //    if (mdci->transmission_type==0) nprime=mdci->rnti&3; // for Localized 2+4 we use 6.8B.5 rule
     // map directly to one antenna port for now
@@ -183,20 +356,135 @@ void generate_mdci_top(PHY_VARS_eNB *eNB, int frame, int subframe,int16_t amp,in
     // first RE of narrowband
     // mpdcchtab5 below contains the mapping from each coded symbol to relative RE avoiding the DMRS
 
+    int             nb_i0;
+    switch (fp->N_RB_DL) {
+
+    case 6:
+    case 25:
+      nb_i0 = 0;
+      break;
+    case 15:
+    case 50:
+    case 75:
+      nb_i0 = 1;
+      break;
+    case 100:
+      nb_i0 = 2;
+      break;
+    default:
+      AssertFatal(1 == 0, "Illegal N_RB_DL %d\n", fp->N_RB_DL);
+      break;
+    }
 
-    int re_offset = fp->first_carrier_offset + 1 + ((fp->N_RB_DL==100)?1:0) + mdci->narrowband*12*6;
-    if (re_offset>fp->ofdm_symbol_size) re_offset-=(fp->ofdm_symbol_size-1);
-    int32_t *txF = &txdataF[0][re_offset];
-    int32_t yIQ;
+    int             re_offset = fp->first_carrier_offset + (12 * nb_i0) + (mdci->narrowband * 12 * 6);
+    if (re_offset > fp->ofdm_symbol_size)
+      re_offset -= (fp->ofdm_symbol_size - 1);
+    int32_t        *txF = &txdataF[0][symbol_offset+re_offset];
+    int32_t         yIQ;
 
-    for (i=0; i<(coded_bits>>1); i++) {
+    for (i = 0; i < (coded_bits >> 1); i++) {
       // QPSK modulation to yIQ
-      ((int16_t*)&yIQ)[0] = (*e_ptr == 1) ? -gain_lin_QPSK : gain_lin_QPSK; e_ptr++;
-      ((int16_t*)&yIQ)[1] = (*e_ptr == 1) ? -gain_lin_QPSK : gain_lin_QPSK; e_ptr++;
-      txF[mpdcch5tab[i+(36*mdci->firstCCE)]] = yIQ;
+      ((int16_t *) & yIQ)[0] = (*e_ptr == 1) ? -gain_lin_QPSK : gain_lin_QPSK;
+      e_ptr++;
+      ((int16_t *) & yIQ)[1] = (*e_ptr == 1) ? -gain_lin_QPSK : gain_lin_QPSK;
+      e_ptr++;
+      txF[mpdcchtab[i]] = yIQ;
+      /*      
+      LOG_I(PHY,"Frame %d, subframe %d: mpdcch pos %d (%d,%d) => (%d,%d)\n",
+	    frame,subframe,i,mpdcchtab[i]+re_offset,mpdcchtab[i]/fp->ofdm_symbol_size,
+	    ((int16_t *) & yIQ)[0],((int16_t *) & yIQ)[1]);*/
     }
 
-  }
-} 
+    if (mdci->transmission_type == 1) w=0; // distributed
+    else w = wp[a_index&1];
+    // pilot scrambling initiatlization (note: this is for a single repetition)
+
+    // x1 is set in lte_gold_generic
+
+    // rule for BL/CE UEs from Section 6.10.3A.1 in 36.211
+
+    if ((mdci->rnti == 0xFFFE) || (mdci->ce_mode == 2))     // CEModeB Note: also for mdci->rnti==SC_RNTI
+      Nacc = fp->frame_type == FDD ? 4 : 10;
+    else
+      Nacc = 1;
+
+    if (fp->frame_type == FDD || Nacc == 1)
+      idelta = 0;
+    else
+      idelta = Nacc - 2;
+
+    j0 = (i0 + idelta) / Nacc;
+    j = (absSF - i0) / Nacc;
+
+
+
+    uint32_t        a = ((((j0 + j) * Nacc) % 10) + 1);
+    uint32_t        b = ((mdci->dmrs_scrambling_init << 1) + 1) << 16;
+    x2 = a * b;
+    x2 = x2 + 2;
+    LOG_I(PHY, "mpdcch_dmrs cinit %x (a=%d,b=%d,i0=%d,j0=%d)\n", x2,a,b,i0,j0);
+
+    // add MPDCCH pilots
+    int             reset = 1;
+
+    int first_prb = (mdci->narrowband*6) + nb_i0;
+    int last_prb  = (mdci->narrowband*6) + nb_i0 + 5;
+    int soffset[4] = {5,6,12,13};
+
+
+    for (int lprime=0,i=0;lprime<4;lprime++) {
+      for (int nprb=0;nprb<110;nprb++) {
+	if (nprb<fp->N_RB_DL) {
+	  re_offset = fp->first_carrier_offset + (12 * nprb);
+	  if (re_offset > fp->ofdm_symbol_size)
+	    re_offset -= (fp->ofdm_symbol_size - 1);
+	  txF = &txdataF[0][symbol_offset + re_offset + fp->ofdm_symbol_size*soffset[lprime]];
+	}
+	for (int mprime=0;mprime<3;mprime++,i+=2) {
+	
+	  if ((i & 0x1f) == 0) {
+	    s = lte_gold_generic(&x1, &x2, reset);
+	    reset = 0;
+	  }
+
+	  // select PRBs corresponding to narrowband
+	  if ((nprb>= first_prb) && 
+	      (nprb<= last_prb)) {
+	    ((int16_t *) & yIQ)[0] = (((s >> (i & 0x1f)) & 1) == 1) ? -gain_lin_QPSK : gain_lin_QPSK;
+	    ((int16_t *) & yIQ)[1] = (((s >> ((i + 1) & 0x1f)) & 1) == 1) ? -gain_lin_QPSK : gain_lin_QPSK;
+	    AssertFatal(mdci->transmission_type==1,"transmission_type %d!=1, handle this ...\n",mdci->transmission_type);
+	    if (mdci->transmission_type==1) { // same thing on both 107 and 109
+	      txF[(5*mprime)] = yIQ;
+	      txF[1+(5*mprime)] = yIQ;
+	    }
+	    else { // put on selected antenna port with w sequence
+
+	      if (((mprime+nprb)&1) == 0) 
+		txF[off+(5*mprime)] = yIQ*w[lprime];
+	      else
+		txF[off+(5*mprime)] = yIQ*w[3-lprime];
+	    }
+	    /*
+	    LOG_I(PHY, "mpdcch_dmrs pos (dist %d, l %d,nprb %d,mprime %d) %d  => (%d,%d)\n", 
+		  mdci->transmission_type, soffset[lprime],nprb,mprime,
+		  re_offset + fp->ofdm_symbol_size*soffset[lprime]+(5*mprime), 
+		  ((int16_t *) & yIQ)[0], ((int16_t *) & yIQ)[1]);*/
+	  } // narrowband condition
+	} // RE (m') loop
+      } // nprb loop
+    } // symbol (l') loop
+  } // num_dci loop
+}
+
+void init_mpdcch(PHY_VARS_eNB * eNB)
+{
+
+  init_mpdcch5ss1tab_normal_regular_subframe_evenNRBDL(eNB);
+  init_mpdcch5ss2tab_normal_regular_subframe_evenNRBDL(eNB);
+  init_mpdcch5ss3tab_normal_regular_subframe_evenNRBDL(eNB);
+  init_mpdcch3ss1tab_normal_regular_subframe_evenNRBDL(eNB);
+  init_mpdcch2ss1tab_normal_regular_subframe_evenNRBDL(eNB);
+  init_mpdcch_dmrs_tab(eNB->frame_parms.ofdm_symbol_size);
+}
 
 #endif
diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c
index 127471dcb602dcfdf0d329ca293b5fe7ce08047e..8898d9d3e3a545a7cca91445137dbea4eacf96d0 100644
--- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c
+++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c
@@ -150,6 +150,7 @@ void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type) {
 
 	for (element_id=0; element_id<db_halflength; element_id+=8) {
 	  i = (uint16_t*) &rx0[element_id];
+
           d = (uint16_t*) &data_block[element_id];
           d[0] = ((uint16_t) lin2alaw_if4p5[i[0]])  | ((uint16_t)(lin2alaw_if4p5[i[1]]<<8));
           d[1] = ((uint16_t) lin2alaw_if4p5[i[2]])  | ((uint16_t)(lin2alaw_if4p5[i[3]]<<8));
diff --git a/openair1/PHY/LTE_TRANSPORT/mdci.h b/openair1/PHY/LTE_TRANSPORT/mdci.h
index 7be278530860fc88792c315130f62e84d77d4292..3cb6380625b0c9b1780ae6605ec63fa1f2f30e50 100644
--- a/openair1/PHY/LTE_TRANSPORT/mdci.h
+++ b/openair1/PHY/LTE_TRANSPORT/mdci.h
@@ -59,7 +59,9 @@ struct DCI6_0A_5MHz {
   /// Modulation and Coding Scheme and Redundancy Version
   uint32_t mcs:4;
   /// RB Assignment (ceil(log2(floor(N_RB_UL/6))) + 5 bits)
-  uint32_t rballoc:7;
+  uint32_t rballoc:5;
+  /// narrowband index log2(floor(N_RB_DL/6))) bits
+  uint32_t narrowband:2;
   /// Hopping flag
   uint32_t hopping:1;
   /// type = 0 => DCI Format 0, type = 1 => DCI Format 1A
@@ -92,7 +94,9 @@ struct DCI6_1A_5MHz {
   /// Modulation and Coding Scheme and Redundancy Version
   uint32_t mcs:4;
   /// Resource block assignment (assignment flag = 0 for 5 MHz, ceil(log2(floor(N_RB_DL/6)))+5)
-  uint32_t rballoc:7;
+  uint32_t rballoc:5;
+  /// narrowband index log2(floor(N_RB_DL/6))) bits
+  uint32_t narrowband:2;
   /// Frequency hopping flag
   uint32_t hopping:1;
   /// 0/1A differentiator
@@ -125,7 +129,9 @@ struct DCI6_0A_10MHz {
   /// Modulation and Coding Scheme and Redundancy Version
   uint32_t mcs:4;
   /// RB Assignment (ceil(log2(floor(N_RB_UL/6))) + 5 bits)
-  uint32_t rballoc:8;
+  uint32_t rballoc:5;
+  /// narrowband index log2(floor(N_RB_DL/6))) bits
+  uint32_t narrowband:3;
   /// Hopping flag
   uint32_t hopping:1;
   /// type = 0 => DCI Format 0, type = 1 => DCI Format 1A
@@ -138,7 +144,7 @@ typedef struct DCI6_0A_10MHz DCI6_0A_10MHz_t;
 /// basic DCI Format Type 6-1A (10 MHz, FDD primary carrier,  24 bits, 5 bit format, TM!=9,TM!=6, no scheduling enhancement)
 struct DCI6_1A_10MHz {
   /// padding to fill 32-bit word
-  uint32_t padding:4;
+  uint32_t padding:3;
   /// DCI subframe repetition number 
   uint32_t dci_rep:2;
   /// HARQ-ACK resource offset
@@ -157,8 +163,10 @@ struct DCI6_1A_10MHz {
   uint32_t rep:2;
   /// Modulation and Coding Scheme and Redundancy Version
   uint32_t mcs:4;
-  /// Resource block assignment (assignment flag = 0 for 10 MHz, ceil(log2(floor(N_RB_DL/6)))+5)
-  uint32_t rballoc:8;
+  /// Resource block assignment
+  uint32_t rballoc:5;
+  /// narrowband index log2(floor(N_RB_DL/6))) bits
+  uint32_t narrowband:3;
   /// Frequency hopping flag
   uint32_t hopping:1;
   /// 0/1A differentiator
@@ -191,7 +199,9 @@ struct DCI6_0A_20MHz {
   /// Modulation and Coding Scheme and Redundancy Version
   uint32_t mcs:4;
   /// RB Assignment (ceil(log2(floor(N_RB_UL/6))) + 5 bits)
-  uint32_t rballoc:9;
+  uint32_t rballoc:5;
+  /// narrowband index log2(floor(N_RB_DL/6))) bits
+  uint32_t narrowband:4;
   /// Hopping flag
   uint32_t hopping:1;
   /// type = 0 => DCI Format 0, type = 1 => DCI Format 1A
@@ -224,7 +234,9 @@ struct DCI6_1A_20MHz {
   /// Modulation and Coding Scheme and Redundancy Version
   uint32_t mcs:4;
   /// Resource block assignment (assignment flag = 0 for 20 MHz, ceil(log2(floor(N_RB_DL/6)))+5)
-  uint32_t rballoc:9;
+  uint32_t rballoc:5;
+  /// narrowband index log2(floor(N_RB_DL/6))) bits
+  uint32_t narrowband:4;
   /// Frequency hopping flag
   uint32_t hopping:1;
   /// 0/1A differentiator
diff --git a/openair1/PHY/LTE_TRANSPORT/prach.c b/openair1/PHY/LTE_TRANSPORT/prach.c
index 405990fb6baa94651a0bca1b6285d63b3714171e..59450cf08114a1329c9a572b76440f47c5071f73 100644
--- a/openair1/PHY/LTE_TRANSPORT/prach.c
+++ b/openair1/PHY/LTE_TRANSPORT/prach.c
@@ -34,6 +34,7 @@
 #include "PHY/phy_extern.h"
 //#include "prach.h"
 #include "PHY/LTE_TRANSPORT/if4_tools.h"
+
 #include "SCHED/sched_eNB.h"
 #include "common/utils/LOG/vcd_signal_dumper.h"
 #include "prach_extern.h"
diff --git a/openair1/PHY/LTE_TRANSPORT/print_stats.c b/openair1/PHY/LTE_TRANSPORT/print_stats.c
new file mode 100644
index 0000000000000000000000000000000000000000..005287935e88d932d144014d7fb8a78e9bc75f35
--- /dev/null
+++ b/openair1/PHY/LTE_TRANSPORT/print_stats.c
@@ -0,0 +1,804 @@
+/*
+ * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The OpenAirInterface Software Alliance licenses this file to You under
+ * the OAI Public License, Version 1.1  (the "License"); you may not use this file
+ * except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.openairinterface.org/?page_id=698
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *-------------------------------------------------------------------------------
+ * For more information about the OpenAirInterface (OAI) Software Alliance:
+ *      contact@openairinterface.org
+ */
+
+/*! \file PHY/LTE_TRANSPORT/print_stats.c
+* \brief PHY statstic logging function
+* \author R. Knopp, F. Kaltenberger, navid nikaein
+* \date 2011
+* \version 0.1
+* \company Eurecom
+* \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr, navid.nikaein@eurecom.fr
+* \note
+* \warning
+*/
+
+#include "PHY/LTE_TRANSPORT/proto.h"
+
+#include "PHY/defs.h"
+#include "PHY/extern.h"
+#include "SCHED/extern.h"
+
+#ifdef OPENAIR2
+#include "openair2/LAYER2/MAC/proto.h"
+#include "openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
+#endif
+
+extern int mac_get_rrc_status(uint8_t Mod_id,uint8_t eNB_flag,uint8_t index);
+#if defined(OAI_USRP) || defined(EXMIMO) || defined(OAI_BLADERF) || defined(OAI_LMSSDR)
+#include "common_lib.h"
+extern openair0_config_t openair0_cfg[];
+#endif
+
+int dump_ue_stats(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc,char* buffer, int length, runmode_t mode, int input_level_dBm)
+{
+
+  uint8_t eNB=0;
+  uint32_t RRC_status;
+  int len=length;
+  int harq_pid,round;
+
+  if (ue==NULL)
+    return 0;
+
+  if ((mode == normal_txrx) || (mode == no_L2_connect)) {
+    len += sprintf(&buffer[len], "[UE_PROC] UE %d, RNTI %x\n",ue->Mod_id, ue->pdcch_vars[0][0]->crnti);
+     len += sprintf(&buffer[len],"[UE PROC] RSRP[0] %.2f dBm/RE, RSSI %.2f dBm, RSRQ[0] %.2f dB, N0 %d dBm/RE (NF %.1f dB)\n",
+		    10*log10(ue->measurements.rsrp[0])-ue->rx_total_gain_dB,
+		    10*log10(ue->measurements.rssi)-ue->rx_total_gain_dB, 
+		    10*log10(ue->measurements.rsrq[0]),
+		    ue->measurements.n0_power_tot_dBm,
+		    (double)ue->measurements.n0_power_tot_dBm+132.24);
+
+    /*
+    len += sprintf(&buffer[len],
+                   "[UE PROC] Frame count: %d\neNB0 RSSI %d dBm/RE (%d dB, %d dB)\neNB1 RSSI %d dBm/RE (%d dB, %d dB)neNB2 RSSI %d dBm/RE (%d dB, %d dB)\nN0 %d dBm/RE, %f dBm/%dPRB (%d dB, %d dB)\n",
+                   proc->frame_rx,
+                   ue->measurements.rx_rssi_dBm[0],
+                   ue->measurements.rx_power_dB[0][0],
+                   ue->measurements.rx_power_dB[0][1],
+                   ue->measurements.rx_rssi_dBm[1],
+                   ue->measurements.rx_power_dB[1][0],
+                   ue->measurements.rx_power_dB[1][1],
+                   ue->measurements.rx_rssi_dBm[2],
+                   ue->measurements.rx_power_dB[2][0],
+                   ue->measurements.rx_power_dB[2][1],
+                   ue->measurements.n0_power_tot_dBm,
+                   ue->measurements.n0_power_tot_dBm+10*log10(12*ue->frame_parms.N_RB_DL),
+                   ue->frame_parms.N_RB_DL,
+                   ue->measurements.n0_power_dB[0],
+                   ue->measurements.n0_power_dB[1]);
+    */
+
+#ifdef EXMIMO
+    len += sprintf(&buffer[len], "[UE PROC] RX Gain %d dB (LNA %d, vga %d dB)\n",ue->rx_total_gain_dB, openair0_cfg[0].rxg_mode[0],(int)openair0_cfg[0].rx_gain[0]);
+#endif
+#if defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR)
+    len += sprintf(&buffer[len], "[UE PROC] RX Gain %d dB\n",ue->rx_total_gain_dB);
+#endif
+#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR)
+    len += sprintf(&buffer[len], "[UE_PROC] Frequency offset %d Hz, estimated carrier frequency %f Hz\n",ue->common_vars.freq_offset,openair0_cfg[0].rx_freq[0]-ue->common_vars.freq_offset);
+#endif
+    len += sprintf(&buffer[len], "[UE PROC] UE mode = %s (%d)\n",mode_string[ue->UE_mode[0]],ue->UE_mode[0]);
+    len += sprintf(&buffer[len], "[UE PROC] timing_advance = %d\n",ue->timing_advance);
+    if (ue->UE_mode[0]==PUSCH) {
+      len += sprintf(&buffer[len], "[UE PROC] Po_PUSCH = %d dBm (PL %d dB, Po_NOMINAL_PUSCH %d dBm, PHR %d dB)\n", 
+		     ue->ulsch[0]->Po_PUSCH,
+		     get_PL(ue->Mod_id,ue->CC_id,0),
+		     ue->frame_parms.ul_power_control_config_common.p0_NominalPUSCH,
+		     ue->ulsch[0]->PHR);
+      len += sprintf(&buffer[len], "[UE PROC] Po_PUCCH = %d dBm (Po_NOMINAL_PUCCH %d dBm, g_pucch %d dB)\n", 
+		     get_PL(ue->Mod_id,ue->CC_id,0)+
+		     ue->frame_parms.ul_power_control_config_common.p0_NominalPUCCH+
+		     ue->dlsch[0][0][0]->g_pucch,
+		     ue->frame_parms.ul_power_control_config_common.p0_NominalPUCCH,
+		     ue->dlsch[0][0][0]->g_pucch);
+    }
+    //for (eNB=0;eNB<NUMBER_OF_eNB_MAX;eNB++) {
+    for (eNB=0; eNB<1; eNB++) {
+      len += sprintf(&buffer[len], "[UE PROC] RX spatial power eNB%d: [%d %d; %d %d] dB\n",
+                     eNB,
+                     ue->measurements.rx_spatial_power_dB[eNB][0][0],
+                     ue->measurements.rx_spatial_power_dB[eNB][0][1],
+                     ue->measurements.rx_spatial_power_dB[eNB][1][0],
+                     ue->measurements.rx_spatial_power_dB[eNB][1][1]);
+
+      len += sprintf(&buffer[len], "[UE PROC] RX total power eNB%d: %d dB, avg: %d dB\n",eNB,ue->measurements.rx_power_tot_dB[eNB],ue->measurements.rx_power_avg_dB[eNB]);
+      len += sprintf(&buffer[len], "[UE PROC] RX total power lin: %d, avg: %d, RX total noise lin: %d, avg: %d\n",ue->measurements.rx_power_tot[eNB],
+                     ue->measurements.rx_power_avg[eNB], ue->measurements.n0_power_tot, ue->measurements.n0_power_avg);
+      len += sprintf(&buffer[len], "[UE PROC] effective SINR %.2f dB\n",ue->sinr_eff);
+      len += sprintf(&buffer[len], "[UE PROC] Wideband CQI eNB %d: %d dB, avg: %d dB\n",eNB,ue->measurements.wideband_cqi_tot[eNB],ue->measurements.wideband_cqi_avg[eNB]);
+
+      switch (ue->frame_parms.N_RB_DL) {
+      case 6:
+        len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 0): [%d %d %d %d %d %d] dB\n",
+                       eNB,
+                       ue->measurements.subband_cqi_dB[eNB][0][0],
+                       ue->measurements.subband_cqi_dB[eNB][0][1],
+                       ue->measurements.subband_cqi_dB[eNB][0][2],
+                       ue->measurements.subband_cqi_dB[eNB][0][3],
+                       ue->measurements.subband_cqi_dB[eNB][0][4],
+                       ue->measurements.subband_cqi_dB[eNB][0][5]);
+
+
+        len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 1): [%d %d %d %d %d %d] dB\n",
+                       eNB,
+                       ue->measurements.subband_cqi_dB[eNB][1][0],
+                       ue->measurements.subband_cqi_dB[eNB][1][1],
+                       ue->measurements.subband_cqi_dB[eNB][1][2],
+                       ue->measurements.subband_cqi_dB[eNB][1][3],
+                       ue->measurements.subband_cqi_dB[eNB][1][4],
+                       ue->measurements.subband_cqi_dB[eNB][1][5]);
+
+
+        len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 0): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n",
+                       eNB,
+                       ue->measurements.subband_pmi_re[eNB][0][0],
+                       ue->measurements.subband_pmi_im[eNB][0][0],
+                       ue->measurements.subband_pmi_re[eNB][1][0],
+                       ue->measurements.subband_pmi_im[eNB][1][0],
+                       ue->measurements.subband_pmi_re[eNB][2][0],
+                       ue->measurements.subband_pmi_im[eNB][2][0],
+                       ue->measurements.subband_pmi_re[eNB][3][0],
+                       ue->measurements.subband_pmi_im[eNB][3][0],
+                       ue->measurements.subband_pmi_re[eNB][4][0],
+                       ue->measurements.subband_pmi_im[eNB][4][0],
+                       ue->measurements.subband_pmi_re[eNB][5][0],
+                       ue->measurements.subband_pmi_im[eNB][5][0]);
+
+        len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 1): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n",
+                       eNB,
+                       ue->measurements.subband_pmi_re[eNB][0][1],
+                       ue->measurements.subband_pmi_im[eNB][0][1],
+                       ue->measurements.subband_pmi_re[eNB][1][1],
+                       ue->measurements.subband_pmi_im[eNB][1][1],
+                       ue->measurements.subband_pmi_re[eNB][2][1],
+                       ue->measurements.subband_pmi_im[eNB][2][1],
+                       ue->measurements.subband_pmi_re[eNB][3][1],
+                       ue->measurements.subband_pmi_im[eNB][3][1],
+                       ue->measurements.subband_pmi_re[eNB][4][1],
+                       ue->measurements.subband_pmi_im[eNB][4][1],
+                       ue->measurements.subband_pmi_re[eNB][5][1],
+                       ue->measurements.subband_pmi_im[eNB][5][1]);
+
+        len += sprintf(&buffer[len], "[UE PROC] PMI Antenna selection eNB%d : [%d %d %d %d %d %d]\n",
+                       eNB,
+                       ue->measurements.selected_rx_antennas[eNB][0],
+                       ue->measurements.selected_rx_antennas[eNB][1],
+                       ue->measurements.selected_rx_antennas[eNB][2],
+                       ue->measurements.selected_rx_antennas[eNB][3],
+                       ue->measurements.selected_rx_antennas[eNB][4],
+                       ue->measurements.selected_rx_antennas[eNB][5]);
+
+        len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (max): %jx\n",eNB,pmi2hex_2Ar1(quantize_subband_pmi(&ue->measurements,eNB,6)));
+        len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (both): %jx,%jx\n",eNB,
+                       pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,0,6)),
+                       pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,1,6)));
+        break;
+
+      case 25:
+        len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 0): [%d %d %d %d %d %d %d] dB\n",
+                       eNB,
+                       ue->measurements.subband_cqi_dB[eNB][0][0],
+                       ue->measurements.subband_cqi_dB[eNB][0][1],
+                       ue->measurements.subband_cqi_dB[eNB][0][2],
+                       ue->measurements.subband_cqi_dB[eNB][0][3],
+                       ue->measurements.subband_cqi_dB[eNB][0][4],
+                       ue->measurements.subband_cqi_dB[eNB][0][5],
+                       ue->measurements.subband_cqi_dB[eNB][0][6]);
+
+        len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 1): [%d %d %d %d %d %d %d] dB\n",
+                       eNB,
+                       ue->measurements.subband_cqi_dB[eNB][1][0],
+                       ue->measurements.subband_cqi_dB[eNB][1][1],
+                       ue->measurements.subband_cqi_dB[eNB][1][2],
+                       ue->measurements.subband_cqi_dB[eNB][1][3],
+                       ue->measurements.subband_cqi_dB[eNB][1][4],
+                       ue->measurements.subband_cqi_dB[eNB][1][5],
+                       ue->measurements.subband_cqi_dB[eNB][1][6]);
+
+
+        len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 0): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n",
+                       eNB,
+                       ue->measurements.subband_pmi_re[eNB][0][0],
+                       ue->measurements.subband_pmi_im[eNB][0][0],
+                       ue->measurements.subband_pmi_re[eNB][1][0],
+                       ue->measurements.subband_pmi_im[eNB][1][0],
+                       ue->measurements.subband_pmi_re[eNB][2][0],
+                       ue->measurements.subband_pmi_im[eNB][2][0],
+                       ue->measurements.subband_pmi_re[eNB][3][0],
+                       ue->measurements.subband_pmi_im[eNB][3][0],
+                       ue->measurements.subband_pmi_re[eNB][4][0],
+                       ue->measurements.subband_pmi_im[eNB][4][0],
+                       ue->measurements.subband_pmi_re[eNB][5][0],
+                       ue->measurements.subband_pmi_im[eNB][5][0],
+                       ue->measurements.subband_pmi_re[eNB][6][0],
+                       ue->measurements.subband_pmi_im[eNB][6][0]);
+
+        len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 1): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n",
+                       eNB,
+                       ue->measurements.subband_pmi_re[eNB][0][1],
+                       ue->measurements.subband_pmi_im[eNB][0][1],
+                       ue->measurements.subband_pmi_re[eNB][1][1],
+                       ue->measurements.subband_pmi_im[eNB][1][1],
+                       ue->measurements.subband_pmi_re[eNB][2][1],
+                       ue->measurements.subband_pmi_im[eNB][2][1],
+                       ue->measurements.subband_pmi_re[eNB][3][1],
+                       ue->measurements.subband_pmi_im[eNB][3][1],
+                       ue->measurements.subband_pmi_re[eNB][4][1],
+                       ue->measurements.subband_pmi_im[eNB][4][1],
+                       ue->measurements.subband_pmi_re[eNB][5][1],
+                       ue->measurements.subband_pmi_im[eNB][5][1],
+                       ue->measurements.subband_pmi_re[eNB][6][1],
+                       ue->measurements.subband_pmi_im[eNB][6][1]);
+
+        len += sprintf(&buffer[len], "[UE PROC] PMI Antenna selection eNB%d : [%d %d %d %d %d %d %d]\n",
+                       eNB,
+                       ue->measurements.selected_rx_antennas[eNB][0],
+                       ue->measurements.selected_rx_antennas[eNB][1],
+                       ue->measurements.selected_rx_antennas[eNB][2],
+                       ue->measurements.selected_rx_antennas[eNB][3],
+                       ue->measurements.selected_rx_antennas[eNB][4],
+                       ue->measurements.selected_rx_antennas[eNB][5],
+                       ue->measurements.selected_rx_antennas[eNB][6]);
+
+        len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (max): %jx\n",eNB,pmi2hex_2Ar1(quantize_subband_pmi(&ue->measurements,eNB,7)));
+        len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (both): %jx,%jx\n",eNB,
+                       pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,0,7)),
+                       pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,1,7)));
+        break;
+
+      case 50:
+        len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 0): [%d %d %d %d %d %d %d %d %d] dB\n",
+                       eNB,
+                       ue->measurements.subband_cqi_dB[eNB][0][0],
+                       ue->measurements.subband_cqi_dB[eNB][0][1],
+                       ue->measurements.subband_cqi_dB[eNB][0][2],
+                       ue->measurements.subband_cqi_dB[eNB][0][3],
+                       ue->measurements.subband_cqi_dB[eNB][0][4],
+                       ue->measurements.subband_cqi_dB[eNB][0][5],
+                       ue->measurements.subband_cqi_dB[eNB][0][6],
+                       ue->measurements.subband_cqi_dB[eNB][0][7],
+                       ue->measurements.subband_cqi_dB[eNB][0][8]);
+
+        len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 1): [%d %d %d %d %d %d %d %d %d] dB\n",
+                       eNB,
+                       ue->measurements.subband_cqi_dB[eNB][1][0],
+                       ue->measurements.subband_cqi_dB[eNB][1][1],
+                       ue->measurements.subband_cqi_dB[eNB][1][2],
+                       ue->measurements.subband_cqi_dB[eNB][1][3],
+                       ue->measurements.subband_cqi_dB[eNB][1][4],
+                       ue->measurements.subband_cqi_dB[eNB][1][5],
+                       ue->measurements.subband_cqi_dB[eNB][1][6],
+                       ue->measurements.subband_cqi_dB[eNB][1][7],
+                       ue->measurements.subband_cqi_dB[eNB][1][8]);
+
+
+        len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 0): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n",
+                       eNB,
+                       ue->measurements.subband_pmi_re[eNB][0][0],
+                       ue->measurements.subband_pmi_im[eNB][0][0],
+                       ue->measurements.subband_pmi_re[eNB][1][0],
+                       ue->measurements.subband_pmi_im[eNB][1][0],
+                       ue->measurements.subband_pmi_re[eNB][2][0],
+                       ue->measurements.subband_pmi_im[eNB][2][0],
+                       ue->measurements.subband_pmi_re[eNB][3][0],
+                       ue->measurements.subband_pmi_im[eNB][3][0],
+                       ue->measurements.subband_pmi_re[eNB][4][0],
+                       ue->measurements.subband_pmi_im[eNB][4][0],
+                       ue->measurements.subband_pmi_re[eNB][5][0],
+                       ue->measurements.subband_pmi_im[eNB][5][0],
+                       ue->measurements.subband_pmi_re[eNB][6][0],
+                       ue->measurements.subband_pmi_im[eNB][6][0],
+                       ue->measurements.subband_pmi_re[eNB][7][0],
+                       ue->measurements.subband_pmi_im[eNB][7][0],
+                       ue->measurements.subband_pmi_re[eNB][8][0],
+                       ue->measurements.subband_pmi_im[eNB][8][0]);
+
+        len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 1): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n",
+                       eNB,
+                       ue->measurements.subband_pmi_re[eNB][0][1],
+                       ue->measurements.subband_pmi_im[eNB][0][1],
+                       ue->measurements.subband_pmi_re[eNB][1][1],
+                       ue->measurements.subband_pmi_im[eNB][1][1],
+                       ue->measurements.subband_pmi_re[eNB][2][1],
+                       ue->measurements.subband_pmi_im[eNB][2][1],
+                       ue->measurements.subband_pmi_re[eNB][3][1],
+                       ue->measurements.subband_pmi_im[eNB][3][1],
+                       ue->measurements.subband_pmi_re[eNB][4][1],
+                       ue->measurements.subband_pmi_im[eNB][4][1],
+                       ue->measurements.subband_pmi_re[eNB][5][1],
+                       ue->measurements.subband_pmi_im[eNB][5][1],
+                       ue->measurements.subband_pmi_re[eNB][6][1],
+                       ue->measurements.subband_pmi_im[eNB][6][1],
+                       ue->measurements.subband_pmi_re[eNB][7][1],
+                       ue->measurements.subband_pmi_im[eNB][7][1],
+                       ue->measurements.subband_pmi_re[eNB][8][1],
+                       ue->measurements.subband_pmi_im[eNB][8][1]);
+
+        len += sprintf(&buffer[len], "[UE PROC] PMI Antenna selection eNB%d : [%d %d %d %d %d %d %d %d %d]\n",
+                       eNB,
+                       ue->measurements.selected_rx_antennas[eNB][0],
+                       ue->measurements.selected_rx_antennas[eNB][1],
+                       ue->measurements.selected_rx_antennas[eNB][2],
+                       ue->measurements.selected_rx_antennas[eNB][3],
+                       ue->measurements.selected_rx_antennas[eNB][4],
+                       ue->measurements.selected_rx_antennas[eNB][5],
+                       ue->measurements.selected_rx_antennas[eNB][6],
+                       ue->measurements.selected_rx_antennas[eNB][7],
+                       ue->measurements.selected_rx_antennas[eNB][8]);
+
+        len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (max): %jx\n",eNB,pmi2hex_2Ar1(quantize_subband_pmi(&ue->measurements,eNB,9)));
+        len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (both): %jx,%jx\n",eNB,
+                       pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,0,9)),
+                       pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,1,9)));
+        break;
+
+      case 100:
+        len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 0): [%d %d %d %d %d %d %d %d %d %d %d %d %d] dB\n",
+                       eNB,
+                       ue->measurements.subband_cqi_dB[eNB][0][0],
+                       ue->measurements.subband_cqi_dB[eNB][0][1],
+                       ue->measurements.subband_cqi_dB[eNB][0][2],
+                       ue->measurements.subband_cqi_dB[eNB][0][3],
+                       ue->measurements.subband_cqi_dB[eNB][0][4],
+                       ue->measurements.subband_cqi_dB[eNB][0][5],
+                       ue->measurements.subband_cqi_dB[eNB][0][6],
+                       ue->measurements.subband_cqi_dB[eNB][0][7],
+                       ue->measurements.subband_cqi_dB[eNB][0][8],
+                       ue->measurements.subband_cqi_dB[eNB][0][9],
+                       ue->measurements.subband_cqi_dB[eNB][0][10],
+                       ue->measurements.subband_cqi_dB[eNB][0][11],
+                       ue->measurements.subband_cqi_dB[eNB][0][12]);
+
+        len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 1): [%d %d %d %d %d %d %d %d %d %d %d %d %d] dB\n",
+                       eNB,
+                       ue->measurements.subband_cqi_dB[eNB][1][0],
+                       ue->measurements.subband_cqi_dB[eNB][1][1],
+                       ue->measurements.subband_cqi_dB[eNB][1][2],
+                       ue->measurements.subband_cqi_dB[eNB][1][3],
+                       ue->measurements.subband_cqi_dB[eNB][1][4],
+                       ue->measurements.subband_cqi_dB[eNB][1][5],
+                       ue->measurements.subband_cqi_dB[eNB][1][6],
+                       ue->measurements.subband_cqi_dB[eNB][1][7],
+                       ue->measurements.subband_cqi_dB[eNB][1][8],
+                       ue->measurements.subband_cqi_dB[eNB][1][9],
+                       ue->measurements.subband_cqi_dB[eNB][1][10],
+                       ue->measurements.subband_cqi_dB[eNB][1][11],
+                       ue->measurements.subband_cqi_dB[eNB][1][12]);
+
+
+        len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 0): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n",
+                       eNB,
+                       ue->measurements.subband_pmi_re[eNB][0][0],
+                       ue->measurements.subband_pmi_im[eNB][0][0],
+                       ue->measurements.subband_pmi_re[eNB][1][0],
+                       ue->measurements.subband_pmi_im[eNB][1][0],
+                       ue->measurements.subband_pmi_re[eNB][2][0],
+                       ue->measurements.subband_pmi_im[eNB][2][0],
+                       ue->measurements.subband_pmi_re[eNB][3][0],
+                       ue->measurements.subband_pmi_im[eNB][3][0],
+                       ue->measurements.subband_pmi_re[eNB][4][0],
+                       ue->measurements.subband_pmi_im[eNB][4][0],
+                       ue->measurements.subband_pmi_re[eNB][5][0],
+                       ue->measurements.subband_pmi_im[eNB][5][0],
+                       ue->measurements.subband_pmi_re[eNB][6][0],
+                       ue->measurements.subband_pmi_im[eNB][6][0],
+                       ue->measurements.subband_pmi_re[eNB][7][0],
+                       ue->measurements.subband_pmi_im[eNB][7][0],
+                       ue->measurements.subband_pmi_re[eNB][8][0],
+                       ue->measurements.subband_pmi_im[eNB][8][0],
+                       ue->measurements.subband_pmi_re[eNB][9][0],
+                       ue->measurements.subband_pmi_im[eNB][9][0],
+                       ue->measurements.subband_pmi_re[eNB][10][0],
+                       ue->measurements.subband_pmi_im[eNB][10][0],
+                       ue->measurements.subband_pmi_re[eNB][11][0],
+                       ue->measurements.subband_pmi_im[eNB][11][0],
+                       ue->measurements.subband_pmi_re[eNB][12][0],
+                       ue->measurements.subband_pmi_im[eNB][12][0]);
+
+        len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 1): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n",
+                       eNB,
+                       ue->measurements.subband_pmi_re[eNB][0][1],
+                       ue->measurements.subband_pmi_im[eNB][0][1],
+                       ue->measurements.subband_pmi_re[eNB][1][1],
+                       ue->measurements.subband_pmi_im[eNB][1][1],
+                       ue->measurements.subband_pmi_re[eNB][2][1],
+                       ue->measurements.subband_pmi_im[eNB][2][1],
+                       ue->measurements.subband_pmi_re[eNB][3][1],
+                       ue->measurements.subband_pmi_im[eNB][3][1],
+                       ue->measurements.subband_pmi_re[eNB][4][1],
+                       ue->measurements.subband_pmi_im[eNB][4][1],
+                       ue->measurements.subband_pmi_re[eNB][5][1],
+                       ue->measurements.subband_pmi_im[eNB][5][1],
+                       ue->measurements.subband_pmi_re[eNB][6][1],
+                       ue->measurements.subband_pmi_im[eNB][6][1],
+                       ue->measurements.subband_pmi_re[eNB][7][1],
+                       ue->measurements.subband_pmi_im[eNB][7][1],
+                       ue->measurements.subband_pmi_re[eNB][8][1],
+                       ue->measurements.subband_pmi_im[eNB][8][1],
+                       ue->measurements.subband_pmi_re[eNB][9][1],
+                       ue->measurements.subband_pmi_im[eNB][9][1],
+                       ue->measurements.subband_pmi_re[eNB][10][1],
+                       ue->measurements.subband_pmi_im[eNB][10][1],
+                       ue->measurements.subband_pmi_re[eNB][11][1],
+                       ue->measurements.subband_pmi_im[eNB][11][1],
+                       ue->measurements.subband_pmi_re[eNB][12][1],
+                       ue->measurements.subband_pmi_im[eNB][12][1]);
+
+        len += sprintf(&buffer[len], "[UE PROC] PMI Antenna selection eNB%d : [%d %d %d %d %d %d %d %d %d %d %d %d %d]\n",
+                       eNB,
+                       ue->measurements.selected_rx_antennas[eNB][0],
+                       ue->measurements.selected_rx_antennas[eNB][1],
+                       ue->measurements.selected_rx_antennas[eNB][2],
+                       ue->measurements.selected_rx_antennas[eNB][3],
+                       ue->measurements.selected_rx_antennas[eNB][4],
+                       ue->measurements.selected_rx_antennas[eNB][5],
+                       ue->measurements.selected_rx_antennas[eNB][6],
+                       ue->measurements.selected_rx_antennas[eNB][7],
+                       ue->measurements.selected_rx_antennas[eNB][8],
+                       ue->measurements.selected_rx_antennas[eNB][9],
+                       ue->measurements.selected_rx_antennas[eNB][10],
+                       ue->measurements.selected_rx_antennas[eNB][11],
+                       ue->measurements.selected_rx_antennas[eNB][12]);
+
+        len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (max): %jx\n",eNB,pmi2hex_2Ar1(quantize_subband_pmi(&ue->measurements,eNB,13)));
+        len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (both): %jx,%jx\n",eNB,
+                       pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,0,13)),
+                       pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,1,13)));
+        break;
+      }
+
+#ifdef OPENAIR2
+      RRC_status = mac_UE_get_rrc_status(ue->Mod_id, 0);
+      len += sprintf(&buffer[len],"[UE PROC] RRC status = %d\n",RRC_status);
+#endif
+
+ 
+      len += sprintf(&buffer[len], "[UE PROC] Transmission Mode %d \n",ue->transmission_mode[eNB]);
+      len += sprintf(&buffer[len], "[UE PROC] PBCH err conseq %d, PBCH error total %d, PBCH FER %d\n",
+                     ue->pbch_vars[eNB]->pdu_errors_conseq,
+                     ue->pbch_vars[eNB]->pdu_errors,
+                     ue->pbch_vars[eNB]->pdu_fer);
+
+      if (ue->transmission_mode[eNB] == 6)
+        len += sprintf(&buffer[len], "[UE PROC] Mode 6 Wideband CQI eNB %d : %d dB\n",eNB,ue->measurements.precoded_cqi_dB[eNB][0]);
+
+      for (harq_pid=0;harq_pid<8;harq_pid++) {
+	len+=sprintf(&buffer[len],"[UE PROC] eNB %d: CW 0 harq_pid %d, mcs %d:",eNB,harq_pid,ue->dlsch[0][0][0]->harq_processes[harq_pid]->mcs);
+	for (round=0;round<8;round++)
+	  len+=sprintf(&buffer[len],"%d/%d ",
+		       ue->dlsch[0][0][0]->harq_processes[harq_pid]->errors[round],
+		       ue->dlsch[0][0][0]->harq_processes[harq_pid]->trials[round]);
+	len+=sprintf(&buffer[len],"\n");
+      }
+      if (ue->dlsch[0][0] && ue->dlsch[0][0][0] && ue->dlsch[0][0][1]) {
+        len += sprintf(&buffer[len], "[UE PROC] Saved PMI for DLSCH eNB %d : %jx (%p)\n",eNB,pmi2hex_2Ar1(ue->dlsch[0][0][0]->pmi_alloc),ue->dlsch[0][0][0]);
+
+        len += sprintf(&buffer[len], "[UE PROC] eNB %d: dl_power_off = %d\n",eNB,ue->dlsch[0][0][0]->harq_processes[0]->dl_power_off);
+
+	for (harq_pid=0;harq_pid<8;harq_pid++) {
+	  len+=sprintf(&buffer[len],"[UE PROC] eNB %d: CW 1 harq_pid %d, mcs %d:",eNB,harq_pid,ue->dlsch[0][0][1]->harq_processes[0]->mcs);
+	  for (round=0;round<8;round++)
+	    len+=sprintf(&buffer[len],"%d/%d ",
+			 ue->dlsch[0][0][1]->harq_processes[harq_pid]->errors[round],
+			 ue->dlsch[0][0][1]->harq_processes[harq_pid]->trials[round]);
+	  len+=sprintf(&buffer[len],"\n");
+	}
+      }
+
+      len += sprintf(&buffer[len], "[UE PROC] DLSCH Total %d, Error %d, FER %d\n",ue->dlsch_received[0],ue->dlsch_errors[0],ue->dlsch_fer[0]);
+      len += sprintf(&buffer[len], "[UE PROC] DLSCH (SI) Total %d, Error %d\n",ue->dlsch_SI_received[0],ue->dlsch_SI_errors[0]);
+      len += sprintf(&buffer[len], "[UE PROC] DLSCH (RA) Total %d, Error %d\n",ue->dlsch_ra_received[0],ue->dlsch_ra_errors[0]);
+#if defined(Rel10) || defined(Rel14)
+      int i=0;
+
+      //len += sprintf(&buffer[len], "[UE PROC] MCH  Total %d\n", ue->dlsch_mch_received[0]);
+      for(i=0; i <ue->frame_parms.num_MBSFN_config; i++ ) {
+        len += sprintf(&buffer[len], "[UE PROC] MCH (MCCH MBSFN %d) Total %d, Error %d, Trials %d\n",
+                       i, ue->dlsch_mcch_received[i][0],ue->dlsch_mcch_errors[i][0],ue->dlsch_mcch_trials[i][0]);
+        len += sprintf(&buffer[len], "[UE PROC] MCH (MTCH MBSFN %d) Total %d, Error %d, Trials %d\n",
+                       i, ue->dlsch_mtch_received[i][0],ue->dlsch_mtch_errors[i][0],ue->dlsch_mtch_trials[i][0]);
+      }
+
+#endif
+      len += sprintf(&buffer[len], "[UE PROC] DLSCH Bitrate %dkbps\n",(ue->bitrate[0]/1000));
+      len += sprintf(&buffer[len], "[UE PROC] Total Received Bits %dkbits\n",(ue->total_received_bits[0]/1000));
+      len += sprintf(&buffer[len], "[UE PROC] IA receiver %d\n",ue->use_ia_receiver);
+
+    }
+
+  } else {
+    len += sprintf(&buffer[len], "[UE PROC] Frame count: %d, RSSI %3.2f dB (%d dB, %d dB), N0 %3.2f dB (%d dB, %d dB)\n",
+                   proc->frame_rx,
+                   10*log10(ue->measurements.rssi),
+                   ue->measurements.rx_power_dB[0][0],
+                   ue->measurements.rx_power_dB[0][1],
+                   10*log10(ue->measurements.n0_power_tot),
+                   ue->measurements.n0_power_dB[0],
+                   ue->measurements.n0_power_dB[1]);
+#ifdef EXMIMO
+    ue->rx_total_gain_dB = ((int)(10*log10(ue->measurements.rssi)))-input_level_dBm;
+    len += sprintf(&buffer[len], "[UE PROC] rxg_mode %d, input level (set by user) %d dBm, VGA gain %d dB ==> total gain %3.2f dB, noise figure %3.2f dB\n",
+                   openair0_cfg[0].rxg_mode[0],
+                   input_level_dBm,
+                   (int)openair0_cfg[0].rx_gain[0],
+                   10*log10(ue->measurements.rssi)-input_level_dBm,
+                   10*log10(ue->measurements.n0_power_tot)-ue->rx_total_gain_dB+105);
+#endif
+  }
+
+  len += sprintf(&buffer[len],"EOF\n");
+
+  return len;
+} // is_clusterhead
+
+/*
+int dump_eNB_stats(PHY_VARS_eNB *eNB, char* buffer, int length)
+{
+
+  unsigned int success=0;
+  uint8_t eNB_id,UE_id,i,j,number_of_cards_l=1;
+  uint32_t ulsch_errors=0,dlsch_errors=0;
+  uint32_t ulsch_round_attempts[4]= {0,0,0,0},ulsch_round_errors[4]= {0,0,0,0};
+  uint32_t dlsch_round_attempts[4]= {0,0,0,0},dlsch_round_errors[4]= {0,0,0,0};
+  uint32_t UE_id_mac, RRC_status;
+  eNB_rxtx_proc_t *proc = &eNB->proc.proc_rxtx[0];
+  if (eNB==NULL)
+    return 0;
+
+  int len = length;
+
+  //  if(eNB->frame==0){
+  eNB->total_dlsch_bitrate = 0;//eNB->UE_stats[UE_id].dlsch_bitrate + eNB->total_dlsch_bitrate;
+  eNB->total_transmitted_bits = 0;// eNB->UE_stats[UE_id].total_transmitted_bits +  eNB->total_transmitted_bits;
+  eNB->total_system_throughput = 0;//eNB->UE_stats[UE_id].total_transmitted_bits + eNB->total_system_throughput;
+  // }
+
+  for (eNB_id=0; eNB_id<number_of_cards_l; eNB_id++) {
+    len += sprintf(&buffer[len],"eNB %d/%d Frame %d: RX Gain %d dB, I0 %d dBm (%d,%d) dB \n",
+                   eNB_id,number_of_cards_l,
+                   proc->frame_tx,
+                   eNB->rx_total_gain_dB,
+                   eNB->measurements.n0_power_tot_dBm,
+                   eNB->measurements.n0_power_dB[0],
+                   eNB->measurements.n0_power_dB[1]);
+
+    len += sprintf(&buffer[len],"PRB I0 (%X.%X.%X.%X): ",
+		   eNB->rb_mask_ul[0],
+		   eNB->rb_mask_ul[1],eNB->rb_mask_ul[2],eNB->rb_mask_ul[3]);
+
+    for (i=0; i<eNB->frame_parms.N_RB_UL; i++) {
+      len += sprintf(&buffer[len],"%4d ",
+                     eNB->measurements.n0_subband_power_tot_dBm[i]);
+      if ((i>0) && ((i%25) == 0)) 
+	len += sprintf(&buffer[len],"\n");
+    }
+    len += sprintf(&buffer[len],"\n");
+    len += sprintf(&buffer[len],"\nPERFORMANCE PARAMETERS\n");
+
+    for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
+      if (eNB &&
+	  (eNB->dlsch!=NULL) &&
+	  (eNB->dlsch[(uint8_t)UE_id]!=NULL) &&
+	  (eNB->dlsch[(uint8_t)UE_id][0]->rnti>0)&&
+	  (eNB->UE_stats[UE_id].mode == PUSCH)) {	
+
+        eNB->total_dlsch_bitrate = eNB->UE_stats[UE_id].dlsch_bitrate + eNB->total_dlsch_bitrate;
+        eNB->total_transmitted_bits = eNB->UE_stats[UE_id].total_TBS + eNB->total_transmitted_bits;
+
+        //eNB->total_system_throughput = eNB->UE_stats[UE_id].total_transmitted_bits + eNB->total_system_throughput;
+         
+	for (i=0; i<8; i++)
+	  success = success + (eNB->UE_stats[UE_id].dlsch_trials[i][0] - eNB->UE_stats[UE_id].dlsch_l2_errors[i]);
+
+    
+	
+	len += sprintf(&buffer[len],"Total DLSCH %d kbits / %d frames ",(eNB->total_transmitted_bits/1000),proc->frame_tx+1);
+	len += sprintf(&buffer[len],"Total DLSCH throughput %d kbps ",(eNB->total_dlsch_bitrate/1000));
+	len += sprintf(&buffer[len],"Total DLSCH trans %d / %d frames\n",success,proc->frame_tx+1);
+	//len += sprintf(&buffer[len],"[eNB PROC] FULL MU-MIMO Transmissions/Total Transmissions = %d/%d\n",eNB->FULL_MUMIMO_transmissions,eNB->check_for_total_transmissions);
+	//len += sprintf(&buffer[len],"[eNB PROC] MU-MIMO Transmissions/Total Transmissions = %d/%d\n",eNB->check_for_MUMIMO_transmissions,eNB->check_for_total_transmissions);
+	//len += sprintf(&buffer[len],"[eNB PROC] SU-MIMO Transmissions/Total Transmissions = %d/%d\n",eNB->check_for_SUMIMO_transmissions,eNB->check_for_total_transmissions);
+	
+	len += sprintf(&buffer[len],"UE %d (%x) Power: (%d,%d) dB, Po_PUSCH: (%d,%d) dBm, Po_PUCCH (%d/%d) dBm, Po_PUCCH1 (%d,%d) dBm,  PUCCH1 Thres %d dBm \n",
+		       UE_id,
+		       eNB->UE_stats[UE_id].crnti,
+		       dB_fixed(eNB->pusch_vars[UE_id]->ulsch_power[0]),
+		       dB_fixed(eNB->pusch_vars[UE_id]->ulsch_power[1]),
+		       eNB->UE_stats[UE_id].UL_rssi[0],
+		       eNB->UE_stats[UE_id].UL_rssi[1],
+		       dB_fixed(eNB->UE_stats[UE_id].Po_PUCCH/eNB->frame_parms.N_RB_UL)-eNB->rx_total_gain_dB,
+		       eNB->frame_parms.ul_power_control_config_common.p0_NominalPUCCH,
+		       dB_fixed(eNB->UE_stats[UE_id].Po_PUCCH1_below/eNB->frame_parms.N_RB_UL)-eNB->rx_total_gain_dB,
+		       dB_fixed(eNB->UE_stats[UE_id].Po_PUCCH1_above/eNB->frame_parms.N_RB_UL)-eNB->rx_total_gain_dB,
+		       PUCCH1_THRES+eNB->measurements.n0_power_tot_dBm-dB_fixed(eNB->frame_parms.N_RB_UL));
+	
+	len+= sprintf(&buffer[len],"DL mcs %d, UL mcs %d, UL rb %d, delta_TF %d, ",
+		      eNB->dlsch[(uint8_t)UE_id][0]->harq_processes[0]->mcs,
+		      eNB->ulsch[(uint8_t)UE_id]->harq_processes[0]->mcs,
+		      eNB->ulsch[(uint8_t)UE_id]->harq_processes[0]->nb_rb,
+		      eNB->ulsch[(uint8_t)UE_id]->harq_processes[0]->delta_TF);
+	
+	len += sprintf(&buffer[len],"Wideband CQI: (%d,%d) dB\n",
+		       eNB->measurements.wideband_cqi_dB[UE_id][0],
+		       eNB->measurements.wideband_cqi_dB[UE_id][1]);
+	
+	len += sprintf(&buffer[len],"DL TM %d, DL_cqi %d, DL_pmi_single %jx ",
+		       eNB->transmission_mode[UE_id],
+		       eNB->UE_stats[UE_id].DL_cqi[0],
+		       pmi2hex_2Ar1(eNB->UE_stats[UE_id].DL_pmi_single));
+
+	len += sprintf(&buffer[len],"Timing advance %d samples (%d 16Ts), update %d ",
+		       eNB->UE_stats[UE_id].UE_timing_offset,
+		       eNB->UE_stats[UE_id].UE_timing_offset>>2,
+		       eNB->UE_stats[UE_id].timing_advance_update);
+	
+	len += sprintf(&buffer[len],"Mode = %s(%d) ",
+		       mode_string[eNB->UE_stats[UE_id].mode],
+		       eNB->UE_stats[UE_id].mode);
+	UE_id_mac = find_UE_id(eNB->Mod_id,eNB->dlsch[(uint8_t)UE_id][0]->rnti);
+	
+	if (UE_id_mac != -1) {
+	  RRC_status = mac_eNB_get_rrc_status(eNB->Mod_id,eNB->dlsch[(uint8_t)UE_id][0]->rnti);
+	  len += sprintf(&buffer[len],"UE_id_mac = %d, RRC status = %d\n",UE_id_mac,RRC_status);
+	} else
+	  len += sprintf(&buffer[len],"UE_id_mac = -1\n");
+	
+        len += sprintf(&buffer[len],"SR received/total: %d/%d (diff %d)\n",
+                       eNB->UE_stats[UE_id].sr_received,
+                       eNB->UE_stats[UE_id].sr_total,
+                       eNB->UE_stats[UE_id].sr_total-eNB->UE_stats[UE_id].sr_received);
+	
+	len += sprintf(&buffer[len],"DL Subband CQI: ");
+
+	int nb_sb;
+	switch (eNB->frame_parms.N_RB_DL) {
+	case 6:
+	  nb_sb=0;
+	  break;
+	case 15:
+	  nb_sb = 4;
+	case 25:
+	  nb_sb = 7;
+	  break;
+	case 50:
+	  nb_sb = 9;
+	  break;
+	case 75:
+	  nb_sb = 10;
+	  break;
+	case 100:
+	  nb_sb = 13;
+	  break;
+	default:
+	  nb_sb=0;
+	  break;
+	}	
+	for (i=0; i<nb_sb; i++)
+	  len += sprintf(&buffer[len],"%2d ",
+			 eNB->UE_stats[UE_id].DL_subband_cqi[0][i]);
+	len += sprintf(&buffer[len],"\n");
+	
+
+
+        ulsch_errors = 0;
+
+        for (j=0; j<4; j++) {
+          ulsch_round_attempts[j]=0;
+          ulsch_round_errors[j]=0;
+        }
+
+        len += sprintf(&buffer[len],"ULSCH errors/attempts per harq (per round): \n");
+
+        for (i=0; i<8; i++) {
+          len += sprintf(&buffer[len],"   harq %d: %d/%d (fer %d) (%d/%d, %d/%d, %d/%d, %d/%d) ",
+                         i,
+                         eNB->UE_stats[UE_id].ulsch_errors[i],
+                         eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][0],
+                         eNB->UE_stats[UE_id].ulsch_round_fer[i][0],
+                         eNB->UE_stats[UE_id].ulsch_round_errors[i][0],
+                         eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][0],
+                         eNB->UE_stats[UE_id].ulsch_round_errors[i][1],
+                         eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][1],
+                         eNB->UE_stats[UE_id].ulsch_round_errors[i][2],
+                         eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][2],
+                         eNB->UE_stats[UE_id].ulsch_round_errors[i][3],
+                         eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][3]);
+	  if ((i&1) == 1)
+	    len += sprintf(&buffer[len],"\n");
+	    
+          ulsch_errors+=eNB->UE_stats[UE_id].ulsch_errors[i];
+
+          for (j=0; j<4; j++) {
+            ulsch_round_attempts[j]+=eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][j];
+            ulsch_round_errors[j]+=eNB->UE_stats[UE_id].ulsch_round_errors[i][j];
+          }
+        }
+
+        len += sprintf(&buffer[len],"ULSCH errors/attempts total %d/%d (%d/%d, %d/%d, %d/%d, %d/%d)\n",
+                       ulsch_errors,ulsch_round_attempts[0],
+
+                       ulsch_round_errors[0],ulsch_round_attempts[0],
+                       ulsch_round_errors[1],ulsch_round_attempts[1],
+                       ulsch_round_errors[2],ulsch_round_attempts[2],
+                       ulsch_round_errors[3],ulsch_round_attempts[3]);
+
+        dlsch_errors = 0;
+
+        for (j=0; j<4; j++) {
+          dlsch_round_attempts[j]=0;
+          dlsch_round_errors[j]=0;
+        }
+
+        len += sprintf(&buffer[len],"DLSCH errors/attempts per harq (per round): \n");
+
+        for (i=0; i<8; i++) {
+          len += sprintf(&buffer[len],"   harq %d: %d/%d (%d/%d/%d, %d/%d/%d, %d/%d/%d, %d/%d/%d) ",
+                         i,
+                         eNB->UE_stats[UE_id].dlsch_l2_errors[i],
+                         eNB->UE_stats[UE_id].dlsch_trials[i][0],
+                         eNB->UE_stats[UE_id].dlsch_ACK[i][0],
+                         eNB->UE_stats[UE_id].dlsch_NAK[i][0],
+                         eNB->UE_stats[UE_id].dlsch_trials[i][0],
+                         eNB->UE_stats[UE_id].dlsch_ACK[i][1],
+                         eNB->UE_stats[UE_id].dlsch_NAK[i][1],
+                         eNB->UE_stats[UE_id].dlsch_trials[i][1],
+                         eNB->UE_stats[UE_id].dlsch_ACK[i][2],
+                         eNB->UE_stats[UE_id].dlsch_NAK[i][2],
+                         eNB->UE_stats[UE_id].dlsch_trials[i][2],
+                         eNB->UE_stats[UE_id].dlsch_ACK[i][3],
+                         eNB->UE_stats[UE_id].dlsch_NAK[i][3],
+                         eNB->UE_stats[UE_id].dlsch_trials[i][3]);
+	  if ((i&1) == 1)
+	    len += sprintf(&buffer[len],"\n");
+
+
+          dlsch_errors+=eNB->UE_stats[UE_id].dlsch_l2_errors[i];
+
+          for (j=0; j<4; j++) {
+            dlsch_round_attempts[j]+=eNB->UE_stats[UE_id].dlsch_trials[i][j];
+            dlsch_round_errors[j]+=eNB->UE_stats[UE_id].dlsch_NAK[i][j];
+          }
+        }
+
+        len += sprintf(&buffer[len],"DLSCH errors/attempts total %d/%d (%d/%d, %d/%d, %d/%d, %d/%d): \n",
+                       dlsch_errors,dlsch_round_attempts[0],
+                       dlsch_round_errors[0],dlsch_round_attempts[0],
+                       dlsch_round_errors[1],dlsch_round_attempts[1],
+                       dlsch_round_errors[2],dlsch_round_attempts[2],
+                       dlsch_round_errors[3],dlsch_round_attempts[3]);
+
+
+        len += sprintf(&buffer[len],"DLSCH total bits from MAC: %dkbit ",(eNB->UE_stats[UE_id].total_TBS_MAC)/1000);
+        len += sprintf(&buffer[len],"DLSCH total bits ack'ed: %dkbit ",(eNB->UE_stats[UE_id].total_TBS)/1000);
+        len += sprintf(&buffer[len],"DLSCH Average throughput (100 frames): %dkbps\n",(eNB->UE_stats[UE_id].dlsch_bitrate/1000));
+	//        len += sprintf(&buffer[len],"[eNB PROC] Transmission Mode %d\n",eNB->transmission_mode[UE_id]);
+      }
+    }
+
+    len += sprintf(&buffer[len],"\n");
+  }
+  
+  len += sprintf(&buffer[len],"EOF\n");
+  
+  return len;
+}
+*/
diff --git a/openair1/PHY/LTE_TRANSPORT/pucch.c b/openair1/PHY/LTE_TRANSPORT/pucch.c
index 0e7ab9e9a2eb6ee78cbad07af06e2fad0dec586c..ac12ee44272985f0da947383c6b8ce8ec58efe90 100644
--- a/openair1/PHY/LTE_TRANSPORT/pucch.c
+++ b/openair1/PHY/LTE_TRANSPORT/pucch.c
@@ -718,7 +718,11 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB,
 		  uint8_t *payload,
 		  int     frame,
 		  uint8_t subframe,
-		  uint8_t pucch1_thres)
+		  uint8_t pucch1_thres
+#ifdef Rel14
+		  ,uint8_t br_flag
+#endif
+		  )
 {
 
 
@@ -727,7 +731,8 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB,
   LTE_DL_FRAME_PARMS *frame_parms                    = &eNB->frame_parms;
   //  PUCCH_CONFIG_DEDICATED *pucch_config_dedicated = &eNB->pucch_config_dedicated[UE_id];
 
-  int8_t sigma2_dB                                   = 20;//eNB->measurements.n0_subband_power_tot_dB[0]-10;
+  int8_t sigma2_dB                                   = max(eNB->measurements.n0_subband_power_tot_dB[0],
+                                                           eNB->measurements.n0_subband_power_tot_dB[eNB->frame_parms.N_RB_UL-1]);
 
   uint32_t u,v,n,aa;
   uint32_t z[12*14];
@@ -984,14 +989,25 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB,
 
     //for (j=0,l=0;l<(nsymb-1);l++) {
     for (j=0,l=0; l<nsymb; l++) {
-      if ((l<(nsymb>>1)) && ((m&1) == 0))
-        re_offset = (m*6) + frame_parms->first_carrier_offset;
-      else if ((l<(nsymb>>1)) && ((m&1) == 1))
-        re_offset = frame_parms->first_carrier_offset + (frame_parms->N_RB_DL - (m>>1) - 1)*12;
-      else if ((m&1) == 0)
-        re_offset = frame_parms->first_carrier_offset + (frame_parms->N_RB_DL - (m>>1) - 1)*12;
+#ifdef Rel14
+      if (br_flag > 0 ) {
+        if ((m&1) == 0)
+          re_offset = (m*6) + frame_parms->first_carrier_offset;
+	else
+	  re_offset = frame_parms->first_carrier_offset + (frame_parms->N_RB_DL - (m>>1) - 1)*12;
+      }
       else
-        re_offset = ((m-1)*6) + frame_parms->first_carrier_offset;
+#endif
+      {
+        if ((l<(nsymb>>1)) && ((m&1) == 0))
+          re_offset = (m*6) + frame_parms->first_carrier_offset;
+        else if ((l<(nsymb>>1)) && ((m&1) == 1))
+          re_offset = frame_parms->first_carrier_offset + (frame_parms->N_RB_DL - (m>>1) - 1)*12;
+        else if ((m&1) == 0)
+          re_offset = frame_parms->first_carrier_offset + (frame_parms->N_RB_DL - (m>>1) - 1)*12;
+        else
+          re_offset = ((m-1)*6) + frame_parms->first_carrier_offset;
+      }
 
       if (re_offset > frame_parms->ofdm_symbol_size)
         re_offset -= (frame_parms->ofdm_symbol_size);
@@ -1302,7 +1318,7 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB,
 #endif
 	  }
 	  
-      
+	  
 
 #ifdef DEBUG_PUCCH_RX
           printf("[eNB] PUCCH subframe %d chest1[%d][%d] => (%d,%d)\n",subframe,aa,re,
diff --git a/openair1/PHY/LTE_TRANSPORT/transport_eNB.h b/openair1/PHY/LTE_TRANSPORT/transport_eNB.h
index 7df39e038c1667dc044ab66c5f6c4c5e2bc9227a..ddf3594880ed147933d1a3e49a1968f3ab5f045b 100644
--- a/openair1/PHY/LTE_TRANSPORT/transport_eNB.h
+++ b/openair1/PHY/LTE_TRANSPORT/transport_eNB.h
@@ -50,6 +50,7 @@
 
 
 
+
 typedef struct {
   /// Status Flag indicating for this DLSCH (idle,active,disabled)
   SCH_status_t status;
@@ -443,6 +444,10 @@ typedef struct {
 } LTE_eNB_UE_stats;
 
 typedef struct {
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+  /// UE type (normal, CEModeA, CEModeB)
+  uint8_t ue_type;
+#endif
   /// HARQ process mask, indicates which processes are currently active
   uint16_t harq_mask;
   /// Pointers to 8 HARQ processes for the ULSCH
diff --git a/openair1/PHY/LTE_TRANSPORT/transport_proto.h b/openair1/PHY/LTE_TRANSPORT/transport_proto.h
index 0c0d2c962d83fb7d0b216bba008db35d44a71576..f4919c6403c9bd34d6badc9c793049b4f4485ba7 100644
--- a/openair1/PHY/LTE_TRANSPORT/transport_proto.h
+++ b/openair1/PHY/LTE_TRANSPORT/transport_proto.h
@@ -385,6 +385,8 @@ uint8_t generate_dci_top(uint8_t num_pdcch_symbols,
                          uint32_t sub_frame_offset);
 
 
+void generate_mdci_top(PHY_VARS_eNB * eNB, int frame, int subframe, int16_t amp, int32_t ** txdataF);
+
 void generate_64qam_table(void);
 void generate_16qam_table(void);
 
@@ -421,6 +423,8 @@ void fill_dci0(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t *proc,DCI
 
 void fill_ulsch(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_ulsch_pdu *ulsch_pdu,int frame,int subframe);
 
+void fill_mpdcch_dci0 (PHY_VARS_eNB * eNB, L1_rxtx_proc_t * proc, mDCI_ALLOC_t * dci_alloc, nfapi_hi_dci0_mpdcch_dci_pdu * pdu);
+
 int generate_eNB_ulsch_params_from_rar(PHY_VARS_eNB *eNB,
 				       unsigned char *rar_pdu,
                                        uint32_t frame,
diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c
index 7c6fc9bdcf60d3bfd9997e0d485366c5a4b1161a..cc62f83f4c057f25862ab4f30e31e94dc905eaee 100644
--- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c
+++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c
@@ -806,10 +806,16 @@ unsigned int  ulsch_decoding(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
 
 
 
-  harq_pid = subframe2harq_pid(frame_parms,frame,subframe);
+#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+  if (ulsch->ue_type>0)     harq_pid = 0;
+  else
+#endif
+    {
+      harq_pid = subframe2harq_pid(frame_parms,proc->frame_rx,subframe);
+    }
 
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_ULSCH_DECODING0+harq_pid,1);
-
+  
   // x1 is set in lte_gold_generic
   x2 = ((uint32_t)ulsch->rnti<<14) + ((uint32_t)subframe<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.3.1
   ulsch_harq = ulsch->harq_processes[harq_pid];
diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c
index f4137697cf621c664fe720fcb6db0bfd74493d33..0c799d8494fcf416fe3682b10bbfca4d07b9be8c 100644
--- a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c
+++ b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c
@@ -1127,17 +1127,20 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
   int16_t *llrp;
   int subframe = proc->subframe_rx;
 
-  harq_pid = subframe2harq_pid(frame_parms,proc->frame_rx,subframe);
+#ifdef Rel14
+  if (ulsch[UE_id]->ue_type > 0) harq_pid =0;
+  else
+#endif
+    {
+      harq_pid = subframe2harq_pid(frame_parms,proc->frame_rx,subframe);
+    }
   Qm = ulsch[UE_id]->harq_processes[harq_pid]->Qm;
   if(LOG_DEBUGFLAG(DEBUG_ULSCH)) {
      LOG_I(PHY,"rx_ulsch: harq_pid %d, nb_rb %d first_rb %d\n",harq_pid,ulsch[UE_id]->harq_processes[harq_pid]->nb_rb,ulsch[UE_id]->harq_processes[harq_pid]->first_rb);
   }
 
-  if (ulsch[UE_id]->harq_processes[harq_pid]->nb_rb == 0) {
-    LOG_E(PHY,"PUSCH (%d/%x) nb_rb=0!\n", harq_pid,ulsch[UE_id]->rnti);
-    return;
-  }
-
+  AssertFatal(ulsch[UE_id]->harq_processes[harq_pid]->nb_rb > 0,
+	      "PUSCH (%d/%x) nb_rb=0!\n", harq_pid,ulsch[UE_id]->rnti);
   for (l=0; l<(frame_parms->symbols_per_tti-ulsch[UE_id]->harq_processes[harq_pid]->srs_active); l++) {
 
   if(LOG_DEBUGFLAG(DEBUG_ULSCH)) {
diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c
old mode 100755
new mode 100644
diff --git a/openair1/PHY/LTE_UE_TRANSPORT/linear_preprocessing_rec.h b/openair1/PHY/LTE_UE_TRANSPORT/linear_preprocessing_rec.h
old mode 100755
new mode 100644
diff --git a/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h b/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h
index 762db5f4164cfcef71b046bf60b921a81466a5ea..dc841075b4e72459e2068ac062d18397ec88cd6f 100644
--- a/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h
+++ b/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h
@@ -1361,6 +1361,10 @@ void init_ul_hopping(LTE_DL_FRAME_PARMS *frame_parms);
   @param nB nB from 36.304 (0=4T,1=2T,2=T,3=T/2,4=T/4,5=T/8,6=T/16,7=T/32*/
 int init_ue_paging_info(PHY_VARS_UE *ue, long defaultPagingCycle, long nB);
 
+#ifdef Rel14
+void init_mpdcch(PHY_VARS_eNB *eNB);
+#endif
+
 int32_t compareints (const void * a, const void * b);
 
 
@@ -1606,7 +1610,6 @@ void generate_pucch3x(int32_t **txdataF,
                     uint8_t subframe,
                     uint16_t rnti);
 
-
 void init_ulsch_power_LUT(void);
 
 /*!
diff --git a/openair1/PHY/defs_common.h b/openair1/PHY/defs_common.h
index 9f4a196a9b21648590b62cec8899e0f46fe9cf88..64ca5afbb63f0c3ef62fe87f4368281c837c5b64 100644
--- a/openair1/PHY/defs_common.h
+++ b/openair1/PHY/defs_common.h
@@ -808,6 +808,8 @@ typedef struct {
   uint8_t harq_pid;
   /// Narrowband index
   uint8_t narrowband;
+  /// number of mdpcch repetitions
+  uint16_t reps;
   /// number of PRB pairs for MPDCCH
   uint8_t number_of_prb_pairs;
   /// mpdcch resource assignment (combinatorial index r)
@@ -822,8 +824,6 @@ typedef struct {
   uint16_t dmrs_scrambling_init;
   /// Absolute subframe of the initial transmission (0-10239)
   uint16_t i0;
-  /// number of mdpcch repetitions
-  uint16_t reps;
   /// current absolute subframe number
   uint16_t absSF;
   /// DCI pdu
diff --git a/openair1/PHY/impl_defs_lte.h b/openair1/PHY/impl_defs_lte.h
index d649dce100482c0fc70012c6b4cc64f51e8e8487..df242aab8425bff5103e7772dcf8eceb5799129d 100644
--- a/openair1/PHY/impl_defs_lte.h
+++ b/openair1/PHY/impl_defs_lte.h
@@ -68,4 +68,5 @@ typedef struct {
   int32_t **tdd_calib_coeffs;
 } RU_COMMON;
 
+
 #endif
diff --git a/openair1/SCHED/fapi_l1.c b/openair1/SCHED/fapi_l1.c
index 26160696284a3b8b5bccb34cb6a9aa98ce09f468..a057b243b9898f8d579ee2c49f2d72b9c163c576 100644
--- a/openair1/SCHED/fapi_l1.c
+++ b/openair1/SCHED/fapi_l1.c
@@ -55,6 +55,8 @@ void handle_nfapi_dci_dl_pdu(PHY_VARS_eNB *eNB,
   LTE_eNB_PDCCH *pdcch_vars       = &eNB->pdcch_vars[idx];
   nfapi_dl_config_dci_dl_pdu *pdu = &dl_config_pdu->dci_dl_pdu;
 
+  if (nfapi_mode==2) return;
+
   LOG_D(PHY,"Frame %d, Subframe %d: DCI processing - populating pdcch_vars->dci_alloc[%d] proc:subframe_tx:%d idx:%d pdcch_vars->num_dci:%d\n",frame,subframe, pdcch_vars->num_dci, proc->subframe_tx, idx, pdcch_vars->num_dci);
 
   // copy dci configuration into eNB structure
@@ -73,6 +75,8 @@ void handle_nfapi_mpdcch_pdu(PHY_VARS_eNB *eNB,
   LTE_eNB_MPDCCH *mpdcch_vars     = &eNB->mpdcch_vars[idx];
   nfapi_dl_config_mpdcch_pdu *pdu = &dl_config_pdu->mpdcch_pdu;
 
+  if (nfapi_mode==2) return;
+
   LOG_D(PHY,"Frame %d, Subframe %d: MDCI processing\n",proc->frame_tx,proc->subframe_tx);
 
   // copy dci configuration into eNB structure
@@ -87,17 +91,35 @@ void handle_nfapi_hi_dci0_dci_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rx
   int idx                         = subframe&1;
   LTE_eNB_PDCCH *pdcch_vars       = &eNB->pdcch_vars[idx];
 
+  if (nfapi_mode==2) return;
+
   //LOG_D(PHY,"%s() SFN/SF:%04d%d Before num_dci:%d\n", __FUNCTION__,frame,subframe,pdcch_vars->num_dci);
 
   // copy dci configuration in to eNB structure
   fill_dci0(eNB,frame,subframe,proc,&pdcch_vars->dci_alloc[pdcch_vars->num_dci], &hi_dci0_config_pdu->dci_pdu);
 }
 
+
+
+void handle_nfapi_hi_dci0_mpdcch_dci_pdu(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
+					 nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu)
+{
+  int idx                         = proc->subframe_tx&1;
+  LTE_eNB_MPDCCH *pdcch_vars      = &eNB->mpdcch_vars[idx];
+  if (nfapi_mode==2) return;
+
+  // copy dci configuration in to eNB structure
+  fill_mpdcch_dci0(eNB,proc,&pdcch_vars->mdci_alloc[pdcch_vars->num_dci], &hi_dci0_config_pdu->mpdcch_dci_pdu);
+}
+
+
 void handle_nfapi_hi_dci0_hi_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t *proc,
                                  nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu)
 {
   LTE_eNB_PHICH *phich = &eNB->phich_vars[subframe&1];
 
+  if (nfapi_mode==2) return;
+
   // copy dci configuration in to eNB structure
   LOG_D(PHY,"Received HI PDU with value %d (rbstart %d,cshift %d)\n",
         hi_dci0_config_pdu->hi_pdu.hi_pdu_rel8.hi_value,
@@ -118,6 +140,8 @@ void handle_nfapi_bch_pdu(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
 {
   nfapi_dl_config_bch_pdu_rel8_t *rel8 = &dl_config_pdu->bch_pdu.bch_pdu_rel8;
 
+  if (nfapi_mode==2) return;
+
   AssertFatal(rel8->length == 3, "BCH PDU has length %d != 3\n",rel8->length);
 
   //LOG_D(PHY,"bch_pdu: %x,%x,%x\n",sdu[0],sdu[1],sdu[2]);
@@ -156,6 +180,8 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_pro
   int UE_id;
   int harq_pid;
 
+  if (nfapi_mode==2) return;
+
   UE_id = find_dlsch(rel8->rnti,eNB,SEARCH_EXIST_OR_FREE);
   if( (UE_id<0) || (UE_id>=NUMBER_OF_UE_MAX) ){
     LOG_E(PHY,"illegal UE_id found!!! rnti %04x UE_id %d\n",rel8->rnti,UE_id);
@@ -168,24 +194,24 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_pro
   dlsch1 = eNB->dlsch[UE_id][1];
 
 #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0))
-  if ((rel13->pdsch_payload_type < 2) && (rel13->ue_type>0)) dlsch0->harq_ids[frame%2][subframe] = 0;
+  if ((rel13->pdsch_payload_type < 2) && (rel13->ue_type>0)) dlsch0->harq_ids[proc->frame_tx%2][proc->subframe_tx] = 0;
 #endif
 
-  harq_pid        = dlsch0->harq_ids[frame%2][subframe];
+  harq_pid        = dlsch0->harq_ids[proc->frame_tx%2][proc->subframe_tx];
   AssertFatal((harq_pid>=0) && (harq_pid<8),"harq_pid %d not in 0...7 frame:%d subframe:%d subframe(TX):%d rnti:%x UE_id:%d dlsch0[harq_ids:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d]\n",
       harq_pid,
       frame,subframe,
       proc->subframe_tx,rel8->rnti,UE_id,
-      dlsch0->harq_ids[frame%2][0],
-      dlsch0->harq_ids[frame%2][1],
-      dlsch0->harq_ids[frame%2][2],
-      dlsch0->harq_ids[frame%2][3],
-      dlsch0->harq_ids[frame%2][4],
-      dlsch0->harq_ids[frame%2][5],
-      dlsch0->harq_ids[frame%2][6],
-      dlsch0->harq_ids[frame%2][7],
-      dlsch0->harq_ids[frame%2][8],
-      dlsch0->harq_ids[frame%2][9]
+      dlsch0->harq_ids[proc->frame_tx%2][0],
+      dlsch0->harq_ids[proc->frame_tx%2][1],
+      dlsch0->harq_ids[proc->frame_tx%2][2],
+      dlsch0->harq_ids[proc->frame_tx%2][3],
+      dlsch0->harq_ids[proc->frame_tx%2][4],
+      dlsch0->harq_ids[proc->frame_tx%2][5],
+      dlsch0->harq_ids[proc->frame_tx%2][6],
+      dlsch0->harq_ids[proc->frame_tx%2][7],
+      dlsch0->harq_ids[proc->frame_tx%2][8],
+      dlsch0->harq_ids[proc->frame_tx%2][9]
       );
   dlsch0_harq     = dlsch0->harq_processes[harq_pid];
   dlsch1_harq     = dlsch1->harq_processes[harq_pid];
@@ -194,7 +220,7 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_pro
   // compute DL power control parameters
   eNB->pdsch_config_dedicated[UE_id].p_a = rel8->pa;
 
-#ifdef PHY_TX_THREAD
+#ifdef PHY_TX_THREAD 
   if (dlsch0->active[proc->subframe_tx]){
 # else
   if (dlsch0->active){
@@ -211,7 +237,7 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_pro
     computeRhoB_eNB(rel8->pa,eNB->frame_parms.pdsch_config_common.p_b,eNB->frame_parms.nb_antenna_ports_eNB,dlsch1,dlsch1_harq->dl_power_off);
   }
 
-  dlsch0_harq->pdsch_start = eNB->pdcch_vars[subframe & 1].num_pdcch_symbols;
+  dlsch0_harq->pdsch_start = eNB->pdcch_vars[proc->subframe_tx & 1].num_pdcch_symbols;
 
   if (dlsch0_harq->round==0) {  //get pointer to SDU if this a new SDU
     if(sdu == NULL) {
@@ -244,18 +270,36 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_pro
 #endif
 
   if ((rel13->pdsch_payload_type <2) && (rel13->ue_type>0)) { // this is a BR/CE UE and SIB1-BR/SI-BR
+    UE_id = find_dlsch(rel8->rnti,eNB,SEARCH_EXIST_OR_FREE);
+    AssertFatal(UE_id!=-1,"no free or exiting dlsch_context\n");
+    AssertFatal(UE_id<NUMBER_OF_UE_MAX,"returned UE_id %d >= %d(NUMBER_OF_UE_MAX)\n",UE_id,NUMBER_OF_UE_MAX);
+ 
+    dlsch0 = eNB->dlsch[UE_id][0];
+    dlsch0->harq_mask = 1; 
+    dlsch0_harq     = dlsch0->harq_processes[0];
+    dlsch0_harq->pdu                    = sdu;
+
+    if (proc->frame_tx < 200) LOG_D(PHY,"NFAPI: frame %d, subframe %d (TX %d.%d): Programming SI-BR (%d) => %d\n",frame,subframe,proc->frame_tx,proc->subframe_tx,rel13->pdsch_payload_type,UE_id);
+ 
     dlsch0->rnti             = 0xFFFF;
     dlsch0->Kmimo            = 1;
     dlsch0->Mdlharq          = 4;
     dlsch0->Nsoft            = 25344;
 
+    dlsch0->i0               = rel13->initial_transmission_sf_io;
+    dlsch0_harq->pdsch_start = rel10->pdsch_start;
+    dlsch0->harq_ids[proc->frame_tx%2][proc->subframe_rx] = 0;
+    dlsch0_harq->frame       = proc->frame_tx;
+    dlsch0_harq->subframe    = proc->subframe_tx;
+
+
 #ifdef PHY_TX_THREAD
     if (rel13->pdsch_payload_type == 0) dlsch0_harq->sib1_br_flag=1;
 #else
     if (rel13->pdsch_payload_type == 0) dlsch0->sib1_br_flag=1;
 #endif
 
-    // configure PDSCH
+     // configure PDSCH
     switch (eNB->frame_parms.N_RB_DL) {
     case 6:
       dlsch0_harq->rb_alloc[0]      = localRIV2alloc_LUT6[rel8->resource_block_coding];
@@ -299,12 +343,19 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_pro
     dlsch0_harq->codeword           = 0;
     dlsch0_harq->pdsch_start        = rel10->pdsch_start;
   }
-#ifdef PHY_TX_THREAD
-  dlsch0_harq->i0          = rel13->initial_transmission_sf_io;
-#else
-  dlsch0->i0               = rel13->initial_transmission_sf_io;
+  else
 #endif
+  { 
+    UE_id = find_dlsch(rel8->rnti,eNB,SEARCH_EXIST_OR_FREE);
+    AssertFatal(UE_id!=-1,"no free or exiting dlsch_context\n");
+    AssertFatal(UE_id<NUMBER_OF_UE_MAX,"returned UE_id %d >= %d(NUMBER_OF_UE_MAX)\n",UE_id,NUMBER_OF_UE_MAX);
 
+    dlsch0 = eNB->dlsch[UE_id][0];
+    dlsch1 = eNB->dlsch[UE_id][1];
+
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+    dlsch0->sib1_br_flag=0;
+    dlsch0->i0               = 0xFFFF;
 #endif
 
 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
@@ -323,9 +374,52 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_pro
       rel8->length
       );
 #endif
+
+    dlsch0->active = 1;
+    harq_pid        = dlsch0->harq_ids[frame%2][proc->subframe_tx];
+    dlsch0->harq_mask |= (1<<harq_pid);
+
+    AssertFatal((harq_pid>=0) && (harq_pid<8),"subframe %d: harq_pid %d not in 0...7\n",proc->subframe_tx,harq_pid);
+    dlsch0_harq     = dlsch0->harq_processes[harq_pid];
+    dlsch1_harq     = dlsch1->harq_processes[harq_pid];
+    AssertFatal(dlsch0_harq!=NULL,"dlsch_harq is null\n");
+
+  // compute DL power control parameters
+
+
+    if (dlsch0->active){
+      computeRhoA_eNB(rel8->pa,dlsch0,dlsch0_harq->dl_power_off, eNB->frame_parms.nb_antenna_ports_eNB);
+      computeRhoB_eNB(rel8->pa,eNB->frame_parms.pdsch_config_common.p_b,eNB->frame_parms.nb_antenna_ports_eNB,dlsch0,dlsch0_harq->dl_power_off);
+    }  
+    if (dlsch1->active){
+      computeRhoA_eNB(rel8->pa, dlsch1,dlsch1_harq->dl_power_off, eNB->frame_parms.nb_antenna_ports_eNB);
+      computeRhoB_eNB(rel8->pa,eNB->frame_parms.pdsch_config_common.p_b,eNB->frame_parms.nb_antenna_ports_eNB,dlsch1,dlsch1_harq->dl_power_off);
+    }
+
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+    dlsch0_harq->pdsch_start = eNB->pdcch_vars[proc->subframe_tx & 1].num_pdcch_symbols;
+#else
+    dlsch0_harq->pdsch_start = rel10->pdsch_start;
+#endif
+    if (dlsch0_harq->round==0) {  //get pointer to SDU if this a new SDU
+      AssertFatal(sdu!=NULL,"NFAPI: frame %d, subframe %d: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d : sdu is null for pdu_index %d\n",
+                  proc->frame_tx,proc->subframe_tx,rel8->rnti,UE_id,harq_pid,
+                  dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index);
+      if (rel8->rnti != 0xFFFF) LOG_D(PHY,"NFAPI: frame %d, subframe %d: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d\n",
+                                    proc->frame_tx,proc->subframe_tx,rel8->rnti,UE_id,harq_pid);
+      if (codeword_index == 0) dlsch0_harq->pdu                    = sdu;
+      else                     dlsch1_harq->pdu                    = sdu;
+    }
+    else {
+      if (rel8->rnti != 0xFFFF) LOG_D(PHY,"NFAPI: frame %d, subframe %d: programming dlsch for round %d, rnti %x, UE_id %d, harq_pid %d\n",
+                                      proc->frame_tx,proc->subframe_tx,dlsch0_harq->round,
+                                    rel8->rnti,UE_id,harq_pid);
+    }
+
+  }
 }
 
-uint16_t to_beta_offset_harqack[16]={16,20,25,32,40,50,64,80,101,127,160,248,400,640,1008,8};
+int16_t to_beta_offset_harqack[16]={16,20,25,32,40,50,64,80,101,127,160,248,400,640,1008,8};
 
 void handle_ulsch_harq_pdu(
         PHY_VARS_eNB                           *eNB,
@@ -340,6 +434,8 @@ void handle_ulsch_harq_pdu(
   LTE_eNB_ULSCH_t *ulsch=eNB->ulsch[UE_id];
   LTE_UL_eNB_HARQ_t *ulsch_harq;
 
+  if (nfapi_mode==2) return;
+
   int harq_pid = rel8->harq_process_number;
   ulsch_harq = ulsch->harq_processes[harq_pid];
   ulsch_harq->frame                      = frame;
@@ -363,6 +459,8 @@ void handle_ulsch_cqi_ri_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request
   int harq_pid = ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.harq_process_number;
   LTE_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_processes[harq_pid];
 
+  if (nfapi_mode==2) return;
+
   ulsch_harq->frame                       = frame;
   ulsch_harq->subframe                    = subframe;
   ulsch_harq->O_RI                        = rel9->aperiodic_cqi_pmi_ri_report.cc[0].ri_size;
@@ -384,6 +482,8 @@ void handle_ulsch_cqi_harq_ri_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_re
   LTE_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_processes[harq_pid];
   nfapi_ul_config_ulsch_harq_information *harq_information = &ul_config_pdu->ulsch_cqi_harq_ri_pdu.harq_information;
 
+  if (nfapi_mode==2) return;
+
   ulsch_harq->frame                       = frame;
   ulsch_harq->subframe                    = subframe;
   ulsch_harq->O_RI                        = rel9->aperiodic_cqi_pmi_ri_report.cc[0].ri_size;
@@ -399,6 +499,9 @@ void handle_ulsch_cqi_harq_ri_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_re
 
 void handle_uci_harq_information(PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci,nfapi_ul_config_harq_information *harq_information)
 {
+
+  if (nfapi_mode==2) return;
+
   if (eNB->frame_parms.frame_type == FDD) {
     uci->num_pucch_resources = harq_information->harq_information_rel9_fdd.number_of_pucch_resources;
 
@@ -452,7 +555,7 @@ void handle_uci_harq_information(PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci,nfapi_ul_co
       uci->n_pucch_3[0] = harq_information->harq_information_rel9_fdd.n_pucch_1_0;
       uci->n_pucch_3[1] = harq_information->harq_information_rel11.n_pucch_2_0;
     }
-    else AssertFatal(1==0,"unsupported HARQ mode %d\n",harq_information->harq_information_rel9_fdd.ack_nack_mode);
+    else AssertFatal(1==0,"unsupported FDD HARQ mode %d size %d\n",harq_information->harq_information_rel9_fdd.ack_nack_mode,harq_information->harq_information_rel9_fdd.harq_size);
   }
   else { // TDD
     uci->num_pucch_resources = harq_information->harq_information_rel10_tdd.number_of_pucch_resources;
@@ -497,6 +600,8 @@ void handle_uci_sr_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request_pdu_t
 {
   LTE_eNB_UCI *uci = &eNB->uci_vars[UE_id];
 
+  if (nfapi_mode==2) return;
+
   uci->frame               = frame;
   uci->subframe            = subframe;
   uci->rnti                = ul_config_pdu->uci_sr_pdu.ue_information.ue_information_rel8.rnti;
@@ -507,7 +612,11 @@ void handle_uci_sr_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request_pdu_t
   uci->n_pucch_1_0_sr[0]   = ul_config_pdu->uci_sr_pdu.sr_information.sr_information_rel8.pucch_index;
   uci->srs_active          = srs_active;
   uci->active              = 1;
-
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+  uci->ue_type                     = ul_config_pdu->uci_sr_pdu.ue_information.ue_information_rel13.ue_type;
+  uci->empty_symbols               = ul_config_pdu->uci_sr_pdu.ue_information.ue_information_rel13.empty_symbols;
+  uci->total_repetitions = ul_config_pdu->uci_sr_pdu.ue_information.ue_information_rel13.total_number_of_repetitions;
+#endif
   LOG_D(PHY,"Programming UCI SR rnti %x, pucch1_0 %d for (%d,%d)\n",
         uci->rnti,uci->n_pucch_1_0_sr[0],frame,subframe);
 }
@@ -516,6 +625,8 @@ void handle_uci_sr_harq_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request_
 {
   LTE_eNB_UCI *uci = &eNB->uci_vars[UE_id];
 
+  if (nfapi_mode==2) return;
+
   uci->frame               = frame;
   uci->subframe            = subframe;
   uci->rnti                = ul_config_pdu->uci_sr_harq_pdu.ue_information.ue_information_rel8.rnti;
@@ -525,7 +636,11 @@ void handle_uci_sr_harq_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request_
   uci->n_pucch_1_0_sr[0]   = ul_config_pdu->uci_sr_harq_pdu.sr_information.sr_information_rel8.pucch_index;
   uci->srs_active          = srs_active;
   uci->active              = 1;
-
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+  uci->ue_type                     = ul_config_pdu->uci_sr_harq_pdu.ue_information.ue_information_rel13.ue_type;
+  uci->empty_symbols               = ul_config_pdu->uci_sr_harq_pdu.ue_information.ue_information_rel13.empty_symbols;
+  uci->total_repetitions = ul_config_pdu->uci_sr_harq_pdu.ue_information.ue_information_rel13.total_number_of_repetitions;
+#endif
   handle_uci_harq_information(eNB,uci,&ul_config_pdu->uci_sr_harq_pdu.harq_information);
 }
 
@@ -533,6 +648,8 @@ void handle_uci_harq_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request_pdu
 {
   LTE_eNB_UCI *uci = &eNB->uci_vars[UE_id];
 
+  if (nfapi_mode==2) return;
+
   LOG_D(PHY,"Frame %d, Subframe %d: Programming UCI_HARQ process (type %d)\n",frame,subframe,HARQ);
   uci->frame             = frame;
   uci->subframe          = subframe;
@@ -540,7 +657,11 @@ void handle_uci_harq_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request_pdu
   uci->type              = HARQ;
   uci->srs_active        = srs_active;
   uci->num_antenna_ports = ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel11.num_ant_ports;
-
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+  uci->ue_type                     = ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.ue_type;
+  uci->empty_symbols               = ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.empty_symbols;
+  uci->total_repetitions           = ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.total_number_of_repetitions;
+#endif
   handle_uci_harq_information(eNB,uci,&ul_config_pdu->uci_harq_pdu.harq_information);
 
   uci->active=1;
@@ -550,6 +671,8 @@ void handle_srs_pdu(PHY_VARS_eNB *eNB,nfapi_ul_config_request_pdu_t *ul_config_p
 {
   int i;
 
+  if (nfapi_mode==2) return;
+
   for (i=0;i<NUMBER_OF_UE_MAX;i++) {
 
     if (eNB->soundingrs_ul_config_dedicated[i].active==1) continue;
@@ -576,6 +699,8 @@ void handle_nfapi_ul_pdu(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
   nfapi_ul_config_ulsch_pdu_rel8_t *rel8 = &ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8;
   int16_t UE_id;
 
+  if (nfapi_mode==2) return;
+
   // check if we have received a dci for this ue and ulsch descriptor is configured
 
   if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE) {
@@ -616,6 +741,9 @@ void handle_nfapi_ul_pdu(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
     AssertFatal((UE_id = find_uci(ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.rnti,
                                   proc->frame_tx,proc->subframe_tx,eNB,SEARCH_EXIST_OR_FREE))>=0,
                 "No available UE UCI for rnti %x\n",ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.rnti);
+    LOG_D(PHY,"Applying UL UCI_HARQ config for UE %d, rnti %x for frame %d, subframe %d\n",
+          UE_id,ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.rnti,frame,subframe);
+
     handle_uci_harq_pdu(eNB,UE_id,ul_config_pdu,frame,subframe,srs_present);
   }
   else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE) {
@@ -697,6 +825,9 @@ void schedule_response(Sched_Rsp_t *Sched_INFO)
   eNB->pdcch_vars[subframe&1].num_pdcch_symbols = number_pdcch_ofdm_symbols;
   eNB->pdcch_vars[subframe&1].num_dci           = 0;
   eNB->phich_vars[subframe&1].num_hi            = 0;
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+  eNB->mpdcch_vars[subframe&1].num_dci           = 0;
+#endif
 
   LOG_D(PHY,"NFAPI: Sched_INFO:SFN/SF:%04d%d DL_req:SFN/SF:%04d%d:dl_pdu:%d tx_req:SFN/SF:%04d%d:pdus:%d\n",
        frame,subframe,
@@ -722,6 +853,7 @@ void schedule_response(Sched_Rsp_t *Sched_INFO)
   
     harq_pid = subframe2harq_pid(fp,ul_frame,ul_subframe);
 
+
     // clear DCI allocation maps for new subframe
 
     for (i=0; i<NUMBER_OF_UE_MAX; i++) {
@@ -852,16 +984,20 @@ void schedule_response(Sched_Rsp_t *Sched_INFO)
 
     switch (hi_dci0_req_pdu->pdu_type) {
 
-      case NFAPI_HI_DCI0_DCI_PDU_TYPE:
-
-        handle_nfapi_hi_dci0_dci_pdu(eNB,NFAPI_SFNSF2SFN(HI_DCI0_req->sfn_sf),NFAPI_SFNSF2SF(HI_DCI0_req->sfn_sf),proc,hi_dci0_req_pdu);
-
-        eNB->pdcch_vars[NFAPI_SFNSF2SF(HI_DCI0_req->sfn_sf)&1].num_dci++;
-        break;
+    case NFAPI_HI_DCI0_DCI_PDU_TYPE:
+      
+      handle_nfapi_hi_dci0_dci_pdu(eNB,NFAPI_SFNSF2SFN(HI_DCI0_req->sfn_sf),NFAPI_SFNSF2SF(HI_DCI0_req->sfn_sf),proc,hi_dci0_req_pdu);
+      eNB->pdcch_vars[NFAPI_SFNSF2SF(HI_DCI0_req->sfn_sf)&1].num_dci++;
+      break;
+      
+    case NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE:
+      handle_nfapi_hi_dci0_mpdcch_dci_pdu(eNB,proc,hi_dci0_req_pdu);
+      eNB->mpdcch_vars[subframe&1].num_dci++;
+      break;
 
-      case NFAPI_HI_DCI0_HI_PDU_TYPE:
-        handle_nfapi_hi_dci0_hi_pdu(eNB,NFAPI_SFNSF2SFN(HI_DCI0_req->sfn_sf),NFAPI_SFNSF2SF(HI_DCI0_req->sfn_sf),proc,hi_dci0_req_pdu);
-        break;
+    case NFAPI_HI_DCI0_HI_PDU_TYPE:
+      handle_nfapi_hi_dci0_hi_pdu(eNB,NFAPI_SFNSF2SFN(HI_DCI0_req->sfn_sf),NFAPI_SFNSF2SF(HI_DCI0_req->sfn_sf),proc,hi_dci0_req_pdu);
+      break;
     }
   }
 
diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c
index 0997f9c552e5a93199cae2da298d46505b19c7db..7750f614a576235a854919b64632fcdbcc4552b0 100644
--- a/openair1/SCHED/phy_procedures_lte_eNb.c
+++ b/openair1/SCHED/phy_procedures_lte_eNb.c
@@ -46,7 +46,7 @@
 #include <time.h>
 
 #if defined(ENABLE_ITTI)
-#   include "intertask_interface.h"
+#include "intertask_interface.h"
 #endif
 
 extern uint8_t nfapi_mode;
@@ -63,7 +63,7 @@ int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *eNB,uint16_t UE_id,uint8_t
   DevAssert( harq_pid < 8 );
 
   Nre = eNB->ulsch[UE_id]->harq_processes[harq_pid]->Nsymb_initial *
-        eNB->ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12;
+    eNB->ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12;
 
   sumKr = 0;
 
@@ -87,7 +87,7 @@ int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *eNB,uint16_t UE_id,uint8_t
   //(eNB->ulsch[UE_id]->harq_processes[harq_pid]->control_only == 1) ? eNB->ulsch[UE_id]->beta_offset_cqi_times8:8;
 
   DevAssert( UE_id < NUMBER_OF_UE_MAX );
-//#warning "This condition happens sometimes. Need more investigation" // navid
+  //#warning "This condition happens sometimes. Need more investigation" // navid
   //DevAssert( MPR_x100/6 < 100 );
 
   if (1==1) { //eNB->ul_power_control_dedicated[UE_id].deltaMCS_Enabled == 1) {
@@ -141,25 +141,22 @@ void pmch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) {
   //  uint8_t sync_area=255;
 #endif
 
-  int subframe = proc->subframe_tx;
+  int             subframe = proc->subframe_tx;
 
-  AssertFatal(1==0,"pmch not tested for the moment, exiting\n");
+  AssertFatal (1 == 0, "pmch not tested for the moment, exiting\n");
 
   // This is DL-Cell spec pilots in Control region
-  generate_pilots_slot(eNB,
-		       eNB->common_vars.txdataF,
-		       AMP,
-		       subframe<<1,1);
+  generate_pilots_slot (eNB, eNB->common_vars.txdataF, AMP, subframe << 1, 1);
+
 
-  
 #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
   // if mcch is active, send regardless of the node type: eNB or RN
   // when mcch is active, MAC sched does not allow MCCH and MTCH multiplexing
   /*
-  mch_pduP = mac_xface->get_mch_sdu(eNB->Mod_id,
-				    eNB->CC_id,
-				    proc->frame_tx,
-				    subframe);
+    mch_pduP = mac_xface->get_mch_sdu(eNB->Mod_id,
+    eNB->CC_id,
+    proc->frame_tx,
+    subframe);
   */
   if ((mch_pduP->Pdu_size > 0) && (mch_pduP->sync_area == 0)) // TEST: only transmit mcch for sync area 0
     LOG_D(PHY,"[eNB%"PRIu8"] Frame %d subframe %d : Got MCH pdu for MBSFN (MCS %"PRIu8", TBS %d) \n",
@@ -173,13 +170,13 @@ void pmch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) {
   }
     
   if (mch_pduP) {
-    fill_eNB_dlsch_MCH(eNB,mch_pduP->mcs,1,0);
+    fill_eNB_dlsch_MCH (eNB, mch_pduP->mcs, 1, 0);
     // Generate PMCH
-    generate_mch(eNB,proc,(uint8_t*)mch_pduP->payload);
+    generate_mch (eNB, proc, (uint8_t *) mch_pduP->payload);
   } else {
-    LOG_D(PHY,"[eNB/RN] Frame %d subframe %d: MCH not generated \n",proc->frame_tx,subframe);
+    LOG_D (PHY, "[eNB/RN] Frame %d subframe %d: MCH not generated \n", proc->frame_tx, subframe);
   }
-  
+
 #endif
 }
 
@@ -194,58 +191,39 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,int frame, int subframe) {
   // generate Cell-Specific Reference Signals for both slots
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_RS_TX,1);
 
-   if(subframe_select(fp,subframe) == SF_S)
-       generate_pilots_slot(eNB,
-                    txdataF,
-                    AMP,
-                    subframe<<1,1);
-   else
-  generate_pilots_slot(eNB,
-		       txdataF,
-		       AMP,
-		       subframe<<1,0);
-
- // check that 2nd slot is for DL
-
-  // check that 2nd slot is for DL
-  if (subframe_select(fp,subframe) == SF_DL)
+  if(subframe_select(fp,subframe) == SF_S)
     generate_pilots_slot(eNB,
 			 txdataF,
 			 AMP,
-			 (subframe<<1)+1,0);
-  
-  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_RS_TX,0);
-      
+			 subframe<<1,1);
+  else
+    generate_pilots_slot(eNB,
+			 txdataF,
+			 AMP,
+			 subframe<<1,0);
+
+  // check that 2nd slot is for DL
+  if (subframe_select (fp, subframe) == SF_DL)
+    generate_pilots_slot (eNB, txdataF, AMP, (subframe << 1) + 1, 0);
+
+  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME (VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_RS_TX, 0);
+
 
   // First half of PSS/SSS (FDD, slot 0)
   if (subframe == 0) {
     if (fp->frame_type == FDD) {
-      generate_pss(txdataF,
-		   AMP,
-		   fp,
-		   (fp->Ncp==NORMAL) ? 6 : 5,
-		   0);
-      generate_sss(txdataF,
-		   AMP,
-		   fp,
-		   (fp->Ncp==NORMAL) ? 5 : 4,
-		   0);
-      
+      generate_pss (txdataF, AMP, fp, (fp->Ncp == NORMAL) ? 6 : 5, 0);
+      generate_sss (txdataF, AMP, fp, (fp->Ncp == NORMAL) ? 5 : 4, 0);
+
     }
-    
 
 
-      
+
     /// First half of SSS (TDD, slot 1)
-    
+
     if (fp->frame_type == TDD) {
-      generate_sss(txdataF,
-		   AMP,
-		   fp,
-		   (fp->Ncp==NORMAL) ? 6 : 5,
-		   1);
+      generate_sss (txdataF, AMP, fp, (fp->Ncp == NORMAL) ? 6 : 5, 1);
     }
-
     // generate PBCH (Physical Broadcast CHannel) info
 
     /// generate PBCH
@@ -256,57 +234,25 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,int frame, int subframe) {
     }
     T(T_ENB_PHY_MIB, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe),
       T_BUFFER(pbch_pdu, 3));
-    generate_pbch(&eNB->pbch,
-		  txdataF,
-		  AMP,
-		  fp,
-		  pbch_pdu,
-		  frame&3);
-  
-  }
-  else if ((subframe == 1) &&
-	   (fp->frame_type == TDD)){
-    generate_pss(txdataF,
-		 AMP,
-		 fp,
-		 2,
-		 2);
+
+    generate_pbch (&eNB->pbch, txdataF, AMP, fp, pbch_pdu, frame & 3);
+
+  } else if ((subframe == 1) && (fp->frame_type == TDD)) {
+    generate_pss (txdataF, AMP, fp, 2, 2);
   }
-  
   // Second half of PSS/SSS (FDD, slot 10)
-  else if ((subframe == 5) && 
-	   (fp->frame_type == FDD)) {
-    generate_pss(txdataF,
-		 AMP,
-		 &eNB->frame_parms,
-		 (fp->Ncp==NORMAL) ? 6 : 5,
-		 10);
-    generate_sss(txdataF,
-		 AMP,
-		 &eNB->frame_parms,
-		 (fp->Ncp==NORMAL) ? 5 : 4,
-		 10);
+  else if ((subframe == 5) && (fp->frame_type == FDD)) {
+    generate_pss (txdataF, AMP, &eNB->frame_parms, (fp->Ncp == NORMAL) ? 6 : 5, 10);
+    generate_sss (txdataF, AMP, &eNB->frame_parms, (fp->Ncp == NORMAL) ? 5 : 4, 10);
 
   }
-
   //  Second-half of SSS (TDD, slot 11)
-  else if ((subframe == 5) &&
-	   (fp->frame_type == TDD)) {
-    generate_sss(txdataF,
-		 AMP,
-		 fp,
-		 (fp->Ncp==NORMAL) ? 6 : 5,
-		 11);
+  else if ((subframe == 5) && (fp->frame_type == TDD)) {
+    generate_sss (txdataF, AMP, fp, (fp->Ncp == NORMAL) ? 6 : 5, 11);
   }
-
   // Second half of PSS (TDD, slot 12)
-  else if ((subframe == 6) &&
-	   (fp->frame_type == TDD)) { 
-    generate_pss(txdataF,
-		 AMP,
-		 fp,
-		 2,
-		 12);
+  else if ((subframe == 6) && (fp->frame_type == TDD)) {
+    generate_pss (txdataF, AMP, fp, 2, 12);
   }
 
 }
@@ -382,74 +328,75 @@ void pdsch_procedures(PHY_VARS_eNB *eNB,
     ue_stats->dlsch_trials[harq_pid][dlsch_harq->round]++;
 #ifdef DEBUG_PHY_PROC
 #ifdef DEBUG_DLSCH
-    LOG_D(PHY,"[eNB] This DLSCH is a retransmission\n");
+    LOG_D (PHY, "[eNB] This DLSCH is a retransmission\n");
 #endif
 #endif
   }
 
 
   LOG_D(PHY,"Generating DLSCH/PDSCH pdu:%p pdsch_start:%d frame:%d subframe:%d nb_rb:%d rb_alloc:%d Qm:%d Nl:%d round:%d\n",
-      dlsch_harq->pdu,dlsch_harq->pdsch_start,frame,subframe,dlsch_harq->nb_rb,dlsch_harq->rb_alloc[0],dlsch_harq->Qm,dlsch_harq->Nl,dlsch_harq->round);
+	dlsch_harq->pdu,dlsch_harq->pdsch_start,frame,subframe,dlsch_harq->nb_rb,dlsch_harq->rb_alloc[0],dlsch_harq->Qm,dlsch_harq->Nl,dlsch_harq->round);
   // 36-212 
   if (nfapi_mode == 0 || nfapi_mode == 1) { // monolthic OR PNF - do not need turbo encoding on VNF
 
     if (dlsch_harq->pdu==NULL){
-        LOG_E(PHY,"dlsch_harq->pdu == NULL SFN/SF:%04d%d dlsch[rnti:%x] dlsch_harq[pdu:%p pdsch_start:%d Qm:%d Nl:%d round:%d nb_rb:%d rb_alloc[0]:%d]\n", frame,subframe,dlsch->rnti, dlsch_harq->pdu,dlsch_harq->pdsch_start,dlsch_harq->Qm,dlsch_harq->Nl,dlsch_harq->round,dlsch_harq->nb_rb,dlsch_harq->rb_alloc[0]);
+      LOG_E(PHY,"dlsch_harq->pdu == NULL SFN/SF:%04d%d dlsch[rnti:%x] dlsch_harq[pdu:%p pdsch_start:%d Qm:%d Nl:%d round:%d nb_rb:%d rb_alloc[0]:%d]\n", frame,subframe,dlsch->rnti, dlsch_harq->pdu,dlsch_harq->pdsch_start,dlsch_harq->Qm,dlsch_harq->Nl,dlsch_harq->round,dlsch_harq->nb_rb,dlsch_harq->rb_alloc[0]);
       return;
     }
 
     start_meas(&eNB->dlsch_encoding_stats);
 
     dlsch_encoding_all(eNB,
-	  dlsch_harq->pdu,
-	  dlsch_harq->pdsch_start,
-	  dlsch,
-	  frame,
-	  subframe,
-	  &eNB->dlsch_rate_matching_stats,
-	  &eNB->dlsch_turbo_encoding_stats,
-	  &eNB->dlsch_turbo_encoding_waiting_stats,
-      &eNB->dlsch_turbo_encoding_main_stats,
-      &eNB->dlsch_turbo_encoding_wakeup_stats0,
-      &eNB->dlsch_turbo_encoding_wakeup_stats1,
-	  &eNB->dlsch_interleaving_stats);
+		       dlsch_harq->pdu,
+		       dlsch_harq->pdsch_start,
+		       dlsch,
+		       frame,
+		       subframe,
+		       &eNB->dlsch_rate_matching_stats,
+		       &eNB->dlsch_turbo_encoding_stats,
+		       &eNB->dlsch_turbo_encoding_waiting_stats,
+		       &eNB->dlsch_turbo_encoding_main_stats,
+		       &eNB->dlsch_turbo_encoding_wakeup_stats0,
+		       &eNB->dlsch_turbo_encoding_wakeup_stats1,
+		       &eNB->dlsch_interleaving_stats);
+
     stop_meas(&eNB->dlsch_encoding_stats);
-  if(eNB->dlsch_encoding_stats.p_time>500*3000 && opp_enabled == 1)
-  {
-    print_meas_now(&eNB->dlsch_encoding_stats,"total coding",stderr);
-  }
-  // 36-211
+    if(eNB->dlsch_encoding_stats.p_time>500*3000 && opp_enabled == 1)
+      {
+	print_meas_now(&eNB->dlsch_encoding_stats,"total coding",stderr);
+      }
+    // 36-211
     start_meas(&eNB->dlsch_scrambling_stats);
     dlsch_scrambling(fp,
-        0,
-        dlsch,
-        harq_pid,
-        get_G(fp,
-          dlsch_harq->nb_rb,
-          dlsch_harq->rb_alloc,
-          dlsch_harq->Qm,
-          dlsch_harq->Nl,
-          dlsch_harq->pdsch_start,
-          frame,subframe,
-          0),
-        0,
-        frame,
-        subframe<<1);
+		     0,
+		     dlsch,
+		     harq_pid,
+		     get_G(fp,
+			   dlsch_harq->nb_rb,
+			   dlsch_harq->rb_alloc,
+			   dlsch_harq->Qm,
+			   dlsch_harq->Nl,
+			   dlsch_harq->pdsch_start,
+			   frame,subframe,
+			   0),
+		     0,
+		     frame,
+		     subframe<<1);
     stop_meas(&eNB->dlsch_scrambling_stats);
 
     start_meas(&eNB->dlsch_modulation_stats);
 
   
     dlsch_modulation(eNB,
-		   eNB->common_vars.txdataF,
-		   AMP,
-		   frame,
-		   subframe,
-		   dlsch_harq->pdsch_start,
-		   dlsch,
-		   dlsch1);
-  
-  stop_meas(&eNB->dlsch_modulation_stats);
+		     eNB->common_vars.txdataF,
+		     AMP,
+		     frame,
+		     subframe,
+		     dlsch_harq->pdsch_start,
+		     dlsch,
+		     dlsch1);
+  
+    stop_meas(&eNB->dlsch_modulation_stats);
   }
 #ifdef PHY_TX_THREAD
   dlsch->active[subframe] = 0;
@@ -463,7 +410,6 @@ void pdsch_procedures(PHY_VARS_eNB *eNB,
 
 
 
-
 void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB,
 			   L1_rxtx_proc_t *proc,
 			   int do_meas)
@@ -475,6 +421,9 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB,
   int16_t UE_id=0;
   uint8_t num_pdcch_symbols=0;
   uint8_t num_dci=0;
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+  uint8_t         num_mdci = 0;
+#endif
   uint8_t ul_subframe;
   uint32_t ul_frame;
   LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
@@ -482,20 +431,19 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB,
 
 
 
-  if ((fp->frame_type == TDD) && (subframe_select(fp,subframe)==SF_UL)) return;
+  if ((fp->frame_type == TDD) && (subframe_select (fp, subframe) == SF_UL))
+    return;
 
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_TX+(eNB->CC_id),1);
   if (do_meas==1) start_meas(&eNB->phy_proc_tx);
   if (do_meas==1) start_meas(&eNB->dlsch_common_and_dci);
 
   // clear the transmit data array for the current subframe
-  for (aa=0; aa<fp->nb_antenna_ports_eNB; aa++) {      
-    memset(&eNB->common_vars.txdataF[aa][subframe*fp->ofdm_symbol_size*(fp->symbols_per_tti)],
-	   0,fp->ofdm_symbol_size*(fp->symbols_per_tti)*sizeof(int32_t));
+  for (aa = 0; aa < fp->nb_antenna_ports_eNB; aa++) {
+    memset (&eNB->common_vars.txdataF[aa][subframe * fp->ofdm_symbol_size * (fp->symbols_per_tti)], 0, fp->ofdm_symbol_size * (fp->symbols_per_tti) * sizeof (int32_t));
   }
   
-
-
+  
   if (nfapi_mode == 0 || nfapi_mode == 1) {
     if (is_pmch_subframe(frame,subframe,fp)) {
       pmch_procedures(eNB,proc);
@@ -505,27 +453,32 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB,
       common_signal_procedures(eNB,proc->frame_tx, proc->subframe_tx);
     }
   }
-
-
+  
+  
   // clear existing ulsch dci allocations before applying info from MAC  (this is table
-  ul_subframe = pdcch_alloc2ul_subframe(fp,subframe);
-  ul_frame = pdcch_alloc2ul_frame(fp,frame,subframe);
-
-
-
+  ul_subframe = pdcch_alloc2ul_subframe (fp, subframe);
+  ul_frame = pdcch_alloc2ul_frame (fp, frame, subframe);
+  
+  
+  
   // clear previous allocation information for all UEs
-  for (i=0; i<NUMBER_OF_UE_MAX; i++) {
+  for (i = 0; i < NUMBER_OF_UE_MAX; i++) {
     if (eNB->dlsch[i][0])
       eNB->dlsch[i][0]->subframe_tx[subframe] = 0;
   }
-
-  /* save old HARQ information needed for PHICH generation */
+  
+  
   /* TODO: check the following test - in the meantime it is put back as it was before */
   //if ((ul_subframe < 10)&&
   //    (subframe_select(fp,ul_subframe)==SF_UL)) { // This means that there is a potential UL subframe that will be scheduled here
   if (ul_subframe < 10) { // This means that there is a potential UL subframe that will be scheduled here
     for (i=0; i<NUMBER_OF_UE_MAX; i++) {
-      harq_pid = subframe2harq_pid(fp,ul_frame,ul_subframe);
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+      if (eNB->ulsch[i] && eNB->ulsch[i]->ue_type >0) harq_pid = 0;
+      else 
+#endif
+	harq_pid = subframe2harq_pid(fp,ul_frame,ul_subframe);
+      
       if (eNB->ulsch[i]) {
 	ulsch_harq = eNB->ulsch[i]->harq_processes[harq_pid];
 	
@@ -548,37 +501,45 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB,
 	 * TODO: check if that works with TDD.
 	 */
 	ulsch_harq->previous_first_rb = ulsch_harq->first_rb;
-	ulsch_harq->previous_n_DMRS   = ulsch_harq->n_DMRS;
+	ulsch_harq->previous_n_DMRS = ulsch_harq->n_DMRS;
 	
       }
     }
   }
-
-
-
+  
+  
   num_pdcch_symbols = eNB->pdcch_vars[subframe&1].num_pdcch_symbols;
   num_dci           = eNB->pdcch_vars[subframe&1].num_dci;
   LOG_D(PHY,"num_pdcch_symbols %"PRIu8",number dci %"PRIu8"\n",num_pdcch_symbols, num_dci);
   VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_DCI_INFO,num_pdcch_symbols);
-
-
-  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_DCI_INFO,(frame*10)+subframe);
-
+  
+  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME (VCD_SIGNAL_DUMPER_VARIABLES_DCI_INFO, (frame * 10) + subframe);
+  
   if (num_dci > 0)
     LOG_D(PHY,"[eNB %"PRIu8"] Frame %d, subframe %d: Calling generate_dci_top (pdcch) (num_dci %"PRIu8") num_pdcch_symbols:%d\n",eNB->Mod_id,frame, subframe, num_dci, num_pdcch_symbols);
-
-
+  
+  
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PDCCH_TX,1);
-
+  
   if (nfapi_mode == 0 || nfapi_mode == 1) {
     generate_dci_top(num_pdcch_symbols,
-        num_dci,
-        &eNB->pdcch_vars[subframe&1].dci_alloc[0],
-        0,
-        AMP,
-        fp,
-        eNB->common_vars.txdataF,
-        subframe);
+		     num_dci,
+		     &eNB->pdcch_vars[subframe&1].dci_alloc[0],
+		     0,
+		     AMP,
+		     fp,
+		     eNB->common_vars.txdataF,
+		     subframe);
+    
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+    num_mdci = eNB->mpdcch_vars[subframe &1].num_dci;
+    if (num_mdci > 0) {
+      LOG_I (PHY, "[eNB %" PRIu8 "] Frame %d, subframe %d: Calling generate_mdci_top (mpdcch) (num_dci %" PRIu8 ")\n", eNB->Mod_id, frame, subframe, num_mdci);
+      
+      generate_mdci_top (eNB, frame, subframe, AMP, eNB->common_vars.txdataF);
+      
+    }
+#endif
   }
 
   if (do_meas==1) stop_meas(&eNB->dlsch_common_and_dci);
@@ -589,66 +550,64 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB,
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_DLSCH,1);
   // Now scan UE specific DLSCH
   LTE_eNB_DLSCH_t *dlsch0,*dlsch1;
-  for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++)
-    {
-      dlsch0 = eNB->dlsch[(uint8_t)UE_id][0]; 
-      dlsch1 = eNB->dlsch[(uint8_t)UE_id][1]; 
-
-      if ((dlsch0)&&
-	  (dlsch0->rnti>0)&&
+  for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
+    dlsch0 = eNB->dlsch[(uint8_t)UE_id][0]; 
+    dlsch1 = eNB->dlsch[(uint8_t)UE_id][1]; 
+    
+    if ((dlsch0)&&(dlsch0->rnti>0)&&
 #ifdef PHY_TX_THREAD
-	  (dlsch0->active[subframe] == 1)) {
+	(dlsch0->active[subframe] == 1) 
 #else
-	  (dlsch0->active == 1)) {
+	(dlsch0->active == 1) 
 #endif
-
-	// get harq_pid
-	harq_pid = dlsch0->harq_ids[frame%2][subframe];
-	AssertFatal(harq_pid>=0,"harq_pid is negative\n");
-
-        if (harq_pid>=8)
-        {
-          LOG_E(PHY,"harq_pid:%d corrupt must be 0-7 UE_id:%d frame:%d subframe:%d rnti:%x\n", harq_pid,UE_id,frame,subframe,dlsch0->rnti);
-        }
-        else
-        {
-          // generate pdsch
-
-          pdsch_procedures(eNB,
-              proc,
-              harq_pid,
-              dlsch0,
-              dlsch1,
-              &eNB->UE_stats[(uint32_t)UE_id],
-              0);
-        }
-
-
-      }
-
-
-      else if ((dlsch0)&&
-	       (dlsch0->rnti>0)&&
+	){
+      
+      // get harq_pid
+      harq_pid = dlsch0->harq_ids[frame%2][subframe];
+      AssertFatal(harq_pid>=0,"harq_pid is negative\n");
+      
+      if (harq_pid>=8)
+	{
+	  LOG_E(PHY,"harq_pid:%d corrupt must be 0-7 UE_id:%d frame:%d subframe:%d rnti:%x\n", harq_pid,UE_id,frame,subframe,dlsch0->rnti);
+	}
+      else
+	{
+	  // generate pdsch
+	  
+	  pdsch_procedures(eNB,
+			   proc,
+			   harq_pid,
+			   dlsch0,
+			   dlsch1,
+			   &eNB->UE_stats[(uint32_t)UE_id],
+			   0);
+	}
+      
+      
+    }
+    
+    
+    else if ((dlsch0)&&(dlsch0->rnti>0)&&
 #ifdef PHY_TX_THREAD
-	       (dlsch0->active[subframe] == 0)) {
+	     (dlsch0->active[subframe] == 0) 
 #else
-           (dlsch0->active == 0)) {
+	     (dlsch0->active == 0) 
 #endif
-
-        // clear subframe TX flag since UE is not scheduled for PDSCH in this subframe (so that we don't look for PUCCH later)
-        dlsch0->subframe_tx[subframe]=0;
-      }
+	     ){
+      // clear subframe TX flag since UE is not scheduled for PDSCH in this subframe (so that we don't look for PUCCH later)
+      dlsch0->subframe_tx[subframe]=0;
     }
-  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_DLSCH,0);
-
-
-
+    
+    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_DLSCH,0);
+    
+  }
+  
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_PHICH,1);
   generate_phich_top(eNB,
 		     proc,
 		     AMP);
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_PHICH,0);
-
+  
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_TX+(eNB->CC_id),0);
   if (do_meas==1) stop_meas(&eNB->dlsch_ue_specific);
   if (do_meas==1) stop_meas(&eNB->phy_proc_tx);
@@ -659,30 +618,25 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB,
 void srs_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) {
 
   LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
-  const int subframe = proc->subframe_rx;
-  const int frame = proc->frame_rx;
-
-  int i;
-
-  if (is_srs_occasion_common(fp,frame,subframe)) { 
+  const int       subframe = proc->subframe_rx;
+  const int       frame = proc->frame_rx;
   
-  // Do SRS processing 
-  // check if there is SRS and we have to use shortened format
-  // TODO: check for exceptions in transmission of SRS together with ACK/NACK
-    for (i=0;i<NUMBER_OF_UE_MAX;i++) {
-
-      if (eNB->soundingrs_ul_config_dedicated[i].active==1) {
-
+  int             i;
+  
+  if (is_srs_occasion_common (fp, frame, subframe)) {
+    
+    // Do SRS processing 
+    // check if there is SRS and we have to use shortened format
+    // TODO: check for exceptions in transmission of SRS together with ACK/NACK
+    for (i = 0; i < NUMBER_OF_UE_MAX; i++) {
       
-	if (lte_srs_channel_estimation(fp,
-				       &eNB->common_vars,
-				       &eNB->srs_vars[i],
-				       &eNB->soundingrs_ul_config_dedicated[i],
-				       subframe,
-				       0/*eNB_id*/)) {
-	  LOG_E(PHY,"problem processing SRS\n");
+      if (eNB->soundingrs_ul_config_dedicated[i].active == 1) {
+	
+	
+	if (lte_srs_channel_estimation (fp, &eNB->common_vars, &eNB->srs_vars[i], &eNB->soundingrs_ul_config_dedicated[i], subframe, 0 /*eNB_id */ )) {
+	  LOG_E (PHY, "problem processing SRS\n");
 	}
-	eNB->soundingrs_ul_config_dedicated[i].active=0;
+	eNB->soundingrs_ul_config_dedicated[i].active = 0;
       }
     }
   }
@@ -694,27 +648,28 @@ void fill_sr_indication(PHY_VARS_eNB *eNB,uint16_t rnti,int frame,int subframe,u
   nfapi_sr_indication_t       *sr_ind =         &eNB->UL_INFO.sr_ind;
   nfapi_sr_indication_body_t  *sr_ind_body =    &sr_ind->sr_indication_body;
   nfapi_sr_indication_pdu_t *pdu =   &sr_ind_body->sr_pdu_list[sr_ind_body->number_of_srs];
-
+  
   sr_ind->sfn_sf = frame<<4|subframe;
   sr_ind->header.message_id = NFAPI_RX_SR_INDICATION;
-
+  
   sr_ind_body->tl.tag = NFAPI_SR_INDICATION_BODY_TAG;
-
+  
   pdu->instance_length                                = 0; // don't know what to do with this
   //  pdu->rx_ue_information.handle                       = handle;
   pdu->rx_ue_information.tl.tag                       = NFAPI_RX_UE_INFORMATION_TAG;
   pdu->rx_ue_information.rnti                         = rnti;
-
+  
   int SNRtimes10 = dB_fixed_times10(stat) - 300;//(10*eNB->measurements.n0_power_dB[0]);
 
 
-  pdu->ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG;
 
+  pdu->ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG;
+  
   if      (SNRtimes10 < -640) pdu->ul_cqi_information.ul_cqi=0;
   else if (SNRtimes10 >  635) pdu->ul_cqi_information.ul_cqi=255;
   else                        pdu->ul_cqi_information.ul_cqi=(640+SNRtimes10)/5;
   pdu->ul_cqi_information.channel = 0;
-
+  
   sr_ind_body->number_of_srs++;
   pthread_mutex_unlock(&eNB->UL_INFO_mutex);
 }
@@ -729,49 +684,48 @@ void uci_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc)
   int i;
   LTE_eNB_UCI *uci;
   uint16_t tdd_multiplexing_mask=0;
-
+  
   for (i=0;i<NUMBER_OF_UE_MAX;i++) {
-
+    
+    
     uci = &eNB->uci_vars[i];
-    if ((uci->active == 1) &&
-	(uci->frame == frame) &&
-	(uci->subframe == subframe)) {
-
-      LOG_D(PHY,"Frame %d, subframe %d: Running uci procedures (type %d) for %d \n",frame,subframe,uci->type,i);
-      uci->active=0;
-
+    if ((uci->active == 1) && (uci->frame == frame) && (uci->subframe == subframe)) {
+      
+      LOG_D (PHY, "Frame %d, subframe %d: Running uci procedures (type %d) for %d \n", frame, subframe, uci->type, i);
+      uci->active = 0;
+      
       // Null out PUCCH PRBs for noise measurement
-      switch(fp->N_RB_UL) {
+      switch (fp->N_RB_UL) {
       case 6:
-        eNB->rb_mask_ul[0] |= (0x1 | (1<<5)); //position 5
-        break;
+	eNB->rb_mask_ul[0] |= (0x1 | (1 << 5)); //position 5
+	break;
       case 15:
-        eNB->rb_mask_ul[0] |= (0x1 | (1<<14)); // position 14
-        break;
+	eNB->rb_mask_ul[0] |= (0x1 | (1 << 14));        // position 14
+	break;
       case 25:
-        eNB->rb_mask_ul[0] |= (0x1 | (1<<24)); // position 24
-        break;
+	eNB->rb_mask_ul[0] |= (0x1 | (1 << 24));        // position 24
+	break;
       case 50:
-        eNB->rb_mask_ul[0] |= 0x1;
-        eNB->rb_mask_ul[1] |= (1<<17); // position 49 (49-32)
-        break;
+	eNB->rb_mask_ul[0] |= 0x1;
+	eNB->rb_mask_ul[1] |= (1 << 17);        // position 49 (49-32)
+	break;
       case 75:
-        eNB->rb_mask_ul[0] |= 0x1;
-        eNB->rb_mask_ul[2] |= (1<<10); // position 74 (74-64)
-        break;
+	eNB->rb_mask_ul[0] |= 0x1;
+	eNB->rb_mask_ul[2] |= (1 << 10);        // position 74 (74-64)
+	break;
       case 100:
-        eNB->rb_mask_ul[0] |= 0x1;
-        eNB->rb_mask_ul[3] |= (1<<3); // position 99 (99-96)
-        break;
+	eNB->rb_mask_ul[0] |= 0x1;
+	eNB->rb_mask_ul[3] |= (1 << 3); // position 99 (99-96)
+	break;
       default:
-        LOG_E(PHY,"Unknown number for N_RB_UL %d\n",fp->N_RB_UL);
-        break;
+	LOG_E (PHY, "Unknown number for N_RB_UL %d\n", fp->N_RB_UL);
+	break;
       }
       SR_payload = 0;
       switch (uci->type) {
       case SR:
       case HARQ_SR:
-		
+	
 	metric_SR = rx_pucch(eNB,
 			     uci->pucch_fmt,
 			     i,
@@ -788,7 +742,7 @@ void uci_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc)
 	      frame,
 	      subframe,
 	      SR_payload,
-              uci->type,
+	      uci->type,
 	      uci->n_pucch_1_0_sr[0]);
 	if (uci->type == SR) {
 	  if (SR_payload == 1) {
@@ -822,7 +776,7 @@ void uci_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc)
 	  /* cancel SR detection if reception on n1_pucch0 is better than on SR PUCCH resource index, otherwise send it up to MAC */
 	  if (uci->type==HARQ_SR && metric[0] > metric_SR) SR_payload = 0;
 	  else if (SR_payload == 1) fill_sr_indication(eNB,uci->rnti,frame,subframe,metric_SR);
- 
+	  
 	  if (uci->type==HARQ_SR && metric[0] <= metric_SR) {
 	    /* when transmitting ACK/NACK on SR PUCCH resource index, SR payload is always 1 */
 	    SR_payload = 1;
@@ -839,16 +793,16 @@ void uci_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc)
 			       PUCCH1a_THRES);
 	  }
 	  
-
+	  
 	  LOG_D(PHY,"[eNB %d][PDSCH %x] Frame %d subframe %d pucch1a (FDD) payload %d (metric %d)\n",
 		eNB->Mod_id,
 		uci->rnti,
 		frame,subframe,
 		pucch_b0b1[0][0],metric[0]);
-
+	  
 	  uci->stat = metric[0]; 	  
 	  fill_uci_harq_indication(eNB,uci,frame,subframe,pucch_b0b1[0],0,0xffff);
-
+	  
 	}
 	else { // frame_type == TDD
 	  LOG_D(PHY,"Frame %d Subframe %d Demodulating PUCCH (UCI %d) for ACK/NAK (uci->pucch_fmt %d,uci->type %d.uci->frame %d, uci->subframe %d): n1_pucch0 %d SR_payload %d\n",
@@ -857,42 +811,21 @@ void uci_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc)
 		uci->frame,uci->subframe,uci->n_pucch_1[0][0],
 		SR_payload);
 #if 1
-	      metric[0] = rx_pucch(eNB,
-				   uci->pucch_fmt,
-				   i,
-				   uci->n_pucch_1[0][0],
-				   0, //n2_pucch
-				   uci->srs_active, // shortened format
-				   pucch_b0b1[0],
-				   frame,
-				   subframe,
-				   PUCCH1a_THRES);
-	      if (uci->type==HARQ_SR && metric[0] > metric_SR) SR_payload = 0;
-	      else if (SR_payload == 1) fill_sr_indication(eNB,uci->rnti,frame,subframe,metric_SR);
-
-	      if (uci->type==HARQ_SR && metric[0] <= metric_SR) {
-	          SR_payload = 1;
-	          metric[0] = rx_pucch(eNB,
-				       pucch_format1b,
-				       i,
-				       uci->n_pucch_1_0_sr[0],
-				       0, //n2_pucch
-				       uci->srs_active, // shortened format
-				       pucch_b0b1[0],
-				       frame,
-				       subframe,
-				       PUCCH1a_THRES);
-	      }
-#else
-	  // if SR was detected, use the n1_pucch from SR
-	  if (SR_payload==1) {
-#ifdef DEBUG_PHY_PROC
-	    LOG_D(PHY,"[eNB %d][PDSCH %x] Frame %d subframe %d Checking ACK/NAK (%d,%d,%d,%d) format %d with SR\n",eNB->Mod_id,
-		  eNB->dlsch[UE_id][0]->rnti,
-		  frame,subframe,
-		  n1_pucch0,n1_pucch1,n1_pucch2,n1_pucch3,format);
-#endif
-	    
+	  metric[0] = rx_pucch(eNB,
+			       uci->pucch_fmt,
+			       i,
+			       uci->n_pucch_1[0][0],
+			       0, //n2_pucch
+			       uci->srs_active, // shortened format
+			       pucch_b0b1[0],
+			       frame,
+			       subframe,
+			       PUCCH1a_THRES);
+	  if (uci->type==HARQ_SR && metric[0] > metric_SR) SR_payload = 0;
+	  else if (SR_payload == 1) fill_sr_indication(eNB,uci->rnti,frame,subframe,metric_SR);
+	  
+	  if (uci->type==HARQ_SR && metric[0] <= metric_SR) {
+	    SR_payload = 1;
 	    metric[0] = rx_pucch(eNB,
 				 pucch_format1b,
 				 i,
@@ -903,18 +836,36 @@ void uci_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc)
 				 frame,
 				 subframe,
 				 PUCCH1a_THRES);
-	  } else { //using assigned pucch resources
+	  }
+#else
+	  // if SR was detected, use the n1_pucch from SR
+	  if (SR_payload==1) {
 #ifdef DEBUG_PHY_PROC
-	    LOG_D(PHY,"[eNB %d][PDSCH %x] Frame %d subframe %d Checking ACK/NAK M=%d (%d,%d,%d,%d) format %d\n",eNB->Mod_id,
-		  eNB->dlsch[UE_id][0]->rnti,
-		  frame,subframe,
-		  uci->num_pucch_resources,
-		  uci->n_pucch_1[res][0],
-		  uci->n_pucch_1[res][1],
-		  uci->n_pucch_1[res][2],
-		  uci->n_pucch_1[res][3],
-		  uci->pucch_fmt);
+	    LOG_D (PHY, "[eNB %d][PDSCH %x] Frame %d subframe %d Checking ACK/NAK (%d,%d,%d,%d) format %d with SR\n", eNB->Mod_id,
+		   eNB->dlsch[UE_id][0]->rnti, frame, subframe, n1_pucch0, n1_pucch1, n1_pucch2, n1_pucch3, format);
 #endif
+	    
+	    metric[0] = rx_pucch (eNB, pucch_format1b, i, uci->n_pucch_1_0_sr[0], 0,    //n2_pucch
+				  uci->srs_active,      // shortened format
+				  pucch_b0b1[0], frame, subframe, PUCCH1a_THRES
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+				  ,uci->ue_type
+#endif
+				  );
+	  } else {              //using assigned pucch resources
+#ifdef DEBUG_PHY_PROC
+	    LOG_D (PHY, "[eNB %d][PDSCH %x] Frame %d subframe %d Checking ACK/NAK M=%d (%d,%d,%d,%d) format %d\n", eNB->Mod_id,
+		   eNB->dlsch[UE_id][0]->rnti,
+		   frame, subframe, uci->num_pucch_resources, uci->n_pucch_1[res][0], uci->n_pucch_1[res][1], uci->n_pucch_1[res][2], uci->n_pucch_1[res][3], uci->pucch_fmt);
+#endif
+	    for (res = 0; res < uci->num_pucch_resources; res++)
+	      metric[res] = rx_pucch (eNB, uci->pucch_fmt, i, uci->n_pucch_1[res][0], 0,        // n2_pucch
+				      uci->srs_active,  // shortened format
+				      pucch_b0b1[res], frame, subframe, PUCCH1a_THRES
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+				      ,uci->ue_type
+#endif		  
+				      );
 	    for (res=0;res<uci->num_pucch_resources;res++)
 	      metric[res] = rx_pucch(eNB,
 				     uci->pucch_fmt,
@@ -925,14 +876,15 @@ void uci_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc)
 				     pucch_b0b1[res],
 				     frame,
 				     subframe,
-				     PUCCH1a_THRES);
-	  	  
-	    
-
+				     PUCCH1a_THRES,
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+				     ,uci->ue_type
+#endif		  
+				     );
 	  }
 #ifdef DEBUG_PHY_PROC
- 	      LOG_D(PHY,"RNTI %x type %d SR_payload %d  Frame %d Subframe %d  pucch_b0b1[0][0] %d pucch_b0b1[0][1] %d pucch_b0b1[1][0] %d pucch_b0b1[1][1] %d  \n",
-	              uci->rnti,uci->type,SR_payload,frame,subframe,pucch_b0b1[0][0],pucch_b0b1[0][1],pucch_b0b1[1][0],pucch_b0b1[1][1]);
+	  LOG_D(PHY,"RNTI %x type %d SR_payload %d  Frame %d Subframe %d  pucch_b0b1[0][0] %d pucch_b0b1[0][1] %d pucch_b0b1[1][0] %d pucch_b0b1[1][1] %d  \n",
+		uci->rnti,uci->type,SR_payload,frame,subframe,pucch_b0b1[0][0],pucch_b0b1[0][1],pucch_b0b1[1][0],pucch_b0b1[1][1]);
 #endif
 #endif
 	  if (SR_payload == 1) { // this implements Table 7.3.1 from 36.213
@@ -1004,7 +956,7 @@ void uci_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc)
 	      harq_ack[0] = 4; // DTX
 	      harq_ack[1] = 6; // NACK/DTX
 	      harq_ack[2] = 6; // NACK/DTX
-              max_metric = 0;
+	      max_metric = 0;
 	    } 
 	    else {
 	      
@@ -1029,8 +981,8 @@ void uci_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc)
 		}
 	      } // if (metric[0]==max_metric) {
 	      else if (metric[1]==max_metric) {
-	      
-	        if (pucch_b0b1[1][0] == 1 && pucch_b0b1[1][1] != 1){
+		
+		if (pucch_b0b1[1][0] == 1 && pucch_b0b1[1][1] != 1){
 		  harq_ack[0] = 1; // ACK
 		  harq_ack[1] = 1; // ACK
 		  harq_ack[2] = 6; // NACK/DTX
@@ -1049,7 +1001,7 @@ void uci_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc)
 		}
 	      } // if (metric[1]==max_metric) {
 	      else {
-  	        if (pucch_b0b1[2][0] == 1 && pucch_b0b1[2][1] == 1){
+		if (pucch_b0b1[2][0] == 1 && pucch_b0b1[2][1] == 1){
 		  harq_ack[0] = 1; // ACK
 		  harq_ack[1] = 1; // ACK
 		  harq_ack[2] = 1; // ACK
@@ -1074,8 +1026,8 @@ void uci_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc)
 		  tdd_multiplexing_mask = 0x4;
 		}
 	      }
-            uci->stat = max_metric;
-	    fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,1,tdd_multiplexing_mask); // multiplexing mode
+	      uci->stat = max_metric;
+	      fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,1,tdd_multiplexing_mask); // multiplexing mode
 	    }
 	  } //else if ((uci->tdd_bundling == 0) && (res==3)) 
 	  else if ((uci->tdd_bundling == 0) && (uci->num_pucch_resources==4)){ // multiplexing + no SR, implement Table 10.1.3-7 (Rel14) for multiplexing with M=4
@@ -1087,9 +1039,9 @@ void uci_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc)
 	      harq_ack[1] = 6; // NACK/DTX
 	      harq_ack[2] = 6; // NACK/DTX
 	      harq_ack[3] = 6; // NACK/DTX
-              max_metric = 0;
+	      max_metric = 0;
 	    } else {
-
+	      
 	      max_metric = max(metric[0],max(metric[1],max(metric[2],metric[3])));
 	      
 	      if (metric[0]==max_metric) {
@@ -1224,29 +1176,24 @@ void uci_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc)
 	  }
 	  
 #ifdef DEBUG_PHY_PROC
-	  LOG_D(PHY,"[eNB %d][PDSCH %x] Frame %d subframe %d ACK/NAK metric 0 %d, metric 1 %d, (%d,%d)\n",eNB->Mod_id,
-		eNB->dlsch[UE_id][0]->rnti,
-		frame,subframe,
-		metric0,metric1,pucch_b0b1[0],pucch_b0b1[1]);
+	  LOG_D (PHY, "[eNB %d][PDSCH %x] Frame %d subframe %d ACK/NAK metric 0 %d, metric 1 %d, (%d,%d)\n", eNB->Mod_id,
+		 eNB->dlsch[UE_id][0]->rnti, frame, subframe, metric0, metric1, pucch_b0b1[0], pucch_b0b1[1]);
 #endif
 	}
 	break;
       default:
-	AssertFatal(1==0,"Unsupported UCI type %d\n",uci->type);
+	AssertFatal (1 == 0, "Unsupported UCI type %d\n", uci->type);
 	break;
       }
-    
+      
       if (SR_payload == 1) {
-	LOG_D(PHY,"[eNB %d][SR %x] Frame %d subframe %d Got SR for PUSCH, transmitting to MAC\n",eNB->Mod_id,
-	      uci->rnti,frame,subframe);
+	LOG_D (PHY, "[eNB %d][SR %x] Frame %d subframe %d Got SR for PUSCH, transmitting to MAC\n", eNB->Mod_id, uci->rnti, frame, subframe);
 	
-	if (eNB->first_sr[i] == 1) { // this is the first request for uplink after Connection Setup, so clear HARQ process 0 use for Msg4
+	if (eNB->first_sr[i] == 1) {    // this is the first request for uplink after Connection Setup, so clear HARQ process 0 use for Msg4
 	  eNB->first_sr[i] = 0;
-	  eNB->dlsch[i][0]->harq_processes[0]->round=0;
-	  eNB->dlsch[i][0]->harq_processes[0]->status=SCH_IDLE;
-	  LOG_D(PHY,"[eNB %d][SR %x] Frame %d subframe %d First SR\n",
-		eNB->Mod_id,
-		eNB->ulsch[i]->rnti,frame,subframe);
+	  eNB->dlsch[i][0]->harq_processes[0]->round = 0;
+	  eNB->dlsch[i][0]->harq_processes[0]->status = SCH_IDLE;
+	  LOG_D (PHY, "[eNB %d][SR %x] Frame %d subframe %d First SR\n", eNB->Mod_id, eNB->ulsch[i]->rnti, frame, subframe);
 	}
       }
     }
@@ -1261,29 +1208,33 @@ void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc)
   LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
   LTE_eNB_ULSCH_t *ulsch;
   LTE_UL_eNB_HARQ_t *ulsch_harq;
-
+  
   const int subframe = proc->subframe_rx;
   const int frame    = proc->frame_rx;
   
   harq_pid = subframe2harq_pid(&eNB->frame_parms,frame,subframe);
 
-  for (i=0; i<NUMBER_OF_UE_MAX; i++) {
+  
+  for (i = 0; i < NUMBER_OF_UE_MAX; i++) {
     ulsch = eNB->ulsch[i];
+    if (ulsch->ue_type > 0) harq_pid = 0;
+    
     ulsch_harq = ulsch->harq_processes[harq_pid];
+    
     if (ulsch->rnti>0) LOG_D(PHY,"eNB->ulsch[%d]->harq_processes[harq_pid:%d] SFN/SF:%04d%d: PUSCH procedures, UE %d/%x ulsch_harq[status:%d SFN/SF:%04d%d handled:%d]\n",
 			     i, harq_pid, frame,subframe,i,ulsch->rnti,
-                             ulsch_harq->status, ulsch_harq->frame, ulsch_harq->subframe, ulsch_harq->handled);
+			     ulsch_harq->status, ulsch_harq->frame, ulsch_harq->subframe, ulsch_harq->handled);
     
     if ((ulsch) &&
-        (ulsch->rnti>0) &&
-        (ulsch_harq->status == ACTIVE) &&
-	    (ulsch_harq->frame == frame) &&
-	    (ulsch_harq->subframe == subframe) &&
-        (ulsch_harq->handled == 0)) {
+	(ulsch->rnti>0) &&
+	(ulsch_harq->status == ACTIVE) &&
+	(ulsch_harq->frame == frame) &&
+	(ulsch_harq->subframe == subframe) &&
+	(ulsch_harq->handled == 0)) {
       
       // UE has ULSCH scheduling
       for (int rb=0;
-           rb<=ulsch_harq->nb_rb;
+	   rb<=ulsch_harq->nb_rb;
 	   rb++) {
 	int rb2 = rb+ulsch_harq->first_rb;
 	eNB->rb_mask_ul[rb2>>5] |= (1<<(rb2&31));
@@ -1331,40 +1282,40 @@ void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc)
       stop_meas(&eNB->ulsch_decoding_stats);
       
       LOG_D(PHY,"[eNB %d][PUSCH %d] frame %d subframe %d RNTI %x RX power (%d,%d) N0 (%d,%d) dB ACK (%d,%d), decoding iter %d ulsch_harq->cqi_crc_status:%d ackBits:%d ulsch_decoding_stats[t:%lld max:%lld]\n",
-            eNB->Mod_id,harq_pid,
-            frame,subframe,
-            ulsch->rnti,
-            dB_fixed(eNB->pusch_vars[i]->ulsch_power[0]),
-            dB_fixed(eNB->pusch_vars[i]->ulsch_power[1]),
-            30,//eNB->measurements.n0_power_dB[0],
-            30,//eNB->measurements.n0_power_dB[1],
-            ulsch_harq->o_ACK[0],
-            ulsch_harq->o_ACK[1],
-            ret,
-            ulsch_harq->cqi_crc_status,
-            ulsch_harq->O_ACK,
-            eNB->ulsch_decoding_stats.p_time, eNB->ulsch_decoding_stats.max);
+	    eNB->Mod_id,harq_pid,
+	    frame,subframe,
+	    ulsch->rnti,
+	    dB_fixed(eNB->pusch_vars[i]->ulsch_power[0]),
+	    dB_fixed(eNB->pusch_vars[i]->ulsch_power[1]),
+	    30,//eNB->measurements.n0_power_dB[0],
+	    30,//eNB->measurements.n0_power_dB[1],
+	    ulsch_harq->o_ACK[0],
+	    ulsch_harq->o_ACK[1],
+	    ret,
+	    ulsch_harq->cqi_crc_status,
+	    ulsch_harq->O_ACK,
+	    eNB->ulsch_decoding_stats.p_time, eNB->ulsch_decoding_stats.max);
       
       //compute the expected ULSCH RX power (for the stats)
       ulsch_harq->delta_TF = get_hundred_times_delta_IF_eNB(eNB,i,harq_pid, 0); // 0 means bw_factor is not considered
       
       if (RC.mac != NULL) { /* ulsim dose not use RC.mac context. */
-        if (ulsch_harq->cqi_crc_status == 1) {
+	if (ulsch_harq->cqi_crc_status == 1) {
 #ifdef DEBUG_PHY_PROC
-	//if (((frame%10) == 0) || (frame < 50))
-	print_CQI(ulsch_harq->o,ulsch_harq->uci_format,0,fp->N_RB_DL);
+	  //if (((frame%10) == 0) || (frame < 50))
+	  print_CQI(ulsch_harq->o,ulsch_harq->uci_format,0,fp->N_RB_DL);
 #endif
-          fill_ulsch_cqi_indication(eNB,frame,subframe,ulsch_harq,ulsch->rnti);
-          RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag &= (~(1 << subframe));
-        } else {
-          if(RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag & (1 << subframe) ){
-            RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag &= (~(1 << subframe));
-            RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_timer=30;
-            LOG_D(PHY,"Frame %d,Subframe %d, We're supposed to get a cqi here. Set cqi_req_timer to 30.\n",frame,subframe);
-          }
-        }
+	  fill_ulsch_cqi_indication(eNB,frame,subframe,ulsch_harq,ulsch->rnti);
+	  RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag &= (~(1 << subframe));
+	} else {
+	  if(RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag & (1 << subframe) ){
+	    RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag &= (~(1 << subframe));
+	    RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_timer=30;
+	    LOG_D(PHY,"Frame %d,Subframe %d, We're supposed to get a cqi here. Set cqi_req_timer to 30.\n",frame,subframe);
+	  }
+	}
       }
-    
+      
       if (ret == (1+MAX_TURBO_ITERATIONS)) {
 	T(T_ENB_PHY_ULSCH_UE_NACK, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), T_INT(ulsch->rnti),
 	  T_INT(harq_pid));
@@ -1380,14 +1331,14 @@ void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc)
 	      ulsch_harq->o_ACK[0],
 	      ulsch_harq->o_ACK[1]);
 	
-        if (ulsch_harq->round >= 3)  {
+	if (ulsch_harq->round >= 3)  {
 	  ulsch_harq->status  = SCH_IDLE;
 	  ulsch_harq->handled = 0;
 	  ulsch->harq_mask   &= ~(1 << harq_pid);
 	  ulsch_harq->round   = 0;
 	}
-
-        MSC_LOG_RX_DISCARDED_MESSAGE(
+	
+	MSC_LOG_RX_DISCARDED_MESSAGE(
 				     MSC_PHY_ENB,MSC_PHY_UE,
 				     NULL,0,
 				     "%05u:%02u ULSCH received rnti %x harq id %u round %d",
@@ -1395,82 +1346,77 @@ void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc)
 				     ulsch->rnti,harq_pid,
 				     ulsch_harq->round-1
 				     );
-
 	
-        /* Mark the HARQ process to release it later if max transmission reached
-         * (see below).
-         * MAC does not send the max transmission count, we have to deal with it
-         * locally in PHY.
-         */
-        ulsch_harq->handled = 1;
-      }  // ulsch in error
+	/* Mark the HARQ process to release it later if max transmission reached
+	 * (see below).
+	 * MAC does not send the max transmission count, we have to deal with it
+	 * locally in PHY.
+	 */
+	ulsch_harq->handled = 1;
+      }                         // ulsch in error
       else {
 	fill_crc_indication(eNB,i,frame,subframe,0); // indicate ACK to MAC
 	fill_rx_indication(eNB,i,frame,subframe);  // indicate SDU to MAC
-
-        ulsch_harq->status = SCH_IDLE;
-        ulsch->harq_mask   &= ~(1 << harq_pid);
-
-        T(T_ENB_PHY_ULSCH_UE_ACK, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), T_INT(ulsch->rnti),
-          T_INT(harq_pid));
-
-
-          MSC_LOG_RX_MESSAGE(
-              MSC_PHY_ENB,MSC_PHY_UE,
-              NULL,0,
-              "%05u:%02u ULSCH received rnti %x harq id %u",
-              frame,subframe,
-              ulsch->rnti,harq_pid
-              );
-
-
+	ulsch_harq->status = SCH_IDLE;
+	ulsch->harq_mask &= ~(1 << harq_pid);
+	
+	T (T_ENB_PHY_ULSCH_UE_ACK, T_INT (eNB->Mod_id), T_INT (frame), T_INT (subframe), T_INT (ulsch->rnti), T_INT (harq_pid));
+
+	MSC_LOG_RX_MESSAGE(
+			   MSC_PHY_ENB,MSC_PHY_UE,
+			   NULL,0,
+			   "%05u:%02u ULSCH received rnti %x harq id %u",
+			   frame,subframe,
+			   ulsch->rnti,harq_pid
+			   );
+	
+	
 #ifdef DEBUG_PHY_PROC
 #ifdef DEBUG_ULSCH
-          LOG_D(PHY,"[eNB] Frame %d, Subframe %d : ULSCH SDU (RX harq_pid %d) %d bytes:",frame,subframe,
-              harq_pid,ulsch_harq->TBS>>3);
-
-          for (j=0; j<ulsch_harq->TBS>>3; j++)
-            LOG_T(PHY,"%x.",ulsch->harq_processes[harq_pid]->b[j]);
-
-          LOG_T(PHY,"\n");
+	LOG_D(PHY,"[eNB] Frame %d, Subframe %d : ULSCH SDU (RX harq_pid %d) %d bytes:",frame,subframe,
+	      harq_pid,ulsch_harq->TBS>>3);
+	
+	for (j=0; j<ulsch_harq->TBS>>3; j++)
+	  LOG_T(PHY,"%x.",ulsch->harq_processes[harq_pid]->b[j]);
+	
+	LOG_T(PHY,"\n");
 #endif
 #endif
       }  // ulsch not in error
-
+      
       if (ulsch_harq->O_ACK>0) fill_ulsch_harq_indication(eNB,ulsch_harq,ulsch->rnti,frame,subframe,ulsch->bundling);
       
       LOG_D(PHY,"[eNB %d] Frame %d subframe %d: received ULSCH harq_pid %d for UE %d, ret = %d, CQI CRC Status %d, ACK %d,%d, ulsch_errors %d/%d\n",
-            eNB->Mod_id,frame,subframe,
-            harq_pid,
-            i,
-            ret,
-            ulsch_harq->cqi_crc_status,
-            ulsch_harq->o_ACK[0],
-            ulsch_harq->o_ACK[1],
-            eNB->UE_stats[i].ulsch_errors[harq_pid],
-            eNB->UE_stats[i].ulsch_decoding_attempts[harq_pid][0]);
+	    eNB->Mod_id,frame,subframe,
+	    harq_pid,
+	    i,
+	    ret,
+	    ulsch_harq->cqi_crc_status,
+	    ulsch_harq->o_ACK[0],
+	    ulsch_harq->o_ACK[1],
+	    eNB->UE_stats[i].ulsch_errors[harq_pid],
+	    eNB->UE_stats[i].ulsch_decoding_attempts[harq_pid][0]);
     } //     if ((ulsch) &&
-      //         (ulsch->rnti>0) &&
-      //         (ulsch_harq->status == ACTIVE))
+    //         (ulsch->rnti>0) &&
+    //         (ulsch_harq->status == ACTIVE))
     else if ((ulsch) &&
-             (ulsch->rnti>0) &&
-             (ulsch_harq->status == ACTIVE) &&
-             (ulsch_harq->frame == frame) &&
-             (ulsch_harq->subframe == subframe) &&
-             (ulsch_harq->handled == 1)) {
-          // this harq process is stale, kill it, this 1024 frames later (10s), consider reducing that
-           ulsch_harq->status = SCH_IDLE;
+	     (ulsch->rnti>0) &&
+	     (ulsch_harq->status == ACTIVE) &&
+	     (ulsch_harq->frame == frame) &&
+	     (ulsch_harq->subframe == subframe) &&
+	     (ulsch_harq->handled == 1)) {
+      // this harq process is stale, kill it, this 1024 frames later (10s), consider reducing that
+      ulsch_harq->status = SCH_IDLE;
       ulsch_harq->handled = 0;
-      ulsch->harq_mask   &= ~(1 << harq_pid);
-      LOG_W(PHY,"Removing stale ULSCH config for UE %x harq_pid %d (harq_mask is now 0x%2.2x)\n",
-            ulsch->rnti, harq_pid, ulsch->harq_mask);
+      ulsch->harq_mask &= ~(1 << harq_pid);
+      LOG_W (PHY, "Removing stale ULSCH config for UE %x harq_pid %d (harq_mask is now 0x%2.2x)\n", ulsch->rnti, harq_pid, ulsch->harq_mask);
     }
   }   //   for (i=0; i<NUMBER_OF_UE_MAX; i++)
 }
 
-extern int oai_exit;
+extern int      oai_exit;
 
-extern void *td_thread(void*);
+extern void    *td_thread (void *);
 
 void init_td_thread(PHY_VARS_eNB *eNB) {
 
@@ -1484,11 +1430,12 @@ void init_td_thread(PHY_VARS_eNB *eNB) {
   pthread_cond_init( &proc->cond_td, NULL);
   
   pthread_create(&proc->pthread_td, &proc->attr_td, td_thread, (void*)&proc->tdp);
-
+  
 }
 void kill_td_thread(PHY_VARS_eNB *eNB) {
 
   L1_proc_t *proc = &eNB->proc;
+
   proc->instance_cnt_td         = 0;
   pthread_cond_signal(&proc->cond_td);
   
@@ -1497,7 +1444,7 @@ void kill_td_thread(PHY_VARS_eNB *eNB) {
   pthread_cond_destroy( &proc->cond_td );
 }
 
-extern void *te_thread(void*);
+extern void    *te_thread (void *);
 
 void init_te_thread(PHY_VARS_eNB *eNB) {
 
@@ -1506,7 +1453,7 @@ void init_te_thread(PHY_VARS_eNB *eNB) {
   for(int i=0; i<3 ;i++){
     proc->tep[i].eNB = eNB;
     proc->tep[i].instance_cnt_te         = -1;
-      
+    
     pthread_mutex_init( &proc->tep[i].mutex_te, NULL);
     pthread_cond_init( &proc->tep[i].cond_te, NULL);
     pthread_attr_init( &proc->tep[i].attr_te);
@@ -1528,24 +1475,30 @@ void kill_te_thread(PHY_VARS_eNB *eNB) {
   }
 }
 
-
-void fill_rx_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe)
-{
+void fill_rx_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe) {
   nfapi_rx_indication_pdu_t *pdu;
-
-  int timing_advance_update;
-  int sync_pos;
-
-  uint32_t harq_pid = subframe2harq_pid(&eNB->frame_parms,
-					frame,subframe);
-
+  
+  int             timing_advance_update;
+  int             sync_pos;
+  
+  uint32_t        harq_pid;
+  
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+  if (eNB->ulsch[UE_id]->ue_type > 0) harq_pid = 0;
+  else
+#endif
+    {
+      harq_pid = subframe2harq_pid (&eNB->frame_parms,
+				    frame, subframe);
+    }
+  
   pthread_mutex_lock(&eNB->UL_INFO_mutex);
-
+  
   eNB->UL_INFO.rx_ind.sfn_sf                    = frame<<4| subframe;
   eNB->UL_INFO.rx_ind.rx_indication_body.tl.tag = NFAPI_RX_INDICATION_BODY_TAG;
-
+  
   pdu                                    = &eNB->UL_INFO.rx_ind.rx_indication_body.rx_pdu_list[eNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus];
-
+  
   //  pdu->rx_ue_information.handle          = eNB->ulsch[UE_id]->handle;
   pdu->rx_ue_information.tl.tag          = NFAPI_RX_UE_INFORMATION_TAG;
   pdu->rx_ue_information.rnti            = eNB->ulsch[UE_id]->rnti;
@@ -1557,125 +1510,142 @@ void fill_rx_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe)
   sync_pos                               = lte_est_timing_advance_pusch(eNB,UE_id);
   timing_advance_update                  = sync_pos; // - eNB->frame_parms.nb_prefix_samples/4; //to check
 
+  
   //  if (timing_advance_update > 10) { dump_ulsch(eNB,frame,subframe,UE_id); exit(-1);}
   //  if (timing_advance_update < -10) { dump_ulsch(eNB,frame,subframe,UE_id); exit(-1);}
   switch (eNB->frame_parms.N_RB_DL) {
-  case 6:   /* nothing to do */          break;
-  case 15:  timing_advance_update /= 2;  break;
-  case 25:  timing_advance_update /= 4;  break;
-  case 50:  timing_advance_update /= 8;  break;
-  case 75:  timing_advance_update /= 12; break;
-  case 100: timing_advance_update /= 16; break;
-  default: abort();
+  case 6:                      /* nothing to do */
+    break;
+  case 15:
+    timing_advance_update /= 2;
+    break;
+  case 25:
+    timing_advance_update /= 4;
+    break;
+  case 50:
+    timing_advance_update /= 8;
+    break;
+  case 75:
+    timing_advance_update /= 12;
+    break;
+  case 100:
+    timing_advance_update /= 16;
+    break;
+  default:
+    abort ();
   }
   // put timing advance command in 0..63 range
   timing_advance_update += 31;
-  if (timing_advance_update < 0)  timing_advance_update = 0;
-  if (timing_advance_update > 63) timing_advance_update = 63;
+  if (timing_advance_update < 0)
+    timing_advance_update = 0;
+  if (timing_advance_update > 63)
+    timing_advance_update = 63;
   pdu->rx_indication_rel8.timing_advance = timing_advance_update;
-
+  
   // estimate UL_CQI for MAC (from antenna port 0 only)
   int SNRtimes10 = dB_fixed_times10(eNB->pusch_vars[UE_id]->ulsch_power[0]) - 300;//(10*eNB->measurements.n0_power_dB[0]);
+  
 
-  if      (SNRtimes10 < -640) pdu->rx_indication_rel8.ul_cqi=0;
-  else if (SNRtimes10 >  635) pdu->rx_indication_rel8.ul_cqi=255;
-  else                        pdu->rx_indication_rel8.ul_cqi=(640+SNRtimes10)/5;
-
+  if (SNRtimes10 < -640)
+    pdu->rx_indication_rel8.ul_cqi = 0;
+  else if (SNRtimes10 > 635)
+    pdu->rx_indication_rel8.ul_cqi = 255;
+  else
+    pdu->rx_indication_rel8.ul_cqi = (640 + SNRtimes10) / 5;
+  
   LOG_D(PHY,"[PUSCH %d] Frame %d Subframe %d Filling RX_indication with SNR %d (%d), timing_advance %d (update %d)\n",
-	harq_pid,frame,subframe,SNRtimes10,pdu->rx_indication_rel8.ul_cqi,pdu->rx_indication_rel8.timing_advance,
+		  harq_pid,frame,subframe,SNRtimes10,pdu->rx_indication_rel8.ul_cqi,pdu->rx_indication_rel8.timing_advance,
 	timing_advance_update);
-
+  
   eNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus++;
   eNB->UL_INFO.rx_ind.sfn_sf = frame<<4 | subframe;
   pthread_mutex_unlock(&eNB->UL_INFO_mutex);
 }
 
 /* release the harq if its round is >= 'after_rounds' */
-static void do_release_harq(PHY_VARS_eNB *eNB,int UE_id,int tb,uint16_t frame,uint8_t subframe,uint16_t mask, int after_rounds)
-{
-
+static void do_release_harq(PHY_VARS_eNB *eNB,int UE_id,int tb,uint16_t frame,uint8_t subframe,uint16_t mask, int after_rounds) {
+  
   LTE_eNB_DLSCH_t *dlsch0=NULL,*dlsch1=NULL;
   LTE_DL_eNB_HARQ_t *dlsch0_harq=NULL,*dlsch1_harq=NULL;
   int harq_pid;
   int subframe_tx,frame_tx;
   int M,m;
-
-  AssertFatal(UE_id!=-1,"no existing dlsch context\n");
-  AssertFatal(UE_id<NUMBER_OF_UE_MAX,"returned UE_id %d >= %d(NUMBER_OF_UE_MAX)\n",UE_id,NUMBER_OF_UE_MAX);
+  AssertFatal (UE_id != -1, "no existing dlsch context\n");
+  AssertFatal (UE_id < NUMBER_OF_UE_MAX, "returned UE_id %d >= %d(NUMBER_OF_UE_MAX)\n", UE_id, NUMBER_OF_UE_MAX);
   dlsch0 = eNB->dlsch[UE_id][0];
   dlsch1 = eNB->dlsch[UE_id][1];
-
+  
   if (eNB->frame_parms.frame_type == FDD) {  
     subframe_tx = (subframe+6)%10;
     frame_tx = ul_ACK_subframe2_dl_frame(&eNB->frame_parms,frame,subframe,subframe_tx);
     harq_pid = dlsch0->harq_ids[frame_tx%2][subframe_tx]; // or just use 0 for fdd?
-
+    
     AssertFatal((harq_pid>=0) && (harq_pid<10),"harq_pid %d not in 0...9\n",harq_pid);
     dlsch0_harq     = dlsch0->harq_processes[harq_pid];
     dlsch1_harq     = dlsch1->harq_processes[harq_pid];
     AssertFatal(dlsch0_harq!=NULL,"dlsch0_harq is null\n");
-
+    
 #if T_TRACER
     if (after_rounds != -1) {
       T(T_ENB_PHY_DLSCH_UE_NACK, T_INT(0), T_INT(frame), T_INT(subframe),
-        T_INT(dlsch0->rnti), T_INT(harq_pid));
+	T_INT(dlsch0->rnti), T_INT(harq_pid));
     } else {
       T(T_ENB_PHY_DLSCH_UE_ACK, T_INT(0), T_INT(frame), T_INT(subframe),
-        T_INT(dlsch0->rnti), T_INT(harq_pid));
+	T_INT(dlsch0->rnti), T_INT(harq_pid));
     }
 #endif
-
+    
     if (dlsch0_harq->round >= after_rounds) {
       dlsch0_harq->status = SCH_IDLE;
       /*if ((dlsch1_harq == NULL)||
-	  ((dlsch1_harq!=NULL)&&
-	   (dlsch1_harq->status == SCH_IDLE)))*/
+	((dlsch1_harq!=NULL)&&
+	(dlsch1_harq->status == SCH_IDLE)))*/
       dlsch0->harq_mask   &= ~(1<<harq_pid);
     }
     LOG_D(PHY,"Frame %d, subframe %d: Releasing harq %d for UE %x\n",frame,subframe,harq_pid,dlsch0->rnti);
-
+    
   }
   else { // release all processes in the bundle that was acked, based on mask
-         // This is at most 4 for multiplexing and 9 for bundling/special bundling
+    // This is at most 4 for multiplexing and 9 for bundling/special bundling
     M=ul_ACK_subframe2_M(&eNB->frame_parms,
-                         subframe);
-
+			 subframe);
+    
     for (m=0; m<M; m++) {
       subframe_tx = ul_ACK_subframe2_dl_subframe(&eNB->frame_parms,
 						 subframe,
 						 m);
       frame_tx = ul_ACK_subframe2_dl_frame(&eNB->frame_parms,frame,subframe,subframe_tx);
       if (((1<<m)&mask) > 0) {
-          harq_pid = dlsch0->harq_ids[frame_tx%2][subframe_tx];
+	harq_pid = dlsch0->harq_ids[frame_tx%2][subframe_tx];
 	if ((harq_pid>=0) && (harq_pid<dlsch0->Mdlharq)) {
 	  dlsch0_harq     = dlsch0->harq_processes[harq_pid];
 	  dlsch1_harq     = dlsch1->harq_processes[harq_pid];
 	  AssertFatal(dlsch0_harq!=NULL,"dlsch0_harq is null\n");
-      
+	  
 #if T_TRACER
-          if (after_rounds != -1) {
-            T(T_ENB_PHY_DLSCH_UE_NACK, T_INT(0), T_INT(frame), T_INT(subframe),
-              T_INT(dlsch0->rnti), T_INT(harq_pid));
-          } else {
-            T(T_ENB_PHY_DLSCH_UE_ACK, T_INT(0), T_INT(frame), T_INT(subframe),
-              T_INT(dlsch0->rnti), T_INT(harq_pid));
-          }
+	  if (after_rounds != -1) {
+	    T(T_ENB_PHY_DLSCH_UE_NACK, T_INT(0), T_INT(frame), T_INT(subframe),
+	      T_INT(dlsch0->rnti), T_INT(harq_pid));
+	  } else {
+	    T(T_ENB_PHY_DLSCH_UE_ACK, T_INT(0), T_INT(frame), T_INT(subframe),
+	      T_INT(dlsch0->rnti), T_INT(harq_pid));
+	  }
 #endif
-          if (dlsch0_harq->round >= after_rounds) {
+	  if (dlsch0_harq->round >= after_rounds) {
 	    dlsch0_harq->status = SCH_IDLE;
 	    if ((dlsch1_harq == NULL)||
-	        ((dlsch1_harq!=NULL)&&
-	         (dlsch1_harq->status == SCH_IDLE)))
+		((dlsch1_harq!=NULL)&&
+		 (dlsch1_harq->status == SCH_IDLE)))
 	      dlsch0->harq_mask   &= ~(1<<harq_pid);
-          }
+	  }
 	}
+	
       }
     }
-  }
+  } 
 }
 
-static void release_harq(PHY_VARS_eNB *eNB,int UE_id,int tb,uint16_t frame,uint8_t subframe,uint16_t mask, int is_ack)
-{
+static void release_harq(PHY_VARS_eNB *eNB,int UE_id,int tb,uint16_t frame,uint8_t subframe,uint16_t mask, int is_ack) {
   /* Maximum number of DL transmissions = 4.
    * TODO: get the value from configuration.
    * If is_ack is true then we release immediately. The value -1 can be used for that.
@@ -1684,14 +1654,14 @@ static void release_harq(PHY_VARS_eNB *eNB,int UE_id,int tb,uint16_t frame,uint8
 }
 
 int getM(PHY_VARS_eNB *eNB,int frame,int subframe) {
-
+  
   int M,Mtx=0;
   LTE_eNB_DLSCH_t *dlsch0=NULL,*dlsch1=NULL;
   LTE_DL_eNB_HARQ_t *dlsch0_harq=NULL,*dlsch1_harq=NULL;
   int harq_pid;
   int subframe_tx,frame_tx;
   int m;
-
+  
   M=ul_ACK_subframe2_M(&eNB->frame_parms,
 		       subframe);
   
@@ -1700,9 +1670,9 @@ int getM(PHY_VARS_eNB *eNB,int frame,int subframe) {
 					       subframe,
 					       m);
     frame_tx =  ul_ACK_subframe2_dl_frame(&eNB->frame_parms,frame,
-                                            subframe,subframe_tx);
+					  subframe,subframe_tx);
     harq_pid = dlsch0->harq_ids[frame_tx%2][subframe_tx];
-
+    
     if (harq_pid>=0 && harq_pid<10) {
       dlsch0_harq     = dlsch0->harq_processes[harq_pid];
       dlsch1_harq     = dlsch1->harq_processes[harq_pid];
@@ -1711,91 +1681,94 @@ int getM(PHY_VARS_eNB *eNB,int frame,int subframe) {
 	  (dlsch1_harq!=NULL && dlsch1_harq->status == ACTIVE)) Mtx ++;
     }
   }
-  return(Mtx);
+  return (Mtx);
 }
 
 
-void fill_ulsch_cqi_indication(PHY_VARS_eNB *eNB,uint16_t frame,uint8_t subframe,LTE_UL_eNB_HARQ_t *ulsch_harq,uint16_t rnti) {
-
-  pthread_mutex_lock(&eNB->UL_INFO_mutex);
-  nfapi_cqi_indication_pdu_t *pdu         = &eNB->UL_INFO.cqi_ind.cqi_pdu_list[eNB->UL_INFO.cqi_ind.number_of_cqis];
+void fill_ulsch_cqi_indication (PHY_VARS_eNB * eNB, uint16_t frame, uint8_t subframe, LTE_UL_eNB_HARQ_t * ulsch_harq, uint16_t rnti) {
+  
+  pthread_mutex_lock (&eNB->UL_INFO_mutex);
+  nfapi_cqi_indication_pdu_t *pdu = &eNB->UL_INFO.cqi_ind.cqi_pdu_list[eNB->UL_INFO.cqi_ind.number_of_cqis];
   nfapi_cqi_indication_raw_pdu_t *raw_pdu = &eNB->UL_INFO.cqi_ind.cqi_raw_pdu_list[eNB->UL_INFO.cqi_ind.number_of_cqis];
 
   pdu->rx_ue_information.tl.tag          = NFAPI_RX_UE_INFORMATION_TAG;
   pdu->rx_ue_information.rnti = rnti;
-  if (ulsch_harq->cqi_crc_status != 1) pdu->cqi_indication_rel9.data_offset = 0;
-  else               pdu->cqi_indication_rel9.data_offset = 1; // fill in after all cqi_indications have been generated when non-zero
-
+  if (ulsch_harq->cqi_crc_status != 1)
+    pdu->cqi_indication_rel9.data_offset = 0;
+  else
+    pdu->cqi_indication_rel9.data_offset = 1;   // fill in after all cqi_indications have been generated when non-zero
+  
   // by default set O to rank 1 value
+
   pdu->cqi_indication_rel9.tl.tag = NFAPI_CQI_INDICATION_REL9_TAG;
   pdu->cqi_indication_rel9.length = (ulsch_harq->Or1>>3) + ((ulsch_harq->Or1&7) > 0 ? 1 : 0);
   pdu->cqi_indication_rel9.ri[0]  = 0;
-
   // if we have RI bits, set them and if rank2 overwrite O
-  if (ulsch_harq->O_RI>0) {
+  if (ulsch_harq->O_RI > 0) {
     pdu->cqi_indication_rel9.ri[0] = ulsch_harq->o_RI[0];
-    if (ulsch_harq->o_RI[0] == 2)   pdu->cqi_indication_rel9.length = (ulsch_harq->Or2>>3) + ((ulsch_harq->Or2&7) > 0 ? 1 : 0);
+    if (ulsch_harq->o_RI[0] == 2)
+      pdu->cqi_indication_rel9.length = (ulsch_harq->Or2 >> 3) + ((ulsch_harq->Or2 & 7) > 0 ? 1 : 0);
     pdu->cqi_indication_rel9.timing_advance = 0;
   }
   
   pdu->cqi_indication_rel9.number_of_cc_reported = 1;
-  pdu->ul_cqi_information.channel = 1; // PUSCH
-  memcpy((void*)raw_pdu->pdu,ulsch_harq->o,pdu->cqi_indication_rel9.length);
+  pdu->ul_cqi_information.channel = 1;  // PUSCH
+  memcpy ((void *) raw_pdu->pdu, ulsch_harq->o, pdu->cqi_indication_rel9.length);
   eNB->UL_INFO.cqi_ind.number_of_cqis++;
   LOG_D(PHY,"eNB->UL_INFO.cqi_ind.number_of_cqis:%d\n", eNB->UL_INFO.cqi_ind.number_of_cqis);
-
+  
   pthread_mutex_unlock(&eNB->UL_INFO_mutex);
+  
+}							
 
-}
+void fill_ulsch_harq_indication (PHY_VARS_eNB * eNB, LTE_UL_eNB_HARQ_t * ulsch_harq, uint16_t rnti, int frame, int subframe, int bundling) {
 
-void fill_ulsch_harq_indication(PHY_VARS_eNB *eNB,LTE_UL_eNB_HARQ_t *ulsch_harq,uint16_t rnti, int frame,int subframe,int bundling)
-{
   int UE_id = find_dlsch(rnti,eNB,SEARCH_EXIST);
   if( (UE_id<0) || (UE_id>=NUMBER_OF_UE_MAX) ){
     LOG_E(PHY,"illegal UE_id found!!! rnti %04x UE_id %d\n",rnti,UE_id);
     return;
   }
   //AssertFatal(UE_id>=0,"UE_id doesn't exist\n");
-
+  
   pthread_mutex_lock(&eNB->UL_INFO_mutex);
   nfapi_harq_indication_pdu_t *pdu =   &eNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list[eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs];
   int M;
   int i;
-
+  
   eNB->UL_INFO.harq_ind.header.message_id = NFAPI_HARQ_INDICATION;
   eNB->UL_INFO.harq_ind.sfn_sf = frame<<4|subframe;
-
+  
   eNB->UL_INFO.harq_ind.harq_indication_body.tl.tag = NFAPI_HARQ_INDICATION_BODY_TAG;
-
+  
   pdu->instance_length                                = 0; // don't know what to do with this
   //  pdu->rx_ue_information.handle                       = handle;
   pdu->rx_ue_information.tl.tag                       = NFAPI_RX_UE_INFORMATION_TAG;
   pdu->rx_ue_information.rnti                         = rnti;
-
+  	    
   if (eNB->frame_parms.frame_type == FDD) {
     pdu->harq_indication_fdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL13_TAG;
     pdu->harq_indication_fdd_rel13.mode = 0;
     pdu->harq_indication_fdd_rel13.number_of_ack_nack = ulsch_harq->O_ACK;
-
-    for (i=0;i<ulsch_harq->O_ACK;i++) {
-      AssertFatal(ulsch_harq->o_ACK[i] == 0 || ulsch_harq->o_ACK[i] == 1, "harq_ack[%d] is %d, should be 1,2 or 4\n",i,ulsch_harq->o_ACK[i]);
-
-      pdu->harq_indication_fdd_rel13.harq_tb_n[i] = 2-ulsch_harq->o_ACK[i];
+    
+    for (i = 0; i < ulsch_harq->O_ACK; i++) {
+      AssertFatal (ulsch_harq->o_ACK[i] == 0 || ulsch_harq->o_ACK[i] == 1, "harq_ack[%d] is %d, should be 1,2 or 4\n", i, ulsch_harq->o_ACK[i]);
+      
+      pdu->harq_indication_fdd_rel13.harq_tb_n[i] = 2 - ulsch_harq->o_ACK[i];
       // release DLSCH if needed
+      
       release_harq(eNB,UE_id,i,frame,subframe,0xffff, ulsch_harq->o_ACK[i] == 1);
+      
     }
-  }
-  else { // TDD
-    M=ul_ACK_subframe2_M(&eNB->frame_parms,
-			 subframe);
-
+  } else {                      // TDD
+    M = ul_ACK_subframe2_M (&eNB->frame_parms, subframe);
+    
     pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG;
     pdu->harq_indication_tdd_rel13.mode = 1-bundling;
     pdu->harq_indication_tdd_rel13.number_of_ack_nack = ulsch_harq->O_ACK;
-
-    for (i=0;i<ulsch_harq->O_ACK;i++) {
-      AssertFatal(ulsch_harq->o_ACK[i] == 0 || ulsch_harq->o_ACK[i] == 1, "harq_ack[%d] is %d, should be 1,2 or 4\n",i,ulsch_harq->o_ACK[i]);
-
+    
+    for (i = 0; i < ulsch_harq->O_ACK; i++) {
+      AssertFatal (ulsch_harq->o_ACK[i] == 0 || ulsch_harq->o_ACK[i] == 1, "harq_ack[%d] is %d, should be 1,2 or 4\n", i, ulsch_harq->o_ACK[i]);
+      
       pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 2-ulsch_harq->o_ACK[i];
       // release DLSCH if needed
       /* TODO: review this code, it's most certainly wrong.
@@ -1810,22 +1783,17 @@ void fill_ulsch_harq_indication(PHY_VARS_eNB *eNB,LTE_UL_eNB_HARQ_t *ulsch_harq,
 	release_harq(eNB,UE_id,0,frame,subframe,1<<i, ulsch_harq->o_ACK[i] == 1);
 	release_harq(eNB,UE_id,1,frame,subframe,1<<i, ulsch_harq->o_ACK[i] == 1);
       }
-    }	
+    }
   }
 
   //LOG_E(PHY,"eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs:%d\n", eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs);
   eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs++;
-
+    
   pthread_mutex_unlock(&eNB->UL_INFO_mutex);
+    
 }
 
-void fill_uci_harq_indication(PHY_VARS_eNB *eNB,
-			      LTE_eNB_UCI *uci,
-			      int frame,
-			      int subframe,
-			      uint8_t *harq_ack,
-			      uint8_t tdd_mapping_mode,
-			      uint16_t tdd_multiplexing_mask) {
+void fill_uci_harq_indication (PHY_VARS_eNB * eNB, LTE_eNB_UCI * uci, int frame, int subframe, uint8_t * harq_ack, uint8_t tdd_mapping_mode, uint16_t tdd_multiplexing_mask) {
 
   int UE_id=find_dlsch(uci->rnti,eNB,SEARCH_EXIST);
   //AssertFatal(UE_id>=0,"UE_id doesn't exist rnti:%x\n", uci->rnti);
@@ -1833,41 +1801,45 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB,
     LOG_E(PHY,"SFN/SF:%04d%d Unable to find rnti:%x do not send HARQ\n", frame, subframe, uci->rnti);
     return;
   }
-
+  
   pthread_mutex_lock(&eNB->UL_INFO_mutex);
-
+  
   nfapi_harq_indication_t *ind       = &eNB->UL_INFO.harq_ind;
   nfapi_harq_indication_body_t *body = &ind->harq_indication_body;
   nfapi_harq_indication_pdu_t *pdu   = &body->harq_pdu_list[eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs];
-
+  
   ind->sfn_sf = frame<<4|subframe;
   ind->header.message_id = NFAPI_HARQ_INDICATION;
-
+  
   body->tl.tag = NFAPI_HARQ_INDICATION_BODY_TAG;
- 
+  
   pdu->instance_length                                = 0; // don't know what to do with this
   //  pdu->rx_ue_information.handle                       = handle;
   pdu->rx_ue_information.tl.tag                       = NFAPI_RX_UE_INFORMATION_TAG;
   pdu->rx_ue_information.rnti                         = uci->rnti;
-
+  
   // estimate UL_CQI for MAC (from antenna port 0 only)
   pdu->ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG;
   int SNRtimes10 = dB_fixed_times10(uci->stat) - 300;//(10*eNB->measurements.n0_power_dB[0]);
-
-  if (SNRtimes10 < -100) LOG_I(PHY,"uci->stat %d \n",uci->stat);
-
-  if      (SNRtimes10 < -640) pdu->ul_cqi_information.ul_cqi=0;
-  else if (SNRtimes10 >  635) pdu->ul_cqi_information.ul_cqi=255;
-  else                        pdu->ul_cqi_information.ul_cqi=(640+SNRtimes10)/5;
+	    
+  if (SNRtimes10 < -100)
+    LOG_I (PHY, "uci->stat %d \n", uci->stat);
+  
+  if (SNRtimes10 < -640)
+    pdu->ul_cqi_information.ul_cqi = 0;
+  else if (SNRtimes10 > 635)
+    pdu->ul_cqi_information.ul_cqi = 255;
+  else
+    pdu->ul_cqi_information.ul_cqi = (640 + SNRtimes10) / 5;
   pdu->ul_cqi_information.channel = 0;
-
+  
   if (eNB->frame_parms.frame_type == FDD) {
     if (uci->pucch_fmt == pucch_format1a) {
       pdu->harq_indication_fdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL13_TAG;
       pdu->harq_indication_fdd_rel13.mode = 0;  
       pdu->harq_indication_fdd_rel13.number_of_ack_nack = 1;
       
-      AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, "harq_ack[0] is %d, should be 1,2 or 4\n",harq_ack[0]);
+      AssertFatal (harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, "harq_ack[0] is %d, should be 1,2 or 4\n", harq_ack[0]);
       pdu->harq_indication_fdd_rel13.harq_tb_n[0] = harq_ack[0];
       // release DLSCH if needed
       release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1);
@@ -1876,10 +1848,10 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB,
       pdu->harq_indication_fdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL13_TAG;
       pdu->harq_indication_fdd_rel13.mode = 0;  
       pdu->harq_indication_fdd_rel13.number_of_ack_nack = 2;
-      AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[1] == 4, "harq_ack[0] is %d, should be 0,1 or 4\n",harq_ack[0]);
-      AssertFatal(harq_ack[1] == 1 || harq_ack[1] == 2 || harq_ack[1] == 4, "harq_ack[1] is %d, should be 0,1 or 4\n",harq_ack[1]);
+      AssertFatal (harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[1] == 4, "harq_ack[0] is %d, should be 0,1 or 4\n", harq_ack[0]);
+      AssertFatal (harq_ack[1] == 1 || harq_ack[1] == 2 || harq_ack[1] == 4, "harq_ack[1] is %d, should be 0,1 or 4\n", harq_ack[1]);
       pdu->harq_indication_fdd_rel13.harq_tb_n[0] = harq_ack[0];
-      pdu->harq_indication_fdd_rel13.harq_tb_n[1] = harq_ack[1]; 
+      pdu->harq_indication_fdd_rel13.harq_tb_n[1] = harq_ack[1];
       // release DLSCH if needed
       release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1);
       release_harq(eNB,UE_id,1,frame,subframe,0xffff, harq_ack[1] == 1);
@@ -1887,18 +1859,15 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB,
     else AssertFatal(1==0,"only format 1a/b for now, received %d\n",uci->pucch_fmt); 
   }
   else { // TDD
-
-    AssertFatal(tdd_mapping_mode==0 || tdd_mapping_mode==1 || tdd_mapping_mode==2,
-		"Illegal tdd_mapping_mode %d\n",tdd_mapping_mode);
-
+    AssertFatal (tdd_mapping_mode == 0 || tdd_mapping_mode == 1 || tdd_mapping_mode == 2, "Illegal tdd_mapping_mode %d\n", tdd_mapping_mode);
     pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG;
     pdu->harq_indication_tdd_rel13.mode = tdd_mapping_mode;  
     LOG_D(PHY,"%s(eNB, uci_harq format %d, rnti:%04x, frame:%d, subframe:%d, tdd_mapping_mode:%d) harq_ack[0]:%d harq_ack[1]:%d\n", __FUNCTION__, uci->pucch_fmt,uci->rnti, frame, subframe, tdd_mapping_mode,harq_ack[0],harq_ack[1]);
     switch (tdd_mapping_mode) {
-    case 0: // bundling
-
+    case 0:                    // bundling
+      
       if (uci->pucch_fmt == pucch_format1a) {
-        pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG;
+	pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG;
 	pdu->harq_indication_tdd_rel13.number_of_ack_nack = 1;	
 	LOG_D(PHY,"bundling, pucch1a, number of ack nack %d\n",pdu->harq_indication_tdd_rel13.number_of_ack_nack);
 	AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, "harq_ack[0] is %d, should be 1,2 or 4\n",harq_ack[0]);
@@ -1910,7 +1879,7 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB,
 	pdu->harq_indication_tdd_rel13.number_of_ack_nack = 2;
 	AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[1] == 4, "harq_ack[0] is %d, should be 0,1 or 4\n",harq_ack[0]);
 	AssertFatal(harq_ack[1] == 1 || harq_ack[1] == 2 || harq_ack[1] == 4, "harq_ack[1] is %d, should be 0,1 or 4\n",harq_ack[1]);
-        pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG;
+	pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG;
 	pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = harq_ack[0];
 	pdu->harq_indication_tdd_rel13.harq_data[1].bundling.value_0 = harq_ack[1]; 
 	// release all DLSCH if needed
@@ -1918,11 +1887,11 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB,
 	release_harq(eNB,UE_id,1,frame,subframe,0xffff, harq_ack[1] == 1);
       }
       break;
-    case 1: // multiplexing
-      AssertFatal(uci->pucch_fmt == pucch_format1b,"uci->pucch_format %d is not format1b\n",uci->pucch_fmt);
+    case 1:                    // multiplexing
+      AssertFatal (uci->pucch_fmt == pucch_format1b, "uci->pucch_format %d is not format1b\n", uci->pucch_fmt);
       
       if (uci->num_pucch_resources == 1 && uci->pucch_fmt == pucch_format1a) {
-        pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG;
+	pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG;
 	pdu->harq_indication_tdd_rel13.number_of_ack_nack = 1;	
 	AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, "harq_ack[0] is %d, should be 1,2 or 4\n",harq_ack[0]);
 	pdu->harq_indication_tdd_rel13.harq_data[0].multiplex.value_0 = harq_ack[0];
@@ -1930,7 +1899,7 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB,
 	release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1);
       }
       else if (uci->num_pucch_resources == 1 && uci->pucch_fmt == pucch_format1b) {
-        pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG;
+	pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG;
 	pdu->harq_indication_tdd_rel13.number_of_ack_nack = 2;
 	AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[1] == 4, "harq_ack[0] is %d, should be 0,1 or 4\n",harq_ack[0]);
 	AssertFatal(harq_ack[1] == 1 || harq_ack[1] == 2 || harq_ack[1] == 4, "harq_ack[1] is %d, should be 0,1 or 4\n",harq_ack[1]);
@@ -1941,9 +1910,9 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB,
 	release_harq(eNB,UE_id,1,frame,subframe,0xffff, harq_ack[1] == 1);
       }
       else { // num_pucch_resources (M) > 1
-        pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG;
+	pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG;
 	pdu->harq_indication_tdd_rel13.number_of_ack_nack = uci->num_pucch_resources;
-
+	
 	pdu->harq_indication_tdd_rel13.harq_data[0].multiplex.value_0 = harq_ack[0];
 	pdu->harq_indication_tdd_rel13.harq_data[1].multiplex.value_0 = harq_ack[1];
 	if (uci->num_pucch_resources == 3) 	pdu->harq_indication_tdd_rel13.harq_data[2].multiplex.value_0 = harq_ack[2];
@@ -1959,135 +1928,129 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB,
       pdu->harq_indication_tdd_rel13.mode = 0;
       int tdd_config5_sf2scheds=0;
       if (eNB->frame_parms.tdd_config==5) tdd_config5_sf2scheds = getM(eNB,frame,subframe);
- 
+      
       switch (harq_ack[0]) {
       case 0:
       case 4:
-          pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0;
-        /* TODO: release_harq here? this whole code looks suspicious */
+	pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0;
+	/* TODO: release_harq here? this whole code looks suspicious */
 	break;
       case 1: // check if M=1,4,7
 	if (uci->num_pucch_resources == 1 || uci->num_pucch_resources == 4 ||
 	    tdd_config5_sf2scheds == 1 || tdd_config5_sf2scheds == 4 || tdd_config5_sf2scheds == 7) {
-	    pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1;
+	  pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1;
 	  release_harq(eNB,UE_id,0,frame,subframe,0xffff, 1);
 	  release_harq(eNB,UE_id,1,frame,subframe,0xffff, 1);
 	}else{
-          pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0;
+	  pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0;
 	}
 	break;
       case 2: // check if M=2,5,8
 	if (uci->num_pucch_resources == 2 || tdd_config5_sf2scheds == 2 || 
 	    tdd_config5_sf2scheds == 5 || tdd_config5_sf2scheds == 8) {
-	    pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1;
+	  pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1;
 	  release_harq(eNB,UE_id,0,frame,subframe,0xffff, 1);
 	  release_harq(eNB,UE_id,1,frame,subframe,0xffff, 1);
 	}else{
-          pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0;
+	  pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0;
 	}
 	break;
       case 3: // check if M=3,6,9
 	if (uci->num_pucch_resources == 3 || tdd_config5_sf2scheds == 3 || 
 	    tdd_config5_sf2scheds == 6 || tdd_config5_sf2scheds == 9) {
-	    pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1;
+	  pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1;
 	  release_harq(eNB,UE_id,0,frame,subframe,0xffff, 1);
 	  release_harq(eNB,UE_id,1,frame,subframe,0xffff, 1);
 	}else{
-          pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0;
+	  pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0;
 	}
 	break;
       }
       break;
-
+      
     }
-  } //TDD
-
-
+  }                             //TDD
+  
+  
   eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs++;
   LOG_D(PHY,"Incremented eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs:%d\n", eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs);
   pthread_mutex_unlock(&eNB->UL_INFO_mutex);  
-
 }
 
-
-void fill_crc_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe,uint8_t crc_flag) {
+void fill_crc_indication (PHY_VARS_eNB * eNB, int UE_id, int frame, int subframe, uint8_t crc_flag) {
 
   pthread_mutex_lock(&eNB->UL_INFO_mutex);
   nfapi_crc_indication_pdu_t *pdu =   &eNB->UL_INFO.crc_ind.crc_indication_body.crc_pdu_list[eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs];
-
+  
   eNB->UL_INFO.crc_ind.sfn_sf                         = frame<<4 | subframe;
   eNB->UL_INFO.crc_ind.header.message_id              = NFAPI_CRC_INDICATION;
   eNB->UL_INFO.crc_ind.crc_indication_body.tl.tag     = NFAPI_CRC_INDICATION_BODY_TAG;
 
-  pdu->instance_length                                = 0; // don't know what to do with this
+  pdu->instance_length = 0;     // don't know what to do with this
   //  pdu->rx_ue_information.handle                       = handle;
+
   pdu->rx_ue_information.tl.tag                       = NFAPI_RX_UE_INFORMATION_TAG;
   pdu->rx_ue_information.rnti                         = eNB->ulsch[UE_id]->rnti;
   pdu->crc_indication_rel8.tl.tag                     = NFAPI_CRC_INDICATION_REL8_TAG;
   pdu->crc_indication_rel8.crc_flag                   = crc_flag;
-
+  
   eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs++;
-
+  
   //LOG_D(PHY, "%s() rnti:%04x crcs:%d crc_flag:%d\n", __FUNCTION__, pdu->rx_ue_information.rnti, eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs, crc_flag);
-
+  
   pthread_mutex_unlock(&eNB->UL_INFO_mutex);
 }
 
 void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc)
 {
   //RX processing for ue-specific resources (i
-  LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
-  const int subframe = proc->subframe_rx;
-  const int frame    = proc->frame_rx;
-
+  LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
+  const int       subframe = proc->subframe_rx;
+  const int       frame = proc->frame_rx;
+  
   /* TODO: use correct rxdata */
-  T(T_ENB_PHY_INPUT_SIGNAL, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), T_INT(0),
-    T_BUFFER(&eNB->RU_list[0]->common.rxdata[0][subframe*eNB->frame_parms.samples_per_tti],
-             eNB->frame_parms.samples_per_tti * 4));
-
+  T (T_ENB_PHY_INPUT_SIGNAL, T_INT (eNB->Mod_id), T_INT (frame), T_INT (subframe), T_INT (0),
+     T_BUFFER (&eNB->RU_list[0]->common.rxdata[0][subframe * eNB->frame_parms.samples_per_tti], eNB->frame_parms.samples_per_tti * 4));
+  
   if ((fp->frame_type == TDD) && (subframe_select(fp,subframe)!=SF_UL)) return;
-
+  
   T(T_ENB_PHY_UL_TICK, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe));
-
+  
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_UESPEC, 1 );
 
-  LOG_D(PHY,"[eNB %d] Frame %d: Doing phy_procedures_eNB_uespec_RX(%d)\n",eNB->Mod_id,frame, subframe);
-
-  eNB->rb_mask_ul[0]=0;
-  eNB->rb_mask_ul[1]=0;
-  eNB->rb_mask_ul[2]=0;
-  eNB->rb_mask_ul[3]=0;
-
+  LOG_D (PHY, "[eNB %d] Frame %d: Doing phy_procedures_eNB_uespec_RX(%d)\n", eNB->Mod_id, frame, subframe);
+  
+  eNB->rb_mask_ul[0] = 0;
+  eNB->rb_mask_ul[1] = 0;
+  eNB->rb_mask_ul[2] = 0;
+  eNB->rb_mask_ul[3] = 0;
+  
   // Fix me here, these should be locked
   eNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus  = 0;
   eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs = 0;
-
   // Call SRS first since all others depend on presence of SRS or lack thereof
-  srs_procedures(eNB,proc);
-
+  srs_procedures (eNB, proc);
+  
   eNB->first_run_I0_measurements = 0;
-
-  uci_procedures(eNB,proc);
-
+  
+  uci_procedures (eNB, proc);
+  
   if (nfapi_mode == 0 || nfapi_mode == 1) { // If PNF or monolithic
     pusch_procedures(eNB,proc);
   }
 
-  lte_eNB_I0_measurements(eNB,
-                          subframe,
-                          0,
-                          eNB->first_run_I0_measurements);
+  lte_eNB_I0_measurements (eNB, subframe, 0, eNB->first_run_I0_measurements);
 
   int min_I0=1000,max_I0=0;
   if ((frame==0) && (subframe==4)) { 
     for (int i=0;i<eNB->frame_parms.N_RB_UL;i++) {
       if (i==(eNB->frame_parms.N_RB_UL>>1) - 1) i+=2;
- 
+      
       if (eNB->measurements.n0_subband_power_tot_dB[i]<min_I0) min_I0 = eNB->measurements.n0_subband_power_tot_dB[i];
       if (eNB->measurements.n0_subband_power_tot_dB[i]>max_I0) max_I0 = eNB->measurements.n0_subband_power_tot_dB[i];
+      
     }
-    LOG_I(PHY,"max_I0 %d, min_I0 %d\n",max_I0,min_I0);
+    LOG_I (PHY, "max_I0 %d, min_I0 %d\n", max_I0, min_I0);
   }
-
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_UESPEC, 0 );
 }
diff --git a/openair1/SCHED/prach_procedures.c b/openair1/SCHED/prach_procedures.c
index 1dead0ee5789927897713630f197f748cdbf86e0..ee16a4f5807a13429564024f47dd79b30b4f084d 100644
--- a/openair1/SCHED/prach_procedures.c
+++ b/openair1/SCHED/prach_procedures.c
@@ -123,44 +123,45 @@ void prach_procedures(PHY_VARS_eNB *eNB
 
 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
   if (br_flag==1) {
-
-    eNB->UL_INFO.rach_ind_br.rach_indication_body.preamble_list                              = eNB->preamble_list_br;
-    int ind=0;
-    int ce_level=0;
-    /* Save for later, it doesn't work 
-    int prach_mask = is_prach_subframe(&eNB->frame_parms,eNB->proc.frame_prach_br,eNB->proc.subframe_prach_br);   
-    for (int ind=0,ce_level=0;ce_level<4;ce_level++) {
-      
-      if ((eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[ce_level]==1)&&
-	  (prach_mask&(1<<(1+ce_level)) > 0) && // prach is active and CE level has finished its repetitions
-	  (eNB->prach_vars_br.repetition_number[ce_level]==
-	   eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[ce_level])) {
-    */ 
-    if (eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[0]==1){ 
-      if ((eNB->prach_energy_counter == 100) && 
-          (max_preamble_energy[0] > eNB->measurements.prach_I0 + 100)) {
-	eNB->UL_INFO.rach_ind_br.rach_indication_body.number_of_preambles++;
-	
-	eNB->preamble_list_br[ind].preamble_rel8.timing_advance        = max_preamble_delay[ind];//
-	eNB->preamble_list_br[ind].preamble_rel8.preamble              = max_preamble[ind];
-	// note: fid is implicitly 0 here, this is the rule for eMTC RA-RNTI from 36.321, Section 5.1.4
-	eNB->preamble_list_br[ind].preamble_rel8.rnti                  = 1+subframe+(eNB->prach_vars_br.first_frame[ce_level]%40);  
-	eNB->preamble_list_br[ind].instance_length                     = 0; //don't know exactly what this is
-	eNB->preamble_list_br[ind].preamble_rel13.rach_resource_type   = 1+ce_level;  // CE Level
-	LOG_D(PHY,"Filling NFAPI indication for RACH %d CELevel %d (mask %x) : TA %d, Preamble %d, rnti %x, rach_resource_type %d\n",
-	      ind,
-	      ce_level,
-	      is_prach_subframe(&eNB->frame_parms,eNB->proc.frame_prach_br,eNB->proc.subframe_prach_br),
-	      eNB->preamble_list_br[ind].preamble_rel8.timing_advance,
-	      eNB->preamble_list_br[ind].preamble_rel8.preamble,
-	      eNB->preamble_list_br[ind].preamble_rel8.rnti,
-	      eNB->preamble_list_br[ind].preamble_rel13.rach_resource_type);
+    int             prach_mask;
+
+    prach_mask = is_prach_subframe (&eNB->frame_parms, eNB->proc.frame_prach_br, eNB->proc.subframe_prach_br);
+
+    eNB->UL_INFO.rach_ind_br.rach_indication_body.preamble_list = eNB->preamble_list_br;
+    int             ind = 0;
+    int             ce_level = 0;
+    /* Save for later, it doesn't work    
+       for (int ind=0,ce_level=0;ce_level<4;ce_level++) {
+
+       if ((eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[ce_level]==1)&&
+       (prach_mask&(1<<(1+ce_level)) > 0) && // prach is active and CE level has finished its repetitions
+       (eNB->prach_vars_br.repetition_number[ce_level]==
+       eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[ce_level])) {
+
+    */
+
+    if (eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[0] == 1) {
+      if ((eNB->prach_energy_counter == 100) && (max_preamble_energy[0] > eNB->measurements.prach_I0 + 200)) {
+        eNB->UL_INFO.rach_ind_br.rach_indication_body.number_of_preambles++;
+
+        eNB->preamble_list_br[ind].preamble_rel8.timing_advance = max_preamble_delay[ind];      //
+        eNB->preamble_list_br[ind].preamble_rel8.preamble = max_preamble[ind];
+        // note: fid is implicitly 0 here, this is the rule for eMTC RA-RNTI from 36.321, Section 5.1.4
+        eNB->preamble_list_br[ind].preamble_rel8.rnti = 1 + subframe + (60*(eNB->prach_vars_br.first_frame[ce_level] % 40));
+        eNB->preamble_list_br[ind].instance_length = 0; //don't know exactly what this is
+        eNB->preamble_list_br[ind].preamble_rel13.rach_resource_type = 1 + ce_level;    // CE Level
+        LOG_I (PHY, "Filling NFAPI indication for RACH %d CELevel %d (mask %x) : TA %d, Preamble %d, rnti %x, rach_resource_type %d\n",
+               ind,
+               ce_level,
+               prach_mask,
+               eNB->preamble_list_br[ind].preamble_rel8.timing_advance,
+               eNB->preamble_list_br[ind].preamble_rel8.preamble, eNB->preamble_list_br[ind].preamble_rel8.rnti, eNB->preamble_list_br[ind].preamble_rel13.rach_resource_type);
       }
+    }
       /*
 	ind++;
-      }
-      } */// ce_level
-    }
+	}
+	} */// ce_level
   }
   else
 #endif
diff --git a/openair1/SIMULATION/LTE_PHY/Abstraction/Training/IEEEtran.cls b/openair1/SIMULATION/LTE_PHY/Abstraction/Training/IEEEtran.cls
old mode 100755
new mode 100644
diff --git a/openair1/SIMULATION/LTE_PHY/Abstraction/Training/bare_adv.tex b/openair1/SIMULATION/LTE_PHY/Abstraction/Training/bare_adv.tex
old mode 100755
new mode 100644
diff --git a/openair1/SIMULATION/LTE_PHY/Abstraction/Training/bare_jrnl.tex b/openair1/SIMULATION/LTE_PHY/Abstraction/Training/bare_jrnl.tex
old mode 100755
new mode 100644
diff --git a/openair1/SIMULATION/LTE_PHY/Abstraction/Training/bare_jrnl_compsoc.tex b/openair1/SIMULATION/LTE_PHY/Abstraction/Training/bare_jrnl_compsoc.tex
old mode 100755
new mode 100644
diff --git a/openair1/SIMULATION/LTE_PHY/launch_sim.sh b/openair1/SIMULATION/LTE_PHY/launch_sim.sh
old mode 100644
new mode 100755
diff --git a/openair1/SIMULATION/LTE_PHY/mat2wv.m b/openair1/SIMULATION/LTE_PHY/mat2wv.m
old mode 100755
new mode 100644
diff --git a/openair1/SIMULATION/LTE_PHY/pbsPhyProcSim.sh b/openair1/SIMULATION/LTE_PHY/pbsPhyProcSim.sh
old mode 100644
new mode 100755
diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c
index 24338e1370335b5ac6b51b0b4db3c7efdf3cf174..09d0bb9150ebda157ea30b2009352345e1cb0434 100644
--- a/openair1/SIMULATION/LTE_PHY/ulsim.c
+++ b/openair1/SIMULATION/LTE_PHY/ulsim.c
@@ -413,9 +413,9 @@ int main(int argc, char **argv) {
   // enable these lines if you need debug info
   // however itti will catch all signals, so ctrl-c won't work anymore
   // alternatively you can disable ITTI completely in CMakeLists.txt
-  //itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, NULL);
-  //set_comp_log(PHY,LOG_DEBUG,LOG_MED,1);
-  //set_glog(LOG_DEBUG,LOG_MED);
+  //  itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, NULL);
+  //  set_comp_log(PHY,LOG_DEBUG,LOG_HIGH,1);
+  //  set_glog(LOG_DEBUG,LOG_HIGH);
   //hapZEbm:n:Y:X:x:s:w:e:q:d:D:O:c:r:i:f:y:c:oA:C:R:g:N:l:S:T:QB:PI:LF
   static paramdef_t options[] = {
     { "awgn", "Use AWGN channel and not multipath", PARAMFLAG_BOOL, strptr:NULL, defintval:0, TYPE_INT, 0, NULL, NULL },
diff --git a/openair1/SIMULATION/TOOLS/scm.m b/openair1/SIMULATION/TOOLS/scm.m
old mode 100755
new mode 100644
diff --git a/openair2/COMMON/platform_types.h b/openair2/COMMON/platform_types.h
index d24be0575e2bba1e3d234d743cf7ab612950d144..ee8d6abcc9cb2e4b97ec53e0346e28ec59c44598 100644
--- a/openair2/COMMON/platform_types.h
+++ b/openair2/COMMON/platform_types.h
@@ -236,6 +236,9 @@ typedef struct protocol_ctxt_s {
   sub_frame_t subframe;      /*!< \brief  LTE sub frame number.*/
   eNB_index_t eNB_index;     /*!< \brief  valid for UE indicating the index of connected eNB(s)      */
   boolean_t   configured;  /*!< \brief  flag indicating whether the instance is configured or not  */
+#ifdef Rel14
+  boolean_t		brOption;
+#endif
 } protocol_ctxt_t;
 // warning time hardcoded
 #define PROTOCOL_CTXT_TIME_MILLI_SECONDS(CtXt_h) ((CtXt_h)->frame*10+(CtXt_h)->subframe)
diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h
index 9a47580dbc785b0fae1009785bc63a3f0e59e2bf..f6e2216c1ba848233d85dd7b5206dc1f83f40d02 100644
--- a/openair2/COMMON/rrc_messages_types.h
+++ b/openair2/COMMON/rrc_messages_types.h
@@ -87,11 +87,81 @@ typedef struct RrcStateInd_s {
   Rrc_Sub_State_t sub_state;
 } RrcStateInd;
 
+typedef struct RadioResourceConfig_s {
+  long                    prach_root;
+  long                    prach_config_index;
+  BOOLEAN_t               prach_high_speed;
+  long                    prach_zero_correlation;
+  long                    prach_freq_offset;
+  long                    pucch_delta_shift;
+  long                    pucch_nRB_CQI;
+  long                    pucch_nCS_AN;
+  long                    pucch_n1_AN;
+  long                    pdsch_referenceSignalPower;
+  long                    pdsch_p_b;
+  long                    pusch_n_SB;
+  long                    pusch_hoppingMode;
+  long                    pusch_hoppingOffset;
+  BOOLEAN_t               pusch_enable64QAM;
+  BOOLEAN_t               pusch_groupHoppingEnabled;
+  long                    pusch_groupAssignment;
+  BOOLEAN_t               pusch_sequenceHoppingEnabled;
+  long                    pusch_nDMRS1;
+  long                    phich_duration;
+  long                    phich_resource;
+  BOOLEAN_t               srs_enable;
+  long                    srs_BandwidthConfig;
+  long                    srs_SubframeConfig;
+  BOOLEAN_t               srs_ackNackST;
+  BOOLEAN_t               srs_MaxUpPts;
+  long                    pusch_p0_Nominal;
+  long                    pusch_alpha;
+  long                    pucch_p0_Nominal;
+  long                    msg3_delta_Preamble;
+  long                    ul_CyclicPrefixLength;
+  e_LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1                    pucch_deltaF_Format1;
+  e_LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1b                   pucch_deltaF_Format1b;
+  e_LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2                    pucch_deltaF_Format2;
+  e_LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2a                   pucch_deltaF_Format2a;
+  e_LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2b                   pucch_deltaF_Format2b;
+  long                    rach_numberOfRA_Preambles;
+  BOOLEAN_t               rach_preamblesGroupAConfig;
+  long                    rach_sizeOfRA_PreamblesGroupA;
+  long                    rach_messageSizeGroupA;
+  e_LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB                    rach_messagePowerOffsetGroupB;
+  long                    rach_powerRampingStep;
+  long                    rach_preambleInitialReceivedTargetPower;
+  long                    rach_preambleTransMax;
+  long                    rach_raResponseWindowSize;
+  long                    rach_macContentionResolutionTimer;
+  long                    rach_maxHARQ_Msg3Tx;
+  long                    bcch_modificationPeriodCoeff;
+  long                    pcch_defaultPagingCycle;
+  long                    pcch_nB;
+  long                    ue_TimersAndConstants_t300;
+  long                    ue_TimersAndConstants_t301;
+  long                    ue_TimersAndConstants_t310;
+  long                    ue_TimersAndConstants_t311;
+  long                    ue_TimersAndConstants_n310;
+  long                    ue_TimersAndConstants_n311;
+  long                    ue_TransmissionMode;
+  long                    ue_multiple_max;
+#ifdef Rel14
+  //SIB2 BR Options
+  long*			  preambleTransMax_CE_r13;
+  BOOLEAN_t		  prach_ConfigCommon_v1310;
+  BOOLEAN_t*	          mpdcch_startSF_CSS_RA_r13;
+  long			  mpdcch_startSF_CSS_RA_r13_val;
+  long*			  prach_HoppingOffset_r13;
+#endif
+} RadioResourceConfig;
+
 // eNB: ENB_APP -> RRC messages
 typedef struct RrcConfigurationReq_s {
-  uint32_t            cell_identity;
+  uint32_t                cell_identity;
+
+  uint16_t                tac;
 
-  uint16_t            tac;
 
   uint16_t            mcc[PLMN_LIST_MAX_SIZE];
   uint16_t            mnc[PLMN_LIST_MAX_SIZE];
@@ -113,68 +183,89 @@ typedef struct RrcConfigurationReq_s {
   int16_t                 Nid_cell[MAX_NUM_CCs];// for testing, change later
   int16_t                 N_RB_DL[MAX_NUM_CCs];// for testing, change later
   int                     nb_antenna_ports[MAX_NUM_CCs];
-  long                    prach_root[MAX_NUM_CCs];
-  long                    prach_config_index[MAX_NUM_CCs];
-  BOOLEAN_t               prach_high_speed[MAX_NUM_CCs];
-  long                    prach_zero_correlation[MAX_NUM_CCs];
-  long                    prach_freq_offset[MAX_NUM_CCs];
-  long                    pucch_delta_shift[MAX_NUM_CCs];
-  long                    pucch_nRB_CQI[MAX_NUM_CCs];
-  long                    pucch_nCS_AN[MAX_NUM_CCs];
-  //#if (LTE_RRC_VERSION < MAKE_VERSION(10, 0, 0))
-  long                    pucch_n1_AN[MAX_NUM_CCs];
-  //#endif
-  long                    pdsch_referenceSignalPower[MAX_NUM_CCs];
-  long                    pdsch_p_b[MAX_NUM_CCs];
-  long                    pusch_n_SB[MAX_NUM_CCs];
-  long                    pusch_hoppingMode[MAX_NUM_CCs];
-  long                    pusch_hoppingOffset[MAX_NUM_CCs];
-  BOOLEAN_t               pusch_enable64QAM[MAX_NUM_CCs];
-  BOOLEAN_t               pusch_groupHoppingEnabled[MAX_NUM_CCs];
-  long                    pusch_groupAssignment[MAX_NUM_CCs];
-  BOOLEAN_t               pusch_sequenceHoppingEnabled[MAX_NUM_CCs];
-  long                    pusch_nDMRS1[MAX_NUM_CCs];
-  long                    phich_duration[MAX_NUM_CCs];
-  long                    phich_resource[MAX_NUM_CCs];
-  BOOLEAN_t               srs_enable[MAX_NUM_CCs];
-  long                    srs_BandwidthConfig[MAX_NUM_CCs];
-  long                    srs_SubframeConfig[MAX_NUM_CCs];
-  BOOLEAN_t               srs_ackNackST[MAX_NUM_CCs];
-  BOOLEAN_t               srs_MaxUpPts[MAX_NUM_CCs];
-  long                    pusch_p0_Nominal[MAX_NUM_CCs];
-  long                    pusch_alpha[MAX_NUM_CCs];
-  long                    pucch_p0_Nominal[MAX_NUM_CCs];
-  long                    msg3_delta_Preamble[MAX_NUM_CCs];
-  long                    ul_CyclicPrefixLength[MAX_NUM_CCs];
-  e_LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1                pucch_deltaF_Format1[MAX_NUM_CCs];
-  e_LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1b               pucch_deltaF_Format1b[MAX_NUM_CCs];
-  e_LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2                pucch_deltaF_Format2[MAX_NUM_CCs];
-  e_LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2a               pucch_deltaF_Format2a[MAX_NUM_CCs];
-  e_LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2b               pucch_deltaF_Format2b[MAX_NUM_CCs];
-  long                    rach_numberOfRA_Preambles[MAX_NUM_CCs];
-  BOOLEAN_t               rach_preamblesGroupAConfig[MAX_NUM_CCs];
-  long                    rach_sizeOfRA_PreamblesGroupA[MAX_NUM_CCs];
-  long                    rach_messageSizeGroupA[MAX_NUM_CCs];
-  e_LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB                rach_messagePowerOffsetGroupB[MAX_NUM_CCs];
-  long                    rach_powerRampingStep[MAX_NUM_CCs];
-  long                    rach_preambleInitialReceivedTargetPower[MAX_NUM_CCs];
-  long                    rach_preambleTransMax[MAX_NUM_CCs];
-  long                    rach_raResponseWindowSize[MAX_NUM_CCs];
-  long                    rach_macContentionResolutionTimer[MAX_NUM_CCs];
-  long                    rach_maxHARQ_Msg3Tx[MAX_NUM_CCs];
-  long                    bcch_modificationPeriodCoeff[MAX_NUM_CCs];
-  long                    pcch_defaultPagingCycle[MAX_NUM_CCs];
-  long                    pcch_nB[MAX_NUM_CCs];
-  long                    ue_TimersAndConstants_t300[MAX_NUM_CCs];
-  long                    ue_TimersAndConstants_t301[MAX_NUM_CCs];
-  long                    ue_TimersAndConstants_t310[MAX_NUM_CCs];
-  long                    ue_TimersAndConstants_t311[MAX_NUM_CCs];
-  long                    ue_TimersAndConstants_n310[MAX_NUM_CCs];
-  long                    ue_TimersAndConstants_n311[MAX_NUM_CCs];
-  long                    ue_TransmissionMode[MAX_NUM_CCs];
-  long                    ue_multiple_max[MAX_NUM_CCs];
+  int                     eMBMS_configured;
+  int                     eMTC_configured;
+  int                     SL_configured;
 
-  //TTN - for D2D
+  RadioResourceConfig     radioresourceconfig[MAX_NUM_CCs];
+  RadioResourceConfig     radioresourceconfig_BR[MAX_NUM_CCs];
+   
+#if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0))
+  //MIB
+  long	 		  schedulingInfoSIB1_BR_r13[MAX_NUM_CCs];
+  //SIB1 BR options
+  uint16_t*		  hyperSFN_r13                           [MAX_NUM_CCs];
+  long*			  eDRX_Allowed_r13                       [MAX_NUM_CCs];
+  BOOLEAN_t		  cellSelectionInfoCE_r13                [MAX_NUM_CCs];
+  long			  q_RxLevMinCE_r13                       [MAX_NUM_CCs];
+  long*			  q_QualMinRSRQ_CE_r13                   [MAX_NUM_CCs];
+  BOOLEAN_t		  bandwidthReducedAccessRelatedInfo_r13  [MAX_NUM_CCs];
+  long            si_Narrowband_r13         [MAX_NUM_CCs][32];
+  long            si_TBS_r13                [MAX_NUM_CCs][32];
+  int             scheduling_info_br_size   [MAX_NUM_CCs];
+  long			  si_WindowLength_BR_r13                       [MAX_NUM_CCs];
+  long			  si_RepetitionPattern_r13                     [MAX_NUM_CCs];
+  BOOLEAN_t		 * fdd_DownlinkOrTddSubframeBitmapBR_r13       [MAX_NUM_CCs];
+  uint64_t		  fdd_DownlinkOrTddSubframeBitmapBR_val_r13    [MAX_NUM_CCs];
+  uint16_t		  *fdd_UplinkSubframeBitmapBR_r13              [MAX_NUM_CCs];
+  long			  startSymbolBR_r13                            [MAX_NUM_CCs];
+  long			  si_HoppingConfigCommon_r13                   [MAX_NUM_CCs];
+  long*			  si_ValidityTime_r13                          [MAX_NUM_CCs];
+  long            systemInfoValueTagSi_r13      [MAX_NUM_CCs][10];
+  int             system_info_value_tag_SI_size [MAX_NUM_CCs];
+  BOOLEAN_t		  freqHoppingParametersDL_r13                   [MAX_NUM_CCs];
+  long*			  mpdcch_pdsch_HoppingNB_r13                    [MAX_NUM_CCs];
+  BOOLEAN_t		  interval_DLHoppingConfigCommonModeA_r13       [MAX_NUM_CCs];
+  long			  interval_DLHoppingConfigCommonModeA_r13_val   [MAX_NUM_CCs];
+  BOOLEAN_t		  interval_DLHoppingConfigCommonModeB_r13       [MAX_NUM_CCs];
+  long			  interval_DLHoppingConfigCommonModeB_r13_val   [MAX_NUM_CCs];
+  long*			  mpdcch_pdsch_HoppingOffset_r13                [MAX_NUM_CCs];
+  long firstPreamble_r13                 [MAX_NUM_CCs][4];
+  long lastPreamble_r13                  [MAX_NUM_CCs][4];
+  long ra_ResponseWindowSize_r13         [MAX_NUM_CCs][4];
+  long mac_ContentionResolutionTimer_r13 [MAX_NUM_CCs][4];
+  long rar_HoppingConfig_r13             [MAX_NUM_CCs][4];
+  int  rach_CE_LevelInfoList_r13_size    [MAX_NUM_CCs];
+//  long pcch_defaultPagingCycle_br;
+  long rsrp_range           [MAX_NUM_CCs][3];
+  int rsrp_range_list_size  [MAX_NUM_CCs];
+  long prach_config_index                        [MAX_NUM_CCs][4];
+  long prach_freq_offset                         [MAX_NUM_CCs][4];
+  long *prach_StartingSubframe_r13               [MAX_NUM_CCs][4];
+  long *maxNumPreambleAttemptCE_r13              [MAX_NUM_CCs][4];
+  long numRepetitionPerPreambleAttempt_r13       [MAX_NUM_CCs][4];
+  long mpdcch_NumRepetition_RA_r13               [MAX_NUM_CCs][4];
+  long prach_HoppingConfig_r13                   [MAX_NUM_CCs][4];
+  int  prach_parameters_list_size                [MAX_NUM_CCs];
+  long max_available_narrow_band                 [MAX_NUM_CCs][4][2];
+  int  max_available_narrow_band_size            [MAX_NUM_CCs][4];
+  long pucch_info_value       [MAX_NUM_CCs][4];
+  int  pucch_info_value_size  [MAX_NUM_CCs];
+  bool  pcch_config_v1310               [MAX_NUM_CCs];
+  long  paging_narrowbands_r13          [MAX_NUM_CCs];
+  long  mpdcch_numrepetition_paging_r13 [MAX_NUM_CCs];
+  long  *nb_v1310                        [MAX_NUM_CCs];
+  long  *pucch_NumRepetitionCE_Msg4_Level0_r13  [MAX_NUM_CCs];
+  long  *pucch_NumRepetitionCE_Msg4_Level1_r13  [MAX_NUM_CCs];
+  long  *pucch_NumRepetitionCE_Msg4_Level2_r13  [MAX_NUM_CCs];
+  long  *pucch_NumRepetitionCE_Msg4_Level3_r13  [MAX_NUM_CCs];
+  bool  sib2_freq_hoppingParameters_r13_exists             [MAX_NUM_CCs];
+  long  *sib2_mpdcch_pdsch_hoppingNB_r13                   [MAX_NUM_CCs];
+  long  *sib2_interval_DLHoppingConfigCommonModeA_r13      [MAX_NUM_CCs];
+  long  sib2_interval_DLHoppingConfigCommonModeA_r13_val  [MAX_NUM_CCs];         
+  long  *sib2_interval_DLHoppingConfigCommonModeB_r13      [MAX_NUM_CCs]; 
+  long  sib2_interval_DLHoppingConfigCommonModeB_r13_val  [MAX_NUM_CCs];        
+  long  *sib2_interval_ULHoppingConfigCommonModeA_r13      [MAX_NUM_CCs];
+  long  sib2_interval_ULHoppingConfigCommonModeA_r13_val  [MAX_NUM_CCs];         
+  long  *sib2_interval_ULHoppingConfigCommonModeB_r13      [MAX_NUM_CCs];
+  long  sib2_interval_ULHoppingConfigCommonModeB_r13_val  [MAX_NUM_CCs];
+  long  *sib2_mpdcch_pdsch_hoppingOffset_r13               [MAX_NUM_CCs];
+  long  *pdsch_maxNumRepetitionCEmodeA_r13                 [MAX_NUM_CCs];
+  long  *pdsch_maxNumRepetitionCEmodeB_r13                 [MAX_NUM_CCs];
+  long  *pusch_maxNumRepetitionCEmodeA_r13                 [MAX_NUM_CCs];
+  long  *pusch_maxNumRepetitionCEmodeB_r13                 [MAX_NUM_CCs];
+  long  *pusch_HoppingOffset_v1310                         [MAX_NUM_CCs];
+#endif
   //SIB18
   e_LTE_SL_CP_Len_r12            rxPool_sc_CP_Len[MAX_NUM_CCs];
   e_LTE_SL_PeriodComm_r12        rxPool_sc_Period[MAX_NUM_CCs];
@@ -224,9 +315,7 @@ typedef struct RrcConfigurationReq_s {
 
 typedef struct NbIoTRrcConfigurationReq_s {
   uint32_t            cell_identity;
-
   uint16_t            tac;
-
   uint16_t        mcc;
   uint16_t        mnc;
   uint8_t       mnc_digit_length;
diff --git a/openair2/DOCS/DOXYGEN/Doxyfile b/openair2/DOCS/DOXYGEN/Doxyfile
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/DLC_arch.png b/openair2/DOCS/DOXYGEN/images/DLC_arch.png
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/Diapositive6.JPG b/openair2/DOCS/DOXYGEN/images/Diapositive6.JPG
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/Framing.png b/openair2/DOCS/DOXYGEN/images/Framing.png
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/Framing.vsd b/openair2/DOCS/DOXYGEN/images/Framing.vsd
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/MAC Services.vsd b/openair2/DOCS/DOXYGEN/images/MAC Services.vsd
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/MAC_Measurements.png b/openair2/DOCS/DOXYGEN/images/MAC_Measurements.png
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/MAC_Measurements.vsd b/openair2/DOCS/DOXYGEN/images/MAC_Measurements.vsd
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/MAC_Services.eps b/openair2/DOCS/DOXYGEN/images/MAC_Services.eps
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/MAC_Services.vsd b/openair2/DOCS/DOXYGEN/images/MAC_Services.vsd
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/MAC_Services2.eps b/openair2/DOCS/DOXYGEN/images/MAC_Services2.eps
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/MAC_Services2.png b/openair2/DOCS/DOXYGEN/images/MAC_Services2.png
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/MAC_Services2.vsd b/openair2/DOCS/DOXYGEN/images/MAC_Services2.vsd
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/MAC_arch.eps b/openair2/DOCS/DOXYGEN/images/MAC_arch.eps
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/MAC_architecture.JPG b/openair2/DOCS/DOXYGEN/images/MAC_architecture.JPG
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/OFDM Transmitter.png b/openair2/DOCS/DOXYGEN/images/OFDM Transmitter.png
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/OFDM Transmitter.vsd b/openair2/DOCS/DOXYGEN/images/OFDM Transmitter.vsd
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/PHY_arch.eps b/openair2/DOCS/DOXYGEN/images/PHY_arch.eps
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/PHY_arch.png b/openair2/DOCS/DOXYGEN/images/PHY_arch.png
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/PHY_arch.vsd b/openair2/DOCS/DOXYGEN/images/PHY_arch.vsd
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/QAM modulation.png b/openair2/DOCS/DOXYGEN/images/QAM modulation.png
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/QAM modulation.vsd b/openair2/DOCS/DOXYGEN/images/QAM modulation.vsd
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/QAMmodulation.png b/openair2/DOCS/DOXYGEN/images/QAMmodulation.png
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/Transmission.pdf b/openair2/DOCS/DOXYGEN/images/Transmission.pdf
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/cellular_topology.doc b/openair2/DOCS/DOXYGEN/images/cellular_topology.doc
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/cellular_topology.pdf b/openair2/DOCS/DOXYGEN/images/cellular_topology.pdf
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/cellular_topology_small.png b/openair2/DOCS/DOXYGEN/images/cellular_topology_small.png
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/channel server.png b/openair2/DOCS/DOXYGEN/images/channel server.png
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/channel server.vsd b/openair2/DOCS/DOXYGEN/images/channel server.vsd
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/convolutional.png b/openair2/DOCS/DOXYGEN/images/convolutional.png
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/convolutional.vsd b/openair2/DOCS/DOXYGEN/images/convolutional.vsd
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/irs_dcf.jpg b/openair2/DOCS/DOXYGEN/images/irs_dcf.jpg
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/irs_pcf.jpg b/openair2/DOCS/DOXYGEN/images/irs_pcf.jpg
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/layer2_stack.jpg b/openair2/DOCS/DOXYGEN/images/layer2_stack.jpg
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/layer2_stack.pdf b/openair2/DOCS/DOXYGEN/images/layer2_stack.pdf
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/layer2_stack.png b/openair2/DOCS/DOXYGEN/images/layer2_stack.png
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/mac_channels.png b/openair2/DOCS/DOXYGEN/images/mac_channels.png
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/mac_w3g4f_mac_channels.pdf b/openair2/DOCS/DOXYGEN/images/mac_w3g4f_mac_channels.pdf
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/mac_w3g4f_mac_channels.png b/openair2/DOCS/DOXYGEN/images/mac_w3g4f_mac_channels.png
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/mac_w3g4f_mac_channels.vsd b/openair2/DOCS/DOXYGEN/images/mac_w3g4f_mac_channels.vsd
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/mac_wbs.jpg b/openair2/DOCS/DOXYGEN/images/mac_wbs.jpg
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/macphynet.eps b/openair2/DOCS/DOXYGEN/images/macphynet.eps
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/macphynet.png b/openair2/DOCS/DOXYGEN/images/macphynet.png
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/mesh_frame.pdf b/openair2/DOCS/DOXYGEN/images/mesh_frame.pdf
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/mesh_topology.pdf b/openair2/DOCS/DOXYGEN/images/mesh_topology.pdf
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/mesh_topology_small.png b/openair2/DOCS/DOXYGEN/images/mesh_topology_small.png
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/scrambler.png b/openair2/DOCS/DOXYGEN/images/scrambler.png
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/scrambler.vsd b/openair2/DOCS/DOXYGEN/images/scrambler.vsd
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/w3g4f_framing.png b/openair2/DOCS/DOXYGEN/images/w3g4f_framing.png
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/w3g4f_framing.vsd b/openair2/DOCS/DOXYGEN/images/w3g4f_framing.vsd
old mode 100755
new mode 100644
diff --git a/openair2/DOCS/DOXYGEN/images/widens_mac_channels.vsd b/openair2/DOCS/DOXYGEN/images/widens_mac_channels.vsd
old mode 100755
new mode 100644
diff --git a/openair2/ENB_APP/RRC_paramsvalues.h b/openair2/ENB_APP/RRC_paramsvalues.h
index cfab58b451f1677848289309162fc47728c8100e..ea559ff74b8bf9d4bc11447c615d94d07dce1e37 100644
--- a/openair2/ENB_APP/RRC_paramsvalues.h
+++ b/openair2/ENB_APP/RRC_paramsvalues.h
@@ -35,6 +35,8 @@
 #define ENB_CONFIG_STRING_ENB_LIST                      "eNBs"
 /* component carriers configuration section name */		
 #define ENB_CONFIG_STRING_COMPONENT_CARRIERS                            "component_carriers"		 
+#define ENB_CONFIG_STRING_COMPONENT_BR_PARAMETERS                       "br_parameters"
+
 
 #define ENB_CONFIG_STRING_FRAME_TYPE                                    "frame_type"
 #define ENB_CONFIG_STRING_PBCH_REPETITION                               "pbch_repetition"
diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c
index faee587fa99c5e893e1cde81d1799cb4c424698c..e1f995a7b541699c4810dfefb5e531ddfbf812a7 100644
--- a/openair2/ENB_APP/enb_config.c
+++ b/openair2/ENB_APP/enb_config.c
@@ -82,75 +82,17 @@ void RCconfig_flexran() {
   int32_t Nid_cell = 0;
   uint16_t Nid_cell_tr = 0;
   uint32_t enb_id = 0;
+
   /*
-     the only reason for all these variables is, that they are "hard-encoded"
-     into the CCPARAMS_DESC macro and we need it for the Nid_cell variable ...
+  int32_t     srb1_timer_poll_retransmit    = 0;
+  int32_t     srb1_timer_reordering         = 0;
+  int32_t     srb1_timer_status_prohibit    = 0;
+  int32_t     srb1_poll_pdu                 = 0;
+  int32_t     srb1_poll_byte                = 0;
+  int32_t     srb1_max_retx_threshold       = 0;
   */
-  char *frame_type, *prefix_type, *pbch_repetition, *prach_high_speed,
-       *pusch_hoppingMode, *pusch_enable64QAM, *pusch_groupHoppingEnabled,
-       *pusch_sequenceHoppingEnabled, *phich_duration, *phich_resource,
-       *srs_enable, *srs_ackNackST, *srs_MaxUpPts, *pusch_alpha,
-       *pucch_deltaF_Format1, *pucch_deltaF_Format1b, *pucch_deltaF_Format2,
-       *pucch_deltaF_Format2a, *pucch_deltaF_Format2b,
-       *rach_preamblesGroupAConfig, *rach_messagePowerOffsetGroupB, *pcch_nB;
-  long long int     downlink_frequency;
-  int32_t tdd_config, tdd_config_s, eutra_band, uplink_frequency_offset,
-          Nid_cell_mbsfn, N_RB_DL, nb_antenna_ports, prach_root, prach_config_index,
-          prach_zero_correlation, prach_freq_offset, pucch_delta_shift,
-          pucch_nRB_CQI, pucch_nCS_AN, pucch_n1_AN, pdsch_referenceSignalPower,
-          pdsch_p_b, pusch_n_SB, pusch_hoppingOffset, pusch_groupAssignment,
-          pusch_nDMRS1, srs_BandwidthConfig, srs_SubframeConfig, pusch_p0_Nominal,
-          pucch_p0_Nominal, msg3_delta_Preamble, rach_numberOfRA_Preambles,
-          rach_sizeOfRA_PreamblesGroupA, rach_messageSizeGroupA,
-          rach_powerRampingStep, rach_preambleInitialReceivedTargetPower,
-          rach_preambleTransMax, rach_raResponseWindowSize,
-          rach_macContentionResolutionTimer, rach_maxHARQ_Msg3Tx,
-          pcch_defaultPagingCycle, bcch_modificationPeriodCoeff,
-          ue_TimersAndConstants_t300, ue_TimersAndConstants_t301,
-          ue_TimersAndConstants_t310, ue_TimersAndConstants_t311,
-          ue_TimersAndConstants_n310, ue_TimersAndConstants_n311,
-          ue_TransmissionMode, ue_multiple_max;
-  const char       *rxPool_sc_CP_Len;
-  const char       *rxPool_sc_Period;
-  const char       *rxPool_data_CP_Len;
-  libconfig_int     rxPool_ResourceConfig_prb_Num;
-  libconfig_int     rxPool_ResourceConfig_prb_Start;
-  libconfig_int     rxPool_ResourceConfig_prb_End;
-  const char       *rxPool_ResourceConfig_offsetIndicator_present;
-  libconfig_int     rxPool_ResourceConfig_offsetIndicator_choice;
-  const char       *rxPool_ResourceConfig_subframeBitmap_present;
-  char             *rxPool_ResourceConfig_subframeBitmap_choice_bs_buf;
-  libconfig_int     rxPool_ResourceConfig_subframeBitmap_choice_bs_size;
-  libconfig_int     rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused;
-  //SIB19
-  //for discRxPool
-  const char       *discRxPool_cp_Len;
-  const char       *discRxPool_discPeriod;
-  libconfig_int     discRxPool_numRetx;
-  libconfig_int     discRxPool_numRepetition;
-  libconfig_int     discRxPool_ResourceConfig_prb_Num;
-  libconfig_int     discRxPool_ResourceConfig_prb_Start;
-  libconfig_int     discRxPool_ResourceConfig_prb_End;
-  const char       *discRxPool_ResourceConfig_offsetIndicator_present;
-  libconfig_int     discRxPool_ResourceConfig_offsetIndicator_choice;
-  const char       *discRxPool_ResourceConfig_subframeBitmap_present;
-  char             *discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf;
-  libconfig_int     discRxPool_ResourceConfig_subframeBitmap_choice_bs_size;
-  libconfig_int     discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused;
-  //for discRxPoolPS
-  const char       *discRxPoolPS_cp_Len;
-  const char       *discRxPoolPS_discPeriod;
-  libconfig_int     discRxPoolPS_numRetx;
-  libconfig_int     discRxPoolPS_numRepetition;
-  libconfig_int     discRxPoolPS_ResourceConfig_prb_Num;
-  libconfig_int     discRxPoolPS_ResourceConfig_prb_Start;
-  libconfig_int     discRxPoolPS_ResourceConfig_prb_End;
-  const char       *discRxPoolPS_ResourceConfig_offsetIndicator_present;
-  libconfig_int     discRxPoolPS_ResourceConfig_offsetIndicator_choice;
-  const char       *discRxPoolPS_ResourceConfig_subframeBitmap_present;
-  char             *discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf;
-  libconfig_int     discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size;
-  libconfig_int     discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused;
+
+
   /* get number of eNBs */
   paramdef_t ENBSParams[] = ENBSPARAMS_DESC;
   config_get(ENBSParams, sizeof(ENBSParams)/sizeof(paramdef_t), NULL);
@@ -160,9 +102,29 @@ void RCconfig_flexran() {
   paramlist_def_t ENBParamList = {ENB_CONFIG_STRING_ENB_LIST, NULL, 0};
   /* for Nid_cell */
   checkedparam_t config_check_CCparams[] = CCPARAMS_CHECK;
-  paramdef_t CCsParams[] = CCPARAMS_DESC;
+  ccparams_lte_t ccparams_lte;
+  memset((void*)&ccparams_lte,0,sizeof(ccparams_lte_t));
+  paramdef_t CCsParams[] = CCPARAMS_DESC(ccparams_lte);
   paramlist_def_t CCsParamList = {ENB_CONFIG_STRING_COMPONENT_CARRIERS, NULL, 0};
 
+  // Note: these should be turned on for EMTC support inside of FlexRAN
+  // ccparams_emtc_t ccparams_emtc;
+  //paramdef_t brParams[]              = BRPARAMS_DESC(ccparams_emtc);
+  //paramdef_t schedulingInfoBrParams[] = SI_INFO_BR_DESC(ccparams_emtc);
+  //paramlist_def_t schedulingInfoBrParamList = {ENB_CONFIG_STRING_SCHEDULING_INFO_BR, NULL, 0};
+  //paramdef_t rachcelevelParams[]     = RACH_CE_LEVELINFOLIST_R13_DESC(ccparams_emtc);
+  //paramlist_def_t rachcelevellist    = {ENB_CONFIG_STRING_RACH_CE_LEVELINFOLIST_R13, NULL, 0};
+  //paramdef_t rsrprangeParams[]       = RSRP_RANGE_LIST_DESC(ccparams_emtc);
+  //paramlist_def_t rsrprangelist      = {ENB_CONFIG_STRING_RSRP_RANGE_LIST, NULL, 0};
+  //paramdef_t prachParams[]           = PRACH_PARAMS_CE_R13_DESC(ccparams_emtc);
+  //paramlist_def_t prachParamslist    = {ENB_CONFIG_STRING_PRACH_PARAMETERS_CE_R13, NULL, 0};
+  //paramdef_t n1PUCCH_ANR13Params[]   = N1PUCCH_AN_INFOLIST_R13_DESC(ccparams_emtc);
+  //paramlist_def_t n1PUCCHInfoList    = {ENB_CONFIG_STRING_N1PUCCH_AN_INFOLIST_R13, NULL, 0};
+  //paramdef_t pcchv1310Params[]       = PCCH_CONFIG_V1310_DESC(ccparams_emtc);
+  //paramdef_t sib2freqhoppingParams[] = SIB2_FREQ_HOPPING_R13_DESC(ccparams_emtc);
+
+  //  paramdef_t SRB1Params[] = SRB1PARAMS_DESC;
+
   /* map parameter checking array instances to parameter definition array instances */
   for (int I = 0; I < (sizeof(CCsParams) / sizeof(paramdef_t)); I++) {
     CCsParams[I].chkPptr = &(config_check_CCparams[I]);
@@ -225,9 +187,9 @@ void RCconfig_flexran() {
     /* assume for the moment the monolithic case, i.e. agent can provide
        information for all layers */
     RC.flexran[i]->capability_mask = FLEXRAN_CAP_LOPHY | FLEXRAN_CAP_HIPHY
-                                     | FLEXRAN_CAP_LOMAC | FLEXRAN_CAP_HIMAC
-                                     | FLEXRAN_CAP_RLC   | FLEXRAN_CAP_PDCP
-                                     | FLEXRAN_CAP_SDAP  | FLEXRAN_CAP_RRC;
+      | FLEXRAN_CAP_LOMAC | FLEXRAN_CAP_HIMAC
+      | FLEXRAN_CAP_RLC   | FLEXRAN_CAP_PDCP
+      | FLEXRAN_CAP_SDAP  | FLEXRAN_CAP_RRC;
   }
 }
 
@@ -331,6 +293,7 @@ void RCconfig_macrlc() {
     mac_top_init_eNB();
     RC.nb_mac_CC = (int *)malloc(RC.nb_macrlc_inst*sizeof(int));
 
+
     for (j=0; j<RC.nb_macrlc_inst; j++) {
       RC.mac[j]->puSch10xSnr = *(MacRLC_ParamList.paramarray[j][MACRLC_PUSCH10xSNR_IDX ].iptr);
       RC.mac[j]->puCch10xSnr = *(MacRLC_ParamList.paramarray[j][MACRLC_PUCCH10xSNR_IDX ].iptr);
@@ -389,148 +352,48 @@ void RCconfig_macrlc() {
 }
 
 int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) {
+
   int               num_enbs                      = 0;
   int               j,k                           = 0;
-  int32_t     enb_id                        = 0;
+  int32_t           enb_id                        = 0;
   int               nb_cc                         = 0;
-  char       *frame_type                    = NULL;
-  int32_t     tdd_config                    = 0;
-  int32_t     tdd_config_s                  = 0;
-  char       *prefix_type                   = NULL;
-  char       *pbch_repetition               = NULL;
-  int32_t     eutra_band                    = 0;
-  long long int     downlink_frequency            = 0;
-  int32_t     uplink_frequency_offset       = 0;
-  int32_t     Nid_cell                      = 0;
-  int32_t     Nid_cell_mbsfn                = 0;
-  int32_t     N_RB_DL                       = 0;
-  int32_t     nb_antenna_ports              = 0;
-  int32_t     prach_root                    = 0;
-  int32_t     prach_config_index            = 0;
-  char            *prach_high_speed         = NULL;
-  int32_t     prach_zero_correlation        = 0;
-  int32_t     prach_freq_offset             = 0;
-  int32_t     pucch_delta_shift             = 0;
-  int32_t     pucch_nRB_CQI                 = 0;
-  int32_t     pucch_nCS_AN                  = 0;
-  //#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
-  int32_t     pucch_n1_AN                   = 0;
-  //#endif
-  int32_t     pdsch_referenceSignalPower    = 0;
-  int32_t     pdsch_p_b                     = 0;
-  int32_t     pusch_n_SB                    = 0;
-  char       *pusch_hoppingMode             = NULL;
-  int32_t     pusch_hoppingOffset           = 0;
-  char          *pusch_enable64QAM          = NULL;
-  char          *pusch_groupHoppingEnabled  = NULL;
-  int32_t     pusch_groupAssignment         = 0;
-  char          *pusch_sequenceHoppingEnabled = NULL;
-  int32_t     pusch_nDMRS1                  = 0;
-  char       *phich_duration                = NULL;
-  char       *phich_resource                = NULL;
-  char       *srs_enable                    = NULL;
-  int32_t     srs_BandwidthConfig           = 0;
-  int32_t     srs_SubframeConfig            = 0;
-  char       *srs_ackNackST                 = NULL;
-  char       *srs_MaxUpPts                  = NULL;
-  int32_t     pusch_p0_Nominal              = 0;
-  char       *pusch_alpha                   = NULL;
-  int32_t     pucch_p0_Nominal              = 0;
-  int32_t     msg3_delta_Preamble           = 0;
-  //int32_t     ul_CyclicPrefixLength         = 0;
-  char       *pucch_deltaF_Format1          = NULL;
-  //const char*       pucch_deltaF_Format1a         = NULL;
-  char       *pucch_deltaF_Format1b         = NULL;
-  char       *pucch_deltaF_Format2          = NULL;
-  char       *pucch_deltaF_Format2a         = NULL;
-  char       *pucch_deltaF_Format2b         = NULL;
-  int32_t     rach_numberOfRA_Preambles     = 0;
-  char       *rach_preamblesGroupAConfig    = NULL;
-  int32_t     rach_sizeOfRA_PreamblesGroupA = 0;
-  int32_t     rach_messageSizeGroupA        = 0;
-  char       *rach_messagePowerOffsetGroupB = NULL;
-  int32_t     rach_powerRampingStep         = 0;
-  int32_t     rach_preambleInitialReceivedTargetPower    = 0;
-  int32_t     rach_preambleTransMax         = 0;
-  int32_t     rach_raResponseWindowSize     = 10;
-  int32_t     rach_macContentionResolutionTimer = 0;
-  int32_t     rach_maxHARQ_Msg3Tx           = 0;
-  int32_t     pcch_defaultPagingCycle       = 0;
-  char       *pcch_nB                       = NULL;
-  int32_t     bcch_modificationPeriodCoeff  = 0;
-  int32_t     ue_TimersAndConstants_t300    = 0;
-  int32_t     ue_TimersAndConstants_t301    = 0;
-  int32_t     ue_TimersAndConstants_t310    = 0;
-  int32_t     ue_TimersAndConstants_t311    = 0;
-  int32_t     ue_TimersAndConstants_n310    = 0;
-  int32_t     ue_TimersAndConstants_n311    = 0;
-  int32_t     ue_TransmissionMode           = 0;
-  int32_t     ue_multiple_max               = 0;
-  //TTN - for D2D
-  //SIB18
-  const char       *rxPool_sc_CP_Len                                        = NULL;
-  const char       *rxPool_sc_Period                                        = NULL;
-  const char       *rxPool_data_CP_Len                                      = NULL;
-  libconfig_int     rxPool_ResourceConfig_prb_Num                           = 0;
-  libconfig_int     rxPool_ResourceConfig_prb_Start                         = 0;
-  libconfig_int     rxPool_ResourceConfig_prb_End                           = 0;
-  const char       *rxPool_ResourceConfig_offsetIndicator_present           = NULL;
-  libconfig_int     rxPool_ResourceConfig_offsetIndicator_choice            = 0;
-  const char       *rxPool_ResourceConfig_subframeBitmap_present            = NULL;
-  char             *rxPool_ResourceConfig_subframeBitmap_choice_bs_buf      = NULL;
-  libconfig_int     rxPool_ResourceConfig_subframeBitmap_choice_bs_size     = 0;
-  libconfig_int     rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused     = 0;
-  //SIB19
-  //For discRxPool
-  const char       *discRxPool_cp_Len                                              = NULL;
-  const char       *discRxPool_discPeriod                                          = NULL;
-  libconfig_int     discRxPool_numRetx                                             = 0;
-  libconfig_int     discRxPool_numRepetition                                       = 0;
-  libconfig_int     discRxPool_ResourceConfig_prb_Num                              = 0;
-  libconfig_int     discRxPool_ResourceConfig_prb_Start                            = 0;
-  libconfig_int     discRxPool_ResourceConfig_prb_End                              = 0;
-  const char       *discRxPool_ResourceConfig_offsetIndicator_present              = NULL;
-  libconfig_int     discRxPool_ResourceConfig_offsetIndicator_choice               = 0;
-  const char       *discRxPool_ResourceConfig_subframeBitmap_present               = NULL;
-  char             *discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf         = NULL;
-  libconfig_int     discRxPool_ResourceConfig_subframeBitmap_choice_bs_size        = 0;
-  libconfig_int     discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0;
-  //For discRxPoolPS
-  const char       *discRxPoolPS_cp_Len                                              = NULL;
-  const char       *discRxPoolPS_discPeriod                                          = NULL;
-  libconfig_int     discRxPoolPS_numRetx                                             = 0;
-  libconfig_int     discRxPoolPS_numRepetition                                       = 0;
-  libconfig_int     discRxPoolPS_ResourceConfig_prb_Num                              = 0;
-  libconfig_int     discRxPoolPS_ResourceConfig_prb_Start                            = 0;
-  libconfig_int     discRxPoolPS_ResourceConfig_prb_End                              = 0;
-  const char       *discRxPoolPS_ResourceConfig_offsetIndicator_present              = NULL;
-  libconfig_int     discRxPoolPS_ResourceConfig_offsetIndicator_choice               = 0;
-  const char       *discRxPoolPS_ResourceConfig_subframeBitmap_present               = NULL;
-  char             *discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf         = NULL;
-  libconfig_int     discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size        = 0;
-  libconfig_int     discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0;
-  int32_t     srb1_timer_poll_retransmit    = 0;
-  int32_t     srb1_timer_reordering         = 0;
-  int32_t     srb1_timer_status_prohibit    = 0;
-  int32_t     srb1_poll_pdu                 = 0;
-  int32_t     srb1_poll_byte                = 0;
-  int32_t     srb1_max_retx_threshold       = 0;
-  int32_t     my_int;
-  // for no gcc warnings
-  (void)my_int;
+  ccparams_lte_t ccparams_lte;
+  ccparams_sidelink_t SLconfig;
+  ccparams_eMTC_t eMTCconfig;
+
+  memset((void*)&ccparams_lte,0,sizeof(ccparams_lte_t));
+  memset((void*)&SLconfig,0,sizeof(ccparams_sidelink_t));
+  memset((void*)&eMTCconfig,0,sizeof(ccparams_eMTC_t));
+
+
   paramdef_t ENBSParams[] = ENBSPARAMS_DESC;
   paramdef_t ENBParams[]  = ENBPARAMS_DESC;
   paramlist_def_t ENBParamList = {ENB_CONFIG_STRING_ENB_LIST,NULL,0};
   checkedparam_t config_check_CCparams[] = CCPARAMS_CHECK;
-  paramdef_t CCsParams[] = CCPARAMS_DESC;
+  paramdef_t CCsParams[] = CCPARAMS_DESC(ccparams_lte);
   paramlist_def_t CCsParamList = {ENB_CONFIG_STRING_COMPONENT_CARRIERS,NULL,0};
-  paramdef_t SRB1Params[] = SRB1PARAMS_DESC;
+
+  paramdef_t eMTCParams[]              = EMTCPARAMS_DESC((&eMTCconfig));
+  checkedparam_t config_check_eMTCparams[] = EMTCPARAMS_CHECK;
+
+  srb1_params_t srb1_params;
+  memset((void*)&srb1_params,0,sizeof(srb1_params_t));
+  paramdef_t SRB1Params[] = SRB1PARAMS_DESC(srb1_params);
+
+
+  paramdef_t SLParams[]              = CCPARAMS_SIDELINK_DESC(SLconfig);
+
 
   /* map parameter checking array instances to parameter definition array instances */
   for (int I=0; I< ( sizeof(CCsParams)/ sizeof(paramdef_t)  ) ; I++) {
     CCsParams[I].chkPptr = &(config_check_CCparams[I]);
   }
 
+
+  for (int I = 0; I < (sizeof(CCsParams) / sizeof(paramdef_t)); I++) {
+    eMTCParams[I].chkPptr = &(config_check_eMTCparams[I]);
+  }
+
   /* get global parameters, defined outside any section in the config file */
   config_get( ENBSParams,sizeof(ENBSParams)/sizeof(paramdef_t),NULL);
   num_enbs = ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt;
@@ -626,104 +489,82 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) {
             config_get( CCsParams,sizeof(CCsParams)/sizeof(paramdef_t),ccspath);
             //printf("Component carrier %d\n",component_carrier);
             nb_cc++;
-            RRC_CONFIGURATION_REQ (msg_p).tdd_config[j] = tdd_config;
-            AssertFatal (tdd_config <= LTE_TDD_Config__subframeAssignment_sa6,
+
+            RRC_CONFIGURATION_REQ (msg_p).tdd_config[j] = ccparams_lte.tdd_config;
+            AssertFatal (ccparams_lte.tdd_config <= LTE_TDD_Config__subframeAssignment_sa6,
                          "Failed to parse eNB configuration file %s, enb %d illegal tdd_config %d (should be 0-%d)!",
-                         RC.config_file_name, i, tdd_config, LTE_TDD_Config__subframeAssignment_sa6);
-            RRC_CONFIGURATION_REQ (msg_p).tdd_config_s[j] = tdd_config_s;
-            AssertFatal (tdd_config_s <= LTE_TDD_Config__specialSubframePatterns_ssp8,
+                         RC.config_file_name, i, ccparams_lte.tdd_config, LTE_TDD_Config__subframeAssignment_sa6);
+            RRC_CONFIGURATION_REQ (msg_p).tdd_config_s[j] = ccparams_lte.tdd_config_s;
+            AssertFatal (ccparams_lte.tdd_config_s <= LTE_TDD_Config__specialSubframePatterns_ssp8,
                          "Failed to parse eNB configuration file %s, enb %d illegal tdd_config_s %d (should be 0-%d)!",
-                         RC.config_file_name, i, tdd_config_s, LTE_TDD_Config__specialSubframePatterns_ssp8);
-
-            if (!prefix_type)
+                         RC.config_file_name, i, ccparams_lte.tdd_config_s, LTE_TDD_Config__specialSubframePatterns_ssp8);
+            if (!ccparams_lte.prefix_type)
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d define %s: NORMAL,EXTENDED!\n",
                            RC.config_file_name, i, ENB_CONFIG_STRING_PREFIX_TYPE);
-            else if (strcmp(prefix_type, "NORMAL") == 0) {
+            else if (strcmp(ccparams_lte.prefix_type, "NORMAL") == 0) {
               RRC_CONFIGURATION_REQ (msg_p).prefix_type[j] = NORMAL;
-            } else  if (strcmp(prefix_type, "EXTENDED") == 0) {
+            } else  if (strcmp(ccparams_lte.prefix_type, "EXTENDED") == 0) {
               RRC_CONFIGURATION_REQ (msg_p).prefix_type[j] = EXTENDED;
             } else {
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for prefix_type choice: NORMAL or EXTENDED !\n",
-                           RC.config_file_name, i, prefix_type);
+                           RC.config_file_name, i, ccparams_lte.prefix_type);
             }
 
 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
 
-            if (!pbch_repetition)
+            if (!ccparams_lte.pbch_repetition)
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d define %s: TRUE,FALSE!\n",
                            RC.config_file_name, i, ENB_CONFIG_STRING_PBCH_REPETITION);
-            else if (strcmp(pbch_repetition, "TRUE") == 0) {
+            else if (strcmp(ccparams_lte.pbch_repetition, "TRUE") == 0) {
               RRC_CONFIGURATION_REQ (msg_p).pbch_repetition[j] = 1;
-            } else  if (strcmp(pbch_repetition, "FALSE") == 0) {
+            } else  if (strcmp(ccparams_lte.pbch_repetition, "FALSE") == 0) {
               RRC_CONFIGURATION_REQ (msg_p).pbch_repetition[j] = 0;
             } else {
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pbch_repetition choice: TRUE or FALSE !\n",
-                           RC.config_file_name, i, pbch_repetition);
+                           RC.config_file_name, i, ccparams_lte.pbch_repetition);
             }
 
 #endif
-            RRC_CONFIGURATION_REQ (msg_p).eutra_band[j] = eutra_band;
-            RRC_CONFIGURATION_REQ (msg_p).downlink_frequency[j] = (uint32_t) downlink_frequency;
-            RRC_CONFIGURATION_REQ (msg_p).uplink_frequency_offset[j] = (unsigned int) uplink_frequency_offset;
-            RRC_CONFIGURATION_REQ (msg_p).Nid_cell[j]= Nid_cell;
+            RRC_CONFIGURATION_REQ (msg_p).eutra_band[j] = ccparams_lte.eutra_band;
+            RRC_CONFIGURATION_REQ (msg_p).downlink_frequency[j] = (uint32_t) ccparams_lte.downlink_frequency;
+            RRC_CONFIGURATION_REQ (msg_p).uplink_frequency_offset[j] = (unsigned int) ccparams_lte.uplink_frequency_offset;
+
+
+            RRC_CONFIGURATION_REQ (msg_p).Nid_cell[j]= ccparams_lte.Nid_cell;
 
-            if (Nid_cell>503) {
+            if (ccparams_lte.Nid_cell>503) {
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for Nid_cell choice: 0...503 !\n",
-                           RC.config_file_name, i, Nid_cell);
+                           RC.config_file_name, i, ccparams_lte.Nid_cell);
             }
 
-            RRC_CONFIGURATION_REQ (msg_p).N_RB_DL[j]= N_RB_DL;
+            RRC_CONFIGURATION_REQ (msg_p).N_RB_DL[j]= ccparams_lte.N_RB_DL;
 
-            if ((N_RB_DL!=6) && (N_RB_DL!=15) && (N_RB_DL!=25) && (N_RB_DL!=50) && (N_RB_DL!=75) && (N_RB_DL!=100)) {
+            if ((ccparams_lte.N_RB_DL!=6) && 
+		(ccparams_lte.N_RB_DL!=15) && 
+		(ccparams_lte.N_RB_DL!=25) && 
+		(ccparams_lte.N_RB_DL!=50) && 
+		(ccparams_lte.N_RB_DL!=75) && 
+		(ccparams_lte.N_RB_DL!=100)) {
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for N_RB_DL choice: 6,15,25,50,75,100 !\n",
-                           RC.config_file_name, i, N_RB_DL);
+                           RC.config_file_name, i, ccparams_lte.N_RB_DL);
             }
 
-            if (strcmp(frame_type, "FDD") == 0) {
+            if (strcmp(ccparams_lte.frame_type, "FDD") == 0) {
               RRC_CONFIGURATION_REQ (msg_p).frame_type[j] = FDD;
-            } else  if (strcmp(frame_type, "TDD") == 0) {
+            } else  if (strcmp(ccparams_lte.frame_type, "TDD") == 0) {
               RRC_CONFIGURATION_REQ (msg_p).frame_type[j] = TDD;
             } else {
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for frame_type choice: FDD or TDD !\n",
-                           RC.config_file_name, i, frame_type);
-            }
-
-            RRC_CONFIGURATION_REQ (msg_p).tdd_config[j] = tdd_config;
-            AssertFatal (tdd_config <= LTE_TDD_Config__subframeAssignment_sa6,
-                         "Failed to parse eNB configuration file %s, enb %d illegal tdd_config %d (should be 0-%d)!",
-                         RC.config_file_name, i, tdd_config, LTE_TDD_Config__subframeAssignment_sa6);
-            RRC_CONFIGURATION_REQ (msg_p).tdd_config_s[j] = tdd_config_s;
-            AssertFatal (tdd_config_s <= LTE_TDD_Config__specialSubframePatterns_ssp8,
-                         "Failed to parse eNB configuration file %s, enb %d illegal tdd_config_s %d (should be 0-%d)!",
-                         RC.config_file_name, i, tdd_config_s, LTE_TDD_Config__specialSubframePatterns_ssp8);
-
-            if (!prefix_type)
-              AssertFatal (0,
-                           "Failed to parse eNB configuration file %s, enb %d define %s: NORMAL,EXTENDED!\n",
-                           RC.config_file_name, i, ENB_CONFIG_STRING_PREFIX_TYPE);
-            else if (strcmp(prefix_type, "NORMAL") == 0) {
-              RRC_CONFIGURATION_REQ (msg_p).prefix_type[j] = NORMAL;
-            } else  if (strcmp(prefix_type, "EXTENDED") == 0) {
-              RRC_CONFIGURATION_REQ (msg_p).prefix_type[j] = EXTENDED;
-            } else {
-              AssertFatal (0,
-                           "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for prefix_type choice: NORMAL or EXTENDED !\n",
-                           RC.config_file_name, i, prefix_type);
+                           RC.config_file_name, i, ccparams_lte.frame_type);
             }
 
-            RRC_CONFIGURATION_REQ (msg_p).eutra_band[j] = eutra_band;
-            // printf( "\teutra band:\t%d\n",RRC_CONFIGURATION_REQ (msg_p).eutra_band);
-            RRC_CONFIGURATION_REQ (msg_p).downlink_frequency[j] = (uint32_t) downlink_frequency;
-            //printf( "\tdownlink freq:\t%u\n",RRC_CONFIGURATION_REQ (msg_p).downlink_frequency);
-            RRC_CONFIGURATION_REQ (msg_p).uplink_frequency_offset[j] = (unsigned int) uplink_frequency_offset;
-
             if (config_check_band_frequencies(j,
                                               RRC_CONFIGURATION_REQ (msg_p).eutra_band[j],
                                               RRC_CONFIGURATION_REQ (msg_p).downlink_frequency[j],
@@ -732,1284 +573,1151 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) {
               AssertFatal(0, "error calling enb_check_band_frequencies\n");
             }
 
-            if ((nb_antenna_ports <1) || (nb_antenna_ports > 2))
+
+            if ((ccparams_lte.nb_antenna_ports <1) || (ccparams_lte.nb_antenna_ports > 2))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for nb_antenna_ports choice: 1..2 !\n",
-                           RC.config_file_name, i, nb_antenna_ports);
+                           RC.config_file_name, i, ccparams_lte.nb_antenna_ports);
+
+            RRC_CONFIGURATION_REQ (msg_p).nb_antenna_ports[j] = ccparams_lte.nb_antenna_ports;
 
-            RRC_CONFIGURATION_REQ (msg_p).nb_antenna_ports[j] = nb_antenna_ports;
-            RRC_CONFIGURATION_REQ (msg_p).prach_root[j] =  prach_root;
+	    // Radio Resource Configuration (SIB2)
 
-            if ((prach_root <0) || (prach_root > 1023))
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].prach_root =  ccparams_lte.prach_root;
+
+            if ((ccparams_lte.prach_root <0) || (ccparams_lte.prach_root > 1023))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_root choice: 0..1023 !\n",
-                           RC.config_file_name, i, prach_root);
+                           RC.config_file_name, i, ccparams_lte.prach_root);
 
-            RRC_CONFIGURATION_REQ (msg_p).prach_config_index[j] = prach_config_index;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].prach_config_index = ccparams_lte.prach_config_index;
 
-            if ((prach_config_index <0) || (prach_config_index > 63))
+            if ((ccparams_lte.prach_config_index <0) || (ccparams_lte.prach_config_index > 63))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_config_index choice: 0..1023 !\n",
-                           RC.config_file_name, i, prach_config_index);
+                           RC.config_file_name, i, ccparams_lte.prach_config_index);
 
-            if (!prach_high_speed)
+            if (!ccparams_lte.prach_high_speed)
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n",
                            RC.config_file_name, i, ENB_CONFIG_STRING_PRACH_HIGH_SPEED);
-            else if (strcmp(prach_high_speed, "ENABLE") == 0) {
-              RRC_CONFIGURATION_REQ (msg_p).prach_high_speed[j] = TRUE;
-            } else if (strcmp(prach_high_speed, "DISABLE") == 0) {
-              RRC_CONFIGURATION_REQ (msg_p).prach_high_speed[j] = FALSE;
+            else if (strcmp(ccparams_lte.prach_high_speed, "ENABLE") == 0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].prach_high_speed = TRUE;
+            } else if (strcmp(ccparams_lte.prach_high_speed, "DISABLE") == 0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].prach_high_speed = FALSE;
             } else
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for prach_config choice: ENABLE,DISABLE !\n",
-                           RC.config_file_name, i, prach_high_speed);
+                           RC.config_file_name, i, ccparams_lte.prach_high_speed);
 
-            RRC_CONFIGURATION_REQ (msg_p).prach_zero_correlation[j] =prach_zero_correlation;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].prach_zero_correlation = ccparams_lte.prach_zero_correlation;
 
-            if ((prach_zero_correlation <0) || (prach_zero_correlation > 15))
+            if ((ccparams_lte.prach_zero_correlation <0) || 
+		(ccparams_lte.prach_zero_correlation > 15))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_zero_correlation choice: 0..15!\n",
-                           RC.config_file_name, i, prach_zero_correlation);
+                           RC.config_file_name, i, ccparams_lte.prach_zero_correlation);
 
-            RRC_CONFIGURATION_REQ (msg_p).prach_freq_offset[j] = prach_freq_offset;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].prach_freq_offset = ccparams_lte.prach_freq_offset;
 
-            if ((prach_freq_offset <0) || (prach_freq_offset > 94))
+            if ((ccparams_lte.prach_freq_offset <0) || 
+		(ccparams_lte.prach_freq_offset > 94))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_freq_offset choice: 0..94!\n",
-                           RC.config_file_name, i, prach_freq_offset);
+                           RC.config_file_name, i, ccparams_lte.prach_freq_offset);
 
-            RRC_CONFIGURATION_REQ (msg_p).pucch_delta_shift[j] = pucch_delta_shift-1;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_delta_shift = ccparams_lte.pucch_delta_shift-1;
 
-            if ((pucch_delta_shift <1) || (pucch_delta_shift > 3))
+            if ((ccparams_lte.pucch_delta_shift <1) || 
+		(ccparams_lte.pucch_delta_shift > 3))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_delta_shift choice: 1..3!\n",
-                           RC.config_file_name, i, pucch_delta_shift);
+                           RC.config_file_name, i, ccparams_lte.pucch_delta_shift);
 
-            RRC_CONFIGURATION_REQ (msg_p).pucch_nRB_CQI[j] = pucch_nRB_CQI;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_nRB_CQI = ccparams_lte.pucch_nRB_CQI;
 
-            if ((pucch_nRB_CQI <0) || (pucch_nRB_CQI > 98))
+            if ((ccparams_lte.pucch_nRB_CQI <0) || 
+		(ccparams_lte.pucch_nRB_CQI > 98))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_nRB_CQI choice: 0..98!\n",
-                           RC.config_file_name, i, pucch_nRB_CQI);
+                           RC.config_file_name, i, ccparams_lte.pucch_nRB_CQI);
 
-            RRC_CONFIGURATION_REQ (msg_p).pucch_nCS_AN[j] = pucch_nCS_AN;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_nCS_AN = ccparams_lte.pucch_nCS_AN;
 
-            if ((pucch_nCS_AN <0) || (pucch_nCS_AN > 7))
+            if ((ccparams_lte.pucch_nCS_AN <0) || 
+		(ccparams_lte.pucch_nCS_AN > 7))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_nCS_AN choice: 0..7!\n",
-                           RC.config_file_name, i, pucch_nCS_AN);
+                           RC.config_file_name, i, ccparams_lte.pucch_nCS_AN);
+
 
             //#if (LTE_RRC_VERSION < MAKE_VERSION(10, 0, 0))
-            RRC_CONFIGURATION_REQ (msg_p).pucch_n1_AN[j] = pucch_n1_AN;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_n1_AN = ccparams_lte.pucch_n1_AN;
 
-            if ((pucch_n1_AN <0) || (pucch_n1_AN > 2047))
+            if ((ccparams_lte.pucch_n1_AN <0) || 
+		(ccparams_lte.pucch_n1_AN > 2047))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_n1_AN choice: 0..2047!\n",
-                           RC.config_file_name, i, pucch_n1_AN);
+                           RC.config_file_name, i, ccparams_lte.pucch_n1_AN);
 
             //#endif
-            RRC_CONFIGURATION_REQ (msg_p).pdsch_referenceSignalPower[j] = pdsch_referenceSignalPower;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pdsch_referenceSignalPower = ccparams_lte.pdsch_referenceSignalPower;
 
-            if ((pdsch_referenceSignalPower <-60) || (pdsch_referenceSignalPower > 50))
+            if ((ccparams_lte.pdsch_referenceSignalPower <-60) || 
+		(ccparams_lte.pdsch_referenceSignalPower > 50))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pdsch_referenceSignalPower choice:-60..50!\n",
-                           RC.config_file_name, i, pdsch_referenceSignalPower);
+                           RC.config_file_name, i, ccparams_lte.pdsch_referenceSignalPower);
 
-            RRC_CONFIGURATION_REQ (msg_p).pdsch_p_b[j] = pdsch_p_b;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pdsch_p_b = ccparams_lte.pdsch_p_b;
 
-            if ((pdsch_p_b <0) || (pdsch_p_b > 3))
+            if ((ccparams_lte.pdsch_p_b <0) || 
+		(ccparams_lte.pdsch_p_b > 3))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pdsch_p_b choice: 0..3!\n",
-                           RC.config_file_name, i, pdsch_p_b);
+                           RC.config_file_name, i, ccparams_lte.pdsch_p_b);
 
-            RRC_CONFIGURATION_REQ (msg_p).pusch_n_SB[j] = pusch_n_SB;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_n_SB = ccparams_lte.pusch_n_SB;
 
-            if ((pusch_n_SB <1) || (pusch_n_SB > 4))
+            if ((ccparams_lte.pusch_n_SB <1) || 
+		(ccparams_lte.pusch_n_SB > 4))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_n_SB choice: 1..4!\n",
-                           RC.config_file_name, i, pusch_n_SB);
+                           RC.config_file_name, i, ccparams_lte.pusch_n_SB);
 
-            if (!pusch_hoppingMode)
+            if (!ccparams_lte.pusch_hoppingMode)
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d define %s: interSubframe,intraAndInterSubframe!\n",
                            RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_HOPPINGMODE);
-            else if (strcmp(pusch_hoppingMode,"interSubFrame")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_hoppingMode[j] = LTE_PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_interSubFrame;
-            }  else if (strcmp(pusch_hoppingMode,"intraAndInterSubFrame")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_hoppingMode[j] = LTE_PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_intraAndInterSubFrame;
+
+            else if (strcmp(ccparams_lte.pusch_hoppingMode,"interSubFrame")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_hoppingMode = LTE_PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_interSubFrame;
+            }  
+	    else if (strcmp(ccparams_lte.pusch_hoppingMode,"intraAndInterSubFrame")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_hoppingMode = LTE_PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_intraAndInterSubFrame;
             } else
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_hoppingMode choice: interSubframe,intraAndInterSubframe!\n",
-                           RC.config_file_name, i, pusch_hoppingMode);
+                           RC.config_file_name, i, ccparams_lte.pusch_hoppingMode);
 
-            RRC_CONFIGURATION_REQ (msg_p).pusch_hoppingOffset[j] = pusch_hoppingOffset;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_hoppingOffset = ccparams_lte.pusch_hoppingOffset;
 
-            if ((pusch_hoppingOffset<0) || (pusch_hoppingOffset>98))
+            if ((ccparams_lte.pusch_hoppingOffset<0) || 
+		(ccparams_lte.pusch_hoppingOffset>98))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_hoppingOffset choice: 0..98!\n",
-                           RC.config_file_name, i, pusch_hoppingMode);
+                           RC.config_file_name, i, ccparams_lte.pusch_hoppingMode);
 
-            if (!pusch_enable64QAM)
+            if (!ccparams_lte.pusch_enable64QAM)
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n",
                            RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_ENABLE64QAM);
-            else if (strcmp(pusch_enable64QAM, "ENABLE") == 0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_enable64QAM[j] = TRUE;
-            }  else if (strcmp(pusch_enable64QAM, "DISABLE") == 0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_enable64QAM[j] = FALSE;
-            } else
+            else if (strcmp(ccparams_lte.pusch_enable64QAM, "ENABLE") == 0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_enable64QAM = TRUE;
+            }  
+	    else if (strcmp(ccparams_lte.pusch_enable64QAM, "DISABLE") == 0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_enable64QAM = FALSE;
+            } 
+	    else
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_enable64QAM choice: ENABLE,DISABLE!\n",
-                           RC.config_file_name, i, pusch_enable64QAM);
+                           RC.config_file_name, i, ccparams_lte.pusch_enable64QAM);
 
-            if (!pusch_groupHoppingEnabled)
+            if (!ccparams_lte.pusch_groupHoppingEnabled)
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n",
                            RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_GROUP_HOPPING_EN);
-            else if (strcmp(pusch_groupHoppingEnabled, "ENABLE") == 0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_groupHoppingEnabled[j] = TRUE;
-            }  else if (strcmp(pusch_groupHoppingEnabled, "DISABLE") == 0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_groupHoppingEnabled[j] = FALSE;
-            } else
+            else if (strcmp(ccparams_lte.pusch_groupHoppingEnabled, "ENABLE") == 0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_groupHoppingEnabled = TRUE;
+            }  
+	    else if (strcmp(ccparams_lte.pusch_groupHoppingEnabled, "DISABLE") == 0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_groupHoppingEnabled= FALSE;
+            } 
+	    else
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_groupHoppingEnabled choice: ENABLE,DISABLE!\n",
-                           RC.config_file_name, i, pusch_groupHoppingEnabled);
+                           RC.config_file_name, i, ccparams_lte.pusch_groupHoppingEnabled);
 
-            RRC_CONFIGURATION_REQ (msg_p).pusch_groupAssignment[j] = pusch_groupAssignment;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_groupAssignment = ccparams_lte.pusch_groupAssignment;
 
-            if ((pusch_groupAssignment<0)||(pusch_groupAssignment>29))
+            if ((ccparams_lte.pusch_groupAssignment<0)||
+		(ccparams_lte.pusch_groupAssignment>29))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_groupAssignment choice: 0..29!\n",
-                           RC.config_file_name, i, pusch_groupAssignment);
+                           RC.config_file_name, i, ccparams_lte.pusch_groupAssignment);
 
-            if (!pusch_sequenceHoppingEnabled)
+            if (!ccparams_lte.pusch_sequenceHoppingEnabled)
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n",
                            RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_SEQUENCE_HOPPING_EN);
-            else if (strcmp(pusch_sequenceHoppingEnabled, "ENABLE") == 0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_sequenceHoppingEnabled[j] = TRUE;
-            }  else if (strcmp(pusch_sequenceHoppingEnabled, "DISABLE") == 0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_sequenceHoppingEnabled[j] = FALSE;
+            else if (strcmp(ccparams_lte.pusch_sequenceHoppingEnabled, "ENABLE") == 0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_sequenceHoppingEnabled = TRUE;
+            }  
+	    else if (strcmp(ccparams_lte.pusch_sequenceHoppingEnabled, "DISABLE") == 0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_sequenceHoppingEnabled = FALSE;
             } else
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_sequenceHoppingEnabled choice: ENABLE,DISABLE!\n",
-                           RC.config_file_name, i, pusch_sequenceHoppingEnabled);
+                           RC.config_file_name, i, ccparams_lte.pusch_sequenceHoppingEnabled);
 
-            RRC_CONFIGURATION_REQ (msg_p).pusch_nDMRS1[j] = pusch_nDMRS1;  //cyclic_shift in RRC!
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_nDMRS1= ccparams_lte.pusch_nDMRS1;  //cyclic_shift in RRC!
 
-            if ((pusch_nDMRS1 <0) || (pusch_nDMRS1>7))
+            if ((ccparams_lte.pusch_nDMRS1 <0) || 
+		(ccparams_lte.pusch_nDMRS1>7))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_nDMRS1 choice: 0..7!\n",
-                           RC.config_file_name, i, pusch_nDMRS1);
+                           RC.config_file_name, i, ccparams_lte.pusch_nDMRS1);
 
-            if (strcmp(phich_duration,"NORMAL")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).phich_duration[j] = LTE_PHICH_Config__phich_Duration_normal;
-            } else if (strcmp(phich_duration,"EXTENDED")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).phich_duration[j] = LTE_PHICH_Config__phich_Duration_extended;
+
+            if (strcmp(ccparams_lte.phich_duration,"NORMAL")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_duration= LTE_PHICH_Config__phich_Duration_normal;
+            } else if (strcmp(ccparams_lte.phich_duration,"EXTENDED")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_duration= LTE_PHICH_Config__phich_Duration_extended;
             } else
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for phich_duration choice: NORMAL,EXTENDED!\n",
-                           RC.config_file_name, i, phich_duration);
-
-            if (strcmp(phich_resource,"ONESIXTH")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).phich_resource[j] = LTE_PHICH_Config__phich_Resource_oneSixth ;
-            } else if (strcmp(phich_resource,"HALF")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).phich_resource[j] = LTE_PHICH_Config__phich_Resource_half;
-            } else if (strcmp(phich_resource,"ONE")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).phich_resource[j] = LTE_PHICH_Config__phich_Resource_one;
-            } else if (strcmp(phich_resource,"TWO")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).phich_resource[j] = LTE_PHICH_Config__phich_Resource_two;
-            } else
+                           RC.config_file_name, i, ccparams_lte.phich_duration);
+
+            if (strcmp(ccparams_lte.phich_resource,"ONESIXTH")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_resource= LTE_PHICH_Config__phich_Resource_oneSixth ;
+            } 
+	    else if (strcmp(ccparams_lte.phich_resource,"HALF")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_resource= LTE_PHICH_Config__phich_Resource_half;
+            } 
+	    else if (strcmp(ccparams_lte.phich_resource,"ONE")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_resource= LTE_PHICH_Config__phich_Resource_one;
+            } 
+	    else if (strcmp(ccparams_lte.phich_resource,"TWO")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_resource= LTE_PHICH_Config__phich_Resource_two;
+            } 
+	    else
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for phich_resource choice: ONESIXTH,HALF,ONE,TWO!\n",
-                           RC.config_file_name, i, phich_resource);
+                           RC.config_file_name, i, ccparams_lte.phich_resource);
 
             printf("phich.resource %ld (%s), phich.duration %ld (%s)\n",
-                   RRC_CONFIGURATION_REQ (msg_p).phich_resource[j],phich_resource,
-                   RRC_CONFIGURATION_REQ (msg_p).phich_duration[j],phich_duration);
+                   RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_resource,ccparams_lte.phich_resource,
+                   RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_duration,ccparams_lte.phich_duration);
 
-            if (strcmp(srs_enable, "ENABLE") == 0) {
-              RRC_CONFIGURATION_REQ (msg_p).srs_enable[j] = TRUE;
-            } else if (strcmp(srs_enable, "DISABLE") == 0) {
-              RRC_CONFIGURATION_REQ (msg_p).srs_enable[j] = FALSE;
-            } else
+            if (strcmp(ccparams_lte.srs_enable, "ENABLE") == 0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_enable= TRUE;
+            } 
+	    else if (strcmp(ccparams_lte.srs_enable, "DISABLE") == 0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_enable= FALSE;
+            } 
+	    else
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for srs_BandwidthConfig choice: ENABLE,DISABLE !\n",
-                           RC.config_file_name, i, srs_enable);
+                           RC.config_file_name, i, ccparams_lte.srs_enable);
 
-            if (RRC_CONFIGURATION_REQ (msg_p).srs_enable[j] == TRUE) {
-              RRC_CONFIGURATION_REQ (msg_p).srs_BandwidthConfig[j] = srs_BandwidthConfig;
+            if (RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_enable== TRUE) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_BandwidthConfig= ccparams_lte.srs_BandwidthConfig;
 
-              if ((srs_BandwidthConfig < 0) || (srs_BandwidthConfig >7))
+              if ((ccparams_lte.srs_BandwidthConfig < 0) || 
+		  (ccparams_lte.srs_BandwidthConfig >7))
                 AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value %d for srs_BandwidthConfig choice: 0...7\n",
-                             RC.config_file_name, i, srs_BandwidthConfig);
+                             RC.config_file_name, i, ccparams_lte.srs_BandwidthConfig);
 
-              RRC_CONFIGURATION_REQ (msg_p).srs_SubframeConfig[j] = srs_SubframeConfig;
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_SubframeConfig= ccparams_lte.srs_SubframeConfig;
 
-              if ((srs_SubframeConfig<0) || (srs_SubframeConfig>15))
+              if ((ccparams_lte.srs_SubframeConfig<0) || 
+		  (ccparams_lte.srs_SubframeConfig>15))
                 AssertFatal (0,
                              "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for srs_SubframeConfig choice: 0..15 !\n",
-                             RC.config_file_name, i, srs_SubframeConfig);
+                             RC.config_file_name, i, ccparams_lte.srs_SubframeConfig);
 
-              if (strcmp(srs_ackNackST, "ENABLE") == 0) {
-                RRC_CONFIGURATION_REQ (msg_p).srs_ackNackST[j] = TRUE;
-              } else if (strcmp(srs_ackNackST, "DISABLE") == 0) {
-                RRC_CONFIGURATION_REQ (msg_p).srs_ackNackST[j] = FALSE;
+              if (strcmp(ccparams_lte.srs_ackNackST, "ENABLE") == 0) {
+                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_ackNackST= TRUE;
+              } 
+	      else if (strcmp(ccparams_lte.srs_ackNackST, "DISABLE") == 0) {
+                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_ackNackST= FALSE;
               } else
                 AssertFatal (0,
                              "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for srs_BandwidthConfig choice: ENABLE,DISABLE !\n",
-                             RC.config_file_name, i, srs_ackNackST);
-
-              if (strcmp(srs_MaxUpPts, "ENABLE") == 0) {
-                RRC_CONFIGURATION_REQ (msg_p).srs_MaxUpPts[j] = TRUE;
-              } else if (strcmp(srs_MaxUpPts, "DISABLE") == 0) {
-                RRC_CONFIGURATION_REQ (msg_p).srs_MaxUpPts[j] = FALSE;
-              } else
+                             RC.config_file_name, i, ccparams_lte.srs_ackNackST);
+
+              if (strcmp(ccparams_lte.srs_MaxUpPts, "ENABLE") == 0) {
+                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_MaxUpPts= TRUE;
+              } 
+	      else if (strcmp(ccparams_lte.srs_MaxUpPts, "DISABLE") == 0) {
+                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_MaxUpPts= FALSE;
+              } 
+	      else
                 AssertFatal (0,
                              "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for srs_MaxUpPts choice: ENABLE,DISABLE !\n",
-                             RC.config_file_name, i, srs_MaxUpPts);
+                             RC.config_file_name, i, ccparams_lte.srs_MaxUpPts);
             }
 
-            RRC_CONFIGURATION_REQ (msg_p).pusch_p0_Nominal[j] = pusch_p0_Nominal;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_p0_Nominal= ccparams_lte.pusch_p0_Nominal;
 
-            if ((pusch_p0_Nominal<-126) || (pusch_p0_Nominal>24))
+            if ((ccparams_lte.pusch_p0_Nominal<-126) || 
+		(ccparams_lte.pusch_p0_Nominal>24))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_p0_Nominal choice: -126..24 !\n",
-                           RC.config_file_name, i, pusch_p0_Nominal);
+                           RC.config_file_name, i, ccparams_lte.pusch_p0_Nominal);
 
 #if (LTE_RRC_VERSION <= MAKE_VERSION(12, 0, 0))
 
-            if (strcmp(pusch_alpha,"AL0")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = LTE_UplinkPowerControlCommon__alpha_al0;
-            } else if (strcmp(pusch_alpha,"AL04")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = LTE_UplinkPowerControlCommon__alpha_al04;
-            } else if (strcmp(pusch_alpha,"AL05")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = LTE_UplinkPowerControlCommon__alpha_al05;
-            } else if (strcmp(pusch_alpha,"AL06")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = LTE_UplinkPowerControlCommon__alpha_al06;
-            } else if (strcmp(pusch_alpha,"AL07")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = LTE_UplinkPowerControlCommon__alpha_al07;
-            } else if (strcmp(pusch_alpha,"AL08")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = LTE_UplinkPowerControlCommon__alpha_al08;
-            } else if (strcmp(pusch_alpha,"AL09")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = LTE_UplinkPowerControlCommon__alpha_al09;
-            } else if (strcmp(pusch_alpha,"AL1")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = LTE_UplinkPowerControlCommon__alpha_al1;
+            if (strcmp(ccparams_lte.pusch_alpha,"AL0")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al0;
+            } 
+	    else if (strcmp(ccparams_lte.pusch_alpha,"AL04")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al04;
+            } 
+	    else if (strcmp(ccparams_lte.pusch_alpha,"AL05")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al05;
+            } 
+	    else if (strcmp(ccparams_lte.pusch_alpha,"AL06")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al06;
+            } 
+	    else if (strcmp(ccparams_lte.pusch_alpha,"AL07")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al07;
+            } 
+	    else if (strcmp(ccparams_lte.pusch_alpha,"AL08")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al08;
+            } 
+	    else if (strcmp(ccparams_lte.pusch_alpha,"AL09")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al09;
+            } 
+	    else if (strcmp(ccparams_lte.pusch_alpha,"AL1")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al1;
             }
 
 #endif
 #if (LTE_RRC_VERSION >= MAKE_VERSION(12, 0, 0))
 
-            if (strcmp(pusch_alpha,"AL0")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = LTE_Alpha_r12_al0;
-            } else if (strcmp(pusch_alpha,"AL04")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = LTE_Alpha_r12_al04;
-            } else if (strcmp(pusch_alpha,"AL05")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = LTE_Alpha_r12_al05;
-            } else if (strcmp(pusch_alpha,"AL06")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = LTE_Alpha_r12_al06;
-            } else if (strcmp(pusch_alpha,"AL07")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = LTE_Alpha_r12_al07;
-            } else if (strcmp(pusch_alpha,"AL08")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = LTE_Alpha_r12_al08;
-            } else if (strcmp(pusch_alpha,"AL09")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = LTE_Alpha_r12_al09;
-            } else if (strcmp(pusch_alpha,"AL1")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = LTE_Alpha_r12_al1;
+            if (strcmp(ccparams_lte.pusch_alpha,"AL0")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al0;
+            } 
+	    else if (strcmp(ccparams_lte.pusch_alpha,"AL04")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al04;
+            } 
+	    else if (strcmp(ccparams_lte.pusch_alpha,"AL05")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al05;
+            } 
+	    else if (strcmp(ccparams_lte.pusch_alpha,"AL06")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al06;
+            } 
+	    else if (strcmp(ccparams_lte.pusch_alpha,"AL07")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al07;
+            } 
+	    else if (strcmp(ccparams_lte.pusch_alpha,"AL08")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al08;
+            } 
+	    else if (strcmp(ccparams_lte.pusch_alpha,"AL09")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al09;
+            } 
+	    else if (strcmp(ccparams_lte.pusch_alpha,"AL1")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al1;
             }
 
 #endif
             else
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_Alpha choice: AL0,AL04,AL05,AL06,AL07,AL08,AL09,AL1!\n",
-                           RC.config_file_name, i, pusch_alpha);
+                           RC.config_file_name, i, ccparams_lte.pusch_alpha);
 
-            RRC_CONFIGURATION_REQ (msg_p).pucch_p0_Nominal[j] = pucch_p0_Nominal;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_p0_Nominal= ccparams_lte.pucch_p0_Nominal;
 
-            if ((pucch_p0_Nominal<-127) || (pucch_p0_Nominal>-96))
+            if ((ccparams_lte.pucch_p0_Nominal<-127) || 
+		(ccparams_lte.pucch_p0_Nominal>-96))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_p0_Nominal choice: -127..-96 !\n",
-                           RC.config_file_name, i, pucch_p0_Nominal);
+                           RC.config_file_name, i, ccparams_lte.pucch_p0_Nominal);
 
-            RRC_CONFIGURATION_REQ (msg_p).msg3_delta_Preamble[j] = msg3_delta_Preamble;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].msg3_delta_Preamble= ccparams_lte.msg3_delta_Preamble;
 
-            if ((msg3_delta_Preamble<-1) || (msg3_delta_Preamble>6))
+            if ((ccparams_lte.msg3_delta_Preamble<-1) || 
+		(ccparams_lte.msg3_delta_Preamble>6))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for msg3_delta_Preamble choice: -1..6 !\n",
-                           RC.config_file_name, i, msg3_delta_Preamble);
-
-            if (strcmp(pucch_deltaF_Format1,"deltaF_2")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format1[j] = LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF_2;
-            } else if (strcmp(pucch_deltaF_Format1,"deltaF0")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format1[j] = LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF0;
-            } else if (strcmp(pucch_deltaF_Format1,"deltaF2")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format1[j] = LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF2;
-            } else
+                           RC.config_file_name, i, ccparams_lte.msg3_delta_Preamble);
+
+            if (strcmp(ccparams_lte.pucch_deltaF_Format1,"deltaF_2")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF_2;
+            } 
+	    else if (strcmp(ccparams_lte.pucch_deltaF_Format1,"deltaF0")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF0;
+            } 
+	    else if (strcmp(ccparams_lte.pucch_deltaF_Format1,"deltaF2")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF2;
+            } 
+	    else
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format1 choice: deltaF_2,dltaF0,deltaF2!\n",
-                           RC.config_file_name, i, pucch_deltaF_Format1);
-
-            if (strcmp(pucch_deltaF_Format1b,"deltaF1")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format1b[j] = LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF1;
-            } else if (strcmp(pucch_deltaF_Format1b,"deltaF3")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format1b[j] = LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF3;
-            } else if (strcmp(pucch_deltaF_Format1b,"deltaF5")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format1b[j] = LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF5;
-            } else
+                           RC.config_file_name, i, ccparams_lte.pucch_deltaF_Format1);
+
+            if (strcmp(ccparams_lte.pucch_deltaF_Format1b,"deltaF1")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF1;
+            } 
+	    else if (strcmp(ccparams_lte.pucch_deltaF_Format1b,"deltaF3")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF3;
+            } 
+	    else if (strcmp(ccparams_lte.pucch_deltaF_Format1b,"deltaF5")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF5;
+            } 
+	    else
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format1b choice: deltaF1,dltaF3,deltaF5!\n",
-                           RC.config_file_name, i, pucch_deltaF_Format1b);
-
-            if (strcmp(pucch_deltaF_Format2,"deltaF_2")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format2[j] = LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF_2;
-            } else if (strcmp(pucch_deltaF_Format2,"deltaF0")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format2[j] = LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF0;
-            } else if (strcmp(pucch_deltaF_Format2,"deltaF1")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format2[j] = LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF1;
-            } else if (strcmp(pucch_deltaF_Format2,"deltaF2")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format2[j] = LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF2;
+                           RC.config_file_name, i, ccparams_lte.pucch_deltaF_Format1b);
+
+            if (strcmp(ccparams_lte.pucch_deltaF_Format2,"deltaF_2")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF_2;
+            } 
+	    else if (strcmp(ccparams_lte.pucch_deltaF_Format2,"deltaF0")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF0;
+            } 
+	    else if (strcmp(ccparams_lte.pucch_deltaF_Format2,"deltaF1")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF1;
+            } 
+	    else if (strcmp(ccparams_lte.pucch_deltaF_Format2,"deltaF2")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF2;
             } else
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format2 choice: deltaF_2,dltaF0,deltaF1,deltaF2!\n",
-                           RC.config_file_name, i, pucch_deltaF_Format2);
-
-            if (strcmp(pucch_deltaF_Format2a,"deltaF_2")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format2a[j] = LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF_2;
-            } else if (strcmp(pucch_deltaF_Format2a,"deltaF0")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format2a[j] = LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF0;
-            } else if (strcmp(pucch_deltaF_Format2a,"deltaF2")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format2a[j] = LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF2;
-            } else
+                           RC.config_file_name, i, ccparams_lte.pucch_deltaF_Format2);
+
+            if (strcmp(ccparams_lte.pucch_deltaF_Format2a,"deltaF_2")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2a= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF_2;
+            }
+	    else if (strcmp(ccparams_lte.pucch_deltaF_Format2a,"deltaF0")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2a= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF0;
+            } 
+	    else if (strcmp(ccparams_lte.pucch_deltaF_Format2a,"deltaF2")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2a= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF2;
+            } 
+	    else
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format2a choice: deltaF_2,dltaF0,deltaF2!\n",
-                           RC.config_file_name, i, pucch_deltaF_Format2a);
-
-            if (strcmp(pucch_deltaF_Format2b,"deltaF_2")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format2b[j] = LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF_2;
-            } else if (strcmp(pucch_deltaF_Format2b,"deltaF0")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format2b[j] = LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF0;
-            } else if (strcmp(pucch_deltaF_Format2b,"deltaF2")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).pucch_deltaF_Format2b[j] = LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF2;
-            } else
+                           RC.config_file_name, i, ccparams_lte.pucch_deltaF_Format2a);
+
+            if (strcmp(ccparams_lte.pucch_deltaF_Format2b,"deltaF_2")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF_2;
+            } 
+	    else if (strcmp(ccparams_lte.pucch_deltaF_Format2b,"deltaF0")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF0;
+            } 
+	    else if (strcmp(ccparams_lte.pucch_deltaF_Format2b,"deltaF2")==0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF2;
+            } 
+	    else
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format2b choice: deltaF_2,dltaF0,deltaF2!\n",
-                           RC.config_file_name, i, pucch_deltaF_Format2b);
+                           RC.config_file_name, i, ccparams_lte.pucch_deltaF_Format2b);
 
-            RRC_CONFIGURATION_REQ (msg_p).rach_numberOfRA_Preambles[j] = (rach_numberOfRA_Preambles/4)-1;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_numberOfRA_Preambles= (ccparams_lte.rach_numberOfRA_Preambles/4)-1;
 
-            if ((rach_numberOfRA_Preambles <4) || (rach_numberOfRA_Preambles>64) || ((rach_numberOfRA_Preambles&3)!=0))
+            if ((ccparams_lte.rach_numberOfRA_Preambles <4) || 
+		(ccparams_lte.rach_numberOfRA_Preambles>64) || 
+		((ccparams_lte.rach_numberOfRA_Preambles&3)!=0))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_numberOfRA_Preambles choice: 4,8,12,...,64!\n",
-                           RC.config_file_name, i, rach_numberOfRA_Preambles);
+                           RC.config_file_name, i, ccparams_lte.rach_numberOfRA_Preambles);
 
-            if (strcmp(rach_preamblesGroupAConfig, "ENABLE") == 0) {
-              RRC_CONFIGURATION_REQ (msg_p).rach_preamblesGroupAConfig[j] = TRUE;
-              RRC_CONFIGURATION_REQ (msg_p).rach_sizeOfRA_PreamblesGroupA[j] = (rach_sizeOfRA_PreamblesGroupA/4)-1;
+            if (strcmp(ccparams_lte.rach_preamblesGroupAConfig, "ENABLE") == 0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preamblesGroupAConfig= TRUE;
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_sizeOfRA_PreamblesGroupA= (ccparams_lte.rach_sizeOfRA_PreamblesGroupA/4)-1;
 
-              if ((rach_numberOfRA_Preambles <4) || (rach_numberOfRA_Preambles>60) || ((rach_numberOfRA_Preambles&3)!=0))
+              if ((ccparams_lte.rach_numberOfRA_Preambles <4) || 
+		  (ccparams_lte.rach_numberOfRA_Preambles>60) || 
+		  ((ccparams_lte.rach_numberOfRA_Preambles&3)!=0))
                 AssertFatal (0,
                              "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_sizeOfRA_PreamblesGroupA choice: 4,8,12,...,60!\n",
-                             RC.config_file_name, i, rach_sizeOfRA_PreamblesGroupA);
-
-              switch (rach_messageSizeGroupA) {
-                case 56:
-                  RRC_CONFIGURATION_REQ (msg_p).rach_messageSizeGroupA[j] = LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b56;
-                  break;
-
-                case 144:
-                  RRC_CONFIGURATION_REQ (msg_p).rach_messageSizeGroupA[j] = LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b144;
-                  break;
-
-                case 208:
-                  RRC_CONFIGURATION_REQ (msg_p).rach_messageSizeGroupA[j] = LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b208;
-                  break;
-
-                case 256:
-                  RRC_CONFIGURATION_REQ (msg_p).rach_messageSizeGroupA[j] = LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b256;
-                  break;
-
-                default:
-                  AssertFatal (0,
-                               "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_messageSizeGroupA choice: 56,144,208,256!\n",
-                               RC.config_file_name, i, rach_messageSizeGroupA);
-                  break;
+                             RC.config_file_name, i, ccparams_lte.rach_sizeOfRA_PreamblesGroupA);
+
+              switch (ccparams_lte.rach_messageSizeGroupA) {
+	      case 56:
+		RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b56;
+		break;
+
+	      case 144:
+		RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b144;
+		break;
+
+	      case 208:
+		RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b208;
+		break;
+
+	      case 256:
+		RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b256;
+		break;
+
+	      default:
+		AssertFatal (0,
+			     "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_messageSizeGroupA choice: 56,144,208,256!\n",
+			     RC.config_file_name, i, ccparams_lte.rach_messageSizeGroupA);
+		break;
               }
 
-              if (strcmp(rach_messagePowerOffsetGroupB,"minusinfinity")==0) {
-                RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_minusinfinity;
-              } else if (strcmp(rach_messagePowerOffsetGroupB,"dB0")==0) {
-                RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB0;
-              } else if (strcmp(rach_messagePowerOffsetGroupB,"dB5")==0) {
-                RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB5;
-              } else if (strcmp(rach_messagePowerOffsetGroupB,"dB8")==0) {
-                RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB8;
-              } else if (strcmp(rach_messagePowerOffsetGroupB,"dB10")==0) {
-                RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB10;
-              } else if (strcmp(rach_messagePowerOffsetGroupB,"dB12")==0) {
-                RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB12;
-              } else if (strcmp(rach_messagePowerOffsetGroupB,"dB15")==0) {
-                RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB15;
-              } else if (strcmp(rach_messagePowerOffsetGroupB,"dB18")==0) {
-                RRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB18;
-              } else
+              if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"minusinfinity")==0) {
+                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_minusinfinity;
+              } 
+	      else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB0")==0) {
+                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB0;
+              } 
+	      else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB5")==0) {
+                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB5;
+              } 
+	      else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB8")==0) {
+                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB8;
+              } 
+	      else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB10")==0) {
+                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB10;
+              } 
+	      else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB12")==0) {
+                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB12;
+              } 
+	      else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB15")==0) {
+                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB15;
+              } 
+	      else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB18")==0) {
+                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB18;
+              } 
+	      else
                 AssertFatal (0,
                              "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rach_messagePowerOffsetGroupB choice: minusinfinity,dB0,dB5,dB8,dB10,dB12,dB15,dB18!\n",
-                             RC.config_file_name, i, rach_messagePowerOffsetGroupB);
-            } else if (strcmp(rach_preamblesGroupAConfig, "DISABLE") == 0) {
-              RRC_CONFIGURATION_REQ (msg_p).rach_preamblesGroupAConfig[j] = FALSE;
+                             RC.config_file_name, i, ccparams_lte.rach_messagePowerOffsetGroupB);
+            } else if (strcmp(ccparams_lte.rach_preamblesGroupAConfig, "DISABLE") == 0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preamblesGroupAConfig= FALSE;
             } else
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rach_preamblesGroupAConfig choice: ENABLE,DISABLE !\n",
-                           RC.config_file_name, i, rach_preamblesGroupAConfig);
+                           RC.config_file_name, i, ccparams_lte.rach_preamblesGroupAConfig);
 
-            RRC_CONFIGURATION_REQ (msg_p).rach_preambleInitialReceivedTargetPower[j] = (rach_preambleInitialReceivedTargetPower+120)/2;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleInitialReceivedTargetPower= (ccparams_lte.rach_preambleInitialReceivedTargetPower+120)/2;
 
-            if ((rach_preambleInitialReceivedTargetPower<-120) || (rach_preambleInitialReceivedTargetPower>-90) || ((rach_preambleInitialReceivedTargetPower&1)!=0))
+            if ((ccparams_lte.rach_preambleInitialReceivedTargetPower<-120) || 
+		(ccparams_lte.rach_preambleInitialReceivedTargetPower>-90) || 
+		((ccparams_lte.rach_preambleInitialReceivedTargetPower&1)!=0))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_preambleInitialReceivedTargetPower choice: -120,-118,...,-90 !\n",
-                           RC.config_file_name, i, rach_preambleInitialReceivedTargetPower);
+                           RC.config_file_name, i, ccparams_lte.rach_preambleInitialReceivedTargetPower);
 
-            RRC_CONFIGURATION_REQ (msg_p).rach_powerRampingStep[j] = rach_powerRampingStep/2;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_powerRampingStep= ccparams_lte.rach_powerRampingStep/2;
 
-            if ((rach_powerRampingStep<0) || (rach_powerRampingStep>6) || ((rach_powerRampingStep&1)!=0))
+            if ((ccparams_lte.rach_powerRampingStep<0) || 
+		(ccparams_lte.rach_powerRampingStep>6) || 
+		((ccparams_lte.rach_powerRampingStep&1)!=0))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_powerRampingStep choice: 0,2,4,6 !\n",
-                           RC.config_file_name, i, rach_powerRampingStep);
+                           RC.config_file_name, i, ccparams_lte.rach_powerRampingStep);
 
-            switch (rach_preambleTransMax) {
+            switch (ccparams_lte.rach_preambleTransMax) {
 #if (LTE_RRC_VERSION < MAKE_VERSION(14, 0, 0))
 
-              case 3:
-                RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] = LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n3;
-                break;
+	    case 3:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n3;
+	      break;
 
-              case 4:
-                RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] = LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n4;
-                break;
+	    case 4:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n4;
+	      break;
 
-              case 5:
-                RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] = LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n5;
-                break;
+	    case 5:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n5;
+	      break;
 
-              case 6:
-                RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] = LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n6;
-                break;
+	    case 6:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n6;
+	      break;
 
-              case 7:
-                RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] = LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n7;
-                break;
+	    case 7:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n7;
+	      break;
 
-              case 8:
-                RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] = LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n8;
-                break;
+	    case 8:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n8;
+	      break;
 
-              case 10:
-                RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] = LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n10;
-                break;
+	    case 10:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n10;
+	      break;
 
-              case 20:
-                RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] = LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n20;
-                break;
+	    case 20:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n20;
+	      break;
 
-              case 50:
-                RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] = LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n50;
-                break;
+	    case 50:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n50;
+	      break;
 
-              case 100:
-                RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] = LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n100;
-                break;
+	    case 100:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n100;
+	      break;
 
-              case 200:
-                RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] = LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n200;
-                break;
+	    case 200:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n200;
+	      break;
 #else
 
-              case 3:
-                RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] = LTE_PreambleTransMax_n3;
-                break;
+	    case 3:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n3;
+	      break;
 
-              case 4:
-                RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] = LTE_PreambleTransMax_n4;
-                break;
+	    case 4:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n4;
+	      break;
 
-              case 5:
-                RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] = LTE_PreambleTransMax_n5;
-                break;
+	    case 5:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n5;
+	      break;
 
-              case 6:
-                RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] = LTE_PreambleTransMax_n6;
-                break;
+	    case 6:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n6;
+	      break;
 
-              case 7:
-                RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] = LTE_PreambleTransMax_n7;
-                break;
+	    case 7:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n7;
+	      break;
 
-              case 8:
-                RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] = LTE_PreambleTransMax_n8;
-                break;
+	    case 8:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n8;
+	      break;
 
-              case 10:
-                RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] = LTE_PreambleTransMax_n10;
-                break;
+	    case 10:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n10;
+	      break;
 
-              case 20:
-                RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] = LTE_PreambleTransMax_n20;
-                break;
+	    case 20:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n20;
+	      break;
 
-              case 50:
-                RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] = LTE_PreambleTransMax_n50;
-                break;
+	    case 50:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n50;
+	      break;
 
-              case 100:
-                RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] = LTE_PreambleTransMax_n100;
-                break;
+	    case 100:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n100;
+	      break;
+
+	    case 200:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n200;
+	      break;
 
-              case 200:
-                RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] = LTE_PreambleTransMax_n200;
-                break;
 #endif
 
-              default:
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_preambleTransMax choice: 3,4,5,6,7,8,10,20,50,100,200!\n",
-                             RC.config_file_name, i, rach_preambleTransMax);
-                break;
+	    default:
+	      AssertFatal (0,
+			   "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_preambleTransMax choice: 3,4,5,6,7,8,10,20,50,100,200!\n",
+			   RC.config_file_name, i, ccparams_lte.rach_preambleTransMax);
+	      break;
             }
 
-            RRC_CONFIGURATION_REQ (msg_p).rach_raResponseWindowSize[j] =  (rach_raResponseWindowSize==10)?7:rach_raResponseWindowSize-2;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_raResponseWindowSize=  (ccparams_lte.rach_raResponseWindowSize==10)?7:ccparams_lte.rach_raResponseWindowSize-2;
 
-            if ((rach_raResponseWindowSize<0)||(rach_raResponseWindowSize==9)||(rach_raResponseWindowSize>10))
+            if ((ccparams_lte.rach_raResponseWindowSize<0)||
+		(ccparams_lte.rach_raResponseWindowSize==9)||
+		(ccparams_lte.rach_raResponseWindowSize>10))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_raResponseWindowSize choice: 2,3,4,5,6,7,8,10!\n",
-                           RC.config_file_name, i, rach_preambleTransMax);
+                           RC.config_file_name, i, ccparams_lte.rach_preambleTransMax);
 
-            RRC_CONFIGURATION_REQ (msg_p).rach_macContentionResolutionTimer[j] = (rach_macContentionResolutionTimer/8)-1;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_macContentionResolutionTimer= (ccparams_lte.rach_macContentionResolutionTimer/8)-1;
 
-            if ((rach_macContentionResolutionTimer<8) || (rach_macContentionResolutionTimer>64) || ((rach_macContentionResolutionTimer&7)!=0))
+            if ((ccparams_lte.rach_macContentionResolutionTimer<8) || 
+		(ccparams_lte.rach_macContentionResolutionTimer>64) || 
+		((ccparams_lte.rach_macContentionResolutionTimer&7)!=0))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_macContentionResolutionTimer choice: 8,16,...,56,64!\n",
-                           RC.config_file_name, i, rach_preambleTransMax);
+                           RC.config_file_name, i, ccparams_lte.rach_preambleTransMax);
 
-            RRC_CONFIGURATION_REQ (msg_p).rach_maxHARQ_Msg3Tx[j] = rach_maxHARQ_Msg3Tx;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_maxHARQ_Msg3Tx= ccparams_lte.rach_maxHARQ_Msg3Tx;
 
-            if ((rach_maxHARQ_Msg3Tx<0) || (rach_maxHARQ_Msg3Tx>8))
+            if ((ccparams_lte.rach_maxHARQ_Msg3Tx<0) || 
+		(ccparams_lte.rach_maxHARQ_Msg3Tx>8))
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_maxHARQ_Msg3Tx choice: 1..8!\n",
-                           RC.config_file_name, i, rach_preambleTransMax);
-
-            switch (pcch_defaultPagingCycle) {
-              case 32:
-                RRC_CONFIGURATION_REQ (msg_p).pcch_defaultPagingCycle[j] = LTE_PCCH_Config__defaultPagingCycle_rf32;
-                break;
-
-              case 64:
-                RRC_CONFIGURATION_REQ (msg_p).pcch_defaultPagingCycle[j] = LTE_PCCH_Config__defaultPagingCycle_rf64;
-                break;
-
-              case 128:
-                RRC_CONFIGURATION_REQ (msg_p).pcch_defaultPagingCycle[j] = LTE_PCCH_Config__defaultPagingCycle_rf128;
-                break;
-
-              case 256:
-                RRC_CONFIGURATION_REQ (msg_p).pcch_defaultPagingCycle[j] = LTE_PCCH_Config__defaultPagingCycle_rf256;
-                break;
-
-              default:
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pcch_defaultPagingCycle choice: 32,64,128,256!\n",
-                             RC.config_file_name, i, pcch_defaultPagingCycle);
-                break;
+                           RC.config_file_name, i, ccparams_lte.rach_preambleTransMax);
+
+            switch (ccparams_lte.pcch_defaultPagingCycle) {
+	    case 32:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf32;
+	      break;
+
+	    case 64:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf64;
+	      break;
+
+	    case 128:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf128;
+	      break;
+
+	    case 256:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf256;
+	      break;
+
+	    default:
+	      AssertFatal (0,
+			   "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pcch_defaultPagingCycle choice: 32,64,128,256!\n",
+			   RC.config_file_name, i, ccparams_lte.pcch_defaultPagingCycle);
+	      break;
             }
 
-            if (strcmp(pcch_nB, "fourT") == 0) {
-              RRC_CONFIGURATION_REQ (msg_p).pcch_nB[j] = LTE_PCCH_Config__nB_fourT;
-            } else if (strcmp(pcch_nB, "twoT") == 0) {
-              RRC_CONFIGURATION_REQ (msg_p).pcch_nB[j] = LTE_PCCH_Config__nB_twoT;
-            } else if (strcmp(pcch_nB, "oneT") == 0) {
-              RRC_CONFIGURATION_REQ (msg_p).pcch_nB[j] = LTE_PCCH_Config__nB_oneT;
-            } else if (strcmp(pcch_nB, "halfT") == 0) {
-              RRC_CONFIGURATION_REQ (msg_p).pcch_nB[j] = LTE_PCCH_Config__nB_halfT;
-            } else if (strcmp(pcch_nB, "quarterT") == 0) {
-              RRC_CONFIGURATION_REQ (msg_p).pcch_nB[j] = LTE_PCCH_Config__nB_quarterT;
-            } else if (strcmp(pcch_nB, "oneEighthT") == 0) {
-              RRC_CONFIGURATION_REQ (msg_p).pcch_nB[j] = LTE_PCCH_Config__nB_oneEighthT;
-            } else if (strcmp(pcch_nB, "oneSixteenthT") == 0) {
-              RRC_CONFIGURATION_REQ (msg_p).pcch_nB[j] = LTE_PCCH_Config__nB_oneSixteenthT;
-            } else if (strcmp(pcch_nB, "oneThirtySecondT") == 0) {
-              RRC_CONFIGURATION_REQ (msg_p).pcch_nB[j] = LTE_PCCH_Config__nB_oneThirtySecondT;
-            } else
-              AssertFatal (0,
-                           "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pcch_nB choice: fourT,twoT,oneT,halfT,quarterT,oneighthT,oneSixteenthT,oneThirtySecondT !\n",
-                           RC.config_file_name, i, pcch_defaultPagingCycle);
-
-            switch (bcch_modificationPeriodCoeff) {
-              case 2:
-                RRC_CONFIGURATION_REQ (msg_p).bcch_modificationPeriodCoeff[j] = LTE_BCCH_Config__modificationPeriodCoeff_n2;
-                break;
-
-              case 4:
-                RRC_CONFIGURATION_REQ (msg_p).bcch_modificationPeriodCoeff[j] = LTE_BCCH_Config__modificationPeriodCoeff_n4;
-                break;
-
-              case 8:
-                RRC_CONFIGURATION_REQ (msg_p).bcch_modificationPeriodCoeff[j] = LTE_BCCH_Config__modificationPeriodCoeff_n8;
-                break;
-
-              case 16:
-                RRC_CONFIGURATION_REQ (msg_p).bcch_modificationPeriodCoeff[j] = LTE_BCCH_Config__modificationPeriodCoeff_n16;
-                break;
-
-              default:
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for bcch_modificationPeriodCoeff choice: 2,4,8,16",
-                             RC.config_file_name, i, bcch_modificationPeriodCoeff);
-                break;
+            if (strcmp(ccparams_lte.pcch_nB, "fourT") == 0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_fourT;
+            } 
+	    else if (strcmp(ccparams_lte.pcch_nB, "twoT") == 0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_twoT;
+            } 
+	    else if (strcmp(ccparams_lte.pcch_nB, "oneT") == 0) {
+ 	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_oneT;
+            } 
+	    else if (strcmp(ccparams_lte.pcch_nB, "halfT") == 0) {
+ 	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_halfT;
+            } 
+	    else if (strcmp(ccparams_lte.pcch_nB, "quarterT") == 0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_quarterT;
+            } 
+	    else if (strcmp(ccparams_lte.pcch_nB, "oneEighthT") == 0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_oneEighthT;
+            } 
+	    else if (strcmp(ccparams_lte.pcch_nB, "oneSixteenthT") == 0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_oneSixteenthT;
+            } 
+	    else if (strcmp(ccparams_lte.pcch_nB, "oneThirtySecondT") == 0) {
+              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_oneThirtySecondT;
+            } 
+	    else
+              AssertFatal (0,
+                           "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pcch_nB choice: fourT,twoT,oneT,halfT,quarterT,oneighthT,oneSixteenthT,oneThirtySecondT !\n",
+                           RC.config_file_name, i, ccparams_lte.pcch_nB);
+
+            switch (ccparams_lte.bcch_modificationPeriodCoeff) {
+	    case 2:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n2;
+	      break;
+
+	    case 4:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n4;
+	      break;
+
+	    case 8:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n8;
+	      break;
+
+	    case 16:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n16;
+	      break;
+
+	    default:
+	      AssertFatal (0,
+			   "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for bcch_modificationPeriodCoeff choice: 2,4,8,16",
+			   RC.config_file_name, i, ccparams_lte.bcch_modificationPeriodCoeff);
+	      break;
             }
 
-            RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t300[j] = ue_TimersAndConstants_t300;
-            RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t301[j] = ue_TimersAndConstants_t301;
-            RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t310[j] = ue_TimersAndConstants_t310;
-            RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_t311[j] = ue_TimersAndConstants_t311;
-            RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n310[j] = ue_TimersAndConstants_n310;
-            RRC_CONFIGURATION_REQ (msg_p).ue_TimersAndConstants_n311[j] = ue_TimersAndConstants_n311;
-
-            switch (ue_TransmissionMode) {
-              case 1:
-                RRC_CONFIGURATION_REQ (msg_p).ue_TransmissionMode[j] = LTE_AntennaInfoDedicated__transmissionMode_tm1;
-                break;
-
-              case 2:
-                RRC_CONFIGURATION_REQ (msg_p).ue_TransmissionMode[j] = LTE_AntennaInfoDedicated__transmissionMode_tm2;
-                break;
-
-              case 3:
-                RRC_CONFIGURATION_REQ (msg_p).ue_TransmissionMode[j] = LTE_AntennaInfoDedicated__transmissionMode_tm3;
-                break;
-
-              case 4:
-                RRC_CONFIGURATION_REQ (msg_p).ue_TransmissionMode[j] = LTE_AntennaInfoDedicated__transmissionMode_tm4;
-                break;
-
-              case 5:
-                RRC_CONFIGURATION_REQ (msg_p).ue_TransmissionMode[j] = LTE_AntennaInfoDedicated__transmissionMode_tm5;
-                break;
-
-              case 6:
-                RRC_CONFIGURATION_REQ (msg_p).ue_TransmissionMode[j] = LTE_AntennaInfoDedicated__transmissionMode_tm6;
-                break;
-
-              case 7:
-                RRC_CONFIGURATION_REQ (msg_p).ue_TransmissionMode[j] = LTE_AntennaInfoDedicated__transmissionMode_tm7;
-                break;
-
-              default:
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_TransmissionMode choice: 1,2,3,4,5,6,7",
-                             RC.config_file_name, i, ue_TransmissionMode);
-                break;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TimersAndConstants_t300= ccparams_lte.ue_TimersAndConstants_t300;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TimersAndConstants_t301= ccparams_lte.ue_TimersAndConstants_t301;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TimersAndConstants_t310= ccparams_lte.ue_TimersAndConstants_t310;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TimersAndConstants_t311= ccparams_lte.ue_TimersAndConstants_t311;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TimersAndConstants_n310= ccparams_lte.ue_TimersAndConstants_n310;
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TimersAndConstants_n311= ccparams_lte.ue_TimersAndConstants_n311;
+
+            switch (ccparams_lte.ue_TransmissionMode) {
+	    case 1:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm1;
+	      break;
+
+	    case 2:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm2;
+	      break;
+
+	    case 3:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm3;
+	      break;
+
+	    case 4:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm4;
+	      break;
+
+	    case 5:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm5;
+	      break;
+
+	    case 6:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm6;
+	      break;
+
+	    case 7:
+	      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm7;
+	      break;
+
+	    default:
+	      AssertFatal (0,
+			   "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_TransmissionMode choice: 1,2,3,4,5,6,7",
+			   RC.config_file_name, i, ccparams_lte.ue_TransmissionMode);
+	      break;
             }
 
-            RRC_CONFIGURATION_REQ (msg_p).ue_multiple_max[j] = ue_multiple_max;
-
-            switch (N_RB_DL) {
-              case 25:
-                if ((ue_multiple_max < 1) || (ue_multiple_max > 4))
-                  AssertFatal (0,
-                               "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_multiple_max choice: 1..4!\n",
-                               RC.config_file_name, i, ue_multiple_max);
-
-                break;
-
-              case 50:
-                if ((ue_multiple_max < 1) || (ue_multiple_max > 8))
-                  AssertFatal (0,
-                               "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_multiple_max choice: 1..8!\n",
-                               RC.config_file_name, i, ue_multiple_max);
+            RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_multiple_max= ccparams_lte.ue_multiple_max;
+
+            switch (ccparams_lte.N_RB_DL) {
+	    case 25:
+	      if ((ccparams_lte.ue_multiple_max < 1) || 
+		  (ccparams_lte.ue_multiple_max > 4))
+		AssertFatal (0,
+			     "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_multiple_max choice: 1..4!\n",
+			     RC.config_file_name, i, ccparams_lte.ue_multiple_max);
+
+	      break;
+
+	    case 50:
+	      if ((ccparams_lte.ue_multiple_max < 1) || 
+		  (ccparams_lte.ue_multiple_max > 8))
+		AssertFatal (0,
+			     "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_multiple_max choice: 1..8!\n",
+			     RC.config_file_name, i, ccparams_lte.ue_multiple_max);
+
+	      break;
+
+	    case 100:
+	      if ((ccparams_lte.ue_multiple_max < 1) || 
+		  (ccparams_lte.ue_multiple_max > 16))
+		AssertFatal (0,
+			     "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_multiple_max choice: 1..16!\n",
+			     RC.config_file_name, i, ccparams_lte.ue_multiple_max);
+
+	      break;
+
+	    default:
+	      AssertFatal (0,
+			   "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for N_RB_DL choice: 25,50,100 !\n",
+			   RC.config_file_name, i, ccparams_lte.N_RB_DL);
+	      break;
+            }
 
-                break;
+	    // eMBMS configuration
+	    RRC_CONFIGURATION_REQ(msg_p).eMBMS_configured = 0;
+	    printf("No eMBMS configuration, skipping it\n");
 
-              case 100:
-                if ((ue_multiple_max < 1) || (ue_multiple_max > 16))
-                  AssertFatal (0,
-                               "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_multiple_max choice: 1..16!\n",
-                               RC.config_file_name, i, ue_multiple_max);
+	    // eMTC configuration
+	    char brparamspath[MAX_OPTNAME_SIZE*2 + 16];
+	    sprintf(brparamspath,"%s.%s", ccspath, ENB_CONFIG_STRING_EMTC_PARAMETERS);
+	    config_get(eMTCParams, sizeof(eMTCParams)/sizeof(paramdef_t), brparamspath);
+	    RRC_CONFIGURATION_REQ(msg_p).eMTC_configured = eMTCconfig.eMTC_configured&1;
 
-                break;
+	    if (eMTCconfig.eMTC_configured > 0) fill_eMTC_configuration(msg_p,&eMTCconfig, i,j,RC.config_file_name,brparamspath); 
+	    else   	                        printf("No eMTC configuration, skipping it\n");
+	    
 
-              default:
-                AssertFatal (0,
-                             "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for N_RB_DL choice: 25,50,100 !\n",
-                             RC.config_file_name, i, N_RB_DL);
-                break;
-            }
-
-            //TTN - for D2D
-            //SIB18
-            if (strcmp(rxPool_sc_CP_Len,"normal")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_CP_Len[j] = LTE_SL_CP_Len_r12_normal;
-            } else if (strcmp(rxPool_sc_CP_Len,"extended")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_CP_Len[j] = LTE_SL_CP_Len_r12_extended;
-            } else
-              AssertFatal (0,
-                           "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rxPool_sc_CP_Len choice: normal,extended!\n",
-                           RC.config_file_name, i, rxPool_sc_CP_Len);
-
-            if (strcmp(rxPool_sc_Period,"sf40")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = LTE_SL_PeriodComm_r12_sf40;
-            } else if (strcmp(rxPool_sc_Period,"sf60")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = LTE_SL_PeriodComm_r12_sf60;
-            } else if (strcmp(rxPool_sc_Period,"sf70")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = LTE_SL_PeriodComm_r12_sf70;
-            } else if (strcmp(rxPool_sc_Period,"sf80")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = LTE_SL_PeriodComm_r12_sf80;
-            } else if (strcmp(rxPool_sc_Period,"sf120")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = LTE_SL_PeriodComm_r12_sf120;
-            } else if (strcmp(rxPool_sc_Period,"sf140")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = LTE_SL_PeriodComm_r12_sf140;
-            } else if (strcmp(rxPool_sc_Period,"sf160")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = LTE_SL_PeriodComm_r12_sf160;
-            } else if (strcmp(rxPool_sc_Period,"sf240")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = LTE_SL_PeriodComm_r12_sf240;
-            } else if (strcmp(rxPool_sc_Period,"sf280")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = LTE_SL_PeriodComm_r12_sf280;
-            } else if (strcmp(rxPool_sc_Period,"sf320")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = LTE_SL_PeriodComm_r12_sf320;
-            } else if (strcmp(rxPool_sc_Period,"spare6")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = LTE_SL_PeriodComm_r12_spare6;
-            } else if (strcmp(rxPool_sc_Period,"spare5")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = LTE_SL_PeriodComm_r12_spare5;
-            } else if (strcmp(rxPool_sc_Period,"spare4")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = LTE_SL_PeriodComm_r12_spare4;
-            } else if (strcmp(rxPool_sc_Period,"spare3")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = LTE_SL_PeriodComm_r12_spare3;
-            } else if (strcmp(rxPool_sc_Period,"spare2")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = LTE_SL_PeriodComm_r12_spare2;
-            } else if (strcmp(rxPool_sc_Period,"spare")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = LTE_SL_PeriodComm_r12_spare;
-            } else
-              AssertFatal (0,
-                           "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rxPool_sc_Period choice: sf40,sf60,sf70,sf80,sf120,sf140,sf160,sf240,sf280,sf320,spare6,spare5,spare4,spare3,spare2,spare!\n",
-                           RC.config_file_name, i, rxPool_sc_Period);
-
-            if (strcmp(rxPool_data_CP_Len,"normal")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_data_CP_Len[j] = LTE_SL_CP_Len_r12_normal;
-            } else if (strcmp(rxPool_data_CP_Len,"extended")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_data_CP_Len[j] = LTE_SL_CP_Len_r12_extended;
-            } else
-              AssertFatal (0,
-                           "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rxPool_data_CP_Len choice: normal,extended!\n",
-                           RC.config_file_name, i, rxPool_data_CP_Len);
-
-            RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_prb_Num[j] = rxPool_ResourceConfig_prb_Num;
-            RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_prb_Start[j] = rxPool_ResourceConfig_prb_Start;
-            RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_prb_End[j] = rxPool_ResourceConfig_prb_End;
-
-            if (strcmp(rxPool_ResourceConfig_offsetIndicator_present,"prNothing")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_offsetIndicator_present[j] = LTE_SL_OffsetIndicator_r12_PR_NOTHING;
-            } else if (strcmp(rxPool_ResourceConfig_offsetIndicator_present,"prSmall")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_offsetIndicator_present[j] = LTE_SL_OffsetIndicator_r12_PR_small_r12;
-            } else if (strcmp(rxPool_ResourceConfig_offsetIndicator_present,"prLarge")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_offsetIndicator_present[j] = LTE_SL_OffsetIndicator_r12_PR_large_r12;
-            } else
-              AssertFatal (0,
-                           "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rxPool_ResourceConfig_offsetIndicator_present choice: prNothing,prSmal,prLarge!\n",
-                           RC.config_file_name, i, rxPool_ResourceConfig_offsetIndicator_present);
-
-            RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_offsetIndicator_choice[j] = rxPool_ResourceConfig_offsetIndicator_choice;
-
-            if (strcmp(rxPool_ResourceConfig_subframeBitmap_present,"prNothing")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_NOTHING;
-            } else if (strcmp(rxPool_ResourceConfig_subframeBitmap_present,"prBs4")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_bs4_r12;
-            } else if (strcmp(rxPool_ResourceConfig_subframeBitmap_present,"prBs8")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_bs8_r12;
-            } else if (strcmp(rxPool_ResourceConfig_subframeBitmap_present,"prBs12")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_bs12_r12;
-            } else if (strcmp(rxPool_ResourceConfig_subframeBitmap_present,"prBs16")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_bs16_r12;
-            } else if (strcmp(rxPool_ResourceConfig_subframeBitmap_present,"prBs30")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_bs30_r12;
-            } else if (strcmp(rxPool_ResourceConfig_subframeBitmap_present,"prBs40")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_bs40_r12;
-            } else if (strcmp(rxPool_ResourceConfig_subframeBitmap_present,"prBs42")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_bs42_r12;
-            } else
-              AssertFatal (0,
-                           "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rxPool_ResourceConfig_subframeBitmap_present choice: prNothing,prBs4,prBs8,prBs12,prBs16,prBs30,prBs40,prBs42!\n",
-                           RC.config_file_name, i, rxPool_ResourceConfig_subframeBitmap_present);
-
-            RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[j] = rxPool_ResourceConfig_subframeBitmap_choice_bs_buf;
-            RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_choice_bs_size[j] = rxPool_ResourceConfig_subframeBitmap_choice_bs_size;
-            RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[j] = rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused;
-
-            //SIB19 - for discRxPool
-            if (strcmp(discRxPool_cp_Len,"normal")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPool_cp_Len[j] = LTE_SL_CP_Len_r12_normal;
-            } else if (strcmp(discRxPool_cp_Len,"extended")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPool_cp_Len[j] = LTE_SL_CP_Len_r12_extended;
-            } else
-              AssertFatal (0,
-                           "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPool_cp_Len choice: normal,extended!\n",
-                           RC.config_file_name, i, discRxPool_cp_Len);
-
-            if (strcmp(discRxPool_discPeriod,"rf32")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[j] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf32;
-            } else if (strcmp(discRxPool_discPeriod,"rf64")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[j] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf64;
-            } else if (strcmp(discRxPool_discPeriod,"rf128")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[j] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf128;
-            } else if (strcmp(discRxPool_discPeriod,"rf256")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[j] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf256;
-            } else if (strcmp(discRxPool_discPeriod,"rf512")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[j] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf512;
-            } else if (strcmp(discRxPool_discPeriod,"rf1024")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[j] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf1024;
-            } else if (strcmp(discRxPool_discPeriod,"rf16")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[j] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf16_v1310;
-            } else if (strcmp(discRxPool_discPeriod,"spare")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[j] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_spare;
-            } else
-              AssertFatal (0,
-                           "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPool_discPeriod choice: rf32,rf64,rf128,rf512,rf1024,rf16,spare!\n",
-                           RC.config_file_name, i, discRxPool_discPeriod);
-
-            RRC_CONFIGURATION_REQ (msg_p).discRxPool_numRetx[j] = discRxPool_numRetx;
-            RRC_CONFIGURATION_REQ (msg_p).discRxPool_numRepetition[j] = discRxPool_numRepetition;
-            RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_prb_Num[j] = discRxPool_ResourceConfig_prb_Num;
-            RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_prb_Start[j] = discRxPool_ResourceConfig_prb_Start;
-            RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_prb_End[j] = discRxPool_ResourceConfig_prb_End;
-
-            if (strcmp(discRxPool_ResourceConfig_offsetIndicator_present,"prNothing")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_offsetIndicator_present[j] = LTE_SL_OffsetIndicator_r12_PR_NOTHING;
-            } else if (strcmp(discRxPool_ResourceConfig_offsetIndicator_present,"prSmall")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_offsetIndicator_present[j] = LTE_SL_OffsetIndicator_r12_PR_small_r12;
-            } else if (strcmp(discRxPool_ResourceConfig_offsetIndicator_present,"prLarge")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_offsetIndicator_present[j] = LTE_SL_OffsetIndicator_r12_PR_large_r12;
-            } else
-              AssertFatal (0,
-                           "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPool_ResourceConfig_offsetIndicator_present choice: prNothing,prSmal,prLarge!\n",
-                           RC.config_file_name, i, discRxPool_ResourceConfig_offsetIndicator_present);
-
-            RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_offsetIndicator_choice[j] = discRxPool_ResourceConfig_offsetIndicator_choice;
-
-            if (strcmp(discRxPool_ResourceConfig_subframeBitmap_present,"prNothing")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_NOTHING;
-            } else if (strcmp(discRxPool_ResourceConfig_subframeBitmap_present,"prBs4")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_bs4_r12;
-            } else if (strcmp(discRxPool_ResourceConfig_subframeBitmap_present,"prBs8")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_bs8_r12;
-            } else if (strcmp(discRxPool_ResourceConfig_subframeBitmap_present,"prBs12")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_bs12_r12;
-            } else if (strcmp(discRxPool_ResourceConfig_subframeBitmap_present,"prBs16")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_bs16_r12;
-            } else if (strcmp(discRxPool_ResourceConfig_subframeBitmap_present,"prBs30")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_bs30_r12;
-            } else if (strcmp(discRxPool_ResourceConfig_subframeBitmap_present,"prBs40")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_bs40_r12;
-            } else if (strcmp(discRxPool_ResourceConfig_subframeBitmap_present,"prBs42")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_bs42_r12;
-            } else
-              AssertFatal (0,
-                           "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPool_ResourceConfig_subframeBitmap_present choice: prNothing,prBs4,prBs8,prBs12,prBs16,prBs30,prBs40,prBs42!\n",
-                           RC.config_file_name, i, discRxPool_ResourceConfig_subframeBitmap_present);
-
-            RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[j] = discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf;
-            RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[j] = discRxPool_ResourceConfig_subframeBitmap_choice_bs_size;
-            RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[j] = discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused;
-
-            //SIB19 - For discRxPoolPS
-            if (strcmp(discRxPoolPS_cp_Len,"normal")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_cp_Len[j] = LTE_SL_CP_Len_r12_normal;
-            } else if (strcmp(discRxPoolPS_cp_Len,"extended")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_cp_Len[j] = LTE_SL_CP_Len_r12_extended;
-            } else
-              AssertFatal (0,
-                           "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPoolPS_cp_Len choice: normal,extended!\n",
-                           RC.config_file_name, i, discRxPoolPS_cp_Len);
-
-            if (strcmp(discRxPoolPS_discPeriod,"rf32")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[j] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf32;
-            } else if (strcmp(discRxPoolPS_discPeriod,"rf64")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[j] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf64;
-            } else if (strcmp(discRxPoolPS_discPeriod,"rf128")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[j] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf128;
-            } else if (strcmp(discRxPoolPS_discPeriod,"rf256")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[j] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf256;
-            } else if (strcmp(discRxPoolPS_discPeriod,"rf512")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[j] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf512;
-            } else if (strcmp(discRxPoolPS_discPeriod,"rf1024")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[j] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf1024;
-            } else if (strcmp(discRxPoolPS_discPeriod,"rf16")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[j] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf16_v1310;
-            } else if (strcmp(discRxPoolPS_discPeriod,"spare")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[j] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_spare;
-            } else
-              AssertFatal (0,
-                           "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPoolPS_discPeriod choice: rf32,rf64,rf128,rf512,rf1024,rf16,spare!\n",
-                           RC.config_file_name, i, discRxPoolPS_discPeriod);
-
-            RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_numRetx[j] = discRxPoolPS_numRetx;
-            RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_numRepetition[j] = discRxPoolPS_numRepetition;
-            RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_prb_Num[j] = discRxPoolPS_ResourceConfig_prb_Num;
-            RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_prb_Start[j] = discRxPoolPS_ResourceConfig_prb_Start;
-            RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_prb_End[j] = discRxPoolPS_ResourceConfig_prb_End;
-
-            if (strcmp(discRxPoolPS_ResourceConfig_offsetIndicator_present,"prNothing")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_offsetIndicator_present[j] = LTE_SL_OffsetIndicator_r12_PR_NOTHING;
-            } else if (strcmp(discRxPoolPS_ResourceConfig_offsetIndicator_present,"prSmall")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_offsetIndicator_present[j] = LTE_SL_OffsetIndicator_r12_PR_small_r12;
-            } else if (strcmp(discRxPoolPS_ResourceConfig_offsetIndicator_present,"prLarge")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_offsetIndicator_present[j] = LTE_SL_OffsetIndicator_r12_PR_large_r12;
-            } else
-              AssertFatal (0,
-                           "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPoolPS_ResourceConfig_offsetIndicator_present choice: prNothing,prSmal,prLarge!\n",
-                           RC.config_file_name, i, discRxPoolPS_ResourceConfig_offsetIndicator_present);
-
-            RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_offsetIndicator_choice[j] = discRxPoolPS_ResourceConfig_offsetIndicator_choice;
-
-            if (strcmp(discRxPoolPS_ResourceConfig_subframeBitmap_present,"prNothing")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_NOTHING;
-            } else if (strcmp(discRxPoolPS_ResourceConfig_subframeBitmap_present,"prBs4")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_bs4_r12;
-            } else if (strcmp(discRxPoolPS_ResourceConfig_subframeBitmap_present,"prBs8")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_bs8_r12;
-            } else if (strcmp(discRxPoolPS_ResourceConfig_subframeBitmap_present,"prBs12")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_bs12_r12;
-            } else if (strcmp(discRxPoolPS_ResourceConfig_subframeBitmap_present,"prBs16")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_bs16_r12;
-            } else if (strcmp(discRxPoolPS_ResourceConfig_subframeBitmap_present,"prBs30")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_bs30_r12;
-            } else if (strcmp(discRxPoolPS_ResourceConfig_subframeBitmap_present,"prBs40")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_bs40_r12;
-            } else if (strcmp(discRxPoolPS_ResourceConfig_subframeBitmap_present,"prBs42")==0) {
-              RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[j] = LTE_SubframeBitmapSL_r12_PR_bs42_r12;
-            } else
-              AssertFatal (0,
-                           "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPoolPS_ResourceConfig_subframeBitmap_present choice: prNothing,prBs4,prBs8,prBs12,prBs16,prBs30,prBs40,prBs42!\n",
-                           RC.config_file_name, i, discRxPoolPS_ResourceConfig_subframeBitmap_present);
+	    // Sidelink configuration
+	    char SLparamspath[MAX_OPTNAME_SIZE*2 + 16];
+	    sprintf(SLparamspath,"%s.%s", ccspath, ENB_CONFIG_STRING_SL_PARAMETERS);
+	    config_get( SLParams, sizeof(SLParams)/sizeof(paramdef_t), SLparamspath);
 
-            RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[j] = discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf;
-            RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[j] = discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size;
-            RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[j] = discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused;
-          }
-        }
+	    // Sidelink Resource pool information
+	    RRC_CONFIGURATION_REQ (msg_p).SL_configured=SLconfig.sidelink_configured&1;
+	    if (SLconfig.sidelink_configured==1) fill_SL_configuration(msg_p,&SLconfig,i,j,RC.config_file_name);
+	    else                                 printf("No SL configuration skipping it\n");
+	  }
+	}
 
         char srb1path[MAX_OPTNAME_SIZE*2 + 8];
         sprintf(srb1path,"%s.%s",enbpath,ENB_CONFIG_STRING_SRB1);
-        int npar = config_get( SRB1Params,sizeof(SRB1Params)/sizeof(paramdef_t), srb1path);
-
-        if (npar == sizeof(SRB1Params)/sizeof(paramdef_t)) {
-          switch (srb1_max_retx_threshold) {
-            case 1:
-              rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t1;
-              break;
-
-            case 2:
-              rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t2;
-              break;
-
-            case 3:
-              rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t3;
-              break;
-
-            case 4:
-              rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t4;
-              break;
-
-            case 6:
-              rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t6;
-              break;
-
-            case 8:
-              rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t8;
-              break;
-
-            case 16:
-              rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t16;
-              break;
-
-            case 32:
-              rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t32;
-              break;
-
-            default:
-              AssertFatal (0,
-                           "Bad config value when parsing eNB configuration file %s, enb %d  srb1_max_retx_threshold %u!\n",
-                           RC.config_file_name, i, srb1_max_retx_threshold);
-          }
-
-          switch (srb1_poll_pdu) {
-            case 4:
-              rrc->srb1_poll_pdu = LTE_PollPDU_p4;
-              break;
-
-            case 8:
-              rrc->srb1_poll_pdu = LTE_PollPDU_p8;
-              break;
-
-            case 16:
-              rrc->srb1_poll_pdu = LTE_PollPDU_p16;
-              break;
-
-            case 32:
-              rrc->srb1_poll_pdu = LTE_PollPDU_p32;
-              break;
-
-            case 64:
-              rrc->srb1_poll_pdu = LTE_PollPDU_p64;
-              break;
-
-            case 128:
-              rrc->srb1_poll_pdu = LTE_PollPDU_p128;
-              break;
-
-            case 256:
-              rrc->srb1_poll_pdu = LTE_PollPDU_p256;
-              break;
-
-            default:
-              if (srb1_poll_pdu >= 10000)
-                rrc->srb1_poll_pdu = LTE_PollPDU_pInfinity;
-              else
-                AssertFatal (0,
-                             "Bad config value when parsing eNB configuration file %s, enb %d  srb1_poll_pdu %u!\n",
-                             RC.config_file_name, i, srb1_poll_pdu);
-          }
-
-          rrc->srb1_poll_byte             = srb1_poll_byte;
-
-          switch (srb1_poll_byte) {
-            case 25:
-              rrc->srb1_poll_byte = LTE_PollByte_kB25;
-              break;
-
-            case 50:
-              rrc->srb1_poll_byte = LTE_PollByte_kB50;
-              break;
-
-            case 75:
-              rrc->srb1_poll_byte = LTE_PollByte_kB75;
-              break;
-
-            case 100:
-              rrc->srb1_poll_byte = LTE_PollByte_kB100;
-              break;
-
-            case 125:
-              rrc->srb1_poll_byte = LTE_PollByte_kB125;
-              break;
-
-            case 250:
-              rrc->srb1_poll_byte = LTE_PollByte_kB250;
-              break;
-
-            case 375:
-              rrc->srb1_poll_byte = LTE_PollByte_kB375;
-              break;
-
-            case 500:
-              rrc->srb1_poll_byte = LTE_PollByte_kB500;
-              break;
-
-            case 750:
-              rrc->srb1_poll_byte = LTE_PollByte_kB750;
-              break;
-
-            case 1000:
-              rrc->srb1_poll_byte = LTE_PollByte_kB1000;
-              break;
-
-            case 1250:
-              rrc->srb1_poll_byte = LTE_PollByte_kB1250;
-              break;
-
-            case 1500:
-              rrc->srb1_poll_byte = LTE_PollByte_kB1500;
-              break;
-
-            case 2000:
-              rrc->srb1_poll_byte = LTE_PollByte_kB2000;
-              break;
-
-            case 3000:
-              rrc->srb1_poll_byte = LTE_PollByte_kB3000;
-              break;
-
-            default:
-              if (srb1_poll_byte >= 10000)
-                rrc->srb1_poll_byte = LTE_PollByte_kBinfinity;
-              else
-                AssertFatal (0,
-                             "Bad config value when parsing eNB configuration file %s, enb %d  srb1_poll_byte %u!\n",
-                             RC.config_file_name, i, srb1_poll_byte);
-          }
-
-          if (srb1_timer_poll_retransmit <= 250) {
-            rrc->srb1_timer_poll_retransmit = (srb1_timer_poll_retransmit - 5)/5;
-          } else if (srb1_timer_poll_retransmit <= 500) {
-            rrc->srb1_timer_poll_retransmit = (srb1_timer_poll_retransmit - 300)/50 + 50;
-          } else {
-            AssertFatal (0,
-                         "Bad config value when parsing eNB configuration file %s, enb %d  srb1_timer_poll_retransmit %u!\n",
-                         RC.config_file_name, i, srb1_timer_poll_retransmit);
-          }
-
-          if (srb1_timer_status_prohibit <= 250) {
-            rrc->srb1_timer_status_prohibit = srb1_timer_status_prohibit/5;
-          } else if ((srb1_timer_poll_retransmit >= 300) && (srb1_timer_poll_retransmit <= 500)) {
-            rrc->srb1_timer_status_prohibit = (srb1_timer_status_prohibit - 300)/50 + 51;
-          } else {
-            AssertFatal (0,
-                         "Bad config value when parsing eNB configuration file %s, enb %d  srb1_timer_status_prohibit %u!\n",
-                         RC.config_file_name, i, srb1_timer_status_prohibit);
-          }
-
-          switch (srb1_timer_reordering) {
-            case 0:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms0;
-              break;
-
-            case 5:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms5;
-              break;
-
-            case 10:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms10;
-              break;
-
-            case 15:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms15;
-              break;
-
-            case 20:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms20;
-              break;
-
-            case 25:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms25;
-              break;
-
-            case 30:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms30;
-              break;
-
-            case 35:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms35;
-              break;
-
-            case 40:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms40;
-              break;
-
-            case 45:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms45;
-              break;
-
-            case 50:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms50;
-              break;
-
-            case 55:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms55;
-              break;
-
-            case 60:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms60;
-              break;
-
-            case 65:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms65;
-              break;
-
-            case 70:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms70;
-              break;
-
-            case 75:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms75;
-              break;
-
-            case 80:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms80;
-              break;
-
-            case 85:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms85;
-              break;
-
-            case 90:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms90;
-              break;
-
-            case 95:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms95;
-              break;
-
-            case 100:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms100;
-              break;
-
-            case 110:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms110;
-              break;
-
-            case 120:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms120;
-              break;
-
-            case 130:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms130;
-              break;
-
-            case 140:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms140;
-              break;
-
-            case 150:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms150;
-              break;
-
-            case 160:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms160;
-              break;
-
-            case 170:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms170;
-              break;
-
-            case 180:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms180;
-              break;
-
-            case 190:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms190;
-              break;
-
-            case 200:
-              rrc->srb1_timer_reordering = LTE_T_Reordering_ms200;
-              break;
-
-            default:
-              AssertFatal (0,
-                           "Bad config value when parsing eNB configuration file %s, enb %d  srb1_timer_reordering %u!\n",
-                           RC.config_file_name, i, srb1_timer_reordering);
-          }
-        } else {
-          rrc->srb1_timer_poll_retransmit = LTE_T_PollRetransmit_ms80;
-          rrc->srb1_timer_reordering      = LTE_T_Reordering_ms35;
-          rrc->srb1_timer_status_prohibit = LTE_T_StatusProhibit_ms0;
-          rrc->srb1_poll_pdu              = LTE_PollPDU_p4;
-          rrc->srb1_poll_byte             = LTE_PollByte_kBinfinity;
-          rrc->srb1_max_retx_threshold    = LTE_UL_AM_RLC__maxRetxThreshold_t8;
-        }
-
-        break;
+        config_get( SRB1Params,sizeof(SRB1Params)/sizeof(paramdef_t), srb1path);
+
+
+	switch (srb1_params.srb1_max_retx_threshold) {
+	case 1:
+	  rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t1;
+	  break;
+	  
+	case 2:
+	  rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t2;
+	  break;
+	  
+	case 3:
+	  rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t3;
+	  break;
+	  
+	case 4:
+	  rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t4;
+	  break;
+	  
+	case 6:
+	  rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t6;
+	  break;
+	  
+	case 8:
+	  rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t8;
+	  break;
+	  
+	case 16:
+	  rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t16;
+	  break;
+	  
+	case 32:
+	  rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t32;
+	  break;
+	  
+	default:
+	  AssertFatal (0,
+		       "Bad config value when parsing eNB configuration file %s, enb %d  srb1_max_retx_threshold %u!\n",
+		       RC.config_file_name, i, srb1_params.srb1_max_retx_threshold);
+	}
+	
+	switch (srb1_params.srb1_poll_pdu) {
+	case 4:
+	  rrc->srb1_poll_pdu = LTE_PollPDU_p4;
+	  break;
+	  
+	case 8:
+	  rrc->srb1_poll_pdu = LTE_PollPDU_p8;
+	  break;
+	  
+	case 16:
+	  rrc->srb1_poll_pdu = LTE_PollPDU_p16;
+	  break;
+	  
+	case 32:
+	  rrc->srb1_poll_pdu = LTE_PollPDU_p32;
+	  break;
+	  
+	case 64:
+	  rrc->srb1_poll_pdu = LTE_PollPDU_p64;
+	  break;
+	  
+	case 128:
+	  rrc->srb1_poll_pdu = LTE_PollPDU_p128;
+	  break;
+	  
+	case 256:
+	  rrc->srb1_poll_pdu = LTE_PollPDU_p256;
+	  break;
+	  
+	default:
+	  if (srb1_params.srb1_poll_pdu >= 10000)
+	    rrc->srb1_poll_pdu = LTE_PollPDU_pInfinity;
+	  else
+	    AssertFatal (0,
+			 "Bad config value when parsing eNB configuration file %s, enb %d  srb1_poll_pdu %u!\n",
+			 RC.config_file_name, i, srb1_params.srb1_poll_pdu);
+	}
+	
+	rrc->srb1_poll_byte             = srb1_params.srb1_poll_byte;
+	
+	switch (srb1_params.srb1_poll_byte) {
+	case 25:
+	  rrc->srb1_poll_byte = LTE_PollByte_kB25;
+	  break;
+	  
+	case 50:
+	  rrc->srb1_poll_byte = LTE_PollByte_kB50;
+	  break;
+	  
+	case 75:
+	  rrc->srb1_poll_byte = LTE_PollByte_kB75;
+	  break;
+	  
+	case 100:
+	  rrc->srb1_poll_byte = LTE_PollByte_kB100;
+	  break;
+	  
+	case 125:
+	  rrc->srb1_poll_byte = LTE_PollByte_kB125;
+	  break;
+	  
+	case 250:
+	  rrc->srb1_poll_byte = LTE_PollByte_kB250;
+	  break;
+	  
+	case 375:
+	  rrc->srb1_poll_byte = LTE_PollByte_kB375;
+	  break;
+	  
+	case 500:
+	  rrc->srb1_poll_byte = LTE_PollByte_kB500;
+	  break;
+	  
+	case 750:
+	  rrc->srb1_poll_byte = LTE_PollByte_kB750;
+	  break;
+	  
+	case 1000:
+	  rrc->srb1_poll_byte = LTE_PollByte_kB1000;
+	  break;
+	  
+	case 1250:
+	  rrc->srb1_poll_byte = LTE_PollByte_kB1250;
+	  break;
+	  
+	case 1500:
+	  rrc->srb1_poll_byte = LTE_PollByte_kB1500;
+	  break;
+	  
+	case 2000:
+	  rrc->srb1_poll_byte = LTE_PollByte_kB2000;
+	  break;
+	  
+	case 3000:
+	  rrc->srb1_poll_byte = LTE_PollByte_kB3000;
+	  break;
+	  
+	default:
+	  if (srb1_params.srb1_poll_byte >= 10000)
+	    rrc->srb1_poll_byte = LTE_PollByte_kBinfinity;
+	  else
+	    AssertFatal (0,
+			 "Bad config value when parsing eNB configuration file %s, enb %d  srb1_poll_byte %u!\n",
+			 RC.config_file_name, i, srb1_params.srb1_poll_byte);
+	}
+	
+	if (srb1_params.srb1_timer_poll_retransmit <= 250) {
+	  rrc->srb1_timer_poll_retransmit = (srb1_params.srb1_timer_poll_retransmit - 5)/5;
+	} else if (srb1_params.srb1_timer_poll_retransmit <= 500) {
+	  rrc->srb1_timer_poll_retransmit = (srb1_params.srb1_timer_poll_retransmit - 300)/50 + 50;
+	} else {
+	  AssertFatal (0,
+		       "Bad config value when parsing eNB configuration file %s, enb %d  srb1_timer_poll_retransmit %u!\n",
+		       RC.config_file_name, i, srb1_params.srb1_timer_poll_retransmit);
+	}
+	
+	if (srb1_params.srb1_timer_status_prohibit <= 250) {
+	  rrc->srb1_timer_status_prohibit = srb1_params.srb1_timer_status_prohibit/5;
+	} else if ((srb1_params.srb1_timer_poll_retransmit >= 300) && (srb1_params.srb1_timer_poll_retransmit <= 500)) {
+	  rrc->srb1_timer_status_prohibit = (srb1_params.srb1_timer_status_prohibit - 300)/50 + 51;
+	} else {
+	  AssertFatal (0,
+		       "Bad config value when parsing eNB configuration file %s, enb %d  srb1_timer_status_prohibit %u!\n",
+		       RC.config_file_name, i, srb1_params.srb1_timer_status_prohibit);
+	}
+	
+	switch (srb1_params.srb1_timer_reordering) {
+	case 0:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms0;
+	  break;
+	  
+	case 5:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms5;
+	  break;
+	  
+	case 10:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms10;
+	  break;
+	  
+	case 15:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms15;
+	  break;
+	  
+	case 20:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms20;
+	  break;
+	  
+	case 25:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms25;
+	  break;
+	  
+	case 30:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms30;
+	  break;
+	  
+	case 35:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms35;
+	  break;
+	  
+	case 40:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms40;
+	  break;
+	  
+	case 45:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms45;
+	  break;
+	  
+	case 50:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms50;
+	  break;
+	  
+	case 55:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms55;
+	  break;
+	  
+	case 60:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms60;
+	  break;
+	  
+	case 65:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms65;
+	  break;
+	  
+	case 70:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms70;
+	  break;
+	  
+	case 75:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms75;
+	  break;
+	  
+	case 80:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms80;
+	  break;
+	  
+	case 85:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms85;
+	  break;
+	  
+	case 90:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms90;
+	  break;
+	  
+	case 95:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms95;
+	  break;
+	  
+	case 100:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms100;
+	  break;
+	  
+	case 110:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms110;
+	  break;
+	  
+	case 120:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms120;
+	  break;
+	  
+	case 130:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms130;
+	  break;
+	  
+	case 140:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms140;
+	  break;
+	  
+	case 150:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms150;
+	  break;
+	  
+	case 160:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms160;
+	  break;
+	  
+	case 170:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms170;
+	  break;
+	  
+	case 180:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms180;
+	  break;
+	  
+	case 190:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms190;
+	  break;
+	  
+	case 200:
+	  rrc->srb1_timer_reordering = LTE_T_Reordering_ms200;
+	  break;
+	  
+	default:
+	  AssertFatal (0,
+		       "Bad config value when parsing eNB configuration file %s, enb %d  srb1_timer_reordering %u!\n",
+		       RC.config_file_name, i, srb1_params.srb1_timer_reordering);
+	}
       }
     }
   }
 
   return 0;
+
 }
 
 int RCconfig_gtpu(void ) {
@@ -2061,124 +1769,12 @@ int RCconfig_S1(
   const char *active_enb[MAX_ENB];
   char *address = NULL;
   char *cidr    = NULL;
-  /*------------------------------------------------------------------------------*/
-  /*
-  * the only reason for all these variables is, that they are "hard-encoded" into
-  * the CCPARAMS_DESC macro and we need it for the default_DRX value ...
-  */
-  char       *frame_type                    = NULL;
-  int32_t     tdd_config                    = 0;
-  int32_t     tdd_config_s                  = 0;
-  char       *prefix_type                   = NULL;
-  char       *pbch_repetition               = NULL;
-  int32_t     eutra_band                    = 0;
-  long long int     downlink_frequency      = 0;
-  int32_t     uplink_frequency_offset       = 0;
-  int32_t     Nid_cell                      = 0;
-  int32_t     Nid_cell_mbsfn                = 0;
-  int32_t     N_RB_DL                       = 0;
-  int32_t     nb_antenna_ports              = 0;
-  int32_t     prach_root                    = 0;
-  int32_t     prach_config_index            = 0;
-  char            *prach_high_speed         = NULL;
-  int32_t     prach_zero_correlation        = 0;
-  int32_t     prach_freq_offset             = 0;
-  int32_t     pucch_delta_shift             = 0;
-  int32_t     pucch_nRB_CQI                 = 0;
-  int32_t     pucch_nCS_AN                  = 0;
-  int32_t     pucch_n1_AN                   = 0;
-  int32_t     pdsch_referenceSignalPower    = 0;
-  int32_t     pdsch_p_b                     = 0;
-  int32_t     pusch_n_SB                    = 0;
-  char       *pusch_hoppingMode             = NULL;
-  int32_t     pusch_hoppingOffset           = 0;
-  char          *pusch_enable64QAM          = NULL;
-  char          *pusch_groupHoppingEnabled  = NULL;
-  int32_t     pusch_groupAssignment         = 0;
-  char        *pusch_sequenceHoppingEnabled = NULL;
-  int32_t     pusch_nDMRS1                  = 0;
-  char       *phich_duration                = NULL;
-  char       *phich_resource                = NULL;
-  char       *srs_enable                    = NULL;
-  int32_t     srs_BandwidthConfig           = 0;
-  int32_t     srs_SubframeConfig            = 0;
-  char       *srs_ackNackST                 = NULL;
-  char       *srs_MaxUpPts                  = NULL;
-  int32_t     pusch_p0_Nominal              = 0;
-  char       *pusch_alpha                   = NULL;
-  int32_t     pucch_p0_Nominal              = 0;
-  int32_t     msg3_delta_Preamble           = 0;
-  char       *pucch_deltaF_Format1          = NULL;
-  char       *pucch_deltaF_Format1b         = NULL;
-  char       *pucch_deltaF_Format2          = NULL;
-  char       *pucch_deltaF_Format2a         = NULL;
-  char       *pucch_deltaF_Format2b         = NULL;
-  int32_t     rach_numberOfRA_Preambles     = 0;
-  char       *rach_preamblesGroupAConfig    = NULL;
-  int32_t     rach_sizeOfRA_PreamblesGroupA = 0;
-  int32_t     rach_messageSizeGroupA        = 0;
-  char       *rach_messagePowerOffsetGroupB = NULL;
-  int32_t     rach_powerRampingStep         = 0;
-  int32_t     rach_preambleInitialReceivedTargetPower = 0;
-  int32_t     rach_preambleTransMax         = 0;
-  int32_t     rach_raResponseWindowSize     = 10;
-  int32_t     rach_macContentionResolutionTimer = 0;
-  int32_t     rach_maxHARQ_Msg3Tx           = 0;
-  int32_t     pcch_defaultPagingCycle       = 0;
-  char       *pcch_nB                       = NULL;
-  int32_t     bcch_modificationPeriodCoeff  = 0;
-  int32_t     ue_TimersAndConstants_t300    = 0;
-  int32_t     ue_TimersAndConstants_t301    = 0;
-  int32_t     ue_TimersAndConstants_t310    = 0;
-  int32_t     ue_TimersAndConstants_t311    = 0;
-  int32_t     ue_TimersAndConstants_n310    = 0;
-  int32_t     ue_TimersAndConstants_n311    = 0;
-  int32_t     ue_TransmissionMode           = 0;
-  int32_t     ue_multiple_max               = 0;
-  //TTN - for D2D
-  //SIB18
-  const char       *rxPool_sc_CP_Len                                        = NULL;
-  const char       *rxPool_sc_Period                                        = NULL;
-  const char       *rxPool_data_CP_Len                                      = NULL;
-  libconfig_int     rxPool_ResourceConfig_prb_Num                           = 0;
-  libconfig_int     rxPool_ResourceConfig_prb_Start                         = 0;
-  libconfig_int     rxPool_ResourceConfig_prb_End                           = 0;
-  const char       *rxPool_ResourceConfig_offsetIndicator_present           = NULL;
-  libconfig_int     rxPool_ResourceConfig_offsetIndicator_choice            = 0;
-  const char       *rxPool_ResourceConfig_subframeBitmap_present            = NULL;
-  char             *rxPool_ResourceConfig_subframeBitmap_choice_bs_buf      = NULL;
-  libconfig_int     rxPool_ResourceConfig_subframeBitmap_choice_bs_size     = 0;
-  libconfig_int     rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused     = 0;
-  //SIB19
-  //For discRxPool
-  const char       *discRxPool_cp_Len                                              = NULL;
-  const char       *discRxPool_discPeriod                                          = NULL;
-  libconfig_int     discRxPool_numRetx                                             = 0;
-  libconfig_int     discRxPool_numRepetition                                       = 0;
-  libconfig_int     discRxPool_ResourceConfig_prb_Num                              = 0;
-  libconfig_int     discRxPool_ResourceConfig_prb_Start                            = 0;
-  libconfig_int     discRxPool_ResourceConfig_prb_End                              = 0;
-  const char       *discRxPool_ResourceConfig_offsetIndicator_present              = NULL;
-  libconfig_int     discRxPool_ResourceConfig_offsetIndicator_choice               = 0;
-  const char       *discRxPool_ResourceConfig_subframeBitmap_present               = NULL;
-  char             *discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf         = NULL;
-  libconfig_int     discRxPool_ResourceConfig_subframeBitmap_choice_bs_size        = 0;
-  libconfig_int     discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0;
-  //For discRxPoolPS
-  const char       *discRxPoolPS_cp_Len                                              = NULL;
-  const char       *discRxPoolPS_discPeriod                                          = NULL;
-  libconfig_int     discRxPoolPS_numRetx                                             = 0;
-  libconfig_int     discRxPoolPS_numRepetition                                       = 0;
-  libconfig_int     discRxPoolPS_ResourceConfig_prb_Num                              = 0;
-  libconfig_int     discRxPoolPS_ResourceConfig_prb_Start                            = 0;
-  libconfig_int     discRxPoolPS_ResourceConfig_prb_End                              = 0;
-  const char       *discRxPoolPS_ResourceConfig_offsetIndicator_present              = NULL;
-  libconfig_int     discRxPoolPS_ResourceConfig_offsetIndicator_choice               = 0;
-  const char       *discRxPoolPS_ResourceConfig_subframeBitmap_present               = NULL;
-  char             *discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf         = NULL;
-  libconfig_int     discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size        = 0;
-  libconfig_int     discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0;
-  /*------------------------------------------------------------------------------*/
+
+  ccparams_lte_t ccparams_lte;
+
+  memset((void*)&ccparams_lte,0,sizeof(ccparams_lte_t));
+
+
   // for no gcc warnings
   (void)my_int;
   memset((char *)active_enb, 0, MAX_ENB * sizeof(char *));
@@ -2215,7 +1811,7 @@ int RCconfig_S1(
           if (strcmp(ENBSParams[ENB_ACTIVE_ENBS_IDX].strlistptr[j], *(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr)) == 0) {
             paramdef_t PLMNParams[] = PLMNPARAMS_DESC;
             paramlist_def_t PLMNParamList = {ENB_CONFIG_STRING_PLMN_LIST, NULL, 0};
-            paramdef_t CCsParams[] = CCPARAMS_DESC;
+            paramdef_t CCsParams[] = CCPARAMS_DESC(ccparams_lte);
             /* map parameter checking array instances to parameter definition array instances */
             checkedparam_t config_check_CCparams[] = CCPARAMS_CHECK;
 
@@ -2290,7 +1886,7 @@ int RCconfig_S1(
             sprintf(aprefix, "%s.[%i].%s.[%i]", ENB_CONFIG_STRING_ENB_LIST, k, ENB_CONFIG_STRING_COMPONENT_CARRIERS, 0);
             config_get(CCsParams, sizeof(CCsParams)/sizeof(paramdef_t), aprefix);
 
-            switch (pcch_defaultPagingCycle) {
+            switch (ccparams_lte.pcch_defaultPagingCycle) {
               case 32: {
                 S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 0;
                 break;
@@ -2314,7 +1910,7 @@ int RCconfig_S1(
               default: {
                 LOG_E(S1AP, "Default I-DRX value in conf file is invalid (%i). Should be 32, 64, 128 or 256. \
            Default DRX set to 32 in MME configuration\n",
-                      pcch_defaultPagingCycle);
+                      ccparams_lte.pcch_defaultPagingCycle);
                 S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 0;
               }
             }
@@ -2404,80 +2000,20 @@ int RCconfig_X2(MessageDef *msg_p, uint32_t i) {
   int   enb_id;
   char *address = NULL;
   char *cidr    = NULL;
+
+  ccparams_lte_t ccparams_lte;
+
+  memset((void*)&ccparams_lte,0,sizeof(ccparams_lte_t));
+
+
   paramdef_t ENBSParams[] = ENBSPARAMS_DESC;
   paramdef_t ENBParams[]  = ENBPARAMS_DESC;
   paramlist_def_t ENBParamList = {ENB_CONFIG_STRING_ENB_LIST,NULL,0};
   /* get global parameters, defined outside any section in the config file */
   config_get( ENBSParams,sizeof(ENBSParams)/sizeof(paramdef_t),NULL);
-  /* define CC params */
-  int32_t Nid_cell = 0;
-  char *frame_type, *prefix_type, *pbch_repetition, *prach_high_speed,
-       *pusch_hoppingMode, *pusch_enable64QAM, *pusch_groupHoppingEnabled,
-       *pusch_sequenceHoppingEnabled, *phich_duration, *phich_resource,
-       *srs_enable, *srs_ackNackST, *srs_MaxUpPts, *pusch_alpha,
-       *pucch_deltaF_Format1, *pucch_deltaF_Format1b, *pucch_deltaF_Format2,
-       *pucch_deltaF_Format2a, *pucch_deltaF_Format2b,
-       *rach_preamblesGroupAConfig, *rach_messagePowerOffsetGroupB, *pcch_nB;
-  long long int     downlink_frequency;
-  int32_t tdd_config, tdd_config_s, eutra_band, uplink_frequency_offset,
-          Nid_cell_mbsfn, N_RB_DL, nb_antenna_ports, prach_root, prach_config_index,
-          prach_zero_correlation, prach_freq_offset, pucch_delta_shift,
-          pucch_nRB_CQI, pucch_nCS_AN, pucch_n1_AN, pdsch_referenceSignalPower,
-          pdsch_p_b, pusch_n_SB, pusch_hoppingOffset, pusch_groupAssignment,
-          pusch_nDMRS1, srs_BandwidthConfig, srs_SubframeConfig, pusch_p0_Nominal,
-          pucch_p0_Nominal, msg3_delta_Preamble, rach_numberOfRA_Preambles,
-          rach_sizeOfRA_PreamblesGroupA, rach_messageSizeGroupA,
-          rach_powerRampingStep, rach_preambleInitialReceivedTargetPower,
-          rach_preambleTransMax, rach_raResponseWindowSize,
-          rach_macContentionResolutionTimer, rach_maxHARQ_Msg3Tx,
-          pcch_defaultPagingCycle, bcch_modificationPeriodCoeff,
-          ue_TimersAndConstants_t300, ue_TimersAndConstants_t301,
-          ue_TimersAndConstants_t310, ue_TimersAndConstants_t311,
-          ue_TimersAndConstants_n310, ue_TimersAndConstants_n311,
-          ue_TransmissionMode, ue_multiple_max;
-  const char       *rxPool_sc_CP_Len;
-  const char       *rxPool_sc_Period;
-  const char       *rxPool_data_CP_Len;
-  libconfig_int     rxPool_ResourceConfig_prb_Num;
-  libconfig_int     rxPool_ResourceConfig_prb_Start;
-  libconfig_int     rxPool_ResourceConfig_prb_End;
-  const char       *rxPool_ResourceConfig_offsetIndicator_present;
-  libconfig_int     rxPool_ResourceConfig_offsetIndicator_choice;
-  const char       *rxPool_ResourceConfig_subframeBitmap_present;
-  char             *rxPool_ResourceConfig_subframeBitmap_choice_bs_buf;
-  libconfig_int     rxPool_ResourceConfig_subframeBitmap_choice_bs_size;
-  libconfig_int     rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused;
-  //SIB19
-  //for discRxPool
-  const char       *discRxPool_cp_Len;
-  const char       *discRxPool_discPeriod;
-  libconfig_int     discRxPool_numRetx;
-  libconfig_int     discRxPool_numRepetition;
-  libconfig_int     discRxPool_ResourceConfig_prb_Num;
-  libconfig_int     discRxPool_ResourceConfig_prb_Start;
-  libconfig_int     discRxPool_ResourceConfig_prb_End;
-  const char       *discRxPool_ResourceConfig_offsetIndicator_present;
-  libconfig_int     discRxPool_ResourceConfig_offsetIndicator_choice;
-  const char       *discRxPool_ResourceConfig_subframeBitmap_present;
-  char             *discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf;
-  libconfig_int     discRxPool_ResourceConfig_subframeBitmap_choice_bs_size;
-  libconfig_int     discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused;
-  //for discRxPoolPS
-  const char       *discRxPoolPS_cp_Len;
-  const char       *discRxPoolPS_discPeriod;
-  libconfig_int     discRxPoolPS_numRetx;
-  libconfig_int     discRxPoolPS_numRepetition;
-  libconfig_int     discRxPoolPS_ResourceConfig_prb_Num;
-  libconfig_int     discRxPoolPS_ResourceConfig_prb_Start;
-  libconfig_int     discRxPoolPS_ResourceConfig_prb_End;
-  const char       *discRxPoolPS_ResourceConfig_offsetIndicator_present;
-  libconfig_int     discRxPoolPS_ResourceConfig_offsetIndicator_choice;
-  const char       *discRxPoolPS_ResourceConfig_subframeBitmap_present;
-  char             *discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf;
-  libconfig_int     discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size;
-  libconfig_int     discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused;
+
   checkedparam_t config_check_CCparams[] = CCPARAMS_CHECK;
-  paramdef_t CCsParams[] = CCPARAMS_DESC;
+  paramdef_t CCsParams[] = CCPARAMS_DESC(ccparams_lte);
   paramlist_def_t CCsParamList = {ENB_CONFIG_STRING_COMPONENT_CARRIERS, NULL, 0};
 
   /* map parameter checking array instances to parameter definition array instances */
@@ -2486,188 +2022,190 @@ int RCconfig_X2(MessageDef *msg_p, uint32_t i) {
   }
 
   /*#if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME)
-      if (strcasecmp( *(ENBSParams[ENB_ASN1_VERBOSITY_IDX].strptr), ENB_CONFIG_STRING_ASN1_VERBOSITY_NONE) == 0) {
-        asn_debug      = 0;
-        asn1_xer_print = 0;
-      } else if (strcasecmp( *(ENBSParams[ENB_ASN1_VERBOSITY_IDX].strptr), ENB_CONFIG_STRING_ASN1_VERBOSITY_INFO) == 0) {
-        asn_debug      = 1;
-        asn1_xer_print = 1;
-      } else if (strcasecmp(*(ENBSParams[ENB_ASN1_VERBOSITY_IDX].strptr) , ENB_CONFIG_STRING_ASN1_VERBOSITY_ANNOYING) == 0) {
-        asn_debug      = 1;
-        asn1_xer_print = 2;
-      } else {
-        asn_debug      = 0;
-        asn1_xer_print = 0;
-      }
-  #endif */
+    if (strcasecmp( *(ENBSParams[ENB_ASN1_VERBOSITY_IDX].strptr), ENB_CONFIG_STRING_ASN1_VERBOSITY_NONE) == 0) {
+    asn_debug      = 0;
+    asn1_xer_print = 0;
+    } else if (strcasecmp( *(ENBSParams[ENB_ASN1_VERBOSITY_IDX].strptr), ENB_CONFIG_STRING_ASN1_VERBOSITY_INFO) == 0) {
+    asn_debug      = 1;
+    asn1_xer_print = 1;
+    } else if (strcasecmp(*(ENBSParams[ENB_ASN1_VERBOSITY_IDX].strptr) , ENB_CONFIG_STRING_ASN1_VERBOSITY_ANNOYING) == 0) {
+    asn_debug      = 1;
+    asn1_xer_print = 2;
+    } else {
+    asn_debug      = 0;
+    asn1_xer_print = 0;
+    }
+    #endif */
   AssertFatal(i < ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt,
-              "Failed to parse config file %s, %uth attribute %s \n",
-              RC.config_file_name, i, ENB_CONFIG_STRING_ACTIVE_ENBS);
+    "Failed to parse config file %s, %uth attribute %s \n",
+    RC.config_file_name, i, ENB_CONFIG_STRING_ACTIVE_ENBS);
 
   if (ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt > 0) {
     // Output a list of all eNBs.
     config_getlist( &ENBParamList,ENBParams,sizeof(ENBParams)/sizeof(paramdef_t),NULL);
-
+    
     if (ENBParamList.numelt > 0) {
       for (k = 0; k < ENBParamList.numelt; k++) {
-        if (ENBParamList.paramarray[k][ENB_ENB_ID_IDX].uptr == NULL) {
-          // Calculate a default eNB ID
+	if (ENBParamList.paramarray[k][ENB_ENB_ID_IDX].uptr == NULL) {
+	  // Calculate a default eNB ID
 # if defined(ENABLE_USE_MME)
-          uint32_t hash;
-          hash = s1ap_generate_eNB_id ();
-          enb_id = k + (hash & 0xFFFF8);
+	  uint32_t hash;
+	  hash = s1ap_generate_eNB_id ();
+	  enb_id = k + (hash & 0xFFFF8);
 # else
-          enb_id = k;
+	  enb_id = k;
 # endif
-        } else {
-          enb_id = *(ENBParamList.paramarray[k][ENB_ENB_ID_IDX].uptr);
-        }
-
-        // search if in active list
-        for (j = 0; j < ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt; j++) {
-          if (strcmp(ENBSParams[ENB_ACTIVE_ENBS_IDX].strlistptr[j], *(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr)) == 0) {
-            paramdef_t PLMNParams[] = PLMNPARAMS_DESC;
-            paramlist_def_t PLMNParamList = {ENB_CONFIG_STRING_PLMN_LIST, NULL, 0};
-            /* map parameter checking array instances to parameter definition array instances */
-            checkedparam_t config_check_PLMNParams [] = PLMNPARAMS_CHECK;
-
-            for (int I = 0; I < sizeof(PLMNParams) / sizeof(paramdef_t); ++I)
-              PLMNParams[I].chkPptr = &(config_check_PLMNParams[I]);
-
-            paramdef_t X2Params[]  = X2PARAMS_DESC;
-            paramlist_def_t X2ParamList = {ENB_CONFIG_STRING_TARGET_ENB_X2_IP_ADDRESS,NULL,0};
-            paramdef_t SCTPParams[]  = SCTPPARAMS_DESC;
-            paramdef_t NETParams[]  =  NETPARAMS_DESC;
-            /* TODO: fix the size - if set lower we have a crash (MAX_OPTNAME_SIZE was 64 when this code was written) */
-            /* this is most probably a problem with the config module */
-            char aprefix[MAX_OPTNAME_SIZE*80 + 8];
-            sprintf(aprefix,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k);
-            /* Some default/random parameters */
-            X2AP_REGISTER_ENB_REQ (msg_p).eNB_id = enb_id;
-
-            if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_MACRO_ENB") == 0) {
-              X2AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_MACRO_ENB;
-            } else  if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_HOME_ENB") == 0) {
-              X2AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_HOME_ENB;
-            } else {
-              AssertFatal (0,
-                           "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n",
-                           RC.config_file_name, i, *(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr));
-            }
-
-            X2AP_REGISTER_ENB_REQ (msg_p).eNB_name         = strdup(*(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr));
-            X2AP_REGISTER_ENB_REQ (msg_p).tac              = *ENBParamList.paramarray[k][ENB_TRACKING_AREA_CODE_IDX].uptr;
-            config_getlist(&PLMNParamList, PLMNParams, sizeof(PLMNParams)/sizeof(paramdef_t), aprefix);
-
-            if (PLMNParamList.numelt < 1 || PLMNParamList.numelt > 6)
-              AssertFatal(0, "The number of PLMN IDs must be in [1,6], but is %d\n",
-                          PLMNParamList.numelt);
-
-            if (PLMNParamList.numelt > 1)
-              LOG_W(X2AP, "X2AP currently handles only one PLMN, ignoring the others!\n");
-
-            X2AP_REGISTER_ENB_REQ (msg_p).mcc = *PLMNParamList.paramarray[0][ENB_MOBILE_COUNTRY_CODE_IDX].uptr;
-            X2AP_REGISTER_ENB_REQ (msg_p).mnc = *PLMNParamList.paramarray[0][ENB_MOBILE_NETWORK_CODE_IDX].uptr;
-            X2AP_REGISTER_ENB_REQ (msg_p).mnc_digit_length = *PLMNParamList.paramarray[0][ENB_MNC_DIGIT_LENGTH].u8ptr;
-            AssertFatal(X2AP_REGISTER_ENB_REQ(msg_p).mnc_digit_length == 3
-                        || X2AP_REGISTER_ENB_REQ(msg_p).mnc < 100,
-                        "MNC %d cannot be encoded in two digits as requested (change mnc_digit_length to 3)\n",
-                        X2AP_REGISTER_ENB_REQ(msg_p).mnc);
-            /* CC params */
-            config_getlist(&CCsParamList, NULL, 0, aprefix);
-            X2AP_REGISTER_ENB_REQ (msg_p).num_cc = CCsParamList.numelt;
-
-            if (CCsParamList.numelt > 0) {
-              //char ccspath[MAX_OPTNAME_SIZE*2 + 16];
-              for (J = 0; J < CCsParamList.numelt ; J++) {
-                sprintf(aprefix, "%s.[%i].%s.[%i]", ENB_CONFIG_STRING_ENB_LIST, k, ENB_CONFIG_STRING_COMPONENT_CARRIERS, J);
-                config_get(CCsParams, sizeof(CCsParams)/sizeof(paramdef_t), aprefix);
-                X2AP_REGISTER_ENB_REQ (msg_p).eutra_band[J] = eutra_band;
-                X2AP_REGISTER_ENB_REQ (msg_p).downlink_frequency[J] = (uint32_t) downlink_frequency;
-                X2AP_REGISTER_ENB_REQ (msg_p).uplink_frequency_offset[J] = (unsigned int) uplink_frequency_offset;
-                X2AP_REGISTER_ENB_REQ (msg_p).Nid_cell[J]= Nid_cell;
-
-                if (Nid_cell>503) {
-                  AssertFatal (0,
-                               "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for Nid_cell choice: 0...503 !\n",
-                               RC.config_file_name, k, Nid_cell);
-                }
-
-                X2AP_REGISTER_ENB_REQ (msg_p).N_RB_DL[J]= N_RB_DL;
-
-                if ((N_RB_DL!=6) && (N_RB_DL!=15) && (N_RB_DL!=25) && (N_RB_DL!=50) && (N_RB_DL!=75) && (N_RB_DL!=100)) {
-                  AssertFatal (0,
-                               "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for N_RB_DL choice: 6,15,25,50,75,100 !\n",
-                               RC.config_file_name, k, N_RB_DL);
-                }
-
-                if (strcmp(frame_type, "FDD") == 0) {
-                  X2AP_REGISTER_ENB_REQ (msg_p).frame_type[J] = FDD;
-                } else  if (strcmp(frame_type, "TDD") == 0) {
-                  X2AP_REGISTER_ENB_REQ (msg_p).frame_type[J] = TDD;
-                } else {
-                  AssertFatal (0,
-                               "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for frame_type choice: FDD or TDD !\n",
-                               RC.config_file_name, k, frame_type);
-                }
-
-                X2AP_REGISTER_ENB_REQ (msg_p).fdd_earfcn_DL[J] = to_earfcn_DL(eutra_band, downlink_frequency, N_RB_DL);
-                X2AP_REGISTER_ENB_REQ (msg_p).fdd_earfcn_UL[J] = to_earfcn_UL(eutra_band, downlink_frequency + uplink_frequency_offset, N_RB_DL);
-              }
-            }
-
-            sprintf(aprefix,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k);
-            config_getlist( &X2ParamList,X2Params,sizeof(X2Params)/sizeof(paramdef_t),aprefix);
-            AssertFatal(X2ParamList.numelt <= X2AP_MAX_NB_ENB_IP_ADDRESS,
-                        "value of X2ParamList.numelt %d must be lower than X2AP_MAX_NB_ENB_IP_ADDRESS %d value: reconsider to increase X2AP_MAX_NB_ENB_IP_ADDRESS\n",
-                        X2ParamList.numelt,X2AP_MAX_NB_ENB_IP_ADDRESS);
-            X2AP_REGISTER_ENB_REQ (msg_p).nb_x2 = 0;
-
-            for (l = 0; l < X2ParamList.numelt; l++) {
-              X2AP_REGISTER_ENB_REQ (msg_p).nb_x2 += 1;
-              strcpy(X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4_address,*(X2ParamList.paramarray[l][ENB_X2_IPV4_ADDRESS_IDX].strptr));
-              strcpy(X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6_address,*(X2ParamList.paramarray[l][ENB_X2_IPV6_ADDRESS_IDX].strptr));
-
-              if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv4") == 0) {
-                X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4 = 1;
-              } else if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv6") == 0) {
-                X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6 = 1;
-              } else if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "no") == 0) {
-                X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4 = 1;
-                X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6 = 1;
-              }
-            }
-
-            // SCTP SETTING
-            X2AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = SCTP_OUT_STREAMS;
-            X2AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams  = SCTP_IN_STREAMS;
+	} else {
+	  enb_id = *(ENBParamList.paramarray[k][ENB_ENB_ID_IDX].uptr);
+	}
+	
+	// search if in active list
+	for (j = 0; j < ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt; j++) {
+	  if (strcmp(ENBSParams[ENB_ACTIVE_ENBS_IDX].strlistptr[j], *(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr)) == 0) {
+	    paramdef_t PLMNParams[] = PLMNPARAMS_DESC;
+	    paramlist_def_t PLMNParamList = {ENB_CONFIG_STRING_PLMN_LIST, NULL, 0};
+	    /* map parameter checking array instances to parameter definition array instances */
+	    checkedparam_t config_check_PLMNParams [] = PLMNPARAMS_CHECK;
+	    
+	    for (int I = 0; I < sizeof(PLMNParams) / sizeof(paramdef_t); ++I)
+	      PLMNParams[I].chkPptr = &(config_check_PLMNParams[I]);
+	    
+	    paramdef_t X2Params[]  = X2PARAMS_DESC;
+	    paramlist_def_t X2ParamList = {ENB_CONFIG_STRING_TARGET_ENB_X2_IP_ADDRESS,NULL,0};
+	    paramdef_t SCTPParams[]  = SCTPPARAMS_DESC;
+	    paramdef_t NETParams[]  =  NETPARAMS_DESC;
+	    /* TODO: fix the size - if set lower we have a crash (MAX_OPTNAME_SIZE was 64 when this code was written) */
+	    /* this is most probably a problem with the config module */
+	    char aprefix[MAX_OPTNAME_SIZE*80 + 8];
+	    sprintf(aprefix,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k);
+	    /* Some default/random parameters */
+	    X2AP_REGISTER_ENB_REQ (msg_p).eNB_id = enb_id;
+	    
+	    if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_MACRO_ENB") == 0) {
+	      X2AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_MACRO_ENB;
+	    } else  if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_HOME_ENB") == 0) {
+	      X2AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_HOME_ENB;
+	    } else {
+	      AssertFatal (0,
+			   "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n",
+			   RC.config_file_name, i, *(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr));
+	    }
+	    
+	    X2AP_REGISTER_ENB_REQ (msg_p).eNB_name         = strdup(*(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr));
+	    X2AP_REGISTER_ENB_REQ (msg_p).tac              = *ENBParamList.paramarray[k][ENB_TRACKING_AREA_CODE_IDX].uptr;
+	    config_getlist(&PLMNParamList, PLMNParams, sizeof(PLMNParams)/sizeof(paramdef_t), aprefix);
+	    
+	    if (PLMNParamList.numelt < 1 || PLMNParamList.numelt > 6)
+	      AssertFatal(0, "The number of PLMN IDs must be in [1,6], but is %d\n",
+			  PLMNParamList.numelt);
+	    
+	    
+	    if (PLMNParamList.numelt > 1)
+	      LOG_W(X2AP, "X2AP currently handles only one PLMN, ignoring the others!\n");
+	    
+	    X2AP_REGISTER_ENB_REQ (msg_p).mcc = *PLMNParamList.paramarray[0][ENB_MOBILE_COUNTRY_CODE_IDX].uptr;
+	    X2AP_REGISTER_ENB_REQ (msg_p).mnc = *PLMNParamList.paramarray[0][ENB_MOBILE_NETWORK_CODE_IDX].uptr;
+	    X2AP_REGISTER_ENB_REQ (msg_p).mnc_digit_length = *PLMNParamList.paramarray[0][ENB_MNC_DIGIT_LENGTH].u8ptr;
+	    AssertFatal(X2AP_REGISTER_ENB_REQ(msg_p).mnc_digit_length == 3
+			|| X2AP_REGISTER_ENB_REQ(msg_p).mnc < 100,
+			"MNC %d cannot be encoded in two digits as requested (change mnc_digit_length to 3)\n",
+			X2AP_REGISTER_ENB_REQ(msg_p).mnc);
+	    /* CC params */
+	    config_getlist(&CCsParamList, NULL, 0, aprefix);
+	    X2AP_REGISTER_ENB_REQ (msg_p).num_cc = CCsParamList.numelt;
+	    
+	    if (CCsParamList.numelt > 0) {
+	      //char ccspath[MAX_OPTNAME_SIZE*2 + 16];
+	      for (J = 0; J < CCsParamList.numelt ; J++) {
+		sprintf(aprefix, "%s.[%i].%s.[%i]", ENB_CONFIG_STRING_ENB_LIST, k, ENB_CONFIG_STRING_COMPONENT_CARRIERS, J);
+		config_get(CCsParams, sizeof(CCsParams)/sizeof(paramdef_t), aprefix);
+		X2AP_REGISTER_ENB_REQ (msg_p).eutra_band[J] = ccparams_lte.eutra_band;
+		X2AP_REGISTER_ENB_REQ (msg_p).downlink_frequency[J] = (uint32_t) ccparams_lte.downlink_frequency;
+		X2AP_REGISTER_ENB_REQ (msg_p).uplink_frequency_offset[J] = (unsigned int) ccparams_lte.uplink_frequency_offset;
+		X2AP_REGISTER_ENB_REQ (msg_p).Nid_cell[J]= ccparams_lte.Nid_cell;
+		
+		if (ccparams_lte.Nid_cell>503) {
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for Nid_cell choice: 0...503 !\n",
+			       RC.config_file_name, k, ccparams_lte.Nid_cell);
+		}
+		
+		X2AP_REGISTER_ENB_REQ (msg_p).N_RB_DL[J]= ccparams_lte.N_RB_DL;
+		
+		if ((ccparams_lte.N_RB_DL!=6) && (ccparams_lte.N_RB_DL!=15) && (ccparams_lte.N_RB_DL!=25) && (ccparams_lte.N_RB_DL!=50) && (ccparams_lte.N_RB_DL!=75) && (ccparams_lte.N_RB_DL!=100)) {
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for N_RB_DL choice: 6,15,25,50,75,100 !\n",
+			       RC.config_file_name, k, ccparams_lte.N_RB_DL);
+		}
+		
+		if (strcmp(ccparams_lte.frame_type, "FDD") == 0) {
+		  X2AP_REGISTER_ENB_REQ (msg_p).frame_type[J] = FDD;
+		} else  if (strcmp(ccparams_lte.frame_type, "TDD") == 0) {
+		  X2AP_REGISTER_ENB_REQ (msg_p).frame_type[J] = TDD;
+		} else {
+		  AssertFatal (0,
+			       "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for frame_type choice: FDD or TDD !\n",
+			       RC.config_file_name, k, ccparams_lte.frame_type);
+		}
+		
+		X2AP_REGISTER_ENB_REQ (msg_p).fdd_earfcn_DL[J] = to_earfcn_DL(ccparams_lte.eutra_band, ccparams_lte.downlink_frequency, ccparams_lte.N_RB_DL);
+		X2AP_REGISTER_ENB_REQ (msg_p).fdd_earfcn_UL[J] = to_earfcn_UL(ccparams_lte.eutra_band, ccparams_lte.downlink_frequency + ccparams_lte.uplink_frequency_offset, ccparams_lte.N_RB_DL);
+	      }
+	    }
+	    
+	    sprintf(aprefix,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k);
+	    config_getlist( &X2ParamList,X2Params,sizeof(X2Params)/sizeof(paramdef_t),aprefix);
+	    AssertFatal(X2ParamList.numelt <= X2AP_MAX_NB_ENB_IP_ADDRESS,
+			"value of X2ParamList.numelt %d must be lower than X2AP_MAX_NB_ENB_IP_ADDRESS %d value: reconsider to increase X2AP_MAX_NB_ENB_IP_ADDRESS\n",
+			X2ParamList.numelt,X2AP_MAX_NB_ENB_IP_ADDRESS);
+	    X2AP_REGISTER_ENB_REQ (msg_p).nb_x2 = 0;
+	    
+	    for (l = 0; l < X2ParamList.numelt; l++) {
+	      X2AP_REGISTER_ENB_REQ (msg_p).nb_x2 += 1;
+	      strcpy(X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4_address,*(X2ParamList.paramarray[l][ENB_X2_IPV4_ADDRESS_IDX].strptr));
+	      strcpy(X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6_address,*(X2ParamList.paramarray[l][ENB_X2_IPV6_ADDRESS_IDX].strptr));
+	      
+	      if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv4") == 0) {
+		X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4 = 1;
+	      } else if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv6") == 0) {
+		X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6 = 1;
+	      } else if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "no") == 0) {
+		X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4 = 1;
+		X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6 = 1;
+	      }
+	    }
+	    
+	    
+	    // SCTP SETTING
+	    X2AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = SCTP_OUT_STREAMS;
+	    X2AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams  = SCTP_IN_STREAMS;
 # if defined(ENABLE_USE_MME)
-            sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_SCTP_CONFIG);
-            config_get( SCTPParams,sizeof(SCTPParams)/sizeof(paramdef_t),aprefix);
-            X2AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams = (uint16_t)*(SCTPParams[ENB_SCTP_INSTREAMS_IDX].uptr);
-            X2AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = (uint16_t)*(SCTPParams[ENB_SCTP_OUTSTREAMS_IDX].uptr);
+	    sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_SCTP_CONFIG);
+	    config_get( SCTPParams,sizeof(SCTPParams)/sizeof(paramdef_t),aprefix);
+	    X2AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams = (uint16_t)*(SCTPParams[ENB_SCTP_INSTREAMS_IDX].uptr);
+	    X2AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = (uint16_t)*(SCTPParams[ENB_SCTP_OUTSTREAMS_IDX].uptr);
 #endif
-            sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG);
-            // NETWORK_INTERFACES
-            config_get( NETParams,sizeof(NETParams)/sizeof(paramdef_t),aprefix);
-            X2AP_REGISTER_ENB_REQ (msg_p).enb_port_for_X2C = (uint32_t)*(NETParams[ENB_PORT_FOR_X2C_IDX].uptr);
-
-            if ((NETParams[ENB_IPV4_ADDR_FOR_X2C_IDX].strptr == NULL) || (X2AP_REGISTER_ENB_REQ (msg_p).enb_port_for_X2C == 0)) {
-              LOG_E(RRC,"Add eNB IPv4 address and/or port for X2C in the CONF file!\n");
-              exit(1);
-            }
-
-            cidr = *(NETParams[ENB_IPV4_ADDR_FOR_X2C_IDX].strptr);
-            address = strtok(cidr, "/");
-            X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv6 = 0;
-            X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv4 = 1;
-            strcpy(X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv4_address, address);
-          }
-        }
+	    sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG);
+	    // NETWORK_INTERFACES
+	    config_get( NETParams,sizeof(NETParams)/sizeof(paramdef_t),aprefix);
+	    X2AP_REGISTER_ENB_REQ (msg_p).enb_port_for_X2C = (uint32_t)*(NETParams[ENB_PORT_FOR_X2C_IDX].uptr);
+	    
+	    if ((NETParams[ENB_IPV4_ADDR_FOR_X2C_IDX].strptr == NULL) || (X2AP_REGISTER_ENB_REQ (msg_p).enb_port_for_X2C == 0)) {
+	      LOG_E(RRC,"Add eNB IPv4 address and/or port for X2C in the CONF file!\n");
+	      exit(1);
+	    }
+	    
+	    cidr = *(NETParams[ENB_IPV4_ADDR_FOR_X2C_IDX].strptr);
+	    address = strtok(cidr, "/");
+	    X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv6 = 0;
+	    X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv4 = 1;
+	    strcpy(X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv4_address, address);
+	  }
+	}
       }
     }
   }
-
+  
   return 0;
 }
 
@@ -2722,7 +2260,6 @@ void RCConfig(void) {
 
   if (RC.nb_inst > 0) {
     RC.nb_CC = (int *)malloc((1+RC.nb_inst)*sizeof(int));
-
     for (int i=0; i<RC.nb_inst; i++) {
       sprintf(aprefix,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,i);
       config_getlist( &CCsParamList,NULL,0, aprefix);
diff --git a/openair2/ENB_APP/enb_config.h b/openair2/ENB_APP/enb_config.h
index f5cf3018288485afffd0c5118b00e0c2b24917bb..0edb84039ba9b5ea3f5c3b0ba08aedbe0da63995 100644
--- a/openair2/ENB_APP/enb_config.h
+++ b/openair2/ENB_APP/enb_config.h
@@ -44,6 +44,7 @@
 #include "rrc_messages_types.h"
 #include "RRC/LTE/rrc_defs.h"
 #include <intertask_interface.h>
+#include "enb_paramdef.h"
 
 #define IPV4_STR_ADDR_TO_INT_NWBO(AdDr_StR,NwBo,MeSsAgE ) do {\
             struct in_addr inp;\
@@ -104,5 +105,8 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc);
 int RCconfig_S1(MessageDef *msg_p, uint32_t i);
 int RCconfig_X2(MessageDef *msg_p, uint32_t i);
 
+void fill_SL_configuration(MessageDef *msg_p,  ccparams_sidelink_t *SLconfig,int cell_idx,int cc_idx,char *config_fname);
+void fill_eMTC_configuration(MessageDef *msg_p,  ccparams_eMTC_t *eMTCconfig, int cell_idx,int cc_idx,char *config_fname,char *brparamspath);
+
 #endif /* ENB_CONFIG_H_ */
 /** @} */
diff --git a/openair2/ENB_APP/enb_config_SL.c b/openair2/ENB_APP/enb_config_SL.c
new file mode 100644
index 0000000000000000000000000000000000000000..e9f2515f81603abebc44a0aeb5e5f955057c7589
--- /dev/null
+++ b/openair2/ENB_APP/enb_config_SL.c
@@ -0,0 +1,293 @@
+/*
+ * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The OpenAirInterface Software Alliance licenses this file to You under
+ * the OAI Public License, Version 1.1  (the "License"); you may not use this file
+ * except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.openairinterface.org/?page_id=698
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *-------------------------------------------------------------------------------
+ * For more information about the OpenAirInterface (OAI) Software Alliance:
+ *      contact@openairinterface.org
+ */
+
+/*
+  enb_config_SL.c
+  -------------------
+  AUTHOR  : T.T.Nguyen / R. Knopp
+  COMPANY : EURECOM
+  EMAIL   : raymond.knopp@eurecom.fr
+*/
+
+#include <string.h>
+#include <inttypes.h>
+
+#include "common/utils/LOG/log.h"
+#include "assertions.h"
+#include "enb_config.h"
+#include "intertask_interface.h"
+#include "LTE_SystemInformationBlockType2.h"
+#include "common/config/config_userapi.h"
+#include "RRC_config_tools.h"
+#include "enb_paramdef.h"
+#include "enb_paramdef_sidelink.h"
+ 
+void fill_SL_configuration(MessageDef *msg_p,  ccparams_sidelink_t *SLconfig,int cell_idx,int cc_idx,char *config_fname) {
+
+  printf("Configuring SL\n");
+  //SIB18
+  if (strcmp(SLconfig->rxPool_sc_CP_Len,"normal")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_CP_Len[cc_idx] = LTE_SL_CP_Len_r12_normal;
+  } else if (strcmp(SLconfig->rxPool_sc_CP_Len,"extended")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_CP_Len[cc_idx] = LTE_SL_CP_Len_r12_extended;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rxPool_sc_CP_Len choice: normal,extended!\n",
+		 config_fname, cell_idx, SLconfig->rxPool_sc_CP_Len);
+	      
+  if (strcmp(SLconfig->rxPool_sc_Period,"sf40")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[cc_idx] = LTE_SL_PeriodComm_r12_sf40;
+  } else if (strcmp(SLconfig->rxPool_sc_Period,"sf60")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[cc_idx] = LTE_SL_PeriodComm_r12_sf60;
+  } else if (strcmp(SLconfig->rxPool_sc_Period,"sf70")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[cc_idx] = LTE_SL_PeriodComm_r12_sf70;
+  } else if (strcmp(SLconfig->rxPool_sc_Period,"sf80")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[cc_idx] = LTE_SL_PeriodComm_r12_sf80;
+  } else if (strcmp(SLconfig->rxPool_sc_Period,"sf120")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[cc_idx] = LTE_SL_PeriodComm_r12_sf120;
+  } else if (strcmp(SLconfig->rxPool_sc_Period,"sf140")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[cc_idx] = LTE_SL_PeriodComm_r12_sf140;
+  } else if (strcmp(SLconfig->rxPool_sc_Period,"sf160")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[cc_idx] = LTE_SL_PeriodComm_r12_sf160;
+  } else if (strcmp(SLconfig->rxPool_sc_Period,"sf240")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[cc_idx] = LTE_SL_PeriodComm_r12_sf240;
+  } else if (strcmp(SLconfig->rxPool_sc_Period,"sf280")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[cc_idx] = LTE_SL_PeriodComm_r12_sf280;
+  } else if (strcmp(SLconfig->rxPool_sc_Period,"sf320")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[cc_idx] = LTE_SL_PeriodComm_r12_sf320;
+  } else if (strcmp(SLconfig->rxPool_sc_Period,"spare6")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[cc_idx] = LTE_SL_PeriodComm_r12_spare6;
+  } else if (strcmp(SLconfig->rxPool_sc_Period,"spare5")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[cc_idx] = LTE_SL_PeriodComm_r12_spare5;
+  } else if (strcmp(SLconfig->rxPool_sc_Period,"spare4")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[cc_idx] = LTE_SL_PeriodComm_r12_spare4;
+  } else if (strcmp(SLconfig->rxPool_sc_Period,"spare3")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[cc_idx] = LTE_SL_PeriodComm_r12_spare3;
+  } else if (strcmp(SLconfig->rxPool_sc_Period,"spare2")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[cc_idx] = LTE_SL_PeriodComm_r12_spare2;
+  } else if (strcmp(SLconfig->rxPool_sc_Period,"spare")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[cc_idx] = LTE_SL_PeriodComm_r12_spare;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rxPool_sc_Period choice: sf40,sf60,sf70,sf80,sf120,sf140,sf160,sf240,sf280,sf320,spare6,spare5,spare4,spare3,spare2,spare!\n",
+		 config_fname, cell_idx, SLconfig->rxPool_sc_Period);
+	      
+  if (strcmp(SLconfig->rxPool_data_CP_Len,"normal")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_data_CP_Len[cc_idx] = LTE_SL_CP_Len_r12_normal;
+  } else if (strcmp(SLconfig->rxPool_data_CP_Len,"extended")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_data_CP_Len[cc_idx] = LTE_SL_CP_Len_r12_extended;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rxPool_data_CP_Len choice: normal,extended!\n",
+		 config_fname, cell_idx, SLconfig->rxPool_data_CP_Len);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_prb_Num[cc_idx] = SLconfig->rxPool_ResourceConfig_prb_Num;
+  RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_prb_Start[cc_idx] = SLconfig->rxPool_ResourceConfig_prb_Start;
+  RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_prb_End[cc_idx] = SLconfig->rxPool_ResourceConfig_prb_End;
+	      
+  if (strcmp(SLconfig->rxPool_ResourceConfig_offsetIndicator_present,"prNothing")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_offsetIndicator_present[cc_idx] = LTE_SL_OffsetIndicator_r12_PR_NOTHING;
+  } else if (strcmp(SLconfig->rxPool_ResourceConfig_offsetIndicator_present,"prSmall")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_offsetIndicator_present[cc_idx] = LTE_SL_OffsetIndicator_r12_PR_small_r12;
+  } else if (strcmp(SLconfig->rxPool_ResourceConfig_offsetIndicator_present,"prLarge")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_offsetIndicator_present[cc_idx] = LTE_SL_OffsetIndicator_r12_PR_large_r12;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rxPool_ResourceConfig_offsetIndicator_present choice: prNothing,prSmal,prLarge!\n",
+		 config_fname, cell_idx, SLconfig->rxPool_ResourceConfig_offsetIndicator_present);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_offsetIndicator_choice[cc_idx] = SLconfig->rxPool_ResourceConfig_offsetIndicator_choice;
+	      
+  if (strcmp(SLconfig->rxPool_ResourceConfig_subframeBitmap_present,"prNothing")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_NOTHING;
+  } else if (strcmp(SLconfig->rxPool_ResourceConfig_subframeBitmap_present,"prBs4")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_bs4_r12;
+  } else if (strcmp(SLconfig->rxPool_ResourceConfig_subframeBitmap_present,"prBs8")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_bs8_r12;
+  } else if (strcmp(SLconfig->rxPool_ResourceConfig_subframeBitmap_present,"prBs12")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_bs12_r12;
+  } else if (strcmp(SLconfig->rxPool_ResourceConfig_subframeBitmap_present,"prBs16")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_bs16_r12;
+  } else if (strcmp(SLconfig->rxPool_ResourceConfig_subframeBitmap_present,"prBs30")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_bs30_r12;
+  } else if (strcmp(SLconfig->rxPool_ResourceConfig_subframeBitmap_present,"prBs40")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_bs40_r12;
+  } else if (strcmp(SLconfig->rxPool_ResourceConfig_subframeBitmap_present,"prBs42")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_bs42_r12;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rxPool_ResourceConfig_subframeBitmap_present choice: prNothing,prBs4,prBs8,prBs12,prBs16,prBs30,prBs40,prBs42!\n",
+		 config_fname, cell_idx, SLconfig->rxPool_ResourceConfig_subframeBitmap_present);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[cc_idx] = SLconfig->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf;
+  RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_choice_bs_size[cc_idx] = SLconfig->rxPool_ResourceConfig_subframeBitmap_choice_bs_size;
+  RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[cc_idx] = SLconfig->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused;
+	      
+  //SIB19 - for discRxPool
+  if (strcmp(SLconfig->discRxPool_cp_Len,"normal")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPool_cp_Len[cc_idx] = LTE_SL_CP_Len_r12_normal;
+  } else if (strcmp(SLconfig->discRxPool_cp_Len,"extended")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPool_cp_Len[cc_idx] = LTE_SL_CP_Len_r12_extended;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPool_cp_Len choice: normal,extended!\n",
+		 config_fname, cell_idx, SLconfig->discRxPool_cp_Len);
+	      
+  if (strcmp(SLconfig->discRxPool_discPeriod,"rf32")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[cc_idx] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf32;
+  } else if (strcmp(SLconfig->discRxPool_discPeriod,"rf64")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[cc_idx] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf64;
+  } else if (strcmp(SLconfig->discRxPool_discPeriod,"rf128")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[cc_idx] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf128;
+  } else if (strcmp(SLconfig->discRxPool_discPeriod,"rf256")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[cc_idx] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf256;
+  } else if (strcmp(SLconfig->discRxPool_discPeriod,"rf512")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[cc_idx] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf512;
+  } else if (strcmp(SLconfig->discRxPool_discPeriod,"rf1024")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[cc_idx] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf1024;
+  } else if (strcmp(SLconfig->discRxPool_discPeriod,"rf16")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[cc_idx] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf16_v1310;
+  } else if (strcmp(SLconfig->discRxPool_discPeriod,"spare")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[cc_idx] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_spare;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPool_discPeriod choice: rf32,rf64,rf128,rf512,rf1024,rf16,spare!\n",
+		 config_fname, cell_idx, SLconfig->discRxPool_discPeriod);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).discRxPool_numRetx[cc_idx] = SLconfig->discRxPool_numRetx;
+  RRC_CONFIGURATION_REQ (msg_p).discRxPool_numRepetition[cc_idx] = SLconfig->discRxPool_numRepetition;
+  RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_prb_Num[cc_idx] = SLconfig->discRxPool_ResourceConfig_prb_Num;
+  RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_prb_Start[cc_idx] = SLconfig->discRxPool_ResourceConfig_prb_Start;
+  RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_prb_End[cc_idx] = SLconfig->discRxPool_ResourceConfig_prb_End;
+	      
+  if (strcmp(SLconfig->discRxPool_ResourceConfig_offsetIndicator_present,"prNothing")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_offsetIndicator_present[cc_idx] = LTE_SL_OffsetIndicator_r12_PR_NOTHING;
+  } else if (strcmp(SLconfig->discRxPool_ResourceConfig_offsetIndicator_present,"prSmall")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_offsetIndicator_present[cc_idx] = LTE_SL_OffsetIndicator_r12_PR_small_r12;
+  } else if (strcmp(SLconfig->discRxPool_ResourceConfig_offsetIndicator_present,"prLarge")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_offsetIndicator_present[cc_idx] = LTE_SL_OffsetIndicator_r12_PR_large_r12;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPool_ResourceConfig_offsetIndicator_present choice: prNothing,prSmal,prLarge!\n",
+		 config_fname, cell_idx, SLconfig->discRxPool_ResourceConfig_offsetIndicator_present);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_offsetIndicator_choice[cc_idx] = SLconfig->discRxPool_ResourceConfig_offsetIndicator_choice;
+	      
+  if (strcmp(SLconfig->discRxPool_ResourceConfig_subframeBitmap_present,"prNothing")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_NOTHING;
+  } else if (strcmp(SLconfig->discRxPool_ResourceConfig_subframeBitmap_present,"prBs4")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_bs4_r12;
+  } else if (strcmp(SLconfig->discRxPool_ResourceConfig_subframeBitmap_present,"prBs8")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_bs8_r12;
+  } else if (strcmp(SLconfig->discRxPool_ResourceConfig_subframeBitmap_present,"prBs12")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_bs12_r12;
+  } else if (strcmp(SLconfig->discRxPool_ResourceConfig_subframeBitmap_present,"prBs16")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_bs16_r12;
+  } else if (strcmp(SLconfig->discRxPool_ResourceConfig_subframeBitmap_present,"prBs30")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_bs30_r12;
+  } else if (strcmp(SLconfig->discRxPool_ResourceConfig_subframeBitmap_present,"prBs40")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_bs40_r12;
+  } else if (strcmp(SLconfig->discRxPool_ResourceConfig_subframeBitmap_present,"prBs42")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_bs42_r12;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPool_ResourceConfig_subframeBitmap_present choice: prNothing,prBs4,prBs8,prBs12,prBs16,prBs30,prBs40,prBs42!\n",
+		 config_fname, cell_idx, SLconfig->discRxPool_ResourceConfig_subframeBitmap_present);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[cc_idx] = SLconfig->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf;
+  RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[cc_idx] = SLconfig->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size;
+  RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[cc_idx] = SLconfig->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused;
+	      
+  //SIB19 - For discRxPoolPS
+  if (strcmp(SLconfig->discRxPoolPS_cp_Len,"normal")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_cp_Len[cc_idx] = LTE_SL_CP_Len_r12_normal;
+  } else if (strcmp(SLconfig->discRxPoolPS_cp_Len,"extended")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_cp_Len[cc_idx] = LTE_SL_CP_Len_r12_extended;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPoolPS_cp_Len choice: normal,extended!\n",
+		 config_fname, cell_idx, SLconfig->discRxPoolPS_cp_Len);
+	      
+  if (strcmp(SLconfig->discRxPoolPS_discPeriod,"rf32")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[cc_idx] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf32;
+  } else if (strcmp(SLconfig->discRxPoolPS_discPeriod,"rf64")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[cc_idx] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf64;
+  } else if (strcmp(SLconfig->discRxPoolPS_discPeriod,"rf128")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[cc_idx] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf128;
+  } else if (strcmp(SLconfig->discRxPoolPS_discPeriod,"rf256")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[cc_idx] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf256;
+  } else if (strcmp(SLconfig->discRxPoolPS_discPeriod,"rf512")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[cc_idx] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf512;
+  } else if (strcmp(SLconfig->discRxPoolPS_discPeriod,"rf1024")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[cc_idx] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf1024;
+  } else if (strcmp(SLconfig->discRxPoolPS_discPeriod,"rf16")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[cc_idx] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_rf16_v1310;
+  } else if (strcmp(SLconfig->discRxPoolPS_discPeriod,"spare")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[cc_idx] = LTE_SL_DiscResourcePool_r12__discPeriod_r12_spare;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPoolPS_discPeriod choice: rf32,rf64,rf128,rf512,rf1024,rf16,spare!\n",
+		 config_fname, cell_idx, SLconfig->discRxPoolPS_discPeriod);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_numRetx[cc_idx] = SLconfig->discRxPoolPS_numRetx;
+  RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_numRepetition[cc_idx] = SLconfig->discRxPoolPS_numRepetition;
+  RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_prb_Num[cc_idx] = SLconfig->discRxPoolPS_ResourceConfig_prb_Num;
+  RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_prb_Start[cc_idx] = SLconfig->discRxPoolPS_ResourceConfig_prb_Start;
+  RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_prb_End[cc_idx] = SLconfig->discRxPoolPS_ResourceConfig_prb_End;
+	      
+  if (strcmp(SLconfig->discRxPoolPS_ResourceConfig_offsetIndicator_present,"prNothing")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_offsetIndicator_present[cc_idx] = LTE_SL_OffsetIndicator_r12_PR_NOTHING;
+  } else if (strcmp(SLconfig->discRxPoolPS_ResourceConfig_offsetIndicator_present,"prSmall")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_offsetIndicator_present[cc_idx] = LTE_SL_OffsetIndicator_r12_PR_small_r12;
+  } else if (strcmp(SLconfig->discRxPoolPS_ResourceConfig_offsetIndicator_present,"prLarge")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_offsetIndicator_present[cc_idx] = LTE_SL_OffsetIndicator_r12_PR_large_r12;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPoolPS_ResourceConfig_offsetIndicator_present choice: prNothing,prSmal,prLarge!\n",
+		 config_fname, cell_idx, SLconfig->discRxPoolPS_ResourceConfig_offsetIndicator_present);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_offsetIndicator_choice[cc_idx] = SLconfig->discRxPoolPS_ResourceConfig_offsetIndicator_choice;
+	      
+  if (strcmp(SLconfig->discRxPoolPS_ResourceConfig_subframeBitmap_present,"prNothing")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_NOTHING;
+  } else if (strcmp(SLconfig->discRxPoolPS_ResourceConfig_subframeBitmap_present,"prBs4")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_bs4_r12;
+  } else if (strcmp(SLconfig->discRxPoolPS_ResourceConfig_subframeBitmap_present,"prBs8")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_bs8_r12;
+  } else if (strcmp(SLconfig->discRxPoolPS_ResourceConfig_subframeBitmap_present,"prBs12")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_bs12_r12;
+  } else if (strcmp(SLconfig->discRxPoolPS_ResourceConfig_subframeBitmap_present,"prBs16")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_bs16_r12;
+  } else if (strcmp(SLconfig->discRxPoolPS_ResourceConfig_subframeBitmap_present,"prBs30")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_bs30_r12;
+  } else if (strcmp(SLconfig->discRxPoolPS_ResourceConfig_subframeBitmap_present,"prBs40")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_bs40_r12;
+  } else if (strcmp(SLconfig->discRxPoolPS_ResourceConfig_subframeBitmap_present,"prBs42")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[cc_idx] = LTE_SubframeBitmapSL_r12_PR_bs42_r12;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPoolPS_ResourceConfig_subframeBitmap_present choice: prNothing,prBs4,prBs8,prBs12,prBs16,prBs30,prBs40,prBs42!\n",
+		 config_fname, cell_idx, SLconfig->discRxPoolPS_ResourceConfig_subframeBitmap_present);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[cc_idx] = SLconfig->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf;
+  RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[cc_idx] = SLconfig->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size;
+  RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[cc_idx] = SLconfig->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused;
+} // sidelink_configured==1
diff --git a/openair2/ENB_APP/enb_config_eMTC.c b/openair2/ENB_APP/enb_config_eMTC.c
new file mode 100644
index 0000000000000000000000000000000000000000..f0a829c42487d3126592940b08a33a123591838e
--- /dev/null
+++ b/openair2/ENB_APP/enb_config_eMTC.c
@@ -0,0 +1,1210 @@
+/*
+ * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The OpenAirInterface Software Alliance licenses this file to You under
+ * the OAI Public License, Version 1.1  (the "License"); you may not use this file
+ * except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.openairinterface.org/?page_id=698
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *-------------------------------------------------------------------------------
+ * For more information about the OpenAirInterface (OAI) Software Alliance:
+ *      contact@openairinterface.org
+ */
+
+/*
+  enb_config_SL.c
+  -------------------
+  AUTHOR  : R. Knopp
+  COMPANY : EURECOM
+  EMAIL   : raymond.knopp@eurecom.fr
+*/
+
+#include <string.h>
+#include <inttypes.h>
+
+#include "common/utils/LOG/log.h"
+#include "assertions.h"
+#include "enb_config.h"
+#include "intertask_interface.h"
+#include "LTE_SystemInformationBlockType2.h"
+#include "common/config/config_userapi.h"
+#include "RRC_config_tools.h"
+#include "enb_paramdef.h"
+ 
+void fill_eMTC_configuration(MessageDef *msg_p,  ccparams_eMTC_t *eMTCconfig, int cell_idx,int cc_idx,char *config_fname,char *brparamspath) {
+
+  paramdef_t schedulingInfoBrParams[] = SI_INFO_BR_DESC(eMTCconfig);
+  paramlist_def_t schedulingInfoBrParamList = {ENB_CONFIG_STRING_SCHEDULING_INFO_BR, NULL, 0};
+  paramdef_t rachcelevelParams[]     = RACH_CE_LEVELINFOLIST_R13_DESC(eMTCconfig);
+  paramlist_def_t rachcelevellist    = {ENB_CONFIG_STRING_RACH_CE_LEVELINFOLIST_R13, NULL, 0};
+  paramdef_t rsrprangeParams[]       = RSRP_RANGE_LIST_DESC(eMTCconfig);
+  paramlist_def_t rsrprangelist      = {ENB_CONFIG_STRING_RSRP_RANGE_LIST, NULL, 0};
+  paramdef_t prachParams[]           = PRACH_PARAMS_CE_R13_DESC(eMTCconfig);
+  paramlist_def_t prachParamslist    = {ENB_CONFIG_STRING_PRACH_PARAMETERS_CE_R13, NULL, 0};
+  paramdef_t n1PUCCH_ANR13Params[]   = N1PUCCH_AN_INFOLIST_R13_DESC(eMTCconfig);
+  paramlist_def_t n1PUCCHInfoList    = {ENB_CONFIG_STRING_N1PUCCH_AN_INFOLIST_R13, NULL, 0};
+  paramdef_t pcchv1310Params[]       = PCCH_CONFIG_V1310_DESC(eMTCconfig);
+  paramdef_t sib2freqhoppingParams[] = SIB2_FREQ_HOPPING_R13_DESC(eMTCconfig);
+
+
+
+  printf("Found parameters for eMTC from %s : %s\n",config_fname,brparamspath);
+  RRC_CONFIGURATION_REQ(msg_p).schedulingInfoSIB1_BR_r13[cc_idx] = eMTCconfig->schedulingInfoSIB1_BR_r13;
+  
+  
+  if (!strcmp(eMTCconfig->cellSelectionInfoCE_r13, "ENABLE")) {
+    RRC_CONFIGURATION_REQ(msg_p).cellSelectionInfoCE_r13[cc_idx] = TRUE;
+    RRC_CONFIGURATION_REQ(msg_p).q_RxLevMinCE_r13[cc_idx]= eMTCconfig->q_RxLevMinCE_r13;
+    //                            RRC_CONFIGURATION_REQ(msg_p).q_QualMinRSRQ_CE_r13[cc_idx]= calloc(1, sizeof(long));
+    //                            *RRC_CONFIGURATION_REQ(msg_p).q_QualMinRSRQ_CE_r13[cc_idx]= q_QualMinRSRQ_CE_r13;
+  } else {
+    RRC_CONFIGURATION_REQ(msg_p).cellSelectionInfoCE_r13[cc_idx] = FALSE;
+  }
+  
+	      
+	      
+  if (!strcmp(eMTCconfig->bandwidthReducedAccessRelatedInfo_r13, "ENABLE")) {
+    RRC_CONFIGURATION_REQ(msg_p).bandwidthReducedAccessRelatedInfo_r13[cc_idx] = TRUE;
+		
+		
+		
+    if (!strcmp(eMTCconfig->si_WindowLength_BR_r13, "ms20")) {
+      RRC_CONFIGURATION_REQ(msg_p).si_WindowLength_BR_r13[cc_idx] = 0;
+    } else if (!strcmp(eMTCconfig->si_WindowLength_BR_r13, "ms40")) {
+      RRC_CONFIGURATION_REQ(msg_p).si_WindowLength_BR_r13[cc_idx] = 1;
+    } else if (!strcmp(eMTCconfig->si_WindowLength_BR_r13, "ms60")) {
+      RRC_CONFIGURATION_REQ(msg_p).si_WindowLength_BR_r13[cc_idx] = 2;
+    } else if (!strcmp(eMTCconfig->si_WindowLength_BR_r13, "ms80")) {
+      RRC_CONFIGURATION_REQ(msg_p).si_WindowLength_BR_r13[cc_idx] = 3;
+    } else if (!strcmp(eMTCconfig->si_WindowLength_BR_r13, "ms120")) {
+      RRC_CONFIGURATION_REQ(msg_p).si_WindowLength_BR_r13[cc_idx] = 4;
+    } else if (!strcmp(eMTCconfig->si_WindowLength_BR_r13, "ms160")) {
+      RRC_CONFIGURATION_REQ(msg_p).si_WindowLength_BR_r13[cc_idx] = 5;
+    } else if (!strcmp(eMTCconfig->si_WindowLength_BR_r13, "ms200")) {
+      RRC_CONFIGURATION_REQ(msg_p).si_WindowLength_BR_r13[cc_idx] = 6;
+    } else if (!strcmp(eMTCconfig->si_WindowLength_BR_r13, "spare")) {
+      RRC_CONFIGURATION_REQ(msg_p).si_WindowLength_BR_r13[cc_idx] = 7;
+    }
+		
+		
+    if (!strcmp(eMTCconfig->si_RepetitionPattern_r13, "everyRF")) {
+      RRC_CONFIGURATION_REQ(msg_p).si_RepetitionPattern_r13[cc_idx] = 0;
+    } else if (!strcmp(eMTCconfig->si_RepetitionPattern_r13, "every2ndRF")) {
+      RRC_CONFIGURATION_REQ(msg_p).si_RepetitionPattern_r13[cc_idx] = 1;
+    } else if (!strcmp(eMTCconfig->si_RepetitionPattern_r13, "every4thRF")) {
+      RRC_CONFIGURATION_REQ(msg_p).si_RepetitionPattern_r13[cc_idx] = 2;
+    } else if (!strcmp(eMTCconfig->si_RepetitionPattern_r13, "every8thRF")) {
+      RRC_CONFIGURATION_REQ(msg_p).si_RepetitionPattern_r13[cc_idx] = 3;
+    }
+		
+  } else {
+    RRC_CONFIGURATION_REQ(msg_p).bandwidthReducedAccessRelatedInfo_r13[cc_idx] = FALSE;
+  }
+	      
+  char schedulingInfoBrPath[MAX_OPTNAME_SIZE * 2];
+  config_getlist(&schedulingInfoBrParamList, NULL, 0, brparamspath);
+  RRC_CONFIGURATION_REQ (msg_p).scheduling_info_br_size[cc_idx] = schedulingInfoBrParamList.numelt;
+  int siInfoindex;
+  for (siInfoindex = 0; siInfoindex < schedulingInfoBrParamList.numelt; siInfoindex++) {
+    sprintf(schedulingInfoBrPath, "%s.%s.[%i]", brparamspath, ENB_CONFIG_STRING_EMTC_PARAMETERS, siInfoindex);
+    config_get(schedulingInfoBrParams, sizeof(schedulingInfoBrParams) / sizeof(paramdef_t), schedulingInfoBrPath);
+    RRC_CONFIGURATION_REQ (msg_p).si_Narrowband_r13[cc_idx][siInfoindex] = eMTCconfig->si_Narrowband_r13;
+    RRC_CONFIGURATION_REQ (msg_p).si_TBS_r13[cc_idx][siInfoindex] = eMTCconfig->si_TBS_r13;
+  }
+	      
+	      
+	      
+  //                        RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[cc_idx].system_info_value_tag_SI_size[cc_idx] = 0;
+	      
+	      
+  RRC_CONFIGURATION_REQ(msg_p).fdd_DownlinkOrTddSubframeBitmapBR_r13[cc_idx] = CALLOC(1, sizeof(BOOLEAN_t));
+  if (!strcmp(eMTCconfig->fdd_DownlinkOrTddSubframeBitmapBR_r13, "subframePattern40-r13")) {
+    *RRC_CONFIGURATION_REQ(msg_p).fdd_DownlinkOrTddSubframeBitmapBR_r13[cc_idx] = FALSE;
+    RRC_CONFIGURATION_REQ(msg_p).fdd_DownlinkOrTddSubframeBitmapBR_val_r13[cc_idx] = eMTCconfig->fdd_DownlinkOrTddSubframeBitmapBR_val_r13;
+  } else {
+    *RRC_CONFIGURATION_REQ(msg_p).fdd_DownlinkOrTddSubframeBitmapBR_r13[cc_idx] = TRUE;
+    RRC_CONFIGURATION_REQ(msg_p).fdd_DownlinkOrTddSubframeBitmapBR_val_r13[cc_idx] = eMTCconfig->fdd_DownlinkOrTddSubframeBitmapBR_val_r13;
+  }
+	      
+  RRC_CONFIGURATION_REQ(msg_p).startSymbolBR_r13[cc_idx] = eMTCconfig->startSymbolBR_r13;
+	      
+	      
+  if (!strcmp(eMTCconfig->si_HoppingConfigCommon_r13, "off")) {
+    RRC_CONFIGURATION_REQ(msg_p).si_HoppingConfigCommon_r13[cc_idx] = 1;
+  } else if (!strcmp(eMTCconfig->si_HoppingConfigCommon_r13, "on")) {
+    RRC_CONFIGURATION_REQ(msg_p).si_HoppingConfigCommon_r13[cc_idx] = 0;
+  }
+	      
+	      
+  RRC_CONFIGURATION_REQ(msg_p).si_ValidityTime_r13[cc_idx] = calloc(1, sizeof(long));
+  if (!strcmp(eMTCconfig->si_ValidityTime_r13, "true")) {
+    *RRC_CONFIGURATION_REQ(msg_p).si_ValidityTime_r13[cc_idx] = 0;
+  } else {
+    AssertFatal(0,
+		"Failed to parse eNB configuration file %s, enb %d  si_ValidityTime_r13 unknown value!\n",
+		config_fname, cell_idx);
+  }
+	      
+	      
+  if (!strcmp(eMTCconfig->freqHoppingParametersDL_r13, "ENABLE"))
+    {
+      RRC_CONFIGURATION_REQ(msg_p).freqHoppingParametersDL_r13[cc_idx] = TRUE;
+		  
+      if (!strcmp(eMTCconfig->interval_DLHoppingConfigCommonModeA_r13, "interval-TDD-r13"))
+	RRC_CONFIGURATION_REQ(msg_p).interval_DLHoppingConfigCommonModeA_r13[cc_idx] = FALSE;
+      else
+	RRC_CONFIGURATION_REQ(msg_p).interval_DLHoppingConfigCommonModeA_r13[cc_idx] = TRUE;
+      RRC_CONFIGURATION_REQ(msg_p).interval_DLHoppingConfigCommonModeA_r13_val[cc_idx] = eMTCconfig->interval_DLHoppingConfigCommonModeA_r13_val;
+		  
+      if (!strcmp(eMTCconfig->interval_DLHoppingConfigCommonModeB_r13, "interval-TDD-r13"))
+	RRC_CONFIGURATION_REQ(msg_p).interval_DLHoppingConfigCommonModeB_r13[cc_idx] = FALSE;
+      else
+	RRC_CONFIGURATION_REQ(msg_p).interval_DLHoppingConfigCommonModeB_r13[cc_idx] = TRUE;
+      RRC_CONFIGURATION_REQ(msg_p).interval_DLHoppingConfigCommonModeB_r13_val[cc_idx] = eMTCconfig->interval_DLHoppingConfigCommonModeB_r13_val;
+		  
+      RRC_CONFIGURATION_REQ(msg_p).mpdcch_pdsch_HoppingNB_r13[cc_idx] = calloc(1, sizeof(long));
+      if (!strcmp(eMTCconfig->mpdcch_pdsch_HoppingNB_r13, "nb2")) {
+	*RRC_CONFIGURATION_REQ(msg_p).mpdcch_pdsch_HoppingNB_r13[cc_idx] = 0;
+      } else if (!strcmp(eMTCconfig->mpdcch_pdsch_HoppingNB_r13, "nb4")) {
+	*RRC_CONFIGURATION_REQ(msg_p).mpdcch_pdsch_HoppingNB_r13[cc_idx] = 1;
+      } else {
+	AssertFatal(0,
+		    "Failed to parse eNB configuration file %s, enb %d  mpdcch_pdsch_HoppingNB_r13 unknown value!\n",
+		    config_fname, cell_idx);
+      }
+
+
+      RRC_CONFIGURATION_REQ(msg_p).mpdcch_pdsch_HoppingOffset_r13[cc_idx] = calloc(1, sizeof(long));
+      *RRC_CONFIGURATION_REQ(msg_p).mpdcch_pdsch_HoppingOffset_r13[cc_idx] = eMTCconfig->mpdcch_pdsch_HoppingOffset_r13;
+		  
+    }
+  else
+    {
+      RRC_CONFIGURATION_REQ(msg_p).freqHoppingParametersDL_r13[cc_idx] = FALSE;
+    }
+	      
+  /** ------------------------------SIB2/3 BR------------------------------------------ */
+	      
+	      
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].prach_root =  eMTCconfig->ccparams.prach_root;
+	      
+  if ((eMTCconfig->ccparams.prach_root <0) || (eMTCconfig->ccparams.prach_root > 1023))
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_root choice: 0..1023 !\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.prach_root);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].prach_config_index = eMTCconfig->ccparams.prach_config_index;
+	      
+  if ((eMTCconfig->ccparams.prach_config_index <0) || (eMTCconfig->ccparams.prach_config_index > 63))
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_config_index choice: 0..1023 !\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.prach_config_index);
+	      
+  if (!eMTCconfig->ccparams.prach_high_speed)
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n",
+		 config_fname, cell_idx,ENB_CONFIG_STRING_PRACH_HIGH_SPEED);
+  else if (strcmp(eMTCconfig->ccparams.prach_high_speed, "ENABLE") == 0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].prach_high_speed = TRUE;
+  } else if (strcmp(eMTCconfig->ccparams.prach_high_speed, "DISABLE") == 0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].prach_high_speed = FALSE;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for prach_config choice: ENABLE,DISABLE !\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.prach_high_speed);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].prach_zero_correlation = eMTCconfig->ccparams.prach_zero_correlation;
+	      
+  if ((eMTCconfig->ccparams.prach_zero_correlation <0) || (eMTCconfig->ccparams.prach_zero_correlation > 15))
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_zero_correlation choice: 0..15!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.prach_zero_correlation);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].prach_freq_offset = eMTCconfig->ccparams.prach_freq_offset;
+	      
+  if ((eMTCconfig->ccparams.prach_freq_offset <0) || (eMTCconfig->ccparams.prach_freq_offset > 94))
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_freq_offset choice: 0..94!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.prach_freq_offset);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pucch_delta_shift = eMTCconfig->ccparams.pucch_delta_shift-1;
+	      
+  if ((eMTCconfig->ccparams.pucch_delta_shift <1) || (eMTCconfig->ccparams.pucch_delta_shift > 3))
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_delta_shift choice: 1..3!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pucch_delta_shift);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pucch_nRB_CQI = eMTCconfig->ccparams.pucch_nRB_CQI;
+	      
+  if ((eMTCconfig->ccparams.pucch_nRB_CQI <0) || (eMTCconfig->ccparams.pucch_nRB_CQI > 98))
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_nRB_CQI choice: 0..98!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pucch_nRB_CQI);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pucch_nCS_AN = eMTCconfig->ccparams.pucch_nCS_AN;
+	      
+  if ((eMTCconfig->ccparams.pucch_nCS_AN <0) || (eMTCconfig->ccparams.pucch_nCS_AN > 7))
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_nCS_AN choice: 0..7!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pucch_nCS_AN);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pucch_n1_AN = eMTCconfig->ccparams.pucch_n1_AN;
+	      
+  if ((eMTCconfig->ccparams.pucch_n1_AN <0) || (eMTCconfig->ccparams.pucch_n1_AN > 2047))
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_n1_AN choice: 0..2047!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pucch_n1_AN);
+	      
+  //#endif
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pdsch_referenceSignalPower = eMTCconfig->ccparams.pdsch_referenceSignalPower;
+	      
+  if ((eMTCconfig->ccparams.pdsch_referenceSignalPower <-60) || (eMTCconfig->ccparams.pdsch_referenceSignalPower > 50))
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pdsch_referenceSignalPower choice:-60..50!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pdsch_referenceSignalPower);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pdsch_p_b = eMTCconfig->ccparams.pdsch_p_b;
+	      
+  if ((eMTCconfig->ccparams.pdsch_p_b <0) || (eMTCconfig->ccparams.pdsch_p_b > 3))
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pdsch_p_b choice: 0..3!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pdsch_p_b);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pusch_n_SB = eMTCconfig->ccparams.pusch_n_SB;
+	      
+  if ((eMTCconfig->ccparams.pusch_n_SB <1) || (eMTCconfig->ccparams.pusch_n_SB > 4))
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_n_SB choice: 1..4!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pusch_n_SB);
+	      
+  if (!eMTCconfig->ccparams.pusch_hoppingMode)
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d define %s: interSubframe,intraAndInterSubframe!\n",
+		 config_fname, cell_idx,ENB_CONFIG_STRING_PUSCH_HOPPINGMODE);
+  else if (strcmp(eMTCconfig->ccparams.pusch_hoppingMode,"interSubFrame")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pusch_hoppingMode = LTE_PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_interSubFrame;
+  }  else if (strcmp(eMTCconfig->ccparams.pusch_hoppingMode,"intraAndInterSubFrame")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pusch_hoppingMode = LTE_PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_intraAndInterSubFrame;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_hoppingMode choice: interSubframe,intraAndInterSubframe!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pusch_hoppingMode);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pusch_hoppingOffset = eMTCconfig->ccparams.pusch_hoppingOffset;
+	      
+  if ((eMTCconfig->ccparams.pusch_hoppingOffset<0) || (eMTCconfig->ccparams.pusch_hoppingOffset>98))
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_hoppingOffset choice: 0..98!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pusch_hoppingMode);
+	      
+  if (!eMTCconfig->ccparams.pusch_enable64QAM)
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n",
+		 config_fname, cell_idx,ENB_CONFIG_STRING_PUSCH_ENABLE64QAM);
+  else if (strcmp(eMTCconfig->ccparams.pusch_enable64QAM, "ENABLE") == 0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pusch_enable64QAM = TRUE;
+  }  else if (strcmp(eMTCconfig->ccparams.pusch_enable64QAM, "DISABLE") == 0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pusch_enable64QAM = FALSE;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_enable64QAM choice: ENABLE,DISABLE!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pusch_enable64QAM);
+	      
+  if (!eMTCconfig->ccparams.pusch_groupHoppingEnabled)
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n",
+		 config_fname, cell_idx,ENB_CONFIG_STRING_PUSCH_GROUP_HOPPING_EN);
+  else if (strcmp(eMTCconfig->ccparams.pusch_groupHoppingEnabled, "ENABLE") == 0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pusch_groupHoppingEnabled = TRUE;
+  }  else if (strcmp(eMTCconfig->ccparams.pusch_groupHoppingEnabled, "DISABLE") == 0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pusch_groupHoppingEnabled= FALSE;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_groupHoppingEnabled choice: ENABLE,DISABLE!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pusch_groupHoppingEnabled);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pusch_groupAssignment = eMTCconfig->ccparams.pusch_groupAssignment;
+	      
+  if ((eMTCconfig->ccparams.pusch_groupAssignment<0)||(eMTCconfig->ccparams.pusch_groupAssignment>29))
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_groupAssignment choice: 0..29!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pusch_groupAssignment);
+	      
+  if (!eMTCconfig->ccparams.pusch_sequenceHoppingEnabled)
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d define %s: ENABLE,DISABLE!\n",
+		 config_fname, cell_idx,ENB_CONFIG_STRING_PUSCH_SEQUENCE_HOPPING_EN);
+  else if (strcmp(eMTCconfig->ccparams.pusch_sequenceHoppingEnabled, "ENABLE") == 0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pusch_sequenceHoppingEnabled = TRUE;
+  }  else if (strcmp(eMTCconfig->ccparams.pusch_sequenceHoppingEnabled, "DISABLE") == 0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pusch_sequenceHoppingEnabled = FALSE;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_sequenceHoppingEnabled choice: ENABLE,DISABLE!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pusch_sequenceHoppingEnabled);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pusch_nDMRS1= eMTCconfig->ccparams.pusch_nDMRS1;  //cyclic_shift in RRC!
+	      
+  if ((eMTCconfig->ccparams.pusch_nDMRS1 <0) || (eMTCconfig->ccparams.pusch_nDMRS1>7))
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_nDMRS1 choice: 0..7!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pusch_nDMRS1);
+	      
+  if (strcmp(eMTCconfig->ccparams.phich_duration,"NORMAL")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].phich_duration= LTE_PHICH_Config__phich_Duration_normal;
+  } else if (strcmp(eMTCconfig->ccparams.phich_duration,"EXTENDED")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].phich_duration= LTE_PHICH_Config__phich_Duration_extended;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for phich_duration choice: NORMAL,EXTENDED!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.phich_duration);
+	      
+  if (strcmp(eMTCconfig->ccparams.phich_resource,"ONESIXTH")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].phich_resource= LTE_PHICH_Config__phich_Resource_oneSixth ;
+  } else if (strcmp(eMTCconfig->ccparams.phich_resource,"HALF")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].phich_resource= LTE_PHICH_Config__phich_Resource_half;
+  } else if (strcmp(eMTCconfig->ccparams.phich_resource,"ONE")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].phich_resource= LTE_PHICH_Config__phich_Resource_one;
+  } else if (strcmp(eMTCconfig->ccparams.phich_resource,"TWO")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].phich_resource= LTE_PHICH_Config__phich_Resource_two;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for phich_resource choice: ONESIXTH,HALF,ONE,TWO!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.phich_resource);
+	      
+  printf("phich.resource eMTC %ld (%s), phich.duration eMTC %ld (%s)\n",
+	 RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].phich_resource,eMTCconfig->ccparams.phich_resource,
+	 RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].phich_duration,eMTCconfig->ccparams.phich_duration);
+	      
+  if (strcmp(eMTCconfig->ccparams.srs_enable, "ENABLE") == 0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].srs_enable= TRUE;
+  } else if (strcmp(eMTCconfig->ccparams.srs_enable, "DISABLE") == 0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].srs_enable= FALSE;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for srs_BandwidthConfig choice: ENABLE,DISABLE !\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.srs_enable);
+	      
+  if (RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].srs_enable== TRUE) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].srs_BandwidthConfig= eMTCconfig->ccparams.srs_BandwidthConfig;
+		
+    if ((eMTCconfig->ccparams.srs_BandwidthConfig < 0) || (eMTCconfig->ccparams.srs_BandwidthConfig >7))
+      AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value %d for srs_BandwidthConfig choice: 0...7\n",
+		   config_fname, cell_idx,eMTCconfig->ccparams.srs_BandwidthConfig);
+		
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].srs_SubframeConfig= eMTCconfig->ccparams.srs_SubframeConfig;
+		
+    if ((eMTCconfig->ccparams.srs_SubframeConfig<0) || (eMTCconfig->ccparams.srs_SubframeConfig>15))
+      AssertFatal (0,
+		   "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for srs_SubframeConfig choice: 0..15 !\n",
+		   config_fname, cell_idx,eMTCconfig->ccparams.srs_SubframeConfig);
+		
+    if (strcmp(eMTCconfig->ccparams.srs_ackNackST, "ENABLE") == 0) {
+      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].srs_ackNackST= TRUE;
+    } else if (strcmp(eMTCconfig->ccparams.srs_ackNackST, "DISABLE") == 0) {
+      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].srs_ackNackST= FALSE;
+    } else
+      AssertFatal (0,
+		   "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for srs_BandwidthConfig choice: ENABLE,DISABLE !\n",
+		   config_fname, cell_idx,eMTCconfig->ccparams.srs_ackNackST);
+		
+    if (strcmp(eMTCconfig->ccparams.srs_MaxUpPts, "ENABLE") == 0) {
+      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].srs_MaxUpPts= TRUE;
+    } else if (strcmp(eMTCconfig->ccparams.srs_MaxUpPts, "DISABLE") == 0) {
+      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].srs_MaxUpPts= FALSE;
+    } else
+      AssertFatal (0,
+		   "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for srs_MaxUpPts choice: ENABLE,DISABLE !\n",
+		   config_fname, cell_idx,eMTCconfig->ccparams.srs_MaxUpPts);
+  }
+	      
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pusch_p0_Nominal= eMTCconfig->ccparams.pusch_p0_Nominal;
+	      
+  if ((eMTCconfig->ccparams.pusch_p0_Nominal<-126) || (eMTCconfig->ccparams.pusch_p0_Nominal>24))
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_p0_Nominal choice: -126..24 !\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pusch_p0_Nominal);
+	      
+  if (strcmp(eMTCconfig->ccparams.pusch_alpha,"AL0")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pusch_alpha= LTE_Alpha_r12_al0;
+  } else if (strcmp(eMTCconfig->ccparams.pusch_alpha,"AL04")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pusch_alpha= LTE_Alpha_r12_al04;
+  } else if (strcmp(eMTCconfig->ccparams.pusch_alpha,"AL05")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pusch_alpha= LTE_Alpha_r12_al05;
+  } else if (strcmp(eMTCconfig->ccparams.pusch_alpha,"AL06")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pusch_alpha= LTE_Alpha_r12_al06;
+  } else if (strcmp(eMTCconfig->ccparams.pusch_alpha,"AL07")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pusch_alpha= LTE_Alpha_r12_al07;
+  } else if (strcmp(eMTCconfig->ccparams.pusch_alpha,"AL08")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pusch_alpha= LTE_Alpha_r12_al08;
+  } else if (strcmp(eMTCconfig->ccparams.pusch_alpha,"AL09")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pusch_alpha= LTE_Alpha_r12_al09;
+  } else if (strcmp(eMTCconfig->ccparams.pusch_alpha,"AL1")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pusch_alpha= LTE_Alpha_r12_al1;
+  }
+	      
+  else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_Alpha choice: AL0,AL04,AL05,AL06,AL07,AL08,AL09,AL1!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pusch_alpha);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pucch_p0_Nominal= eMTCconfig->ccparams.pucch_p0_Nominal;
+	      
+  if ((eMTCconfig->ccparams.pucch_p0_Nominal<-127) || (eMTCconfig->ccparams.pucch_p0_Nominal>-96))
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_p0_Nominal choice: -127..-96 !\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pucch_p0_Nominal);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].msg3_delta_Preamble= eMTCconfig->ccparams.msg3_delta_Preamble;
+	      
+  if ((eMTCconfig->ccparams.msg3_delta_Preamble<-1) || (eMTCconfig->ccparams.msg3_delta_Preamble>6))
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for msg3_delta_Preamble choice: -1..6 !\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.msg3_delta_Preamble);
+	      
+  if (strcmp(eMTCconfig->ccparams.pucch_deltaF_Format1,"deltaF_2")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pucch_deltaF_Format1= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF_2;
+  } else if (strcmp(eMTCconfig->ccparams.pucch_deltaF_Format1,"deltaF0")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pucch_deltaF_Format1= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF0;
+  } else if (strcmp(eMTCconfig->ccparams.pucch_deltaF_Format1,"deltaF2")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pucch_deltaF_Format1= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF2;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format1 choice: deltaF_2,dltaF0,deltaF2!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pucch_deltaF_Format1);
+	      
+  if (strcmp(eMTCconfig->ccparams.pucch_deltaF_Format1b,"deltaF1")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pucch_deltaF_Format1b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF1;
+  } else if (strcmp(eMTCconfig->ccparams.pucch_deltaF_Format1b,"deltaF3")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pucch_deltaF_Format1b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF3;
+  } else if (strcmp(eMTCconfig->ccparams.pucch_deltaF_Format1b,"deltaF5")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pucch_deltaF_Format1b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF5;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format1b choice: deltaF1,dltaF3,deltaF5!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pucch_deltaF_Format1b);
+	      
+  if (strcmp(eMTCconfig->ccparams.pucch_deltaF_Format2,"deltaF_2")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pucch_deltaF_Format2= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF_2;
+  } else if (strcmp(eMTCconfig->ccparams.pucch_deltaF_Format2,"deltaF0")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pucch_deltaF_Format2= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF0;
+  } else if (strcmp(eMTCconfig->ccparams.pucch_deltaF_Format2,"deltaF1")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pucch_deltaF_Format2= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF1;
+  } else if (strcmp(eMTCconfig->ccparams.pucch_deltaF_Format2,"deltaF2")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pucch_deltaF_Format2= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF2;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format2 choice: deltaF_2,dltaF0,deltaF1,deltaF2!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pucch_deltaF_Format2);
+	      
+  if (strcmp(eMTCconfig->ccparams.pucch_deltaF_Format2a,"deltaF_2")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pucch_deltaF_Format2a= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF_2;
+  } else if (strcmp(eMTCconfig->ccparams.pucch_deltaF_Format2a,"deltaF0")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pucch_deltaF_Format2a= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF0;
+  } else if (strcmp(eMTCconfig->ccparams.pucch_deltaF_Format2a,"deltaF2")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pucch_deltaF_Format2a= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF2;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format2a choice: deltaF_2,dltaF0,deltaF2!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pucch_deltaF_Format2a);
+	      
+  if (strcmp(eMTCconfig->ccparams.pucch_deltaF_Format2b,"deltaF_2")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pucch_deltaF_Format2b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF_2;
+  } else if (strcmp(eMTCconfig->ccparams.pucch_deltaF_Format2b,"deltaF0")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pucch_deltaF_Format2b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF0;
+  } else if (strcmp(eMTCconfig->ccparams.pucch_deltaF_Format2b,"deltaF2")==0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pucch_deltaF_Format2b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF2;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format2b choice: deltaF_2,dltaF0,deltaF2!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pucch_deltaF_Format2b);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_numberOfRA_Preambles= (eMTCconfig->ccparams.rach_numberOfRA_Preambles/4)-1;
+	      
+  if ((eMTCconfig->ccparams.rach_numberOfRA_Preambles <4) || (eMTCconfig->ccparams.rach_numberOfRA_Preambles >64) || ((eMTCconfig->ccparams.rach_numberOfRA_Preambles&3)!=0))
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_numberOfRA_Preambles choice: 4,8,12,...,64!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.rach_numberOfRA_Preambles);
+	      
+  if (strcmp(eMTCconfig->ccparams.rach_preamblesGroupAConfig, "ENABLE") == 0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_preamblesGroupAConfig= TRUE;
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_sizeOfRA_PreamblesGroupA= (eMTCconfig->ccparams.rach_sizeOfRA_PreamblesGroupA/4)-1;
+		
+    if ((eMTCconfig->ccparams.rach_numberOfRA_Preambles <4) || (eMTCconfig->ccparams.rach_numberOfRA_Preambles>60) || ((eMTCconfig->ccparams.rach_numberOfRA_Preambles&3)!=0))
+      AssertFatal (0,
+		   "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_sizeOfRA_PreamblesGroupA choice: 4,8,12,...,60!\n",
+		   config_fname, cell_idx,eMTCconfig->ccparams.rach_sizeOfRA_PreamblesGroupA);
+		
+    switch (eMTCconfig->ccparams.rach_messageSizeGroupA) {
+    case 56:
+      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b56;
+      break;
+		  
+    case 144:
+      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b144;
+      break;
+		  
+    case 208:
+      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b208;
+      break;
+		  
+    case 256:
+      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b256;
+      break;
+		  
+    default:
+      AssertFatal (0,
+		   "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_messageSizeGroupA choice: 56,144,208,256!\n",
+		   config_fname, cell_idx,eMTCconfig->ccparams.rach_messageSizeGroupA);
+      break;
+    }
+		
+    if (strcmp(eMTCconfig->ccparams.rach_messagePowerOffsetGroupB,"minusinfinity")==0) {
+      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_minusinfinity;
+    } else if (strcmp(eMTCconfig->ccparams.rach_messagePowerOffsetGroupB,"dB0")==0) {
+      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB0;
+    } else if (strcmp(eMTCconfig->ccparams.rach_messagePowerOffsetGroupB,"dB5")==0) {
+      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB5;
+    } else if (strcmp(eMTCconfig->ccparams.rach_messagePowerOffsetGroupB,"dB8")==0) {
+      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB8;
+    } else if (strcmp(eMTCconfig->ccparams.rach_messagePowerOffsetGroupB,"dB10")==0) {
+      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB10;
+    } else if (strcmp(eMTCconfig->ccparams.rach_messagePowerOffsetGroupB,"dB12")==0) {
+      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB12;
+    } else if (strcmp(eMTCconfig->ccparams.rach_messagePowerOffsetGroupB,"dB15")==0) {
+      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB15;
+    } else if (strcmp(eMTCconfig->ccparams.rach_messagePowerOffsetGroupB,"dB18")==0) {
+      RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB18;
+    } else
+      AssertFatal (0,
+		   "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rach_messagePowerOffsetGroupB choice: minusinfinity,dB0,dB5,dB8,dB10,dB12,dB15,dB18!\n",
+		   config_fname, cell_idx,eMTCconfig->ccparams.rach_messagePowerOffsetGroupB);
+  } else if (strcmp(eMTCconfig->ccparams.rach_preamblesGroupAConfig, "DISABLE") == 0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_preamblesGroupAConfig= FALSE;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rach_preamblesGroupAConfig choice: ENABLE,DISABLE !\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.rach_preamblesGroupAConfig);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_preambleInitialReceivedTargetPower= (eMTCconfig->ccparams.rach_preambleInitialReceivedTargetPower+120)/2;
+	      
+  if ((eMTCconfig->ccparams.rach_preambleInitialReceivedTargetPower<-120) || (eMTCconfig->ccparams.rach_preambleInitialReceivedTargetPower>-90) || ((eMTCconfig->ccparams.rach_preambleInitialReceivedTargetPower&1)!=0))
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_preambleInitialReceivedTargetPower choice: -120,-118,...,-90 !\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.rach_preambleInitialReceivedTargetPower);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_powerRampingStep= eMTCconfig->ccparams.rach_powerRampingStep/2;
+	      
+  if ((eMTCconfig->ccparams.rach_powerRampingStep<0) || (eMTCconfig->ccparams.rach_powerRampingStep>6) || ((eMTCconfig->ccparams.rach_powerRampingStep&1)!=0))
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_powerRampingStep choice: 0,2,4,6 !\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.rach_powerRampingStep);
+	      
+  switch (eMTCconfig->ccparams.rach_preambleTransMax) {
+  case 3:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_preambleTransMax=  LTE_PreambleTransMax_n3;
+    break;
+		
+  case 4:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_preambleTransMax=  LTE_PreambleTransMax_n4;
+    break;
+		
+  case 5:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_preambleTransMax=  LTE_PreambleTransMax_n5;
+    break;
+		
+  case 6:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_preambleTransMax=  LTE_PreambleTransMax_n6;
+    break;
+		
+  case 7:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_preambleTransMax=  LTE_PreambleTransMax_n7;
+    break;
+		
+  case 8:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_preambleTransMax=  LTE_PreambleTransMax_n8;
+    break;
+		
+  case 10:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_preambleTransMax=  LTE_PreambleTransMax_n10;
+    break;
+		
+  case 20:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_preambleTransMax=  LTE_PreambleTransMax_n20;
+    break;
+		
+  case 50:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_preambleTransMax=  LTE_PreambleTransMax_n50;
+    break;
+		
+  case 100:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_preambleTransMax=  LTE_PreambleTransMax_n100;
+    break;
+		
+  case 200:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_preambleTransMax=  LTE_PreambleTransMax_n200;
+    break;
+		
+  default:
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_preambleTransMax choice: 3,4,5,6,7,8,10,20,50,100,200!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.rach_preambleTransMax);
+    break;
+  }
+	      
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_raResponseWindowSize=  (eMTCconfig->ccparams.rach_raResponseWindowSize==10)?7:eMTCconfig->ccparams.rach_raResponseWindowSize-2;
+	      
+  if ((eMTCconfig->ccparams.rach_raResponseWindowSize<0)||(eMTCconfig->ccparams.rach_raResponseWindowSize==9)||(eMTCconfig->ccparams.rach_raResponseWindowSize>10))
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_raResponseWindowSize choice: 2,3,4,5,6,7,8,10!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.rach_raResponseWindowSize);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_macContentionResolutionTimer= (eMTCconfig->ccparams.rach_macContentionResolutionTimer/8)-1;
+	      
+  if ((eMTCconfig->ccparams.rach_macContentionResolutionTimer<8) || (eMTCconfig->ccparams.rach_macContentionResolutionTimer>64) || ((eMTCconfig->ccparams.rach_macContentionResolutionTimer&7)!=0))
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_macContentionResolutionTimer choice: 8,16,...,56,64!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.rach_macContentionResolutionTimer);
+	      
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].rach_maxHARQ_Msg3Tx= eMTCconfig->ccparams.rach_maxHARQ_Msg3Tx;
+	      
+  if ((eMTCconfig->ccparams.rach_maxHARQ_Msg3Tx<0) || (eMTCconfig->ccparams.rach_maxHARQ_Msg3Tx>8))
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_maxHARQ_Msg3Tx choice: 1..8!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.rach_maxHARQ_Msg3Tx);
+	      
+  switch (eMTCconfig->ccparams.pcch_defaultPagingCycle) {
+  case 32:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf32;
+    break;
+		
+  case 64:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf64;
+    break;
+		
+  case 128:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf128;
+    break;
+		
+  case 256:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf256;
+    break;
+		
+  default:
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pcch_defaultPagingCycle choice: 32,64,128,256!\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pcch_defaultPagingCycle);
+    break;
+  }
+	      
+  if (strcmp(eMTCconfig->ccparams.pcch_nB, "fourT") == 0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pcch_nB= LTE_PCCH_Config__nB_fourT;
+  } else if (strcmp(eMTCconfig->ccparams.pcch_nB, "twoT") == 0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pcch_nB= LTE_PCCH_Config__nB_twoT;
+  } else if (strcmp(eMTCconfig->ccparams.pcch_nB, "oneT") == 0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pcch_nB= LTE_PCCH_Config__nB_oneT;
+  } else if (strcmp(eMTCconfig->ccparams.pcch_nB, "halfT") == 0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pcch_nB= LTE_PCCH_Config__nB_halfT;
+  } else if (strcmp(eMTCconfig->ccparams.pcch_nB, "quarterT") == 0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pcch_nB= LTE_PCCH_Config__nB_quarterT;
+  } else if (strcmp(eMTCconfig->ccparams.pcch_nB, "oneEighthT") == 0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pcch_nB= LTE_PCCH_Config__nB_oneEighthT;
+  } else if (strcmp(eMTCconfig->ccparams.pcch_nB, "oneSixteenthT") == 0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pcch_nB= LTE_PCCH_Config__nB_oneSixteenthT;
+  } else if (strcmp(eMTCconfig->ccparams.pcch_nB, "oneThirtySecondT") == 0) {
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].pcch_nB= LTE_PCCH_Config__nB_oneThirtySecondT;
+  } else
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pcch_nB choice: fourT,twoT,oneT,halfT,quarterT,oneighthT,oneSixteenthT,oneThirtySecondT !\n",
+		 config_fname, cell_idx,eMTCconfig->ccparams.pcch_nB);
+	      
+  switch (eMTCconfig->ccparams.bcch_modificationPeriodCoeff) {
+  case 2:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n2;
+    break;
+		
+  case 4:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n4;
+    break;
+		
+  case 8:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n8;
+    break;
+		
+  case 16:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n16;
+    break;
+		
+  default:
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for bcch_modificationPeriodCoeff choice: 2,4,8,16",
+		 config_fname, cell_idx,eMTCconfig->ccparams.bcch_modificationPeriodCoeff);
+    break;
+  }
+	      
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].ue_TimersAndConstants_t300= eMTCconfig->ccparams.ue_TimersAndConstants_t300;
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].ue_TimersAndConstants_t301= eMTCconfig->ccparams.ue_TimersAndConstants_t301;
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].ue_TimersAndConstants_t310= eMTCconfig->ccparams.ue_TimersAndConstants_t310;
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].ue_TimersAndConstants_t311= eMTCconfig->ccparams.ue_TimersAndConstants_t311;
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].ue_TimersAndConstants_n310= eMTCconfig->ccparams.ue_TimersAndConstants_n310;
+  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].ue_TimersAndConstants_n311= eMTCconfig->ccparams.ue_TimersAndConstants_n311;
+	      
+  switch (eMTCconfig->ccparams.ue_TransmissionMode) {
+  case 1:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm1;
+    break;
+		
+  case 2:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm2;
+    break;
+		
+  case 3:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm3;
+    break;
+		
+  case 4:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm4;
+    break;
+		
+  case 5:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm5;
+    break;
+		
+  case 6:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm6;
+    break;
+		
+  case 7:
+    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig_BR[cc_idx].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm7;
+    break;
+		
+  default:
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_TransmissionMode choice: 1,2,3,4,5,6,7",
+		 config_fname, cell_idx, eMTCconfig->ccparams.ue_TransmissionMode);
+    break;
+  }
+	      
+	      
+  if (!strcmp(eMTCconfig->prach_ConfigCommon_v1310, "ENABLE")) {
+    RRC_CONFIGURATION_REQ(msg_p).radioresourceconfig_BR[cc_idx].prach_ConfigCommon_v1310 = TRUE;
+    
+    RRC_CONFIGURATION_REQ(msg_p).radioresourceconfig_BR[cc_idx].mpdcch_startSF_CSS_RA_r13 = calloc(1, sizeof(BOOLEAN_t));
+    
+    if (!strcmp(eMTCconfig->mpdcch_startSF_CSS_RA_r13, "tdd-r13")) {
+      *RRC_CONFIGURATION_REQ(msg_p).radioresourceconfig_BR[cc_idx].mpdcch_startSF_CSS_RA_r13 = FALSE;
+    } else {
+      *RRC_CONFIGURATION_REQ(msg_p).radioresourceconfig_BR[cc_idx].mpdcch_startSF_CSS_RA_r13 = TRUE;
+    }
+    
+    if (!strcmp(eMTCconfig->mpdcch_startSF_CSS_RA_r13_val, "v1")) {
+      RRC_CONFIGURATION_REQ(msg_p).radioresourceconfig_BR[cc_idx].mpdcch_startSF_CSS_RA_r13_val = 0;
+    } else if (!strcmp(eMTCconfig->mpdcch_startSF_CSS_RA_r13_val, "v1dot5")) {
+      RRC_CONFIGURATION_REQ(msg_p).radioresourceconfig_BR[cc_idx].mpdcch_startSF_CSS_RA_r13_val = 1;
+    } else if (!strcmp(eMTCconfig->mpdcch_startSF_CSS_RA_r13_val, "v2")) {
+      RRC_CONFIGURATION_REQ(msg_p).radioresourceconfig_BR[cc_idx].mpdcch_startSF_CSS_RA_r13_val = 2;
+    } else if (!strcmp(eMTCconfig->mpdcch_startSF_CSS_RA_r13_val, "v2dot5")) {
+      RRC_CONFIGURATION_REQ(msg_p).radioresourceconfig_BR[cc_idx].mpdcch_startSF_CSS_RA_r13_val = 3;
+    } else if (!strcmp(eMTCconfig->mpdcch_startSF_CSS_RA_r13_val, "v4")) {
+      RRC_CONFIGURATION_REQ(msg_p).radioresourceconfig_BR[cc_idx].mpdcch_startSF_CSS_RA_r13_val = 4;
+    } else if (!strcmp(eMTCconfig->mpdcch_startSF_CSS_RA_r13_val, "v5")) {
+      RRC_CONFIGURATION_REQ(msg_p).radioresourceconfig_BR[cc_idx].mpdcch_startSF_CSS_RA_r13_val = 5;
+    } else if (!strcmp(eMTCconfig->mpdcch_startSF_CSS_RA_r13_val, "v8")) {
+      RRC_CONFIGURATION_REQ(msg_p).radioresourceconfig_BR[cc_idx].mpdcch_startSF_CSS_RA_r13_val = 6;
+    } else if (!strcmp(eMTCconfig->mpdcch_startSF_CSS_RA_r13_val, "10")) {
+      RRC_CONFIGURATION_REQ(msg_p).radioresourceconfig_BR[cc_idx].mpdcch_startSF_CSS_RA_r13_val = 7;
+    } else {
+      AssertFatal(0,
+		  "Failed to parse eNB configuration file %s, enb %d mpdcch_startSF_CSS_RA_r13_val! Unknown Value !!\n",
+		  config_fname, cell_idx);
+    }
+
+    RRC_CONFIGURATION_REQ(msg_p).radioresourceconfig_BR[cc_idx].prach_HoppingOffset_r13 = calloc(1, sizeof(long));
+    *RRC_CONFIGURATION_REQ(msg_p).radioresourceconfig_BR[cc_idx].prach_HoppingOffset_r13 = eMTCconfig->prach_HoppingOffset_r13;
+  } else {
+    RRC_CONFIGURATION_REQ(msg_p).radioresourceconfig_BR[cc_idx].prach_ConfigCommon_v1310 = FALSE;
+  }
+  
+	      
+  RRC_CONFIGURATION_REQ(msg_p).pdsch_maxNumRepetitionCEmodeA_r13[cc_idx] = CALLOC(1, sizeof(long));
+  if (!strcmp(eMTCconfig->pdsch_maxNumRepetitionCEmodeA_r13, "r16")) {
+    *RRC_CONFIGURATION_REQ(msg_p).pdsch_maxNumRepetitionCEmodeA_r13[cc_idx] = 0;
+  } else if (!strcmp(eMTCconfig->pdsch_maxNumRepetitionCEmodeA_r13, "r32")) {
+    *RRC_CONFIGURATION_REQ(msg_p).pdsch_maxNumRepetitionCEmodeA_r13[cc_idx] = 1;
+  } else {
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, pdsch_maxNumRepetitionCEmodeA_r13 unknown value!\n",
+		 config_fname);
+  }
+	      
+	      
+  RRC_CONFIGURATION_REQ(msg_p).pusch_maxNumRepetitionCEmodeA_r13[cc_idx] = CALLOC(1, sizeof(long));
+  if (!strcmp(eMTCconfig->pusch_maxNumRepetitionCEmodeA_r13, "r8")) {
+    *RRC_CONFIGURATION_REQ(msg_p).pusch_maxNumRepetitionCEmodeA_r13[cc_idx] =  0;
+  } else if (!strcmp(eMTCconfig->pusch_maxNumRepetitionCEmodeA_r13, "r16")) {
+    *RRC_CONFIGURATION_REQ(msg_p).pusch_maxNumRepetitionCEmodeA_r13[cc_idx] =  1;
+  } else if (!strcmp(eMTCconfig->pusch_maxNumRepetitionCEmodeA_r13, "r32")) {
+    *RRC_CONFIGURATION_REQ(msg_p).pusch_maxNumRepetitionCEmodeA_r13[cc_idx] =  2;
+  } else {
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, pusch_maxNumRepetitionCEmodeA_r13 unknown value!\n",
+		 config_fname);
+  }
+	      
+  char rachCELevelInfoListPath[MAX_OPTNAME_SIZE * 2];
+  config_getlist(&rachcelevellist, NULL, 0, brparamspath);
+  RRC_CONFIGURATION_REQ (msg_p).rach_CE_LevelInfoList_r13_size[cc_idx] = rachcelevellist.numelt;
+  int rachCEInfoIndex;
+  for (rachCEInfoIndex = 0; rachCEInfoIndex < rachcelevellist.numelt; rachCEInfoIndex++) {
+    sprintf(rachCELevelInfoListPath, "%s.%s.[%i]", brparamspath, ENB_CONFIG_STRING_RACH_CE_LEVELINFOLIST_R13, rachCEInfoIndex);
+    config_get(rachcelevelParams, sizeof(rachcelevelParams) / sizeof(paramdef_t), rachCELevelInfoListPath);
+		
+    RRC_CONFIGURATION_REQ (msg_p).firstPreamble_r13[cc_idx][rachCEInfoIndex] = eMTCconfig->firstPreamble_r13;
+    RRC_CONFIGURATION_REQ (msg_p).lastPreamble_r13[cc_idx][rachCEInfoIndex]  = eMTCconfig->lastPreamble_r13;
+
+    switch (eMTCconfig->ra_ResponseWindowSize_r13) {
+    case 20:
+      RRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindowSize_r13[cc_idx][rachCEInfoIndex] = LTE_RACH_CE_LevelInfo_r13__ra_ResponseWindowSize_r13_sf20;
+      break;
+    case 50:
+      RRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindowSize_r13[cc_idx][rachCEInfoIndex] = LTE_RACH_CE_LevelInfo_r13__ra_ResponseWindowSize_r13_sf50;
+      break;
+    case 80:
+      RRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindowSize_r13[cc_idx][rachCEInfoIndex] = LTE_RACH_CE_LevelInfo_r13__ra_ResponseWindowSize_r13_sf80;
+      break;
+    case 120:
+      RRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindowSize_r13[cc_idx][rachCEInfoIndex] = LTE_RACH_CE_LevelInfo_r13__ra_ResponseWindowSize_r13_sf120;
+      break;
+    case 180:
+      RRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindowSize_r13[cc_idx][rachCEInfoIndex] = LTE_RACH_CE_LevelInfo_r13__ra_ResponseWindowSize_r13_sf180;
+      break;
+    case 240:
+      RRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindowSize_r13[cc_idx][rachCEInfoIndex] = LTE_RACH_CE_LevelInfo_r13__ra_ResponseWindowSize_r13_sf240;
+      break;
+    case 320:
+      RRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindowSize_r13[cc_idx][rachCEInfoIndex] = LTE_RACH_CE_LevelInfo_r13__ra_ResponseWindowSize_r13_sf320;
+      break;
+    case 400:
+      RRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindowSize_r13[cc_idx][rachCEInfoIndex] = LTE_RACH_CE_LevelInfo_r13__ra_ResponseWindowSize_r13_sf400;
+      break;
+    default:
+      AssertFatal(1==0,
+		"Illegal ra_ResponseWindowSize_r13 %d\n",eMTCconfig->ra_ResponseWindowSize_r13);
+    }
+		
+
+    switch(eMTCconfig->mac_ContentionResolutionTimer_r13) {
+    case 80:
+      RRC_CONFIGURATION_REQ (msg_p).mac_ContentionResolutionTimer_r13[cc_idx][rachCEInfoIndex] = LTE_RACH_CE_LevelInfo_r13__mac_ContentionResolutionTimer_r13_sf80;
+      break;
+    case 100:
+      RRC_CONFIGURATION_REQ (msg_p).mac_ContentionResolutionTimer_r13[cc_idx][rachCEInfoIndex] = LTE_RACH_CE_LevelInfo_r13__mac_ContentionResolutionTimer_r13_sf100;
+      break;
+    case 120:
+      RRC_CONFIGURATION_REQ (msg_p).mac_ContentionResolutionTimer_r13[cc_idx][rachCEInfoIndex] = LTE_RACH_CE_LevelInfo_r13__mac_ContentionResolutionTimer_r13_sf120;
+      break;
+    case 160:
+      RRC_CONFIGURATION_REQ (msg_p).mac_ContentionResolutionTimer_r13[cc_idx][rachCEInfoIndex] = LTE_RACH_CE_LevelInfo_r13__mac_ContentionResolutionTimer_r13_sf160;
+      break;
+    case 200:
+      RRC_CONFIGURATION_REQ (msg_p).mac_ContentionResolutionTimer_r13[cc_idx][rachCEInfoIndex] = LTE_RACH_CE_LevelInfo_r13__mac_ContentionResolutionTimer_r13_sf200;
+      break;
+    case 240:
+      RRC_CONFIGURATION_REQ (msg_p).mac_ContentionResolutionTimer_r13[cc_idx][rachCEInfoIndex] = LTE_RACH_CE_LevelInfo_r13__mac_ContentionResolutionTimer_r13_sf240;
+      break;
+    case 480:
+      RRC_CONFIGURATION_REQ (msg_p).mac_ContentionResolutionTimer_r13[cc_idx][rachCEInfoIndex] = LTE_RACH_CE_LevelInfo_r13__mac_ContentionResolutionTimer_r13_sf480;
+      break;
+    case 960:
+      RRC_CONFIGURATION_REQ (msg_p).mac_ContentionResolutionTimer_r13[cc_idx][rachCEInfoIndex] = LTE_RACH_CE_LevelInfo_r13__mac_ContentionResolutionTimer_r13_sf960;
+      break;
+    default:
+      AssertFatal(1==0,"Illegal mac_ContentionResolutionTimer_r13 %d\n",
+		  eMTCconfig->mac_ContentionResolutionTimer_r13);
+      break;
+    }
+    RRC_CONFIGURATION_REQ (msg_p).rar_HoppingConfig_r13[cc_idx][rachCEInfoIndex] = eMTCconfig->rar_HoppingConfig_r13;
+    AssertFatal(eMTCconfig->rar_HoppingConfig_r13 == 0 || eMTCconfig->rar_HoppingConfig_r13 == 1,
+		"illegal rar_HoppingConfig_r13 %d\n",eMTCconfig->rar_HoppingConfig_r13);
+  } // end for loop (rach ce level info)
+	      
+  char rsrpRangeListPath[MAX_OPTNAME_SIZE * 2];
+  config_getlist(&rsrprangelist, NULL, 0, brparamspath);
+  RRC_CONFIGURATION_REQ (msg_p).rsrp_range_list_size[cc_idx] = rsrprangelist.numelt;
+	      
+	      
+  int rsrprangeindex;
+  for (rsrprangeindex = 0; rsrprangeindex < rsrprangelist.numelt; rsrprangeindex++) {
+    sprintf(rsrpRangeListPath, "%s.%s.[%i]", brparamspath, ENB_CONFIG_STRING_RSRP_RANGE_LIST, rsrprangeindex);
+    config_get(rsrprangeParams, sizeof(rsrprangeParams) / sizeof(paramdef_t), rsrpRangeListPath);
+    RRC_CONFIGURATION_REQ (msg_p).rsrp_range[cc_idx][rsrprangeindex] = eMTCconfig->rsrp_range_br;
+		
+  }
+	      
+	      
+  char prachparameterscePath[MAX_OPTNAME_SIZE * 2];
+  config_getlist(&prachParamslist, NULL, 0, brparamspath);
+  RRC_CONFIGURATION_REQ (msg_p).prach_parameters_list_size[cc_idx] = prachParamslist.numelt;
+	      
+  int prachparamsindex;
+  for (prachparamsindex = 0; prachparamsindex < prachParamslist.numelt; prachparamsindex++) {
+    sprintf(prachparameterscePath, "%s.%s.[%i]", brparamspath, ENB_CONFIG_STRING_PRACH_PARAMETERS_CE_R13, prachparamsindex);
+    config_get(prachParams, sizeof(prachParams) / sizeof(paramdef_t), prachparameterscePath);
+		
+    RRC_CONFIGURATION_REQ (msg_p).prach_config_index[cc_idx][prachparamsindex]                  = eMTCconfig->prach_config_index_br;
+    RRC_CONFIGURATION_REQ (msg_p).prach_freq_offset[cc_idx][prachparamsindex]                   = eMTCconfig->prach_freq_offset_br;
+		
+    RRC_CONFIGURATION_REQ (msg_p).prach_StartingSubframe_r13[cc_idx][prachparamsindex] = calloc(1, sizeof(long));
+    switch(eMTCconfig->prach_StartingSubframe_r13) {
+    case 2:
+      *RRC_CONFIGURATION_REQ (msg_p).prach_StartingSubframe_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__prach_StartingSubframe_r13_sf2;
+      break;
+    case 4:
+      *RRC_CONFIGURATION_REQ (msg_p).prach_StartingSubframe_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__prach_StartingSubframe_r13_sf4;
+      break;
+    case 8:
+      *RRC_CONFIGURATION_REQ (msg_p).prach_StartingSubframe_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__prach_StartingSubframe_r13_sf8;
+      break;
+    case 16:
+      *RRC_CONFIGURATION_REQ (msg_p).prach_StartingSubframe_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__prach_StartingSubframe_r13_sf16;
+      break;
+    case 32:
+      *RRC_CONFIGURATION_REQ (msg_p).prach_StartingSubframe_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__prach_StartingSubframe_r13_sf32;
+      break;
+    case 64:
+      *RRC_CONFIGURATION_REQ (msg_p).prach_StartingSubframe_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__prach_StartingSubframe_r13_sf64;
+      break;
+    case 128:
+      *RRC_CONFIGURATION_REQ (msg_p).prach_StartingSubframe_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__prach_StartingSubframe_r13_sf128;
+      break;
+    case 256:
+      *RRC_CONFIGURATION_REQ (msg_p).prach_StartingSubframe_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__prach_StartingSubframe_r13_sf256;
+      break;
+    default:
+      AssertFatal(1==0,"prach_StartingSubframe_r13 %d is illegal\n",
+		  eMTCconfig->prach_StartingSubframe_r13);
+      break;
+    }
+
+    RRC_CONFIGURATION_REQ (msg_p).maxNumPreambleAttemptCE_r13[cc_idx][prachparamsindex] = calloc(1, sizeof(long));
+    if (eMTCconfig->maxNumPreambleAttemptCE_r13==10)  *RRC_CONFIGURATION_REQ (msg_p).maxNumPreambleAttemptCE_r13[cc_idx][prachparamsindex] = 6;
+    else                                              *RRC_CONFIGURATION_REQ (msg_p).maxNumPreambleAttemptCE_r13[cc_idx][prachparamsindex] = eMTCconfig->maxNumPreambleAttemptCE_r13-3;
+    AssertFatal(eMTCconfig->maxNumPreambleAttemptCE_r13 > 2 && eMTCconfig->maxNumPreambleAttemptCE_r13 <11,
+		"prachparamsindex %d: Illegal maxNumPreambleAttemptCE_r13 %d\n",
+		prachparamsindex,eMTCconfig->maxNumPreambleAttemptCE_r13);
+		
+
+    switch(eMTCconfig->numRepetitionPerPreambleAttempt_r13) { 
+    case 1:
+      RRC_CONFIGURATION_REQ (msg_p).numRepetitionPerPreambleAttempt_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__numRepetitionPerPreambleAttempt_r13_n1;
+      break;
+    case 2:
+      RRC_CONFIGURATION_REQ (msg_p).numRepetitionPerPreambleAttempt_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__numRepetitionPerPreambleAttempt_r13_n2;
+      break;
+    case 4:
+      RRC_CONFIGURATION_REQ (msg_p).numRepetitionPerPreambleAttempt_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__numRepetitionPerPreambleAttempt_r13_n4;
+      break;
+    case 8:
+      RRC_CONFIGURATION_REQ (msg_p).numRepetitionPerPreambleAttempt_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__numRepetitionPerPreambleAttempt_r13_n8;
+      break;
+    case 16:
+      RRC_CONFIGURATION_REQ (msg_p).numRepetitionPerPreambleAttempt_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__numRepetitionPerPreambleAttempt_r13_n16;
+      break;
+    case 32:
+      RRC_CONFIGURATION_REQ (msg_p).numRepetitionPerPreambleAttempt_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__numRepetitionPerPreambleAttempt_r13_n32;
+      break;
+    case 64:
+      RRC_CONFIGURATION_REQ (msg_p).numRepetitionPerPreambleAttempt_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__numRepetitionPerPreambleAttempt_r13_n64;
+      break;
+    case 128:
+      RRC_CONFIGURATION_REQ (msg_p).numRepetitionPerPreambleAttempt_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__numRepetitionPerPreambleAttempt_r13_n128;
+      break;
+    default:
+      AssertFatal(1==0,
+		  "illegal numReptitionPerPreambleAttempt %d\n",
+		  eMTCconfig->numRepetitionPerPreambleAttempt_r13);
+      break;
+    }
+    switch (eMTCconfig->mpdcch_NumRepetition_RA_r13) {
+    case 1:
+      RRC_CONFIGURATION_REQ (msg_p).mpdcch_NumRepetition_RA_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__mpdcch_NumRepetition_RA_r13_r1;
+	break;
+    case 2:
+      RRC_CONFIGURATION_REQ (msg_p).mpdcch_NumRepetition_RA_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__mpdcch_NumRepetition_RA_r13_r2;
+	break;
+    case 4:
+      RRC_CONFIGURATION_REQ (msg_p).mpdcch_NumRepetition_RA_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__mpdcch_NumRepetition_RA_r13_r4;
+	break;
+    case 8:
+      RRC_CONFIGURATION_REQ (msg_p).mpdcch_NumRepetition_RA_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__mpdcch_NumRepetition_RA_r13_r8;
+	break;
+    case 16:
+      RRC_CONFIGURATION_REQ (msg_p).mpdcch_NumRepetition_RA_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__mpdcch_NumRepetition_RA_r13_r16;
+	break;
+    case 32:
+      RRC_CONFIGURATION_REQ (msg_p).mpdcch_NumRepetition_RA_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__mpdcch_NumRepetition_RA_r13_r32;
+	break;
+    case 64:
+      RRC_CONFIGURATION_REQ (msg_p).mpdcch_NumRepetition_RA_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__mpdcch_NumRepetition_RA_r13_r64;
+	break;
+    case 128:
+      RRC_CONFIGURATION_REQ (msg_p).mpdcch_NumRepetition_RA_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__mpdcch_NumRepetition_RA_r13_r128;
+	break;
+    case 256:
+      RRC_CONFIGURATION_REQ (msg_p).mpdcch_NumRepetition_RA_r13[cc_idx][prachparamsindex] = LTE_PRACH_ParametersCE_r13__mpdcch_NumRepetition_RA_r13_r256;
+	break;
+    default:
+      AssertFatal (1==0,
+		 "illegal mpdcch_NumRepeition_RA_r13 %d\n",
+		   eMTCconfig->mpdcch_NumRepetition_RA_r13);
+      break;
+    }
+		
+    RRC_CONFIGURATION_REQ (msg_p).prach_HoppingConfig_r13[cc_idx][prachparamsindex] = eMTCconfig->prach_HoppingConfig_r13;
+		
+    AssertFatal (eMTCconfig->prach_HoppingConfig_r13 >=0 && eMTCconfig->prach_HoppingConfig_r13 < 2,
+		 "Illegal prach_HoppingConfig_r13 %d\n",eMTCconfig->prach_HoppingConfig_r13);
+		
+		
+    int maxavailablenarrowband_count = prachParams[7].numelt;
+		
+    RRC_CONFIGURATION_REQ (msg_p).max_available_narrow_band_size[cc_idx][prachparamsindex] = maxavailablenarrowband_count;
+    int narrow_band_index;
+    for (narrow_band_index = 0; narrow_band_index < maxavailablenarrowband_count; narrow_band_index++) {
+      RRC_CONFIGURATION_REQ (msg_p).max_available_narrow_band[cc_idx][prachparamsindex][narrow_band_index] = prachParams[7].iptr[narrow_band_index];
+    }
+  }
+
+  char n1PUCCHInfoParamsPath[MAX_OPTNAME_SIZE * 2];
+  config_getlist(&n1PUCCHInfoList, NULL, 0, brparamspath);
+  RRC_CONFIGURATION_REQ (msg_p).pucch_info_value_size[cc_idx] = n1PUCCHInfoList.numelt;
+	      
+  int n1PUCCHinfolistindex;
+  for (n1PUCCHinfolistindex = 0; n1PUCCHinfolistindex < n1PUCCHInfoList.numelt; n1PUCCHinfolistindex++) {
+    sprintf(n1PUCCHInfoParamsPath, "%s.%s.[%i]", brparamspath, ENB_CONFIG_STRING_N1PUCCH_AN_INFOLIST_R13, n1PUCCHinfolistindex);
+    config_get(n1PUCCH_ANR13Params, sizeof(n1PUCCH_ANR13Params) / sizeof(paramdef_t), n1PUCCHInfoParamsPath);
+    RRC_CONFIGURATION_REQ (msg_p).pucch_info_value[cc_idx][n1PUCCHinfolistindex] = eMTCconfig->pucch_info_value;
+  }
+	      
+  char PCCHConfigv1310Path[MAX_OPTNAME_SIZE*2 + 16];
+  sprintf(PCCHConfigv1310Path, "%s.%s", brparamspath, ENB_CONFIG_STRING_PCCH_CONFIG_V1310);
+  config_get(pcchv1310Params, sizeof(pcchv1310Params)/sizeof(paramdef_t), PCCHConfigv1310Path);
+	      
+	      
+	      
+  /** PCCH CONFIG V1310 */
+	      
+  RRC_CONFIGURATION_REQ(msg_p).pcch_config_v1310[cc_idx] = TRUE;
+  RRC_CONFIGURATION_REQ(msg_p).paging_narrowbands_r13[cc_idx] = eMTCconfig->paging_narrowbands_r13;
+  RRC_CONFIGURATION_REQ(msg_p).mpdcch_numrepetition_paging_r13[cc_idx] = eMTCconfig->mpdcch_numrepetition_paging_r13;
+  AssertFatal (eMTCconfig->mpdcch_numrepetition_paging_r13 == 1 ||
+	       eMTCconfig->mpdcch_numrepetition_paging_r13 == 2 ||
+	       eMTCconfig->mpdcch_numrepetition_paging_r13 == 4 ||
+	       eMTCconfig->mpdcch_numrepetition_paging_r13 == 8 ||
+	       eMTCconfig->mpdcch_numrepetition_paging_r13 == 16 ||
+	       eMTCconfig->mpdcch_numrepetition_paging_r13 == 32 ||
+	       eMTCconfig->mpdcch_numrepetition_paging_r13 == 64 ||
+	       eMTCconfig->mpdcch_numrepetition_paging_r13 == 128 ||
+	       eMTCconfig->mpdcch_numrepetition_paging_r13 == 256,
+	       "illegal mpdcch_numrepetition_paging_r13 %d\n",
+	       eMTCconfig->mpdcch_numrepetition_paging_r13);
+	      
+	      
+  //                        RRC_CONFIGURATION_REQ(msg_p).nb_v1310[cc_idx] = CALLOC(1, sizeof(long));
+  //                        if (!strcmp(nb_v1310, "one64thT")) {
+  //                            *RRC_CONFIGURATION_REQ(msg_p).nb_v1310[cc_idx] = 0;
+  //                        } else if (!strcmp(nb_v1310, "one128thT")) {
+  //                            *RRC_CONFIGURATION_REQ(msg_p).nb_v1310[cc_idx] = 1;
+  //                        } else if (!strcmp(nb_v1310, "one256thT")) {
+  //                            *RRC_CONFIGURATION_REQ(msg_p).nb_v1310[cc_idx] = 2;
+  //                        } else {
+  //                            AssertFatal(0,
+  //                                        "Failed to parse eNB configuration file %s, nb_v1310, unknown value !\n",
+  //                                        config_fname);
+  //                        }
+	      
+	      
+	      
+  RRC_CONFIGURATION_REQ (msg_p).pucch_NumRepetitionCE_Msg4_Level0_r13[cc_idx] = CALLOC(1, sizeof(long));
+  // ++cnt; // check this ,, the conter is up above
+  if (!strcmp(eMTCconfig->pucch_NumRepetitionCE_Msg4_Level0_r13, "n1")) {
+    *RRC_CONFIGURATION_REQ (msg_p).pucch_NumRepetitionCE_Msg4_Level0_r13[cc_idx] = 0;
+  } else if (!strcmp(eMTCconfig->pucch_NumRepetitionCE_Msg4_Level0_r13, "n2")) {
+    *RRC_CONFIGURATION_REQ (msg_p).pucch_NumRepetitionCE_Msg4_Level0_r13[cc_idx] = 1;
+  } else if (!strcmp(eMTCconfig->pucch_NumRepetitionCE_Msg4_Level0_r13, "n4")) {
+    *RRC_CONFIGURATION_REQ (msg_p).pucch_NumRepetitionCE_Msg4_Level0_r13[cc_idx] = 2;
+  } else if (!strcmp(eMTCconfig->pucch_NumRepetitionCE_Msg4_Level0_r13, "n8")) {
+    *RRC_CONFIGURATION_REQ (msg_p).pucch_NumRepetitionCE_Msg4_Level0_r13[cc_idx] = 3;
+  } else {
+    AssertFatal (0,
+		 "Failed to parse eNB configuration file %s, pucch_NumRepetitionCE_Msg4_Level0_r13 unknown value!\n",
+		 config_fname);
+  }
+	      
+	      
+	      
+  /** SIB2 FREQ HOPPING PARAMETERS R13 */
+  RRC_CONFIGURATION_REQ(msg_p).sib2_freq_hoppingParameters_r13_exists[cc_idx] = TRUE;
+	      
+  char sib2FreqHoppingParametersR13Path[MAX_OPTNAME_SIZE*2 + 16];
+  sprintf(sib2FreqHoppingParametersR13Path, "%s.%s", brparamspath, ENB_CONFIG_STRING_SIB2_FREQ_HOPPINGPARAMETERS_R13);
+  config_get(sib2freqhoppingParams, sizeof(sib2freqhoppingParams)/sizeof(paramdef_t), sib2FreqHoppingParametersR13Path);
+	      
+	      
+  RRC_CONFIGURATION_REQ(msg_p).sib2_interval_ULHoppingConfigCommonModeA_r13[cc_idx] = CALLOC(1, sizeof(long));
+  if (!strcmp(eMTCconfig->sib2_interval_ULHoppingConfigCommonModeA_r13, "FDD")) {
+    *RRC_CONFIGURATION_REQ(msg_p).sib2_interval_ULHoppingConfigCommonModeA_r13[cc_idx] = 0;
+    
+    switch(eMTCconfig->sib2_interval_ULHoppingConfigCommonModeA_r13_val) {
+    case 1:
+      RRC_CONFIGURATION_REQ(msg_p).sib2_interval_ULHoppingConfigCommonModeA_r13_val[cc_idx] = 0;
+      break;
+    case 2:
+      RRC_CONFIGURATION_REQ(msg_p).sib2_interval_ULHoppingConfigCommonModeA_r13_val[cc_idx] = 1;
+      break;
+    case 4:
+      RRC_CONFIGURATION_REQ(msg_p).sib2_interval_ULHoppingConfigCommonModeA_r13_val[cc_idx] = 2;
+      break;
+    case 8:
+      RRC_CONFIGURATION_REQ(msg_p).sib2_interval_ULHoppingConfigCommonModeA_r13_val[cc_idx] = 3;
+      break;
+    default:
+      AssertFatal(1==0,
+		  "illegal sib2_interval_ULHoppingConfigCommonModeA_r13_val %d\n",
+		  eMTCconfig->sib2_interval_ULHoppingConfigCommonModeA_r13_val);
+    }
+  } else if (!strcmp(eMTCconfig->sib2_interval_ULHoppingConfigCommonModeA_r13, "TDD")) {
+    *RRC_CONFIGURATION_REQ(msg_p).sib2_interval_ULHoppingConfigCommonModeA_r13[cc_idx] = 1;
+    switch(eMTCconfig->sib2_interval_ULHoppingConfigCommonModeA_r13_val) {
+    case 1:
+      RRC_CONFIGURATION_REQ(msg_p).sib2_interval_ULHoppingConfigCommonModeA_r13_val[cc_idx] = 0;
+      break;
+    case 5:
+      RRC_CONFIGURATION_REQ(msg_p).sib2_interval_ULHoppingConfigCommonModeA_r13_val[cc_idx] = 1;
+      break;
+    case 10:
+      RRC_CONFIGURATION_REQ(msg_p).sib2_interval_ULHoppingConfigCommonModeA_r13_val[cc_idx] = 2;
+      break;
+    case 20:
+      RRC_CONFIGURATION_REQ(msg_p).sib2_interval_ULHoppingConfigCommonModeA_r13_val[cc_idx] = 3;
+      break;
+    default:
+      AssertFatal(1==0,
+		  "illegal sib2_interval_ULHoppingConfigCommonModeA_r13_val %d\n",
+		  eMTCconfig->sib2_interval_ULHoppingConfigCommonModeA_r13_val);
+      break;
+    }
+  } else {
+    AssertFatal (1==0,
+		 "Failed to parse eNB configuration file %s, sib2_interval_ULHoppingConfigCommonModeA_r13 unknown value !!\n",
+		 config_fname);
+  }
+} 
diff --git a/openair2/ENB_APP/enb_paramdef.h b/openair2/ENB_APP/enb_paramdef.h
old mode 100755
new mode 100644
index 576a9bf0a2abdef36f4b83f9e2e25815fe5806b9..b44ec9de16b00b6a2e0b23a9c1c1b24dbb24dd67
--- a/openair2/ENB_APP/enb_paramdef.h
+++ b/openair2/ENB_APP/enb_paramdef.h
@@ -19,7 +19,7 @@
  *      contact@openairinterface.org
  */
 
-/*! \file openair2/ENB_APP/enb_paramdef.f
+/*! \file openair2/ENB_APP/enb_paramdef.h
  * \brief definition of configuration parameters for all eNodeB modules 
  * \author Francois TABURET
  * \date 2017
@@ -30,6 +30,8 @@
  * \warning
  */
 
+#ifndef ENB_PARAMDEF_H_
+#define ENB_PARAMDEF_H_
 #include "common/config/config_paramdesc.h"
 #include "RRC_paramsvalues.h"
 
@@ -299,9 +301,24 @@ typedef enum {
 //#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
 #define ENB_CONFIG_STRING_PUCCH_N1_AN                                   "pucch_n1_AN"
 //#endif
+
+#define ENB_CONFIG_STRING_PCCH_CONFIG_V1310                      "pcch_config_v1310"
+#define ENB_CONFIG_STRING_PAGING_NARROWBANDS_R13                 "paging_narrowbands_r13"
+#define ENB_CONFIG_STRING_MPDCCH_NUMREPETITION_PAGING_R13        "mpdcch_numrepetition_paging_r13"
+#define ENB_CONFIG_STRING_NB_V1310                               "nb_v1310"
+
+
+#define ENB_CONFIG_STRING_PUCCH_NUM_REPETITION_CE_MSG4_LEVEL0    "pucch_NumRepetitionCE_Msg4_Level0_r13" 
+#define ENB_CONFIG_STRING_PUCCH_NUM_REPETITION_CE_MSG4_LEVEL1    "pucch_NumRepetitionCE_Msg4_Level1_r13"
+#define ENB_CONFIG_STRING_PUCCH_NUM_REPETITION_CE_MSG4_LEVEL2    "pucch_NumRepetitionCE_Msg4_Level2_r13"
+#define ENB_CONFIG_STRING_PUCCH_NUM_REPETITION_CE_MSG4_LEVEL3    "pucch_NumRepetitionCE_Msg4_Level3_r13"
+
+#define ENB_CONFIG_STRING_FREQ_HOPPING_PARAMETERS_R13                      "sib2_freq_hoppingParameters_r13"
+
+
 #define ENB_CONFIG_STRING_PDSCH_RS_EPRE                                 "pdsch_referenceSignalPower"
 #define ENB_CONFIG_STRING_PDSCH_PB                                      "pdsch_p_b"
-#define ENB_CONFIG_STRING_PUSCH_N_SB                                     "pusch_n_SB"
+#define ENB_CONFIG_STRING_PUSCH_N_SB                                    "pusch_n_SB"
 #define ENB_CONFIG_STRING_PUSCH_HOPPINGMODE                             "pusch_hoppingMode"
 #define ENB_CONFIG_STRING_PUSCH_HOPPINGOFFSET                           "pusch_hoppingOffset"
 #define ENB_CONFIG_STRING_PUSCH_ENABLE64QAM                             "pusch_enable64QAM"
@@ -325,6 +342,7 @@ typedef enum {
 #define ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2                          "pucch_deltaF_Format2"
 #define ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2A                         "pucch_deltaF_Format2a"
 #define ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2B                         "pucch_deltaF_Format2b"
+
 #define ENB_CONFIG_STRING_RACH_NUM_RA_PREAMBLES                         "rach_numberOfRA_Preambles"
 #define ENB_CONFIG_STRING_RACH_PREAMBLESGROUPACONFIG                    "rach_preamblesGroupAConfig"
 #define ENB_CONFIG_STRING_RACH_SIZEOFRA_PREAMBLESGROUPA                 "rach_sizeOfRA_PreamblesGroupA"
@@ -348,6 +366,14 @@ typedef enum {
 #define ENB_CONFIG_STRING_UE_TRANSMISSION_MODE                          "ue_TransmissionMode"
 #define ENB_CONFIG_STRING_UE_MULTIPLE_MAX                               "ue_multiple_max"
 
+#define ENB_CONFIG_STRING_PDSCH_MAX_NUM_REPETITION_CE_MODE_A_R13        "pdsch_maxNumRepetitionCEmodeA_r13"
+#define ENB_CONFIG_STRING_PDSCH_MAX_NUM_REPETITION_CE_MODE_B_R13        "pdsch_maxNumRepetitionCEmodeB_r13"
+
+#define ENB_CONFIG_STRING_PUSCH_MAX_NUM_REPETITION_CE_MODE_A_R13        "pusch_maxNumRepetitionCEmodeA_r13"
+#define ENB_CONFIG_STRING_PUSCH_MAX_NUM_REPETITION_CE_MODE_B_R13        "pusch_maxNumRepetitionCEmodeB_r13"
+#define ENB_CONFIG_STRING_PUSCH_HOPPING_OFFSET_V1310                    "pusch_HoppingOffset_v1310"
+
+		
 //TTN - for D2D
 //SIB18
 #define ENB_CONFIG_STRING_RXPOOL_SC_CP_LEN                              "rxPool_sc_CP_Len"
@@ -392,12 +418,93 @@ typedef enum {
 #define ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_CHOICE_BS_SIZE             "DISCRXPOOLPS_ResourceConfig_subframeBitmap_choice_bs_size"
 #define ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_CHOICE_BS_ASN_BITS_UNUSED  "DISCRXPOOLPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused"
 
+
 /*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
 /*                                     component carriers configuration parameters                                                                                                     */
 /*   optname                                                   helpstr   paramflags    XXXptr                                        defXXXval                    type         numelt  */
 /*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
 /* init for checkedparam_t structure */
 
+typedef struct ccparams_lte_s {
+  char             *frame_type;
+  int32_t           tdd_config;
+  int32_t           tdd_config_s;
+  char             *prefix_type;
+  char             *pbch_repetition;
+  int32_t           eutra_band;
+  long long int     downlink_frequency;
+  int32_t           uplink_frequency_offset;
+  int32_t           Nid_cell;
+  int32_t           Nid_cell_mbsfn;
+  int32_t           N_RB_DL;
+  int32_t           nb_antenna_ports;
+  int32_t           prach_root;
+  int32_t           prach_config_index;
+  char             *prach_high_speed;
+  int32_t           prach_zero_correlation;
+  int32_t           prach_freq_offset;
+  int32_t           pucch_delta_shift;
+  int32_t           pucch_nRB_CQI;
+  int32_t           pucch_nCS_AN;
+  int32_t           pucch_n1_AN;
+  int32_t           pdsch_referenceSignalPower;
+  int32_t           pdsch_p_b;
+  int32_t           pusch_n_SB;
+  char             *pusch_hoppingMode;
+  int32_t           pusch_hoppingOffset;
+  char             *pusch_enable64QAM;
+  char             *pusch_groupHoppingEnabled;
+  int32_t           pusch_groupAssignment;
+  char             *pusch_sequenceHoppingEnabled;
+  int32_t           pusch_nDMRS1;
+  char             *phich_duration;
+  char             *phich_resource;
+  char             *srs_enable;
+  int32_t           srs_BandwidthConfig;
+  int32_t           srs_SubframeConfig;
+  char             *srs_ackNackST;
+  char             *srs_MaxUpPts;
+  int32_t           pusch_p0_Nominal;
+  char             *pusch_alpha;
+  int32_t           pucch_p0_Nominal;
+  int32_t           msg3_delta_Preamble;
+  int32_t           ul_CyclicPrefixLength;
+  char             *pucch_deltaF_Format1;
+  char             *pucch_deltaF_Format1a;
+  char             *pucch_deltaF_Format1b;
+  char             *pucch_deltaF_Format2;
+  char             *pucch_deltaF_Format2a;
+  char             *pucch_deltaF_Format2b;
+  int32_t           rach_numberOfRA_Preambles;
+  char             *rach_preamblesGroupAConfig;
+  int32_t           rach_sizeOfRA_PreamblesGroupA;
+  int32_t           rach_messageSizeGroupA;
+  char             *rach_messagePowerOffsetGroupB;
+  int32_t           rach_powerRampingStep;
+  int32_t           rach_preambleInitialReceivedTargetPower;
+  int32_t           rach_preambleTransMax;
+  int32_t           rach_raResponseWindowSize;
+  int32_t           rach_macContentionResolutionTimer;
+  int32_t           rach_maxHARQ_Msg3Tx;
+  int32_t           pcch_defaultPagingCycle;
+  char             *pcch_nB;
+  int32_t           bcch_modificationPeriodCoeff;
+  int32_t           ue_TimersAndConstants_t300;
+  int32_t           ue_TimersAndConstants_t301;
+  int32_t           ue_TimersAndConstants_t310;
+  int32_t           ue_TimersAndConstants_t311;
+  int32_t           ue_TimersAndConstants_n310;
+  int32_t           ue_TimersAndConstants_n311;
+  int32_t           ue_TransmissionMode;
+  int32_t           ue_multiple_max;
+  int32_t           srb1_timer_poll_retransmit;
+  int32_t           srb1_timer_reordering;
+  int32_t           srb1_timer_status_prohibit;
+  int32_t           srb1_poll_pdu;
+  int32_t           srb1_poll_byte;
+  int32_t           srb1_max_retx_threshold;
+} ccparams_lte_t;
+
 #define CCPARAMS_CHECK                 {                                     \
              { .s5= {NULL }} ,						     \
              { .s5= {NULL }} ,						     \
@@ -505,123 +612,87 @@ typedef enum {
                           { .s5= {NULL }} ,						     \
                           { .s5= {NULL }} ,						     \
                           { .s5= {NULL }} ,						     \
-                          { .s5= {NULL }} ,						     \
+			  { .s5= {NULL }}				\
 }
 /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
 /*                                     component carriers configuration parameters                                                                                                                   */
 /*   optname                                                   helpstr   paramflags    XXXptr                                        defXXXval                    type         numelt  checked_param */
 /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
 
-#define CCPARAMS_DESC { \
-{ENB_CONFIG_STRING_FRAME_TYPE,                                   NULL,   0,           strptr:&frame_type,                             defstrval:"FDD",           TYPE_STRING,     0},  \
-{ENB_CONFIG_STRING_TDD_CONFIG,                                   NULL,   0,           iptr:&tdd_config,                               defintval:3,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_TDD_CONFIG_S,                                 NULL,   0,           iptr:&tdd_config_s,                             defintval:0,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_PREFIX_TYPE,                                  NULL,   0,           strptr:&prefix_type,                            defstrval:"NORMAL",        TYPE_STRING,     0},  \
-{ENB_CONFIG_STRING_PBCH_REPETITION,                              NULL,   0,           strptr:&pbch_repetition,                        defstrval:"FALSE",         TYPE_STRING,     0},  \
-{ENB_CONFIG_STRING_EUTRA_BAND,                                   NULL,   0,           iptr:&eutra_band,                               defintval:7,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_DOWNLINK_FREQUENCY,                           NULL,   0,           i64ptr:(int64_t *)&downlink_frequency,          defint64val:2680000000,    TYPE_UINT64,     0},  \
-{ENB_CONFIG_STRING_UPLINK_FREQUENCY_OFFSET,                      NULL,   0,           iptr:&uplink_frequency_offset,                  defintval:-120000000,      TYPE_INT,        0},  \
-{ENB_CONFIG_STRING_NID_CELL,                                     NULL,   0,           iptr:&Nid_cell,                                 defintval:0,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_N_RB_DL,                                      NULL,   0,           iptr:&N_RB_DL,                                  defintval:25,              TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_CELL_MBSFN,                                   NULL,   0,           iptr:&Nid_cell_mbsfn,                           defintval:0,               TYPE_INT,        0},  \
-{ENB_CONFIG_STRING_NB_ANT_PORTS,                                 NULL,   0,           iptr:&nb_antenna_ports,                         defintval:1,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_PRACH_ROOT,                                   NULL,   0,           iptr:&prach_root,                               defintval:0,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_PRACH_CONFIG_INDEX,                           NULL,   0,           iptr:&prach_config_index,                       defintval:0,               TYPE_INT,        0},  \
-{ENB_CONFIG_STRING_PRACH_HIGH_SPEED,                             NULL,   0,           strptr:&prach_high_speed,                       defstrval:"DISABLE",       TYPE_STRING,     0},  \
-{ENB_CONFIG_STRING_PRACH_ZERO_CORRELATION,                       NULL,   0,           iptr:&prach_zero_correlation,                   defintval:1,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_PRACH_FREQ_OFFSET,                            NULL,   0,           iptr:&prach_freq_offset,                        defintval:2,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_PUCCH_DELTA_SHIFT,                            NULL,   0,           iptr:&pucch_delta_shift,                        defintval:1,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_PUCCH_NRB_CQI,                                NULL,   0,           iptr:&pucch_nRB_CQI,                            defintval:1,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_PUCCH_NCS_AN,                                 NULL,   0,           iptr:&pucch_nCS_AN,                             defintval:0,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_PUCCH_N1_AN,                                  NULL,   0,           iptr:&pucch_n1_AN,                              defintval:0,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_PDSCH_RS_EPRE,                                NULL,   0,           iptr:&pdsch_referenceSignalPower,               defintval:-29,             TYPE_INT,        0},  \
-{ENB_CONFIG_STRING_PDSCH_PB,                                     NULL,   0,           iptr:&pdsch_p_b,                                defintval:0,               TYPE_INT,        0},  \
-{ENB_CONFIG_STRING_PUSCH_N_SB,                                   NULL,   0,           iptr:&pusch_n_SB,                               defintval:1,               TYPE_INT,        0},  \
-{ENB_CONFIG_STRING_PUSCH_HOPPINGMODE,                            NULL,   0,           strptr:&pusch_hoppingMode,                      defstrval:"interSubFrame", TYPE_STRING,     0},  \
-{ENB_CONFIG_STRING_PUSCH_HOPPINGOFFSET,                          NULL,   0,           iptr:&pusch_hoppingOffset,                      defintval:0,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_PUSCH_ENABLE64QAM,                            NULL,   0,           strptr:&pusch_enable64QAM,                      defstrval:"DISABLE",       TYPE_STRING,     0},  \
-{ENB_CONFIG_STRING_PUSCH_GROUP_HOPPING_EN,                       NULL,   0,           strptr:&pusch_groupHoppingEnabled,              defstrval:"ENABLE",        TYPE_STRING,     0},  \
-{ENB_CONFIG_STRING_PUSCH_GROUP_ASSIGNMENT,                       NULL,   0,           iptr:&pusch_groupAssignment,                    defintval:0,               TYPE_INT,        0},  \
-{ENB_CONFIG_STRING_PUSCH_SEQUENCE_HOPPING_EN,                    NULL,   0,           strptr:&pusch_sequenceHoppingEnabled,           defstrval:"DISABLE",       TYPE_STRING,     0},  \
-{ENB_CONFIG_STRING_PUSCH_NDMRS1,                                 NULL,   0,           iptr:&pusch_nDMRS1,                             defintval:0,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_PHICH_DURATION,                               NULL,   0,           strptr:&phich_duration,                         defstrval:"NORMAL",        TYPE_STRING,     0},  \
-{ENB_CONFIG_STRING_PHICH_RESOURCE,                               NULL,   0,           strptr:&phich_resource,                         defstrval:"ONESIXTH",      TYPE_STRING,     0},  \
-{ENB_CONFIG_STRING_SRS_ENABLE,                                   NULL,   0,           strptr:&srs_enable,                             defstrval:"DISABLE",       TYPE_STRING,     0},  \
-{ENB_CONFIG_STRING_SRS_BANDWIDTH_CONFIG,                         NULL,   0,           iptr:&srs_BandwidthConfig,                      defintval:0,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_SRS_SUBFRAME_CONFIG,                          NULL,   0,           iptr:&srs_SubframeConfig,                       defintval:0,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_SRS_ACKNACKST_CONFIG,                         NULL,   0,           strptr:&srs_ackNackST,                          defstrval:"DISABLE",       TYPE_STRING,     0},  \
-{ENB_CONFIG_STRING_SRS_MAXUPPTS,                                 NULL,   0,           strptr:&srs_MaxUpPts,                           defstrval:"DISABLE",       TYPE_STRING,     0},  \
-{ENB_CONFIG_STRING_PUSCH_PO_NOMINAL,                             NULL,   0,           iptr:&pusch_p0_Nominal,                         defintval:-90,             TYPE_INT,        0},  \
-{ENB_CONFIG_STRING_PUSCH_ALPHA,                                  NULL,   0,           strptr:&pusch_alpha,                            defstrval:"AL1",           TYPE_STRING,     0},  \
-{ENB_CONFIG_STRING_PUCCH_PO_NOMINAL,                             NULL,   0,           iptr:&pucch_p0_Nominal,                         defintval:-96,             TYPE_INT,        0},  \
-{ENB_CONFIG_STRING_MSG3_DELTA_PREAMBLE,                          NULL,   0,           iptr:&msg3_delta_Preamble,                      defintval:6,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT1,                         NULL,   0,           strptr:&pucch_deltaF_Format1,                   defstrval:"DELTAF2",       TYPE_STRING,     0},  \
-{ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT1b,                        NULL,   0,           strptr:&pucch_deltaF_Format1b,                  defstrval:"deltaF3",       TYPE_STRING,     0},  \
-{ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2,                         NULL,   0,           strptr:&pucch_deltaF_Format2,                   defstrval:"deltaF0",       TYPE_STRING,     0},  \
-{ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2A,                        NULL,   0,           strptr:&pucch_deltaF_Format2a,                  defstrval:"deltaF0",       TYPE_STRING,     0},  \
-{ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2B,                        NULL,   0,           strptr:&pucch_deltaF_Format2b,                  defstrval:"deltaF0",       TYPE_STRING,     0},  \
-{ENB_CONFIG_STRING_RACH_NUM_RA_PREAMBLES,                        NULL,   0,           iptr:&rach_numberOfRA_Preambles,                defintval:4,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_RACH_PREAMBLESGROUPACONFIG,                   NULL,   0,           strptr:&rach_preamblesGroupAConfig,             defstrval:"DISABLE",       TYPE_STRING,     0},  \
-{ENB_CONFIG_STRING_RACH_SIZEOFRA_PREAMBLESGROUPA,                NULL,   0,           iptr:&rach_sizeOfRA_PreamblesGroupA,            defintval:0,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_RACH_MESSAGESIZEGROUPA,                       NULL,   0,           iptr:&rach_messageSizeGroupA,                   defintval:56,              TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_RACH_MESSAGEPOWEROFFSETGROUPB,                NULL,   0,           strptr:&rach_messagePowerOffsetGroupB,          defstrval:"minusinfinity", TYPE_STRING,     0},  \
-{ENB_CONFIG_STRING_RACH_POWERRAMPINGSTEP,                        NULL,   0,           iptr:&rach_powerRampingStep,                    defintval:4,               TYPE_INT,        0},  \
-{ENB_CONFIG_STRING_RACH_PREAMBLEINITIALRECEIVEDTARGETPOWER,      NULL,   0,           iptr:&rach_preambleInitialReceivedTargetPower,  defintval:-100,            TYPE_INT,        0},  \
-{ENB_CONFIG_STRING_RACH_PREAMBLETRANSMAX,                        NULL,   0,           iptr:&rach_preambleTransMax,                    defintval:10,              TYPE_INT,        0},  \
-{ENB_CONFIG_STRING_RACH_RARESPONSEWINDOWSIZE,                    NULL,   0,           iptr:&rach_raResponseWindowSize,                defintval:10,              TYPE_INT,        0},  \
-{ENB_CONFIG_STRING_RACH_MACCONTENTIONRESOLUTIONTIMER,            NULL,   0,           iptr:&rach_macContentionResolutionTimer,        defintval:48,              TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_RACH_MAXHARQMSG3TX,                           NULL,   0,           iptr:&rach_maxHARQ_Msg3Tx,                      defintval:4,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_PCCH_DEFAULT_PAGING_CYCLE,                    NULL,   0,           iptr:&pcch_defaultPagingCycle,                  defintval:128,             TYPE_INT,        0},  \
-{ENB_CONFIG_STRING_PCCH_NB,                                      NULL,   0,           strptr:&pcch_nB,                                defstrval:"oneT",          TYPE_STRING,     0},  \
-{ENB_CONFIG_STRING_BCCH_MODIFICATIONPERIODCOEFF,                 NULL,   0,           iptr:&bcch_modificationPeriodCoeff,             defintval:2,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_UETIMERS_T300,                                NULL,   0,           iptr:&ue_TimersAndConstants_t300,               defintval:1000,            TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_UETIMERS_T301,                                NULL,   0,           iptr:&ue_TimersAndConstants_t301,               defintval:1000,            TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_UETIMERS_T310,                                NULL,   0,           iptr:&ue_TimersAndConstants_t310,               defintval:1000,            TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_UETIMERS_T311,                                NULL,   0,           iptr:&ue_TimersAndConstants_t311,               defintval:10000,           TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_UETIMERS_N310,                                NULL,   0,           iptr:&ue_TimersAndConstants_n310,               defintval:20,              TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_UETIMERS_N311,                                NULL,   0,           iptr:&ue_TimersAndConstants_n311,               defintval:1,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_UE_TRANSMISSION_MODE,                         NULL,   0,           iptr:&ue_TransmissionMode,                      defintval:1,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_UE_MULTIPLE_MAX,                              NULL,   0,           iptr:&ue_multiple_max,                          defintval:4,               TYPE_UINT,       0},  \
-{ENB_CONFIG_STRING_RXPOOL_SC_CP_LEN,                             NULL,   0,   strptr:(char **)&rxPool_sc_CP_Len,          defstrval:"normal",  TYPE_STRING,  0}, \
-{ENB_CONFIG_STRING_RXPOOL_SC_PRIOD,                              NULL,   0,   strptr:(char **)&rxPool_sc_Period,          defstrval:"sf40",  TYPE_STRING,  0}, \
-{ENB_CONFIG_STRING_RXPOOL_DATA_CP_LEN,                           NULL,   0,   strptr:(char **)&rxPool_data_CP_Len,          defstrval:"normal",  TYPE_STRING,  0}, \
-{ENB_CONFIG_STRING_RXPOOL_RC_PRB_NUM,                            NULL,   0,   iptr:(int32_t *)&rxPool_ResourceConfig_prb_Num,         defintval:1,       TYPE_UINT,    0}, \
-{ENB_CONFIG_STRING_RXPOOL_RC_PRB_START,                          NULL,   0,   iptr:(int32_t *)&rxPool_ResourceConfig_prb_Start,         defintval:1,       TYPE_UINT,    0}, \
-{ENB_CONFIG_STRING_RXPOOL_RC_PRB_END,                            NULL,   0,   iptr:(int32_t *)&rxPool_ResourceConfig_prb_End,         defintval:1,       TYPE_UINT,    0}, \
-{ENB_CONFIG_STRING_RXPOOL_RC_OFFSETIND_PRESENT,                  NULL,   0,   strptr:(char **)&rxPool_ResourceConfig_offsetIndicator_present,            defstrval:"prNothing",  TYPE_STRING,  0}, \
-{ENB_CONFIG_STRING_RXPOOL_RC_OFFSETIND_CHOICE,                   NULL,   0,   iptr:(int32_t *)&rxPool_ResourceConfig_offsetIndicator_choice,         defintval:1,       TYPE_UINT,    0}, \
-{ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_PRESENT,                   NULL,   0,   strptr:(char **)&rxPool_ResourceConfig_subframeBitmap_present,            defstrval:"prNothing",  TYPE_STRING,  0}, \
-{ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_CHOICE_BS_BUF,             NULL,   0,   strptr:(char **)&rxPool_ResourceConfig_subframeBitmap_choice_bs_buf,            defstrval:"001001",  TYPE_STRING,  0}, \
-{ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_CHOICE_BS_SIZE,            NULL,   0,   iptr:(int32_t *)&rxPool_ResourceConfig_subframeBitmap_choice_bs_size,         defintval:1,       TYPE_UINT,    0}, \
-{ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_CHOICE_BS_ASN_BITS_UNUSED, NULL,   0,   iptr:(int32_t *)&rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused,         defintval:1,       TYPE_UINT,    0}, \
-{ENB_CONFIG_STRING_DISCRXPOOL_CP_LEN,                            NULL,   0,   strptr:(char **)&discRxPool_cp_Len,          defstrval:"normal",  TYPE_STRING,  0}, \
-{ENB_CONFIG_STRING_DISCRXPOOL_DISCPERIOD,                        NULL,   0,   strptr:(char **)&discRxPool_discPeriod,          defstrval:"rf32",  TYPE_STRING,  0}, \
-{ENB_CONFIG_STRING_DISCRXPOOL_NUMRETX,                           NULL,   0,   iptr:(int32_t *)&discRxPool_numRetx,         defintval:1,       TYPE_UINT,    0}, \
-{ENB_CONFIG_STRING_DISCRXPOOL_NUMREPETITION,                     NULL,   0,   iptr:(int32_t *)&discRxPool_numRepetition,         defintval:1,       TYPE_UINT,    0}, \
-{ENB_CONFIG_STRING_DISCRXPOOL_RC_PRB_NUM,                        NULL,   0,   iptr:(int32_t *)&discRxPool_ResourceConfig_prb_Num,         defintval:1,       TYPE_UINT,    0}, \
-{ENB_CONFIG_STRING_DISCRXPOOL_RC_PRB_START,                      NULL,   0,   iptr:(int32_t *)&discRxPool_ResourceConfig_prb_Start,         defintval:1,       TYPE_UINT,    0}, \
-{ENB_CONFIG_STRING_DISCRXPOOL_RC_PRB_END,                        NULL,   0,   iptr:(int32_t *)&discRxPool_ResourceConfig_prb_End,         defintval:1,       TYPE_UINT,    0}, \
-{ENB_CONFIG_STRING_DISCRXPOOL_RC_OFFSETIND_PRESENT,              NULL,   0,   strptr:(char **)&discRxPool_ResourceConfig_offsetIndicator_present,            defstrval:"prNothing",  TYPE_STRING,  0}, \
-{ENB_CONFIG_STRING_DISCRXPOOL_RC_OFFSETIND_CHOICE,               NULL,   0,   iptr:(int32_t *)&discRxPool_ResourceConfig_offsetIndicator_choice,         defintval:1,       TYPE_UINT,    0}, \
-{ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_PRESENT,               NULL,   0,   strptr:(char **)&discRxPool_ResourceConfig_subframeBitmap_present,            defstrval:"prNothing",  TYPE_STRING,  0}, \
-{ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_CHOICE_BS_BUF,         NULL,   0,   strptr:(char **)&discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf,            defstrval:"001001",  TYPE_STRING,  0}, \
-{ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_CHOICE_BS_SIZE,        NULL,   0,   iptr:(int32_t *)&discRxPool_ResourceConfig_subframeBitmap_choice_bs_size,         defintval:1,       TYPE_UINT,    0}, \
-{ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_CHOICE_BS_ASN_BITS_UNUSED,NULL,   0,   iptr:(int32_t *)&discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused,         defintval:1,       TYPE_UINT,    0}, \
-{ENB_CONFIG_STRING_DISCRXPOOLPS_CP_LEN,                            NULL,   0,   strptr:(char **)&discRxPoolPS_cp_Len,          defstrval:"normal",  TYPE_STRING,  0}, \
-{ENB_CONFIG_STRING_DISCRXPOOLPS_DISCPERIOD,                        NULL,   0,   strptr:(char **)&discRxPoolPS_discPeriod,          defstrval:"rf32",  TYPE_STRING,  0}, \
-{ENB_CONFIG_STRING_DISCRXPOOLPS_NUMRETX,                           NULL,   0,   iptr:(int32_t *)&discRxPoolPS_numRetx,         defintval:1,       TYPE_UINT,    0}, \
-{ENB_CONFIG_STRING_DISCRXPOOLPS_NUMREPETITION,                     NULL,   0,   iptr:(int32_t *)&discRxPoolPS_numRepetition,         defintval:1,       TYPE_UINT,    0}, \
-{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_PRB_NUM,                        NULL,   0,   iptr:(int32_t *)&discRxPoolPS_ResourceConfig_prb_Num,         defintval:1,       TYPE_UINT,    0}, \
-{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_PRB_START,                      NULL,   0,   iptr:(int32_t *)&discRxPoolPS_ResourceConfig_prb_Start,         defintval:1,       TYPE_UINT,    0}, \
-{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_PRB_END,                        NULL,   0,   iptr:(int32_t *)&discRxPoolPS_ResourceConfig_prb_End,         defintval:1,       TYPE_UINT,    0}, \
-{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_OFFSETIND_PRESENT,              NULL,   0,   strptr:(char **)&discRxPoolPS_ResourceConfig_offsetIndicator_present,            defstrval:"prNothing",  TYPE_STRING,  0}, \
-{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_OFFSETIND_CHOICE,               NULL,   0,   iptr:(int32_t *)&discRxPoolPS_ResourceConfig_offsetIndicator_choice,         defintval:1,       TYPE_UINT,    0}, \
-{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_PRESENT,               NULL,   0,   strptr:(char **)&discRxPoolPS_ResourceConfig_subframeBitmap_present,            defstrval:"prNothing",  TYPE_STRING,  0}, \
-{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_CHOICE_BS_BUF,         NULL,   0,   strptr:(char **)&discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf,            defstrval:"001001",  TYPE_STRING,  0}, \
-{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_CHOICE_BS_SIZE,        NULL,   0,   iptr:(int32_t *)&discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size,         defintval:1,       TYPE_UINT,    0}, \
-{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_CHOICE_BS_ASN_BITS_UNUSED,NULL,   0,   iptr:(int32_t *)&discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused,         defintval:1,       TYPE_UINT,    0} \
+#define CCPARAMS_DESC(ccparams) {					\
+{ENB_CONFIG_STRING_FRAME_TYPE,                                   NULL,   0,           strptr:&ccparams.frame_type,                             defstrval:"FDD",           TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_TDD_CONFIG,                                   NULL,   0,           iptr:&ccparams.tdd_config,                               defintval:3,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_TDD_CONFIG_S,                                 NULL,   0,           iptr:&ccparams.tdd_config_s,                             defintval:0,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PREFIX_TYPE,                                  NULL,   0,           strptr:&ccparams.prefix_type,                            defstrval:"NORMAL",        TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PBCH_REPETITION,                              NULL,   0,           strptr:&ccparams.pbch_repetition,                        defstrval:"FALSE",         TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_EUTRA_BAND,                                   NULL,   0,           iptr:&ccparams.eutra_band,                               defintval:7,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_DOWNLINK_FREQUENCY,                           NULL,   0,           i64ptr:(int64_t *)&ccparams.downlink_frequency,          defint64val:2680000000,    TYPE_UINT64,     0},  \
+{ENB_CONFIG_STRING_UPLINK_FREQUENCY_OFFSET,                      NULL,   0,           iptr:&ccparams.uplink_frequency_offset,                  defintval:-120000000,      TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_NID_CELL,                                     NULL,   0,           iptr:&ccparams.Nid_cell,                                 defintval:0,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_N_RB_DL,                                      NULL,   0,           iptr:&ccparams.N_RB_DL,                                  defintval:25,              TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_CELL_MBSFN,                                   NULL,   0,           iptr:&ccparams.Nid_cell_mbsfn,                           defintval:0,               TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_NB_ANT_PORTS,                                 NULL,   0,           iptr:&ccparams.nb_antenna_ports,                         defintval:1,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PRACH_ROOT,                                   NULL,   0,           iptr:&ccparams.prach_root,                               defintval:0,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PRACH_CONFIG_INDEX,                           NULL,   0,           iptr:&ccparams.prach_config_index,                       defintval:0,               TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_PRACH_HIGH_SPEED,                             NULL,   0,           strptr:&ccparams.prach_high_speed,                       defstrval:"DISABLE",       TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PRACH_ZERO_CORRELATION,                       NULL,   0,           iptr:&ccparams.prach_zero_correlation,                   defintval:1,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PRACH_FREQ_OFFSET,                            NULL,   0,           iptr:&ccparams.prach_freq_offset,                        defintval:2,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PUCCH_DELTA_SHIFT,                            NULL,   0,           iptr:&ccparams.pucch_delta_shift,                        defintval:1,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PUCCH_NRB_CQI,                                NULL,   0,           iptr:&ccparams.pucch_nRB_CQI,                            defintval:1,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PUCCH_NCS_AN,                                 NULL,   0,           iptr:&ccparams.pucch_nCS_AN,                             defintval:0,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PUCCH_N1_AN,                                  NULL,   0,           iptr:&ccparams.pucch_n1_AN,                              defintval:0,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PDSCH_RS_EPRE,                                NULL,   0,           iptr:&ccparams.pdsch_referenceSignalPower,               defintval:-29,             TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_PDSCH_PB,                                     NULL,   0,           iptr:&ccparams.pdsch_p_b,                                defintval:0,               TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_PUSCH_N_SB,                                   NULL,   0,           iptr:&ccparams.pusch_n_SB,                               defintval:1,               TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_PUSCH_HOPPINGMODE,                            NULL,   0,           strptr:&ccparams.pusch_hoppingMode,                      defstrval:"interSubFrame", TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PUSCH_HOPPINGOFFSET,                          NULL,   0,           iptr:&ccparams.pusch_hoppingOffset,                      defintval:0,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PUSCH_ENABLE64QAM,                            NULL,   0,           strptr:&ccparams.pusch_enable64QAM,                      defstrval:"DISABLE",       TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PUSCH_GROUP_HOPPING_EN,                       NULL,   0,           strptr:&ccparams.pusch_groupHoppingEnabled,              defstrval:"ENABLE",        TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PUSCH_GROUP_ASSIGNMENT,                       NULL,   0,           iptr:&ccparams.pusch_groupAssignment,                    defintval:0,               TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_PUSCH_SEQUENCE_HOPPING_EN,                    NULL,   0,           strptr:&ccparams.pusch_sequenceHoppingEnabled,           defstrval:"DISABLE",       TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PUSCH_NDMRS1,                                 NULL,   0,           iptr:&ccparams.pusch_nDMRS1,                             defintval:0,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PHICH_DURATION,                               NULL,   0,           strptr:&ccparams.phich_duration,                         defstrval:"NORMAL",        TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PHICH_RESOURCE,                               NULL,   0,           strptr:&ccparams.phich_resource,                         defstrval:"ONESIXTH",      TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_SRS_ENABLE,                                   NULL,   0,           strptr:&ccparams.srs_enable,                             defstrval:"DISABLE",       TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_SRS_BANDWIDTH_CONFIG,                         NULL,   0,           iptr:&ccparams.srs_BandwidthConfig,                      defintval:0,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_SRS_SUBFRAME_CONFIG,                          NULL,   0,           iptr:&ccparams.srs_SubframeConfig,                       defintval:0,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_SRS_ACKNACKST_CONFIG,                         NULL,   0,           strptr:&ccparams.srs_ackNackST,                          defstrval:"DISABLE",       TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_SRS_MAXUPPTS,                                 NULL,   0,           strptr:&ccparams.srs_MaxUpPts,                           defstrval:"DISABLE",       TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PUSCH_PO_NOMINAL,                             NULL,   0,           iptr:&ccparams.pusch_p0_Nominal,                         defintval:-90,             TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_PUSCH_ALPHA,                                  NULL,   0,           strptr:&ccparams.pusch_alpha,                            defstrval:"AL1",           TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PUCCH_PO_NOMINAL,                             NULL,   0,           iptr:&ccparams.pucch_p0_Nominal,                         defintval:-96,             TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_MSG3_DELTA_PREAMBLE,                          NULL,   0,           iptr:&ccparams.msg3_delta_Preamble,                      defintval:6,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT1,                         NULL,   0,           strptr:&ccparams.pucch_deltaF_Format1,                   defstrval:"DELTAF2",       TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT1b,                        NULL,   0,           strptr:&ccparams.pucch_deltaF_Format1b,                  defstrval:"deltaF3",       TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2,                         NULL,   0,           strptr:&ccparams.pucch_deltaF_Format2,                   defstrval:"deltaF0",       TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2A,                        NULL,   0,           strptr:&ccparams.pucch_deltaF_Format2a,                  defstrval:"deltaF0",       TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2B,                        NULL,   0,           strptr:&ccparams.pucch_deltaF_Format2b,                  defstrval:"deltaF0",       TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_RACH_NUM_RA_PREAMBLES,                        NULL,   0,           iptr:&ccparams.rach_numberOfRA_Preambles,                defintval:4,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_RACH_PREAMBLESGROUPACONFIG,                   NULL,   0,           strptr:&ccparams.rach_preamblesGroupAConfig,             defstrval:"DISABLE",       TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_RACH_SIZEOFRA_PREAMBLESGROUPA,                NULL,   0,           iptr:&ccparams.rach_sizeOfRA_PreamblesGroupA,            defintval:0,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_RACH_MESSAGESIZEGROUPA,                       NULL,   0,           iptr:&ccparams.rach_messageSizeGroupA,                   defintval:56,              TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_RACH_MESSAGEPOWEROFFSETGROUPB,                NULL,   0,           strptr:&ccparams.rach_messagePowerOffsetGroupB,          defstrval:"minusinfinity", TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_RACH_POWERRAMPINGSTEP,                        NULL,   0,           iptr:&ccparams.rach_powerRampingStep,                    defintval:4,               TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_RACH_PREAMBLEINITIALRECEIVEDTARGETPOWER,      NULL,   0,           iptr:&ccparams.rach_preambleInitialReceivedTargetPower,  defintval:-100,            TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_RACH_PREAMBLETRANSMAX,                        NULL,   0,           iptr:&ccparams.rach_preambleTransMax,                    defintval:10,              TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_RACH_RARESPONSEWINDOWSIZE,                    NULL,   0,           iptr:&ccparams.rach_raResponseWindowSize,                defintval:10,              TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_RACH_MACCONTENTIONRESOLUTIONTIMER,            NULL,   0,           iptr:&ccparams.rach_macContentionResolutionTimer,        defintval:48,              TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_RACH_MAXHARQMSG3TX,                           NULL,   0,           iptr:&ccparams.rach_maxHARQ_Msg3Tx,                      defintval:4,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PCCH_DEFAULT_PAGING_CYCLE,                    NULL,   0,           iptr:&ccparams.pcch_defaultPagingCycle,                  defintval:128,             TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_PCCH_NB,                                      NULL,   0,           strptr:&ccparams.pcch_nB,                                defstrval:"oneT",          TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_BCCH_MODIFICATIONPERIODCOEFF,                 NULL,   0,           iptr:&ccparams.bcch_modificationPeriodCoeff,             defintval:2,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_UETIMERS_T300,                                NULL,   0,           iptr:&ccparams.ue_TimersAndConstants_t300,               defintval:1000,            TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_UETIMERS_T301,                                NULL,   0,           iptr:&ccparams.ue_TimersAndConstants_t301,               defintval:1000,            TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_UETIMERS_T310,                                NULL,   0,           iptr:&ccparams.ue_TimersAndConstants_t310,               defintval:1000,            TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_UETIMERS_T311,                                NULL,   0,           iptr:&ccparams.ue_TimersAndConstants_t311,               defintval:10000,           TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_UETIMERS_N310,                                NULL,   0,           iptr:&ccparams.ue_TimersAndConstants_n310,               defintval:20,              TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_UETIMERS_N311,                                NULL,   0,           iptr:&ccparams.ue_TimersAndConstants_n311,               defintval:1,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_UE_TRANSMISSION_MODE,                         NULL,   0,           iptr:&ccparams.ue_TransmissionMode,                      defintval:1,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_UE_MULTIPLE_MAX,                              NULL,   0,           iptr:&ccparams.ue_multiple_max,                          defintval:4,               TYPE_UINT,       0}  \
 }
 
+
+
 #define ENB_CONFIG_FRAME_TYPE_IDX                            0  			     
 #define ENB_CONFIG_TDD_CONFIG_IDX                            1  			     
 #define ENB_CONFIG_TDD_CONFIG_S_IDX			     2
@@ -691,7 +762,6 @@ typedef enum {
 #define ENB_CONFIG_UETIMERS_N311_IDX			     66
 #define ENB_CONFIG_UE_TRANSMISSION_MODE_IDX		     67
 
-/*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
 /*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
 /* SRB1 configuration parameters section name */
 #define ENB_CONFIG_STRING_SRB1                                          "srb1_parameters"
@@ -708,21 +778,27 @@ typedef enum {
 /*                                            SRB1 configuration parameters                                                                                  */
 /*   optname                                          helpstr   paramflags    XXXptr                             defXXXval         type           numelt     */
 /*-----------------------------------------------------------------------------------------------------------------------------------------------------------*/
-#define SRB1PARAMS_DESC {                                                                                                \
-{ENB_CONFIG_STRING_SRB1_TIMER_POLL_RETRANSMIT,         NULL,   0,            iptr:&srb1_timer_poll_retransmit,   defintval:80,     TYPE_UINT,      0},       \
-{ENB_CONFIG_STRING_SRB1_TIMER_REORDERING,              NULL,   0,            iptr:&srb1_timer_reordering,        defintval:35,     TYPE_UINT,      0},       \
-{ENB_CONFIG_STRING_SRB1_TIMER_STATUS_PROHIBIT,         NULL,   0,            iptr:&srb1_timer_status_prohibit,   defintval:0,      TYPE_UINT,      0},       \
-{ENB_CONFIG_STRING_SRB1_POLL_PDU,                      NULL,   0,            iptr:&srb1_poll_pdu,                defintval:4,      TYPE_UINT,      0},       \
-{ENB_CONFIG_STRING_SRB1_POLL_BYTE,                     NULL,   0,            iptr:&srb1_poll_byte,               defintval:99999,  TYPE_UINT,      0},       \
-{ENB_CONFIG_STRING_SRB1_MAX_RETX_THRESHOLD,            NULL,   0,            iptr:&srb1_max_retx_threshold,      defintval:4,      TYPE_UINT,      0}        \
+typedef struct srb1_params_s {
+  int32_t     srb1_timer_poll_retransmit;
+  int32_t     srb1_timer_reordering;
+  int32_t     srb1_timer_status_prohibit;
+  int32_t     srb1_poll_pdu;
+  int32_t     srb1_poll_byte;
+  int32_t     srb1_max_retx_threshold;
+} srb1_params_t;
+
+#define SRB1PARAMS_DESC(srb1_params) {					\
+{ENB_CONFIG_STRING_SRB1_TIMER_POLL_RETRANSMIT,         NULL,   0,            iptr:&srb1_params.srb1_timer_poll_retransmit,   defintval:80,     TYPE_UINT,      0},       \
+{ENB_CONFIG_STRING_SRB1_TIMER_REORDERING,              NULL,   0,            iptr:&srb1_params.srb1_timer_reordering,        defintval:35,     TYPE_UINT,      0},       \
+{ENB_CONFIG_STRING_SRB1_TIMER_STATUS_PROHIBIT,         NULL,   0,            iptr:&srb1_params.srb1_timer_status_prohibit,   defintval:0,      TYPE_UINT,      0},       \
+{ENB_CONFIG_STRING_SRB1_POLL_PDU,                      NULL,   0,            iptr:&srb1_params.srb1_poll_pdu,                defintval:4,      TYPE_UINT,      0},       \
+{ENB_CONFIG_STRING_SRB1_POLL_BYTE,                     NULL,   0,            iptr:&srb1_params.srb1_poll_byte,               defintval:99999,  TYPE_UINT,      0},       \
+{ENB_CONFIG_STRING_SRB1_MAX_RETX_THRESHOLD,            NULL,   0,            iptr:&srb1_params.srb1_max_retx_threshold,      defintval:4,      TYPE_UINT,      0}        \
 }
-/*-----------------------------------------------------------------------------------------------------------------------------------------------------------*/
 
 /* MME configuration parameters section name */
 #define ENB_CONFIG_STRING_MME_IP_ADDRESS                "mme_ip_address"
 
-/* SRB1 configuration parameters names   */
-
 
 #define ENB_CONFIG_STRING_MME_IPV4_ADDRESS              "ipv4"
 #define ENB_CONFIG_STRING_MME_IPV6_ADDRESS              "ipv6"
@@ -954,3 +1030,7 @@ typedef enum {
 #define CONFIG_HLP_WORKER                          "coding and FEP worker thread WORKER_DISABLE or WORKER_ENABLE\n"
 #define CONFIG_HLP_PARALLEL                        "PARALLEL_SINGLE_THREAD, PARALLEL_RU_L1_SPLIT, or PARALLEL_RU_L1_TRX_SPLIT(RU_L1_TRX_SPLIT by defult)\n"
 /*-------------------------------------------------------------------------------------------------------------------------------------------------------------*/
+
+#include "enb_paramdef_emtc.h"
+#include "enb_paramdef_sidelink.h"
+#endif
diff --git a/openair2/ENB_APP/enb_paramdef_emtc.h b/openair2/ENB_APP/enb_paramdef_emtc.h
new file mode 100644
index 0000000000000000000000000000000000000000..ba8483ef9f0fd6bb1d100098dd17bd356f802021
--- /dev/null
+++ b/openair2/ENB_APP/enb_paramdef_emtc.h
@@ -0,0 +1,398 @@
+/*
+ * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The OpenAirInterface Software Alliance licenses this file to You under
+ * the OAI Public License, Version 1.1  (the "License"); you may not use this file
+ * except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.openairinterface.org/?page_id=698
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *-------------------------------------------------------------------------------
+ * For more information about the OpenAirInterface (OAI) Software Alliance:
+ *      contact@openairinterface.org
+ */
+
+/*! \file openair2/ENB_APP/enb_paramdef_emtc.h
+ * \brief definition of configuration parameters for emtc eNodeB modules 
+ * \author Raymond KNOPP
+ * \date 2018
+ * \version 0.1
+ * \company EURECOM France
+ * \email: raymond.knopp@eurecom.fr
+ * \note
+ * \warning
+ */
+
+#include "common/config/config_paramdesc.h"
+#include "RRC_paramsvalues.h"
+
+#define ENB_CONFIG_STRING_EMTC_PARAMETERS                                  "emtc_parameters"
+#define ENB_CONFIG_STRING_SCHEDULING_INFO_BR                               "scheduling_info_br"
+#define ENB_CONFIG_STRING_RSRP_RANGE_LIST                                  "rsrp_range_list"
+#define ENB_CONFIG_STRING_PRACH_CONFIG_COMMON_V1310                        "prach_ConfigCommon_v1310"
+#define ENB_CONFIG_STRING_MPDCCH_START_SF_CSS_RA_R13                       "mpdcch_startSF_CSS_RA_r13"
+#define ENB_CONFIG_STRING_MPDCCH_START_SF_CSS_RA_R13_VAL                   "mpdcch_startSF_CSS_RA_r13_val"
+#define ENB_CONFIG_STRING_PRACH_HOPPING_OFFSET_R13                         "prach_HoppingOffset_r13"
+#define ENB_CONFIG_STRING_SCHEDULING_INFO_SIB1_BR_R13                      "schedulingInfoSIB1_BR_r13"
+#define ENB_CONFIG_STRING_CELL_SELECTION_INFO_CE_R13                       "cellSelectionInfoCE_r13"
+#define ENB_CONFIG_STRING_Q_RX_LEV_MIN_CE_R13                              "q_RxLevMinCE_r13"
+#define ENB_CONFIG_STRING_BANDWIDTH_REDUCED_ACCESS_RELATED_INFO_R13        "bandwidthReducedAccessRelatedInfo_r13"
+#define ENB_CONFIG_STRING_SI_WINDOW_LENGTH_BR_R13                          "si_WindowLength_BR_r13"
+#define ENB_CONFIG_STRING_SI_REPETITION_PATTERN_R13                        "si_RepetitionPattern_r13"
+#define ENB_CONFIG_STRING_FDD_DOWNLINK_OR_TDD_SUBFRAME_BITMAP_BR_R13       "fdd_DownlinkOrTddSubframeBitmapBR_r13"
+#define ENB_CONFIG_STRING_FDD_DOWNLINK_OR_TDD_SUBFRAME_BITMAP_BR_VAL_R13   "fdd_DownlinkOrTddSubframeBitmapBR_val_r13"
+#define ENB_CONFIG_STRING_START_SYMBOL_BR_R13                              "startSymbolBR_r13"
+#define ENB_CONFIG_STRING_SI_HOPPING_CONFIG_COMMON_R13                     "si_HoppingConfigCommon_r13"
+#define ENB_CONFIG_STRING_SI_VALIDITY_TIME_R13                             "si_ValidityTime_r13"
+#define ENB_CONFIG_STRING_FREQ_HOPPING_PARAMETERS_DL_R13                   "freqHoppingParametersDL_r13"
+#define ENB_CONFIG_STRING_MPDCCH_PDSCH_HOPPING_NB_R13                      "mpdcch_pdsch_HoppingNB_r13"
+#define ENB_CONFIG_STRING_INTERVAL_DL_HOPPING_CONFIG_COMMON_MODE_A_R13     "interval_DLHoppingConfigCommonModeA_r13"
+#define ENB_CONFIG_STRING_INTERVAL_DL_HOPPING_CONFIG_COMMON_MODE_A_R13_VAL "interval_DLHoppingConfigCommonModeA_r13_val"
+#define ENB_CONFIG_STRING_INTERVAL_DL_HOPPING_CONFIG_COMMON_MODE_B_R13     "interval_DLHoppingConfigCommonModeB_r13"
+#define ENB_CONFIG_STRING_INTERVAL_DL_HOPPING_CONFIG_COMMON_MODE_B_R13_VAL "interval_DLHoppingConfigCommonModeB_r13_val"
+#define ENB_CONFIG_STRING_MPDCCH_PDSCH_HOPPING_OFFSET_R13                  "mpdcch_pdsch_HoppingOffset_r13"
+#define ENB_CONFIG_STRING_PREAMBLE_TRANSMAX_CE_R13                         "preamble_TransMax_ce_r13"
+#define ENB_CONFIG_STRING_PREAMBLE_TRANSMAX_CE_R13_VAL                     "preamble_TransMax_ce_r13_val"
+#define ENB_CONFIG_STRING_PDSCH_MAX_NUM_REPETITION_CE_MODE_A_R13           "pdsch_maxNumRepetitionCEmodeA_r13"
+#define ENB_CONFIG_STRING_PUSCH_MAX_NUM_REPETITION_CE_MODE_A_R13           "pusch_maxNumRepetitionCEmodeA_r13"
+#define ENB_CONFIG_STRING_SYSTEM_INFO_VALUE_TAG_LIST                       "system_info_value_tag_SI"
+#define ENB_CONFIG_STRING_FIRST_PREAMBLE_R13                               "firstPreamble_r13"
+#define ENB_CONFIG_STRING_LAST_PREAMBLE_R13                                "lastPreamble_r13"
+#define ENB_CONFIG_STRING_RA_RESPONSE_WINDOW_SIZE_R13                      "ra_ResponseWindowSize_r13"
+#define ENB_CONFIG_STRING_MAC_CONTENTION_RESOLUTION_TIMER_R13              "mac_ContentionResolutionTimer_r13"
+#define ENB_CONFIG_STRING_RAR_HOPPING_CONFIG_R13                           "rar_HoppingConfig_r13  "
+#define ENB_CONFIG_STRING_RACH_CE_LEVELINFOLIST_R13                        "rach_CE_LevelInfoList_r13"
+#define ENB_CONFIG_STRING_PRACH_CONFIG_INDEX_BR                            "prach_config_index_br"
+#define ENB_CONFIG_STRING_PRACH_FREQ_OFFSET_BR                             "prach_freq_offset_br"
+#define ENB_CONFIG_STRING_PRACH_STARTING_SUBFRAME_R13                      "prach_StartingSubframe_r13"
+#define ENB_CONFIG_STRING_MAX_NUM_PER_PREAMBLE_ATTEMPT_CE_R13              "maxNumPreambleAttemptCE_r13"
+#define ENB_CONFIG_STRING_NUM_REPETITION_PER_PREAMBLE_ATTEMPT_R13          "numRepetitionPerPreambleAttempt_r13"
+#define ENB_CONFIG_STRING_MPDCCH_NUM_REPETITION_RA_R13                     "mpdcch_NumRepetition_RA_r13"
+#define ENB_CONFIG_STRING_PRACH_HOPPING_CONFIG_R13                         "prach_HoppingConfig_r13"
+#define ENB_CONFIG_SRING_MAX_AVAILABLE_NARROW_BAND                         "max_available_narrow_band"
+#define ENB_CONFIG_STRING_PRACH_PARAMETERS_CE_R13                          "prach_parameters_ce_r13"							
+#define ENB_CONFIG_STRING_PUCCH_INFO_VALUE                                 "pucch_info_value"
+#define ENB_CONFIG_STRING_N1PUCCH_AN_INFOLIST_R13                          "n1PUCCH_AN_InfoList_r13"
+#define ENB_CONFIG_STRING_PCCH_CONFIG_V1310                                "pcch_config_v1310"
+#define ENB_CONFIG_STRING_SIB2_FREQ_HOPPINGPARAMETERS_R13                  "sib2_freq_hoppingParameters_r13" 
+
+typedef struct ccparams_eMTC_s {
+  /// indicator that eMTC is configured for this cell
+  int32_t        eMTC_configured;
+  /// the SIB2 parameters for eMTC SIB2
+  ccparams_lte_t ccparams;
+  int            si_Narrowband_r13;
+  int            si_TBS_r13;
+  int            systemInfoValueTagSi_r13;
+  int            firstPreamble_r13;
+  int            lastPreamble_r13;
+  int            ra_ResponseWindowSize_r13;
+  int            mac_ContentionResolutionTimer_r13;
+  int            rar_HoppingConfig_r13;
+  int            rsrp_range_br;
+  int            prach_config_index_br;
+  int            prach_freq_offset_br;
+  int            prach_StartingSubframe_r13;
+  int            maxNumPreambleAttemptCE_r13;
+  int            numRepetitionPerPreambleAttempt_r13;
+  int            mpdcch_NumRepetition_RA_r13;
+  int            prach_HoppingConfig_r13;
+  int           *maxavailablenarrowband;
+  int            pucch_info_value;
+  int            paging_narrowbands_r13;
+  int            mpdcch_numrepetition_paging_r13;
+  int            nb_v1310;
+  char          *pucch_NumRepetitionCE_Msg4_Level0_r13;
+  char          *pucch_NumRepetitionCE_Msg4_Level1_r13;
+  char          *pucch_NumRepetitionCE_Msg4_Level2_r13;
+  char          *pucch_NumRepetitionCE_Msg4_Level3_r13;
+  int            sib2_mpdcch_pdsch_hoppingNB_r13;
+  char          *sib2_interval_DLHoppingConfigCommonModeA_r13;
+  int            sib2_interval_DLHoppingConfigCommonModeA_r13_val;
+  char          *sib2_interval_DLHoppingConfigCommonModeB_r13;
+  int            sib2_interval_DLHoppingConfigCommonModeB_r13_val;
+  char          *sib2_interval_ULHoppingConfigCommonModeA_r13;
+  int            sib2_interval_ULHoppingConfigCommonModeA_r13_val;
+  char          *sib2_interval_ULHoppingConfigCommonModeB_r13;
+  int            sib2_interval_ULHoppingConfigCommonModeB_r13_val;
+  int            sib2_mpdcch_pdsch_hoppingOffset_r13;
+  int            pusch_HoppingOffset_v1310;
+  int            hyperSFN_r13;
+  int            eDRX_Allowed_r13;
+  int            q_RxLevMinCE_r13;
+  int            q_QualMinRSRQ_CE_r13;
+  char          *si_WindowLength_BR_r13;
+  char          *si_RepetitionPattern_r13;
+  int            startSymbolBR_r13;
+  char          *si_HoppingConfigCommon_r13;
+  char          *si_ValidityTime_r13;
+  char          *mpdcch_pdsch_HoppingNB_r13;
+  int            interval_DLHoppingConfigCommonModeA_r13_val;
+  int            interval_DLHoppingConfigCommonModeB_r13_val;
+  int            mpdcch_pdsch_HoppingOffset_r13;
+  char          *preambleTransMax_CE_r13;
+  int            prach_HoppingOffset_r13;
+  int            schedulingInfoSIB1_BR_r13;
+  int64_t        fdd_DownlinkOrTddSubframeBitmapBR_val_r13;
+  char          *cellSelectionInfoCE_r13;
+  char          *bandwidthReducedAccessRelatedInfo_r13;
+  char          *fdd_DownlinkOrTddSubframeBitmapBR_r13;
+  char          *fdd_UplinkSubframeBitmapBR_r13;
+  char          *freqHoppingParametersDL_r13;
+  char          *interval_DLHoppingConfigCommonModeA_r13;
+  char          *interval_DLHoppingConfigCommonModeB_r13;
+  char          *prach_ConfigCommon_v1310;
+  char          *mpdcch_startSF_CSS_RA_r13;
+  char          *mpdcch_startSF_CSS_RA_r13_val;
+  char          *pdsch_maxNumRepetitionCEmodeA_r13;
+  char          *pdsch_maxNumRepetitionCEmodeB_r13;
+  char          *pusch_maxNumRepetitionCEmodeA_r13;
+  char          *pusch_maxNumRepetitionCEmodeB_r13;
+} ccparams_eMTC_t;
+
+
+#define EMTCPARAMS_DESC(eMTCconfig) {					\
+  {"eMTC_configured",                                              NULL,   0,           iptr:&eMTCconfig->eMTC_configured,                             defintval:0,                       TYPE_UINT,         0}, \
+{ENB_CONFIG_STRING_PRACH_ROOT,                                           NULL,   0,           iptr:&eMTCconfig->ccparams.prach_root,                                  defintval:0,                       TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PRACH_CONFIG_INDEX,                                   NULL,   0,           iptr:&eMTCconfig->ccparams.prach_config_index,                          defintval:0,                       TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_PRACH_HIGH_SPEED,                                     NULL,   0,           strptr:&eMTCconfig->ccparams.prach_high_speed,                          defstrval:"DISABLE",               TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PRACH_ZERO_CORRELATION,                               NULL,   0,           iptr:&eMTCconfig->ccparams.prach_zero_correlation,                      defintval:1,                       TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PRACH_FREQ_OFFSET,                                    NULL,   0,           iptr:&eMTCconfig->ccparams.prach_freq_offset,                           defintval:2,                       TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PUCCH_DELTA_SHIFT,                                    NULL,   0,           iptr:&eMTCconfig->ccparams.pucch_delta_shift,                           defintval:1,                       TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PUCCH_NRB_CQI,                                        NULL,   0,           iptr:&eMTCconfig->ccparams.pucch_nRB_CQI,                               defintval:1,                       TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PUCCH_NCS_AN,                                         NULL,   0,           iptr:&eMTCconfig->ccparams.pucch_nCS_AN,                                defintval:0,                       TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PUCCH_N1_AN,                                          NULL,   0,           iptr:&eMTCconfig->ccparams.pucch_n1_AN,                                 defintval:32,                      TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PDSCH_RS_EPRE,                                        NULL,   0,           iptr:&eMTCconfig->ccparams.pdsch_referenceSignalPower,                  defintval:-29,                     TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_PDSCH_PB,                                             NULL,   0,           iptr:&eMTCconfig->ccparams.pdsch_p_b,                                   defintval:0,                       TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_PUSCH_N_SB,                                           NULL,   0,           iptr:&eMTCconfig->ccparams.pusch_n_SB,                                  defintval:1,                       TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_PUSCH_HOPPINGMODE,                                    NULL,   0,           strptr:&eMTCconfig->ccparams.pusch_hoppingMode,                         defstrval:"interSubFrame",         TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PUSCH_HOPPINGOFFSET,                                  NULL,   0,           iptr:&eMTCconfig->ccparams.pusch_hoppingOffset,                         defintval:0,                       TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PUSCH_ENABLE64QAM,                                    NULL,   0,           strptr:&eMTCconfig->ccparams.pusch_enable64QAM,                         defstrval:"DISABLE",               TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PUSCH_GROUP_HOPPING_EN,                               NULL,   0,           strptr:&eMTCconfig->ccparams.pusch_groupHoppingEnabled,                 defstrval:"ENABLE",                TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PUSCH_GROUP_ASSIGNMENT,                               NULL,   0,           iptr:&eMTCconfig->ccparams.pusch_groupAssignment,                       defintval:0,                       TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_PUSCH_SEQUENCE_HOPPING_EN,                            NULL,   0,           strptr:&eMTCconfig->ccparams.pusch_sequenceHoppingEnabled,              defstrval:"DISABLE",               TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PUSCH_NDMRS1,                                         NULL,   0,           iptr:&eMTCconfig->ccparams.pusch_nDMRS1,                                defintval:0,                       TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PHICH_DURATION,                                       NULL,   0,           strptr:&eMTCconfig->ccparams.phich_duration,                            defstrval:"NORMAL",                TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PHICH_RESOURCE,                                       NULL,   0,           strptr:&eMTCconfig->ccparams.phich_resource,                            defstrval:"ONESIXTH",              TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_SRS_ENABLE,                                           NULL,   0,           strptr:&eMTCconfig->ccparams.srs_enable,                                defstrval:"DISABLE",               TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_SRS_BANDWIDTH_CONFIG,                                 NULL,   0,           iptr:&eMTCconfig->ccparams.srs_BandwidthConfig,                         defintval:0,                       TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_SRS_SUBFRAME_CONFIG,                                  NULL,   0,           iptr:&eMTCconfig->ccparams.srs_SubframeConfig,                          defintval:0,                       TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_SRS_ACKNACKST_CONFIG,                                 NULL,   0,           strptr:&eMTCconfig->ccparams.srs_ackNackST,                             defstrval:"DISABLE",               TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_SRS_MAXUPPTS,                                         NULL,   0,           strptr:&eMTCconfig->ccparams.srs_MaxUpPts,                              defstrval:"DISABLE",               TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PUSCH_PO_NOMINAL,                                     NULL,   0,           iptr:&eMTCconfig->ccparams.pusch_p0_Nominal,                            defintval:-90,                     TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_PUSCH_ALPHA,                                          NULL,   0,           strptr:&eMTCconfig->ccparams.pusch_alpha,                               defstrval:"AL1",                   TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PUCCH_PO_NOMINAL,                                     NULL,   0,           iptr:&eMTCconfig->ccparams.pucch_p0_Nominal,                            defintval:-96,                     TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_MSG3_DELTA_PREAMBLE,                                  NULL,   0,           iptr:&eMTCconfig->ccparams.msg3_delta_Preamble,                         defintval:6,                       TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT1,                                 NULL,   0,           strptr:&eMTCconfig->ccparams.pucch_deltaF_Format1,                      defstrval:"DELTAF2",               TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT1b,                                NULL,   0,           strptr:&eMTCconfig->ccparams.pucch_deltaF_Format1b,                     defstrval:"deltaF3",               TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2,                                 NULL,   0,           strptr:&eMTCconfig->ccparams.pucch_deltaF_Format2,                      defstrval:"deltaF0",               TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2A,                                NULL,   0,           strptr:&eMTCconfig->ccparams.pucch_deltaF_Format2a,                     defstrval:"deltaF0",               TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_PUCCH_DELTAF_FORMAT2B,                                NULL,   0,           strptr:&eMTCconfig->ccparams.pucch_deltaF_Format2b,                     defstrval:"deltaF0",               TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_RACH_NUM_RA_PREAMBLES,                                NULL,   0,           iptr:&eMTCconfig->ccparams.rach_numberOfRA_Preambles,                   defintval:4,                       TYPE_UINT,     0},  \
+{ENB_CONFIG_STRING_RACH_PREAMBLESGROUPACONFIG,                           NULL,   0,           strptr:&eMTCconfig->ccparams.rach_preamblesGroupAConfig,                defstrval:"DISABLE",               TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_RACH_SIZEOFRA_PREAMBLESGROUPA,                        NULL,   0,           iptr:&eMTCconfig->ccparams.rach_sizeOfRA_PreamblesGroupA,               defintval:0,                       TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_RACH_MESSAGESIZEGROUPA,                               NULL,   0,           iptr:&eMTCconfig->ccparams.rach_messageSizeGroupA,                      defintval:56,                      TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_RACH_MESSAGEPOWEROFFSETGROUPB,                        NULL,   0,           strptr:&eMTCconfig->ccparams.rach_messagePowerOffsetGroupB,             defstrval:"minusinfinity",         TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_RACH_POWERRAMPINGSTEP,                                NULL,   0,           iptr:&eMTCconfig->ccparams.rach_powerRampingStep,                       defintval:4,                       TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_RACH_PREAMBLEINITIALRECEIVEDTARGETPOWER,              NULL,   0,           iptr:&eMTCconfig->ccparams.rach_preambleInitialReceivedTargetPower,     defintval:-100,                    TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_RACH_PREAMBLETRANSMAX,                                NULL,   0,           iptr:&eMTCconfig->ccparams.rach_preambleTransMax,                       defintval:10,                      TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_RACH_RARESPONSEWINDOWSIZE,                            NULL,   0,           iptr:&eMTCconfig->ccparams.rach_raResponseWindowSize,                   defintval:10,                      TYPE_INT,        0},  \
+{ENB_CONFIG_STRING_RACH_MACCONTENTIONRESOLUTIONTIMER,                    NULL,   0,           iptr:&eMTCconfig->ccparams.rach_macContentionResolutionTimer,           defintval:48,                      TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_RACH_MAXHARQMSG3TX,                                   NULL,   0,           iptr:&eMTCconfig->ccparams.rach_maxHARQ_Msg3Tx,                         defintval:4,                       TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_PCCH_DEFAULT_PAGING_CYCLE,                            NULL,   0,           iptr:&eMTCconfig->ccparams.pcch_defaultPagingCycle,                     defintval:128,                 TYPE_INT,     0},  \
+{ENB_CONFIG_STRING_PCCH_NB,                                              NULL,   0,           strptr:&eMTCconfig->ccparams.pcch_nB,                                   defstrval:"oneT",                  TYPE_STRING,     0},  \
+{ENB_CONFIG_STRING_BCCH_MODIFICATIONPERIODCOEFF,                         NULL,   0,           iptr:&eMTCconfig->ccparams.bcch_modificationPeriodCoeff,                defintval:2,                       TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_RACH_PREAMBLESGROUPACONFIG,                           NULL,   0,           strptr:&eMTCconfig->ccparams.rach_preamblesGroupAConfig,                defstrval:"",                      TYPE_STRING,     0}, \
+{ENB_CONFIG_STRING_UETIMERS_T300,                                NULL,   0,           iptr:&eMTCconfig->ccparams.ue_TimersAndConstants_t300,               defintval:1000,            TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_UETIMERS_T301,                                NULL,   0,           iptr:&eMTCconfig->ccparams.ue_TimersAndConstants_t301,               defintval:1000,            TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_UETIMERS_T310,                                NULL,   0,           iptr:&eMTCconfig->ccparams.ue_TimersAndConstants_t310,               defintval:1000,            TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_UETIMERS_T311,                                NULL,   0,           iptr:&eMTCconfig->ccparams.ue_TimersAndConstants_t311,               defintval:10000,           TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_UETIMERS_N310,                                NULL,   0,           iptr:&eMTCconfig->ccparams.ue_TimersAndConstants_n310,               defintval:20,              TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_UETIMERS_N311,                                NULL,   0,           iptr:&eMTCconfig->ccparams.ue_TimersAndConstants_n311,               defintval:1,               TYPE_UINT,       0},  \
+{ENB_CONFIG_STRING_UE_TRANSMISSION_MODE,                         NULL,   0,           iptr:&eMTCconfig->ccparams.ue_TransmissionMode,                      defintval:1,               TYPE_UINT,       0},  \
+  {ENB_CONFIG_STRING_SCHEDULING_INFO_SIB1_BR_R13,                  NULL,   0,           iptr:&eMTCconfig->schedulingInfoSIB1_BR_r13,                   defintval:4,                       TYPE_UINT,         0}, \
+  {ENB_CONFIG_STRING_PRACH_CONFIG_COMMON_V1310,                    NULL,   0,           strptr:&eMTCconfig->prach_ConfigCommon_v1310,               defstrval:"ENABLE",        TYPE_STRING,     0}, \
+  {ENB_CONFIG_STRING_MPDCCH_START_SF_CSS_RA_R13,                   NULL,   0,           strptr:&eMTCconfig->mpdcch_startSF_CSS_RA_r13,              defstrval:"fdd-r13",       TYPE_STRING,     0}, \
+  {ENB_CONFIG_STRING_MPDCCH_START_SF_CSS_RA_R13_VAL,               NULL,   0,           strptr:&eMTCconfig->mpdcch_startSF_CSS_RA_r13_val,          defstrval:"v1",            TYPE_STRING,     0}, \
+  {ENB_CONFIG_STRING_PRACH_HOPPING_OFFSET_R13,                     NULL,   0,           iptr:&eMTCconfig->prach_HoppingOffset_r13,                  defintval:0,               TYPE_INT,        0}, \
+  {ENB_CONFIG_STRING_PDSCH_MAX_NUM_REPETITION_CE_MODE_A_R13,       NULL,   0,           strptr:&eMTCconfig->pdsch_maxNumRepetitionCEmodeA_r13,      defstrval:"r16",           TYPE_STRING,     0}, \
+  {ENB_CONFIG_STRING_PUSCH_MAX_NUM_REPETITION_CE_MODE_A_R13,       NULL,   0,           strptr:&eMTCconfig->pusch_maxNumRepetitionCEmodeA_r13,      defstrval:"r8",            TYPE_STRING,     0},	\
+{ENB_CONFIG_STRING_CELL_SELECTION_INFO_CE_R13,                           NULL,   0,           strptr:&eMTCconfig->cellSelectionInfoCE_r13,                   defstrval:"ENABLE",                TYPE_STRING,       0}, \
+{ENB_CONFIG_STRING_Q_RX_LEV_MIN_CE_R13,                                  NULL,   0,           iptr:&eMTCconfig->q_RxLevMinCE_r13,                            defintval:-70,                     TYPE_INT,          0}, \
+{ENB_CONFIG_STRING_BANDWIDTH_REDUCED_ACCESS_RELATED_INFO_R13,            NULL,   0,           strptr:&eMTCconfig->bandwidthReducedAccessRelatedInfo_r13,     defstrval:"ENABLE",                TYPE_STRING,       0}, \
+{ENB_CONFIG_STRING_SI_WINDOW_LENGTH_BR_R13,                              NULL,   0,           strptr:&eMTCconfig->si_WindowLength_BR_r13,                    defstrval:"ms20",                  TYPE_STRING,       0}, \
+{ENB_CONFIG_STRING_SI_REPETITION_PATTERN_R13,                            NULL,   0,           strptr:&eMTCconfig->si_RepetitionPattern_r13,                  defstrval:"everyRF",               TYPE_STRING,       0},			\
+{ENB_CONFIG_STRING_FDD_DOWNLINK_OR_TDD_SUBFRAME_BITMAP_BR_R13,           NULL,   0,           strptr:&eMTCconfig->fdd_DownlinkOrTddSubframeBitmapBR_r13,     defstrval:"subframePattern40-r13", TYPE_STRING,       0}, \
+{ENB_CONFIG_STRING_FDD_DOWNLINK_OR_TDD_SUBFRAME_BITMAP_BR_VAL_R13,       NULL,   0,           i64ptr:&eMTCconfig->fdd_DownlinkOrTddSubframeBitmapBR_val_r13, defint64val:0xFFFFFFFFFF,          TYPE_UINT64,       0}, \
+{ENB_CONFIG_STRING_START_SYMBOL_BR_R13,                                  NULL,   0,           iptr:&eMTCconfig->startSymbolBR_r13,                           defintval:3,                       TYPE_UINT,         0}, \
+{ENB_CONFIG_STRING_SI_HOPPING_CONFIG_COMMON_R13,                         NULL,   0,           strptr:&eMTCconfig->si_HoppingConfigCommon_r13 ,               defstrval:"off",                   TYPE_STRING,       0}, \
+{ENB_CONFIG_STRING_SI_VALIDITY_TIME_R13,                                 NULL,   0,           strptr:&eMTCconfig->si_ValidityTime_r13,                       defstrval:"true",                  TYPE_STRING,       0}, \
+{ENB_CONFIG_STRING_FREQ_HOPPING_PARAMETERS_DL_R13,                       NULL,   0,           strptr:&eMTCconfig->freqHoppingParametersDL_r13,               defstrval:"DISABLE",               TYPE_STRING,       0}, \
+{ENB_CONFIG_STRING_MPDCCH_PDSCH_HOPPING_NB_R13,                          NULL,   0,           strptr:&eMTCconfig->mpdcch_pdsch_HoppingNB_r13,                defstrval:"nb2",                   TYPE_STRING,       0}, \
+{ENB_CONFIG_STRING_INTERVAL_DL_HOPPING_CONFIG_COMMON_MODE_A_R13,         NULL,   0,           strptr:&eMTCconfig->interval_DLHoppingConfigCommonModeA_r13,   defstrval:"interval-FDD-r13",      TYPE_STRING,       0}, \
+{ENB_CONFIG_STRING_INTERVAL_DL_HOPPING_CONFIG_COMMON_MODE_A_R13_VAL,     NULL,   0,           iptr:&eMTCconfig->interval_DLHoppingConfigCommonModeA_r13_val, defintval:0,                       TYPE_UINT,         0}, \
+{ENB_CONFIG_STRING_INTERVAL_DL_HOPPING_CONFIG_COMMON_MODE_B_R13,         NULL,   0,           strptr:&eMTCconfig->interval_DLHoppingConfigCommonModeB_r13,   defstrval:"interval-FDD-r13",      TYPE_STRING,       0}, \
+{ENB_CONFIG_STRING_INTERVAL_DL_HOPPING_CONFIG_COMMON_MODE_B_R13_VAL,     NULL,   0,           iptr:&eMTCconfig->interval_DLHoppingConfigCommonModeB_r13_val, defintval:0,                       TYPE_UINT,         0}, \
+{ENB_CONFIG_STRING_MPDCCH_PDSCH_HOPPING_OFFSET_R13,                      NULL,   0,           iptr:&eMTCconfig->mpdcch_pdsch_HoppingOffset_r13,              defintval:1,                       TYPE_UINT,         0}, \
+{ENB_CONFIG_STRING_PREAMBLE_TRANSMAX_CE_R13,                             NULL,   0,           strptr:&eMTCconfig->preambleTransMax_CE_r13,                   defstrval:"n10",                   TYPE_STRING,       0},  \
+{ENB_CONFIG_STRING_PUCCH_NUM_REPETITION_CE_MSG4_LEVEL0,                  NULL,   0,           strptr:&eMTCconfig->pucch_NumRepetitionCE_Msg4_Level0_r13,     defstrval:"n1",                    TYPE_STRING,     0}, \
+{ENB_CONFIG_STRING_PUCCH_NUM_REPETITION_CE_MSG4_LEVEL1,                  NULL,   0,           strptr:&eMTCconfig->pucch_NumRepetitionCE_Msg4_Level1_r13,     defstrval:"",                      TYPE_STRING,     0}, \
+{ENB_CONFIG_STRING_PUCCH_NUM_REPETITION_CE_MSG4_LEVEL2,                  NULL,   0,           strptr:&eMTCconfig->pucch_NumRepetitionCE_Msg4_Level2_r13,     defstrval:"",                      TYPE_STRING,     0}, \
+  {ENB_CONFIG_STRING_PUCCH_NUM_REPETITION_CE_MSG4_LEVEL3,                  NULL,   0,           strptr:&eMTCconfig->pucch_NumRepetitionCE_Msg4_Level3_r13,     defstrval:"",                      TYPE_STRING,     0} \
+ }
+
+#define EMTCPARAMS_CHECK                 {                                     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+             { .s1a= { config_check_modify_integer, UETIMER_T300_OKVALUES, UETIMER_T300_MODVALUES,8}} ,						     \
+             { .s1a= { config_check_modify_integer, UETIMER_T301_OKVALUES, UETIMER_T301_MODVALUES,8}} ,						     \
+             { .s1a= { config_check_modify_integer, UETIMER_T310_OKVALUES, UETIMER_T310_MODVALUES,7}} ,						     \
+             { .s1a= { config_check_modify_integer, UETIMER_T311_OKVALUES, UETIMER_T311_MODVALUES,7}} ,						     \
+             { .s1a= { config_check_modify_integer, UETIMER_N310_OKVALUES, UETIMER_N310_MODVALUES,8}} , 					      \
+             { .s1a= { config_check_modify_integer, UETIMER_N311_OKVALUES, UETIMER_N311_MODVALUES,8}} , 					      \
+             { .s5= {NULL }} ,						     \
+             { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+                          { .s5= {NULL }} ,						     \
+}
+
+#define SYSTEM_INFO_VALUE_TAG_SI_DESC(eMTCconfig) {			\
+{"systemInfoValueTagSi_r13", NULL,   0,           iptr:&eMTCconfig->systemInfoValueTagSi_r13,                              defintval:0,              TYPE_UINT,       0} \
+  }
+
+
+#define SI_INFO_BR_DESC(eMTCconfig) {					\
+{"si_Narrowband_r13", NULL,   0,           iptr:&eMTCconfig->si_Narrowband_r13,             defintval:5,             TYPE_UINT,       0}, \
+{"si_TBS_r13",        NULL,   0,           iptr:&eMTCconfig->si_TBS_r13,                    defintval:5,             TYPE_UINT,       0} \
+}
+
+#define RSRP_RANGE_LIST_DESC(eMTCconfig) {				\
+{"rsrp_range_br", NULL,   0,           iptr:&eMTCconfig->rsrp_range_br,                     defintval:0,     TYPE_UINT,       0} \
+  }
+
+
+#define RACH_CE_LEVELINFOLIST_R13_DESC(eMTCconfig) {			\
+{ENB_CONFIG_STRING_FIRST_PREAMBLE_R13,                     NULL,   0,           iptr:&eMTCconfig->firstPreamble_r13,                 defintval:60,            TYPE_UINT,       0}, \
+{ENB_CONFIG_STRING_LAST_PREAMBLE_R13,                      NULL,   0,           iptr:&eMTCconfig->lastPreamble_r13,                  defintval:63,            TYPE_UINT,       0}, \
+{ENB_CONFIG_STRING_RA_RESPONSE_WINDOW_SIZE_R13,            NULL,   0,           iptr:&eMTCconfig->ra_ResponseWindowSize_r13,         defintval:20,        TYPE_UINT,     0}, \
+{ENB_CONFIG_STRING_MAC_CONTENTION_RESOLUTION_TIMER_R13,    NULL,   0,           iptr:&eMTCconfig->mac_ContentionResolutionTimer_r13, defintval:80,        TYPE_UINT,     0}, \
+{ENB_CONFIG_STRING_RAR_HOPPING_CONFIG_R13,                 NULL,   0,           iptr:&eMTCconfig->rar_HoppingConfig_r13,             defintval:0,         TYPE_UINT,     0}\
+}
+
+#define PRACH_PARAMS_CE_R13_DESC(eMTCconfig) {				\
+{ENB_CONFIG_STRING_PRACH_CONFIG_INDEX_BR,                   NULL,   0,           iptr:&eMTCconfig->prach_config_index_br,                 defintval:3,             TYPE_UINT,       0}, \
+{ENB_CONFIG_STRING_PRACH_FREQ_OFFSET_BR,                    NULL,   0,           iptr:&eMTCconfig->prach_freq_offset_br,                  defintval:1,             TYPE_UINT,       0}, \
+{ENB_CONFIG_STRING_PRACH_STARTING_SUBFRAME_R13,             NULL,   0,           iptr:&eMTCconfig->prach_StartingSubframe_r13,            defintval:0,             TYPE_UINT,       0}, \
+{ENB_CONFIG_STRING_MAX_NUM_PER_PREAMBLE_ATTEMPT_CE_R13,     NULL,   0,           iptr:&eMTCconfig->maxNumPreambleAttemptCE_r13,         defintval:10,         TYPE_UINT,     0}, \
+{ENB_CONFIG_STRING_NUM_REPETITION_PER_PREAMBLE_ATTEMPT_R13, NULL,   0,           iptr:&eMTCconfig->numRepetitionPerPreambleAttempt_r13, defintval:1,          TYPE_UINT,     0}, \
+{ENB_CONFIG_STRING_MPDCCH_NUM_REPETITION_RA_R13,            NULL,   0,           iptr:&eMTCconfig->mpdcch_NumRepetition_RA_r13,         defintval:1,          TYPE_UINT,     0}, \
+{ENB_CONFIG_STRING_PRACH_HOPPING_CONFIG_R13,                NULL,   0,           iptr:&eMTCconfig->prach_HoppingConfig_r13,             defintval:0,         TYPE_UINT,     0}, \
+{ENB_CONFIG_SRING_MAX_AVAILABLE_NARROW_BAND,                NULL,   0,           uptr:NULL,                                  defintarrayval:NULL,     TYPE_INTARRAY,   0} \
+}
+
+#define N1PUCCH_AN_INFOLIST_R13_DESC(eMTCconfig) {			\
+{ENB_CONFIG_STRING_PUCCH_INFO_VALUE,                     NULL,   0,           iptr:&eMTCconfig->pucch_info_value,                    defintval:0,             TYPE_UINT,       0} \
+}
+
+
+#define PCCH_CONFIG_V1310_DESC(eMTCconfig) {				\
+{ENB_CONFIG_STRING_PAGING_NARROWBANDS_R13,          NULL,   0,           iptr:&eMTCconfig->paging_narrowbands_r13,                   defintval:1,             TYPE_UINT,       0}, \
+{ENB_CONFIG_STRING_MPDCCH_NUMREPETITION_PAGING_R13, NULL,   0,           iptr:&eMTCconfig->mpdcch_numrepetition_paging_r13,          defintval:1,          TYPE_UINT,     0}, \
+{ENB_CONFIG_STRING_NB_V1310,                        NULL,   0,           iptr:&eMTCconfig->nb_v1310,                                 defintval:256,   TYPE_UINT,     0} \
+}
+
+
+#define SIB2_FREQ_HOPPING_R13_DESC(eMTCconfig) {			\
+{ENB_CONFIG_STRING_MPDCCH_PDSCH_HOPPING_NB_R13,                      NULL,   0,           iptr:&eMTCconfig->sib2_mpdcch_pdsch_hoppingNB_r13,                  defintval:0,            TYPE_UINT,       0}, \
+{"sib2_interval_DLHoppingConfigCommonModeA_r13",                     NULL,   0,           strptr:&eMTCconfig->sib2_interval_DLHoppingConfigCommonModeA_r13,       defstrval:"FDD",            TYPE_STRING,       0}, \
+{"sib2_interval_DLHoppingConfigCommonModeA_r13_val",                 NULL,   0,           iptr:&eMTCconfig->sib2_interval_DLHoppingConfigCommonModeA_r13_val,   defintval:0,            TYPE_UINT,       0}, \
+{"sib2_interval_DLHoppingConfigCommonModeB_r13",                     NULL,   0,           strptr:&eMTCconfig->sib2_interval_DLHoppingConfigCommonModeB_r13,       defstrval:"FDD",            TYPE_STRING,       0}, \
+{"sib2_interval_DLHoppingConfigCommonModeB_r13_val",                 NULL,   0,           iptr:&eMTCconfig->sib2_interval_DLHoppingConfigCommonModeB_r13_val,   defintval:0,            TYPE_UINT,       0}, \
+{"sib2_interval_ULHoppingConfigCommonModeA_r13",     NULL,   0,           strptr:&eMTCconfig->sib2_interval_ULHoppingConfigCommonModeA_r13,     defstrval:"FDD",         TYPE_STRING,       0}, \
+{"sib2_interval_ULHoppingConfigCommonModeA_r13_val", NULL,   0,           iptr:&eMTCconfig->sib2_interval_ULHoppingConfigCommonModeA_r13_val, defintval:4,        TYPE_UINT,       0}, \
+{"sib2_interval_ULHoppingConfigCommonModeB_r13",                     NULL,   0,           strptr:&eMTCconfig->sib2_interval_ULHoppingConfigCommonModeB_r13,       defstrval:"FDD",            TYPE_STRING,       0}, \
+{"sib2_interval_ULHoppingConfigCommonModeB_r13_val",                 NULL,   0,           iptr:&eMTCconfig->sib2_interval_ULHoppingConfigCommonModeB_r13_val,   defintval:0,            TYPE_UINT,       0}, \
+{"sib2_mpdcch_pdsch_hoppingOffset_r13",                              NULL,   0,           iptr:&eMTCconfig->sib2_mpdcch_pdsch_hoppingOffset_r13,                defintval:1,             TYPE_UINT,         0} \
+}
diff --git a/openair2/ENB_APP/enb_paramdef_sidelink.h b/openair2/ENB_APP/enb_paramdef_sidelink.h
new file mode 100644
index 0000000000000000000000000000000000000000..3e73ba43b738dcfbc8771e8faa8db176fae51aa7
--- /dev/null
+++ b/openair2/ENB_APP/enb_paramdef_sidelink.h
@@ -0,0 +1,183 @@
+/*
+ * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The OpenAirInterface Software Alliance licenses this file to You under
+ * the OAI Public License, Version 1.1  (the "License"); you may not use this file
+ * except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.openairinterface.org/?page_id=698
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *-------------------------------------------------------------------------------
+ * For more information about the OpenAirInterface (OAI) Software Alliance:
+ *      contact@openairinterface.org
+ */
+
+/*! \file openair2/ENB_APP/enb_paramdef_sidelink.h
+ * \brief definition of configuration parameters for sidelink eNodeB modules 
+ * \author Raymond KNOPP
+ * \date 2018
+ * \version 0.1
+ * \company EURECOM France
+ * \email: raymond.knopp@eurecom.fr
+ * \note
+ * \warning
+ */
+
+#ifndef ENB_PARAMDEF_SIDELINK_H_
+#define ENB_PARAMDEF_SIDELINK_H_
+#include "common/config/config_paramdesc.h"
+#include "RRC_paramsvalues.h"
+#include <libconfig.h>
+
+#define ENB_CONFIG_STRING_SL_PARAMETERS                                 "SLparameters"
+//SIB18
+#define ENB_CONFIG_STRING_RXPOOL_SC_CP_LEN                              "rxPool_sc_CP_Len"
+#define ENB_CONFIG_STRING_RXPOOL_SC_PRIOD                               "rxPool_sc_Period"
+#define ENB_CONFIG_STRING_RXPOOL_DATA_CP_LEN                            "rxPool_data_CP_Len"
+#define ENB_CONFIG_STRING_RXPOOL_RC_PRB_NUM                             "rxPool_ResourceConfig_prb_Num"
+#define ENB_CONFIG_STRING_RXPOOL_RC_PRB_START                           "rxPool_ResourceConfig_prb_Start"
+#define ENB_CONFIG_STRING_RXPOOL_RC_PRB_END                             "rxPool_ResourceConfig_prb_End"
+#define ENB_CONFIG_STRING_RXPOOL_RC_OFFSETIND_PRESENT                   "rxPool_ResourceConfig_offsetIndicator_present"
+#define ENB_CONFIG_STRING_RXPOOL_RC_OFFSETIND_CHOICE                    "rxPool_ResourceConfig_offsetIndicator_choice"
+#define ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_PRESENT                    "rxPool_ResourceConfig_subframeBitmap_present"
+#define ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_CHOICE_BS_BUF              "rxPool_ResourceConfig_subframeBitmap_choice_bs_buf"
+#define ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_CHOICE_BS_SIZE             "rxPool_ResourceConfig_subframeBitmap_choice_bs_size"
+#define ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_CHOICE_BS_ASN_BITS_UNUSED  "rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused"
+//SIB19 for DiscRxPool
+#define ENB_CONFIG_STRING_DISCRXPOOL_CP_LEN                                 "discRxPool_cp_Len"
+#define ENB_CONFIG_STRING_DISCRXPOOL_DISCPERIOD                             "discRxPool_discPeriod"
+#define ENB_CONFIG_STRING_DISCRXPOOL_NUMRETX                                "discRxPool_numRetx"
+#define ENB_CONFIG_STRING_DISCRXPOOL_NUMREPETITION                          "discRxPool_numRepetition"
+#define ENB_CONFIG_STRING_DISCRXPOOL_RC_PRB_NUM                             "discRxPool_ResourceConfig_prb_Num"
+#define ENB_CONFIG_STRING_DISCRXPOOL_RC_PRB_START                           "discRxPool_ResourceConfig_prb_Start"
+#define ENB_CONFIG_STRING_DISCRXPOOL_RC_PRB_END                             "discRxPool_ResourceConfig_prb_End"
+#define ENB_CONFIG_STRING_DISCRXPOOL_RC_OFFSETIND_PRESENT                   "discRxPool_ResourceConfig_offsetIndicator_present"
+#define ENB_CONFIG_STRING_DISCRXPOOL_RC_OFFSETIND_CHOICE                    "discRxPool_ResourceConfig_offsetIndicator_choice"
+#define ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_PRESENT                    "discRxPool_ResourceConfig_subframeBitmap_present"
+#define ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_CHOICE_BS_BUF              "discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf"
+#define ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_CHOICE_BS_SIZE             "discRxPool_ResourceConfig_subframeBitmap_choice_bs_size"
+#define ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_CHOICE_BS_ASN_BITS_UNUSED  "discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused"
+
+//SIB19 for DiscRxPoolPS
+#define ENB_CONFIG_STRING_DISCRXPOOLPS_CP_LEN                                 "DISCRXPOOLPS_cp_Len"
+#define ENB_CONFIG_STRING_DISCRXPOOLPS_DISCPERIOD                             "DISCRXPOOLPS_discPeriod"
+#define ENB_CONFIG_STRING_DISCRXPOOLPS_NUMRETX                                "DISCRXPOOLPS_numRetx"
+#define ENB_CONFIG_STRING_DISCRXPOOLPS_NUMREPETITION                          "DISCRXPOOLPS_numRepetition"
+#define ENB_CONFIG_STRING_DISCRXPOOLPS_RC_PRB_NUM                             "DISCRXPOOLPS_ResourceConfig_prb_Num"
+#define ENB_CONFIG_STRING_DISCRXPOOLPS_RC_PRB_START                           "DISCRXPOOLPS_ResourceConfig_prb_Start"
+#define ENB_CONFIG_STRING_DISCRXPOOLPS_RC_PRB_END                             "DISCRXPOOLPS_ResourceConfig_prb_End"
+#define ENB_CONFIG_STRING_DISCRXPOOLPS_RC_OFFSETIND_PRESENT                   "DISCRXPOOLPS_ResourceConfig_offsetIndicator_present"
+#define ENB_CONFIG_STRING_DISCRXPOOLPS_RC_OFFSETIND_CHOICE                    "DISCRXPOOLPS_ResourceConfig_offsetIndicator_choice"
+#define ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_PRESENT                    "DISCRXPOOLPS_ResourceConfig_subframeBitmap_present"
+#define ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_CHOICE_BS_BUF              "DISCRXPOOLPS_ResourceConfig_subframeBitmap_choice_bs_buf"
+#define ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_CHOICE_BS_SIZE             "DISCRXPOOLPS_ResourceConfig_subframeBitmap_choice_bs_size"
+#define ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_CHOICE_BS_ASN_BITS_UNUSED  "DISCRXPOOLPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused"
+
+
+/*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
+/*                                     component carriers configuration parameters                                                                                                     */
+/*   optname                                                   helpstr   paramflags    XXXptr                                        defXXXval                    type         numelt  */
+/*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
+/* init for checkedparam_t structure */
+
+typedef struct ccparams_sidelink_s {
+  int               sidelink_configured;
+  //SIB18
+  char             *rxPool_sc_CP_Len;
+  char             *rxPool_sc_Period;
+  char             *rxPool_data_CP_Len;
+  libconfig_int     rxPool_ResourceConfig_prb_Num;
+  libconfig_int     rxPool_ResourceConfig_prb_Start;
+  libconfig_int     rxPool_ResourceConfig_prb_End;
+  char             *rxPool_ResourceConfig_offsetIndicator_present;
+  libconfig_int     rxPool_ResourceConfig_offsetIndicator_choice;
+  char             *rxPool_ResourceConfig_subframeBitmap_present;
+  char             *rxPool_ResourceConfig_subframeBitmap_choice_bs_buf;
+  libconfig_int     rxPool_ResourceConfig_subframeBitmap_choice_bs_size;
+  libconfig_int     rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused;
+  //SIB19
+  //For discRxPool
+  char             *discRxPool_cp_Len;
+  char             *discRxPool_discPeriod;
+  libconfig_int     discRxPool_numRetx;
+  libconfig_int     discRxPool_numRepetition;
+  libconfig_int     discRxPool_ResourceConfig_prb_Num;
+  libconfig_int     discRxPool_ResourceConfig_prb_Start;
+  libconfig_int     discRxPool_ResourceConfig_prb_End;
+  char             *discRxPool_ResourceConfig_offsetIndicator_present;
+  libconfig_int     discRxPool_ResourceConfig_offsetIndicator_choice;
+  char             *discRxPool_ResourceConfig_subframeBitmap_present;
+  char             *discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf;
+  libconfig_int     discRxPool_ResourceConfig_subframeBitmap_choice_bs_size;
+  libconfig_int     discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused;
+  //For discRxPoolPS
+  char             *discRxPoolPS_cp_Len;
+  const char       *discRxPoolPS_discPeriod;
+  libconfig_int     discRxPoolPS_numRetx;
+  libconfig_int     discRxPoolPS_numRepetition;
+  libconfig_int     discRxPoolPS_ResourceConfig_prb_Num;
+  libconfig_int     discRxPoolPS_ResourceConfig_prb_Start;
+  libconfig_int     discRxPoolPS_ResourceConfig_prb_End;
+  const char       *discRxPoolPS_ResourceConfig_offsetIndicator_present;
+  libconfig_int     discRxPoolPS_ResourceConfig_offsetIndicator_choice;
+  const char       *discRxPoolPS_ResourceConfig_subframeBitmap_present;
+  char             *discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf;
+  libconfig_int     discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size;
+  libconfig_int     discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused;
+} ccparams_sidelink_t;
+
+/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
+/*                                     component carriers configuration parameters                                                                                                                   */
+/*   optname                                                   helpstr   paramflags    XXXptr                                        defXXXval                    type         numelt  checked_param */
+/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
+
+#define CCPARAMS_SIDELINK_DESC(SLparams) {				\
+{"sidelink_configured",                                          NULL,   0,   iptr:(int*)&SLparams.sidelink_configured,   defintval:0,  TYPE_UINT,  0}, \
+{ENB_CONFIG_STRING_RXPOOL_SC_CP_LEN,                             NULL,   0,   strptr:(char **)&SLparams.rxPool_sc_CP_Len,          defstrval:"normal",  TYPE_STRING,  0}, \
+{ENB_CONFIG_STRING_RXPOOL_SC_PRIOD,                              NULL,   0,   strptr:(char **)&SLparams.rxPool_sc_Period,          defstrval:"sf40",  TYPE_STRING,  0}, \
+{ENB_CONFIG_STRING_RXPOOL_DATA_CP_LEN,                           NULL,   0,   strptr:(char **)&SLparams.rxPool_data_CP_Len,          defstrval:"normal",  TYPE_STRING,  0}, \
+{ENB_CONFIG_STRING_RXPOOL_RC_PRB_NUM,                            NULL,   0,   iptr:(int32_t *)&SLparams.rxPool_ResourceConfig_prb_Num,         defintval:1,       TYPE_UINT,    0}, \
+{ENB_CONFIG_STRING_RXPOOL_RC_PRB_START,                          NULL,   0,   iptr:(int32_t *)&SLparams.rxPool_ResourceConfig_prb_Start,         defintval:1,       TYPE_UINT,    0}, \
+{ENB_CONFIG_STRING_RXPOOL_RC_PRB_END,                            NULL,   0,   iptr:(int32_t *)&SLparams.rxPool_ResourceConfig_prb_End,         defintval:1,       TYPE_UINT,    0}, \
+{ENB_CONFIG_STRING_RXPOOL_RC_OFFSETIND_PRESENT,                  NULL,   0,   strptr:(char **)&SLparams.rxPool_ResourceConfig_offsetIndicator_present,            defstrval:"prNothing",  TYPE_STRING,  0}, \
+{ENB_CONFIG_STRING_RXPOOL_RC_OFFSETIND_CHOICE,                   NULL,   0,   iptr:(int32_t *)&SLparams.rxPool_ResourceConfig_offsetIndicator_choice,         defintval:1,       TYPE_UINT,    0}, \
+{ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_PRESENT,                   NULL,   0,   strptr:(char **)&SLparams.rxPool_ResourceConfig_subframeBitmap_present,            defstrval:"prNothing",  TYPE_STRING,  0}, \
+{ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_CHOICE_BS_BUF,             NULL,   0,   strptr:(char **)&SLparams.rxPool_ResourceConfig_subframeBitmap_choice_bs_buf,            defstrval:"001001",  TYPE_STRING,  0}, \
+{ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_CHOICE_BS_SIZE,            NULL,   0,   iptr:(int32_t *)&SLparams.rxPool_ResourceConfig_subframeBitmap_choice_bs_size,         defintval:1,       TYPE_UINT,    0}, \
+{ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_CHOICE_BS_ASN_BITS_UNUSED, NULL,   0,   iptr:(int32_t *)&SLparams.rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused,         defintval:1,       TYPE_UINT,    0}, \
+{ENB_CONFIG_STRING_DISCRXPOOL_CP_LEN,                            NULL,   0,   strptr:(char **)&SLparams.discRxPool_cp_Len,          defstrval:"normal",  TYPE_STRING,  0}, \
+{ENB_CONFIG_STRING_DISCRXPOOL_DISCPERIOD,                        NULL,   0,   strptr:(char **)&SLparams.discRxPool_discPeriod,          defstrval:"rf32",  TYPE_STRING,  0}, \
+{ENB_CONFIG_STRING_DISCRXPOOL_NUMRETX,                           NULL,   0,   iptr:(int32_t *)&SLparams.discRxPool_numRetx,         defintval:1,       TYPE_UINT,    0}, \
+{ENB_CONFIG_STRING_DISCRXPOOL_NUMREPETITION,                     NULL,   0,   iptr:(int32_t *)&SLparams.discRxPool_numRepetition,         defintval:1,       TYPE_UINT,    0}, \
+{ENB_CONFIG_STRING_DISCRXPOOL_RC_PRB_NUM,                        NULL,   0,   iptr:(int32_t *)&SLparams.discRxPool_ResourceConfig_prb_Num,         defintval:1,       TYPE_UINT,    0}, \
+{ENB_CONFIG_STRING_DISCRXPOOL_RC_PRB_START,                      NULL,   0,   iptr:(int32_t *)&SLparams.discRxPool_ResourceConfig_prb_Start,         defintval:1,       TYPE_UINT,    0}, \
+{ENB_CONFIG_STRING_DISCRXPOOL_RC_PRB_END,                        NULL,   0,   iptr:(int32_t *)&SLparams.discRxPool_ResourceConfig_prb_End,         defintval:1,       TYPE_UINT,    0}, \
+{ENB_CONFIG_STRING_DISCRXPOOL_RC_OFFSETIND_PRESENT,              NULL,   0,   strptr:(char **)&SLparams.discRxPool_ResourceConfig_offsetIndicator_present,            defstrval:"prNothing",  TYPE_STRING,  0}, \
+{ENB_CONFIG_STRING_DISCRXPOOL_RC_OFFSETIND_CHOICE,               NULL,   0,   iptr:(int32_t *)&SLparams.discRxPool_ResourceConfig_offsetIndicator_choice,         defintval:1,       TYPE_UINT,    0}, \
+{ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_PRESENT,               NULL,   0,   strptr:(char **)&SLparams.discRxPool_ResourceConfig_subframeBitmap_present,            defstrval:"prNothing",  TYPE_STRING,  0}, \
+{ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_CHOICE_BS_BUF,         NULL,   0,   strptr:(char **)&SLparams.discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf,            defstrval:"001001",  TYPE_STRING,  0}, \
+{ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_CHOICE_BS_SIZE,        NULL,   0,   iptr:(int32_t *)&SLparams.discRxPool_ResourceConfig_subframeBitmap_choice_bs_size,         defintval:1,       TYPE_UINT,    0}, \
+{ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_CHOICE_BS_ASN_BITS_UNUSED,NULL,   0,   iptr:(int32_t *)&SLparams.discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused,         defintval:1,       TYPE_UINT,    0}, \
+{ENB_CONFIG_STRING_DISCRXPOOLPS_CP_LEN,                            NULL,   0,   strptr:(char **)&SLparams.discRxPoolPS_cp_Len,          defstrval:"normal",  TYPE_STRING,  0}, \
+{ENB_CONFIG_STRING_DISCRXPOOLPS_DISCPERIOD,                        NULL,   0,   strptr:(char **)&SLparams.discRxPoolPS_discPeriod,          defstrval:"rf32",  TYPE_STRING,  0}, \
+{ENB_CONFIG_STRING_DISCRXPOOLPS_NUMRETX,                           NULL,   0,   iptr:(int32_t *)&SLparams.discRxPoolPS_numRetx,         defintval:1,       TYPE_UINT,    0}, \
+{ENB_CONFIG_STRING_DISCRXPOOLPS_NUMREPETITION,                     NULL,   0,   iptr:(int32_t *)&SLparams.discRxPoolPS_numRepetition,         defintval:1,       TYPE_UINT,    0}, \
+{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_PRB_NUM,                        NULL,   0,   iptr:(int32_t *)&SLparams.discRxPoolPS_ResourceConfig_prb_Num,         defintval:1,       TYPE_UINT,    0}, \
+{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_PRB_START,                      NULL,   0,   iptr:(int32_t *)&SLparams.discRxPoolPS_ResourceConfig_prb_Start,         defintval:1,       TYPE_UINT,    0}, \
+{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_PRB_END,                        NULL,   0,   iptr:(int32_t *)&SLparams.discRxPoolPS_ResourceConfig_prb_End,         defintval:1,       TYPE_UINT,    0}, \
+{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_OFFSETIND_PRESENT,              NULL,   0,   strptr:(char **)&SLparams.discRxPoolPS_ResourceConfig_offsetIndicator_present,            defstrval:"prNothing",  TYPE_STRING,  0}, \
+{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_OFFSETIND_CHOICE,               NULL,   0,   iptr:(int32_t *)&SLparams.discRxPoolPS_ResourceConfig_offsetIndicator_choice,         defintval:1,       TYPE_UINT,    0}, \
+{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_PRESENT,               NULL,   0,   strptr:(char **)&SLparams.discRxPoolPS_ResourceConfig_subframeBitmap_present,            defstrval:"prNothing",  TYPE_STRING,  0}, \
+{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_CHOICE_BS_BUF,         NULL,   0,   strptr:(char **)&SLparams.discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf,            defstrval:"001001",  TYPE_STRING,  0}, \
+{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_CHOICE_BS_SIZE,        NULL,   0,   iptr:(int32_t *)&SLparams.discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size,         defintval:1,       TYPE_UINT,    0}, \
+{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_CHOICE_BS_ASN_BITS_UNUSED,NULL,   0,   iptr:(int32_t *)&SLparams.discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused,         defintval:1,       TYPE_UINT,    0} \
+}
+#endif
+
diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c
index 909f45168a8c71080be1280b894fa931d541b6f1..8ada30cc82d02c36001eabe977ff1c9025f94ed5 100644
--- a/openair2/ENB_APP/flexran_agent_ran_api.c
+++ b/openair2/ENB_APP/flexran_agent_ran_api.c
@@ -674,13 +674,13 @@ uint8_t flexran_get_special_subframe_assignment(mid_t mod_id, uint8_t cc_id)
 long flexran_get_ra_ResponseWindowSize(mid_t mod_id, uint8_t cc_id)
 {
   if (!rrc_is_present(mod_id)) return 0;
-  return RC.rrc[mod_id]->configuration.rach_raResponseWindowSize[cc_id];
+  return RC.rrc[mod_id]->configuration.radioresourceconfig[cc_id].rach_raResponseWindowSize;
 }
 
 long flexran_get_mac_ContentionResolutionTimer(mid_t mod_id, uint8_t cc_id)
 {
   if (!rrc_is_present(mod_id)) return 0;
-  return RC.rrc[mod_id]->configuration.rach_macContentionResolutionTimer[cc_id];
+  return RC.rrc[mod_id]->configuration.radioresourceconfig[cc_id].rach_macContentionResolutionTimer;
 }
 
 Protocol__FlexDuplexMode flexran_get_duplex_mode(mid_t mod_id, uint8_t cc_id)
@@ -1135,7 +1135,7 @@ int8_t flexran_agent_get_operating_pdsch_refpower(mid_t mod_id, uint8_t cc_id)
 long flexran_agent_get_operating_pusch_p0(mid_t mod_id, uint8_t cc_id)
 {
   if (!rrc_is_present(mod_id)) return 0;
-  return RC.rrc[mod_id]->configuration.pusch_p0_Nominal[cc_id];
+  return RC.rrc[mod_id]->configuration.radioresourceconfig[cc_id].pusch_p0_Nominal;
 }
 
 void flexran_agent_set_operating_dl_freq(mid_t mod_id, uint8_t cc_id, uint32_t dl_freq_mhz)
diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c
index ac5c4a5de31e5447ffd96b5843dc508392172014..3252bb6b92f6a629a1c965db5b31c7f793e33b44 100644
--- a/openair2/LAYER2/MAC/config.c
+++ b/openair2/LAYER2/MAC/config.c
@@ -534,6 +534,7 @@ config_sib2(int Mod_idP,
     cfg->emtc_config.prach_ce_level_3_enable.tl.tag=NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_ENABLE_TAG;
     cfg->num_tlv++;
 
+
     switch (prach_ParametersListCE_r13->list.count) {
     case 4:
       p = prach_ParametersListCE_r13->list.array[3];
@@ -549,16 +550,17 @@ config_sib2(int Mod_idP,
       cfg->emtc_config.prach_ce_level_3_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_FREQUENCY_OFFSET_TAG;
       cfg->num_tlv++;
 
-      cfg->emtc_config.prach_ce_level_3_number_of_repetitions_per_attempt.value = p->numRepetitionPerPreambleAttempt_r13;
+      cfg->emtc_config.prach_ce_level_3_number_of_repetitions_per_attempt.value = 1<<p->numRepetitionPerPreambleAttempt_r13;
       cfg->emtc_config.prach_ce_level_3_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG;
       cfg->num_tlv++;
 
       if (p->prach_StartingSubframe_r13) {
-	cfg->emtc_config.prach_ce_level_3_starting_subframe_periodicity.value   = *p->prach_StartingSubframe_r13;
+	cfg->emtc_config.prach_ce_level_3_starting_subframe_periodicity.value   = 2<<*p->prach_StartingSubframe_r13;
         cfg->emtc_config.prach_ce_level_3_starting_subframe_periodicity.tl.tag  = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_STARTING_SUBFRAME_PERIODICITY_TAG;
         cfg->num_tlv++;
       }
 
+
       cfg->emtc_config.prach_ce_level_3_hopping_enable.value                    = p->prach_HoppingConfig_r13;
       cfg->emtc_config.prach_ce_level_3_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_ENABLE_TAG;
       cfg->num_tlv++;
@@ -581,12 +583,12 @@ config_sib2(int Mod_idP,
       cfg->emtc_config.prach_ce_level_2_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_FREQUENCY_OFFSET_TAG;
       cfg->num_tlv++;
 
-      cfg->emtc_config.prach_ce_level_2_number_of_repetitions_per_attempt.value = p->numRepetitionPerPreambleAttempt_r13;
+      cfg->emtc_config.prach_ce_level_2_number_of_repetitions_per_attempt.value = 1<<p->numRepetitionPerPreambleAttempt_r13;
       cfg->emtc_config.prach_ce_level_2_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG;
       cfg->num_tlv++;
 
       if (p->prach_StartingSubframe_r13) {
-	cfg->emtc_config.prach_ce_level_2_starting_subframe_periodicity.value   = *p->prach_StartingSubframe_r13;
+	cfg->emtc_config.prach_ce_level_2_starting_subframe_periodicity.value   = 2<<*p->prach_StartingSubframe_r13;
         cfg->emtc_config.prach_ce_level_2_starting_subframe_periodicity.tl.tag  = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_STARTING_SUBFRAME_PERIODICITY_TAG;
         cfg->num_tlv++;
       }
@@ -613,12 +615,12 @@ config_sib2(int Mod_idP,
       cfg->emtc_config.prach_ce_level_1_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_FREQUENCY_OFFSET_TAG;
       cfg->num_tlv++;
 
-      cfg->emtc_config.prach_ce_level_1_number_of_repetitions_per_attempt.value = p->numRepetitionPerPreambleAttempt_r13;
+      cfg->emtc_config.prach_ce_level_1_number_of_repetitions_per_attempt.value = 1<<p->numRepetitionPerPreambleAttempt_r13;
       cfg->emtc_config.prach_ce_level_1_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG;
       cfg->num_tlv++;
 
       if (p->prach_StartingSubframe_r13) {
-	cfg->emtc_config.prach_ce_level_1_starting_subframe_periodicity.value   = *p->prach_StartingSubframe_r13;
+	cfg->emtc_config.prach_ce_level_1_starting_subframe_periodicity.value   = 2<<*p->prach_StartingSubframe_r13;
         cfg->emtc_config.prach_ce_level_1_starting_subframe_periodicity.tl.tag  = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_STARTING_SUBFRAME_PERIODICITY_TAG;
         cfg->num_tlv++;
       }
@@ -645,12 +647,12 @@ config_sib2(int Mod_idP,
       cfg->emtc_config.prach_ce_level_0_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_FREQUENCY_OFFSET_TAG;
       cfg->num_tlv++;
 
-      cfg->emtc_config.prach_ce_level_0_number_of_repetitions_per_attempt.value = p->numRepetitionPerPreambleAttempt_r13;
+      cfg->emtc_config.prach_ce_level_0_number_of_repetitions_per_attempt.value = 1<<p->numRepetitionPerPreambleAttempt_r13;
       cfg->emtc_config.prach_ce_level_0_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG;
       cfg->num_tlv++;
 
       if (p->prach_StartingSubframe_r13) {
-	cfg->emtc_config.prach_ce_level_0_starting_subframe_periodicity.value   = *p->prach_StartingSubframe_r13;
+	cfg->emtc_config.prach_ce_level_0_starting_subframe_periodicity.value   = 2<<*p->prach_StartingSubframe_r13;
         cfg->emtc_config.prach_ce_level_0_starting_subframe_periodicity.tl.tag  = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_STARTING_SUBFRAME_PERIODICITY_TAG;
         cfg->num_tlv++;
       }
@@ -664,6 +666,9 @@ config_sib2(int Mod_idP,
       cfg->num_tlv++;
     }
 
+
+    AssertFatal(cfg->emtc_config.prach_ce_level_0_enable.value>0,"CE_level0 is not enabled\n");
+
     struct LTE_FreqHoppingParameters_r13 *ext4_freqHoppingParameters = radioResourceConfigCommonP->ext4->freqHoppingParameters_r13;
     if ((ext4_freqHoppingParameters) &&
         (ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13)){
@@ -722,55 +727,54 @@ config_dedicated_scell(int Mod_idP,
 }
 
 
-int
-rrc_mac_config_req_eNB(module_id_t Mod_idP,
-		       int CC_idP,
-		       int physCellId,
-		       int p_eNB,
-		       int Ncp, int eutra_band, uint32_t dl_CarrierFreq,
+int rrc_mac_config_req_eNB(module_id_t Mod_idP,
+			   int CC_idP,
+			   int physCellId,
+			   int p_eNB,
+			   int Ncp, int eutra_band, uint32_t dl_CarrierFreq,
 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
-		       int pbch_repetition,
+			   int pbch_repetition,
 #endif
-		       rnti_t rntiP,
-		       LTE_BCCH_BCH_Message_t * mib,
-		       LTE_RadioResourceConfigCommonSIB_t *
-		       radioResourceConfigCommon,
+			   rnti_t rntiP,
+			   LTE_BCCH_BCH_Message_t * mib,
+			   LTE_RadioResourceConfigCommonSIB_t *
+			   radioResourceConfigCommon,
 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
-		       LTE_RadioResourceConfigCommonSIB_t *
-		       radioResourceConfigCommon_BR,
+			   LTE_RadioResourceConfigCommonSIB_t *
+			   radioResourceConfigCommon_BR,
 #endif
-		       struct LTE_PhysicalConfigDedicated
-		       *physicalConfigDedicated,
+			   struct LTE_PhysicalConfigDedicated
+			   *physicalConfigDedicated,
 #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
-		       LTE_SCellToAddMod_r10_t * sCellToAddMod_r10,
-		       //struct LTE_PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
+			   LTE_SCellToAddMod_r10_t * sCellToAddMod_r10,
+			   //struct LTE_PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
 #endif
-		       LTE_MeasObjectToAddMod_t ** measObj,
-		       LTE_MAC_MainConfig_t * mac_MainConfig,
-		       long logicalChannelIdentity,
-		       LTE_LogicalChannelConfig_t * logicalChannelConfig,
-		       LTE_MeasGapConfig_t * measGapConfig,
-		       LTE_TDD_Config_t * tdd_Config,
-		       LTE_MobilityControlInfo_t * mobilityControlInfo,
-		       LTE_SchedulingInfoList_t * schedulingInfoList,
-		       uint32_t ul_CarrierFreq,
-		       long *ul_Bandwidth,
-		       LTE_AdditionalSpectrumEmission_t *
-		       additionalSpectrumEmission,
-		       struct LTE_MBSFN_SubframeConfigList
-		       *mbsfn_SubframeConfigList
+			   LTE_MeasObjectToAddMod_t ** measObj,
+			   LTE_MAC_MainConfig_t * mac_MainConfig,
+			   long logicalChannelIdentity,
+			   LTE_LogicalChannelConfig_t * logicalChannelConfig,
+			   LTE_MeasGapConfig_t * measGapConfig,
+			   LTE_TDD_Config_t * tdd_Config,
+			   LTE_MobilityControlInfo_t * mobilityControlInfo,
+			   LTE_SchedulingInfoList_t * schedulingInfoList,
+			   uint32_t ul_CarrierFreq,
+			   long *ul_Bandwidth,
+			   LTE_AdditionalSpectrumEmission_t *
+			   additionalSpectrumEmission,
+			   struct LTE_MBSFN_SubframeConfigList
+			   *mbsfn_SubframeConfigList
 #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0))
-		       , uint8_t MBMS_Flag,
-		       LTE_MBSFN_AreaInfoList_r9_t * mbsfn_AreaInfoList,
-		       LTE_PMCH_InfoList_r9_t * pmch_InfoList
+			   , uint8_t MBMS_Flag,
+			   LTE_MBSFN_AreaInfoList_r9_t * mbsfn_AreaInfoList,
+			   LTE_PMCH_InfoList_r9_t * pmch_InfoList
 #endif
 #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0))
-		       ,
-		       LTE_SystemInformationBlockType1_v1310_IEs_t *
-		       sib1_v13ext
+			   ,
+			   LTE_SystemInformationBlockType1_v1310_IEs_t *
+			   sib1_v13ext
 #endif
-                       ) {
-			   
+			   ) {
+  
   int i;
 
   int UE_id = -1;
@@ -869,21 +873,13 @@ rrc_mac_config_req_eNB(module_id_t Mod_idP,
       AssertFatal(radioResourceConfigCommon->
 		  rach_ConfigCommon.maxHARQ_Msg3Tx > 0,
 		  "radioResourceconfigCommon %d == 0\n",
-		  (int) radioResourceConfigCommon->
-		  rach_ConfigCommon.maxHARQ_Msg3Tx);
-
-      RC.mac[Mod_idP]->common_channels[CC_idP].
-	radioResourceConfigCommon = radioResourceConfigCommon;
-      if (ul_CarrierFreq > 0)
-	RC.mac[Mod_idP]->common_channels[CC_idP].ul_CarrierFreq =
-	  ul_CarrierFreq;
-      if (ul_Bandwidth)
-	RC.mac[Mod_idP]->common_channels[CC_idP].ul_Bandwidth =
-	  *ul_Bandwidth;
-      else
-	RC.mac[Mod_idP]->common_channels[CC_idP].ul_Bandwidth =
-	  RC.mac[Mod_idP]->common_channels[CC_idP].mib->message.
-	  dl_Bandwidth;
+		  (int) radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx);
+
+      RC.mac[Mod_idP]->common_channels[CC_idP].radioResourceConfigCommon = radioResourceConfigCommon;
+      RC.mac[Mod_idP]->common_channels[CC_idP].radioResourceConfigCommon_BR = radioResourceConfigCommon_BR;
+      if (ul_CarrierFreq > 0) RC.mac[Mod_idP]->common_channels[CC_idP].ul_CarrierFreq        = ul_CarrierFreq;
+      if (ul_Bandwidth) 	RC.mac[Mod_idP]->common_channels[CC_idP].ul_Bandwidth        = *ul_Bandwidth;
+      else RC.mac[Mod_idP]->common_channels[CC_idP].ul_Bandwidth                             = RC.mac[Mod_idP]->common_channels[CC_idP].mib->message.dl_Bandwidth;
 
       config_sib2(Mod_idP, CC_idP, radioResourceConfigCommon,
 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
@@ -896,68 +892,52 @@ rrc_mac_config_req_eNB(module_id_t Mod_idP,
     }
   } // mib != NULL
 
+
   // SRB2_lchan_config->choice.explicitValue.ul_SpecificParameters->logicalChannelGroup
   if (logicalChannelConfig != NULL) {	// check for eMTC specific things
     UE_id = find_UE_id(Mod_idP, rntiP);
 
-    if (UE_id == -1) {
-      LOG_E(MAC, "%s:%d:%s: ERROR, UE_id == -1\n", __FILE__,
-	    __LINE__, __FUNCTION__);
-    } else {
-		if (logicalChannelConfig) {
-        UE_list->
-          UE_template[CC_idP][UE_id].lcgidmap
-          [logicalChannelIdentity] =
-          *logicalChannelConfig->
-			ul_SpecificParameters->logicalChannelGroup;
-		UE_list->
-          UE_template[CC_idP][UE_id].lcgidpriority
-          [logicalChannelIdentity]=
-			logicalChannelConfig->ul_SpecificParameters->priority;
-
-		} else
-			UE_list->
-				UE_template[CC_idP][UE_id].lcgidmap
-				[logicalChannelIdentity] = 0;
+    if (UE_id<0) { 
+      LOG_E(MAC,"Configuration received for unknown UE (%x), shouldn't happen\n",rntiP);
+      return(-1);
     }
+    if (logicalChannelConfig) {
+        UE_list->UE_template[CC_idP][UE_id].lcgidmap[logicalChannelIdentity]      = *logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup;
+	UE_list->UE_template[CC_idP][UE_id].lcgidpriority[logicalChannelIdentity] =  logicalChannelConfig->ul_SpecificParameters->priority;
+    } else UE_list->UE_template[CC_idP][UE_id].lcgidmap[logicalChannelIdentity]   =  0;
   }
-
-
+  
   if (physicalConfigDedicated != NULL) {
     UE_id = find_UE_id(Mod_idP, rntiP);
-
-    if (UE_id == -1)
-      LOG_E(MAC, "%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__);
-    else
-      UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated = physicalConfigDedicated;
+    if (UE_id<0) { 
+      LOG_E(MAC,"Configuration received for unknown UE (%x), shouldn't happen\n",rntiP);
+      return(-1);
+    }
+    UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated = physicalConfigDedicated;
+    LOG_I(MAC,"Added physicalConfigDedicated %p for %d.%d\n",physicalConfigDedicated,CC_idP,UE_id);
   }
 
 
 #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
 
   if (sCellToAddMod_r10 != NULL) {
-    UE_id = find_UE_id(Mod_idP, rntiP);
-    if (UE_id == -1)
-      LOG_E(MAC, "%s:%d:%s: ERROR, UE_id == -1\n", __FILE__,
-	    __LINE__, __FUNCTION__);
-    else
-      config_dedicated_scell(Mod_idP, rntiP, sCellToAddMod_r10);
+    if (UE_id<0) { 
+      LOG_E(MAC,"Configuration received for unknown UE (%x), shouldn't happen\n",rntiP);
+      return(-1);
+    }
+    AssertFatal(UE_id>=0,"Configuration received for unknown UE (%x), shouldn't happen\n",rntiP);
+    config_dedicated_scell(Mod_idP, rntiP, sCellToAddMod_r10);
   }
 #endif
 
-
-
-
   if (mbsfn_SubframeConfigList != NULL) {
     LOG_I(MAC,
 	  "[eNB %d][CONFIG] Received %d subframe allocation pattern for MBSFN\n",
 	  Mod_idP, mbsfn_SubframeConfigList->list.count);
-    RC.mac[Mod_idP]->common_channels[0].num_sf_allocation_pattern =
-      mbsfn_SubframeConfigList->list.count;
+    RC.mac[Mod_idP]->common_channels[0].num_sf_allocation_pattern = mbsfn_SubframeConfigList->list.count;
 
     for (i = 0; i < mbsfn_SubframeConfigList->list.count; i++) {
-      RC.mac[Mod_idP]->common_channels[0].mbsfn_SubframeConfig[i] =
-	mbsfn_SubframeConfigList->list.array[i];
+      RC.mac[Mod_idP]->common_channels[0].mbsfn_SubframeConfig[i] = mbsfn_SubframeConfigList->list.array[i];
       LOG_I(MAC,
 	    "[eNB %d][CONFIG] MBSFN_SubframeConfig[%d] pattern is  %x\n",
 	    Mod_idP, i,
diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h
new file mode 100644
index 0000000000000000000000000000000000000000..6af0fd66ca9ed25f74c950970e7557a72ba6a18b
--- /dev/null
+++ b/openair2/LAYER2/MAC/defs.h
@@ -0,0 +1,1345 @@
+/*
+ * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The OpenAirInterface Software Alliance licenses this file to You under
+ * the OAI Public License, Version 1.1  (the "License"); you may not use this file
+ * except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.openairinterface.org/?page_id=698
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *-------------------------------------------------------------------------------
+ * For more information about the OpenAirInterface (OAI) Software Alliance:
+ *      contact@openairinterface.org
+ */
+
+/*! \file LAYER2/MAC/defs.h
+* \brief MAC data structures, constant, and function prototype
+* \author Navid Nikaein and Raymond Knopp
+* \date 2011
+* \version 0.5
+* \email navid.nikaein@eurecom.fr
+
+*/
+/** @defgroup _oai2  openair2 Reference Implementation
+ * @ingroup _ref_implementation_
+ * @{
+ */
+
+/*@}*/
+
+#ifndef __LAYER2_MAC_DEFS_H__
+#define __LAYER2_MAC_DEFS_H__
+
+
+
+#ifdef USER_MODE
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#endif
+
+//#include "COMMON/openair_defs.h"
+
+
+
+#include "PHY/defs.h"
+#include "PHY/LTE_TRANSPORT/defs.h"
+#include "COMMON/platform_constants.h"
+#include "BCCH-BCH-Message.h"
+#include "RadioResourceConfigCommon.h"
+#include "RadioResourceConfigDedicated.h"
+#include "MeasGapConfig.h"
+#include "SchedulingInfoList.h"
+#include "TDD-Config.h"
+#include "RACH-ConfigCommon.h"
+#include "MeasObjectToAddModList.h"
+#include "MobilityControlInfo.h"
+#if defined(Rel10) || defined(Rel14)
+#include "MBSFN-AreaInfoList-r9.h"
+#include "MBSFN-SubframeConfigList.h"
+#include "PMCH-InfoList-r9.h"
+#include "SCellToAddMod-r10.h"
+#endif
+#ifdef Rel14
+#include "SystemInformationBlockType1-v1310-IEs.h"
+#endif
+
+#include "nfapi_interface.h"
+#include "PHY_INTERFACE/IF_Module.h"
+
+/** @defgroup _mac  MAC
+ * @ingroup _oai2
+ * @{
+ */
+
+#define BCCH_PAYLOAD_SIZE_MAX 128
+#define CCCH_PAYLOAD_SIZE_MAX 128
+#define PCCH_PAYLOAD_SIZE_MAX 128
+#define RAR_PAYLOAD_SIZE_MAX 128
+
+#define SCH_PAYLOAD_SIZE_MAX 4096
+/// Logical channel ids from 36-311 (Note BCCH is not specified in 36-311, uses the same as first DRB)
+
+#if defined(Rel10) || defined(Rel14)
+
+// Mask for identifying subframe for MBMS
+#define MBSFN_TDD_SF3 0x80// for TDD
+#define MBSFN_TDD_SF4 0x40
+#define MBSFN_TDD_SF7 0x20
+#define MBSFN_TDD_SF8 0x10
+#define MBSFN_TDD_SF9 0x08
+#define MBSFN_FDD_SF1 0x80// for FDD
+#define MBSFN_FDD_SF2 0x40
+#define MBSFN_FDD_SF3 0x20
+#define MBSFN_FDD_SF6 0x10
+#define MBSFN_FDD_SF7 0x08
+#define MBSFN_FDD_SF8 0x04
+
+#define MAX_MBSFN_AREA 8
+#define MAX_PMCH_perMBSFN 15
+/*!\brief MAX MCCH payload size  */
+#define MCCH_PAYLOAD_SIZE_MAX 128
+//#define MCH_PAYLOAD_SIZE_MAX 16384// this value is using in case mcs and TBS index are high
+#endif
+
+#ifdef USER_MODE
+#define printk printf
+#endif //USER_MODE
+
+/*!\brief Maximum number of logical channl group IDs */
+#define MAX_NUM_LCGID 4
+/*!\brief logical channl group ID 0 */
+#define LCGID0 0
+/*!\brief logical channl group ID 1 */
+#define LCGID1 1
+/*!\brief logical channl group ID 2 */
+#define LCGID2 2
+/*!\brief logical channl group ID 3 */
+#define LCGID3 3
+/*!\brief Maximum number of logical chanels */
+#define MAX_NUM_LCID 11
+/*!\brief Maximum number od control elemenets */
+#define MAX_NUM_CE 5
+/*!\brief Maximum number of random access process */
+#define NB_RA_PROC_MAX 4
+/*!\brief size of buffer status report table */
+#define BSR_TABLE_SIZE 64
+/*!\brief The power headroom reporting range is from -23 ...+40 dB and beyond, with step 1 */
+#define PHR_MAPPING_OFFSET 23  // if ( x>= -23 ) val = floor (x + 23) 
+/*!\brief maximum number of resource block groups */
+#define N_RBG_MAX 25 // for 20MHz channel BW
+/*!\brief minimum value for channel quality indicator */
+#define MIN_CQI_VALUE  0
+/*!\brief maximum value for channel quality indicator */
+#define MAX_CQI_VALUE  15
+/*!\briefmaximum number of supported bandwidth (1.4, 5, 10, 20 MHz) */
+#define MAX_SUPPORTED_BW  4  
+/*!\brief CQI values range from 1 to 15 (4 bits) */
+#define CQI_VALUE_RANGE 16 
+
+/*!\brief value for indicating BSR Timer is not running */
+#define MAC_UE_BSR_TIMER_NOT_RUNNING   (0xFFFF)
+
+#define LCID_EMPTY 0
+#define LCID_NOT_EMPTY 1
+
+/*!\brief minimum RLC PDU size to be transmitted = min RLC Status PDU or RLC UM PDU SN 5 bits */
+#define MIN_RLC_PDU_SIZE    (2)
+
+/*!\brief minimum MAC data needed for transmitting 1 min RLC PDU size + 1 byte MAC subHeader */
+#define MIN_MAC_HDR_RLC_SIZE    (1 + MIN_RLC_PDU_SIZE)
+
+/*!\brief maximum number of slices / groups */
+#define MAX_NUM_SLICES 4 
+
+/* 
+ * eNB part 
+ */ 
+
+
+/* 
+ * UE/ENB common part 
+ */ 
+/*!\brief MAC header of Random Access Response for Random access preamble identifier (RAPID) */
+typedef struct {
+  uint8_t RAPID:6;
+  uint8_t T:1;
+  uint8_t E:1;
+} __attribute__((__packed__))RA_HEADER_RAPID;
+
+/*!\brief  MAC header of Random Access Response for backoff indicator (BI)*/
+typedef struct {
+  uint8_t BI:4;
+  uint8_t R:2;
+  uint8_t T:1;
+  uint8_t E:1;
+} __attribute__((__packed__))RA_HEADER_BI;
+/*
+typedef struct {
+  uint64_t padding:16;
+  uint64_t t_crnti:16;
+  uint64_t hopping_flag:1;
+  uint64_t rb_alloc:10;
+  uint64_t mcs:4;
+  uint64_t TPC:3;
+  uint64_t UL_delay:1;
+  uint64_t cqi_req:1;
+  uint64_t Timing_Advance_Command:11;  // first/2nd octet LSB
+  uint64_t R:1;                        // octet MSB
+  } __attribute__((__packed__))RAR_PDU;
+
+typedef struct {
+  uint64_t padding:16;
+  uint64_t R:1;                        // octet MSB
+  uint64_t Timing_Advance_Command:11;  // first/2nd octet LSB
+  uint64_t cqi_req:1;
+  uint64_t UL_delay:1;
+  uint64_t TPC:3;
+  uint64_t mcs:4;
+  uint64_t rb_alloc:10;
+  uint64_t hopping_flag:1;
+  uint64_t t_crnti:16;
+  } __attribute__((__packed__))RAR_PDU;
+
+#define sizeof_RAR_PDU 6
+*/
+/*!\brief  MAC subheader short with 7bit Length field */
+typedef struct {
+  uint8_t LCID:5;  // octet 1 LSB
+  uint8_t E:1;
+  uint8_t R:2;     // octet 1 MSB
+  uint8_t L:7;     // octet 2 LSB
+  uint8_t F:1;     // octet 2 MSB
+} __attribute__((__packed__))SCH_SUBHEADER_SHORT;
+/*!\brief  MAC subheader long  with 15bit Length field */
+typedef struct {
+  uint8_t LCID:5;   // octet 1 LSB
+  uint8_t E:1;
+  uint8_t R:2;      // octet 1 MSB
+  uint8_t L_MSB:7;
+  uint8_t F:1;      // octet 2 MSB
+  uint8_t L_LSB:8;
+  uint8_t padding;
+} __attribute__((__packed__))SCH_SUBHEADER_LONG;
+/*!\brief MAC subheader short without length field */
+typedef struct {
+  uint8_t LCID:5;
+  uint8_t E:1;
+  uint8_t R:2;
+} __attribute__((__packed__))SCH_SUBHEADER_FIXED;
+
+/*!\brief  mac control element: short buffer status report for a specific logical channel group ID*/
+typedef struct {
+  uint8_t Buffer_size:6;  // octet 1 LSB
+  uint8_t LCGID:2;        // octet 1 MSB
+} __attribute__((__packed__))BSR_SHORT;
+
+typedef BSR_SHORT BSR_TRUNCATED;
+/*!\brief  mac control element: long buffer status report for all logical channel group ID*/
+typedef struct {
+  uint8_t Buffer_size3:6;
+  uint8_t Buffer_size2:6;
+  uint8_t Buffer_size1:6;
+  uint8_t Buffer_size0:6;
+} __attribute__((__packed__))BSR_LONG;
+
+#define BSR_LONG_SIZE  (sizeof(BSR_LONG))
+/*!\brief  mac control element: timing advance  */
+typedef struct {
+  uint8_t TA:6;
+  uint8_t R:2;
+} __attribute__((__packed__))TIMING_ADVANCE_CMD;
+/*!\brief  mac control element: power headroom report  */
+typedef struct {
+  uint8_t PH:6;
+  uint8_t R:2;
+} __attribute__((__packed__))POWER_HEADROOM_CMD;
+
+/*! \brief MIB payload */
+typedef struct {
+  uint8_t payload[3] ;
+} __attribute__((__packed__))MIB_PDU;
+/*! \brief CCCH payload */
+typedef struct {
+  uint8_t payload[CCCH_PAYLOAD_SIZE_MAX] ;
+} __attribute__((__packed__))CCCH_PDU;
+/*! \brief BCCH payload */
+typedef struct {
+  uint8_t payload[BCCH_PAYLOAD_SIZE_MAX] ;
+} __attribute__((__packed__))BCCH_PDU;
+/*! \brief RAR payload */
+typedef struct {
+  uint8_t payload[RAR_PAYLOAD_SIZE_MAX];
+} __attribute__ ((__packed__)) RAR_PDU;
+/*! \brief BCCH payload */
+typedef struct {
+  uint8_t payload[PCCH_PAYLOAD_SIZE_MAX] ;
+} __attribute__((__packed__))PCCH_PDU;
+
+#if defined(Rel10) || defined(Rel14)
+/*! \brief MCCH payload */
+typedef struct {
+  uint8_t payload[MCCH_PAYLOAD_SIZE_MAX] ;
+} __attribute__((__packed__))MCCH_PDU;
+/*!< \brief MAC control element for activation and deactivation of component carriers */
+typedef struct {
+  uint8_t C7:1;/*!< \brief Component carrier 7 */
+  uint8_t C6:1;/*!< \brief Component carrier 6 */
+  uint8_t C5:1;/*!< \brief Component carrier 5 */
+  uint8_t C4:1;/*!< \brief Component carrier 4 */
+  uint8_t C3:1;/*!< \brief Component carrier 3 */
+  uint8_t C2:1;/*!< \brief Component carrier 2 */
+  uint8_t C1:1;/*!< \brief Component carrier 1 */
+  uint8_t R:1;/*!< \brief Reserved  */
+} __attribute__((__packed__))CC_ELEMENT;
+/*! \brief MAC control element: MCH Scheduling Information */
+typedef struct {
+  uint8_t stop_sf_MSB:3; // octet 1 LSB
+  uint8_t lcid:5;        // octet 2 MSB
+  uint8_t stop_sf_LSB:8;
+} __attribute__((__packed__))MSI_ELEMENT;
+#endif
+/*! \brief Values of CCCH LCID for DLSCH */ 
+#define CCCH_LCHANID 0
+/*!\brief Values of BCCH logical channel (fake)*/
+#define BCCH 3  // SI 
+/*!\brief Values of PCCH logical channel (fake)*/
+#define PCCH 4  // Paging 
+/*!\brief Values of PCCH logical channel (fake) */
+#define MIBCH 5  // MIB 
+/*!\brief Values of BCCH SIB1_BR logical channel (fake) */
+#define BCCH_SIB1_BR 6  // SIB1_BR 
+/*!\brief Values of BCCH SIB_BR logical channel (fake) */
+#define BCCH_SI_BR 7  // SI-BR 
+/*!\brief Value of CCCH / SRB0 logical channel */
+#define CCCH 0  // srb0
+/*!\brief DCCH / SRB1 logical channel */
+#define DCCH 1  // srb1
+/*!\brief DCCH1 / SRB2  logical channel */
+#define DCCH1 2 // srb2
+/*!\brief DTCH DRB1  logical channel */
+#define DTCH 3 // LCID
+/*!\brief MCCH logical channel */
+#define MCCH 4 
+/*!\brief MTCH logical channel */
+#define MTCH 1 
+// DLSCH LCHAN ID
+/*!\brief LCID of UE contention resolution identity for DLSCH*/
+#define UE_CONT_RES 28
+/*!\brief LCID of timing advance for DLSCH */
+#define TIMING_ADV_CMD 29
+/*!\brief LCID of discontinous reception mode for DLSCH */
+#define DRX_CMD 30
+/*!\brief LCID of padding LCID for DLSCH */
+#define SHORT_PADDING 31
+
+#if defined(Rel10) || defined(Rel14)
+// MCH LCHAN IDs (table6.2.1-4 TS36.321)
+/*!\brief LCID of MCCH for DL */
+#define MCCH_LCHANID 0
+/*!\brief LCID of MCH scheduling info for DL */
+#define MCH_SCHDL_INFO 3
+/*!\brief LCID of Carrier component activation/deactivation */
+#define CC_ACT_DEACT 27
+#endif
+
+// ULSCH LCHAN IDs
+/*!\brief LCID of extended power headroom for ULSCH */
+#define EXTENDED_POWER_HEADROOM 25
+/*!\brief LCID of power headroom for ULSCH */
+#define POWER_HEADROOM 26
+/*!\brief LCID of CRNTI for ULSCH */
+#define CRNTI 27
+/*!\brief LCID of truncated BSR for ULSCH */
+#define TRUNCATED_BSR 28
+/*!\brief LCID of short BSR for ULSCH */
+#define SHORT_BSR 29
+/*!\brief LCID of long BSR for ULSCH */
+#define LONG_BSR 30
+/*!\bitmaps for BSR Triggers */
+#define	BSR_TRIGGER_NONE		(0)			/* No BSR Trigger */
+#define	BSR_TRIGGER_REGULAR		(1)			/* For Regular and ReTxBSR Expiry Triggers */
+#define	BSR_TRIGGER_PERIODIC	(2)			/* For BSR Periodic Timer Expiry Trigger */
+#define	BSR_TRIGGER_PADDING		(4)			/* For Padding BSR Trigger */
+
+
+/*! \brief Downlink SCH PDU Structure */
+typedef struct {
+  uint8_t payload[8][SCH_PAYLOAD_SIZE_MAX];
+  uint16_t Pdu_size[8];
+} __attribute__ ((__packed__)) DLSCH_PDU;
+
+
+/*! \brief MCH PDU Structure */
+typedef struct {
+  int8_t payload[SCH_PAYLOAD_SIZE_MAX];
+  uint16_t Pdu_size;
+  uint8_t mcs;
+  uint8_t sync_area;
+  uint8_t msi_active;
+  uint8_t mcch_active;
+  uint8_t mtch_active;
+} __attribute__ ((__packed__)) MCH_PDU;
+
+/*! \brief Uplink SCH PDU Structure */
+typedef struct {
+  int8_t payload[SCH_PAYLOAD_SIZE_MAX];         /*!< \brief SACH payload */
+  uint16_t Pdu_size;
+} __attribute__ ((__packed__)) ULSCH_PDU;
+
+#include "PHY/impl_defs_top.h"
+
+/*!\brief  UE ULSCH scheduling states*/
+typedef enum {
+  S_UL_NONE =0,
+  S_UL_WAITING,
+  S_UL_SCHEDULED,
+  S_UL_BUFFERED,
+  S_UL_NUM_STATUS
+} UE_ULSCH_STATUS;
+
+/*!\brief  UE DLSCH scheduling states*/
+typedef enum {
+  S_DL_NONE =0,
+  S_DL_WAITING,
+  S_DL_SCHEDULED,
+  S_DL_BUFFERED,
+  S_DL_NUM_STATUS
+} UE_DLSCH_STATUS;
+
+/*!\brief  scheduling policy for the contention-based access */
+typedef enum {
+  CBA_ES=0, /// equal share of RB among groups w
+  CBA_ES_S,  /// equal share of RB among groups with small allocation
+  CBA_PF, /// proportional fair (kind of)
+  CBA_PF_S,  /// proportional fair (kind of) with small RB allocation
+  CBA_RS /// random allocation
+} CBA_POLICY;
+
+
+/*! \brief temporary struct for ULSCH sched */
+typedef struct {
+  rnti_t rnti;
+  uint16_t subframe;
+  uint16_t serving_num;
+  UE_ULSCH_STATUS status;
+} eNB_ULSCH_INFO;
+/*! \brief temp struct for DLSCH sched */
+typedef struct {
+  rnti_t rnti;
+  uint16_t weight;
+  uint16_t subframe;
+  uint16_t serving_num;
+  UE_DLSCH_STATUS status;
+} eNB_DLSCH_INFO;
+/*! \brief eNB overall statistics */
+typedef struct {
+  /// num BCCH PDU per CC 
+  uint32_t total_num_bcch_pdu;
+  /// BCCH buffer size  
+  uint32_t bcch_buffer;
+  /// total BCCH buffer size  
+  uint32_t total_bcch_buffer;
+  /// BCCH MCS
+  uint32_t bcch_mcs;
+
+  /// num CCCH PDU per CC 
+  uint32_t total_num_ccch_pdu;
+  /// BCCH buffer size  
+  uint32_t ccch_buffer;
+  /// total BCCH buffer size  
+  uint32_t total_ccch_buffer;
+  /// BCCH MCS
+  uint32_t ccch_mcs;
+
+/// num active users
+  uint16_t num_dlactive_UEs;
+  ///  available number of PRBs for a give SF
+  uint16_t available_prbs;
+  /// total number of PRB available for the user plane
+  uint32_t total_available_prbs;
+  /// aggregation
+  /// total avilable nccc : num control channel element
+  uint16_t available_ncces;
+  // only for a new transmission, should be extended for retransmission
+  // current dlsch  bit rate for all transport channels
+  uint32_t dlsch_bitrate;
+  //
+  uint32_t dlsch_bytes_tx;
+  //
+  uint32_t dlsch_pdus_tx;
+  //
+  uint32_t total_dlsch_bitrate;
+  //
+  uint32_t total_dlsch_bytes_tx;
+  //
+  uint32_t total_dlsch_pdus_tx;
+  
+  // here for RX
+  //
+  uint32_t ulsch_bitrate;
+  //
+  uint32_t ulsch_bytes_rx;
+  //
+  uint64_t ulsch_pdus_rx; 
+
+  uint32_t total_ulsch_bitrate;
+  //
+  uint32_t total_ulsch_bytes_rx;
+  //
+  uint32_t total_ulsch_pdus_rx;
+  
+  
+  /// MAC agent-related stats
+  /// total number of scheduling decisions
+  int sched_decisions;
+  /// missed deadlines
+  int missed_deadlines;
+
+} eNB_STATS;
+/*! \brief eNB statistics for the connected UEs*/
+typedef struct {
+
+  /// CRNTI of UE
+  rnti_t crnti; ///user id (rnti) of connected UEs
+  // rrc status
+  uint8_t rrc_status;
+  /// harq pid
+  uint8_t harq_pid;
+  /// harq rounf
+  uint8_t harq_round;
+  /// total available number of PRBs for a new transmission
+  uint16_t rbs_used;
+  /// total available number of PRBs for a retransmission
+  uint16_t rbs_used_retx;
+  /// total nccc used for a new transmission: num control channel element
+  uint16_t ncce_used;
+  /// total avilable nccc for a retransmission: num control channel element
+  uint16_t ncce_used_retx;
+
+  // mcs1 before the rate adaptaion
+  uint8_t dlsch_mcs1;
+  /// Target mcs2 after rate-adaptation
+  uint8_t dlsch_mcs2;
+  //  current TBS with mcs2
+  uint32_t TBS;
+  //  total TBS with mcs2
+  //  uint32_t total_TBS;
+  //  total rb used for a new transmission
+  uint32_t total_rbs_used;
+  //  total rb used for retransmission
+  uint32_t total_rbs_used_retx;
+
+   /// TX
+  /// Num pkt
+  uint32_t num_pdu_tx[NB_RB_MAX];
+  /// num bytes
+  uint32_t num_bytes_tx[NB_RB_MAX];
+  /// num retransmission / harq
+  uint32_t num_retransmission;
+  /// instantaneous tx throughput for each TTI
+  //  uint32_t tti_throughput[NB_RB_MAX];
+
+  /// overall
+  //
+  uint32_t  dlsch_bitrate;
+  //total
+  uint32_t  total_dlsch_bitrate;
+  /// headers+ CE +  padding bytes for a MAC PDU
+  uint64_t overhead_bytes;
+  /// headers+ CE +  padding bytes for a MAC PDU
+  uint64_t total_overhead_bytes;
+  /// headers+ CE +  padding bytes for a MAC PDU
+  uint64_t avg_overhead_bytes;
+  // MAC multiplexed payload
+  uint64_t total_sdu_bytes;
+  // total MAC pdu bytes
+  uint64_t total_pdu_bytes;
+
+  // total num pdu
+  uint32_t total_num_pdus;
+  //
+  //  uint32_t avg_pdu_size;
+
+  /// RX
+
+  /// PUCCH1a/b power (dBm)
+  int32_t Po_PUCCH_dBm;
+  /// Indicator that Po_PUCCH has been updated by PHY
+  int32_t Po_PUCCH_update;
+  /// Uplink measured RSSI
+  int32_t UL_rssi;
+  /// preassigned mcs after rate adaptation
+  uint8_t ulsch_mcs1;
+  /// adjusted mcs
+  uint8_t ulsch_mcs2;
+
+  /// estimated average pdu inter-departure time
+  uint32_t avg_pdu_idt;
+  /// estimated average pdu size
+  uint32_t avg_pdu_ps;
+  ///
+  uint32_t aggregated_pdu_size;
+  uint32_t aggregated_pdu_arrival;
+
+  ///  uplink transport block size
+  uint32_t ulsch_TBS;
+
+  ///  total rb used for a new uplink transmission
+  uint32_t num_retransmission_rx;
+  ///  total rb used for a new uplink transmission
+  uint32_t rbs_used_rx;
+   ///  total rb used for a new uplink retransmission
+  uint32_t rbs_used_retx_rx;
+  ///  total rb used for a new uplink transmission
+  uint32_t total_rbs_used_rx;
+  /// normalized rx power 
+  int32_t      normalized_rx_power;
+   /// target rx power 
+  int32_t    target_rx_power;
+
+  /// num rx pdu
+  uint32_t num_pdu_rx[NB_RB_MAX];
+  /// num bytes rx
+  uint32_t num_bytes_rx[NB_RB_MAX];
+  /// instantaneous rx throughput for each TTI
+  //  uint32_t tti_goodput[NB_RB_MAX];
+  /// errors
+  uint32_t num_errors_rx;
+  
+  uint64_t overhead_bytes_rx;
+  /// headers+ CE +  padding bytes for a MAC PDU
+  uint64_t total_overhead_bytes_rx;
+  /// headers+ CE +  padding bytes for a MAC PDU
+  uint64_t avg_overhead_bytes_rx;
+ //
+  uint32_t  ulsch_bitrate;
+  //total
+  uint32_t  total_ulsch_bitrate;
+  /// overall
+  ///  MAC pdu bytes
+  uint64_t pdu_bytes_rx;
+  /// total MAC pdu bytes
+  uint64_t total_pdu_bytes_rx;
+  /// total num pdu
+  uint32_t total_num_pdus_rx;
+  /// num of error pdus
+  uint32_t total_num_errors_rx;
+
+} eNB_UE_STATS;
+/*! \brief eNB template for UE context information  */
+typedef struct {
+  /// C-RNTI of UE
+  rnti_t rnti;
+  /// NDI from last scheduling
+  uint8_t oldNDI[8];
+  /// mcs1 from last scheduling
+  uint8_t oldmcs1[8];
+  /// mcs2 from last scheduling
+  uint8_t oldmcs2[8];
+  /// NDI from last UL scheduling
+  uint8_t oldNDI_UL[8];
+  /// mcs from last UL scheduling
+  uint8_t mcs_UL[8];
+  /// TBS from last UL scheduling
+  uint8_t TBS_UL[8];
+  /// CQI_req from last scheduling
+  uint8_t oldCQI_UL[8];
+  /// TPC from last scheduling
+  uint8_t oldTPC_UL[8];
+  /// Flag to indicate UL has been scheduled at least once
+  boolean_t ul_active;
+  /// Flag to indicate UE has been configured (ACK from RRCConnectionSetup received)
+  boolean_t configured;
+
+  /// MCS from last scheduling
+  uint8_t mcs[8];
+
+  /// TPC from last scheduling
+  uint8_t oldTPC[8];
+
+  // PHY interface info
+
+  /// Number of Allocated RBs for DL after scheduling (prior to frequency allocation)
+  uint16_t nb_rb[8]; // num_max_harq
+
+  /// Number of Allocated RBs for UL after scheduling
+  uint16_t nb_rb_ul[8]; // num_max_harq
+
+  /// Number of Allocated RBs for UL after scheduling
+  uint16_t first_rb_ul[8]; // num_max_harq
+
+  /// Cyclic shift for DMRS after scheduling
+  uint16_t cshift[8]; // num_max_harq
+
+  /// Number of Allocated RBs by the ulsch preprocessor
+  uint8_t pre_allocated_nb_rb_ul;
+
+  /// index of Allocated RBs by the ulsch preprocessor
+  int8_t pre_allocated_rb_table_index_ul;
+
+  /// total allocated RBs
+  int8_t total_allocated_rbs;
+
+  /// pre-assigned MCS by the ulsch preprocessor
+  uint8_t pre_assigned_mcs_ul;
+
+  /// assigned MCS by the ulsch scheduler
+  uint8_t assigned_mcs_ul;
+
+  /// DL DAI
+  uint8_t DAI;
+
+  /// UL DAI
+  uint8_t DAI_ul[10];
+
+  /// UL Scheduling Request Received
+  uint8_t ul_SR;
+
+  ///Resource Block indication for each sub-band in MU-MIMO
+  uint8_t rballoc_subband[8][50];
+
+  // Logical channel info for link with RLC
+
+  /// Last received UE BSR info for each logical channel group id
+  uint8_t bsr_info[MAX_NUM_LCGID];
+
+  /// LCGID mapping
+  long lcgidmap[11];
+
+  /// phr information
+  int8_t phr_info;
+
+  /// phr information
+  int8_t phr_info_configured;
+
+  ///dl buffer info
+  uint32_t dl_buffer_info[MAX_NUM_LCID];
+  /// total downlink buffer info
+  uint32_t dl_buffer_total;
+  /// total downlink pdus
+  uint32_t dl_pdus_total;
+  /// downlink pdus for each LCID
+  uint32_t dl_pdus_in_buffer[MAX_NUM_LCID];
+  /// creation time of the downlink buffer head for each LCID
+  uint32_t dl_buffer_head_sdu_creation_time[MAX_NUM_LCID];
+  /// maximum creation time of the downlink buffer head across all LCID
+  uint32_t  dl_buffer_head_sdu_creation_time_max;
+  /// a flag indicating that the downlink head SDU is segmented  
+  uint8_t    dl_buffer_head_sdu_is_segmented[MAX_NUM_LCID];
+  /// size of remaining size to send for the downlink head SDU
+  uint32_t dl_buffer_head_sdu_remaining_size_to_send[MAX_NUM_LCID];
+
+  /// total uplink buffer size 
+  uint32_t ul_total_buffer;
+  /// uplink buffer creation time for each LCID
+  uint32_t ul_buffer_creation_time[MAX_NUM_LCGID];
+  /// maximum uplink buffer creation time across all the LCIDs
+  uint32_t ul_buffer_creation_time_max;
+  /// uplink buffer size per LCID
+  uint32_t ul_buffer_info[MAX_NUM_LCGID];
+
+  /// UE tx power
+  int32_t ue_tx_power;
+
+  /// stores the frame where the last TPC was transmitted
+  uint32_t pusch_tpc_tx_frame;
+  uint32_t pusch_tpc_tx_subframe;
+  uint32_t pucch_tpc_tx_frame;
+  uint32_t pucch_tpc_tx_subframe;
+
+#ifdef LOCALIZATION
+  eNB_UE_estimated_distances distance;
+#endif
+
+#ifdef Rel14
+  uint8_t rach_resource_type;
+
+ uint16_t mpdcch_repetition_cnt;
+  struct PhysicalConfigDedicated  *physicalConfigDedicated;
+  frame_t Msg2_frame;
+  sub_frame_t Msg2_subframe;
+#endif
+} UE_TEMPLATE;
+
+/*! \brief scheduling control information set through an API (not used)*/
+typedef struct {
+  ///UL transmission bandwidth in RBs
+  uint8_t ul_bandwidth[MAX_NUM_LCID];
+  ///DL transmission bandwidth in RBs
+  uint8_t dl_bandwidth[MAX_NUM_LCID];
+
+  //To do GBR bearer
+  uint8_t min_ul_bandwidth[MAX_NUM_LCID];
+
+  uint8_t min_dl_bandwidth[MAX_NUM_LCID];
+
+  ///aggregated bit rate of non-gbr bearer per UE
+  uint64_t  ue_AggregatedMaximumBitrateDL;
+  ///aggregated bit rate of non-gbr bearer per UE
+  uint64_t  ue_AggregatedMaximumBitrateUL;
+  ///CQI scheduling interval in subframes.
+  uint16_t cqiSchedInterval;
+  ///Contention resolution timer used during random access
+  uint8_t mac_ContentionResolutionTimer;
+
+  uint16_t max_allowed_rbs[MAX_NUM_LCID];
+
+  uint8_t max_mcs[MAX_NUM_LCID];
+
+  uint16_t priority[MAX_NUM_LCID];
+
+  // resource scheduling information
+  
+  /// Current DL harq round per harq_pid on each CC
+  uint8_t       round[MAX_NUM_CCs][10];
+  /// Current Active TBs per harq_pid on each CC
+  uint8_t       tbcnt[MAX_NUM_CCs][10];
+  /// Current UL harq round per harq_pid on each CC
+  uint8_t       round_UL[MAX_NUM_CCs][8];
+  uint8_t       dl_pow_off[MAX_NUM_CCs];
+  uint16_t      pre_nb_available_rbs[MAX_NUM_CCs];
+  unsigned char rballoc_sub_UE[MAX_NUM_CCs][N_RBG_MAX];
+  uint16_t      ta_timer;
+  int16_t       ta_update;
+  uint16_t      ul_consecutive_errors;
+  int32_t       context_active_timer;
+  int32_t       cqi_req_timer;
+  int32_t       ul_inactivity_timer;
+  int32_t       ul_failure_timer; 
+  int32_t       ul_scheduled;
+  int32_t       ra_pdcch_order_sent;
+  int32_t       ul_out_of_sync;
+  int32_t       phr_received;
+  uint8_t       periodic_ri_received[NFAPI_CC_MAX];
+  uint8_t       aperiodic_ri_received[NFAPI_CC_MAX];
+  uint32_t      pucch_tpc_accumulated[NFAPI_CC_MAX];
+  uint8_t       pucch1_cqi_update[NFAPI_CC_MAX];
+  uint8_t       pucch1_snr[NFAPI_CC_MAX];
+  uint8_t       pucch2_cqi_update[NFAPI_CC_MAX];
+  uint8_t       pucch2_snr[NFAPI_CC_MAX];
+  uint8_t       pucch3_cqi_update[NFAPI_CC_MAX];
+  uint8_t       pucch3_snr[NFAPI_CC_MAX];
+  uint8_t       pusch_snr[NFAPI_CC_MAX];
+  uint16_t      feedback_cnt[NFAPI_CC_MAX];
+  uint16_t      timing_advance;
+  uint16_t      timing_advance_r9;
+  uint8_t       periodic_wideband_cqi[NFAPI_CC_MAX];
+  uint8_t       periodic_wideband_spatial_diffcqi[NFAPI_CC_MAX];
+  uint8_t       periodic_wideband_pmi[NFAPI_CC_MAX];
+  uint8_t       periodic_subband_cqi[NFAPI_CC_MAX][16];
+  uint8_t       periodic_subband_spatial_diffcqi[NFAPI_CC_MAX][16];
+  uint8_t       aperiodic_subband_cqi0[NFAPI_CC_MAX][25];
+  uint8_t       aperiodic_subband_pmi[NFAPI_CC_MAX][25];
+  uint8_t       aperiodic_subband_diffcqi0[NFAPI_CC_MAX][25];
+  uint8_t       aperiodic_subband_cqi1[NFAPI_CC_MAX][25];
+  uint8_t       aperiodic_subband_diffcqi1[NFAPI_CC_MAX][25];
+  uint8_t       aperiodic_wideband_cqi0[NFAPI_CC_MAX];
+  uint8_t       aperiodic_wideband_pmi[NFAPI_CC_MAX];
+  uint8_t       aperiodic_wideband_cqi1[NFAPI_CC_MAX];
+  uint8_t       aperiodic_wideband_pmi1[NFAPI_CC_MAX];
+  uint8_t       dl_cqi[NFAPI_CC_MAX];
+} UE_sched_ctrl;
+/*! \brief eNB template for the Random access information */
+typedef struct {
+  /// Flag to indicate this process is active
+  boolean_t RA_active;
+  /// Size of DCI for RA-Response (bytes)
+  uint8_t RA_dci_size_bytes1;
+  /// Size of DCI for RA-Response (bits)
+  uint8_t RA_dci_size_bits1;
+  /// Actual DCI to transmit for RA-Response
+  uint8_t RA_alloc_pdu1[(MAX_DCI_SIZE_BITS>>3)+1];
+  /// DCI format for RA-Response (should be 1A)
+  uint8_t RA_dci_fmt1;
+  /// Size of DCI for Msg4/ContRes (bytes)
+  uint8_t RA_dci_size_bytes2;
+  /// Size of DCI for Msg4/ContRes (bits)
+  uint8_t RA_dci_size_bits2;
+  /// Actual DCI to transmit for Msg4/ContRes
+  uint8_t RA_alloc_pdu2[(MAX_DCI_SIZE_BITS>>3)+1];
+  /// DCI format for Msg4/ContRes (should be 1A)
+  uint8_t RA_dci_fmt2;
+  /// Flag to indicate the eNB should generate RAR.  This is triggered by detection of PRACH
+  uint8_t generate_rar;
+  /// Subframe where preamble was received
+  uint8_t preamble_subframe;
+  /// Subframe where Msg2 is to be sent
+  uint8_t Msg2_subframe;
+  /// Frame where Msg2 is to be sent
+  frame_t Msg2_frame;
+  /// Subframe where Msg3 is to be sent
+  sub_frame_t Msg3_subframe;
+  /// Frame where Msg3 is to be sent
+  frame_t Msg3_frame;
+  /// Subframe where Msg4 is to be sent
+  sub_frame_t Msg4_subframe;
+  /// Frame where Msg4 is to be sent
+  frame_t Msg4_frame;
+  /// Flag to indicate the eNB should generate Msg4 upon reception of SDU from RRC.  This is triggered by first ULSCH reception at eNB for new user.
+  uint8_t generate_Msg4;
+  /// Flag to indicate that eNB is waiting for ACK that UE has received Msg3.
+  uint8_t wait_ack_Msg4;
+  /// harq_pid used for Msg4 transmission
+  uint8_t harq_pid;
+  /// UE RNTI allocated during RAR
+  rnti_t rnti;
+  /// RA RNTI allocated from received PRACH
+  uint16_t RA_rnti;
+  /// Received preamble_index
+  uint8_t preamble_index;
+  /// Received UE Contention Resolution Identifier
+  uint8_t cont_res_id[6];
+  /// Timing offset indicated by PHY
+  int16_t timing_offset;
+  /// Timeout for RRC connection
+  int16_t RRC_timer;
+  /// Msg3 first RB
+  uint8_t msg3_first_rb;
+  /// Msg3 number of RB
+  uint8_t msg3_nb_rb;
+  /// Msg3 MCS
+  uint8_t msg3_mcs;
+  /// Msg3 TPC command
+  uint8_t msg3_TPC;
+  /// Msg3 ULdelay command
+  uint8_t msg3_ULdelay;
+  /// Msg3 cqireq command
+  uint8_t msg3_cqireq;
+  /// Round of Msg3 HARQ
+  uint8_t msg3_round;
+  /// TBS used for Msg4
+  int msg4_TBsize;
+  /// MCS used for Msg4
+  int msg4_mcs;
+  /// size off piggybacked RRC SDU
+  uint8_t msg4_rrc_sdu_length;
+  uint32_t msg4_delay;
+
+#ifdef Rel14
+  uint8_t rach_resource_type;
+  uint8_t msg2_mpdcch_repetition_cnt;
+  uint8_t msg2_mpdcch_done;
+  uint8_t msg4_mpdcch_repetition_cnt;
+  uint8_t msg4_mpdcch_done;
+  uint8_t msg2_narrowband;
+  uint32_t msg34_narrowband;
+#endif
+} RA_TEMPLATE;
+
+
+/*! \brief subband bitmap confguration (for ALU icic algo purpose), in test phase */
+typedef struct {
+  uint8_t sbmap[NUMBER_OF_SUBBANDS_MAX]; //13 = number of SB MAX for 100 PRB
+  uint8_t periodicity;
+  uint8_t first_subframe;
+  uint8_t sb_size;
+  uint8_t nb_active_sb;
+} SBMAP_CONF;
+/*! \brief UE list used by eNB to order UEs/CC for scheduling*/ 
+typedef struct {
+  /// Dedicated information for UEs
+  struct PhysicalConfigDedicated  *physicalConfigDedicated[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
+  /// DLSCH pdu 
+  DLSCH_PDU DLSCH_pdu[MAX_NUM_CCs][2][NUMBER_OF_UE_MAX];
+  /// DCI template and MAC connection parameters for UEs
+  UE_TEMPLATE UE_template[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
+  /// DCI template and MAC connection for RA processes
+  int pCC_id[NUMBER_OF_UE_MAX];
+  /// sorted downlink component carrier for the scheduler 
+  int ordered_CCids[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
+  /// number of downlink active component carrier 
+  int numactiveCCs[NUMBER_OF_UE_MAX];
+  /// sorted uplink component carrier for the scheduler 
+  int ordered_ULCCids[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
+  /// number of uplink active component carrier 
+  int numactiveULCCs[NUMBER_OF_UE_MAX];
+  /// number of downlink active component carrier 
+  uint8_t dl_CC_bitmap[NUMBER_OF_UE_MAX];
+  /// eNB to UE statistics
+  eNB_UE_STATS eNB_UE_stats[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
+  /// scheduling control info
+  UE_sched_ctrl UE_sched_ctrl[NUMBER_OF_UE_MAX];
+  int next[NUMBER_OF_UE_MAX];
+  int head;
+  int next_ul[NUMBER_OF_UE_MAX];
+  int head_ul;
+  int avail;
+  int num_UEs;
+  boolean_t active[NUMBER_OF_UE_MAX];
+} UE_list_t;
+
+/*! \brief eNB common channels */ 
+typedef struct {
+  int                              physCellId;
+  int                              p_eNB;
+  int                              Ncp;
+  int                              eutra_band;
+  uint32_t                         dl_CarrierFreq;
+  BCCH_BCH_Message_t               *mib;
+  RadioResourceConfigCommonSIB_t   *radioResourceConfigCommon;
+#ifdef Rel14
+  RadioResourceConfigCommonSIB_t   *radioResourceConfigCommon_BR;  
+#endif
+  TDD_Config_t                     *tdd_Config;
+  SchedulingInfoList_t             *schedulingInfoList;
+  ARFCN_ValueEUTRA_t               ul_CarrierFreq;
+  long                             ul_Bandwidth;
+  /// Outgoing MIB PDU for PHY
+  MIB_PDU MIB_pdu;
+  /// Outgoing BCCH pdu for PHY
+  BCCH_PDU BCCH_pdu;
+  /// Outgoing BCCH DCI allocation
+  uint32_t BCCH_alloc_pdu;
+  /// Outgoing CCCH pdu for PHY
+  CCCH_PDU CCCH_pdu;
+  /// Outgoing RAR pdu for PHY
+  RAR_PDU RAR_pdu;
+  /// Template for RA computations
+  RA_TEMPLATE RA_template[NB_RA_PROC_MAX];
+  /// VRB map for common channels
+  uint8_t vrb_map[100];
+  /// VRB map for common channels and retransmissions by PHICH
+  uint8_t vrb_map_UL[100];
+  /// MBSFN SubframeConfig
+  struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[8];
+  /// number of subframe allocation pattern available for MBSFN sync area
+  uint8_t num_sf_allocation_pattern;
+#if defined(Rel10) || defined(Rel14)
+  /// MBMS Flag
+  uint8_t MBMS_flag;
+  /// Outgoing MCCH pdu for PHY
+  MCCH_PDU MCCH_pdu;
+  /// MCCH active flag
+  uint8_t msi_active;
+  /// MCCH active flag
+  uint8_t mcch_active;
+  /// MTCH active flag
+  uint8_t mtch_active;
+  /// number of active MBSFN area
+  uint8_t num_active_mbsfn_area;
+  /// MBSFN Area Info
+  struct  MBSFN_AreaInfo_r9 *mbsfn_AreaInfo[MAX_MBSFN_AREA];
+  /// PMCH Config
+  struct PMCH_Config_r9 *pmch_Config[MAX_PMCH_perMBSFN];
+  /// MBMS session info list
+  struct MBMS_SessionInfoList_r9 *mbms_SessionList[MAX_PMCH_perMBSFN];
+  /// Outgoing MCH pdu for PHY
+  MCH_PDU MCH_pdu;
+#endif
+#ifdef Rel14
+  /// Rel13 parameters from SIB1
+  SystemInformationBlockType1_v1310_IEs_t *sib1_v13ext;
+  /// Counter for SIB1-BR scheduling
+  int SIB1_BR_cnt;
+  /// Outgoing BCCH-BR pdu for PHY
+  BCCH_PDU BCCH_BR_pdu[20];
+#endif
+} COMMON_channels_t;
+/*! \brief top level eNB MAC structure */ 
+typedef struct eNB_MAC_INST_s {
+  /// Ethernet parameters for northbound midhaul interface
+  eth_params_t         eth_params_n;
+  /// Ethernet parameters for fronthaul interface
+  eth_params_t         eth_params_s;
+  ///
+  module_id_t Mod_id;
+  /// frame counter
+  frame_t frame;
+  /// subframe counter
+  sub_frame_t subframe;
+  /// Pointer to IF module instance for PHY
+  IF_Module_t *if_inst;
+  /// Common cell resources
+  COMMON_channels_t common_channels[MAX_NUM_CCs];
+  /// current PDU index (BCH,MCH,DLSCH)
+  uint16_t pdu_index[MAX_NUM_CCs];
+
+  /// NFAPI Config Request Structure
+  nfapi_config_request_t config[MAX_NUM_CCs];
+  /// Preallocated DL pdu list
+  nfapi_dl_config_request_pdu_t dl_config_pdu_list[MAX_NUM_CCs][MAX_NUM_DL_PDU];
+  /// NFAPI DL Config Request Structure
+  nfapi_dl_config_request_t DL_req[MAX_NUM_CCs];
+  /// Preallocated UL pdu list
+  nfapi_ul_config_request_pdu_t ul_config_pdu_list[MAX_NUM_CCs][MAX_NUM_UL_PDU];
+  /// Preallocated UL pdu list for ULSCH (n+k delay)
+  nfapi_ul_config_request_pdu_t ul_config_pdu_list_tmp[MAX_NUM_CCs][10][MAX_NUM_UL_PDU];
+  /// NFAPI UL Config Request Structure, send to L1 4 subframes before processing takes place
+  nfapi_ul_config_request_t UL_req[MAX_NUM_CCs];
+  /// NFAPI "Temporary" UL Config Request Structure, holds future UL_config requests
+  nfapi_ul_config_request_t UL_req_tmp[MAX_NUM_CCs][10];
+  /// Preallocated HI_DCI0 pdu list 
+  nfapi_hi_dci0_request_pdu_t hi_dci0_pdu_list[MAX_NUM_CCs][MAX_NUM_HI_DCI0_PDU];
+  /// NFAPI HI/DCI0 Config Request Structure
+  nfapi_hi_dci0_request_t HI_DCI0_req[MAX_NUM_CCs];
+  /// Prealocated TX pdu list
+  nfapi_tx_request_pdu_t tx_request_pdu[MAX_NUM_CCs][MAX_NUM_TX_REQUEST_PDU];
+  /// NFAPI DL PDU structure
+  nfapi_tx_request_t TX_req[MAX_NUM_CCs];
+  /// UL handle
+  uint32_t ul_handle;
+  UE_list_t UE_list;
+
+  ///subband bitmap configuration
+  SBMAP_CONF sbmap_conf;
+  /// CCE table used to build DCI scheduling information
+  int CCE_table[MAX_NUM_CCs][800];
+  ///  active flag for Other lcid
+  uint8_t lcid_active[NB_RB_MAX];
+  /// eNB stats
+  eNB_STATS eNB_stats[MAX_NUM_CCs];
+  // MAC function execution peformance profiler
+  /// processing time of eNB scheduler 
+  time_stats_t eNB_scheduler;
+  /// processing time of eNB scheduler for SI 
+  time_stats_t schedule_si;
+  /// processing time of eNB scheduler for Random access
+  time_stats_t schedule_ra;
+  /// processing time of eNB ULSCH scheduler 
+  time_stats_t schedule_ulsch;
+  /// processing time of eNB DCI generation
+  time_stats_t fill_DLSCH_dci;
+  /// processing time of eNB MAC preprocessor
+  time_stats_t schedule_dlsch_preprocessor;
+  /// processing time of eNB DLSCH scheduler 
+  time_stats_t schedule_dlsch; // include rlc_data_req + MAC header + preprocessor
+  /// processing time of eNB MCH scheduler 
+  time_stats_t schedule_mch;
+  /// processing time of eNB ULSCH reception
+  time_stats_t rx_ulsch_sdu; // include rlc_data_ind
+} eNB_MAC_INST;
+
+/* 
+ * UE part 
+ */ 
+
+typedef enum {
+  TYPE0,
+  TYPE1,
+  TYPE1A,
+  TYPE2,
+  TYPE2A,
+  TYPEUESPEC
+} MPDCCH_TYPES_t;
+
+/*!\brief UE layer 2 status */
+typedef enum {
+  CONNECTION_OK=0,
+  CONNECTION_LOST,
+  PHY_RESYNCH,
+  PHY_HO_PRACH
+} UE_L2_STATE_t;
+
+/*!\brief UE scheduling info */
+typedef struct {
+  /// buffer status for each lcgid
+  uint8_t  BSR[MAX_NUM_LCGID]; // should be more for mesh topology
+  /// keep the number of bytes in rlc buffer for each lcgid
+  int32_t  BSR_bytes[MAX_NUM_LCGID];
+  /// after multiplexing buffer remain for each lcid
+  int32_t  LCID_buffer_remain[MAX_NUM_LCID];
+  /// sum of all lcid buffer size
+  uint16_t  All_lcid_buffer_size_lastTTI;
+  /// buffer status for each lcid
+  uint8_t  LCID_status[MAX_NUM_LCID];
+  /// SR pending as defined in 36.321
+  uint8_t  SR_pending;
+  /// SR_COUNTER as defined in 36.321
+  uint16_t SR_COUNTER;
+  /// logical channel group ide for each LCID
+  uint8_t  LCGID[MAX_NUM_LCID];
+  /// retxBSR-Timer, default value is sf2560
+  uint16_t retxBSR_Timer;
+  /// retxBSR_SF, number of subframe before triggering a regular BSR
+  uint16_t retxBSR_SF;
+  /// periodicBSR-Timer, default to infinity
+  uint16_t periodicBSR_Timer;
+  /// periodicBSR_SF, number of subframe before triggering a periodic BSR
+  uint16_t periodicBSR_SF;
+  /// default value is 0: not configured
+  uint16_t sr_ProhibitTimer;
+  /// sr ProhibitTime running
+  uint8_t sr_ProhibitTimer_Running;
+  ///  default value to n5
+  uint16_t maxHARQ_Tx;
+  /// default value is false
+  uint16_t ttiBundling;
+  /// default value is release
+  struct DRX_Config *drx_config;
+  /// default value is release
+  struct MAC_MainConfig__phr_Config *phr_config;
+  ///timer before triggering a periodic PHR
+  uint16_t periodicPHR_Timer;
+  ///timer before triggering a prohibit PHR
+  uint16_t prohibitPHR_Timer;
+  ///DL Pathloss change value
+  uint16_t PathlossChange;
+  ///number of subframe before triggering a periodic PHR
+  int16_t periodicPHR_SF;
+  ///number of subframe before triggering a prohibit PHR
+  int16_t prohibitPHR_SF;
+  ///DL Pathloss Change in db
+  uint16_t PathlossChange_db;
+
+  /// default value is false
+  uint16_t extendedBSR_Sizes_r10;
+  /// default value is false
+  uint16_t extendedPHR_r10;
+
+  //Bj bucket usage per  lcid
+  int16_t Bj[MAX_NUM_LCID];
+  // Bucket size per lcid
+  int16_t bucket_size[MAX_NUM_LCID];
+} UE_SCHEDULING_INFO;
+/*!\brief Top level UE MAC structure */
+typedef struct {
+  uint16_t Node_id;
+  /// RX frame counter
+  frame_t     rxFrame;
+  /// RX subframe counter
+  sub_frame_t rxSubframe;
+  /// TX frame counter
+  frame_t     txFrame;
+  /// TX subframe counter
+  sub_frame_t txSubframe;
+  /// C-RNTI of UE
+  uint16_t crnti;
+  /// C-RNTI of UE before HO
+  rnti_t crnti_before_ho; ///user id (rnti) of connected UEs
+  /// uplink active flag
+  uint8_t ul_active;
+  /// pointer to RRC PHY configuration
+  RadioResourceConfigCommonSIB_t *radioResourceConfigCommon;
+  /// pointer to RACH_ConfigDedicated (NULL when not active, i.e. upon HO completion or T304 expiry)
+  struct RACH_ConfigDedicated *rach_ConfigDedicated;
+  /// pointer to RRC PHY configuration
+  struct PhysicalConfigDedicated *physicalConfigDedicated;
+#if defined(Rel10) || defined(Rel14)
+  /// pointer to RRC PHY configuration SCEll
+  struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10;
+#endif
+  /// pointer to TDD Configuration (NULL for FDD)
+  TDD_Config_t *tdd_Config;
+  /// Number of adjacent cells to measure
+  uint8_t  n_adj_cells;
+  /// Array of adjacent physical cell ids
+  uint32_t adj_cell_id[6];
+  /// Pointer to RRC MAC configuration
+  MAC_MainConfig_t *macConfig;
+  /// Pointer to RRC Measurement gap configuration
+  MeasGapConfig_t  *measGapConfig;
+  /// Pointers to LogicalChannelConfig indexed by LogicalChannelIdentity. Note NULL means LCHAN is inactive.
+  LogicalChannelConfig_t *logicalChannelConfig[MAX_NUM_LCID];
+  /// Scheduling Information
+  UE_SCHEDULING_INFO scheduling_info;
+  /// Outgoing CCCH pdu for PHY
+  CCCH_PDU CCCH_pdu;
+  /// Outgoing RAR pdu for PHY
+  RAR_PDU RAR_pdu;
+  /// Incoming DLSCH pdu for PHY
+  DLSCH_PDU DLSCH_pdu[NUMBER_OF_UE_MAX][2];
+  /// number of attempt for rach
+  uint8_t RA_attempt_number;
+  /// Random-access procedure flag
+  uint8_t RA_active;
+  /// Random-access window counter
+  int8_t RA_window_cnt;
+  /// Random-access Msg3 size in bytes
+  uint8_t RA_Msg3_size;
+  /// Random-access prachMaskIndex
+  uint8_t RA_prachMaskIndex;
+  /// Flag indicating Preamble set (A,B) used for first Msg3 transmission
+  uint8_t RA_usedGroupA;
+  /// Random-access Resources
+  PRACH_RESOURCES_t RA_prach_resources;
+  /// Random-access PREAMBLE_TRANSMISSION_COUNTER
+  uint8_t RA_PREAMBLE_TRANSMISSION_COUNTER;
+  /// Random-access backoff counter
+  int16_t RA_backoff_cnt;
+  /// Random-access variable for window calculation (frame of last change in window counter)
+  uint32_t RA_tx_frame;
+  /// Random-access variable for window calculation (subframe of last change in window counter)
+  uint8_t RA_tx_subframe;
+  /// Random-access Group B maximum path-loss
+  /// Random-access variable for backoff (frame of last change in backoff counter)
+  uint32_t RA_backoff_frame;
+  /// Random-access variable for backoff (subframe of last change in backoff counter)
+  uint8_t RA_backoff_subframe;
+  /// Random-access Group B maximum path-loss
+  uint16_t RA_maxPL;
+  /// Random-access Contention Resolution Timer active flag
+  uint8_t RA_contention_resolution_timer_active;
+  /// Random-access Contention Resolution Timer count value
+  uint8_t RA_contention_resolution_cnt;
+  /// power headroom reporitng reconfigured
+  uint8_t PHR_reconfigured;
+  /// power headroom state as configured by the higher layers
+  uint8_t PHR_state;
+  /// power backoff due to power management (as allowed by P-MPRc) for this cell
+  uint8_t PHR_reporting_active;
+  /// power backoff due to power management (as allowed by P-MPRc) for this cell
+  uint8_t power_backoff_db[NUMBER_OF_eNB_MAX];
+  /// BSR report falg management
+  uint8_t BSR_reporting_active;
+  /// retxBSR-Timer expires flag
+  uint8_t retxBSRTimer_expires_flag;
+  /// periodBSR-Timer expires flag
+  uint8_t periodBSRTimer_expires_flag;
+
+  /// MBSFN_Subframe Configuration
+  struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[8]; // FIXME replace 8 by MAX_MBSFN_AREA?
+  /// number of subframe allocation pattern available for MBSFN sync area
+  uint8_t num_sf_allocation_pattern;
+#if defined(Rel10) || defined(Rel14)
+  /// number of active MBSFN area
+  uint8_t num_active_mbsfn_area;
+  /// MBSFN Area Info
+  struct  MBSFN_AreaInfo_r9 *mbsfn_AreaInfo[MAX_MBSFN_AREA];
+  /// PMCH Config
+  struct PMCH_Config_r9 *pmch_Config[MAX_PMCH_perMBSFN];
+  /// MCCH status
+  uint8_t mcch_status;
+  /// MSI status
+  uint8_t msi_status;// could be an array if there are >1 MCH in one MBSFN area
+#endif
+  //#ifdef CBA
+  /// CBA RNTI for each group 
+  uint16_t cba_rnti[NUM_MAX_CBA_GROUP];
+  /// last SFN for CBA channel access 
+  uint8_t cba_last_access[NUM_MAX_CBA_GROUP];
+  //#endif
+  /// total UE scheduler processing time 
+  time_stats_t ue_scheduler; // total
+  /// UE ULSCH tx  processing time inlcuding RLC interface (rlc_data_req) and mac header generation 
+  time_stats_t tx_ulsch_sdu;  
+  /// UE DLSCH rx  processing time inlcuding RLC interface (mac_rrc_data_ind or mac_rlc_status_ind+mac_rlc_data_ind) and mac header parser
+  time_stats_t rx_dlsch_sdu ; 
+  /// UE query for MCH subframe processing time 
+  time_stats_t ue_query_mch;
+  /// UE MCH rx processing time 
+  time_stats_t rx_mch_sdu;
+  /// UE BCCH rx processing time including RLC interface (mac_rrc_data_ind) 
+  time_stats_t rx_si; 
+  /// UE PCCH rx processing time including RLC interface (mac_rrc_data_ind) 
+  time_stats_t rx_p; 
+} UE_MAC_INST;
+/*! \brief ID of the neighboring cells used for HO*/
+typedef struct {
+  uint16_t cell_ids[6];
+  uint8_t n_adj_cells;
+} neigh_cell_id_t;
+
+#include "proto.h"
+/*@}*/
+#endif /*__LAYER2_MAC_DEFS_H__ */
+
+
+
diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c
index 8648fa57714c3b33c03041f053414235dba412c2..4ebe7313e8764d2658382b6a7445c938a6c6b5f5 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler.c
@@ -443,6 +443,7 @@ clear_nfapi_information(eNB_MAC_INST * eNB, int CC_idP,
     DL_req[CC_idP].dl_config_request_body.number_pdu                          = 0;
     DL_req[CC_idP].dl_config_request_body.number_pdsch_rnti                   = 0;
     DL_req[CC_idP].dl_config_request_body.transmission_power_pcfich           = 6000;
+    DL_req[CC_idP].sfn_sf                                                     = subframeP + (frameP<<4);
 
     HI_DCI0_req->hi_dci0_request_body.sfnsf                                   = subframeP + (frameP<<4);
     HI_DCI0_req->hi_dci0_request_body.number_of_dci                           = 0;
@@ -657,7 +658,6 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP,
   }
 
   // This schedules MIB
-
   if ((subframeP == 0) && (frameP & 3) == 0)
       schedule_mib(module_idP, frameP, subframeP);
   if (get_softmodem_params()->phy_test == 0){
@@ -681,6 +681,10 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP,
     schedule_SR(module_idP, frameP, subframeP);
     // This schedules UCI_CSI in subframeP
     schedule_CSI(module_idP, frameP, subframeP);
+#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+    // This schedules DLSCH in subframeP
+    schedule_ue_spec_br(module_idP,frameP,subframeP);
+#endif
     // This schedules DLSCH in subframeP
     if (schedule_ue_spec_p != NULL) {
        schedule_ue_spec_p(module_idP, frameP, subframeP, mbsfn_status);
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c
index fc954c5050aac46a01afb9d173efa8084b466bb8..23b709f58e607df84b1880f916c82a94ac096a26 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c
@@ -121,53 +121,40 @@ add_msg3(module_id_t module_idP, int CC_id, RA_t * ra, frame_t frameP,
 		ra->rnti);
 
 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
-    if (ra->rach_resource_type > 0) {
-	LOG_D(MAC,
-	      "[eNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d CE level %d is active, Msg3 in (%d,%d)\n",
-	      module_idP, frameP, subframeP, CC_id,
-	      ra->rach_resource_type - 1, ra->Msg3_frame,
-	      ra->Msg3_subframe);
-	LOG_D(MAC,
-	      "Frame %d, Subframe %d Adding Msg3 UL Config Request for (%d,%d) : (%d,%d)\n",
-	      frameP, subframeP, ra->Msg3_frame, ra->Msg3_subframe,
-	      ra->msg3_nb_rb, ra->msg3_round);
-
-	ul_config_pdu =
-	    &ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus];
-
-	memset((void *) ul_config_pdu, 0,
-	       sizeof(nfapi_ul_config_request_pdu_t));
-	ul_config_pdu->pdu_type                                                = NFAPI_UL_CONFIG_ULSCH_PDU_TYPE;
-	ul_config_pdu->pdu_size                                                = (uint8_t) (2 + sizeof(nfapi_ul_config_ulsch_pdu));
-	ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.handle                         = mac->ul_handle++;
-        ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.tl.tag                         = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL8_TAG;
-	ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti                           = ra->rnti;
-	ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.resource_block_start           = narrowband_to_first_rb(cc,
-													ra->msg34_narrowband) + ra->msg3_first_rb;
-	ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.number_of_resource_blocks      = ra->msg3_nb_rb;
-	ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.modulation_type                = 2;
-	ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.cyclic_shift_2_for_drms        = 0;
-	ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_enabled_flag = 0;
-	ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_bits         = 0;
-	ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.new_data_indication            = 0;
-	ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.redundancy_version             = rvseq[ra->msg3_round];
-	ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.harq_process_number            = ((10 * ra->Msg3_frame) + ra->Msg3_subframe) & 7;
-	ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.ul_tx_mode                     = 0;
-	ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.current_tx_nb                  = 0;
-	ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.n_srs                          = 1;
-	ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.size                           = get_TBS_UL(ra->msg3_mcs, ra->msg3_nb_rb);
-	// Re13 fields
-        ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.tl.tag                        = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL13_TAG;
-	ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.ue_type                       = ra->rach_resource_type > 2 ? 2 : 1;
-	ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.total_number_of_repetitions   = 1;
-	ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.repetition_number             = 1;
-	ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.initial_transmission_sf_io    = (ra->Msg3_frame * 10) + ra->Msg3_subframe;
-	ul_req_body->number_of_pdus++;
-        ul_req_body->tl.tag                                                    = NFAPI_UL_CONFIG_REQUEST_BODY_TAG;
-        ul_req->sfn_sf                                                         = ra->Msg3_frame<<4|ra->Msg3_subframe;
-        ul_req->header.message_id                                              = NFAPI_UL_CONFIG_REQUEST;
-    }				//  if (ra->rach_resource_type>0) {  
-    else
+  if (ra->rach_resource_type > 0) {
+    LOG_I (MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d CE level %d is active, Msg3 in (%d,%d)\n",
+           module_idP, frameP, subframeP, CC_id, ra->rach_resource_type - 1, ra->Msg3_frame, ra->Msg3_subframe);
+    LOG_I (MAC, "Frame %d, Subframe %d Adding Msg3 UL Config Request for (%d,%d) : (%d,%d)\n",
+           frameP, subframeP, ra->Msg3_frame, ra->Msg3_subframe, ra->msg3_nb_rb, ra->msg3_round);
+
+    ul_config_pdu = &ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus];
+
+    memset ((void *) ul_config_pdu, 0, sizeof (nfapi_ul_config_request_pdu_t));
+    ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_ULSCH_PDU_TYPE;
+    ul_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_ul_config_ulsch_pdu));
+    ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.handle = mac->ul_handle++;
+    ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti = ra->rnti;
+    ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.resource_block_start = narrowband_to_first_rb (cc, ra->msg34_narrowband) + ra->msg3_first_rb;
+    ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.number_of_resource_blocks = ra->msg3_nb_rb;
+    ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.modulation_type = 2;
+    ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.cyclic_shift_2_for_drms = 0;
+    ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_enabled_flag = 0;
+    ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_bits = 0;
+    ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.new_data_indication = 0;
+    ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.redundancy_version = rvseq[ra->msg3_round];
+    ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.harq_process_number = 0;
+    ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.ul_tx_mode = 0;
+    ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.current_tx_nb = 0;
+    ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.n_srs = 1;
+    ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.size = get_TBS_UL (ra->msg3_mcs, ra->msg3_nb_rb);
+    // Re13 fields
+    ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.ue_type = ra->rach_resource_type > 2 ? 2 : 1;
+    ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.total_number_of_repetitions = 1;
+    ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.repetition_number = 1;
+    ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.initial_transmission_sf_io = (ra->Msg3_frame * 10) + ra->Msg3_subframe;
+    ul_req_body->number_of_pdus++;
+  }                             //  if (ra->rach_resource_type>0) {         
+  else
 #endif
     {
 	LOG_D(MAC,
@@ -257,247 +244,224 @@ generate_Msg2(module_id_t module_idP, int CC_idP, frame_t frameP,
 	      sub_frame_t subframeP, RA_t * ra)
 {
 
-    eNB_MAC_INST *mac = RC.mac[module_idP];
-    COMMON_channels_t *cc = mac->common_channels;
-
-    uint8_t *vrb_map;
-    int first_rb;
-    int N_RB_DL;
-    nfapi_dl_config_request_pdu_t *dl_config_pdu;
-    nfapi_tx_request_pdu_t *TX_req;
-    nfapi_dl_config_request_body_t *dl_req;
-
-    vrb_map = cc[CC_idP].vrb_map;
-    dl_req = &mac->DL_req[CC_idP].dl_config_request_body;
-    dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
-    N_RB_DL = to_prb(cc[CC_idP].mib->message.dl_Bandwidth);
 
+  eNB_MAC_INST *mac = RC.mac[module_idP];
+  COMMON_channels_t *cc = mac->common_channels;
+  
+  uint8_t *vrb_map;
+  int first_rb;
+  int N_RB_DL;
+  nfapi_dl_config_request_pdu_t *dl_config_pdu;
+  nfapi_tx_request_pdu_t *TX_req;
+  nfapi_dl_config_request_body_t *dl_req_body;
+  
+  vrb_map = cc[CC_idP].vrb_map;
+  dl_req_body = &mac->DL_req[CC_idP].dl_config_request_body;
+  dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu];
+  N_RB_DL = to_prb(cc[CC_idP].mib->message.dl_Bandwidth);
+  
 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
-    int rmax = 0;
-    int rep = 0;
-    int reps = 0;
-    int num_nb = 0;
-
-    first_rb = 0;
-    struct LTE_PRACH_ConfigSIB_v1310 *ext4_prach;
-    LTE_PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13;
-    LTE_PRACH_ParametersCE_r13_t *p[4] = { NULL, NULL, NULL, NULL };
-
-    uint16_t absSF = (10 * frameP) + subframeP;
-    uint16_t absSF_Msg2 = (10 * ra->Msg2_frame) + ra->Msg2_subframe;
-
-    LOG_D(MAC,"absSF:%d absSF_Msg2:%d ra->rach_resource_type:%d\n",absSF,absSF_Msg2,ra->rach_resource_type);
-
-    if (absSF < absSF_Msg2)
-	return;			// we're not ready yet, need to be to start ==  
-
-    if (cc[CC_idP].radioResourceConfigCommon_BR) {
-
-	ext4_prach                 = cc[CC_idP].radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310;
-	prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13;
-
-	switch (prach_ParametersListCE_r13->list.count) {
-	case 4:
-	    p[3] = prach_ParametersListCE_r13->list.array[3];
-	case 3:
-	    p[2] = prach_ParametersListCE_r13->list.array[2];
-	case 2:
-	    p[1] = prach_ParametersListCE_r13->list.array[1];
-	case 1:
-	    p[0] = prach_ParametersListCE_r13->list.array[0];
-	    break;
-	default:
-	    AssertFatal(1 == 0,
-			"Illegal count for prach_ParametersListCE_r13 %d\n",
-			(int) prach_ParametersListCE_r13->list.count);
-	    break;
-	}
-    }
+  int             rmax = 0;
+  int             rep = 0;
+  int             reps = 0;
+  int             num_nb = 0;
+
+  first_rb = 0;
+  struct LTE_PRACH_ConfigSIB_v1310 *ext4_prach;
+  LTE_PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13;
+  LTE_PRACH_ParametersCE_r13_t *p[4] = { NULL, NULL, NULL, NULL };
+
+  uint16_t        absSF = (10 * frameP) + subframeP;
+  uint16_t        absSF_Msg2 = (10 * ra->Msg2_frame) + ra->Msg2_subframe;
+
+  if (absSF > absSF_Msg2)
+    return;                     // we're not ready yet, need to be to start ==  
+
+  if (cc[CC_idP].mib->message.schedulingInfoSIB1_BR_r13 > 0 && 
+      cc[CC_idP].radioResourceConfigCommon_BR) {
+
+    ext4_prach = cc[CC_idP].radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310;
+    prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13;
+
+    switch (prach_ParametersListCE_r13->list.count) {
+    case 4:
+      p[3] = prach_ParametersListCE_r13->list.array[3];
+    case 3:
+      p[2] = prach_ParametersListCE_r13->list.array[2];
+    case 2:
+      p[1] = prach_ParametersListCE_r13->list.array[1];
+    case 1:
+      p[0] = prach_ParametersListCE_r13->list.array[0];
+      break;
+    default:
+      AssertFatal (1 == 0, "Illegal count for prach_ParametersListCE_r13 %d\n", (int) prach_ParametersListCE_r13->list.count);
+      break;
 
-    if (ra->rach_resource_type > 0) {
-
-	// This uses an MPDCCH Type 2 common allocation according to Section 9.1.5 36-213
-	// Parameters:
-	//    p=2+4 PRB set (number of PRB pairs 3)
-	//    rmax = mpdcch-NumRepetition-RA-r13 => Table 9.1.5-3
-	//    if CELevel = 0,1 => Table 9.1.5-1b for MPDCCH candidates
-	//    if CELevel = 2,3 => Table 9.1.5-2b for MPDCCH candidates
-	//    distributed transmission
-
-	// rmax from SIB2 information
-	AssertFatal(rmax < 9, "rmax>8!\n");
-	rmax = 1 << p[ra->rach_resource_type-1]->mpdcch_NumRepetition_RA_r13;
-	// choose r1 by default for RAR (Table 9.1.5-5)
-	rep = 0;
-	// get actual repetition count from Table 9.1.5-3
-	reps = (rmax <= 8) ? (1 << rep) : (rmax >> (3 - rep));
-	// get narrowband according to higher-layer config 
-	num_nb = p[ra->rach_resource_type-1]->mpdcch_NarrowbandsToMonitor_r13.list.count;
-	ra->msg2_narrowband = *p[ra->rach_resource_type - 1]->mpdcch_NarrowbandsToMonitor_r13.list.array[ra->preamble_index % num_nb];
-	first_rb = narrowband_to_first_rb(&cc[CC_idP], ra->msg2_narrowband);
-
-	if ((ra->msg2_mpdcch_repetition_cnt == 0) &&
-	    (mpdcch_sf_condition(mac, CC_idP, frameP, subframeP, rmax, TYPE2, -1) > 0)) {
-	    // MPDCCH configuration for RAR
-	    LOG_D(MAC,
-		  "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, Programming MPDCCH %d repetitions\n",
-		  module_idP, frameP, subframeP, reps);
-
-
-	    memset((void *) dl_config_pdu, 0,sizeof(nfapi_dl_config_request_pdu_t));
-	    dl_config_pdu->pdu_type                                                                  = NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE;
-	    dl_config_pdu->pdu_size                                                                  = (uint8_t) (2 + sizeof(nfapi_dl_config_mpdcch_pdu));
-            dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tl.tag                                        = NFAPI_DL_CONFIG_REQUEST_MPDCCH_PDU_REL13_TAG;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_format                                    = (ra->rach_resource_type > 1) ? 11 : 10;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_narrow_band                            = ra->msg2_narrowband;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_prb_pairs                           = 6;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_assignment                     = 0;	// Note: this can be dynamic
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_tansmission_type                       = 1;	// imposed (9.1.5 in 213) for Type 2 Common search space  
-	    AssertFatal(cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13!= NULL,
-			"cc[CC_id].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13 is null\n");
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.start_symbol                                  = cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ecce_index                                    = 0;	// Note: this should be dynamic
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.aggregation_level                             = 16;	// OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti_type                                     = 2;	// RA-RNTI
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti                                          = ra->RA_rnti;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ce_mode                                       = (ra->rach_resource_type < 3) ? 1 : 2;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.drms_scrambling_init                          = cc[CC_idP].physCellId;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.initial_transmission_sf_io                    = (frameP * 10) + subframeP;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.transmission_power                            = 6000;	// 0dB
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_coding                         = getRIV(6, 0, 6);	// Note: still to be checked if it should not be (getRIV(N_RB_DL,first_rb,6)) : Check nFAPI specifications and what is done L1 with this parameter
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs = 4;	// adjust according to size of RAR, 208 bits with N1A_PRB=3
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pdsch_reptition_levels                        = 4;	// fix to 4 for now
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.redundancy_version                            = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.new_data_indicator                            = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_process                                  = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi_length                                   = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi                                          = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi_flag                                      = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi                                           = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_resource_offset                          = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_subframe_repetition_number                = rep;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpc                                           = 1;	// N1A_PRB=3 (36.212); => 208 bits for mcs=4, choose mcs according t message size TBD
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index_length              = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index                     = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.allocate_prach_flag                           = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.preamble_index                                = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.prach_mask_index                              = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.starting_ce_level                             = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.srs_request                                   = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity_flag    = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity         = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.frequency_hopping_enabled_flag                = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.paging_direct_indication_differentiation_flag = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.direct_indication                             = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding            = 0;	// this is not needed by OAI L1, but should be filled in
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports                    = 1;
-	    ra->msg2_mpdcch_repetition_cnt++;
-	    dl_req->number_pdu++;
-            dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG;
-	    ra->Msg2_subframe = (ra->Msg2_subframe + 9) % 10;
-
-            mac->DL_req[CC_idP].sfn_sf = sfnsf_add_subframe(ra->Msg2_frame, ra->Msg2_subframe, 4);	// nFAPI is runnning at TX SFN/SF - ie 4 ahead
-            mac->DL_req[CC_idP].header.message_id = NFAPI_DL_CONFIG_REQUEST;
-	}			//repetition_count==0 && SF condition met
-	if (ra->msg2_mpdcch_repetition_cnt > 0) {	// we're in a stream of repetitions
-	    LOG_D(MAC,
-		  "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, MPDCCH repetition %d\n",
-		  module_idP, frameP, subframeP,
-		  ra->msg2_mpdcch_repetition_cnt);
-
-	    if (ra->msg2_mpdcch_repetition_cnt == reps) {	// this is the last mpdcch repetition
-		if (cc[CC_idP].tdd_Config == NULL) {	// FDD case
-		    // wait 2 subframes for PDSCH transmission
-		    if (subframeP > 7)
-			ra->Msg2_frame = (frameP + 1) & 1023;
-		    else
-			ra->Msg2_frame = frameP;
-		    ra->Msg2_subframe = (subframeP + 2) % 10;	// +2 is the "n+x" from Section 7.1.11  in 36.213
-		} else {
-		    AssertFatal(1 == 0, "TDD case not done yet\n");
-		}
-	    }			// mpdcch_repetition_count == reps
-	    ra->msg2_mpdcch_repetition_cnt++;
+    }
+  }
 
-	    if ((ra->Msg2_frame == frameP)
-		&& (ra->Msg2_subframe == subframeP)) {
-		// Program PDSCH
-		LOG_D(MAC,
-		      "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, Programming PDSCH\n",
-		      module_idP, frameP, subframeP);
-		ra->state = WAITMSG3;
-                LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d: state:WAITMSG3\n", module_idP, frameP, subframeP);
+  if (ra->rach_resource_type > 0) {
+
+    // This uses an MPDCCH Type 2 common allocation according to Section 9.1.5 36-213
+    // Parameters:
+    //    p=2+4 PRB set (number of PRB pairs 3)
+    //    rmax = mpdcch-NumRepetition-RA-r13 => Table 9.1.5-3
+    //    if CELevel = 0,1 => Table 9.1.5-1b for MPDCCH candidates
+    //    if CELevel = 2,3 => Table 9.1.5-2b for MPDCCH candidates
+    //    distributed transmission
+
+    // rmax from SIB2 information
+    AssertFatal (rmax < 9, "rmax>8!\n");
+    rmax = 1 << p[ra->rach_resource_type - 1]->mpdcch_NumRepetition_RA_r13;
+    // choose r1 by default for RAR (Table 9.1.5-5)
+    rep = 0;
+    // get actual repetition count from Table 9.1.5-3
+    reps = (rmax <= 8) ? (1 << rep) : (rmax >> (3 - rep));
+    // get narrowband according to higher-layer config 
+    num_nb = p[ra->rach_resource_type - 1]->mpdcch_NarrowbandsToMonitor_r13.list.count;
+    ra->msg2_narrowband = *p[ra->rach_resource_type - 1]->mpdcch_NarrowbandsToMonitor_r13.list.array[ra->preamble_index % num_nb]-1;
+    first_rb = narrowband_to_first_rb (&cc[CC_idP], ra->msg2_narrowband);
+
+    if ((ra->msg2_mpdcch_repetition_cnt == 0) && (mpdcch_sf_condition (mac, CC_idP, frameP, subframeP, rmax, TYPE2, -1) > 0)) {
+      ra->msg2_mpdcch_done = 0;
+      // MPDCCH configuration for RAR
+      LOG_I (MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2 for CE Level %d, Programming MPDCCH %d repetitions\n", module_idP, frameP, subframeP, ra->rach_resource_type-1,reps);
+
+
+      memset ((void *) dl_config_pdu, 0, sizeof (nfapi_dl_config_request_pdu_t));
+      dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE;
+      dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_mpdcch_pdu));
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_format = (ra->rach_resource_type > 1) ? 11 : 10;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_narrow_band = ra->msg2_narrowband;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_prb_pairs = 6;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_tansmission_type = 1;   // imposed (9.1.5 in 213) for Type 2 Common search space  
+      AssertFatal (cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13 != NULL, "cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13 is null\n");
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.start_symbol = cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ecce_index = 0;        // Note: this should be dynamic
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.aggregation_level = 24;        // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti_type = 2; // RA-RNTI
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti = ra->RA_rnti;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ce_mode = (ra->rach_resource_type < 3) ? 1 : 2;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.drms_scrambling_init = cc[CC_idP].physCellId;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.initial_transmission_sf_io = (frameP * 10) + subframeP;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.transmission_power = 6000;     // 0dB
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_coding = getRIV (6, 0, 6) | (ra->msg2_narrowband<<5);      
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs = 0;       // adjust according to size of RAR, 208 bits with N1A_PRB=3
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pdsch_reptition_levels = 0;    // fix to 4 for now
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.redundancy_version = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.new_data_indicator = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_process = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi_length = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi_flag = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_resource_offset = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_subframe_repetition_number = rep;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpc = 1;       // N1A_PRB=3 (36.212) => 56 bits
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index_length = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.allocate_prach_flag = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.preamble_index = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.prach_mask_index = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.starting_ce_level = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.srs_request = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity_flag = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.frequency_hopping_enabled_flag = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.paging_direct_indication_differentiation_flag = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.direct_indication = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding = 0;        // this is not needed by OAI L1, but should be filled in
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports = 1;
+      ra->msg2_mpdcch_repetition_cnt++;
+      dl_req_body->number_pdu++;
+      ra->Msg2_subframe = (ra->Msg2_subframe + 9) % 10;
+
+    }                           //repetition_count==0 && SF condition met
+    if (ra->msg2_mpdcch_repetition_cnt > 0) {  // we're in a stream of repetitions
+
+
+      if ((ra->msg2_mpdcch_repetition_cnt == reps)&&
+	  (ra->msg2_mpdcch_done == 0)){    // this is the last mpdcch repetition
+	ra->msg2_mpdcch_done = 1;
+        if (cc[CC_idP].tdd_Config == NULL) {    // FDD case
+          // wait 2 subframes for PDSCH transmission
+          if (subframeP > 7)
+            ra->Msg2_frame = (frameP + 1) & 1023;
+          else
+            ra->Msg2_frame = frameP;
+          ra->Msg2_subframe = (subframeP + 2) % 10;    // +2 is the "n+x" from Section 7.1.11  in 36.213
+          LOG_I(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, programmed Msg2 for %d.%d\n", module_idP, frameP, subframeP, ra->Msg2_frame,ra->Msg2_subframe); 
+        } else {
+          AssertFatal (1 == 0, "TDD case not done yet\n");
+        }
+      }                         // mpdcch_repetition_count == reps
+      else if (ra->msg2_mpdcch_done == 0) {
+        LOG_I (MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, MPDCCH repetition %d\n", module_idP, frameP, subframeP, ra->msg2_mpdcch_repetition_cnt);
+        ra->msg2_mpdcch_repetition_cnt++;
+      }
+
+
+      if ((ra->Msg2_frame == frameP) && (ra->Msg2_subframe == subframeP)) {
+        // Program PDSCH
+        LOG_I (MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, Programming PDSCH\n", module_idP, frameP, subframeP);
+
+        dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu];
+        memset ((void *) dl_config_pdu, 0, sizeof (nfapi_dl_config_request_pdu_t));
+        dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE;
+        dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_dlsch_pdu));
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = mac->pdu_index[CC_idP];
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = ra->RA_rnti;
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2;
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0;     // localized
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV (N_RB_DL, first_rb, 6);
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = 0;
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1;   // first block
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0;
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc[CC_idP].p_eNB == 1) ? 0 : 1;
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1;
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1;
+        //      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index                         = ;
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1;
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = 0;
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0;
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize (cc[CC_idP].mib->message.dl_Bandwidth); // ignored
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = (cc[CC_idP].p_eNB == 1) ? 1 : 2;
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1;
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1;
+        //      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector                    = ; 
+
+        // Rel10 fields
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start = cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13;
+        // Rel13 fields
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = (ra->rach_resource_type < 3) ? 1 : 2;;
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 2;        // not SI message
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = (10 * frameP) + subframeP;
+        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.drms_table_flag = 0;
+        dl_req_body->number_pdu++;
+
+	fill_rar_br (mac, CC_idP, ra, frameP, subframeP, cc[CC_idP].RAR_pdu.payload, ra->rach_resource_type - 1)     ; 
+// Program UL processing for Msg3, same as regular LTE
+        get_Msg3alloc (&cc[CC_idP], subframeP, frameP, &ra->Msg3_frame, &ra->Msg3_subframe);
+        add_msg3 (module_idP, CC_idP, ra, frameP, subframeP);
+	ra->state = WAITMSG3;
+        // DL request
+        LOG_I (MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, Programming TX Req\n", module_idP, frameP, subframeP);
+        mac->TX_req[CC_idP].sfn_sf = (frameP << 4) + subframeP;
+        TX_req = &mac->TX_req[CC_idP].tx_request_body.tx_pdu_list[mac->TX_req[CC_idP].tx_request_body.number_of_pdus];
+        TX_req->pdu_length = 7; // This should be changed if we have more than 1 preamble 
+        TX_req->pdu_index = mac->pdu_index[CC_idP]++;
+        TX_req->num_segments = 1;
+        TX_req->segments[0].segment_length = 7;
+        TX_req->segments[0].segment_data = cc[CC_idP].RAR_pdu.payload;
+        mac->TX_req[CC_idP].tx_request_body.number_of_pdus++;
+      }
+    }
 
-		dl_config_pdu =  &dl_req->dl_config_pdu_list[dl_req->number_pdu];
-		memset((void *) dl_config_pdu, 0,sizeof(nfapi_dl_config_request_pdu_t));
-		dl_config_pdu->pdu_type                                                        = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE;
-		dl_config_pdu->pdu_size                                                        = (uint8_t) (2 + sizeof(nfapi_dl_config_dlsch_pdu));
-                dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.tl.tag                                 = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index                              = mac->pdu_index[CC_idP];
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti                                   = ra->RA_rnti;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type               = 2;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0;	// localized
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding                  = getRIV(N_RB_DL, first_rb, 6);
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation                             = 2;	//QPSK
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version                     = 0;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks                       = 1;	// first block
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag  = 0;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme                    = (cc->p_eNB == 1) ? 0 : 1;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers                       = 1;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands                     = 1;
-		//      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index                         = ;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity                   = 1;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa                                     = 4;	// 0 dB
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index               = 0;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap                                   = 0;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb                                   = get_subbandsize(cc->mib->message.dl_Bandwidth);	// ignored
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode                      = (cc->p_eNB == 1) ? 1 : 2;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband                 = 1;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector                          = 1;
-		//      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector                    = ; 
-
-		// Rel10 fields
-                dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.tl.tag                                = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL10_TAG;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start                           = cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13;
-		// Rel13 fields
-                dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.tl.tag                                = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL13_TAG;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type                               = (ra->rach_resource_type < 3) ? 1 : 2;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type                    = 2;	// not SI message
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io            = (10 * frameP) + subframeP;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.drms_table_flag                       = 0;
-		dl_req->number_pdu++;
-
-                mac->DL_req[CC_idP].sfn_sf = (frameP<<4)+subframeP;
-                mac->DL_req[CC_idP].header.message_id = NFAPI_DL_CONFIG_REQUEST;
-
-                LOG_D(MAC,"DL_CONFIG SFN/SF:%d/%d MESSAGE2\n", frameP, subframeP);
-
-		// Program UL processing for Msg3, same as regular LTE
-		get_Msg3alloc(&cc[CC_idP], subframeP, frameP,
-			      &ra->Msg3_frame, &ra->Msg3_subframe);
-		add_msg3(module_idP, CC_idP, ra, frameP, subframeP);
-		fill_rar_br(mac, CC_idP, ra, frameP, subframeP,
-			    cc[CC_idP].RAR_pdu.payload,
-			    ra->rach_resource_type - 1);
-		// DL request
-                mac->TX_req[CC_idP].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG;
-                mac->TX_req[CC_idP].header.message_id = NFAPI_TX_REQUEST;
-		mac->TX_req[CC_idP].sfn_sf = (frameP << 4) + subframeP;
-		TX_req =
-		    &mac->TX_req[CC_idP].tx_request_body.tx_pdu_list[mac->TX_req[CC_idP].tx_request_body.number_of_pdus];
-		TX_req->pdu_length = 7;	// This should be changed if we have more than 1 preamble 
-		TX_req->pdu_index = mac->pdu_index[CC_idP]++;
-		TX_req->num_segments = 1;
-		TX_req->segments[0].segment_length = 7;
-		TX_req->segments[0].segment_data = cc[CC_idP].RAR_pdu.payload;
-		mac->TX_req[CC_idP].tx_request_body.number_of_pdus++;
-		if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR){
-    		  set_dl_ue_select_msg2(CC_idP, 4, -1, ra->rnti);
-		}
-	    }
-	}
+  } else
 
-    } else
 #endif
     {
 
@@ -538,10 +502,10 @@ generate_Msg2(module_id_t module_idP, int CC_idP, frame_t frameP,
 		LOG_D(MAC,
 		      "Frame %d: Subframe %d : Adding common DCI for RA_RNTI %x\n",
 		      frameP, subframeP, ra->RA_rnti);
-		dl_req->number_dci++;
-		dl_req->number_pdu++;
+		dl_req_body->number_dci++;
+		dl_req_body->number_pdu++;
 
-		dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
+		dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu];
 		memset((void *) dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t));
 		dl_config_pdu->pdu_type                                                        = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE;
 		dl_config_pdu->pdu_size                                                        = (uint8_t) (2 + sizeof(nfapi_dl_config_dlsch_pdu));
@@ -568,7 +532,7 @@ generate_Msg2(module_id_t module_idP, int CC_idP, frame_t frameP,
 		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband                 = 1;
 		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector                          = 1;
 		//    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector                    = ; 
-		dl_req->number_pdu++;
+		dl_req_body->number_pdu++;
                 mac->DL_req[CC_idP].sfn_sf = frameP<<4 | subframeP;
 
 		// Program UL processing for Msg3
@@ -612,15 +576,15 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP,
 	      sub_frame_t subframeP, RA_t * ra)
 {
 
-
-    eNB_MAC_INST *mac = RC.mac[module_idP];
-    COMMON_channels_t *cc = mac->common_channels;
-    int16_t rrc_sdu_length;
-    int UE_id = -1;
-    uint16_t msg4_padding;
-    uint16_t msg4_post_padding;
-    uint16_t msg4_header;
-
+  
+  eNB_MAC_INST *mac = RC.mac[module_idP];
+  COMMON_channels_t *cc = mac->common_channels;
+  int16_t rrc_sdu_length;
+  int UE_id = -1;
+  uint16_t msg4_padding;
+  uint16_t msg4_post_padding;
+  uint16_t msg4_header;
+  
   uint8_t                         *vrb_map;
   int                             first_rb;
   int                             N_RB_DL;
@@ -631,72 +595,70 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP,
   nfapi_dl_config_request_t      *dl_req;
   nfapi_dl_config_request_body_t *dl_req_body;
   nfapi_ul_config_request_body_t *ul_req_body;
-  nfapi_ul_config_request_t      *ul_req;
   uint8_t                         lcid;
   uint8_t                         offset;
 
 
+
 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
-    int rmax = 0;
-    int rep = 0;
-    int reps = 0;
-
-
-    first_rb = 0;
-    struct LTE_PRACH_ConfigSIB_v1310 *ext4_prach;
-    struct LTE_PUCCH_ConfigCommon_v1310 *ext4_pucch;
-    LTE_PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13;
-    struct LTE_N1PUCCH_AN_InfoList_r13 *pucch_N1PUCCH_AN_InfoList_r13;
-    LTE_PRACH_ParametersCE_r13_t *p[4] = { NULL, NULL, NULL, NULL };
-    int pucchreps[4] = { 1, 1, 1, 1 };
-    int n1pucchan[4] = { 0, 0, 0, 0 };
-
-    if (cc[CC_idP].radioResourceConfigCommon_BR) {
-
-	ext4_prach = cc[CC_idP].radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310;
-	ext4_pucch = cc[CC_idP].radioResourceConfigCommon_BR->ext4->pucch_ConfigCommon_v1310;
-	prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13;
-	pucch_N1PUCCH_AN_InfoList_r13 = ext4_pucch->n1PUCCH_AN_InfoList_r13;
-	AssertFatal(prach_ParametersListCE_r13 != NULL,"prach_ParametersListCE_r13 is null\n");
-	AssertFatal(pucch_N1PUCCH_AN_InfoList_r13 != NULL,"pucch_N1PUCCH_AN_InfoList_r13 is null\n");
-	// check to verify CE-Level compatibility in SIB2_BR
-	AssertFatal(prach_ParametersListCE_r13->list.count == pucch_N1PUCCH_AN_InfoList_r13->list.count,
-		    "prach_ParametersListCE_r13->list.count!= pucch_N1PUCCH_AN_InfoList_r13->list.count\n");
-
-	switch (prach_ParametersListCE_r13->list.count) {
-	case 4:
-	    p[3] = prach_ParametersListCE_r13->list.array[3];
-	    n1pucchan[3] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[3];
-	    AssertFatal(ext4_pucch->pucch_NumRepetitionCE_Msg4_Level3_r13 != NULL,
-			"pucch_NumRepetitionCE_Msg4_Level3 shouldn't be NULL\n");
-	    pucchreps[3] = (int) (4 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level3_r13);
-
-	case 3:
-	    p[2] = prach_ParametersListCE_r13->list.array[2];
-	    n1pucchan[2] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[2];
-	    AssertFatal(ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13!= NULL,
-			"pucch_NumRepetitionCE_Msg4_Level2 shouldn't be NULL\n");
-	    pucchreps[2] =(int) (4 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13);
-	case 2:
-	    p[1] = prach_ParametersListCE_r13->list.array[1];
-	    n1pucchan[1] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[1];
-	    AssertFatal(ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13 != NULL,
-			"pucch_NumRepetitionCE_Msg4_Level1 shouldn't be NULL\n");
-	    pucchreps[1] = (int) (1 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level1_r13);
-	case 1:
-	    p[0] = prach_ParametersListCE_r13->list.array[0];
-	    n1pucchan[0] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[0];
-	    AssertFatal(ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13 != NULL,
-			"pucch_NumRepetitionCE_Msg4_Level0 shouldn't be NULL\n");
-	    pucchreps[0] =(int) (1 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level0_r13);
-	default:
-	    AssertFatal(1 == 0,
-			"Illegal count for prach_ParametersListCE_r13 %d\n",
-			prach_ParametersListCE_r13->list.count);
-	}
+  int             rmax = 0;
+  int             rep = 0;
+  int             reps = 0;
+
+
+  first_rb = 0;
+  struct LTE_PRACH_ConfigSIB_v1310 *ext4_prach;
+  struct LTE_PUCCH_ConfigCommon_v1310 *ext4_pucch;
+  LTE_PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13;
+  struct LTE_N1PUCCH_AN_InfoList_r13 *pucch_N1PUCCH_AN_InfoList_r13;
+  LTE_PRACH_ParametersCE_r13_t *p[4] = { NULL, NULL, NULL, NULL };
+  int             pucchreps[4] = { 1, 1, 1, 1 };
+  int             n1pucchan[4] = { 0, 0, 0, 0 };
+
+  if (cc[CC_idP].mib->message.schedulingInfoSIB1_BR_r13 > 0 && 
+      cc[CC_idP].radioResourceConfigCommon_BR) {
+
+    ext4_prach = cc[CC_idP].radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310;
+    ext4_pucch = cc[CC_idP].radioResourceConfigCommon_BR->ext4->pucch_ConfigCommon_v1310;
+    prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13;
+    pucch_N1PUCCH_AN_InfoList_r13 = ext4_pucch->n1PUCCH_AN_InfoList_r13;
+    AssertFatal (prach_ParametersListCE_r13 != NULL, "prach_ParametersListCE_r13 is null\n");
+    AssertFatal (pucch_N1PUCCH_AN_InfoList_r13 != NULL, "pucch_N1PUCCH_AN_InfoList_r13 is null\n");
+    // check to verify CE-Level compatibility in SIB2_BR
+    AssertFatal (prach_ParametersListCE_r13->list.count == pucch_N1PUCCH_AN_InfoList_r13->list.count, "prach_ParametersListCE_r13->list.count!= pucch_N1PUCCH_AN_InfoList_r13->list.count\n");
+
+    switch (prach_ParametersListCE_r13->list.count) {
+    case 4:
+      p[3] = prach_ParametersListCE_r13->list.array[3];
+      n1pucchan[3] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[3];
+      AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level3_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level3 shouldn't be NULL\n");
+      pucchreps[3] = (int) (4 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level3_r13);
+
+    case 3:
+      p[2] = prach_ParametersListCE_r13->list.array[2];
+      n1pucchan[2] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[2];
+      AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level2 shouldn't be NULL\n");
+      pucchreps[2] = (int) (4 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13);
+    case 2:
+      p[1] = prach_ParametersListCE_r13->list.array[1];
+      n1pucchan[1] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[1];
+      AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level1_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level1 shouldn't be NULL\n");
+      pucchreps[1] = (int) (1 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level1_r13);
+    case 1:
+      p[0] = prach_ParametersListCE_r13->list.array[0];
+      n1pucchan[0] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[0];
+      AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level0_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level0 shouldn't be NULL\n");
+      pucchreps[0] = (int) (1 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level0_r13);
+      break;
+    default:
+      AssertFatal (1 == 0, "Illegal count for prach_ParametersListCE_r13 %d\n", prach_ParametersListCE_r13->list.count);
+
     }
+  }
+
 #endif
 
+
     vrb_map = cc[CC_idP].vrb_map;
 
     dl_req        = &mac->DL_req[CC_idP];
@@ -705,7 +667,11 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP,
     N_RB_DL = to_prb(cc[CC_idP].mib->message.dl_Bandwidth);
 
     UE_id = find_UE_id(module_idP, ra->rnti);
-    AssertFatal(UE_id >= 0, "Can't find UE for t-crnti\n");
+    if (UE_id < 0) {
+      LOG_E(MAC,"Can't find UE for t-crnti %x, kill RA procedure for this UE\n",ra->rnti);
+      cancel_ra_proc(module_idP, CC_idP, frameP, ra->rnti);
+      return;
+    }
 
     // set HARQ process round to 0 for this UE
 
@@ -728,289 +694,240 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP,
 
 
 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
-    if (ra->rach_resource_type > 0) {
-
-	// Generate DCI + repetitions first
-	// This uses an MPDCCH Type 2 allocation according to Section 9.1.5 36-213, Type2 common allocation according to Table 7.1-8 (36-213)
-	// Parameters:
-	//    p=2+4 PRB set (number of PRB pairs 6)
-	//    rmax = mpdcch-NumRepetition-RA-r13 => Table 9.1.5-3
-	//    if CELevel = 0,1 => Table 9.1.5-1b for MPDCCH candidates
-	//    if CELevel = 2,3 => Table 9.1.5-2b for MPDCCH candidates
-	//    distributed transmission
-
-	// rmax from SIB2 information
-	rmax = p[ra->rach_resource_type - 1]->mpdcch_NumRepetition_RA_r13;
-	AssertFatal(rmax >= 4,
-		    "choose rmax>=4 for enough repeititions, or reduce rep to 1 or 2\n");
-
-	// choose r3 by default for Msg4 (this is ok from table 9.1.5-3 for rmax = >=4, if we choose rmax <4 it has to be less
-	rep = 2;
-	// get actual repetition count from Table 9.1.5-3
-	reps = (rmax <= 8) ? (1 << rep) : (rmax >> (3 - rep));
-	// get first narrowband
-	first_rb =
-	    narrowband_to_first_rb(&cc[CC_idP], ra->msg34_narrowband);
-
-	if ((ra->msg4_mpdcch_repetition_cnt == 0) &&
-	    (mpdcch_sf_condition
-	     (mac, CC_idP, frameP, subframeP, rmax, TYPE2, -1) > 0)) {
-	    // MPDCCH configuration for RAR
-
-	    memset((void *) dl_config_pdu, 0,
-		   sizeof(nfapi_dl_config_request_pdu_t));
-	    dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE;
-	    dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_dl_config_mpdcch_pdu));
-            dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_MPDCCH_PDU_REL13_TAG;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_format = (ra->rach_resource_type > 1) ? 11 : 10;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_narrow_band = ra->msg34_narrowband;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_prb_pairs = 6;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_assignment = 0;	// Note: this can be dynamic
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_tansmission_type = 1;
-	    AssertFatal(cc[CC_idP].
-			sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13
-			!= NULL,
-			"cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13 is null\n");
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.start_symbol = cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ecce_index = 0;	// Note: this should be dynamic
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.aggregation_level = 16;	// OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti_type = 0;	// t-C-RNTI
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti = ra->RA_rnti;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ce_mode = (ra->rach_resource_type < 3) ? 1 : 2;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.drms_scrambling_init = cc[CC_idP].physCellId;	/// Check this is still N_id_cell for type2 common
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.initial_transmission_sf_io = (frameP * 10) + subframeP;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.transmission_power = 6000;	// 0dB
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_coding = getRIV(6, 0, 6);	// check if not getRIV(N_RB_DL,first_rb,6);
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs = 4;	// adjust according to size of Msg4, 208 bits with N1A_PRB=3
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pdsch_reptition_levels = 4;	// fix to 4 for now
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.redundancy_version = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.new_data_indicator = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_process = ra->harq_pid;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi_length = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi_flag = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_resource_offset = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_subframe_repetition_number = rep;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpc = 1;	// N1A_PRB=3; => 208 bits
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index_length = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.allocate_prach_flag = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.preamble_index = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.prach_mask_index = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.starting_ce_level = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.srs_request = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity_flag = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.frequency_hopping_enabled_flag = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.paging_direct_indication_differentiation_flag = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.direct_indication = 0;
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding = 0;	// this is not needed by OAI L1, but should be filled in
-	    dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports = 1;
-	    ra->msg4_mpdcch_repetition_cnt++;
-	    dl_req_body->number_pdu++;
-            dl_req_body->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG;
-
-            dl_req->sfn_sf = (ra->Msg4_frame<<4)+ra->Msg4_subframe;
-            dl_req->header.message_id = NFAPI_DL_CONFIG_REQUEST;
-
-	}			//repetition_count==0 && SF condition met
-	else if (ra->msg4_mpdcch_repetition_cnt > 0) {	// we're in a stream of repetitions
-	    ra->msg4_mpdcch_repetition_cnt++;
-	    if (ra->msg4_mpdcch_repetition_cnt == reps) {	// this is the last mpdcch repetition
-		if (cc[CC_idP].tdd_Config == NULL) {	// FDD case
-		    // wait 2 subframes for PDSCH transmission
-		    if (subframeP > 7)
-			ra->Msg4_frame = (frameP + 1) & 1023;
-		    else
-			ra->Msg4_frame = frameP;
-		    ra->Msg4_subframe = (subframeP + 2) % 10;
-		} else {
-		    AssertFatal(1 == 0, "TDD case not done yet\n");
-		}
-	    }			// mpdcch_repetition_count == reps
-	    if ((ra->Msg4_frame == frameP) && (ra->Msg4_subframe == subframeP)) {
-
-		// Program PDSCH
-
-	        // Get RRCConnectionSetup for Piggyback
-	        /*rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, 1,	// 1 transport block
-	    				      &cc[CC_idP].CCCH_pdu.payload[0], ENB_FLAG_YES, module_idP, 0);	// not used in this case*/
-
-	    	rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, 1,	// 1 transport block
-	    					      &cc[CC_idP].CCCH_pdu.payload[0], 0);	// not used in this case
-
-	        LOG_D(MAC,
-	        	  "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: UE_id %d, rrc_sdu_length %d\n",
-	        	  module_idP, CC_idP, frameP, subframeP, UE_id, rrc_sdu_length);
-
-	        AssertFatal(rrc_sdu_length > 0,
-	    		"[MAC][eNB Scheduler] CCCH not allocated\n");
-
-		LOG_D(MAC,
-		      "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating Msg4 BR with RRC Piggyback (ce_level %d RNTI %x)\n",
-		      module_idP, CC_idP, frameP, subframeP,
-		      ra->rach_resource_type - 1, ra->rnti);
-
-		AssertFatal(1 == 0,
-			    "Msg4 generation not finished for BL/CE UE\n");
-		dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu];
-		memset((void *) dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t));
-		dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE;
-		dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_dl_config_dlsch_pdu));
-                dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index =  mac->pdu_index[CC_idP];
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = ra->rnti;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2;	// format 1A/1B/1D
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0;	// localized
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(N_RB_DL, first_rb, 6);	// check that this isn't getRIV(6,0,6)
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2;	//QPSK
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = 0;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1;	// first block
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc->p_eNB == 1) ? 0 : 1;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1;
-		//      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index                         = ;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4;	// 0 dB
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = 0;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth);	// ignored
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = (cc->p_eNB == 1) ? 1 : 2;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1;
-		//      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector                    = ; 
-
-                dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL10_TAG;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start = cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13;
-
-                dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL13_TAG;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = (ra->rach_resource_type < 3) ? 1 : 2;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 2;	// not SI message
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = (10 * frameP) + subframeP;
-		dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.drms_table_flag = 0;
-		dl_req_body->number_pdu++;
-                dl_req_body->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG;
-
-                mac->DL_req[CC_idP].sfn_sf = (frameP<<4)+subframeP;
-                mac->DL_req[CC_idP].header.message_id = NFAPI_DL_CONFIG_REQUEST;
-	
-		ra->state = WAITMSG4ACK;
-                LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d: state:WAITMSG4ACK\n", module_idP, frameP, subframeP);
-
-		lcid = 0;
-
-		UE_list->UE_sched_ctrl[UE_id].round[CC_idP][ra->harq_pid] = 0;
-		msg4_header = 1 + 6 + 1;	// CR header, CR CE, SDU header
-
-		if ((ra->msg4_TBsize - rrc_sdu_length - msg4_header) <= 2) {
-		    msg4_padding = ra->msg4_TBsize - rrc_sdu_length - msg4_header;
-		    msg4_post_padding = 0;
-		} else {
-		    msg4_padding = 0;
-		    msg4_post_padding = ra->msg4_TBsize - rrc_sdu_length - msg4_header - 1;
-		}
-
-		LOG_D(MAC,
-		      "[eNB %d][RAPROC] CC_id %d Frame %d subframeP %d Msg4 : TBS %d, sdu_len %d, msg4_header %d, msg4_padding %d, msg4_post_padding %d\n",
-		      module_idP, CC_idP, frameP, subframeP,
-		      ra->msg4_TBsize, rrc_sdu_length, msg4_header,
-		      msg4_padding, msg4_post_padding);
-		DevAssert(UE_id != UE_INDEX_INVALID);	// FIXME not sure how to gracefully return
-		// CHECK THIS: &cc[CC_idP].CCCH_pdu.payload[0]
-		offset = generate_dlsch_header((unsigned char *) mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) UE_id].payload[0], 1,	//num_sdus
-					       (unsigned short *) &rrc_sdu_length,	//
-					       &lcid,	// sdu_lcid
-					       255,	// no drx
-					       31,	// no timing advance
-					       ra->cont_res_id,	// contention res id
-					       msg4_padding,	// no padding
-					       msg4_post_padding);
-
-		memcpy((void *) &mac->UE_list.
-		       DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0][(unsigned char)offset],
-		       &cc[CC_idP].CCCH_pdu.payload[0], rrc_sdu_length);
-
-		// DL request
-		mac->TX_req[CC_idP].sfn_sf = (frameP << 4) + subframeP;
-                mac->TX_req[CC_idP].tx_request_body.tl.tag  = NFAPI_TX_REQUEST_BODY_TAG;
-                mac->TX_req[CC_idP].header.message_id 	    = NFAPI_TX_REQUEST;
-
-		TX_req =
-		    &mac->TX_req[CC_idP].tx_request_body.tx_pdu_list[mac->TX_req[CC_idP].tx_request_body.number_of_pdus];
-		TX_req->pdu_length = rrc_sdu_length;
-		TX_req->pdu_index = mac->pdu_index[CC_idP]++;
-		TX_req->num_segments = 1;
-		TX_req->segments[0].segment_length = rrc_sdu_length;
-		TX_req->segments[0].segment_data = mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) UE_id].payload[0];
-		mac->TX_req[CC_idP].tx_request_body.number_of_pdus++;
-
-		// Program ACK/NAK for Msg4 PDSCH
-		int absSF = (ra->Msg3_frame * 10) + ra->Msg3_subframe;
-		// see Section 10.2 from 36.213
-		int ackNAK_absSF = absSF + reps + 4;
-		AssertFatal(reps > 2,
-			    "Have to handle programming of ACK when PDSCH repetitions is > 2\n");
-		ul_req = &mac->UL_req_tmp[CC_idP][ackNAK_absSF % 10];
-		ul_req_body = &ul_req->ul_config_request_body;
-		ul_config_pdu = &ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus];
-
-		ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE;
-		ul_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_ul_config_uci_harq_pdu));
-                ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG;
-		ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.handle = 0;	// don't know how to use this
-		ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.rnti = ra->rnti;
-                ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL13_TAG;
-		ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.ue_type = (ra->rach_resource_type < 3) ? 1 : 2;
-		ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.empty_symbols = 0;
-		ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.total_number_of_repetitions = pucchreps[ra->rach_resource_type - 1];
-		ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.repetition_number = 0;
-
-                ul_req_body->tl.tag                                                                         = NFAPI_UL_CONFIG_REQUEST_BODY_TAG;
-                ul_req->sfn_sf  									    = sfnsf_add_subframe(ra->Msg3_frame, ra->Msg3_subframe, 4);
-                ul_req->header.message_id  								    = NFAPI_UL_CONFIG_REQUEST;
-                LOG_D(MAC,"UL_req_tmp[CC_idP:%d][ackNAK_absSF mod 10:%d] ra->Msg3_frame:%d ra->Msg3_subframe:%d + 4 sfn_sf:%d\n", CC_idP, ackNAK_absSF%10, ra->Msg3_frame, ra->Msg3_subframe, NFAPI_SFNSF2DEC(ul_req->sfn_sf));
-
-		// Note need to keep sending this across reptitions!!!! Not really for PUCCH, to ask small-cell forum, we'll see for the other messages, maybe parameters change across repetitions and FAPI has to provide for that
-		if (cc[CC_idP].tdd_Config == NULL) {	// FDD case
-                  ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel8_fdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL8_FDD_TAG;
-		    ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel8_fdd.n_pucch_1_0 = n1pucchan[ra->rach_resource_type - 1];
-		    // NOTE: How to fill in the rest of the n_pucch_1_0 information 213 Section 10.1.2.1 in the general case
-		    // = N_ECCE_q + Delta_ARO + n1pucchan[ce_level]
-		    // higher in the MPDCCH configuration, N_ECCE_q is hard-coded to 0, and harq resource offset to 0 =>
-		    // Delta_ARO = 0 from Table 10.1.2.1-1
-		    ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel8_fdd.harq_size = 1;	// 1-bit ACK/NAK
-		} else {
-		    AssertFatal(1 == 0,
-				"PUCCH configuration for ACK/NAK not handled yet for TDD BL/CE case\n");
-		}
-		ul_req_body->number_of_pdus++;
-		T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT(module_idP),
-		  T_INT(CC_idP), T_INT(ra->rnti), T_INT(frameP),
-		  T_INT(subframeP), T_INT(0 /*harq_pid always 0? */ ),
-		  T_BUFFER(&mac->UE_list.DLSCH_pdu[CC_idP][0][UE_id].
-			   payload[0], ra->msg4_TBsize));
-
-		if (opt_enabled == 1) {
-		    trace_pdu(DIRECTION_DOWNLINK,
-			      (uint8_t *) mac->
-			      UE_list.DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0],
-			      rrc_sdu_length, UE_id, WS_C_RNTI,
-			      UE_RNTI(module_idP, UE_id), mac->frame,
-			      mac->subframe, 0, 0);
-		    LOG_D(OPT,
-			  "[eNB %d][DLSCH] CC_id %d Frame %d trace pdu for rnti %x with size %d\n",
-			  module_idP, CC_idP, frameP, UE_RNTI(module_idP,UE_id),
-			  rrc_sdu_length);
-		}
-		if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR){
-        	  set_dl_ue_select_msg4(CC_idP, 4, UE_id, ra->rnti);
-		}
-	    }			// Msg4 frame/subframe
-	}			// msg4_mpdcch_repetition_count
-    }				// rach_resource_type > 0 
-    else
+  if (ra->rach_resource_type > 0) {
+
+    ra->harq_pid = 0;
+    // Generate DCI + repetitions first
+    // This uses an MPDCCH Type 2 allocation according to Section 9.1.5 36-213, Type2 common allocation according to Table 7.1-8 (36-213)
+    // Parameters:
+    //    p=2+4 PRB set (number of PRB pairs 6)
+    //    rmax = mpdcch-NumRepetition-RA-r13 => Table 9.1.5-3
+    //    if CELevel = 0,1 => Table 9.1.5-1b for MPDCCH candidates
+    //    if CELevel = 2,3 => Table 9.1.5-2b for MPDCCH candidates
+    //    distributed transmission
+
+    // rmax from SIB2 information
+    rmax = 1<<p[ra->rach_resource_type - 1]->mpdcch_NumRepetition_RA_r13;
+    
+
+    // choose r3 by default for Msg4 (this is ok from table 9.1.5-3 for rmax = >=4, if we choose rmax <4 it has to be less
+    rep = 0;
+    // get actual repetition count from Table 9.1.5-3
+    reps = (rmax <= 8) ? (1 << rep) : (rmax >> (3 - rep));
+    // get first narrowband
+    first_rb = narrowband_to_first_rb (&cc[CC_idP], ra->msg34_narrowband);
+
+    if ((ra->msg4_mpdcch_repetition_cnt == 0) && (mpdcch_sf_condition (mac, CC_idP, frameP, subframeP, rmax, TYPE2, -1) > 0)) {
+      // Get RRCConnectionSetup for Piggyback
+      ra->msg4_rrc_sdu_length = mac_rrc_data_req (module_idP, CC_idP, frameP, CCCH, 1,       // 1 transport block
+							   &cc[CC_idP].CCCH_pdu.payload[0], 0);     // not used in this case
+      
+      AssertFatal (ra->msg4_rrc_sdu_length > 0, "[MAC][eNB Scheduler] CCCH not allocated\n");
+      
+      
+      LOG_I (MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: UE_id %d, rrc_sdu_length %d, dl_req->num_pdu %d\n", module_idP, CC_idP, frameP, subframeP, UE_id, ra->msg4_rrc_sdu_length,dl_req_body->number_pdu);
+      
+      // MPDCCH configuration for Msg4
+      ra->msg4_mpdcch_done=0;
+      memset ((void *) dl_config_pdu, 0, sizeof (nfapi_dl_config_request_pdu_t));
+      dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE;
+      dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_mpdcch_pdu));
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_format = (ra->rach_resource_type > 1) ? 11 : 10;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_narrow_band = ra->msg2_narrowband;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_prb_pairs = 6;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_tansmission_type = 1;   // imposed (9.1.5 in 213) for Type 2 Common search space  
+      AssertFatal (cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13 != NULL, "cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13 is null\n");
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.start_symbol = cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ecce_index = 0;        // Note: this should be dynamic
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.aggregation_level = 24;        // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti_type = 0; // t-CRNTI
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti = ra->rnti;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ce_mode = (ra->rach_resource_type < 3) ? 1 : 2;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.drms_scrambling_init = cc[CC_idP].physCellId;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.initial_transmission_sf_io = (frameP * 10) + subframeP;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.transmission_power = 6000;     // 0dB
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_coding = getRIV (6, 0, 6) | (ra->msg2_narrowband<<5);
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs = 4;       // adjust according to size of RAR, 208 bits with N1A_PRB=3
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pdsch_reptition_levels = 0;    // fix to 4 for now
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.redundancy_version = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.new_data_indicator = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_process = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi_length = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi_flag = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_resource_offset = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_subframe_repetition_number = rep;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpc = 3;       // N1A_PRB=3 (36.212) => 56 bits
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index_length = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.allocate_prach_flag = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.preamble_index = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.prach_mask_index = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.starting_ce_level = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.srs_request = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity_flag = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.frequency_hopping_enabled_flag = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.paging_direct_indication_differentiation_flag = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.direct_indication = 0;
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding = 0;        // this is not needed by OAI L1, but should be filled in
+      dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports = 1;
+
+      ra->msg4_mpdcch_repetition_cnt++;
+      dl_req_body->number_pdu++;
+      ra->msg4_TBsize = get_TBS_DL(dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs,
+					    6);
+    }                           //repetition_count==0 && SF condition met
+    
+    if ((ra->msg4_mpdcch_repetition_cnt > 0)&&
+	(ra->msg4_mpdcch_done==0)) {     // we're in a stream of repetitions
+      LOG_I(MAC,"SFN.SF %d.%d : msg4 mpdcch repetition number %d/%d\n",
+	    frameP,subframeP,ra->msg4_mpdcch_repetition_cnt,reps);
+      if (ra->msg4_mpdcch_repetition_cnt == reps) {    // this is the last mpdcch repetition
+        ra->msg4_mpdcch_done = 1;
+	if (cc[CC_idP].tdd_Config == NULL) {    // FDD case
+          // wait 2 subframes for PDSCH transmission
+          if (subframeP > 7)
+            ra->Msg4_frame = (frameP + 1) & 1023;
+          else
+            ra->Msg4_frame = frameP;
+          ra->Msg4_subframe = (subframeP + 2) % 10;
+	  LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Set Msg4 PDSCH in %d.%d\n",
+		module_idP, CC_idP, frameP, subframeP, ra->Msg4_frame,ra->Msg4_subframe);
+        } else {
+          AssertFatal (1 == 0, "TDD case not done yet\n");
+        }
+      }
+      else if (ra->msg4_mpdcch_done==0)
+	ra->msg4_mpdcch_repetition_cnt++;
+    }
+// mpdcch_repetition_count == reps
+    else if ((ra->Msg4_frame == frameP) && (ra->Msg4_subframe == subframeP)) {
+      
+      // Program PDSCH
+      
+      LOG_I (MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating Msg4 BR with RRC Piggyback (ce_level %d RNTI %x)\n",
+	     module_idP, CC_idP, frameP, subframeP, ra->rach_resource_type - 1, ra->rnti);
+      
+      
+      dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu];
+      memset ((void *) dl_config_pdu, 0, sizeof (nfapi_dl_config_request_pdu_t));
+      dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE;
+      dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_dlsch_pdu));
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = mac->pdu_index[CC_idP];
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = ra->rnti;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2;   // format 1A/1B/1D
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0;     // localized
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV (N_RB_DL, first_rb, 6);  // check that this isn't getRIV(6,0,6)
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = 0;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1;   // first block
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc[CC_idP].p_eNB == 1) ? 0 : 1;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1;
+      //      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index                         = ;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = 0;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize (cc[CC_idP].mib->message.dl_Bandwidth); // ignored
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = (cc[CC_idP].p_eNB == 1) ? 1 : 2;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1;
+      //      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector                    = ; 
+      
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start = cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13;
+      
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = (ra->rach_resource_type < 3) ? 1 : 2;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 2;        // not SI message
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = (10 * frameP) + subframeP;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.drms_table_flag = 0;
+      dl_req_body->number_pdu++;
+      
+
+      ra->state = WAITMSG4ACK;
+      
+      lcid = 0;
+      
+      UE_list->UE_sched_ctrl[UE_id].round[CC_idP][ra->harq_pid] = 0;
+      msg4_header = 1 + 6 + 1;        // CR header, CR CE, SDU header
+      AssertFatal((ra->msg4_TBsize - ra->msg4_rrc_sdu_length - msg4_header)>=0,
+		  "msg4_TBS %d is too small, change mcs to increase by %d bytes\n",ra->msg4_TBsize,ra->msg4_rrc_sdu_length+msg4_header-ra->msg4_TBsize);
+      if ((ra->msg4_TBsize - ra->msg4_rrc_sdu_length - msg4_header) <= 2) {
+	msg4_padding = ra->msg4_TBsize - ra->msg4_rrc_sdu_length - msg4_header;
+	msg4_post_padding = 0;
+      } else {
+	msg4_padding = 0;
+	msg4_post_padding = ra->msg4_TBsize - ra->msg4_rrc_sdu_length - msg4_header - 1;
+      }
+      
+      LOG_I (MAC, "[eNB %d][RAPROC] CC_id %d Frame %d subframeP %d Msg4 : TBS %d, sdu_len %d, msg4_header %d, msg4_padding %d, msg4_post_padding %d\n",
+	     module_idP, CC_idP, frameP, subframeP, ra->msg4_TBsize, ra->msg4_rrc_sdu_length, msg4_header, msg4_padding, msg4_post_padding);
+      DevAssert (UE_id != UE_INDEX_INVALID);  // FIXME not sure how to gracefully return
+      // CHECK THIS: &cc[CC_idP].CCCH_pdu.payload[0]
+      offset = generate_dlsch_header ((unsigned char *) mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) UE_id].payload[0], 1,       //num_sdus
+				      (unsigned short *) &ra->msg4_rrc_sdu_length,     //
+				      &lcid,  // sdu_lcid
+				      255,    // no drx
+				      31,     // no timing advance
+				      ra->cont_res_id,       // contention res id
+				      msg4_padding,   // no padding
+				      msg4_post_padding);
+      
+      memcpy ((void *) &mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) UE_id].payload[0][(unsigned char) offset], &cc[CC_idP].CCCH_pdu.payload[0], ra->msg4_rrc_sdu_length);
+      
+      // DL request
+      mac->TX_req[CC_idP].sfn_sf = (frameP << 4) + subframeP;
+      TX_req = &mac->TX_req[CC_idP].tx_request_body.tx_pdu_list[mac->TX_req[CC_idP].tx_request_body.number_of_pdus];
+      TX_req->pdu_length = ra->msg4_TBsize;
+      TX_req->pdu_index = mac->pdu_index[CC_idP]++;
+      TX_req->num_segments = 1;
+      TX_req->segments[0].segment_length = ra->msg4_TBsize;
+      TX_req->segments[0].segment_data = mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) UE_id].payload[0];
+      mac->TX_req[CC_idP].tx_request_body.number_of_pdus++;
+      
+      // Program ACK/NAK for Msg4 PDSCH
+      int             absSF = (frameP * 10) + subframeP;
+      // see Section 10.2 from 36.213
+      int             ackNAK_absSF = absSF + reps + 3;
+      AssertFatal (reps == 1, "Have to handle programming of ACK when PDSCH repetitions is > 1\n");
+      ul_req_body = &mac->UL_req_tmp[CC_idP][ackNAK_absSF % 10].ul_config_request_body;
+      ul_config_pdu = &ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus];
+      
+      ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE;
+      ul_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_ul_config_uci_harq_pdu));
+      ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.handle = 0;      // don't know how to use this
+      ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.rnti = ra->rnti;
+      ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.ue_type = (ra->rach_resource_type < 3) ? 1 : 2;
+      ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.empty_symbols = 0;
+      ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.total_number_of_repetitions = pucchreps[ra->rach_resource_type - 1];
+      ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.repetition_number = 0;
+      // Note need to keep sending this across reptitions!!!! Not really for PUCCH, to ask small-cell forum, we'll see for the other messages, maybe parameters change across repetitions and FAPI has to provide for that
+      if (cc[CC_idP].tdd_Config == NULL) {    // FDD case
+	ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.n_pucch_1_0 = n1pucchan[ra->rach_resource_type - 1];
+	// NOTE: How to fill in the rest of the n_pucch_1_0 information 213 Section 10.1.2.1 in the general case
+	// = N_ECCE_q + Delta_ARO + n1pucchan[ce_level]
+	// higher in the MPDCCH configuration, N_ECCE_q is hard-coded to 0, and harq resource offset to 0 =>
+	// Delta_ARO = 0 from Table 10.1.2.1-1
+	ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.harq_size = 1; // 1-bit ACK/NAK
+	ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.number_of_pucch_resources = 1;
+      } else {
+	AssertFatal (1 == 0, "PUCCH configuration for ACK/NAK not handled yet for TDD BL/CE case\n");
+      }
+      ul_req_body->number_of_pdus++;
+      T (T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT (module_idP), T_INT (CC_idP), T_INT (ra->rnti), T_INT (frameP), T_INT (subframeP),
+	 T_INT (0 /*harq_pid always 0? */ ), T_BUFFER (&mac->UE_list.DLSCH_pdu[CC_idP][0][UE_id].payload[0], ra->msg4_TBsize));
+      
+      if (opt_enabled == 1) {
+	trace_pdu (1, (uint8_t *) mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) UE_id].payload[0], ra->msg4_rrc_sdu_length, UE_id, 3, UE_RNTI (module_idP, UE_id), mac->frame, mac->subframe, 0, 0);
+	LOG_D (OPT, "[eNB %d][DLSCH] CC_id %d Frame %d trace pdu for rnti %x with size %d\n", module_idP, CC_idP, frameP, UE_RNTI (module_idP, UE_id), ra->msg4_rrc_sdu_length);
+      }
+    }                           // Msg4 frame/subframe  
+  }                             // rach_resource_type > 0 
+  else
 #endif
     {
     // This is normal LTE case
@@ -1409,15 +1326,14 @@ schedule_RA(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP)
     RA_t *ra;
     uint8_t i;
 
-    start_meas(&mac->schedule_ra);
 
+    start_meas(&mac->schedule_ra);
 
     for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
 	// skip UL component carriers if TDD
 	if (is_UL_sf(&cc[CC_id], subframeP) == 1)
 	    continue;
 
-
 	for (i = 0; i < NB_RA_PROC_MAX; i++) {
 
 	    ra = (RA_t *) & cc[CC_id].ra[i];
@@ -1436,6 +1352,7 @@ schedule_RA(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP)
     }				// CC_id
 
     stop_meas(&mac->schedule_ra);
+
 }
 
 
@@ -1457,18 +1374,20 @@ initiate_ra_proc(module_id_t module_idP,
 
     COMMON_channels_t *cc = &RC.mac[module_idP]->common_channels[CC_id];
     RA_t *ra = &cc->ra[0];
-
 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
 
+
     struct LTE_PRACH_ConfigSIB_v1310 *ext4_prach = NULL;
     LTE_PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13 = NULL;
   
-    static uint8_t failure_cnt = 0;
 
-    if (cc->radioResourceConfigCommon_BR
-	&& cc->radioResourceConfigCommon_BR->ext4) {
-	ext4_prach = cc->radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310;
-	prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13;
+
+    if (cc->mib->message.schedulingInfoSIB1_BR_r13>0) {
+      AssertFatal(cc->radioResourceConfigCommon_BR != NULL,"radioResourceConfigCommon_BR is null\n");
+      AssertFatal(cc->radioResourceConfigCommon_BR->ext4 != NULL, "radioResourceConfigCommon_BR->ext4 is null\n");
+      ext4_prach = cc->radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310;
+      AssertFatal(ext4_prach!=NULL,"ext4_prach is null\n");
+      prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13;
     }
 
 #endif /* #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) */
@@ -1486,6 +1405,8 @@ initiate_ra_proc(module_id_t module_idP,
     uint16_t msg2_subframe = subframeP;
     int offset;
 
+    static uint8_t failure_cnt = 0 ;
+
 #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0))
 
     if (prach_ParametersListCE_r13 &&
@@ -1517,6 +1438,7 @@ initiate_ra_proc(module_id_t module_idP,
 #endif
 
 
+
             //TODO Fill in other TDD config. What about nfapi_mode?
             if(cc->tdd_Config!=NULL){
               switch(cc->tdd_Config->subframeAssignment){
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_bch.c b/openair2/LAYER2/MAC/eNB_scheduler_bch.c
index 460e4f42c9fffcc917b0300709bf5bf47f34a603..339d4102aa48416bfe4b498c3219c55c4f3c7f0a 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_bch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_bch.c
@@ -310,195 +310,189 @@ schedule_SI_BR(module_id_t module_idP, frame_t frameP,
 	       sub_frame_t subframeP)
 //------------------------------------------------------------------------------
 {
-    int8_t bcch_sdu_length;
-    int CC_id;
-    eNB_MAC_INST *eNB = RC.mac[module_idP];
-    COMMON_channels_t *cc;
-    uint8_t *vrb_map;
-    int first_rb = -1;
-    int N_RB_DL;
-    nfapi_dl_config_request_pdu_t *dl_config_pdu;
-    nfapi_tx_request_pdu_t *TX_req;
-    nfapi_dl_config_request_body_t *dl_req;
-    int i;
-    int rvidx;
-    int absSF = (frameP * 10) + subframeP;
-    uint16_t sfn_sf = frameP << 4 | subframeP;
-
-
-    for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
 
-	cc = &eNB->common_channels[CC_id];
-	vrb_map = (void *) &cc->vrb_map;
-	N_RB_DL = to_prb(cc->mib->message.dl_Bandwidth);
-	dl_req = &eNB->DL_req[CC_id].dl_config_request_body;
-
-	// Time-domain scheduling
-	if (cc->mib->message.schedulingInfoSIB1_BR_r13 == 0)
-	    continue;
-	else {
-	    AssertFatal(cc->sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13 != NULL,
-			"sib_v13ext->bandwidthReducedAccessRelatedInfo_r13 is null\n");
-
-	    LTE_SchedulingInfoList_BR_r13_t *schedulingInfoList_BR_r13 = cc->sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->schedulingInfoList_BR_r13;
-	    AssertFatal(schedulingInfoList_BR_r13 != NULL,
-			"sib_v13ext->schedulingInfoList_BR_r13 is null\n");
-
-	    LTE_SchedulingInfoList_t *schedulingInfoList = cc->schedulingInfoList;
-	    AssertFatal(schedulingInfoList_BR_r13->list.count == schedulingInfoList->list.count,
-			"schedulingInfolist_BR.r13->list.count %d != schedulingInfoList.list.count %d\n",
-			schedulingInfoList_BR_r13->list.count,
-			schedulingInfoList->list.count);
-
-	    AssertFatal(cc->sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->si_WindowLength_BR_r13<=LTE_SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_WindowLength_BR_r13_ms200,
-			"si_WindowLength_BR_r13 %d > %d\n",
-			(int) cc->sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->si_WindowLength_BR_r13,
-			LTE_SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_WindowLength_BR_r13_ms200);
-
-	    // check that SI frequency-hopping is disabled
-	    AssertFatal(cc->sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->si_HoppingConfigCommon_r13 == LTE_SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_HoppingConfigCommon_r13_off,
-			"Deactivate SI_HoppingConfigCommon_r13 in configuration file, not supported for now\n");
-	    long si_WindowLength_BR_r13 = si_WindowLength_BR_r13tab[cc->sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->si_WindowLength_BR_r13];
-
-	    long si_RepetitionPattern_r13 = cc->sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->si_RepetitionPattern_r13;
-	    AssertFatal(si_RepetitionPattern_r13<=LTE_SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_RepetitionPattern_r13_every8thRF,
-			"si_RepetitionPattern_r13 %d > %d\n",
-			(int) si_RepetitionPattern_r13,
-			LTE_SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_RepetitionPattern_r13_every8thRF);
-	    // cycle through SIB list
-
-	    for (i = 0; i < schedulingInfoList_BR_r13->list.count; i++) {
-		long si_Periodicity = schedulingInfoList->list.array[i]->si_Periodicity;
-		long si_Narrowband_r13 = schedulingInfoList_BR_r13->list.array[i]->si_Narrowband_r13;
-		long si_TBS_r13 = si_TBS_r13tab[schedulingInfoList_BR_r13->list.array[i]->si_TBS_r13];
-
-		// check if the SI is to be scheduled now
-		int period_in_sf = 80 << si_Periodicity;	// 2^i * 80 subframes, note: si_Periodicity is 2^i * 80ms
-		int sf_mod_period = absSF % period_in_sf;
-		int k = sf_mod_period & 3;
-		// Note: definition of k and rvidx from 36.321 section 5.3.1
-		rvidx = (((3 * k) >> 1) + (k & 1)) & 3;
-
-		if ((sf_mod_period < si_WindowLength_BR_r13)
-		    && ((frameP & (((1 << si_RepetitionPattern_r13) - 1))) == 0)) {	// this SIB is to be scheduled
-
-		    bcch_sdu_length = mac_rrc_data_req(module_idP, CC_id, frameP, BCCH_SI_BR + i, 1, &cc->BCCH_BR_pdu[i + 1].payload[0], 0);	// not used in this case
-
-		    AssertFatal(bcch_sdu_length > 0,
-				"RRC returned 0 bytes for SI-BR %d\n", i);
-
-		    if (bcch_sdu_length > 0) {
-			AssertFatal(bcch_sdu_length <= (si_TBS_r13 >> 3),
-				    "RRC provided bcch with length %d > %d (si_TBS_r13 %d)\n",
-				    bcch_sdu_length,
-				    (int) (si_TBS_r13 >> 3),
-				    (int) schedulingInfoList_BR_r13->list.array[i]->si_TBS_r13);
-
-			// allocate all 6 PRBs in narrowband for SIB1_BR
-
-			// check that SIB1 didn't take this narrowband
-			if (vrb_map[first_rb] > 0) continue;
-
-			first_rb = narrowband_to_first_rb(cc,si_Narrowband_r13 - 1);
-			vrb_map[first_rb] = 1;
-			vrb_map[first_rb + 1] = 1;
-			vrb_map[first_rb + 2] = 1;
-			vrb_map[first_rb + 4] = 1;
-			vrb_map[first_rb + 5] = 1;
-
-			if ((frameP & 1023) < 200)
-			    LOG_D(MAC,
-				  "[eNB %d] Frame %d Subframe %d: SI_BR->DLSCH CC_id %d, Narrowband %d rvidx %d (sf_mod_period %d : si_WindowLength_BR_r13 %d : si_RepetitionPattern_r13 %d) bcch_sdu_length %d\n",
-				  module_idP, frameP, subframeP, CC_id,
-				  (int) si_Narrowband_r13 - 1, rvidx,
-				  sf_mod_period,
-				  (int) si_WindowLength_BR_r13,
-				  (int) si_RepetitionPattern_r13,
-				  bcch_sdu_length);
-
-
-
-
-			dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
-			memset((void *) dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t));
-			dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE;
-			dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_dl_config_dlsch_pdu));
-                        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG;
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.length = si_TBS_r13 >> 3;
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = eNB->pdu_index[CC_id];
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = 0xFFFF;
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2;	// format 1A/1B/1D
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0;	// localized
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(N_RB_DL, first_rb, 6);
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2;	//QPSK
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = rvidx;
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1;	// first block
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0;
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc->p_eNB == 1) ? 0 : 1;
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1;
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1;
-			//  dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index                         = ;
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1;
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4;	// 0 dB
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = 0;
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0;
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth);	// ignored
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = (cc->p_eNB == 1) ? 1 : 2;
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1;
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1;
-			// Rel10 fields (for PDSCH starting symbol)
-                        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL10_TAG;
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start = cc[CC_id].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13;
-			// Rel13 fields
-                        dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL13_TAG;
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = 1;	// CEModeA UE
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 1;	// SI-BR
-			dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = absSF - sf_mod_period;
-
-			//  dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector                    = ; 
-			dl_req->number_pdu++;
-                        dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG;
-
-			// Program TX Request
-			TX_req = &eNB->TX_req[CC_id].tx_request_body.tx_pdu_list[eNB->TX_req[CC_id].tx_request_body.number_of_pdus];
-			TX_req->pdu_length = bcch_sdu_length;
-			TX_req->pdu_index = eNB->pdu_index[CC_id]++;
-			TX_req->num_segments = 1;
-			TX_req->segments[0].segment_length = bcch_sdu_length;
-			TX_req->segments[0].segment_data = cc->BCCH_BR_pdu[i + 1].payload;
-			eNB->TX_req[CC_id].tx_request_body.number_of_pdus++;
-                        eNB->TX_req[CC_id].sfn_sf = sfn_sf;
-                        eNB->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG;
-                        eNB->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST;
-
-			if (opt_enabled == 1) {
-			    trace_pdu(DIRECTION_DOWNLINK,
-				      &cc->BCCH_BR_pdu[i + 1].payload[0],
-				      bcch_sdu_length,
-				      0xffff,
-				      WS_SI_RNTI,
-				      0xffff, eNB->frame, eNB->subframe, 0,
-				      0);
-			    LOG_D(OPT,
-				  "[eNB %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n",
-				  module_idP, frameP, CC_id, 0xffff,
-				  bcch_sdu_length);
-			}
-			if (cc->tdd_Config != NULL) {	//TDD
-			    LOG_D(MAC,
-				  "[eNB] Frame %d : Scheduling BCCH-BR %d->DLSCH (TDD) for CC_id %d SI-BR %d bytes\n",
-				  frameP, i, CC_id, bcch_sdu_length);
-			} else {
-			    LOG_D(MAC,
-				  "[eNB] Frame %d : Scheduling BCCH-BR %d->DLSCH (FDD) for CC_id %d SI-BR %d bytes\n",
-				  frameP, i, CC_id, bcch_sdu_length);
-			}
-		    }
-		}		// scheduling in current frame/subframe
-	    }			//for SI List
-	}			// eMTC is activated
-    }				// CC_id
-    return;
+  int8_t                                  bcch_sdu_length;
+  int                                     CC_id;
+  eNB_MAC_INST                            *eNB = RC.mac[module_idP];
+  COMMON_channels_t                       *cc;
+  uint8_t                                 *vrb_map;
+  int                                     first_rb = -1;
+  int                                     N_RB_DL;
+  nfapi_dl_config_request_pdu_t           *dl_config_pdu;
+  nfapi_tx_request_pdu_t                  *TX_req;
+  nfapi_dl_config_request_body_t          *dl_req;
+  int                                     i;
+  int                                     rvidx;
+  int                                     absSF = (frameP*10)+subframeP;
+
+
+  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
+
+    cc              = &eNB->common_channels[CC_id];
+    vrb_map         = (void*)&cc->vrb_map;
+    N_RB_DL         = to_prb(cc->mib->message.dl_Bandwidth);
+    dl_req          = &eNB->DL_req[CC_id].dl_config_request_body;
+
+    // Time-domain scheduling
+    if (cc->mib->message.schedulingInfoSIB1_BR_r13==0) continue;
+    else  {
+
+
+      AssertFatal(cc->sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13!=NULL,
+		  "sib_v13ext->bandwidthReducedAccessRelatedInfo_r13 is null\n");
+
+      LTE_SchedulingInfoList_BR_r13_t *schedulingInfoList_BR_r13 = cc->sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->schedulingInfoList_BR_r13;
+      AssertFatal(schedulingInfoList_BR_r13!=NULL,
+		  "sib_v13ext->schedulingInfoList_BR_r13 is null\n");
+
+      LTE_SchedulingInfoList_t *schedulingInfoList = cc->schedulingInfoList;
+      AssertFatal(schedulingInfoList_BR_r13->list.count==schedulingInfoList->list.count,
+		  "schedulingInfolist_BR.r13->list.count %d != schedulingInfoList.list.count %d\n",
+		  schedulingInfoList_BR_r13->list.count,schedulingInfoList->list.count); 
+
+      AssertFatal(cc->sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->si_WindowLength_BR_r13<=LTE_SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_WindowLength_BR_r13_ms200,
+		  "si_WindowLength_BR_r13 %d > %d\n",
+		  (int)cc->sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->si_WindowLength_BR_r13,
+		  LTE_SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_WindowLength_BR_r13_ms200);
+
+      // check that SI frequency-hopping is disabled
+      AssertFatal(cc->sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->si_HoppingConfigCommon_r13==LTE_SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_HoppingConfigCommon_r13_off,
+		  "Deactivate SI_HoppingConfigCommon_r13 in configuration file, not supported for now\n");
+      long si_WindowLength_BR_r13   = si_WindowLength_BR_r13tab[cc->sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->si_WindowLength_BR_r13];
+
+      long si_RepetitionPattern_r13 = cc->sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->si_RepetitionPattern_r13;
+      AssertFatal(si_RepetitionPattern_r13<=LTE_SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_RepetitionPattern_r13_every8thRF,
+		  "si_RepetitionPattern_r13 %d > %d\n",
+		  (int)si_RepetitionPattern_r13,
+		  LTE_SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_RepetitionPattern_r13_every8thRF);
+      // cycle through SIB list
+
+      for (i=0;i<schedulingInfoList_BR_r13->list.count;i++) {
+	long si_Periodicity           = schedulingInfoList->list.array[i]->si_Periodicity;
+	long si_Narrowband_r13        = schedulingInfoList_BR_r13->list.array[i]->si_Narrowband_r13;
+	long si_TBS_r13               = si_TBS_r13tab[schedulingInfoList_BR_r13->list.array[i]->si_TBS_r13];
+
+	// check if the SI is to be scheduled now
+	int period_in_sf              = 80<<si_Periodicity; // 2^i * 80 subframes, note: si_Periodicity is 2^i * 80ms
+	int sf_mod_period             = absSF%period_in_sf;
+	int k                         = sf_mod_period&3;
+	// Note: definition of k and rvidx from 36.321 section 5.3.1
+	rvidx = (((3*k)>>1) + (k&1))&3;
+	
+        if ((sf_mod_period < si_WindowLength_BR_r13) &&
+	    ((frameP&(((1<<si_RepetitionPattern_r13)-1)))==0)) { // this SIB is to be scheduled
+
+	  bcch_sdu_length = mac_rrc_data_req(module_idP,
+					     CC_id,
+					     frameP,
+					     BCCH_SI_BR+i,1,
+					     &cc->BCCH_BR_pdu[i+1].payload[0],
+					     0); // not used in this case
+	  
+	  AssertFatal(bcch_sdu_length>0,"RRC returned 0 bytes for SI-BR %d\n",i);
+	  
+	  if (bcch_sdu_length > 0) {
+	    AssertFatal(bcch_sdu_length <= (si_TBS_r13>>3),
+			"RRC provided bcch with length %d > %d (si_TBS_r13 %d)\n",
+			bcch_sdu_length,(int)(si_TBS_r13>>3),(int)schedulingInfoList_BR_r13->list.array[i]->si_TBS_r13);
+
+	    // allocate all 6 PRBs in narrowband for SIB1_BR
+
+	    // check that SIB1 didn't take this narrowband
+	    if (vrb_map[first_rb] > 0) continue;
+
+	    first_rb = narrowband_to_first_rb(cc,si_Narrowband_r13-1);
+	    vrb_map[first_rb]   = 1;
+	    vrb_map[first_rb+1] = 1;
+	    vrb_map[first_rb+2] = 1;
+	    vrb_map[first_rb+4] = 1;
+	    vrb_map[first_rb+5] = 1;
+
+	    if ((frameP&1023) < 200) 
+	      LOG_D(MAC,"[eNB %d] Frame %d Subframe %d: SI_BR->DLSCH CC_id %d, Narrowband %d rvidx %d (sf_mod_period %d : si_WindowLength_BR_r13 %d : si_RepetitionPattern_r13 %d) bcch_sdu_length %d\n",
+					   module_idP,frameP,subframeP,CC_id,(int)si_Narrowband_r13-1,rvidx,
+					   sf_mod_period,(int)si_WindowLength_BR_r13,(int)si_RepetitionPattern_r13,
+					   bcch_sdu_length);	    
+
+
+
+	    
+	    dl_config_pdu                                                                  = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; 
+	    memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t));
+	    dl_config_pdu->pdu_type                                                        = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; 
+	    dl_config_pdu->pdu_size                                                        = (uint8_t)(2+sizeof(nfapi_dl_config_dlsch_pdu));
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.length                                 = si_TBS_r13>>3;
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index                              = eNB->pdu_index[CC_id];
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti                                   = 0xFFFF;
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type               = 2;   // format 1A/1B/1D
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0;   // localized
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding                  = getRIV(N_RB_DL,first_rb,6);
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation                             = 2; //QPSK
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version                     = rvidx;
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks                       = 1;// first block
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag  = 0;
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme                    = (cc->p_eNB==1 ) ? 0 : 1;
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers                       = 1;
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands                     = 1;
+	    //	dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index                         = ;
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity                   = 1;
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa                                     = 4; // 0 dB
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index               = 0;
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap                                   = 0;
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb                                   = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode                      = (cc->p_eNB==1 ) ? 1 : 2;
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband                 = 1;
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector                          = 1;
+	    // Rel10 fields (for PDSCH starting symbol)
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start                           = cc[CC_id].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13;
+	    // Rel13 fields
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type                               = 1; // CEModeA UE
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type                    = 1; // SI-BR
+	    dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io            = absSF - sf_mod_period; 
+	    
+	    //	dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector                    = ; 
+	    dl_req->number_pdu++;
+	    
+	    // Program TX Request
+	    TX_req                                                                = &eNB->TX_req[CC_id].tx_request_body.tx_pdu_list[eNB->TX_req[CC_id].tx_request_body.number_of_pdus]; 
+	    TX_req->pdu_length                                                    = bcch_sdu_length;
+	    TX_req->pdu_index                                                     = eNB->pdu_index[CC_id]++;
+	    TX_req->num_segments                                                  = 1;
+	    TX_req->segments[0].segment_length                                    = bcch_sdu_length;
+	    TX_req->segments[0].segment_data                                      = cc->BCCH_BR_pdu[i+1].payload;
+	    eNB->TX_req[CC_id].tx_request_body.number_of_pdus++;
+	    
+	    if (opt_enabled == 1) {
+	      trace_pdu(1,
+			&cc->BCCH_BR_pdu[i+1].payload[0],
+			bcch_sdu_length,
+			0xffff,
+			4,
+			0xffff,
+			eNB->frame,
+			eNB->subframe,
+			0,
+			0);
+	      LOG_D(OPT,"[eNB %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n",
+		    module_idP, frameP, CC_id, 0xffff, bcch_sdu_length);
+	    }
+	    if (cc->tdd_Config!=NULL) { //TDD
+	      LOG_D(MAC,"[eNB] Frame %d : Scheduling BCCH-BR %d->DLSCH (TDD) for CC_id %d SI-BR %d bytes\n",
+		    frameP,i,
+		    CC_id,
+		    bcch_sdu_length);
+	    } else {
+	      LOG_D(MAC,"[eNB] Frame %d : Scheduling BCCH-BR %d->DLSCH (FDD) for CC_id %d SI-BR %d bytes\n",
+		    frameP,i,
+		    CC_id,
+		    bcch_sdu_length);
+	    }
+	  }
+	} // scheduling in current frame/subframe
+      } //for SI List
+    } // eMTC is activated
+  } // CC_id
+  return;
 }
 #endif
 
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
index 9a26460fa3662c63c50e0cc79afb8e20c5f11aec..737f4dfe749b7a5ce506b26c8a21e777db8a4c12 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
@@ -414,7 +414,1101 @@ schedule_dlsch(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP, in
 }
 
 // changes to pre-processor for eMTC
+//------------------------------------------------------------------------------
+
+void  getRepetition(UE_TEMPLATE * pue_template,unsigned int *maxRep , unsigned int *narrowBandindex){
+    LTE_EPDCCH_SetConfig_r11_t *epdcch_setconfig_r11;
+
+    AssertFatal(pue_template->physicalConfigDedicated !=NULL, "no RRC physical configuration for this UE ") ;
+    AssertFatal(pue_template->physicalConfigDedicated->ext4 !=NULL, "no RRC physical configuration for this UE ") ;
+
+    AssertFatal(pue_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.count > 0 ,"epdcch config list is empty") ;
+
+    epdcch_setconfig_r11 = pue_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.array[0] ;
+
+    AssertFatal(epdcch_setconfig_r11->ext2 !=NULL && epdcch_setconfig_r11->ext2->mpdcch_config_r13 !=NULL," mpdcch config not found")  ;
+
+*maxRep = epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_NumRepetition_r13  ;
+
+    *narrowBandindex = epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13  ;
+
+
+
+
+}
+
+
+
+/*void
+schedule_ue_spec_br(
+    module_id_t   module_idP,
+    frame_t       frameP,
+    sub_frame_t   subframeP,
+    int*          mbsfn_flag
+)
+//------------------------------------------------------------------------------
+{
+	uint8_t                        CC_id;
+	int                            UE_id;
+	unsigned char                  aggregation;
+	mac_rlc_status_resp_t          rlc_status;
+	unsigned char                  header_len_dcch = 0, header_len_dcch_tmp = 0;
+	unsigned char                  header_len_dtch = 0, header_len_dtch_tmp = 0, header_len_dtch_last = 0;
+	unsigned char                  ta_len = 0;
+	unsigned char                  sdu_lcids[NB_RB_MAX], lcid, offset, num_sdus = 0;
+	uint16_t                       nb_rb, nb_rb_temp, nb_available_rb;
+	uint16_t                       TBS, j, sdu_lengths[NB_RB_MAX], rnti, padding = 0, post_padding = 0;
+	unsigned char                  dlsch_buffer[MAX_DLSCH_PAYLOAD_BYTES];
+	unsigned char                  round = 0;
+	unsigned char                  harq_pid = 0;
+	eNB_UE_STATS                   *eNB_UE_stats = NULL;
+	uint16_t                       sdu_length_total = 0;
+
+	eNB_MAC_INST                   *eNB = RC.mac[module_idP];
+	COMMON_channels_t              *cc = eNB->common_channels;
+	UE_list_t                      *UE_list = &eNB->UE_list;
+	int                            continue_flag = 0;
+	int32_t                        normalized_rx_power, target_rx_power;
+	int32_t                        tpc = 1;
+	static int32_t                 tpc_accumulated = 0;
+	UE_sched_ctrl                  *ue_sched_ctl;
+	int                            mcs;
+	int                            i;
+	int                            min_rb_unit[MAX_NUM_CCs];
+	int                            N_RB_DL[MAX_NUM_CCs];
+	int                            total_nb_available_rb[MAX_NUM_CCs];
+	int                            N_RBG[MAX_NUM_CCs];
+	nfapi_dl_config_request_body_t *dl_req;
+	nfapi_dl_config_request_pdu_t  *dl_config_pdu;
+	nfapi_tx_request_pdu_t         *TX_req;
+	int                            tdd_sfa;
+
+#if 0
+	if (UE_list->head == -1) {
+		return;
+	}
+#endif
+
+	uint8_t                         *vrb_map;
+	int								first_rb;
+	start_meas(&eNB->schedule_dlsch);
+	VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_IN);
+
+
+
+	aggregation = 2;
+	for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
+		N_RB_DL[CC_id] = to_prb(cc[CC_id].mib->message.dl_Bandwidth);
+		min_rb_unit[CC_id] = get_min_rb_unit(module_idP, CC_id);
+		// get number of PRBs less those used by common channels
+		total_nb_available_rb[CC_id] = N_RB_DL[CC_id];
+		for (i = 0; i < N_RB_DL[CC_id]; i++)
+			if (cc[CC_id].vrb_map[i] != 0)
+				total_nb_available_rb[CC_id]--;
+
+		N_RBG[CC_id] = to_rbg(cc[CC_id].mib->message.dl_Bandwidth);
+
+		// store the global enb stats:
+		eNB->eNB_stats[CC_id].num_dlactive_UEs = UE_list->num_UEs;
+		eNB->eNB_stats[CC_id].available_prbs = total_nb_available_rb[CC_id];
+		eNB->eNB_stats[CC_id].total_available_prbs += total_nb_available_rb[CC_id];
+		eNB->eNB_stats[CC_id].dlsch_bytes_tx = 0;
+		eNB->eNB_stats[CC_id].dlsch_pdus_tx = 0;
+	}
+
+	/// CALLING Pre_Processor for downlink scheduling (Returns estimation of RBs required by each UE and the allocation on sub-band)
+
+	VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR, VCD_FUNCTION_IN);
+	//start_meas(&eNB->schedule_dlsch_preprocessor);
+	//dlsch_scheduler_pre_processor(module_idP,
+	 //   frameP,
+	//    subframeP,
+	//    N_RBG,
+	 //   mbsfn_flag);
+	//stop_meas(&eNB->schedule_dlsch_preprocessor);
+	VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR, VCD_FUNCTION_OUT);
+
+
+	for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++)
+	{
+		vrb_map = cc[CC_id].vrb_map;
+
+		LOG_D(MAC, "doing schedule_ue_spec for CC_id %d\n", CC_id);
+
+		dl_req = &eNB->DL_req[CC_id].dl_config_request_body;
+
+		if (mbsfn_flag[CC_id] > 0)
+			continue;
+		
+	    unsigned int rmax;
+            unsigned int narrowBandindex_index;
+            unsigned int first_rb, rep, reps;
+
+            // rmax from RRC connection setup
+            getRepetition(&UE_list->UE_template[CC_id][UE_id], &rmax, &narrowBandindex_index);
+
+            first_rb = narrowband_to_first_rb(cc,narrowBandindex_index);
+
+		if (vrb_map[first_rb] == 1)  // skip scheduling emtc UEs if first RB is taken 
+			continue ; 
+
+		for (UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id])
+		{
+
+            if (UE_list->UE_template[CC_id][UE_id].rach_resource_type ==0 )  // do  the following scheduling only if the UE is emtc
+                  continue ;
+
+            //[khalid] ******** allocate here the vrb_map
+            // 1st check on the vrb_map[] and allocate the one that is next to them
+
+            // at the end of the scheduler make sure the right subbands coresponding to these RBs are allocated the UE in UE_template directely
+            // also check on the fill_DCI function
+
+            
+
+            vrb_map[first_rb] = 1;
+            vrb_map[first_rb + 1] = 1;
+            vrb_map[first_rb + 2] = 1;
+            vrb_map[first_rb + 3] = 1;
+            vrb_map[first_rb + 4] = 1;
+            vrb_map[first_rb + 5] = 1;
+
+
+
+
+
+			continue_flag = 0; // reset the flag to allow allocation for the remaining UEs
+			rnti = UE_RNTI(module_idP, UE_id);
+			eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id];
+			ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id];
+
+            //[khalid] allocate the middle RB subbands in sf 1,5 for synch signals and PBCH
+
+
+
+
+			if (rnti == NOT_A_RNTI) {
+				LOG_D(MAC, "Cannot find rnti for UE_id %d (num_UEs %d)\n", UE_id, UE_list->num_UEs);
+				continue_flag = 1;
+			}
+
+			if (eNB_UE_stats == NULL) {
+				LOG_D(MAC, "[eNB] Cannot find eNB_UE_stats\n");
+				continue_flag = 1;
+			}
+
+			//if (continue_flag != 1) {
+			//	switch (get_tmode(module_idP, CC_id, UE_id)) {
+			//	case 1:
+			//	case 2:
+			//	case 7:
+			//		aggregation = get_aggregation(get_bw_index(module_idP, CC_id),
+			//			eNB_UE_stats->dl_cqi,
+			//			format1);
+			//		break;
+			//	case 3:
+			//		aggregation = get_aggregation(get_bw_index(module_idP, CC_id),
+			//			eNB_UE_stats->dl_cqi,
+			//			format2A);
+			//		break;
+			//	default:
+			//		LOG_W(MAC, "Unsupported transmission mode %d\n", get_tmode(module_idP, CC_id, UE_id));
+			//		aggregation = 2;
+			//	}
+			//}
+
+			if ((ue_sched_ctl->pre_nb_available_rbs[CC_id] == 0) ||  // no RBs allocated
+				CCE_allocation_infeasible(module_idP, CC_id, 0, subframeP, aggregation, rnti)
+				) {
+				LOG_D(MAC, "[eNB %d] Frame %d : no RB allocated for UE %d on CC_id %d: continue \n",
+					module_idP, frameP, UE_id, CC_id);
+				continue_flag = 1; //to next user (there might be rbs availiable for other UEs in TM5
+			}
+
+			//if (cc[CC_id].tdd_Config != NULL) { //TDD
+			//	set_ue_dai(subframeP,
+			//		UE_id,
+			//		CC_id,
+			//		cc[CC_id].tdd_Config->subframeAssignment,
+			//		UE_list);
+			//	// update UL DAI after DLSCH scheduling
+			//	set_ul_DAI(module_idP, UE_id, CC_id, frameP, subframeP);
+			//}
+
+		   //if (continue_flag == 1) {
+			//    add_ue_dlsch_info(module_idP,
+		   //         CC_id,
+			//        UE_id,
+			//        subframeP,
+			//        S_DL_NONE);
+		  //      continue;
+		   // }
 
+			nb_available_rb = 6; // to be checked
+			harq_pid = ue_sched_ctl->harq_pid[CC_id];
+			round = ue_sched_ctl->round[CC_id];
+			UE_list->eNB_UE_stats[CC_id][UE_id].crnti = rnti;
+			UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status = mac_eNB_get_rrc_status(module_idP, rnti);x
+			UE_list->eNB_UE_stats[CC_id][UE_id].harq_pid = harq_pid;
+			UE_list->eNB_UE_stats[CC_id][UE_id].harq_round = round;
+
+			sdu_length_total = 0;
+			num_sdus = 0;
+
+
+			//DevCheck(((eNB_UE_stats->dl_cqi < MIN_CQI_VALUE) || (eNB_UE_stats->dl_cqi > MAX_CQI_VALUE)),
+			//eNB_UE_stats->dl_cqi, MIN_CQI_VALUE, MAX_CQI_VALUE);
+
+			eNB_UE_stats->dlsch_mcs1 = cqi_to_mcs[eNB_UE_stats->dl_cqi]; //to be checked
+			eNB_UE_stats->dlsch_mcs1 = cmin(eNB_UE_stats->dlsch_mcs1, 15);
+
+
+			// store stats
+			UE_list->eNB_UE_stats[CC_id][UE_id].dl_cqi = eNB_UE_stats->dl_cqi;
+
+			// initializing the rb allocation indicator for each UE
+			//to be checked
+			for (j = 0; j < N_RBG[CC_id]; j++) {
+				UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = 0;
+			}
+
+			LOG_D(MAC, "[eNB %d] Frame %d: Scheduling UE %d on CC_id %d (rnti %x, harq_pid %d, round %d, rb %d, cqi %d, mcs %d, rrc %d)\n",
+				module_idP, frameP, UE_id, CC_id, rnti, harq_pid, round, nb_available_rb,
+				eNB_UE_stats->dl_cqi, eNB_UE_stats->dlsch_mcs1,
+				UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status);
+
+
+
+			// process retransmission
+
+			if (round > 0)
+			{
+
+
+                // choose r3 by default for RAR (Table 9.1.5-5)
+                rep = 2;
+                // get actual repetition count from Table 9.1.5-3
+                reps = (rmax <= 8) ? (1 << rep) : (rmax >> (3 - rep));
+
+
+				// get freq_allocation
+				nb_rb = 6;//UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid];
+
+				if (nb_rb <= nb_available_rb)
+				{
+					
+
+					//if (nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) {
+						for (j = 0; j < N_RBG[CC_id]; j++) { // for indicating the rballoc for each sub-band
+							UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j];
+						}
+					//}
+					//else {
+					//	nb_rb_temp = nb_rb;
+					//	j = 0;
+
+					//	while ((nb_rb_temp > 0) && (j < N_RBG[CC_id])) {
+					//		if (ue_sched_ctl->rballoc_sub_UE[CC_id][j] == 1) {
+					//			UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j];
+
+					//			if ((j == N_RBG[CC_id] - 1) &&
+					//				((N_RB_DL[CC_id] == 25) ||
+					//				(N_RB_DL[CC_id] == 50))) {
+					//				nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id] + 1;
+					//			}
+					//			else {
+					//				nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id];
+					//			}
+					//		}
+
+					//		j = j + 1;
+					//	}
+					//}
+
+					nb_available_rb -= nb_rb;
+
+					//eNB->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb;
+					//eNB->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id];
+
+					//for(j=0; j<N_RBG[CC_id]; j++) {
+					//eNB->mu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j];
+					//}
+
+
+					switch (get_tmode(module_idP, CC_id, UE_id)) {
+					case 1:
+					case 2:
+					case 7:
+					default:
+                    {
+
+                        if ((UE_list->UE_template[CC_id][UE_id].mpdcch_repetition_cnt == 0) &&
+                            (mpdcch_sf_condition(eNB, CC_id, frameP, subframeP, rmax, TYPEUESPEC,UE_id) > 0))
+						{
+							// MPDCCH configuration for RAR
+							dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
+							memset((void*)dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t));
+							dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE;
+							dl_config_pdu->pdu_size = (uint8_t)(2 + sizeof(nfapi_dl_config_mpdcch_pdu));
+                            dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_format = (UE_list->UE_template[CC_id][UE_id].rach_resource_type > 1) ? 11 : 10;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_narrow_band = narrowBandindex_index;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_prb_pairs = 6;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_tansmission_type = 1; // imposed (9.1.5 in 213) for Type 2 Common search space
+                            AssertFatal(cc[CC_id].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13 != NULL,
+								"cc[CC_id].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13 is null\n");
+                            dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.start_symbol = cc[CC_id].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ecce_index = 0;  // Note: this should be dynamic
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.aggregation_level = 16; // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti_type = 4;  // other-RNTI
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti = rnti;
+                            dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ce_mode = (UE_list->UE_template[CC_id][UE_id].rach_resource_type < 3) ? 1 : 2;
+                            dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.drms_scrambling_init = cc[CC_id].physCellId;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.initial_transmission_sf_io = (frameP * 10) + subframeP;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.transmission_power = 6000; // 0dB
+
+                            //[khalid] missing DCI format   should be 10 for 6-1A
+
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_coding = getRIV(6, 0, 6);  // Note: still to be checked if it should not be (getRIV(N_RB_DL,first_rb,6)) : Check nFAPI specifications and what is done L1 with this parameter
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs = UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid]; // adjust according to size of RAR, 208 bits with N1A_PRB=3
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pdsch_reptition_levels = 4; // fix to 4 for now
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.redundancy_version = (round & 3);
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.new_data_indicator = UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid];
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_process = harq_pid;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi_length = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi_flag = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_resource_offset = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_subframe_repetition_number = rep;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpc = 1;// N1A_PRB=3 (36.212); => 208 bits for mcs=4, choose mcs according t message size TBD
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index_length = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.allocate_prach_flag = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.preamble_index = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.prach_mask_index = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.starting_ce_level = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.srs_request = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity_flag = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.frequency_hopping_enabled_flag = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.paging_direct_indication_differentiation_flag = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.direct_indication = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding = 0; // this is not needed by OAI L1, but should be filled in
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports = 1;
+                            UE_list->UE_template[CC_id][UE_id].mpdcch_repetition_cnt++;
+							dl_req->number_pdu++;
+
+
+							
+
+							//eNB_UE_stats->dlsch_trials[round]++;
+							UE_list->eNB_UE_stats[CC_id][UE_id].num_retransmission += 1;
+							UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx = nb_rb;
+							UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_retx += nb_rb;
+							UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1 = eNB_UE_stats->dlsch_mcs1;
+							UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2 = eNB_UE_stats->dlsch_mcs1;
+
+							add_ue_dlsch_info(module_idP,
+								CC_id,
+								UE_id,
+								subframeP,
+								S_DL_SCHEDULED);
+
+						} //repetition_count==0 && SF condition met
+                        else if (UE_list->UE_template[CC_id][UE_id].mpdcch_repetition_cnt > 0)
+						{
+							// we're in a stream of repetitions
+                            UE_list->UE_template[CC_id][UE_id].mpdcch_repetition_cnt++;
+                            if (UE_list->UE_template[CC_id][UE_id].mpdcch_repetition_cnt == reps)
+							{
+								// this is the last mpdcch repetition
+                                if (cc[CC_id].tdd_Config == NULL) { // FDD case
+																	 // wait 2 subframes for PDSCH transmission
+                                    if (subframeP > 7) UE_list->UE_template[CC_id][UE_id].Msg2_frame = (frameP + 1) & 1023;
+                                    else             UE_list->UE_template[CC_id][UE_id].Msg2_frame = frameP;
+                                    UE_list->UE_template[CC_id][UE_id].Msg2_subframe = (subframeP + 2) % 10; // +2 is the "n+x" from Section 7.1.11  in 36.213
+								}
+								else {
+									AssertFatal(1 == 0, "TDD case not done yet\n");
+								}
+							} // mpdcch_repetition_count == reps
+                            if ((UE_list->UE_template[CC_id][UE_id].Msg2_frame == frameP) && (UE_list->UE_template[CC_id][UE_id].Msg2_subframe == subframeP)) {
+								// Program PDSCH
+
+								dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
+								memset((void*)dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t));
+								dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE;
+								dl_config_pdu->pdu_size = (uint8_t)(2 + sizeof(nfapi_dl_config_dlsch_pdu));
+                                dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = eNB->pdu_index[CC_id];
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = rnti;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 4;   // format 6-1A
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0;   // localized
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(N_RB_DL, first_rb, 6);
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = (round & 3);
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1;// first block
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc->p_eNB == 1) ? 0 : 1;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1;
+								//	dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index                         = ;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = 0;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = (cc->p_eNB == 1) ? 1 : 2;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1;
+								//	dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector                    = ;
+
+                                dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = (UE_list->UE_template[CC_id][UE_id].rach_resource_type < 3) ? 1 : 2;;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 2;  // not SI message
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = (10 * frameP) + subframeP;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.drms_table_flag = 0;
+								dl_req->number_pdu++;
+
+
+							}
+						}
+
+					}
+
+
+
+					
+					}
+
+					
+
+					
+				}
+				else {
+					LOG_D(MAC, "[eNB %d] Frame %d CC_id %d : don't schedule UE %d, its retransmission takes more resources than we have\n",
+						module_idP, frameP, CC_id, UE_id);
+				}
+			}
+			else 
+			{ 
+				// This is a potentially new SDU opportunity //
+
+				rlc_status.bytes_in_buffer = 0;
+				// Now check RLC information to compute number of required RBs
+				// get maximum TBS size for RLC request
+
+
+
+				TBS = 408;
+				// check first for RLC data on DCCH
+				// add the length for  all the control elements (timing adv, drx, etc) : header + payload
+
+				ta_len = (ue_sched_ctl->ta_update != 0) ? 2 : 0;
+
+				header_len_dcch = 2; // 2 bytes DCCH SDU subheader
+
+				if (TBS - ta_len - header_len_dcch > 0) {
+					rlc_status = mac_rlc_status_ind(
+						module_idP,
+						rnti,
+						module_idP,
+						frameP,
+						subframeP,
+						ENB_FLAG_YES,
+						MBMS_FLAG_NO,
+						DCCH,
+						(TBS - ta_len - header_len_dcch)); // transport block set size
+
+					sdu_lengths[0] = 0;
+
+					if (rlc_status.bytes_in_buffer > 0) {  // There is DCCH to transmit
+						LOG_D(MAC, "[eNB %d] Frame %d, DL-DCCH->DLSCH CC_id %d, Requesting %d bytes from RLC (RRC message)\n",
+							module_idP, frameP, CC_id, TBS - header_len_dcch);
+						sdu_lengths[0] = mac_rlc_data_req(
+							module_idP,
+							rnti,
+							module_idP,
+							frameP,
+							ENB_FLAG_YES,
+							MBMS_FLAG_NO,
+							DCCH,
+							TBS, //not used
+							(char *)&dlsch_buffer[0]);
+
+						T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP),
+							T_INT(harq_pid), T_INT(DCCH), T_INT(sdu_lengths[0]));
+
+						LOG_D(MAC, "[eNB %d][DCCH] CC_id %d Got %d bytes from RLC\n", module_idP, CC_id, sdu_lengths[0]);
+						sdu_length_total = sdu_lengths[0];
+						sdu_lcids[0] = DCCH;
+						UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[DCCH] += 1;
+						UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH] += sdu_lengths[0];
+						num_sdus = 1;
+#ifdef DEBUG_eNB_SCHEDULER
+						LOG_T(MAC, "[eNB %d][DCCH] CC_id %d Got %d bytes :", module_idP, CC_id, sdu_lengths[0]);
+
+						for (j = 0; j < sdu_lengths[0]; j++) {
+							LOG_T(MAC, "%x ", dlsch_buffer[j]);
+						}
+
+						LOG_T(MAC, "\n");
+#endif
+					}
+					else {
+						header_len_dcch = 0;
+						sdu_length_total = 0;
+					}
+				}
+
+				// check for DCCH1 and update header information (assume 2 byte sub-header)
+				if (TBS - ta_len - header_len_dcch - sdu_length_total > 0) {
+					rlc_status = mac_rlc_status_ind(
+						module_idP,
+						rnti,
+						module_idP,
+						frameP,
+						subframeP,
+						ENB_FLAG_YES,
+						MBMS_FLAG_NO,
+						DCCH + 1,
+						(TBS - ta_len - header_len_dcch - sdu_length_total)); // transport block set size less allocations for timing advance and
+																			  // DCCH SDU
+					sdu_lengths[num_sdus] = 0;
+
+					if (rlc_status.bytes_in_buffer > 0) {
+						LOG_I(MAC, "[eNB %d], Frame %d, DCCH1->DLSCH, CC_id %d, Requesting %d bytes from RLC (RRC message)\n",
+							module_idP, frameP, CC_id, TBS - header_len_dcch - sdu_length_total);
+						sdu_lengths[num_sdus] += mac_rlc_data_req(
+							module_idP,
+							rnti,
+							module_idP,
+							frameP,
+							ENB_FLAG_YES,
+							MBMS_FLAG_NO,
+							DCCH + 1,
+							TBS, //not used
+							(char *)&dlsch_buffer[sdu_length_total]);
+
+						T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP),
+							T_INT(harq_pid), T_INT(DCCH + 1), T_INT(sdu_lengths[num_sdus]));
+
+						sdu_lcids[num_sdus] = DCCH1;
+						sdu_length_total += sdu_lengths[num_sdus];
+						header_len_dcch += 2;
+						UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[DCCH1] += 1;
+						UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH1] += sdu_lengths[num_sdus];
+						num_sdus++;
+#ifdef DEBUG_eNB_SCHEDULER
+						LOG_T(MAC, "[eNB %d][DCCH1] CC_id %d Got %d bytes :", module_idP, CC_id, sdu_lengths[num_sdus]);
+
+						for (j = 0; j < sdu_lengths[num_sdus]; j++) {
+							LOG_T(MAC, "%x ", dlsch_buffer[j]);
+						}
+
+						LOG_T(MAC, "\n");
+#endif
+
+					}
+				}
+
+				// assume the max dtch header size, and adjust it later
+				header_len_dtch = 0;
+				header_len_dtch_last = 0; // the header length of the last mac sdu
+										  // lcid has to be sorted before the actual allocation (similar struct as ue_list).
+				for (lcid = NB_RB_MAX - 1; lcid >= DTCH; lcid--) {
+					// TBD: check if the lcid is active
+
+					header_len_dtch += 3;
+					header_len_dtch_last = 3;
+					LOG_D(MAC, "[eNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (tbs %d, len %d)\n",
+						module_idP, frameP, lcid, TBS,
+						TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch);
+
+					if (TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch > 0) { // NN: > 2 ? 
+						rlc_status = mac_rlc_status_ind(module_idP,
+							rnti,
+							module_idP,
+							frameP,
+							subframeP,
+							ENB_FLAG_YES,
+							MBMS_FLAG_NO,
+							lcid,
+							TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch);
+
+
+						if (rlc_status.bytes_in_buffer > 0) {
+
+							LOG_D(MAC, "[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n",
+								module_idP, frameP, TBS - header_len_dcch - sdu_length_total - header_len_dtch, lcid, header_len_dtch);
+							sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,
+								rnti,
+								module_idP,
+								frameP,
+								ENB_FLAG_YES,
+								MBMS_FLAG_NO,
+								lcid,
+								TBS,	//not used
+								(char*)&dlsch_buffer[sdu_length_total]);
+							T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP),
+								T_INT(harq_pid), T_INT(lcid), T_INT(sdu_lengths[num_sdus]));
+
+							LOG_D(MAC, "[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", module_idP, sdu_lengths[num_sdus], lcid);
+							sdu_lcids[num_sdus] = lcid;
+							sdu_length_total += sdu_lengths[num_sdus];
+							UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[lcid] += 1;
+							UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[lcid] += sdu_lengths[num_sdus];
+							if (sdu_lengths[num_sdus] < 128) {
+								header_len_dtch--;
+								header_len_dtch_last--;
+							}
+							num_sdus++;
+						} // no data for this LCID
+						else {
+							header_len_dtch -= 3;
+						}
+					} // no TBS left
+					else {
+						header_len_dtch -= 3;
+						break;
+					}
+				}
+				if (header_len_dtch == 0)
+					header_len_dtch_last = 0;
+				// there is at least one SDU 
+				// if (num_sdus > 0 ){
+				if ((sdu_length_total + header_len_dcch + header_len_dtch) > 0) {
+
+					// Now compute number of required RBs for total sdu length
+					// Assume RAH format 2
+					// adjust  header lengths
+					header_len_dcch_tmp = header_len_dcch;
+					header_len_dtch_tmp = header_len_dtch;
+					if (header_len_dtch == 0) {
+						header_len_dcch = (header_len_dcch > 0) ? 1 : 0;//header_len_dcch;  // remove length field
+					}
+					else {
+						header_len_dtch_last -= 1; // now use it to find how many bytes has to be removed for the last MAC SDU 
+						header_len_dtch = (header_len_dtch > 0) ? header_len_dtch - header_len_dtch_last : header_len_dtch;     // remove length field for the last SDU
+					}
+
+					//mcs = eNB_UE_stats->dlsch_mcs1;
+					//if (mcs == 0) {
+					//	nb_rb = 4;  // don't let the TBS get too small
+					//}
+					//else {
+					//	nb_rb = min_rb_unit[CC_id];
+					//}
+
+                    //[khalid]: maximum MCS (7 or 15) depend on the DCI formate used from UE_list->UE_template[CC_id [UE_id].rach_resource_type
+
+					mcs = 4;
+					nb_rb = 6;
+
+
+					TBS = 408;//get_TBS_DL(mcs, nb_rb);
+
+					//while (TBS < (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) {
+					//	nb_rb += min_rb_unit[CC_id];  //
+
+					//	if (nb_rb > nb_available_rb) { // if we've gone beyond the maximum number of RBs
+					//								 // (can happen if N_RB_DL is odd)
+					//		TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_available_rb);
+					//		nb_rb = nb_available_rb;
+					//		break;
+					//	}
+
+					//	TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_rb);
+					//}
+
+					//if (nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) {
+						for (j = 0; j < N_RBG[CC_id]; j++) { // for indicating the rballoc for each sub-band
+							UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j];
+						}
+					//}
+					//else 
+					//{
+					//	nb_rb_temp = nb_rb;
+					//	j = 0;
+
+					//	while ((nb_rb_temp > 0) && (j < N_RBG[CC_id])) {
+					//		if (ue_sched_ctl->rballoc_sub_UE[CC_id][j] == 1) {
+					//			UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j];
+
+					//			if ((j == N_RBG[CC_id] - 1) &&
+					//				((N_RB_DL[CC_id] == 25) ||
+					//				(N_RB_DL[CC_id] == 50))) {
+					//				nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id] + 1;
+					//			}
+					//			else {
+					//				nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id];
+					//			}
+					//		}
+
+					//		j = j + 1;
+					//	}
+					//}
+					
+					//RC.eNB[module_idP][CC_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb;
+					//RC.eNB[module_idP][CC_id]->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id];
+
+					//for(j=0; j<N_RBG[CC_id]; j++) {
+					//RC.eNB[module_idP][CC_id]->mu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j];
+
+					//}
+					//
+					// decrease mcs until TBS falls below required length
+					//while ((TBS > (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) && (mcs > 0)) {
+					//	mcs--;
+					//	TBS = get_TBS_DL(mcs, nb_rb);
+					//}
+
+                    // if we have decreased too much or we don't have enough RBs, increase MCS
+					//while ((TBS < (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) && (((ue_sched_ctl->dl_pow_off[CC_id] > 0) && (mcs < 28))
+					//	|| ((ue_sched_ctl->dl_pow_off[CC_id] == 0) && (mcs <= 15)))) {
+					//	mcs++;
+					//	TBS = get_TBS_DL(mcs, nb_rb);
+					//}
+
+					LOG_D(MAC, "dlsch_mcs before and after the rate matching = (%d, %d)\n", eNB_UE_stats->dlsch_mcs1, mcs);
+
+#ifdef DEBUG_eNB_SCHEDULER
+					LOG_D(MAC, "[eNB %d] CC_id %d Generated DLSCH header (mcs %d, TBS %d, nb_rb %d)\n",
+						module_idP, CC_id, mcs, TBS, nb_rb);
+					// msg("[MAC][eNB ] Reminder of DLSCH with random data %d %d %d %d \n",
+					//  TBS, sdu_length_total, offset, TBS-sdu_length_total-offset);
+#endif
+
+					if ((TBS - header_len_dcch - header_len_dtch - sdu_length_total - ta_len) <= 2) {
+						padding = (TBS - header_len_dcch - header_len_dtch - sdu_length_total - ta_len);
+						post_padding = 0;
+					}
+					else {
+						padding = 0;
+
+						// adjust the header len
+						if (header_len_dtch == 0) {
+							header_len_dcch = header_len_dcch_tmp;
+						}
+						else { //if (( header_len_dcch==0)&&((header_len_dtch==1)||(header_len_dtch==2)))
+							header_len_dtch = header_len_dtch_tmp;
+						}
+
+						post_padding = TBS - sdu_length_total - header_len_dcch - header_len_dtch - ta_len; // 1 is for the postpadding header
+					}
+
+
+					offset = generate_dlsch_header((unsigned char*)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0],
+						num_sdus,              //num_sdus
+						sdu_lengths,  //
+						sdu_lcids,
+						255,                                   // no drx
+						ue_sched_ctl->ta_update, // timing advance
+						NULL,                                  // contention res id
+						padding,
+						post_padding);
+
+					//#ifdef DEBUG_eNB_SCHEDULER
+					if (ue_sched_ctl->ta_update) {
+						LOG_I(MAC,
+							"[eNB %d][DLSCH] Frame %d Generate header for UE_id %d on CC_id %d: sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,timing advance value : %d, padding %d,post_padding %d,(mcs %d, TBS %d, nb_rb %d),header_dcch %d, header_dtch %d\n",
+							module_idP, frameP, UE_id, CC_id, sdu_length_total, num_sdus, sdu_lengths[0], sdu_lcids[0], offset,
+							ue_sched_ctl->ta_update, padding, post_padding, mcs, TBS, nb_rb, header_len_dcch, header_len_dtch);
+					}
+					//#endif
+#ifdef DEBUG_eNB_SCHEDULER
+					LOG_T(MAC, "[eNB %d] First 16 bytes of DLSCH : \n");
+
+					for (i = 0; i < 16; i++) {
+						LOG_T(MAC, "%x.", dlsch_buffer[i]);
+					}
+
+					LOG_T(MAC, "\n");
+#endif
+					// cycle through SDUs and place in dlsch_buffer
+					memcpy(&UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset], dlsch_buffer, sdu_length_total);
+					// memcpy(RC.mac[0].DLSCH_pdu[0][0].payload[0][offset],dcch_buffer,sdu_lengths[0]);
+
+					// fill remainder of DLSCH with random data
+					for (j = 0; j < (TBS - sdu_length_total - offset); j++) {
+						UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset + sdu_length_total + j] = (char)(taus() & 0xff);
+					}
+
+
+					if (opt_enabled == 1) {
+						trace_pdu(1, (uint8_t *)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0],
+							TBS, module_idP, 3, UE_RNTI(module_idP, UE_id),
+							eNB->frame, eNB->subframe, 0, 0);
+						LOG_D(OPT, "[eNB %d][DLSCH] CC_id %d Frame %d  rnti %x  with size %d\n",
+							module_idP, CC_id, frameP, UE_RNTI(module_idP, UE_id), TBS);
+					}
+
+					T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP),
+						T_INT(harq_pid), T_BUFFER(UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], TBS));
+
+					UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] = nb_rb;
+
+					add_ue_dlsch_info(module_idP,
+						CC_id,
+						UE_id,
+						subframeP,
+						S_DL_SCHEDULED);
+					// store stats
+					eNB->eNB_stats[CC_id].dlsch_bytes_tx += sdu_length_total;
+					eNB->eNB_stats[CC_id].dlsch_pdus_tx += 1;
+
+					UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used = nb_rb;
+					UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used += nb_rb;
+					UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1 = 4;//eNB_UE_stats->dlsch_mcs1;
+					UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2 = mcs;
+					UE_list->eNB_UE_stats[CC_id][UE_id].TBS = TBS;
+
+					UE_list->eNB_UE_stats[CC_id][UE_id].overhead_bytes = TBS - sdu_length_total;
+					UE_list->eNB_UE_stats[CC_id][UE_id].total_sdu_bytes += sdu_length_total;
+					UE_list->eNB_UE_stats[CC_id][UE_id].total_pdu_bytes += TBS;
+					UE_list->eNB_UE_stats[CC_id][UE_id].total_num_pdus += 1;
+
+					
+
+					// do PUCCH power control
+					// this is the normalized RX power
+					eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id];
+					normalized_rx_power = eNB_UE_stats->Po_PUCCH_dBm;
+					target_rx_power = get_target_pucch_rx_power(module_idP, CC_id) + 20;
+
+					// this assumes accumulated tpc
+					// make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out
+					//int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame * 10 + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe;
+					//if (((framex10psubframe + 10) <= (frameP * 10 + subframeP)) || //normal case
+					//	((framex10psubframe > (frameP * 10 + subframeP)) && (((10240 - framex10psubframe + frameP * 10 + subframeP) >= 10)))) //frame wrap-around
+					//	if (eNB_UE_stats->Po_PUCCH_update == 1) {
+					//		eNB_UE_stats->Po_PUCCH_update = 0;
+
+					//		UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame = frameP;
+					//		UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe = subframeP;
+
+					//		if (normalized_rx_power > (target_rx_power + 1)) {
+					//			tpc = 0; //-1
+					//			tpc_accumulated--;
+					//		}
+					//		else if (normalized_rx_power < (target_rx_power - 1)) {
+					//			tpc = 2; //+1
+					//			tpc_accumulated++;
+					//		}
+					//		else {
+					//			tpc = 1; //0
+					//		}
+					//		
+					//		
+
+					//	} // Po_PUCCH has been updated 
+					//	else {
+					//		tpc = 1; //0
+					//	} // time to do TPC update 
+					//else {
+					//	tpc = 1; //0
+					//}
+
+                    {
+
+						// choose r3 by default for RAR (Table 9.1.5-5)
+						rep = 2;
+						// get actual repetition count from Table 9.1.5-3
+						reps = (rmax <= 8) ? (1 << rep) : (rmax >> (3 - rep));
+						
+
+
+                        if ((UE_list->UE_template[CC_id][UE_id].mpdcch_repetition_cnt == 0) &&
+                            (mpdcch_sf_condition(eNB, CC_id, frameP, subframeP, rmax, TYPEUESPEC,UE_id) > 0))
+						{
+							// MPDCCH configuration for RAR
+							dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
+							memset((void*)dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t));
+							dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE;
+							dl_config_pdu->pdu_size = (uint8_t)(2 + sizeof(nfapi_dl_config_mpdcch_pdu));
+                            dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_format = (UE_list->UE_template[CC_id][UE_id].rach_resource_type > 1) ? 11 : 10;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_narrow_band = narrowBandindex_index;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_prb_pairs = 6;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_tansmission_type = 1; // imposed (9.1.5 in 213) for Type 2 Common search space
+                            AssertFatal(cc[CC_id].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13 != NULL,
+								"cc[CC_id].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13 is null\n");
+                            dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.start_symbol = cc[CC_id].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ecce_index = 0;  // Note: this should be dynamic
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.aggregation_level = 16; // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti_type = 4;  // other-RNTI
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti = rnti;
+                            dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ce_mode = (UE_list->UE_template[CC_id][UE_id].rach_resource_type < 3) ? 1 : 2;
+                            dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.drms_scrambling_init = cc[CC_id].physCellId;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.initial_transmission_sf_io = (frameP * 10) + subframeP;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.transmission_power = 6000; // 0dB
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_coding = getRIV(6, 0, 6);  // Note: still to be checked if it should not be (getRIV(N_RB_DL,first_rb,6)) : Check nFAPI specifications and what is done L1 with this parameter
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs = 4; // adjust according to size of RAR, 208 bits with N1A_PRB=3
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pdsch_reptition_levels = 4; // fix to 4 for now
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.redundancy_version = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.new_data_indicator = 1 - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid];
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_process = harq_pid;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi_length = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi_flag = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_resource_offset = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_subframe_repetition_number = rep;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpc = 1;// N1A_PRB=3 (36.212); => 208 bits for mcs=4, choose mcs according t message size TBD
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index_length = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.allocate_prach_flag = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.preamble_index = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.prach_mask_index = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.starting_ce_level = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.srs_request = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity_flag = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.frequency_hopping_enabled_flag = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.paging_direct_indication_differentiation_flag = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.direct_indication = 0;
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding = 0; // this is not needed by OAI L1, but should be filled in
+							dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports = 1;
+                            UE_list->UE_template[CC_id][UE_id].mpdcch_repetition_cnt++;
+							dl_req->number_pdu++;
+
+
+							// Toggle NDI for next time
+							LOG_D(MAC, "CC_id %d Frame %d, subframeP %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n",
+								CC_id, frameP, subframeP, UE_id,
+								UE_list->UE_template[CC_id][UE_id].rnti, harq_pid, UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]);
+
+							UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid] = 1 - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid];
+							UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid] = mcs;
+							UE_list->UE_template[CC_id][UE_id].oldmcs2[harq_pid] = 0;
+
+							eNB->TX_req[CC_id].sfn_sf = (frameP << 3) + subframeP;
+							TX_req = &eNB->TX_req[CC_id].tx_request_body.tx_pdu_list[eNB->TX_req[CC_id].tx_request_body.number_of_pdus];
+							TX_req->pdu_length = TBS;
+							TX_req->pdu_index = eNB->pdu_index[CC_id]++;
+							TX_req->num_segments = 1;
+							TX_req->segments[0].segment_length = TBS;
+							TX_req->segments[0].segment_data = eNB->UE_list.DLSCH_pdu[CC_id][0][(unsigned char)UE_id].payload[harq_pid];
+							eNB->TX_req[CC_id].tx_request_body.number_of_pdus++;
+
+						} //repetition_count==0 && SF condition met
+                        else if (UE_list->UE_template[CC_id][UE_id].mpdcch_repetition_cnt > 0)
+						{
+							// we're in a stream of repetitions
+                            UE_list->UE_template[CC_id][UE_id].mpdcch_repetition_cnt++;
+                            if (UE_list->UE_template[CC_id][UE_id].mpdcch_repetition_cnt == reps)
+							{ 
+								// this is the last mpdcch repetition
+                                if (cc[CC_id].tdd_Config == NULL) { // FDD case
+																	 // wait 2 subframes for PDSCH transmission
+                                    if (subframeP > 7) UE_list->UE_template[CC_id][UE_id].Msg2_frame = (frameP + 1) & 1023;
+                                    else             UE_list->UE_template[CC_id][UE_id].Msg2_frame = frameP;
+                                    UE_list->UE_template[CC_id][UE_id].Msg2_subframe = (subframeP + 2) % 10; // +2 is the "n+x" from Section 7.1.11  in 36.213
+								}
+								else {
+									AssertFatal(1 == 0, "TDD case not done yet\n");
+								}
+							} // mpdcch_repetition_count == reps
+                            if ((UE_list->UE_template[CC_id][UE_id].Msg2_frame == frameP) && (UE_list->UE_template[CC_id][UE_id].Msg2_subframe == subframeP)) {
+								// Program PDSCH
+								
+								dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
+								memset((void*)dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t));
+								dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE;
+								dl_config_pdu->pdu_size = (uint8_t)(2 + sizeof(nfapi_dl_config_dlsch_pdu));
+                                dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = eNB->pdu_index[CC_id];
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = rnti;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 4;   // format 6-1A
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0;   // localized
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(N_RB_DL, first_rb, 6);
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = 0;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1;// first block
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc->p_eNB == 1) ? 0 : 1;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1;
+								//	dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index                         = ;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = 0;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = (cc->p_eNB == 1) ? 1 : 2;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1;
+								//	dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector                    = ;
+
+                                dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = (UE_list->UE_template[CC_id][UE_id].rach_resource_type < 3) ? 1 : 2;;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 2;  // not SI message
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = (10 * frameP) + subframeP;
+								dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.drms_table_flag = 0;
+								dl_req->number_pdu++;
+
+								// Program UL processing for Msg3, same as regular LTE
+								//get_Msg3alloc(&cc[CC_idP], subframeP, frameP, &RA_template->Msg3_frame, &RA_template->Msg3_subframe);
+
+
+								//fill_rar_br(eNB, CC_idP, RA_template, frameP, subframeP, cc[CC_idP].RAR_pdu.payload, RA_template->rach_resource_type - 1);
+								//// DL request
+								//eNB->TX_req[CC_idP].sfn_sf = (frameP << 3) + subframeP;
+								//TX_req = &eNB->TX_req[CC_idP].tx_request_body.tx_pdu_list[eNB->TX_req[CC_idP].tx_request_body.number_of_pdus];
+								//TX_req->pdu_length = 7;  // This should be changed if we have more than 1 preamble
+								//TX_req->pdu_index = eNB->pdu_index[CC_idP]++;
+								//TX_req->num_segments = 1;
+								//TX_req->segments[0].segment_length = 7;
+								//TX_req->segments[0].segment_data = cc[CC_idP].RAR_pdu.payload;
+								//eNB->TX_req[CC_idP].tx_request_body.number_of_pdus++;
+							}
+						}
+
+					}
+
+					//dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
+					//memset((void*)dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t));
+					//dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE;
+					//dl_config_pdu->pdu_size = (uint8_t)(2 + sizeof(nfapi_dl_config_dci_dl_pdu));
+					//dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1;
+					//dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = get_aggregation(get_bw_index(module_idP, CC_id), eNB_UE_stats->dl_cqi, format1);
+					//dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti;
+					//dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1;    // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications
+					//dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power
+
+					//dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = harq_pid;
+					//dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = tpc; // dont adjust power when retransmitting
+					//dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = 1 - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid];
+					//dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = mcs;
+					//dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = 0;
+					////deactivate second codeword
+					//dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_2 = 0;
+					//dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_2 = 1;
+				
+					//dl_req->number_dci++;
+					//dl_req->number_pdu++;
+
+
+				}
+				else {  // There is no data from RLC or MAC header, so don't schedule
+
+				}
+			}
+
+			if (cc[CC_id].tdd_Config != NULL) { // TDD
+				set_ul_DAI(module_idP, UE_id, CC_id, frameP, subframeP);
+			}
+
+		} // UE_id loop
+	}  // CC_id loop
+
+
+	fill_DLSCH_dci(module_idP, frameP, subframeP, mbsfn_flag);
+
+	stop_meas(&eNB->schedule_dlsch);
+	VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_OUT);
+
+}
+*/
+
+			
 //------------------------------------------------------------------------------
 void
 schedule_ue_spec(module_id_t module_idP, int slice_idxP,
@@ -583,6 +1677,8 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP,
         continue_flag = 1;
       }
 
+      if (UE_list->UE_template[CC_id][UE_id].rach_resource_type > 0) continue_flag=1;
+	
       if (eNB_UE_stats == NULL) {
         LOG_D(MAC, "[eNB] Cannot find eNB_UE_stats\n");
         continue_flag = 1;
@@ -613,7 +1709,7 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP,
             break;
 
           default:
-            LOG_W(MAC, "Unsupported transmission mode %d\n", get_tmode(module_idP, CC_id, UE_id));
+            AssertFatal(1==0,"Unsupported transmission mode %d\n", get_tmode(module_idP, CC_id, UE_id));
             aggregation = 2;
         }
       }
@@ -1595,6 +2691,606 @@ void dlsch_scheduler_qos_multiplexing(module_id_t Mod_id, int frameP, sub_frame_
 }
 
 
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+//------------------------------------------------------------------------------
+void
+schedule_ue_spec_br(
+		    module_id_t   module_idP,
+		    frame_t       frameP,
+		    sub_frame_t   subframeP
+		    ) {
+  int CC_id = 0,UE_id;
+  eNB_MAC_INST                        *mac = RC.mac[module_idP];
+  COMMON_channels_t                    *cc = mac->common_channels;
+  UE_list_t                      *UE_list  = &mac->UE_list;
+  UE_TEMPLATE       *UE_template;
+  UE_sched_ctrl     *ue_sched_ctl;
+  int32_t                        tpc=1;
+  int rvseq[4] = {0,2,3,1};
+  mac_rlc_status_resp_t          rlc_status;
+  unsigned char                  header_len_dcch=0, header_len_dcch_tmp=0; 
+  unsigned char                  header_len_dtch=0, header_len_dtch_tmp=0, header_len_dtch_last=0; 
+  unsigned char                  ta_len=0;
+  unsigned char                  sdu_lcids[NB_RB_MAX],lcid,offset,num_sdus=0;
+  uint16_t                       TBS,j,sdu_lengths[NB_RB_MAX],rnti,padding=0,post_padding=0;
+  unsigned char                  dlsch_buffer[MAX_DLSCH_PAYLOAD_BYTES];
+  int round;
+  int                            ta_update;
+  uint16_t                       sdu_length_total = 0;
+  int                            mcs;
+  int32_t                        normalized_rx_power, target_rx_power;
+
+  nfapi_dl_config_request_pdu_t *dl_config_pdu;
+  nfapi_ul_config_request_pdu_t *ul_config_pdu;
+  nfapi_tx_request_pdu_t *TX_req;
+  nfapi_dl_config_request_body_t *dl_req;
+  nfapi_ul_config_request_body_t *ul_req;
+
+  struct LTE_PRACH_ConfigSIB_v1310 *ext4_prach;
+  struct LTE_PUCCH_ConfigCommon_v1310 *ext4_pucch;
+  LTE_PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13;
+  struct LTE_N1PUCCH_AN_InfoList_r13 *pucch_N1PUCCH_AN_InfoList_r13;
+  int             pucchreps[4] = { 1, 1, 1, 1 };
+  int             n1pucchan[4] = { 0, 0, 0, 0 }; 
+  uint32_t        ackNAK_absSF;
+  int             first_rb;
+
+  dl_req = &mac->DL_req[CC_id].dl_config_request_body;
+  dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
+
+  if ((frameP&1) == 0) return;
+
+  if (cc[CC_id].mib->message.schedulingInfoSIB1_BR_r13 ==0) return;
+
+  if (cc[CC_id].radioResourceConfigCommon_BR) {
+
+    ext4_prach = cc[CC_id].radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310;
+    ext4_pucch = cc[CC_id].radioResourceConfigCommon_BR->ext4->pucch_ConfigCommon_v1310;
+    prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13;
+    pucch_N1PUCCH_AN_InfoList_r13 = ext4_pucch->n1PUCCH_AN_InfoList_r13;
+    AssertFatal (prach_ParametersListCE_r13 != NULL, "prach_ParametersListCE_r13 is null\n");
+    AssertFatal (pucch_N1PUCCH_AN_InfoList_r13 != NULL, "pucch_N1PUCCH_AN_InfoList_r13 is null\n");
+    // check to verify CE-Level compatibility in SIB2_BR
+    AssertFatal (prach_ParametersListCE_r13->list.count == pucch_N1PUCCH_AN_InfoList_r13->list.count, "prach_ParametersListCE_r13->list.count!= pucch_N1PUCCH_AN_InfoList_r13->list.count\n");
+
+    switch (prach_ParametersListCE_r13->list.count) {
+    case 4:
+      n1pucchan[3] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[3];
+      AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level3_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level3 shouldn't be NULL\n");
+      pucchreps[3] = (int) (4 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level3_r13);
+
+    case 3:
+      n1pucchan[2] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[2];
+      AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level2 shouldn't be NULL\n");
+      pucchreps[2] = (int) (4 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13);
+    case 2:
+      n1pucchan[1] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[1];
+      AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level1_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level1 shouldn't be NULL\n");
+      pucchreps[1] = (int) (1 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level1_r13);
+    case 1:
+      n1pucchan[0] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[0];
+      AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level0_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level0 shouldn't be NULL\n");
+      pucchreps[0] = (int) (1 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level0_r13);
+      break;
+    default:
+      AssertFatal (1 == 0, "Illegal count for prach_ParametersListCE_r13 %d\n", prach_ParametersListCE_r13->list.count);
+    }
+  }
+
+  for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) {
+
+    int harq_pid = 0;
+
+    rnti = UE_RNTI(module_idP,UE_id);
+    if (rnti==NOT_A_RNTI)  continue;
+
+    ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id];
+    UE_template  = &UE_list->UE_template[CC_id][UE_id];
+
+    if (UE_template->rach_resource_type == 0) continue;
+    uint8_t rrc_status = mac_eNB_get_rrc_status(module_idP, rnti);
+
+    if (rrc_status < RRC_CONNECTED) continue;
+
+    round = ue_sched_ctl->round[CC_id][harq_pid];
+
+    AssertFatal (UE_template->physicalConfigDedicated != NULL, 
+		 "UE_template->physicalConfigDedicated is null\n");
+    AssertFatal (UE_template->physicalConfigDedicated->ext4 != NULL, 
+		 "UE_template->physicalConfigDedicated->ext4 is null\n");
+    AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11 != NULL, 
+		 "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11 is null\n");
+    AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present == LTE_EPDCCH_Config_r11__config_r11_PR_setup, 
+		 "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present != setup\n");
+    AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 != NULL,
+		 "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 = NULL\n");
+
+    LTE_EPDCCH_SetConfig_r11_t *epdcch_setconfig_r11 = UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.array[0];
+
+    AssertFatal(epdcch_setconfig_r11 != NULL, "epdcch_setconfig_r11 is null\n");
+    AssertFatal(epdcch_setconfig_r11->ext2!=NULL, "epdcch_setconfig_r11->ext2 is null\n");
+    AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13!=NULL,
+		"epdcch_setconfig_r11->ext2->mpdcch_config_r13 is null");
+    AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13!=NULL,
+		"epdcch_setconfig_r11->ext2->mpdcch_config_r13 is null");
+    AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13->present==LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13_PR_setup, 
+		"epdcch_setconfig_r11->ext2->mpdcch_config_r13->present is not setup\n");
+    AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310!=NULL,
+		"epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310 is null");
+    AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present==LTE_EPDCCH_SetConfig_r11__ext2__numberPRB_Pairs_v1310_PR_setup, 
+		"epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present is not setup\n");
+           
+
+    // simple scheduler for 1 repetition, 1 HARQ
+    if (subframeP == 5) { // MPDCCH
+
+      if (round == 8) {
+        rlc_status.bytes_in_buffer = 0;
+        // Now check RLC information to compute number of required RBs
+        // get maximum TBS size for RLC request
+        TBS = get_TBS_DL(9,6);
+        // check first for RLC data on DCCH
+        // add the length for  all the control elements (timing adv, drx, etc) : header + payload
+
+        if (ue_sched_ctl->ta_timer == 0) {
+          ta_update = ue_sched_ctl->ta_update;
+          /* if we send TA then set timer to not send it for a while */
+          if (ta_update != 31)
+            ue_sched_ctl->ta_timer = 20;
+          /* reset ta_update */
+          ue_sched_ctl->ta_update = 31;
+        } else {
+          ta_update = 31;
+        }
+
+        ta_len = (ta_update != 31) ? 2 : 0;
+
+        header_len_dcch = 2; // 2 bytes DCCH SDU subheader
+
+        if ( TBS-ta_len-header_len_dcch > 0 ) {
+	  LOG_I(MAC,"Calling mac_rlc_status_ind for DCCH\n");
+          rlc_status = mac_rlc_status_ind(
+					  module_idP,
+					  rnti,
+					  module_idP,
+					  frameP,
+					  subframeP,
+					  ENB_FLAG_YES,
+					  MBMS_FLAG_NO,
+					  DCCH,
+					  (TBS-ta_len-header_len_dcch)
+					  ,0, 0
+					  ); // transport block set size
+
+          sdu_lengths[0]=0;
+
+          if (rlc_status.bytes_in_buffer > 0) {  // There is DCCH to transmit
+            LOG_I(MAC,"[eNB %d] Frame %d, DL-DCCH->DLSCH CC_id %d, Requesting %d bytes from RLC (RRC message)\n",
+                  module_idP,frameP,CC_id,TBS-header_len_dcch);
+            sdu_lengths[0] = mac_rlc_data_req(
+					      module_idP,
+					      rnti,
+					      module_idP,
+					      frameP,
+					      ENB_FLAG_YES,
+					      MBMS_FLAG_NO,
+					      DCCH,
+					      TBS, //not used
+					      (char *)&dlsch_buffer[0]
+					      ,0, 0
+);
+
+            T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP),
+              T_INT(harq_pid), T_INT(DCCH), T_INT(sdu_lengths[0]));
+
+            LOG_I(MAC,"[eNB %d][DCCH] CC_id %d Got %d bytes from RLC\n",module_idP,CC_id,sdu_lengths[0]);
+            sdu_length_total = sdu_lengths[0];
+            sdu_lcids[0] = DCCH;
+            UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[DCCH]+=1;
+            UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH]+=sdu_lengths[0];
+            num_sdus = 1;
+          } else {
+            header_len_dcch = 0;
+            sdu_length_total = 0;
+          }
+        }
+	
+        // check for DCCH1 and update header information (assume 2 byte sub-header)
+        if (TBS-ta_len-header_len_dcch-sdu_length_total > 0 ) {
+          rlc_status = mac_rlc_status_ind(
+					  module_idP,
+					  rnti,
+					  module_idP,
+					  frameP,
+					  subframeP,
+					  ENB_FLAG_YES,
+					  MBMS_FLAG_NO,
+					  DCCH+1,
+					  (TBS-ta_len-header_len_dcch-sdu_length_total)
+					  ,0, 0); // transport block set size less allocations for timing advance and
+          // DCCH SDU
+	  sdu_lengths[num_sdus] = 0;
+	  
+          if (rlc_status.bytes_in_buffer > 0) {
+            LOG_I(MAC,"[eNB %d], Frame %d, DCCH1->DLSCH, CC_id %d, Requesting %d bytes from RLC (RRC message)\n",
+                  module_idP,frameP,CC_id,TBS-header_len_dcch-sdu_length_total);
+            sdu_lengths[num_sdus] += mac_rlc_data_req(
+						      module_idP,
+						      rnti,
+						      module_idP,
+						      frameP,
+						      ENB_FLAG_YES,
+						      MBMS_FLAG_NO,
+						      DCCH+1,
+						      TBS, //not used
+						      (char *)&dlsch_buffer[sdu_length_total]
+						      ,0, 0
+						      );
+	    
+            T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP),
+              T_INT(harq_pid), T_INT(DCCH+1), T_INT(sdu_lengths[num_sdus]));
+
+            sdu_lcids[num_sdus] = DCCH1;
+            sdu_length_total += sdu_lengths[num_sdus];
+            header_len_dcch += 2;
+            UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[DCCH1]+=1;
+            UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH1]+=sdu_lengths[num_sdus];
+	    num_sdus++;
+	  }
+        }
+
+	// assume the max dtch header size, and adjust it later
+	header_len_dtch=0;
+	header_len_dtch_last=0; // the header length of the last mac sdu
+	// lcid has to be sorted before the actual allocation (similar struct as ue_list).
+	for (lcid=NB_RB_MAX-1; lcid>=DTCH ; lcid--){
+	  // TBD: check if the lcid is active
+	  
+	  header_len_dtch+=3; 
+	  header_len_dtch_last=3;
+	  LOG_D(MAC,"[eNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (tbs %d, len %d)\n",
+		module_idP,frameP,lcid,TBS,
+		TBS-ta_len-header_len_dcch-sdu_length_total-header_len_dtch);
+	  
+	  if (TBS-ta_len-header_len_dcch-sdu_length_total-header_len_dtch > 0 ) { // NN: > 2 ? 
+	    rlc_status = mac_rlc_status_ind(module_idP,
+					    rnti,
+					    module_idP,
+					    frameP,
+					    subframeP,
+					    ENB_FLAG_YES,
+					    MBMS_FLAG_NO,
+					    lcid,
+					    TBS-ta_len-header_len_dcch-sdu_length_total-header_len_dtch
+					    ,0, 0);
+	    
+
+	    if (rlc_status.bytes_in_buffer > 0) {
+	      
+	      LOG_I(MAC,"[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n",
+		    module_idP,frameP,TBS-header_len_dcch-sdu_length_total-header_len_dtch,lcid, header_len_dtch);
+	      sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,
+						       rnti,
+						       module_idP,
+						       frameP,
+						       ENB_FLAG_YES,
+						       MBMS_FLAG_NO,
+						       lcid,
+						       TBS,	//not used
+						       (char*)&dlsch_buffer[sdu_length_total]
+						       ,0, 0);
+	      T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP),
+              T_INT(harq_pid), T_INT(lcid), T_INT(sdu_lengths[num_sdus]));
+
+	      LOG_I(MAC,"[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n",module_idP,sdu_lengths[num_sdus],lcid);
+	      sdu_lcids[num_sdus] = lcid;
+	      sdu_length_total += sdu_lengths[num_sdus];
+
+	      if (sdu_lengths[num_sdus] < 128) {
+		header_len_dtch--;
+		header_len_dtch_last--;
+	      }
+	      num_sdus++;
+	    } // no data for this LCID
+	    else {
+	      header_len_dtch-=3;
+	    }
+	  } // no TBS left
+	  else {
+	    header_len_dtch-=3;
+	    break; 
+	  }
+	}
+	if (header_len_dtch == 0 )
+	  header_len_dtch_last= 0;
+	// there is at least one SDU 
+	// if (num_sdus > 0 ){
+	if ((sdu_length_total + header_len_dcch + header_len_dtch )> 0) {
+	  
+	  // Now compute number of required RBs for total sdu length
+	  // Assume RAH format 2
+	  // adjust  header lengths
+	  header_len_dcch_tmp = header_len_dcch;
+	  header_len_dtch_tmp = header_len_dtch;
+	  if (header_len_dtch==0) {
+	    header_len_dcch = (header_len_dcch >0) ? 1 : 0;//header_len_dcch;  // remove length field
+	  } else {
+	    header_len_dtch_last-=1; // now use it to find how many bytes has to be removed for the last MAC SDU 
+	    header_len_dtch = (header_len_dtch > 0) ? header_len_dtch - header_len_dtch_last  :header_len_dtch;     // remove length field for the last SDU
+	  }
+
+          mcs = 9;
+
+          // decrease mcs until TBS falls below required length
+          while ((TBS > (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) && (mcs>0)) {
+            mcs--;
+            TBS = get_TBS_DL(mcs,6);
+          }
+
+          // if we have decreased too much or we don't have enough RBs, increase MCS
+          while (TBS < (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) {
+            mcs++;
+            TBS = get_TBS_DL(mcs,6);
+          }
+
+	  //#ifdef DEBUG_eNB_SCHEDULER
+          LOG_I(MAC,"[eNB %d] CC_id %d Generated DLSCH header (mcs %d, TBS %d, nb_rb %d)\n",
+                module_idP,CC_id,mcs,TBS,6);
+          // msg("[MAC][eNB ] Reminder of DLSCH with random data %d %d %d %d \n",
+          //  TBS, sdu_length_total, offset, TBS-sdu_length_total-offset);
+
+
+          if ((TBS - header_len_dcch - header_len_dtch - sdu_length_total - ta_len) <= 2) {
+            padding = (TBS - header_len_dcch - header_len_dtch - sdu_length_total - ta_len);
+            post_padding = 0;
+          } else {
+            padding = 0;
+
+            // adjust the header len
+            if (header_len_dtch==0) {
+              header_len_dcch = header_len_dcch_tmp;
+            } else { //if (( header_len_dcch==0)&&((header_len_dtch==1)||(header_len_dtch==2)))
+              header_len_dtch = header_len_dtch_tmp;
+            }
+
+            post_padding = TBS - sdu_length_total - header_len_dcch - header_len_dtch - ta_len ; // 1 is for the postpadding header
+          }
+
+
+          offset = generate_dlsch_header((unsigned char*)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0],
+                                         num_sdus,              //num_sdus
+                                         sdu_lengths,  //
+                                         sdu_lcids,
+                                         255,                                   // no drx
+                                         ta_update, // timing advance
+                                         NULL,                                  // contention res id
+                                         padding,
+                                         post_padding);
+
+
+          if (ta_update != 31) {
+            LOG_D(MAC,
+                  "[eNB %d][DLSCH] Frame %d Generate header for UE_id %d on CC_id %d: sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,timing advance value : %d, padding %d,post_padding %d,(mcs %d, TBS %d, nb_rb %d),header_dcch %d, header_dtch %d\n",
+                  module_idP,frameP, UE_id, CC_id, sdu_length_total,num_sdus,sdu_lengths[0],sdu_lcids[0],offset,
+                  ta_update,padding,post_padding,mcs,TBS,6,header_len_dcch,header_len_dtch);
+	  }
+
+
+
+          // cycle through SDUs and place in dlsch_buffer
+          memcpy(&UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset],dlsch_buffer,sdu_length_total);
+          // memcpy(RC.mac[0].DLSCH_pdu[0][0].payload[0][offset],dcch_buffer,sdu_lengths[0]);
+
+          // fill remainder of DLSCH with random data
+          for (j=0; j<(TBS-sdu_length_total-offset); j++) {
+            UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset+sdu_length_total+j] = (char)(taus()&0xff);
+          }
+
+
+          if (opt_enabled == 1) {
+            trace_pdu(1, (uint8_t *)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0],
+                      TBS, module_idP, 3, UE_RNTI(module_idP,UE_id),
+                      mac->frame, mac->subframe,0,0);
+            LOG_D(OPT,"[eNB %d][DLSCH] CC_id %d Frame %d  rnti %x  with size %d\n",
+                  module_idP, CC_id, frameP, UE_RNTI(module_idP,UE_id), TBS);
+          }
+
+          T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP),
+            T_INT(harq_pid), T_BUFFER(UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], TBS));
+
+	  // do PUCCH power control
+          // this is the normalized RX power
+
+          /* TODO: fix how we deal with power, unit is not dBm, it's special from nfapi */
+	  normalized_rx_power = (5*ue_sched_ctl->pucch1_snr[CC_id]-640)/10+30;
+	  target_rx_power = mac->puCch10xSnr/10+30;
+	    
+          // this assumes accumulated tpc
+	  // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out
+	  int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame*10+UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe;
+          if (((framex10psubframe+10)<=(frameP*10+subframeP)) || //normal case
+	      ((framex10psubframe>(frameP*10+subframeP)) && (((10240-framex10psubframe+frameP*10+subframeP)>=10)))) //frame wrap-around
+	    if (ue_sched_ctl->pucch1_cqi_update[CC_id] == 1) { 
+	      ue_sched_ctl->pucch1_cqi_update[CC_id] = 0;
+
+	      UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame=frameP;
+	      UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe=subframeP;
+	      
+	      if (normalized_rx_power>(target_rx_power+4)) {
+		tpc = 0; //-1
+	      } else if (normalized_rx_power<(target_rx_power-4)) {
+		tpc = 2; //+1
+	      } else {
+		tpc = 1; //0
+	      }
+	      	      
+	      LOG_D(MAC,"[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, normalized/target rx power %d/%d\n",
+		    module_idP,frameP, subframeP,harq_pid,tpc,
+		    normalized_rx_power,target_rx_power);
+
+	    } // Po_PUCCH has been updated 
+	    else {
+	      tpc = 1; //0
+	    } // time to do TPC update 
+	  else {
+	    tpc = 1; //0
+	  }
+
+	  // Toggle NDI in first round
+	  UE_template->oldNDI[harq_pid] = 1-UE_template->oldNDI[harq_pid];
+	  ue_sched_ctl->round[CC_id][harq_pid] = 0;
+	  round=0;
+	}
+
+      }
+
+      if (round < 8) {
+	// fill in MDPDCCH
+	memset ((void *) dl_config_pdu, 0, sizeof (nfapi_dl_config_request_pdu_t));
+	dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE;
+	dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_mpdcch_pdu));
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_format = (UE_template->rach_resource_type > 1) ? 11 : 10;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_narrow_band = epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13-1;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_prb_pairs = 6;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_tansmission_type = epdcch_setconfig_r11->transmissionType_r11;  
+	AssertFatal(UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11!=NULL,
+		    "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 is null\n");
+	
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.start_symbol = *UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ecce_index = 0;        // Note: this should be dynamic
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.aggregation_level = 24;        // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti_type = 4; // t-CRNTI
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti = rnti;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ce_mode = (UE_template->rach_resource_type < 3) ? 1 : 2;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.drms_scrambling_init = epdcch_setconfig_r11->dmrs_ScramblingSequenceInt_r11;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.initial_transmission_sf_io = (frameP * 10) + subframeP;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.transmission_power = 6000;     // 0dB
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_coding = getRIV (6, 0, 6) | ((epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13-1)<<5);
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs = 9;       // adjust according to size of RAR, 208 bits with N1A_PRB=3
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pdsch_reptition_levels = 0;    // fix to 4 for now
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.redundancy_version = rvseq[round&3];
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.new_data_indicator = UE_template->oldNDI[harq_pid];
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_process = 0;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi_length = 0;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi = 0;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi_flag = 0;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi = 0;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_resource_offset = 0;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_subframe_repetition_number = 0;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpc = 3; 
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index_length = 0;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index = 0;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.allocate_prach_flag = 0;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.preamble_index = 0;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.prach_mask_index = 0;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.starting_ce_level = 0;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.srs_request = 0;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity_flag = 0;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity = 0;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.frequency_hopping_enabled_flag = 0;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.paging_direct_indication_differentiation_flag = 0;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.direct_indication = 0;
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding = 0;        // this is not needed by OAI L1, but should be filled in
+	dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports = 1;
+	dl_req->number_pdu++;
+	UE_template->mcs[harq_pid] = dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs;
+      }
+    }
+    else if ((subframeP == 7)&&(round<8)) {  // DLSCH
+	  
+	  int             absSF = (frameP * 10) + subframeP;
+	  
+	  // Have to check that MPDCCH was generated
+	  LOG_I (MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating DLSCH (ce_level %d RNTI %x)\n",
+	    module_idP, CC_id, frameP, subframeP, UE_template->rach_resource_type - 1,rnti);
+	  
+	  first_rb = narrowband_to_first_rb (&cc[CC_id], epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13-1);            
+	  dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
+	  memset ((void *) dl_config_pdu, 0, sizeof (nfapi_dl_config_request_pdu_t));
+      dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE;
+      dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_dlsch_pdu));
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = mac->pdu_index[CC_id];
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = rnti;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2;   // format 1A/1B/1D
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0;     // localized
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV (to_prb (cc[CC_id].mib->message.dl_Bandwidth), first_rb, 6);  // check that this isn't getRIV(6,0,6)
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = 0;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1;   // first block
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc[CC_id].p_eNB == 1) ? 0 : 1;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1;
+      //      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index                         = ;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = 0;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize (cc[CC_id].mib->message.dl_Bandwidth); // ignored
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = (cc[CC_id].p_eNB == 1) ? 1 : 2;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1;
+      //      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector                    = ; 
+      
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start = *UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11;
+      
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = (UE_template->rach_resource_type < 3) ? 1 : 2;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 2;        // not SI message
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = (10 * frameP) + subframeP;
+      dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.drms_table_flag = 0;
+      dl_req->number_pdu++;
+
+      // DL request
+      mac->TX_req[CC_id].sfn_sf = (frameP << 4) + subframeP;
+      TX_req = &mac->TX_req[CC_id].tx_request_body.tx_pdu_list[mac->TX_req[CC_id].tx_request_body.number_of_pdus];
+      TX_req->pdu_length = get_TBS_DL(UE_template->mcs[harq_pid],
+				      6);
+      TX_req->pdu_index = mac->pdu_index[CC_id]++;
+      TX_req->num_segments = 1;
+      TX_req->segments[0].segment_length = TX_req->pdu_length;
+      TX_req->segments[0].segment_data = mac->UE_list.DLSCH_pdu[CC_id][0][(unsigned char) UE_id].payload[0];
+      mac->TX_req[CC_id].tx_request_body.number_of_pdus++;
+
+      ackNAK_absSF = absSF + 4;
+      ul_req = &mac->UL_req_tmp[CC_id][ackNAK_absSF % 10].ul_config_request_body;
+      ul_config_pdu = &ul_req->ul_config_pdu_list[ul_req->number_of_pdus];
+      
+      ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE;
+      ul_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_ul_config_uci_harq_pdu));
+      ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.handle = 0;      // don't know how to use this
+      ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.rnti = rnti;
+      ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.ue_type = (UE_template->rach_resource_type < 3) ? 1 : 2;
+      ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.empty_symbols = 0;
+      ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.total_number_of_repetitions = pucchreps[UE_template->rach_resource_type - 1];
+      ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.repetition_number = 0;
+
+      if (cc[CC_id].tdd_Config == NULL) {    // FDD case
+	ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.n_pucch_1_0 = n1pucchan[UE_template->rach_resource_type - 1];
+	// NOTE: How to fill in the rest of the n_pucch_1_0 information 213 Section 10.1.2.1 in the general case
+	// = N_ECCE_q + Delta_ARO + n1pucchan[ce_level]
+	// higher in the MPDCCH configuration, N_ECCE_q is hard-coded to 0, and harq resource offset to 0 =>
+	// Delta_ARO = 0 from Table 10.1.2.1-1
+	ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.harq_size = 1; // 1-bit ACK/NAK
+	ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.number_of_pucch_resources = 1;
+      } else {
+	AssertFatal (1 == 0, "PUCCH configuration for ACK/NAK not handled yet for TDD BL/CE case\n");
+      }
+      ul_req->number_of_pdus++;
+      T (T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT (module_idP), T_INT (CC_id), T_INT (rnti), T_INT (frameP), T_INT (subframeP),
+	 T_INT (0 /*harq_pid always 0? */ ), T_BUFFER (&mac->UE_list.DLSCH_pdu[CC_id][0][UE_id].payload[0], TX_req->pdu_length));
+      
+      if (opt_enabled == 1) {
+	trace_pdu (1, (uint8_t *) mac->UE_list.DLSCH_pdu[CC_id][0][(unsigned char) UE_id].payload[0], TX_req->pdu_length , UE_id, 3, rnti, frameP, subframeP, 0, 0);
+	LOG_D (OPT, "[eNB %d][DLSCH] CC_id %d Frame %d trace pdu for rnti %x with size %d\n", module_idP, CC_id, frameP, rnti, TX_req->pdu_length );
+      }
+
+    }
+  }
+
+}
+#endif
+
 //------------------------------------------------------------------------------
 void
 fill_DLSCH_dci(module_id_t module_idP,
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c
index 838995bdb402d923a7d0d0d3fcb342bd312a69f7..86f7e16acfd028b5024ad2c4511fa1ef3c11b81d 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c
@@ -195,7 +195,7 @@ void dlsch_scheduler_pre_ue_select_fairRR(
 
   // Initialization
   for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
-    dlsch_ue_max_num[CC_id] = (uint16_t)RC.rrc[module_idP]->configuration.ue_multiple_max[CC_id];
+    dlsch_ue_max_num[CC_id] = (uint16_t)RC.rrc[module_idP]->configuration.radioresourceconfig[CC_id].ue_multiple_max;
     // save origin DL PDU number
     DL_req          = &eNB->DL_req[CC_id].dl_config_request_body;
     saved_dlsch_dci[CC_id] = DL_req->number_pdu;
@@ -1972,7 +1972,7 @@ void ulsch_scheduler_pre_ue_select_fairRR(
     //save ulsch dci number
     saved_ulsch_dci[CC_id] = eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body.number_of_dci;
     // maximum multiplicity number
-    ulsch_ue_max_num[CC_id] =RC.rrc[module_idP]->configuration.ue_multiple_max[CC_id];
+    ulsch_ue_max_num[CC_id] =RC.rrc[module_idP]->configuration.radioresourceconfig[CC_id].ue_multiple_max;
     cc_id_flag[CC_id] = 0;
     ue_first_num[CC_id] = 0;
     ul_inactivity_num[CC_id] = 0;
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
index 4052f1fb21e1436e9e27b366481d18c17e7ca747..9bcec88bf7092af13af90a6a749e01ac208f2108 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
@@ -2274,7 +2274,8 @@ uint8_t get_tmode(module_id_t module_idP, int CC_idP, int UE_idP)
   eNB_MAC_INST *eNB = RC.mac[module_idP];
   COMMON_channels_t *cc = &eNB->common_channels[CC_idP];
 
-  LTE_PhysicalConfigDedicated_t *physicalConfigDedicated = eNB->UE_list.physicalConfigDedicated[CC_idP][UE_idP];
+
+  struct LTE_PhysicalConfigDedicated *physicalConfigDedicated = eNB->UE_list.UE_template[CC_idP][UE_idP].physicalConfigDedicated;
 
   if (physicalConfigDedicated == NULL) {	// RRCConnectionSetup not received by UE yet
     AssertFatal(cc->p_eNB <= 2, "p_eNB is %d, should be <2\n",
@@ -2282,8 +2283,8 @@ uint8_t get_tmode(module_id_t module_idP, int CC_idP, int UE_idP)
     return (cc->p_eNB);
   } else {
     AssertFatal(physicalConfigDedicated->antennaInfo != NULL,
-		"antennaInfo is null for CCId %d, UEid %d\n", CC_idP,
-		UE_idP);
+		"antennaInfo (mod_id %d) is null for CCId %d, UEid %d, physicalConfigDedicated %p\n", module_idP,CC_idP,
+		UE_idP,physicalConfigDedicated);
 
     AssertFatal(physicalConfigDedicated->antennaInfo->present !=
 		LTE_PhysicalConfigDedicated__antennaInfo_PR_NOTHING,
@@ -2292,7 +2293,7 @@ uint8_t get_tmode(module_id_t module_idP, int CC_idP, int UE_idP)
 
     if (physicalConfigDedicated->antennaInfo->present ==
 	LTE_PhysicalConfigDedicated__antennaInfo_PR_explicitValue) {
-      return (physicalConfigDedicated->antennaInfo->
+      return (1+physicalConfigDedicated->antennaInfo->
 	      choice.explicitValue.transmissionMode);
     } else if (physicalConfigDedicated->antennaInfo->present ==
 	       LTE_PhysicalConfigDedicated__antennaInfo_PR_defaultValue) {
@@ -3621,6 +3622,9 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id,
 
     LOG_D(MAC,"frame %d subframe %d harq_pid %d mode %d tmode[0] %d num_ack_nak %d round %d\n",frameP,subframeP,harq_pid,harq_indication_fdd->mode,tmode[0],num_ack_nak,sched_ctl->round[CC_idP][harq_pid]);
 
+    // use 1 HARQ proces of BL/CE UE for now
+    if (UE_list->UE_template[pCCid][UE_id].rach_resource_type > 0) harq_pid = 0;
+
     switch (harq_indication_fdd->mode) {
     case 0:		// Format 1a/b (10.1.2.1)
       AssertFatal(numCC == 1,
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
index 9a6340a72b08bb094a495e3e44ef7f3861903091..c4a6a59e2b482dd66fdc8e11ddd4a1752cdeb07f 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
@@ -105,8 +105,6 @@ rx_sdu(const module_id_t enb_mod_idP,
   int lcgid_updated[4] = {0, 0, 0, 0};
   UE_list_t *UE_list = &mac->UE_list;
   int crnti_rx = 0;
-  RA_t *ra =
-    (RA_t *) & RC.mac[enb_mod_idP]->common_channels[CC_idP].ra[0];
   int first_rb = 0;
   rrc_eNB_ue_context_t *ue_contextP = NULL;
   start_meas(&mac->rx_ulsch_sdu);
@@ -172,6 +170,7 @@ rx_sdu(const module_id_t enb_mod_idP,
         UE_list->UE_sched_ctrl[UE_id].pusch_snr[CC_idP] = ul_cqi;
       }
 
+
       //      AssertFatal(1==0,"ulsch in error\n");
       if (UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] == 3) {
         UE_list->UE_sched_ctrl[UE_id].ul_scheduled &= (~(1 << harq_pid));
@@ -217,6 +216,12 @@ rx_sdu(const module_id_t enb_mod_idP,
       return;
     }
   } else if ((RA_id = find_RA_id(enb_mod_idP, CC_idP, current_rnti)) != -1) { // Check if this is an RA process for the rnti
+
+    RA_t *ra = (RA_t *) & mac->common_channels[CC_idP].ra[RA_id];
+	  
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+    if (ra->rach_resource_type > 0) harq_pid=0;
+#endif
     AssertFatal(mac->common_channels[CC_idP].
                 radioResourceConfigCommon->rach_ConfigCommon.
                 maxHARQ_Msg3Tx > 1,
@@ -226,7 +231,7 @@ rx_sdu(const module_id_t enb_mod_idP,
                 maxHARQ_Msg3Tx);
     LOG_D(MAC,
           "[eNB %d][PUSCH %d] CC_id %d [RAPROC Msg3] Received ULSCH sdu round %d from PHY (rnti %x, RA_id %d) ul_cqi %d\n",
-          enb_mod_idP, harq_pid, CC_idP, ra[RA_id].msg3_round,
+          enb_mod_idP, harq_pid, CC_idP, ra->msg3_round,
           current_rnti, RA_id, ul_cqi);
     first_rb = ra->msg3_first_rb;
 
@@ -234,21 +239,21 @@ rx_sdu(const module_id_t enb_mod_idP,
       LOG_D(MAC,
             "[eNB %d] CC_id %d, RA %d ULSCH in error in round %d/%d\n",
             enb_mod_idP, CC_idP, RA_id,
-            ra[RA_id].msg3_round,
+            ra->msg3_round,
             (int) mac->common_channels[CC_idP].
             radioResourceConfigCommon->rach_ConfigCommon.
             maxHARQ_Msg3Tx);
 
-      if (ra[RA_id].msg3_round >= mac->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx - 1) {
+      if (ra->msg3_round >= mac->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx - 1) {
         cancel_ra_proc(enb_mod_idP, CC_idP, frameP, current_rnti);
       } else {
         first_rb = UE_list->UE_template[CC_idP][UE_id].first_rb_ul[harq_pid];
-        ra[RA_id].msg3_round++;
+        ra->msg3_round++;
         // prepare handling of retransmission
         get_Msg3allocret(&mac->common_channels[CC_idP],
-                         ra[RA_id].Msg3_subframe, ra[RA_id].Msg3_frame,
-                         &ra[RA_id].Msg3_frame, &ra[RA_id].Msg3_subframe);
-        add_msg3(enb_mod_idP, CC_idP, &ra[RA_id], frameP, subframeP);
+                         ra->Msg3_subframe, ra->Msg3_frame,
+                         &ra->Msg3_frame, &ra->Msg3_subframe);
+        add_msg3(enb_mod_idP, CC_idP, ra, frameP, subframeP);
       }
 
       /* TODO: program NACK for PHICH? */
@@ -333,7 +338,7 @@ rx_sdu(const module_id_t enb_mod_idP,
            * the UE state in the eNB is wrong.
            */
           for (ii = 0; ii < NB_RA_PROC_MAX; ii++) {
-            ra = &mac->common_channels[CC_idP].ra[ii];
+            RA_t *ra = &mac->common_channels[CC_idP].ra[ii];
 
             if ((ra->rnti == current_rnti) && (ra->state != IDLE)) {
               mac_rrc_data_ind(enb_mod_idP,
@@ -343,7 +348,11 @@ rx_sdu(const module_id_t enb_mod_idP,
                                DCCH,
                                (uint8_t *) payload_ptr,
                                rx_lengths[i],
-                               0);
+                               0
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+			       ,ra->rach_resource_type>0
+#endif
+			       );
               // prepare transmission of Msg4(RRCConnectionReconfiguration)
               ra->state = MSGCRNTI;
               LOG_I(MAC,
@@ -518,107 +527,112 @@ rx_sdu(const module_id_t enb_mod_idP,
           [i]));
 
     switch (rx_lcids[i]) {
-      case CCCH:
-        if (rx_lengths[i] > CCCH_PAYLOAD_SIZE_MAX) {
-          LOG_E(MAC,
-                "[eNB %d/%d] frame %d received CCCH of size %d (too big, maximum allowed is %d, sdu_len %d), dropping packet\n",
-                enb_mod_idP, CC_idP, frameP, rx_lengths[i],
-                CCCH_PAYLOAD_SIZE_MAX, sdu_lenP);
-          break;
-        }
-
-        LOG_D(MAC,
-              "[eNB %d][RAPROC] CC_id %d Frame %d, Received CCCH:  %x.%x.%x.%x.%x.%x, Terminating RA procedure for UE rnti %x\n",
-              enb_mod_idP, CC_idP, frameP, payload_ptr[0],
-              payload_ptr[1], payload_ptr[2], payload_ptr[3],
-              payload_ptr[4], payload_ptr[5], current_rnti);
-        VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC, 1);
-        VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC, 0);
-
-        for (ii = 0; ii < NB_RA_PROC_MAX; ii++) {
-          RA_t *ra = &mac->common_channels[CC_idP].ra[ii];
-          LOG_D(MAC,
-                "[mac %d][RAPROC] CC_id %d Checking proc %d : rnti (%x, %x), state %d\n",
-                enb_mod_idP, CC_idP, ii, ra->rnti,
-                current_rnti, ra->state);
-
-          if ((ra->rnti == current_rnti) && (ra->state != IDLE)) {
-            //payload_ptr = parse_ulsch_header(msg3,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,msg3_len);
-            if (UE_id < 0) {
-              memcpy(&ra->cont_res_id[0], payload_ptr, 6);
-              LOG_D(MAC,
-                    "[eNB %d][RAPROC] CC_id %d Frame %d CCCH: Received Msg3: length %d, offset %ld\n",
-                    enb_mod_idP, CC_idP, frameP, rx_lengths[i],
-                    payload_ptr - sduP);
-
-              if ((UE_id = add_new_ue(enb_mod_idP, CC_idP,
-                                      mac->common_channels[CC_idP].
-                                      ra[ii].rnti, harq_pid
+    case CCCH:
+      if (rx_lengths[i] > CCCH_PAYLOAD_SIZE_MAX) {
+	LOG_E(MAC,
+	      "[eNB %d/%d] frame %d received CCCH of size %d (too big, maximum allowed is %d, sdu_len %d), dropping packet\n",
+	      enb_mod_idP, CC_idP, frameP, rx_lengths[i],
+	      CCCH_PAYLOAD_SIZE_MAX, sdu_lenP);
+	break;
+      }
+      LOG_D(MAC,
+	    "[eNB %d][RAPROC] CC_id %d Frame %d, Received CCCH:  %x.%x.%x.%x.%x.%x, Terminating RA procedure for UE rnti %x\n",
+	    enb_mod_idP, CC_idP, frameP, payload_ptr[0],
+	    payload_ptr[1], payload_ptr[2], payload_ptr[3],
+	    payload_ptr[4], payload_ptr[5], current_rnti);
+      VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC, 1);
+      VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC, 0);
+      for (ii = 0; ii < NB_RA_PROC_MAX; ii++) {
+	RA_t *ra = &mac->common_channels[CC_idP].ra[ii];
+	
+	LOG_D(MAC,
+	      "[mac %d][RAPROC] CC_id %d Checking proc %d : rnti (%x, %x), state %d\n",
+	      enb_mod_idP, CC_idP, ii, ra->rnti,
+	      current_rnti, ra->state);
+	
+	if ((ra->rnti == current_rnti) && (ra->state != IDLE)) {
+	  
+	  //payload_ptr = parse_ulsch_header(msg3,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,msg3_len);
+	  
+	  if (UE_id < 0) {
+	    memcpy(&ra->cont_res_id[0], payload_ptr, 6);
+	    LOG_D(MAC,
+		  "[eNB %d][RAPROC] CC_id %d Frame %d CCCH: Received Msg3: length %d, offset %ld\n",
+		  enb_mod_idP, CC_idP, frameP, rx_lengths[i],
+		  payload_ptr - sduP);
+	    
+	    if ((UE_id = add_new_ue(enb_mod_idP, CC_idP,
+				    mac->common_channels[CC_idP].
+				    ra->rnti, harq_pid
 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
-                                      ,
-                                      mac->common_channels[CC_idP].
-                                      ra[ii].rach_resource_type
+				    ,
+				    mac->common_channels[CC_idP].
+				    ra->rach_resource_type
 #endif
-                                     )) == -1) {
-                LOG_E(MAC,"[MAC][eNB] Max user count reached\n");
-                cancel_ra_proc(enb_mod_idP, CC_idP, frameP,current_rnti);
-                break;
-                // kill RA procedure
-              } else
-                LOG_D(MAC,
-                      "[eNB %d][RAPROC] CC_id %d Frame %d Added user with rnti %x => UE %d\n",
-                      enb_mod_idP, CC_idP, frameP, ra->rnti,
-                      UE_id);
-            } else {
-              LOG_D(MAC,
-                    "[eNB %d][RAPROC] CC_id %d Frame %d CCCH: Received Msg3 from already registered UE %d: length %d, offset %ld\n",
-                    enb_mod_idP, CC_idP, frameP, UE_id,
-                    rx_lengths[i], payload_ptr - sduP);
-              // kill RA procedure
-            }
+				    )) == -1) {
+              LOG_E(MAC,"[MAC][eNB] Max user count reached\n");
+              cancel_ra_proc(enb_mod_idP, CC_idP, frameP,current_rnti);
+              break;
+	      // kill RA procedure
+	    } else
+	      LOG_D(MAC,
+		    "[eNB %d][RAPROC] CC_id %d Frame %d Added user with rnti %x => UE %d\n",
+		    enb_mod_idP, CC_idP, frameP, ra->rnti,
+		    UE_id);
+	  } else {
+	    LOG_D(MAC,
+		  "[eNB %d][RAPROC] CC_id %d Frame %d CCCH: Received Msg3 from already registered UE %d: length %d, offset %ld\n",
+		  enb_mod_idP, CC_idP, frameP, UE_id,
+		  rx_lengths[i], payload_ptr - sduP);
+	    // kill RA procedure
+	  }
+
+	  mac_rrc_data_ind(enb_mod_idP,
+			   CC_idP,
+			   frameP, subframeP,
+			   current_rnti,
+			   CCCH,
+			   (uint8_t *) payload_ptr,
+			   rx_lengths[i],
+			   0
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+			   ,ra->rach_resource_type>0
+#endif
+			   );
 
-            mac_rrc_data_ind(enb_mod_idP,
-                             CC_idP,
-                             frameP, subframeP,
-                             current_rnti,
-                             CCCH,
-                             (uint8_t *) payload_ptr,
-                             rx_lengths[i],
-                             0);
-
-            if (num_ce > 0) { // handle msg3 which is not RRCConnectionRequest
-              //  process_ra_message(msg3,num_ce,rx_lcids,rx_ces);
-            }
 
-            // prepare transmission of Msg4
-            ra->state = MSG4;
+	  if (num_ce > 0) {	// handle msg3 which is not RRCConnectionRequest
+	    //  process_ra_message(msg3,num_ce,rx_lcids,rx_ces);
+	  }
+	  // prepare transmission of Msg4
+	  ra->state = MSG4;
 
-            if(mac->common_channels[CC_idP].tdd_Config!=NULL) {
+	  if(mac->common_channels[CC_idP].tdd_Config!=NULL) {
               switch(mac->common_channels[CC_idP].tdd_Config->subframeAssignment) {
-                case 1:
-                  ra->Msg4_frame = frameP + ((subframeP > 2) ? 1 : 0);
-                  ra->Msg4_subframe = (subframeP + 7) % 10;
-                  break;
-
-                default:
-                  printf("%s:%d: TODO\n", __FILE__, __LINE__);
-                  abort();
-                  // TODO need to be complete for other tdd configs.
+	      case 1:
+		ra->Msg4_frame = frameP + ((subframeP > 2) ? 1 : 0);
+		ra->Msg4_subframe = (subframeP + 7) % 10;
+		break;
+		
+	      default:
+		printf("%s:%d: TODO\n", __FILE__, __LINE__);
+		abort();
+		// TODO need to be complete for other tdd configs.
               }
-            } else {
-              // Program Msg4 PDCCH+DLSCH/MPDCCH transmission 4 subframes from now, // Check if this is ok for BL/CE, or if the rule is different
-              ra->Msg4_frame = frameP + ((subframeP > 5) ? 1 : 0);
-              ra->Msg4_subframe = (subframeP + 4) % 10;
-            }
-
-            UE_list->UE_sched_ctrl[UE_id].crnti_reconfigurationcomplete_flag = 0;
-          }   // if process is active
-        }     // loop on RA processes
+	  } else {
+	    // Program Msg4 PDCCH+DLSCH/MPDCCH transmission 4 subframes from now, // Check if this is ok for BL/CE, or if the rule is different
+	    ra->Msg4_frame = frameP + ((subframeP > 5) ? 1 : 0);
+	    ra->Msg4_subframe = (subframeP + 4) % 10;
+	  }
+	  
+	  UE_list->UE_sched_ctrl[UE_id].crnti_reconfigurationcomplete_flag = 0;
+	}   // if process is active
+      }     // loop on RA processes
 
-        break;
-
-      case DCCH:
-      case DCCH1:
+      break;
+      
+    case DCCH:
+    case DCCH1:
         //      if(eNB_mac_inst[module_idP][CC_idP].Dcch_lchan[UE_id].Active==1){
 #if defined(ENABLE_MAC_PAYLOAD_DEBUG)
         LOG_T(MAC, "offset: %d\n",
@@ -1026,12 +1040,26 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP,
     }
   }
 
+
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+  int  emtc_active[5];
+  memset(emtc_active,0,5*sizeof(int));
+  schedule_ulsch_rnti_emtc(module_idP, frameP, subframeP, sched_subframe, emtc_active);
+#endif
+
   if (sched_subframe < subframeP) sched_frame++;
 
+
+    //leave out first RB for PUCCH and first narrowband if emtc
   for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; CC_id++) {
     //leave out first RB for PUCCH
     first_rb[CC_id] = 1;
 
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+    first_rb[CC_id] = (emtc_active[CC_id] == 1) ? 7 : 1;
+#else
+    first_rb[CC_id] = 1;
+#endif
     // UE data info;
     // check which UE has data to transmit
     // function to decide the scheduling
@@ -1065,12 +1093,13 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP,
   stop_meas(&mac->schedule_ulsch);
 }
 
-void
-schedule_ulsch_rnti(module_id_t module_idP,
-                    int slice_idx,
-                    frame_t frameP,
-                    sub_frame_t subframeP,
-                    unsigned char sched_subframeP, uint16_t *first_rb) {
+
+void schedule_ulsch_rnti(module_id_t module_idP,
+			 int slice_idx,
+			 frame_t frameP,
+			 sub_frame_t subframeP,
+			 unsigned char sched_subframeP, uint16_t * first_rb)
+{
   int UE_id;
   uint8_t aggregation = 2;
   rnti_t rnti = -1;
@@ -1610,3 +1639,429 @@ schedule_ulsch_rnti(module_id_t module_idP,
     }     // loop over UE_id
   }       // loop of CC_id
 }
+
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+void schedule_ulsch_rnti_emtc(module_id_t   module_idP,
+			     frame_t       frameP,
+			     sub_frame_t   subframeP,
+			     unsigned char sched_subframeP,
+			     int          *emtc_active)
+{
+  int               UE_id;
+  rnti_t            rnti           = -1;
+  uint8_t           round          = 0;
+  uint8_t           harq_pid       = 0;
+  uint8_t           status         = 0;
+  uint32_t          cshift,ndi;
+  int32_t           normalized_rx_power;
+  int32_t           target_rx_power=-90;
+  int               n;
+  int               CC_id = 0;
+  int               N_RB_UL;
+  eNB_MAC_INST      *eNB = RC.mac[module_idP];
+  COMMON_channels_t *cc  = eNB->common_channels;
+  UE_list_t         *UE_list=&eNB->UE_list;
+  UE_TEMPLATE       *UE_template;
+  UE_sched_ctrl     *UE_sched_ctrl;
+  int               sched_frame=frameP;
+  int               rvidx_tab[4] = {0,2,3,1};
+  int               tpc=0;
+  int               cqi_req=0;
+
+  if (sched_subframeP<subframeP) sched_frame++;
+
+  nfapi_hi_dci0_request_body_t   *hi_dci0_req = &eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body;
+  nfapi_hi_dci0_request_pdu_t    *hi_dci0_pdu;
+
+  nfapi_ul_config_request_body_t *ul_req_tmp       = &eNB->UL_req_tmp[CC_id][sched_subframeP].ul_config_request_body;
+
+  // loop over all active UEs
+  if ((frameP&1) == 1) return;
+
+  for (UE_id=UE_list->head_ul; UE_id>=0; UE_id=UE_list->next_ul[UE_id]) {
+
+    if (UE_list->UE_template[UE_PCCID(module_idP,UE_id)][UE_id].rach_resource_type == 0) continue;
+
+    // don't schedule if Msg4 is not received yet
+    if (UE_list->UE_template[UE_PCCID(module_idP,UE_id)][UE_id].configured==FALSE) {
+      LOG_D(MAC,"[eNB %d] frame %d subfarme %d, UE %d: not configured, skipping UE scheduling \n",
+            module_idP,frameP,subframeP,UE_id);
+      continue;
+    }
+
+    rnti = UE_RNTI(module_idP,UE_id);
+
+    if (rnti==NOT_A_RNTI) {
+      LOG_W(MAC,"[eNB %d] frame %d subfarme %d, UE %d: no RNTI \n", module_idP,frameP,subframeP,UE_id);
+      continue;
+    }
+
+    // loop over all active UL CC_ids for this UE
+    for (n=0; n<UE_list->numactiveULCCs[UE_id]; n++) {
+      // This is the actual CC_id in the list
+      CC_id        = UE_list->ordered_ULCCids[n][UE_id];
+      N_RB_UL      = to_prb(cc[CC_id].ul_Bandwidth);
+
+
+      UE_template   = &UE_list->UE_template[CC_id][UE_id];
+      UE_sched_ctrl = &UE_list->UE_sched_ctrl[UE_id];
+      harq_pid      = 0;
+      round         = UE_sched_ctrl->round_UL[CC_id][harq_pid];
+      AssertFatal(round<8,"round %d > 7 for UE %d/%x\n",round,UE_id,rnti);
+      LOG_D(MAC,"[eNB %d] frame %d subframe %d,Checking PUSCH %d for BL/CE UE %d/%x CC %d : aggregation level %d, N_RB_UL %d\n",
+            module_idP,frameP,subframeP,harq_pid,UE_id,rnti,CC_id, 24,N_RB_UL);
+
+      RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP] = UE_template->estimated_ul_buffer;
+      VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BO,RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP]);
+      if ((UE_template->ul_SR >0  || round > 0 || status < RRC_CONNECTED)&&(subframeP==5)) 
+        // if there is information on bsr of DCCH, DTCH or if there is UL_SR, or if there is a packet to retransmit, or we want to schedule a periodic feedback every 10 frames
+        {
+          LOG_I(MAC,"[eNB %d][PUSCH %d] Frame %d subframe %d Scheduling UE %d/%x in round %d(SR %d,UL_inactivity timer %d,UL_failure timer %d,cqi_req_timer %d)\n",
+                module_idP,harq_pid,frameP,subframeP,UE_id,rnti,round,UE_template->ul_SR,
+                UE_sched_ctrl->ul_inactivity_timer,
+
+                UE_sched_ctrl->ul_failure_timer,
+
+                UE_sched_ctrl->cqi_req_timer);
+          // reset the scheduling request
+	  emtc_active[CC_id]=1;
+          UE_template->ul_SR = 0;
+          status = mac_eNB_get_rrc_status(module_idP,rnti);
+
+	  /*
+          if (status < RRC_CONNECTED)
+            cqi_req = 0;
+          else if (UE_sched_ctrl->cqi_req_timer>300) {
+            cqi_req = 1;
+            UE_sched_ctrl->cqi_req_timer=0;
+
+          }
+          else
+            cqi_req = 0;
+	  */
+	  cqi_req = 0;
+
+ 
+          //power control
+          //compute the expected ULSCH RX power (for the stats)
+
+          // this is the normalized RX power and this should be constant (regardless of mcs
+          normalized_rx_power = UE_sched_ctrl->pusch_snr[CC_id];
+          target_rx_power = 178;
+
+          // this assumes accumulated tpc
+          // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out
+          int32_t framex10psubframe = UE_template->pusch_tpc_tx_frame*10+UE_template->pusch_tpc_tx_subframe;
+          if (((framex10psubframe+10)<=(frameP*10+subframeP)) || //normal case
+              ((framex10psubframe>(frameP*10+subframeP)) && (((10240-framex10psubframe+frameP*10+subframeP)>=10)))) //frame wrap-around
+            {
+              UE_template->pusch_tpc_tx_frame=frameP;
+              UE_template->pusch_tpc_tx_subframe=subframeP;
+              if (normalized_rx_power>(target_rx_power+4)) {
+                tpc = 0; //-1
+                UE_sched_ctrl->tpc_accumulated[CC_id]--;
+              } else if (normalized_rx_power<(target_rx_power-4)) {
+                tpc = 2; //+1
+                UE_sched_ctrl->tpc_accumulated[CC_id]++;
+              } else {
+                tpc = 1; //0
+              }
+            } else {
+            tpc = 1; //0
+          }
+          //tpc = 1;
+
+
+          if (tpc!=1) {
+            LOG_D(MAC,"[eNB %d] ULSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n",
+                  module_idP,frameP,subframeP,harq_pid,tpc,
+                  UE_sched_ctrl->tpc_accumulated[CC_id],normalized_rx_power,target_rx_power);
+          }
+
+          // new transmission
+          if (round==0) {
+
+            ndi = 1-UE_template->oldNDI_UL[harq_pid];
+            UE_template->oldNDI_UL[harq_pid]=ndi;
+            UE_list->eNB_UE_stats[CC_id][UE_id].normalized_rx_power=normalized_rx_power;
+            UE_list->eNB_UE_stats[CC_id][UE_id].target_rx_power=target_rx_power;
+            UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1=4;
+            UE_template->mcs_UL[harq_pid] = 4;
+
+
+            UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=UE_template->mcs_UL[harq_pid];
+            //            buffer_occupancy = UE_template->ul_total_buffer;
+
+
+
+            UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid],6);
+            UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx+=6;
+            UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS=UE_template->TBS_UL[harq_pid];
+            //            buffer_occupancy -= TBS;
+
+            T(T_ENB_MAC_UE_UL_SCHEDULE, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP),
+              T_INT(subframeP), T_INT(harq_pid), T_INT(UE_template->mcs_UL[harq_pid]), T_INT(0), T_INT(6),
+              T_INT(UE_template->TBS_UL[harq_pid]), T_INT(ndi));
+
+            // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB)
+            //store for possible retransmission
+            UE_template->nb_rb_ul[harq_pid]    = 6;
+
+
+            UE_sched_ctrl->ul_scheduled |= (1<<harq_pid);
+            if (UE_id == UE_list->head)
+              VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_SCHEDULED,UE_sched_ctrl->ul_scheduled);
+
+            // adjust total UL buffer status by TBS, wait for UL sdus to do final update
+            UE_template->scheduled_ul_bytes += UE_template->TBS_UL[harq_pid];
+
+            LOG_D(MAC, "scheduled_ul_bytes, new %d\n", UE_template->scheduled_ul_bytes);
+
+
+            // Cyclic shift for DM RS
+            cshift = 0;// values from 0 to 7 can be used for mapping the cyclic shift (36.211 , Table 5.5.2.1.1-1)
+            // save it for a potential retransmission
+            UE_template->cshift[harq_pid] = cshift;
+
+	    AssertFatal (UE_template->physicalConfigDedicated != NULL, 
+			 "UE_template->physicalConfigDedicated is null\n");
+	    AssertFatal (UE_template->physicalConfigDedicated->ext4 != NULL, 
+			 "UE_template->physicalConfigDedicated->ext4 is null\n");
+	    AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11 != NULL, 
+			 "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11 is null\n");
+	    AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present == LTE_EPDCCH_Config_r11__config_r11_PR_setup, 
+	      "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present != setup\n");
+	    AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 != NULL,
+	      "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 = NULL\n");
+	    LTE_EPDCCH_SetConfig_r11_t *epdcch_setconfig_r11 = UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.array[0];
+	    AssertFatal(epdcch_setconfig_r11 != NULL, "epdcch_setconfig_r11 is null\n");
+	    AssertFatal(epdcch_setconfig_r11->ext2!=NULL, "epdcch_setconfig_r11->ext2 is null\n");
+	    AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13!=NULL,
+			"epdcch_setconfig_r11->ext2->mpdcch_config_r13 is null");
+	    AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13!=NULL,
+			"epdcch_setconfig_r11->ext2->mpdcch_config_r13 is null");
+	    AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13->present==LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13_PR_setup, 
+			"epdcch_setconfig_r11->ext2->mpdcch_config_r13->present is not setup\n");
+	    AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310!=NULL,
+			"epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310 is null");
+	    AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present==LTE_EPDCCH_SetConfig_r11__ext2__numberPRB_Pairs_v1310_PR_setup, 
+			"epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present is not setup\n");
+
+	    LOG_I(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL 6-0A MPDCCH for BL/CE UE %d/%x, ulsch_frame %d, ulsch_subframe %d,UESS MPDCCH Narrowband %d\n",
+                  harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP,(int)epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13-1);
+
+            UE_template->first_rb_ul[harq_pid] = narrowband_to_first_rb (cc,
+									 epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13-1);	     
+            hi_dci0_pdu                                                         = &hi_dci0_req->hi_dci0_pdu_list[hi_dci0_req->number_of_dci+hi_dci0_req->number_of_hi];
+            memset((void*)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t));
+
+	    hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE;
+	    hi_dci0_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_mpdcch_pdu));
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dci_format = (UE_template->rach_resource_type > 1) ? 5 : 4;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ce_mode = (UE_template->rach_resource_type > 1) ? 2 : 1;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mpdcch_narrowband = epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13-1; 
+
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_prb_pairs = 6;       // checked above that it has to be this
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mpdcch_transmission_type = epdcch_setconfig_r11->transmissionType_r11;  // distibuted
+
+	    AssertFatal(UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11!=NULL,
+	      "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 is null\n");
+
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.start_symbol = *UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ecce_index = 0;        // Note: this should be dynamic
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.aggreagation_level = 24;        // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.rnti_type = 4; // other
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.rnti = rnti;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ce_mode = (UE_template->rach_resource_type < 3) ? 1 : 2;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.drms_scrambling_init = epdcch_setconfig_r11->dmrs_ScramblingSequenceInt_r11;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.initial_transmission_sf_io = (frameP * 10) + subframeP;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.transmission_power = 6000;     // 0dB
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.resource_block_start = UE_template->first_rb_ul[harq_pid];
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_resource_blocks = 6;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mcs = 4;       // adjust according to size of RAR, 208 bits with N1A_PRB=3
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.pusch_repetition_levels = 0;
+	    AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_pdsch_HoppingConfig_r13==
+			LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13__setup__mpdcch_pdsch_HoppingConfig_r13_off,
+			"epdcch_setconfig_r11->ext2->mpdcch_config_r13->mpdcch_pdsch_HoppingConfig_r13 is not off\n"); 
+    	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.frequency_hopping_flag  = 1-epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_pdsch_HoppingConfig_r13;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.redudency_version = 0;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.new_data_indication = UE_template->oldNDI_UL[harq_pid];
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.harq_process = 0;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tpc = tpc;       
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.csi_request = cqi_req;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ul_inex = 0;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dai_presence_flag = 0;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dl_assignment_index = 0;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.srs_request = 0;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dci_subframe_repetition_number = 0;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tcp_bitmap = 0;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.total_dci_length_include_padding = 29; // hard-coded for 10 MHz
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_tx_antenna_ports = 1;
+
+            hi_dci0_req->number_of_dci++;
+
+
+            LOG_I(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for BL/CE UE %d/%x, ulsch_frame %d, ulsch_subframe %d, UESS mpdcch narrowband %d\n",
+                  harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP,
+		  (int)epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13-1);
+
+
+            fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus],
+                                                 cqi_req,
+                                                 cc,
+                                                 UE_template->physicalConfigDedicated,
+                                                 get_tmode(module_idP,CC_id,UE_id),
+                                                 eNB->ul_handle,
+                                                 rnti,
+                                                 UE_template->first_rb_ul[harq_pid], // resource_block_start
+                                                 UE_template->nb_rb_ul[harq_pid], // number_of_resource_blocks
+                                                 UE_template->mcs_UL[harq_pid],
+                                                 cshift, // cyclic_shift_2_for_drms
+                                                 0, // frequency_hopping_enabled_flag
+                                                 0, // frequency_hopping_bits
+                                                 UE_template->oldNDI_UL[harq_pid], // new_data_indication
+                                                 rvidx_tab[round&3], // redundancy_version
+                                                 harq_pid, // harq_process_number
+                                                 0, // ul_tx_mode
+                                                 0, // current_tx_nb
+                                                 0, // n_srs
+                                                 UE_template->TBS_UL[harq_pid]
+                                                 );
+	    fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus],
+						 UE_template->rach_resource_type>2 ? 2 : 1,
+						 1, //total_number_of_repetitions
+						 1, //repetition_number
+						 (frameP*10)+subframeP);
+	  
+
+            ul_req_tmp->number_of_pdus++;
+            eNB->ul_handle++;
+
+            add_ue_ulsch_info(module_idP,
+                              CC_id,
+                              UE_id,
+                              subframeP,
+                              S_UL_SCHEDULED);
+
+            LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0\n", module_idP,CC_id,frameP,subframeP,UE_id);
+
+          }
+          else { // round > 0 => retransmission
+            T(T_ENB_MAC_UE_UL_SCHEDULE_RETRANSMISSION, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP),
+              T_INT(subframeP), T_INT(harq_pid), T_INT(UE_template->mcs_UL[harq_pid]), T_INT(0), T_INT(6),
+              T_INT(round));
+
+	    AssertFatal (UE_template->physicalConfigDedicated != NULL, 
+			 "UE_template->physicalConfigDedicated is null\n");
+	    AssertFatal (UE_template->physicalConfigDedicated->ext4 != NULL, 
+			 "UE_template->physicalConfigDedicated->ext4 is null\n");
+	    AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11 != NULL, 
+			 "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11 is null\n");
+	    AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present == LTE_EPDCCH_Config_r11__config_r11_PR_setup, 
+	      "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present != setup\n");
+	    AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 != NULL,
+	      "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 = NULL\n");
+	    LTE_EPDCCH_SetConfig_r11_t *epdcch_setconfig_r11 = UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.array[0];
+	    AssertFatal(epdcch_setconfig_r11 != NULL, "epdcch_setconfig_r11 is null\n");
+	    AssertFatal(epdcch_setconfig_r11->ext2!=NULL, "epdcch_setconfig_r11->ext2 is null\n");
+	    AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13!=NULL,
+			"epdcch_setconfig_r11->ext2->mpdcch_config_r13 is null");
+	    AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13!=NULL,
+			"epdcch_setconfig_r11->ext2->mpdcch_config_r13 is null");
+	    AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13->present==LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13_PR_setup, 
+			"epdcch_setconfig_r11->ext2->mpdcch_config_r13->present is not setup\n");
+	    AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310!=NULL,
+			"epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310 is null");
+	    AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present==LTE_EPDCCH_SetConfig_r11__ext2__numberPRB_Pairs_v1310_PR_setup, 
+			"epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present is not setup\n");
+
+	    LOG_I(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL 6-0A MPDCCH for BL/CE UE %d/%x, ulsch_frame %d, ulsch_subframe %d,UESS MPDCCH Narrowband %d\n",
+                  harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP,(int)epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13-1);
+
+            UE_template->first_rb_ul[harq_pid] = narrowband_to_first_rb (cc,
+									 epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13-1);	     
+            hi_dci0_pdu                                                         = &hi_dci0_req->hi_dci0_pdu_list[hi_dci0_req->number_of_dci+hi_dci0_req->number_of_hi];
+            memset((void*)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t));
+
+	    hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE;
+	    hi_dci0_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_mpdcch_pdu));
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dci_format = (UE_template->rach_resource_type > 1) ? 5 : 4;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ce_mode = (UE_template->rach_resource_type > 1) ? 2 : 1;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mpdcch_narrowband = epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13-1; 
+
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_prb_pairs = 6;       // checked above that it has to be this
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mpdcch_transmission_type = epdcch_setconfig_r11->transmissionType_r11;  // distibuted
+
+	    AssertFatal(UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11!=NULL,
+	      "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 is null\n");
+
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.start_symbol = *UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ecce_index = 0;        // Note: this should be dynamic
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.aggreagation_level = 24;        // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.rnti_type = 4; // other
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.rnti = rnti;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ce_mode = (UE_template->rach_resource_type < 3) ? 1 : 2;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.drms_scrambling_init = epdcch_setconfig_r11->dmrs_ScramblingSequenceInt_r11;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.initial_transmission_sf_io = (frameP * 10) + subframeP;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.transmission_power = 6000;     // 0dB
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.resource_block_start = UE_template->first_rb_ul[harq_pid];
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_resource_blocks = 6;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mcs = 4;       // adjust according to size of RAR, 208 bits with N1A_PRB=3
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.pusch_repetition_levels = 0;
+	    AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_pdsch_HoppingConfig_r13==
+			LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13__setup__mpdcch_pdsch_HoppingConfig_r13_off,
+			"epdcch_setconfig_r11->ext2->mpdcch_config_r13->mpdcch_pdsch_HoppingConfig_r13 is not off\n"); 
+    	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.frequency_hopping_flag  = 1-epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_pdsch_HoppingConfig_r13;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.redudency_version = rvidx_tab[round&3];
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.new_data_indication = UE_template->oldNDI_UL[harq_pid];
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.harq_process = harq_pid;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tpc = tpc;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.csi_request = cqi_req;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ul_inex = 0;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dai_presence_flag = 0;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dl_assignment_index = 0;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.srs_request = 0;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dci_subframe_repetition_number = 0;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tcp_bitmap = 0;
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.total_dci_length_include_padding = 29; // hard-coded for 10 MHz
+	    hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_tx_antenna_ports = 1;
+
+	    hi_dci0_req->number_of_dci++;
+            fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus],
+                                                 cqi_req,
+                                                 cc,
+                                                 UE_template->physicalConfigDedicated,
+                                                 get_tmode(module_idP,CC_id,UE_id),
+                                                 eNB->ul_handle,
+                                                 rnti,
+                                                 UE_template->first_rb_ul[harq_pid], // resource_block_start
+                                                 UE_template->nb_rb_ul[harq_pid], // number_of_resource_blocks
+                                                 UE_template->mcs_UL[harq_pid],
+                                                 cshift, // cyclic_shift_2_for_drms
+                                                 0, // frequency_hopping_enabled_flag
+                                                 0, // frequency_hopping_bits
+                                                 UE_template->oldNDI_UL[harq_pid], // new_data_indication
+                                                 rvidx_tab[round&3], // redundancy_version
+                                                 harq_pid, // harq_process_number
+                                                 0, // ul_tx_mode
+                                                 0, // current_tx_nb
+                                                 0, // n_srs
+                                                 UE_template->TBS_UL[harq_pid]
+                                                 );
+	    fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus],
+						 UE_template->rach_resource_type>2 ? 2 : 1,
+						 1, //total_number_of_repetitions
+						 1, //repetition_number
+						 (frameP*10)+subframeP);
+            
+	    ul_req_tmp->number_of_pdus++;
+	    eNB->ul_handle++;
+
+          }
+        } // UE_is_to_be_scheduled
+    } // ULCCs
+  } // loop over UE_id
+}
+#endif
diff --git a/openair2/LAYER2/MAC/mac.h b/openair2/LAYER2/MAC/mac.h
index 7785abd16f85fcb9f9d0fb96e886b99272d4a33e..55112166780aa0c6c7149bfb75c47abab48bb028 100644
--- a/openair2/LAYER2/MAC/mac.h
+++ b/openair2/LAYER2/MAC/mac.h
@@ -896,9 +896,6 @@ typedef struct {
     uint32_t pucch_tpc_tx_frame;
     uint32_t pucch_tpc_tx_subframe;
 
-#ifdef LOCALIZATION
-    eNB_UE_estimated_distances distance;
-#endif
 
 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
     uint8_t rach_resource_type;
@@ -978,6 +975,7 @@ typedef struct {
     uint16_t feedback_cnt[NFAPI_CC_MAX];
     uint16_t timing_advance;
     uint16_t timing_advance_r9;
+    uint8_t tpc_accumulated[NFAPI_CC_MAX];
     uint8_t periodic_wideband_cqi[NFAPI_CC_MAX];
     uint8_t periodic_wideband_spatial_diffcqi[NFAPI_CC_MAX];
     uint8_t periodic_wideband_pmi[NFAPI_CC_MAX];
@@ -999,63 +997,66 @@ typedef struct {
 } UE_sched_ctrl;
 /*! \brief eNB template for the Random access information */
 typedef struct {
-    /// Flag to indicate this process is active
-    RA_state state;
-    /// Subframe where preamble was received
-    uint8_t preamble_subframe;
-    /// Subframe where Msg2 is to be sent
-    uint8_t Msg2_subframe;
-    /// Frame where Msg2 is to be sent
-    frame_t Msg2_frame;
-    /// Subframe where Msg3 is to be sent
-    sub_frame_t Msg3_subframe;
-    /// Frame where Msg3 is to be sent
-    frame_t Msg3_frame;
-    /// Subframe where Msg4 is to be sent
-    sub_frame_t Msg4_subframe;
-    /// Frame where Msg4 is to be sent
-    frame_t Msg4_frame;
-    /// harq_pid used for Msg4 transmission
-    uint8_t harq_pid;
-    /// UE RNTI allocated during RAR
-    rnti_t rnti;
-    /// RA RNTI allocated from received PRACH
-    uint16_t RA_rnti;
-    /// Received preamble_index
-    uint8_t preamble_index;
-    /// Received UE Contention Resolution Identifier
-    uint8_t cont_res_id[6];
-    /// Timing offset indicated by PHY
-    int16_t timing_offset;
-    /// Timeout for RRC connection
-    int16_t RRC_timer;
-    /// Msg3 first RB
-    uint8_t msg3_first_rb;
-    /// Msg3 number of RB
-    uint8_t msg3_nb_rb;
-    /// Msg3 MCS
-    uint8_t msg3_mcs;
-    /// Msg3 TPC command
-    uint8_t msg3_TPC;
-    /// Msg3 ULdelay command
-    uint8_t msg3_ULdelay;
-    /// Msg3 cqireq command
-    uint8_t msg3_cqireq;
-    /// Round of Msg3 HARQ
-    uint8_t msg3_round;
-    /// TBS used for Msg4
-    int msg4_TBsize;
-    /// MCS used for Msg4
-    int msg4_mcs;
+  /// Flag to indicate this process is active
+  RA_state state;
+  /// Subframe where preamble was received
+  uint8_t preamble_subframe;
+  /// Subframe where Msg2 is to be sent
+  uint8_t Msg2_subframe;
+  /// Frame where Msg2 is to be sent
+  frame_t Msg2_frame;
+  /// Subframe where Msg3 is to be sent
+  sub_frame_t Msg3_subframe;
+  /// Frame where Msg3 is to be sent
+  frame_t Msg3_frame;
+  /// Subframe where Msg4 is to be sent
+  sub_frame_t Msg4_subframe;
+  /// Frame where Msg4 is to be sent
+  frame_t Msg4_frame;
+  /// harq_pid used for Msg4 transmission
+  uint8_t harq_pid;
+  /// UE RNTI allocated during RAR
+  rnti_t rnti;
+  /// RA RNTI allocated from received PRACH
+  uint16_t RA_rnti;
+  /// Received preamble_index
+  uint8_t preamble_index;
+  /// Received UE Contention Resolution Identifier
+  uint8_t cont_res_id[6];
+  /// Timing offset indicated by PHY
+  int16_t timing_offset;
+  /// Timeout for RRC connection
+  int16_t RRC_timer;
+  /// Msg3 first RB
+  uint8_t msg3_first_rb;
+  /// Msg3 number of RB
+  uint8_t msg3_nb_rb;
+  /// Msg3 MCS
+  uint8_t msg3_mcs;
+  /// Msg3 TPC command
+  uint8_t msg3_TPC;
+  /// Msg3 ULdelay command
+  uint8_t msg3_ULdelay;
+  /// Msg3 cqireq command
+  uint8_t msg3_cqireq;
+  /// Round of Msg3 HARQ
+  uint8_t msg3_round;
+  /// TBS used for Msg4
+  int msg4_TBsize;
+  /// MCS used for Msg4
+  int msg4_mcs;
 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
-    uint8_t rach_resource_type;
-    uint8_t msg2_mpdcch_repetition_cnt;
-    uint8_t msg4_mpdcch_repetition_cnt;
-    uint8_t msg2_narrowband;
-    uint8_t msg34_narrowband;
+  uint8_t rach_resource_type;
+  uint8_t msg2_mpdcch_repetition_cnt;
+  int     msg2_mpdcch_done;
+  uint8_t msg4_mpdcch_repetition_cnt;
+  int     msg4_mpdcch_done;
+  uint8_t msg2_narrowband;
+  uint8_t msg34_narrowband;
+  int     msg4_rrc_sdu_length;
 #endif
-    int32_t  crnti_rrc_mui;
-    int8_t   crnti_harq_pid;
+  int32_t  crnti_rrc_mui;
+  int8_t   crnti_harq_pid;
 } RA_t;
 
 
@@ -1069,43 +1070,40 @@ typedef struct {
 } SBMAP_CONF;
 /*! \brief UE list used by eNB to order UEs/CC for scheduling*/
 typedef struct {
-    /// Dedicated information for UEs
-    LTE_PhysicalConfigDedicated_t *physicalConfigDedicated[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB];
-    /// DLSCH pdu
-    DLSCH_PDU DLSCH_pdu[NFAPI_CC_MAX][2][MAX_MOBILES_PER_ENB];
-    /// DCI template and MAC connection parameters for UEs
-    UE_TEMPLATE UE_template[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB];
-    /// DCI template and MAC connection for RA processes
-    int pCC_id[MAX_MOBILES_PER_ENB];
-    /// sorted downlink component carrier for the scheduler
-    int ordered_CCids[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB];
-    /// number of downlink active component carrier
-    int numactiveCCs[MAX_MOBILES_PER_ENB];
-    /// sorted uplink component carrier for the scheduler
-    int ordered_ULCCids[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB];
-    /// number of uplink active component carrier
-    int numactiveULCCs[MAX_MOBILES_PER_ENB];
-    /// number of downlink active component carrier
-    uint8_t dl_CC_bitmap[MAX_MOBILES_PER_ENB];
-    /// eNB to UE statistics
-    eNB_UE_STATS eNB_UE_stats[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB];
-    /// scheduling control info
-    UE_sched_ctrl UE_sched_ctrl[MAX_MOBILES_PER_ENB];
-    int next[MAX_MOBILES_PER_ENB];
-    int head;
-    int next_ul[MAX_MOBILES_PER_ENB];
-    int head_ul;
-    int avail;
-    int num_UEs;
-    boolean_t active[MAX_MOBILES_PER_ENB];
-
-    /// Sorting criteria for the UE list in the MAC preprocessor
-    uint16_t sorting_criteria[MAX_NUM_SLICES][CR_NUM];
-    uint16_t first_rb_offset[NFAPI_CC_MAX][MAX_NUM_SLICES];
-
-    int assoc_dl_slice_idx[MAX_MOBILES_PER_ENB];
-    int assoc_ul_slice_idx[MAX_MOBILES_PER_ENB];
 
+  DLSCH_PDU DLSCH_pdu[NFAPI_CC_MAX][2][MAX_MOBILES_PER_ENB];
+  /// DCI template and MAC connection parameters for UEs
+  UE_TEMPLATE UE_template[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB];
+  /// DCI template and MAC connection for RA processes
+  int pCC_id[MAX_MOBILES_PER_ENB];
+  /// sorted downlink component carrier for the scheduler
+  int ordered_CCids[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB];
+  /// number of downlink active component carrier
+  int numactiveCCs[MAX_MOBILES_PER_ENB];
+  /// sorted uplink component carrier for the scheduler
+  int ordered_ULCCids[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB];
+  /// number of uplink active component carrier
+  int numactiveULCCs[MAX_MOBILES_PER_ENB];
+  /// number of downlink active component carrier
+  uint8_t dl_CC_bitmap[MAX_MOBILES_PER_ENB];
+  /// eNB to UE statistics
+  eNB_UE_STATS eNB_UE_stats[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB];
+  /// scheduling control info
+  UE_sched_ctrl UE_sched_ctrl[MAX_MOBILES_PER_ENB];
+  int next[MAX_MOBILES_PER_ENB];
+  int head;
+  int next_ul[MAX_MOBILES_PER_ENB];
+  int head_ul;
+  int avail;
+  int num_UEs;
+  boolean_t active[MAX_MOBILES_PER_ENB];
+  
+  /// Sorting criteria for the UE list in the MAC preprocessor
+  uint16_t sorting_criteria[MAX_NUM_SLICES][CR_NUM];
+  uint16_t first_rb_offset[NFAPI_CC_MAX][MAX_NUM_SLICES];
+  
+  int assoc_dl_slice_idx[MAX_MOBILES_PER_ENB];
+  int assoc_ul_slice_idx[MAX_MOBILES_PER_ENB];  
 } UE_list_t;
 
 /*! \brief deleting control information*/
diff --git a/openair2/LAYER2/MAC/mac_proto.h b/openair2/LAYER2/MAC/mac_proto.h
index b953c1d4313dfd405e5a6423f16d87247f8bd80b..883010e8d5e5dbe3db04d06e245dbb8e46c64117 100644
--- a/openair2/LAYER2/MAC/mac_proto.h
+++ b/openair2/LAYER2/MAC/mac_proto.h
@@ -113,6 +113,12 @@ void schedule_ulsch_rnti(module_id_t module_idP, int slice_idx, frame_t frameP,
 			 unsigned char sched_subframe,
 			 uint16_t * first_rb);
 
+void schedule_ulsch_rnti_emtc(module_id_t   module_idP,
+			      frame_t       frameP,
+			      sub_frame_t   subframeP,
+			      unsigned char sched_subframeP,
+			      int          *emtc_active);
+
 /** \brief Second stage of DLSCH scheduling, after schedule_SI, schedule_RA and schedule_dlsch have been called.  This routine first allocates random frequency assignments for SI and RA SDUs using distributed VRB allocations and adds the corresponding DCI SDU to the DCI buffer for PHY.  It then loops over the UE specific DCIs previously allocated and fills in the remaining DCI fields related to frequency allocation.  It assumes localized allocation of type 0 (DCI.rah=0).  The allocation is done for tranmission modes 1,2,4.
 @param Mod_id Instance of eNB
 @param frame Frame index
@@ -133,7 +139,9 @@ void schedule_dlsch(module_id_t module_idP, frame_t frameP,
 
 void schedule_ue_spec(module_id_t module_idP, int slice_idxP,
 		      frame_t frameP,sub_frame_t subframe, int *mbsfn_flag);
-
+void schedule_ue_spec_br(module_id_t   module_idP,
+			 frame_t       frameP,
+			 sub_frame_t   subframeP);
 void schedule_ue_spec_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t subframe,int *mbsfn_flag);
 void schedule_ulsch_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP);
 
diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c
index 341579a084ce7908dd409d54e838aa0013eea6c1..e98019eff9d3e8cf4da6ac56b135722ed9a921dc 100644
--- a/openair2/LAYER2/MAC/pre_processor.c
+++ b/openair2/LAYER2/MAC/pre_processor.c
@@ -1660,6 +1660,11 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP,
       rnti = UE_RNTI(module_idP, i);
       UE_id = i;
 
+
+    if (UE_list->UE_template[CC_id][UE_id].rach_resource_type > 0) continue;
+
+    rnti = UE_RNTI(module_idP,i);
+
       if (rnti == NOT_A_RNTI)
         continue;
 
diff --git a/openair2/LAYER2/MAC/rar_tools.c b/openair2/LAYER2/MAC/rar_tools.c
index 3414d7632f782b4ef5854c8b5b226b4e9863e245..2fa13fc98c2293b9ab5215ef12a5c540bbc9cc47 100644
--- a/openair2/LAYER2/MAC/rar_tools.c
+++ b/openair2/LAYER2/MAC/rar_tools.c
@@ -110,85 +110,101 @@ fill_rar(const module_id_t module_idP,
 
 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
 //------------------------------------------------------------------------------
-unsigned short
-fill_rar_br(eNB_MAC_INST * eNB,
-	    int CC_id,
-	    RA_t * ra,
-	    const frame_t frameP,
-	    const sub_frame_t subframeP,
-	    uint8_t * const dlsch_buffer, const uint8_t ce_level)
+
+unsigned short fill_rar_br(eNB_MAC_INST *eNB,
+			   int CC_id,
+			   RA_t        *ra,
+			   const frame_t      frameP,
+			   const sub_frame_t  subframeP,
+			   uint8_t*    const  dlsch_buffer,
+			   const uint8_t      ce_level
+			   )
 //------------------------------------------------------------------------------
 {
 
-    RA_HEADER_RAPID *rarh = (RA_HEADER_RAPID *) dlsch_buffer;
-    COMMON_channels_t *cc = &eNB->common_channels[CC_id];
-    uint8_t *rar = (uint8_t *) (dlsch_buffer + 1);
-    //  uint8_t nb,reps;
-    uint8_t rballoc;
-    uint8_t mcs, TPC, ULdelay, cqireq;
-    int input_buffer_length;
-
-
-    AssertFatal(ra != NULL, "RA is null \n");
-
-    // subheader fixed
-    rarh->E = 0;		// First and last RAR
-    rarh->T = 1;		// 0 for E/T/R/R/BI subheader, 1 for E/T/RAPID subheader
-    rarh->RAPID = ra->preamble_index;	// Respond to Preamble 0 only for the moment
-    ra->timing_offset /= 16;	//T_A = N_TA/16, where N_TA should be on a 30.72Msps
-    rar[0] = (uint8_t) (ra->timing_offset >> (2 + 4));	// 7 MSBs of timing advance + divide by 4
-    rar[1] = (uint8_t) (ra->timing_offset << (4 - 2)) & 0xf0;	// 4 LSBs of timing advance + divide by 4
-
-    int N_NB_index;
-
-    AssertFatal(1 == 0, "RAR for BL/CE Still to be finished ...\n");
-
-    // Copy the Msg2 narrowband
-    ra->msg34_narrowband = ra->msg2_narrowband;
-
-    if (ce_level < 2) {		//CE Level 0,1, CEmodeA
-	input_buffer_length = 6;
-
-	N_NB_index = get_numnarrowbandbits(cc->mib->message.dl_Bandwidth);
-
-	rar[4] = (uint8_t) (ra->rnti >> 8);
-	rar[5] = (uint8_t) (ra->rnti & 0xff);
-	//cc->ra[ra_idx].timing_offset = 0;
-	//    nb      = 0;
-	rballoc = mac_computeRIV(6, 1 + ce_level, 1);	// one PRB only for UL Grant in position 1+ce_level within Narrowband
-	rar[1] |= (rballoc & 15) << (4 - N_NB_index);	// Hopping = 0 (bit 3), 3 MSBs of rballoc
-
-	//    reps    = 4;
-	mcs = 7;
-	TPC = 3;		// no power increase
-	ULdelay = 0;
-	cqireq = 0;
-	rar[2] |= ((mcs & 0x8) >> 3);	// mcs 10
-	rar[3] =
-	    (((mcs & 0x7) << 5)) | ((TPC & 7) << 2) | ((ULdelay & 1) << 1)
-	    | (cqireq & 1);
-    } else {			// CE level 2,3 => CEModeB
-
-	input_buffer_length = 5;
-
-	rar[3] = (uint8_t) (ra->rnti >> 8);
-	rar[4] = (uint8_t) (ra->rnti & 0xff);
-    }
-    LOG_D(MAC,
-	  "[RAPROC] Frame %d Generating RAR BR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for ce_level %d, CRNTI %x,preamble %d/%d,TIMING OFFSET %d\n",
-	  frameP, *(uint8_t *) rarh, rar[0], rar[1], rar[2], rar[3],
-	  rar[4], rar[5], ce_level, ra->rnti, rarh->RAPID,
-	  ra->preamble_index, ra->timing_offset);
-
-    if (opt_enabled) {
-	trace_pdu(DIRECTION_DOWNLINK , dlsch_buffer, input_buffer_length, eNB->Mod_id,  WS_RA_RNTI , 1,
-		  eNB->frame, eNB->subframe, 0, 0);
-	LOG_D(OPT,
-	      "[RAPROC] RAR Frame %d trace pdu for rnti %x and  rapid %d size %d\n",
-	      frameP, ra->rnti, rarh->RAPID, input_buffer_length);
-    }
-
-    return (ra->rnti);
+  RA_HEADER_RAPID *rarh = (RA_HEADER_RAPID *)dlsch_buffer;
+  COMMON_channels_t *cc = &eNB->common_channels[CC_id];
+  uint8_t *rar = (uint8_t *)(dlsch_buffer+1);
+
+  uint32_t rballoc,reps;
+  uint32_t TPC,ULdelay,cqireq,mpdcch_nb_index;
+  int input_buffer_length;
+
+
+  AssertFatal(ra != NULL, "RA is null \n");
+  
+  // subheader fixed
+  rarh->E = 0;		// First and last RAR
+  rarh->T = 1;		// 0 for E/T/R/R/BI subheader, 1 for E/T/RAPID subheader
+  rarh->RAPID = ra->preamble_index;	// Respond to Preamble 0 only for the moment
+  ra->timing_offset /= 16;	//T_A = N_TA/16, where N_TA should be on a 30.72Msps
+  rar[0] = (uint8_t) (ra->timing_offset >> (2 + 4));	// 7 MSBs of timing advance + divide by 4
+  rar[1] = (uint8_t) (ra->timing_offset << (4 - 2)) & 0xf0;	// 4 LSBs of timing advance + divide by 4
+  
+  int N_NB_index;
+  
+  // Copy the Msg2 narrowband
+  ra->msg34_narrowband = ra->msg2_narrowband;
+  ra->msg3_first_rb    = 0;
+  ra->msg3_nb_rb       = 2;
+
+
+  if (ce_level < 2) {		//CE Level 0,1, CEmodeA
+    input_buffer_length = 6;
+    
+    N_NB_index = get_numnarrowbandbits(cc->mib->message.dl_Bandwidth);
+
+    rar[4] = (uint8_t)(ra->rnti>>8);
+    rar[5] = (uint8_t)(ra->rnti&0xff);
+    //cc->ra[ra_idx].timing_offset = 0;
+    
+    reps = 0;
+    ra->msg3_mcs = 7;
+    TPC = 3; // no power increase
+    ULdelay = 0;
+    cqireq = 0;
+    mpdcch_nb_index = 0;
+    rballoc = mac_computeRIV(6,ra->msg3_first_rb,ra->msg3_nb_rb);
+
+    uint32_t buffer = 0;
+    buffer |= ra->msg34_narrowband << (16 + (4 - N_NB_index));
+    buffer |= ((rballoc & 0xFF) << (12 + (4 - N_NB_index)));
+    buffer |= ((reps & 0x03) << (10 + (4 - N_NB_index)));
+    buffer |= ((ra->msg3_mcs & 0x07) << (7 + (4 - N_NB_index)));
+    buffer |= ((TPC & 0x07) << (4 + (4 - N_NB_index)));
+    buffer |= ((cqireq & 0x01) << (3 + (4 - N_NB_index)));
+    buffer |= ((ULdelay & 0x01) << (2 + (4 - N_NB_index)));
+    buffer |= (mpdcch_nb_index << (4 - N_NB_index));
+    rar[1] = (buffer>>16) & 0x0F;
+    rar[2] = (buffer>>8) & 0xFF;
+    rar[3] = buffer&0xFF;
+  }
+  else { // CE level 2,3 => CEModeB
+
+    AssertFatal(1==0,"Shouldn't get here ...\n");
+    input_buffer_length =5;
+
+
+    rar[3] = (uint8_t)(ra->rnti>>8);
+    rar[4] = (uint8_t)(ra->rnti&0xff);
+  }
+  LOG_I(MAC,"[RAPROC] Frame %d Subframe %d : Generating RAR BR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for ce_level %d, CRNTI %x,preamble %d/%d,TIMING OFFSET %d\n",
+        frameP,subframeP,
+        *(uint8_t*)rarh,rar[0],rar[1],rar[2],rar[3],rar[4],rar[5],
+        ce_level,
+        ra->rnti,
+        rarh->RAPID,ra->preamble_index,
+        ra->timing_offset);
+
+  if (opt_enabled) {
+    trace_pdu(DIRECTION_DOWNLINK , dlsch_buffer, input_buffer_length, eNB->Mod_id,  WS_RA_RNTI , 1,
+	      eNB->frame, eNB->subframe, 0, 0);
+    LOG_D(OPT,
+	  "[RAPROC] RAR Frame %d trace pdu for rnti %x and  rapid %d size %d\n",
+	  frameP, ra->rnti, rarh->RAPID, input_buffer_length);
+  }
+
+  return (ra->rnti);
 }
 #endif
 
diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c
index 19765cff040b230f2190e93ff54f7de81c373bd7..bca5ef0ae8afbb42d8302f6a6da07508d3f90303 100644
--- a/openair2/LAYER2/MAC/ue_procedures.c
+++ b/openair2/LAYER2/MAC/ue_procedures.c
@@ -559,31 +559,34 @@ ue_send_sdu(module_id_t module_idP,
 		LOG_T(MAC, "\n");
 #endif
 
-		mac_rrc_data_ind_ue(module_idP,
-				 CC_id,
-				 frameP, subframeP,
-				 UE_mac_inst[module_idP].crnti,
-				 CCCH,
-				 (uint8_t *) payload_ptr,
-				 rx_lengths[i], eNB_index, 0);
-
-	    } else if ((rx_lcids[i] == DCCH) || (rx_lcids[i] == DCCH1)) {
-		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(module_idP, UE_mac_inst[module_idP].crnti,
-				 eNB_index, frameP, ENB_FLAG_NO,
-				 MBMS_FLAG_NO, rx_lcids[i],
-				 (char *) payload_ptr, rx_lengths[i], 1,
-				 NULL);
-
-	    } else if ((rx_lcids[i] < NB_RB_MAX) && (rx_lcids[i] > DCCH1)) {
-
-		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]);
+      mac_rrc_data_ind_ue(module_idP,
+			  CC_id,
+			  frameP,subframeP,
+			  UE_mac_inst[module_idP].crnti,
+			  CCCH,
+			  (uint8_t*)payload_ptr,
+			  rx_lengths[i],
+			  eNB_index,
+			  0
+			  );
+
+    } else if ((rx_lcids[i] == DCCH) || (rx_lcids[i] == DCCH1)) {
+      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(module_idP,
+                       UE_mac_inst[module_idP].crnti,
+		       eNB_index,
+                       frameP,
+                       ENB_FLAG_NO,
+                       MBMS_FLAG_NO,
+                       rx_lcids[i],
+                       (char *)payload_ptr,
+                       rx_lengths[i],
+                       1,
+                       NULL);
+ 
+    } else if ((rx_lcids[i]  < NB_RB_MAX) && (rx_lcids[i] > DCCH1 )) {
+      
+      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;
@@ -622,6 +625,7 @@ ue_decode_si(module_id_t module_idP, int CC_id, frame_t frameP,
 #if UE_TIMING_TRACE
     start_meas(&UE_mac_inst[module_idP].rx_si);
 #endif
+
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
 	(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_SI, VCD_FUNCTION_IN);
 
@@ -634,6 +638,7 @@ ue_decode_si(module_id_t module_idP, int CC_id, frame_t frameP,
 		     0);
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
 	(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_SI, VCD_FUNCTION_OUT);
+
 #if UE_TIMING_TRACE
     stop_meas(&UE_mac_inst[module_idP].rx_si);
 #endif
@@ -659,6 +664,7 @@ ue_decode_p(module_id_t module_idP, int CC_id, frame_t frameP,
 #if UE_TIMING_TRACE
     start_meas(&UE_mac_inst[module_idP].rx_p);
 #endif
+
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
 	(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_PCCH, VCD_FUNCTION_IN);
 
@@ -672,6 +678,7 @@ ue_decode_p(module_id_t module_idP, int CC_id, frame_t frameP,
 		     0);
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
 	(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_PCCH, VCD_FUNCTION_OUT);
+
 #if UE_TIMING_TRACE
     stop_meas(&UE_mac_inst[module_idP].rx_p);
 #endif
diff --git a/openair2/NETWORK_DRIVER/LITE/RB_TOOL/Makefile b/openair2/NETWORK_DRIVER/LITE/RB_TOOL/Makefile
old mode 100755
new mode 100644
diff --git a/openair2/NETWORK_DRIVER/UE_IP/README b/openair2/NETWORK_DRIVER/UE_IP/README
old mode 100755
new mode 100644
diff --git a/openair2/PHY_INTERFACE/IF_Module.c b/openair2/PHY_INTERFACE/IF_Module.c
index 9ebee10f9b53a16ce39b1082df6723dfcbec8f12..28055bfc2d52334acff100ba00a7d0e953d300e0 100644
--- a/openair2/PHY_INTERFACE/IF_Module.c
+++ b/openair2/PHY_INTERFACE/IF_Module.c
@@ -47,7 +47,10 @@ void handle_rach(UL_IND_t *UL_info) {
       AssertFatal(UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel13.rach_resource_type>0,
 		  "Got regular PRACH preamble, not BL/CE\n");
       LOG_D(MAC,"Frame %d, Subframe %d Calling initiate_ra_proc (CE_level %d)\n",UL_info->frame,UL_info->subframe,
+
 	    UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel13.rach_resource_type-1);
+      UL_info->rach_ind_br.rach_indication_body.number_of_preambles=0;
+
       initiate_ra_proc(UL_info->module_id,
 		       UL_info->CC_id,
 		       UL_info->frame,
diff --git a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c
index 2815ee3688e7c55490be05f26a2068f21bac0e64..c64fd09bfcc1d0049f2ff260d7eefceb9e19a168 100644
--- a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c
+++ b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c
@@ -72,7 +72,7 @@ mac_rrc_data_req(
 }
 
 //------------------------------------------------------------------------------
-int8_t
+/*int8_t
 mac_rrc_data_ind(
   const module_id_t     module_idP,
   const int             CC_idP,
@@ -100,7 +100,7 @@ mac_rrc_data_ind(
            eNB_indexP,
            mbsfn_sync_area)
         );
-}
+}*/
 
 //------------------------------------------------------------------------------
 void
diff --git a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h
index 4b651761de57a7c1cf7438afe33956cef1a3cdec..2e1d05038778f6d698e0323b68a019ecc5676172 100644
--- a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h
+++ b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h
@@ -44,7 +44,7 @@ mac_rrc_data_req(
   const uint8_t         mbsfn_sync_areaP
 );
 
-int8_t
+/*int8_t
 mac_rrc_data_ind(
   const module_id_t     module_idP,
   const int             CC_idP,
@@ -81,7 +81,7 @@ mac_rrc_data_ind_ue(
   const sdu_size_t      sdu_lenP,
   const mac_enb_index_t eNB_indexP,
   const uint8_t         mbsfn_sync_area
-);
+);*/
 
 void mac_lite_sync_ind(
   const module_id_t module_idP,
diff --git a/openair2/RRC/LITE/rrc_common.c b/openair2/RRC/LITE/rrc_common.c
new file mode 100644
index 0000000000000000000000000000000000000000..736b16422b212da7834abd1e2be2bd2e27899a8d
--- /dev/null
+++ b/openair2/RRC/LITE/rrc_common.c
@@ -0,0 +1,496 @@
+/*
+ * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The OpenAirInterface Software Alliance licenses this file to You under
+ * the OAI Public License, Version 1.1  (the "License"); you may not use this file
+ * except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.openairinterface.org/?page_id=698
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *-------------------------------------------------------------------------------
+ * For more information about the OpenAirInterface (OAI) Software Alliance:
+ *      contact@openairinterface.org
+ */
+
+/*! \file rrc_common.c
+ * \brief rrc common procedures for eNB and UE
+ * \author Navid Nikaein and Raymond Knopp
+ * \date 2011 - 2014
+ * \version 1.0
+ * \company Eurecom
+ * \email:  navid.nikaein@eurecom.fr and raymond.knopp@eurecom.fr
+ */
+
+#include "defs.h"
+#include "extern.h"
+#include "LAYER2/MAC/extern.h"
+#include "COMMON/openair_defs.h"
+#include "COMMON/platform_types.h"
+#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
+#include "LAYER2/RLC/rlc.h"
+#include "COMMON/mac_rrc_primitives.h"
+#include "UTIL/LOG/log.h"
+#include "asn1_msg.h"
+#include "pdcp.h"
+#include "UTIL/LOG/vcd_signal_dumper.h"
+#include "rrc_eNB_UE_context.h"
+#include "common/ran_context.h"
+
+#ifdef LOCALIZATION
+#include <sys/time.h>
+#endif
+
+#define DEBUG_RRC 1
+extern RAN_CONTEXT_t RC;
+extern UE_MAC_INST *UE_mac_inst;
+
+extern mui_t rrc_eNB_mui;
+
+//configure  BCCH & CCCH Logical Channels and associated rrc_buffers, configure associated SRBs
+//-----------------------------------------------------------------------------
+void
+openair_rrc_on(
+  const protocol_ctxt_t* const ctxt_pP
+)
+//-----------------------------------------------------------------------------
+{
+  unsigned short i;
+  int            CC_id;
+
+  if (ctxt_pP->enb_flag == ENB_FLAG_YES) {
+    LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" OPENAIR RRC IN....\n",
+          PROTOCOL_RRC_CTXT_ARGS(ctxt_pP));
+    for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
+      rrc_config_buffer (&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SI, BCCH, 1);
+      RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SI.Active = 1;
+      rrc_config_buffer (&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0, CCCH, 1);
+      RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Active = 1;
+    }
+  } else {
+    LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" OPENAIR RRC IN....\n",
+          PROTOCOL_RRC_CTXT_ARGS(ctxt_pP));
+
+    for (i = 0; i < NB_eNB_INST; i++) {
+      LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" Activating CCCH (eNB %d)\n",
+            PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), i);
+      UE_rrc_inst[ctxt_pP->module_id].Srb0[i].Srb_id = CCCH;
+      memcpy (&UE_rrc_inst[ctxt_pP->module_id].Srb0[i].Lchan_desc[0], &CCCH_LCHAN_DESC, LCHAN_DESC_SIZE);
+      memcpy (&UE_rrc_inst[ctxt_pP->module_id].Srb0[i].Lchan_desc[1], &CCCH_LCHAN_DESC, LCHAN_DESC_SIZE);
+      rrc_config_buffer (&UE_rrc_inst[ctxt_pP->module_id].Srb0[i], CCCH, 1);
+      UE_rrc_inst[ctxt_pP->module_id].Srb0[i].Active = 1;
+    }
+  }
+}
+
+//-----------------------------------------------------------------------------
+int
+rrc_init_global_param(
+  void
+)
+//-----------------------------------------------------------------------------
+{
+
+  //#ifdef USER_MODE
+  //  Rrc_xface = (RRC_XFACE*)malloc16(sizeof(RRC_XFACE));
+  //#endif //USRE_MODE
+
+  //  Rrc_xface->openair_rrc_top_init = openair_rrc_top_init;
+  //  Rrc_xface->openair_rrc_eNB_init = openair_rrc_eNB_init;
+  //  Rrc_xface->openair_rrc_UE_init  = openair_rrc_ue_init;
+  //  Rrc_xface->mac_rrc_data_ind     = mac_rrc_data_ind;
+  //Rrc_xface->mac_rrc_data_req     = mac_rrc_data_req;
+  // Rrc_xface->rrc_data_indP        = (void *)rlcrrc_data_ind;
+  //  Rrc_xface->rrc_rx_tx            = rrc_rx_tx;
+  //  Rrc_xface->mac_rrc_meas_ind     = mac_rrc_meas_ind;
+  //  Rrc_xface->get_rrc_status       = get_rrc_status;
+
+  //Rrc_xface->rrc_get_status = ...
+
+  //  Mac_rlc_xface->mac_out_of_sync_ind=mac_out_of_sync_ind;
+
+#ifndef NO_RRM
+  //  Rrc_xface->fn_rrc=fn_rrc;
+#endif
+  //  LOG_D(RRC, "[RRC]INIT_GLOBAL_PARAM: Mac_rlc_xface %p, rrc_rlc_register %p,rlcrrc_data_ind%p\n",Mac_rlc_xface,Mac_rlc_xface->rrc_rlc_register_rrc,rlcrrc_data_ind);
+  /*
+   if((Mac_rlc_xface==NULL) || (Mac_rlc_xface->rrc_rlc_register_rrc==NULL) ||
+   (rlcrrc_data_ind==NULL)) {
+   LOG_E(RRC,"Data structured is not initialized \n");
+   return -1;
+   }
+   */
+  rrc_rlc_register_rrc (rrc_data_ind, NULL); //register with rlc
+
+  DCCH_LCHAN_DESC.transport_block_size = 4;
+  DCCH_LCHAN_DESC.max_transport_blocks = 16;
+  DCCH_LCHAN_DESC.Delay_class = 1;
+  DTCH_DL_LCHAN_DESC.transport_block_size = 52;
+  DTCH_DL_LCHAN_DESC.max_transport_blocks = 20;
+  DTCH_DL_LCHAN_DESC.Delay_class = 1;
+  DTCH_UL_LCHAN_DESC.transport_block_size = 52;
+  DTCH_UL_LCHAN_DESC.max_transport_blocks = 20;
+  DTCH_UL_LCHAN_DESC.Delay_class = 1;
+
+  Rlc_info_um.rlc_mode = RLC_MODE_UM;
+  Rlc_info_um.rlc.rlc_um_info.timer_reordering = 5;
+  Rlc_info_um.rlc.rlc_um_info.sn_field_length = 10;
+  Rlc_info_um.rlc.rlc_um_info.is_mXch = 0;
+  //Rlc_info_um.rlc.rlc_um_info.sdu_discard_mode=16;
+
+  Rlc_info_am_config.rlc_mode = RLC_MODE_AM;
+  Rlc_info_am_config.rlc.rlc_am_info.max_retx_threshold = 50;
+  Rlc_info_am_config.rlc.rlc_am_info.poll_pdu = 8;
+  Rlc_info_am_config.rlc.rlc_am_info.poll_byte = 1000;
+  Rlc_info_am_config.rlc.rlc_am_info.t_poll_retransmit = 15;
+  Rlc_info_am_config.rlc.rlc_am_info.t_reordering = 50;
+  Rlc_info_am_config.rlc.rlc_am_info.t_status_prohibit = 10;
+
+  return 0;
+}
+
+//-----------------------------------------------------------------------------
+void
+rrc_config_buffer(
+  SRB_INFO* Srb_info,
+  uint8_t Lchan_type,
+  uint8_t Role
+)
+//-----------------------------------------------------------------------------
+{
+
+  Srb_info->Rx_buffer.payload_size = 0;
+  Srb_info->Tx_buffer.payload_size = 0;
+}
+
+
+//-----------------------------------------------------------------------------
+void
+rrc_t310_expiration(
+  const protocol_ctxt_t* const ctxt_pP,
+  const uint8_t                 eNB_index
+)
+//-----------------------------------------------------------------------------
+{
+
+  if (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State != RRC_CONNECTED) {
+    LOG_D(RRC, "Timer 310 expired, going to RRC_IDLE\n");
+    UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State = RRC_IDLE;
+    UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].UE_index = 0xffff;
+    UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Rx_buffer.payload_size = 0;
+    UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.payload_size = 0;
+    UE_rrc_inst[ctxt_pP->module_id].Srb1[eNB_index].Srb_info.Rx_buffer.payload_size = 0;
+    UE_rrc_inst[ctxt_pP->module_id].Srb1[eNB_index].Srb_info.Tx_buffer.payload_size = 0;
+
+    if (UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Active == 1) {
+      msg ("[RRC Inst %d] eNB_index %d, Remove RB %d\n ", ctxt_pP->module_id, eNB_index,
+           UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Srb_info.Srb_id);
+      rrc_pdcp_config_req (ctxt_pP,
+                           SRB_FLAG_YES,
+                           CONFIG_ACTION_REMOVE,
+                           UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Srb_info.Srb_id,
+                           0);
+      rrc_rlc_config_req (ctxt_pP,
+                          SRB_FLAG_YES,
+                          MBMS_FLAG_NO,
+                          CONFIG_ACTION_REMOVE,
+                          UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Srb_info.Srb_id,
+                          Rlc_info_um);
+      UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Active = 0;
+      UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Status = IDLE;
+      UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Next_check_frame = 0;
+    }
+  } else { // Restablishment procedure
+    LOG_D(RRC, "Timer 310 expired, trying RRCRestablishment ...\n");
+  }
+}
+
+//-----------------------------------------------------------------------------
+RRC_status_t
+rrc_rx_tx(
+  protocol_ctxt_t* const ctxt_pP,
+  const uint8_t      enb_indexP,
+  const int          CC_id
+)
+//-----------------------------------------------------------------------------
+{
+  //uint8_t        UE_id;
+  int32_t        current_timestamp_ms, ref_timestamp_ms;
+  struct timeval ts;
+  struct rrc_eNB_ue_context_s   *ue_context_p = NULL,*ue_to_be_removed = NULL;
+
+#ifdef LOCALIZATION
+  double                         estimated_distance;
+  protocol_ctxt_t                ctxt;
+#endif
+  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_IN);
+
+  if(ctxt_pP->enb_flag == ENB_FLAG_NO) {
+    // check timers
+
+    if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_active == 1) {
+      if ((UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_cnt % 10) == 0)
+        LOG_D(RRC,
+              "[UE %d][RAPROC] Frame %d T300 Count %d ms\n", ctxt_pP->module_id, ctxt_pP->frame, UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_cnt);
+
+      if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_cnt
+          == T300[UE_rrc_inst[ctxt_pP->module_id].sib2[enb_indexP]->ue_TimersAndConstants.t300]) {
+        UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_active = 0;
+        // ALLOW CCCH to be used
+        UE_rrc_inst[ctxt_pP->module_id].Srb0[enb_indexP].Tx_buffer.payload_size = 0;
+        rrc_ue_generate_RRCConnectionRequest (ctxt_pP, enb_indexP);
+        VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT);
+        return (RRC_ConnSetup_failed);
+      }
+
+      UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T300_cnt++;
+    }
+
+    if ((UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].SIStatus&2)>0) {
+      if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].N310_cnt
+          == N310[UE_rrc_inst[ctxt_pP->module_id].sib2[enb_indexP]->ue_TimersAndConstants.n310]) {
+	LOG_I(RRC,"Activating T310\n");
+        UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_active = 1;
+      }
+    } else { // in case we have not received SIB2 yet
+      /*      if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].N310_cnt == 100) {
+        UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].N310_cnt = 0;
+
+	}*/
+      VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT);
+      return RRC_OK;
+    }
+
+    if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_active == 1) {
+      if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].N311_cnt
+          == N311[UE_rrc_inst[ctxt_pP->module_id].sib2[enb_indexP]->ue_TimersAndConstants.n311]) {
+        UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_active = 0;
+        UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].N311_cnt = 0;
+      }
+
+      if ((UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_cnt % 10) == 0) {
+        LOG_D(RRC, "[UE %d] Frame %d T310 Count %d ms\n", ctxt_pP->module_id, ctxt_pP->frame, UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_cnt);
+      }
+
+      if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_cnt    == T310[UE_rrc_inst[ctxt_pP->module_id].sib2[enb_indexP]->ue_TimersAndConstants.t310]) {
+        UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_active = 0;
+        rrc_t310_expiration (ctxt_pP, enb_indexP);
+        VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT);
+	LOG_I(RRC,"Returning RRC_PHY_RESYNCH: T310 expired\n"); 
+        return RRC_PHY_RESYNCH;
+      }
+
+      UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T310_cnt++;
+    }
+
+    if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_active==1) {
+      if ((UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_cnt % 10) == 0)
+        LOG_D(RRC,"[UE %d][RAPROC] Frame %d T304 Count %d ms\n",ctxt_pP->module_id,ctxt_pP->frame,
+              UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_cnt);
+
+      if (UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_cnt == 0) {
+        UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_active = 0;
+        UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.measFlag = 1;
+        LOG_E(RRC,"[UE %d] Handover failure..initiating connection re-establishment procedure... \n",
+              ctxt_pP->module_id);
+        //Implement 36.331, section 5.3.5.6 here
+        VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT);
+        return(RRC_Handover_failed);
+      }
+
+      UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].T304_cnt--;
+    }
+
+    // Layer 3 filtering of RRC measurements
+    if (UE_rrc_inst[ctxt_pP->module_id].QuantityConfig[0] != NULL) {
+      ue_meas_filtering(ctxt_pP,enb_indexP);
+    }
+
+    ue_measurement_report_triggering(ctxt_pP,enb_indexP);
+
+    if (UE_rrc_inst[ctxt_pP->module_id].Info[0].handoverTarget > 0) {
+      LOG_I(RRC,"[UE %d] Frame %d : RRC handover initiated\n", ctxt_pP->module_id, ctxt_pP->frame);
+    }
+
+    if((UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].State == RRC_HO_EXECUTION)   &&
+        (UE_rrc_inst[ctxt_pP->module_id].HandoverInfoUe.targetCellId != 0xFF)) {
+      UE_rrc_inst[ctxt_pP->module_id].Info[enb_indexP].State= RRC_IDLE;
+      VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT);
+      return(RRC_HO_STARTED);
+    }
+
+  } else { // eNB
+    check_handovers(ctxt_pP);
+    // counetr, and get the value and aggregate
+
+
+    // check for UL failure
+    RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) {
+      LOG_D(RRC,"SFN.SN %d.%d => release timer %d/%d\n",ctxt_pP->frame,ctxt_pP->subframe,
+	    ue_context_p->ue_context.ue_release_timer,ue_context_p->ue_context.ue_release_timer_thres);
+      if ((ctxt_pP->frame == 0) && (ctxt_pP->subframe==0)) {
+	if (ue_context_p->ue_context.Initialue_identity_s_TMSI.presence == TRUE) {
+	  LOG_I(RRC,"UE rnti %x:S-TMSI %x failure timer %d/20000\n",
+		ue_context_p->ue_context.rnti,
+		ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi,
+		ue_context_p->ue_context.ul_failure_timer);
+	}
+	else {
+	  LOG_I(RRC,"UE rnti %x failure timer %d/20000\n",
+		ue_context_p->ue_context.rnti,
+		ue_context_p->ue_context.ul_failure_timer);
+	}
+      }
+      if (ue_context_p->ue_context.ul_failure_timer>0) {
+	ue_context_p->ue_context.ul_failure_timer++;
+	if (ue_context_p->ue_context.ul_failure_timer >= 20000) {
+	  // remove UE after 20 seconds after MAC has indicated UL failure
+	  LOG_I(RRC,"Removing UE %x instance (failure)\n",ue_context_p->ue_context.rnti);
+	  ue_to_be_removed = ue_context_p;
+	  break;
+	}
+      }
+      if (ue_context_p->ue_context.ue_release_timer>0) {
+	ue_context_p->ue_context.ue_release_timer++;
+	if (ue_context_p->ue_context.ue_release_timer >= 
+	    ue_context_p->ue_context.ue_release_timer_thres) {
+	  LOG_I(RRC,"Removing UE %x instance (release timer %d)\n",ue_context_p->ue_context.rnti,ue_context_p->ue_context.ue_release_timer);
+	  ue_to_be_removed = ue_context_p;
+	  exit(-1);
+	  break;
+	}
+      }
+    }
+    if (ue_to_be_removed)
+      rrc_eNB_free_UE(ctxt_pP->module_id,ue_to_be_removed);
+
+#ifdef RRC_LOCALIZATION
+
+    /* for the localization, only primary CC_id might be relevant*/
+    gettimeofday(&ts, NULL);
+    current_timestamp_ms = ts.tv_sec * 1000 + ts.tv_usec / 1000;
+    ref_timestamp_ms = RC.rrc[ctxt_pP->module_id]->reference_timestamp_ms;
+    RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) {
+      ctxt = *ctxt_pP;
+      ctxt.rnti = ue_context_p->ue_context.rnti;
+      estimated_distance = rrc_get_estimated_ue_distance(
+                             &ctxt,
+                             CC_id,
+                             RC.rrc[ctxt_pP->module_id]->loc_type);
+
+      if ((current_timestamp_ms - ref_timestamp_ms > RC.rrc[ctxt_pP->module_id]->aggregation_period_ms) &&
+          estimated_distance != -1) {
+        LOG_D(LOCALIZE, " RRC [UE/id %d -> eNB/id %d] timestamp %d frame %d estimated r = %f\n",
+              ctxt.rnti,
+              ctxt_pP->module_id,
+              current_timestamp_ms,
+              ctxt_pP->frame,
+              estimated_distance);
+        LOG_D(LOCALIZE, " RRC status %d\n", ue_context_p->ue_context.Status);
+        push_front(&RC.rrc[ctxt_pP->module_id]->loc_list,
+                   estimated_distance);
+        RC.rrc[ctxt_pP->module_id]->reference_timestamp_ms = current_timestamp_ms;
+      }
+    }
+
+#endif
+    (void)ts; /* remove gcc warning "unused variable" */
+    (void)ref_timestamp_ms; /* remove gcc warning "unused variable" */
+    (void)current_timestamp_ms; /* remove gcc warning "unused variable" */
+  }
+
+  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT);
+  return (RRC_OK);
+}
+
+//-----------------------------------------------------------------------------
+long
+binary_search_int(
+  int elements[],
+  long numElem,
+  int value
+)
+//-----------------------------------------------------------------------------
+{
+  long first, last, middle, search = -1;
+  first = 0;
+  last = numElem-1;
+  middle = (first+last)/2;
+
+  if(value < elements[0]) {
+    return first;
+  }
+
+  if(value > elements[last]) {
+    return last;
+  }
+
+  while (first <= last) {
+    if (elements[middle] < value) {
+      first = middle+1;
+    } else if (elements[middle] == value) {
+      search = middle+1;
+      break;
+    } else {
+      last = middle -1;
+    }
+
+    middle = (first+last)/2;
+  }
+
+  if (first > last) {
+    LOG_E(RRC,"Error in binary search!");
+  }
+
+  return search;
+}
+
+/* This is a binary search routine which operates on an array of floating
+   point numbers and returns the index of the range the value lies in
+   Used for RSRP and RSRQ measurement mapping. Can potentially be used for other things
+*/
+//-----------------------------------------------------------------------------
+long
+binary_search_float(
+  float elements[],
+  long numElem,
+  float value
+)
+//-----------------------------------------------------------------------------
+{
+  long first, last, middle;
+  first = 0;
+  last = numElem-1;
+  middle = (first+last)/2;
+
+  if(value <= elements[0]) {
+    return first;
+  }
+
+  if(value >= elements[last]) {
+    return last;
+  }
+
+  while (last - first > 1) {
+    if (elements[middle] > value) {
+      last = middle;
+    } else {
+      first = middle;
+    }
+
+    middle = (first+last)/2;
+  }
+
+  if (first < 0 || first >= numElem) {
+    LOG_E(RRC,"\n Error in binary search float!");
+  }
+
+  return first;
+}
+
diff --git a/openair2/RRC/LTE/L2_interface.c b/openair2/RRC/LTE/L2_interface.c
index 4265a841e91741bfc7c2fda4edee37dd97a9b9f7..5929ac6689a6e19710370ce97b9a0a2efbe1a8b5 100644
--- a/openair2/RRC/LTE/L2_interface.c
+++ b/openair2/RRC/LTE/L2_interface.c
@@ -231,6 +231,10 @@ mac_rrc_data_ind(
   const uint8_t        *sduP,
   const sdu_size_t      sdu_lenP,
   const uint8_t         mbsfn_sync_areaP
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+  , const boolean_t		brOption
+#endif
+
 )
 //--------------------------------------------------------------------------
 {
@@ -247,8 +251,9 @@ mac_rrc_data_ind(
   if((srb_idP & RAB_OFFSET) == CCCH) {
     Srb_info = &RC.rrc[module_idP]->carrier[CC_id].Srb0;
     LOG_D(RRC,"[eNB %d] Received SDU for CCCH on SRB %d\n",module_idP,Srb_info->Srb_id);
-
-    //    msg("\n******INST %d Srb_info %p, Srb_id=%d****\n\n",Mod_id,Srb_info,Srb_info->Srb_id);
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+    ctxt.brOption = brOption;
+#endif    
     if (sdu_lenP > 0) {
       memcpy(Srb_info->Rx_buffer.Payload,sduP,sdu_lenP);
       Srb_info->Rx_buffer.payload_size = sdu_lenP;
diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg.c b/openair2/RRC/LTE/MESSAGES/asn1_msg.c
index 6d831741c2292481e0589cf84f0dd44c2f4a8d75..0bb11fa03761ccdb819633609c627a664274af51 100644
--- a/openair2/RRC/LTE/MESSAGES/asn1_msg.c
+++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.c
@@ -20,13 +20,13 @@
  */
 
 /*! \file asn1_msg.c
-* \brief primitives to build the asn1 messages
-* \author Raymond Knopp and Navid Nikaein
-* \date 2011
-* \version 1.0
-* \company Eurecom
-* \email: raymond.knopp@eurecom.fr and  navid.nikaein@eurecom.fr
-*/
+ * \brief primitives to build the asn1 messages
+ * \author Raymond Knopp and Navid Nikaein
+ * \date 2011
+ * \version 1.0
+ * \company Eurecom
+ * \email: raymond.knopp@eurecom.fr and  navid.nikaein@eurecom.fr
+ */
 
 #include <stdio.h>
 #include <sys/types.h>
@@ -65,7 +65,10 @@
 #include "LTE_MasterInformationBlock.h"
 #include "LTE_SystemInformation.h"
 
+
 #include "LTE_SystemInformationBlockType1.h"
+#include "LTE_SystemInformationBlockType1-BR-r13.h"
+
 
 #include "LTE_SIB-Type.h"
 
@@ -105,12 +108,12 @@ extern RAN_CONTEXT_t RC;
 
 uint16_t two_tier_hexagonal_cellIds[7] = {0,1,2,4,5,7,8};
 uint16_t two_tier_hexagonal_adjacent_cellIds[7][6] = {{1,2,4,5,7,8},    // CellId 0
-  {11,18,2,0,8,15}, // CellId 1
-  {18,13,3,4,0,1},  // CellId 2
-  {2,3,14,6,5,0},   // CellId 4
-  {0,4,6,16,9,7},   // CellId 5
-  {8,0,5,9,17,12},  // CellId 7
-  {15,1,0,7,12,10}
+						      {11,18,2,0,8,15}, // CellId 1
+						      {18,13,3,4,0,1},  // CellId 2
+						      {2,3,14,6,5,0},   // CellId 4
+						      {0,4,6,16,9,7},   // CellId 5
+						      {8,0,5,9,17,12},  // CellId 7
+						      {15,1,0,7,12,10}
 };// CellId 8
 
 /*
@@ -172,7 +175,13 @@ uint8_t get_adjacent_cell_mod_id(uint16_t phyCellId) {
   return 0xFF; //error!
 }
 
-uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich_Resource, uint32_t phich_duration, uint32_t frame) {
+
+uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich_Resource, uint32_t phich_duration, uint32_t frame
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) 
+	       , uint32_t schedulingInfoSIB1
+#endif
+	       ) {
+
   asn_enc_rval_t enc_rval;
   LTE_BCCH_BCH_Message_t *mib=&carrier->mib ;
   uint8_t sfn = (uint8_t)((frame>>2)&0xff);
@@ -228,7 +237,10 @@ uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich
 #else
   mib->message.spare.size = 1;
   mib->message.spare.bits_unused = 3;  // This makes a spare of 5 bits
-  mib->message.schedulingInfoSIB1_BR_r13 = 0; // turn off eMTC
+  mib->message.schedulingInfoSIB1_BR_r13 = schedulingInfoSIB1; // turn on/off eMTC
+  LOG_I(RRC,"[MIB] schedulingInfoSIB1 %d\n",
+	(uint32_t)mib->message.schedulingInfoSIB1_BR_r13);
+
 #endif
   enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_BCCH_BCH_Message,
                                    NULL,
@@ -305,7 +317,10 @@ uint8_t do_MIB_SL(const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index,
 
 
 uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,
-                int Mod_id,int CC_id
+		int Mod_id,int CC_id
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+                , BOOLEAN_t brOption
+#endif
 #if defined(ENABLE_ITTI)
   , RrcConfigurationReq *configuration
 #endif
@@ -321,13 +336,29 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,
   asn_enc_rval_t enc_rval;
   LTE_SchedulingInfo_t schedulingInfo;
   LTE_SIB_Type_t sib_type;
-  uint8_t *buffer                      = carrier->SIB1;
-  LTE_BCCH_DL_SCH_Message_t *bcch_message  = &carrier->siblock1;
-  LTE_SystemInformationBlockType1_t **sib1 = &carrier->sib1;
-  int i;
+
+  uint8_t *buffer;
+  LTE_BCCH_DL_SCH_Message_t *bcch_message;
+  LTE_SystemInformationBlockType1_t **sib1;
+
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+  if (brOption) {
+    buffer       = carrier->SIB1_BR;
+    bcch_message = &carrier->siblock1_BR;
+    sib1         = &carrier->sib1_BR;
+  }
+  else
+#endif
+    {
+      buffer       = carrier->SIB1;
+      bcch_message = &carrier->siblock1;
+      sib1         = &carrier->sib1;
+    }
+
   memset(bcch_message,0,sizeof(LTE_BCCH_DL_SCH_Message_t));
   bcch_message->message.present = LTE_BCCH_DL_SCH_MessageType_PR_c1;
   bcch_message->message.choice.c1.present = LTE_BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1;
+
   //  memcpy(&bcch_message.message.choice.c1.choice.systemInformationBlockType1,sib1,sizeof(SystemInformationBlockType1_t));
   *sib1 = &bcch_message->message.choice.c1.choice.systemInformationBlockType1;
   memset(PLMN_identity_info,0,num_plmn * sizeof(LTE_PLMN_IdentityInfo_t));
@@ -335,7 +366,7 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,
   memset(&sib_type,0,sizeof(LTE_SIB_Type_t));
 
   /* as per TS 36.311, up to 6 PLMN_identity_info are allowed in list -> add one by one */
-  for (i = 0; i < configuration->num_plmn; ++i) {
+  for (int i = 0; i < configuration->num_plmn; ++i) {
     PLMN_identity_info[i].plmn_Identity.mcc = CALLOC(1,sizeof(*PLMN_identity_info[i].plmn_Identity.mcc));
     memset(PLMN_identity_info[i].plmn_Identity.mcc,0,sizeof(*PLMN_identity_info[i].plmn_Identity.mcc));
     asn_set_empty(&PLMN_identity_info[i].plmn_Identity.mcc->list);//.size=0;
@@ -397,15 +428,15 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,
   (*sib1)->cellAccessRelatedInfo.trackingAreaCode.buf[0] = 0x00;
   (*sib1)->cellAccessRelatedInfo.trackingAreaCode.buf[1] = 0x01;
 #endif
-  (*sib1)->cellAccessRelatedInfo.trackingAreaCode.size=2;
-  (*sib1)->cellAccessRelatedInfo.trackingAreaCode.bits_unused=0;
+  (*sib1)->cellAccessRelatedInfo.trackingAreaCode.size = 2;
+  (*sib1)->cellAccessRelatedInfo.trackingAreaCode.bits_unused = 0;
   // 28 bits
   (*sib1)->cellAccessRelatedInfo.cellIdentity.buf = MALLOC(8);
 #if defined(ENABLE_ITTI)
   (*sib1)->cellAccessRelatedInfo.cellIdentity.buf[0] = (configuration->cell_identity >> 20) & 0xff;
   (*sib1)->cellAccessRelatedInfo.cellIdentity.buf[1] = (configuration->cell_identity >> 12) & 0xff;
-  (*sib1)->cellAccessRelatedInfo.cellIdentity.buf[2] = (configuration->cell_identity >>  4) & 0xff;
-  (*sib1)->cellAccessRelatedInfo.cellIdentity.buf[3] = (configuration->cell_identity <<  4) & 0xf0;
+  (*sib1)->cellAccessRelatedInfo.cellIdentity.buf[2] = (configuration->cell_identity >> 4) & 0xff;
+  (*sib1)->cellAccessRelatedInfo.cellIdentity.buf[3] = (configuration->cell_identity << 4) & 0xf0;
 #else
   (*sib1)->cellAccessRelatedInfo.cellIdentity.buf[0] = 0x00;
   (*sib1)->cellAccessRelatedInfo.cellIdentity.buf[1] = 0x00;
@@ -427,7 +458,7 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,
 #if defined(ENABLE_ITTI)
     configuration->eutra_band[CC_id];
 #else
-    7;
+  7;
 #endif
   schedulingInfo.si_Periodicity=LTE_SchedulingInfo__si_Periodicity_rf8;
   // This is for SIB2/3
@@ -443,17 +474,399 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,
     (*sib1)->tdd_Config =                             CALLOC(1,sizeof(struct LTE_TDD_Config));
     (*sib1)->tdd_Config->subframeAssignment =
 #if defined(ENABLE_ITTI)
-      configuration->tdd_config[CC_id];
+	configuration->tdd_config[CC_id];
 #else
-      3;
+      3; // +kogo this was frame_parms->tdd_config
 #endif
     (*sib1)->tdd_Config->specialSubframePatterns =
 #if defined(ENABLE_ITTI)
-      configuration->tdd_config_s[CC_id];
+	configuration->tdd_config_s[CC_id];
 #else
       0;
 #endif
+    }
+
+  (*sib1)->si_WindowLength = LTE_SystemInformationBlockType1__si_WindowLength_ms20;
+  (*sib1)->systemInfoValueTag = 0;
+
+
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+  (*sib1)->nonCriticalExtension = calloc(1, sizeof(LTE_SystemInformationBlockType1_v890_IEs_t));
+
+  LTE_SystemInformationBlockType1_v890_IEs_t *sib1_890 = (*sib1)->nonCriticalExtension;
+  sib1_890->lateNonCriticalExtension = NULL;
+  sib1_890->nonCriticalExtension = calloc(1, sizeof(LTE_SystemInformationBlockType1_v920_IEs_t));
+  memset(sib1_890->nonCriticalExtension, 0, sizeof(LTE_SystemInformationBlockType1_v920_IEs_t));
+
+  LTE_SystemInformationBlockType1_v920_IEs_t *sib1_920 = (*sib1_890).nonCriticalExtension;
+  sib1_920->ims_EmergencySupport_r9 = NULL; // ptr
+  sib1_920->cellSelectionInfo_v920 = NULL;
+  sib1_920->nonCriticalExtension = calloc(1, sizeof(LTE_SystemInformationBlockType1_v1130_IEs_t));
+  memset(sib1_920->nonCriticalExtension, 0, sizeof(LTE_SystemInformationBlockType1_v1130_IEs_t));
+
+  //////Rel11
+  LTE_SystemInformationBlockType1_v1130_IEs_t *sib1_1130 = sib1_920->nonCriticalExtension;
+
+  sib1_1130->tdd_Config_v1130 = NULL; // ptr
+  sib1_1130->cellSelectionInfo_v1130 = NULL; // ptr
+  sib1_1130->nonCriticalExtension = calloc(1, sizeof(LTE_SystemInformationBlockType1_v1250_IEs_t));
+  memset(sib1_1130->nonCriticalExtension, 0, sizeof(LTE_SystemInformationBlockType1_v1250_IEs_t));
+
+  ///Rel12
+  LTE_SystemInformationBlockType1_v1250_IEs_t *sib1_1250 = sib1_1130->nonCriticalExtension;
+  sib1_1250->cellAccessRelatedInfo_v1250.category0Allowed_r12 = NULL; // long*
+  sib1_1250->cellSelectionInfo_v1250 = NULL;
+  sib1_1250->freqBandIndicatorPriority_r12 = 0; // long* // FIXME
+  sib1_1250->nonCriticalExtension = NULL;
+
+  ////Rel1310
+#if defined(ENABLE_ITTI)
+  if ((configuration->schedulingInfoSIB1_BR_r13[CC_id] != 0) &&
+      (brOption==TRUE))
+  {
+      sib1_1250->nonCriticalExtension = calloc(1, sizeof(LTE_SystemInformationBlockType1_v1310_IEs_t));
+      memset(sib1_1250->nonCriticalExtension, 0, sizeof(LTE_SystemInformationBlockType1_v1310_IEs_t));
+      LTE_SystemInformationBlockType1_v1310_IEs_t *sib1_1310 = sib1_1250->nonCriticalExtension;
+
+
+      if (configuration->hyperSFN_r13[CC_id])
+      {
+          sib1_1310->hyperSFN_r13 = calloc(1, sizeof(BIT_STRING_t)); // type
+          memset(sib1_1310->hyperSFN_r13, 0, sizeof(BIT_STRING_t));
+          sib1_1310->hyperSFN_r13->buf = calloc(2, sizeof(uint8_t));
+          memmove(sib1_1310->hyperSFN_r13->buf, configuration->hyperSFN_r13[CC_id], 2 * sizeof(uint8_t));
+          sib1_1310->hyperSFN_r13->size = 2;
+          sib1_1310->hyperSFN_r13->bits_unused = 6;
+      }
+      else
+          sib1_1310->hyperSFN_r13 = NULL;
+
+      if (configuration->eDRX_Allowed_r13[CC_id])
+      {
+          sib1_1310->eDRX_Allowed_r13 = calloc(1, sizeof(long));
+          *sib1_1310->eDRX_Allowed_r13 = *configuration->eDRX_Allowed_r13[CC_id];
+      }
+      else
+          sib1_1310->eDRX_Allowed_r13 = NULL; // long*
+
+      if (configuration->cellSelectionInfoCE_r13[CC_id])
+      {
+          sib1_1310->cellSelectionInfoCE_r13 = calloc(1, sizeof(LTE_CellSelectionInfoCE_r13_t));
+          memset(sib1_1310->cellSelectionInfoCE_r13, 0, sizeof(LTE_CellSelectionInfoCE_r13_t));
+          sib1_1310->cellSelectionInfoCE_r13->q_RxLevMinCE_r13 = configuration->q_RxLevMinCE_r13[CC_id]; // (Q_RxLevMin_t) long
+          if (configuration->q_QualMinRSRQ_CE_r13[CC_id])
+          {
+              sib1_1310->cellSelectionInfoCE_r13->q_QualMinRSRQ_CE_r13 = calloc(1, sizeof(long));
+              *sib1_1310->cellSelectionInfoCE_r13->q_QualMinRSRQ_CE_r13 = *configuration->q_QualMinRSRQ_CE_r13[CC_id];
+          }
+          else
+              sib1_1310->cellSelectionInfoCE_r13->q_QualMinRSRQ_CE_r13 = NULL;
+      }
+      else
+          sib1_1310->cellSelectionInfoCE_r13 = NULL;
+
+      if (configuration->bandwidthReducedAccessRelatedInfo_r13[CC_id])
+      {
+
+
+          sib1_1310->bandwidthReducedAccessRelatedInfo_r13
+                  = calloc(1, sizeof(struct LTE_SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13));
+
+          LOG_I(RRC,"Allocating memory for BR access of SI (%p)\n",
+                sib1_1310->bandwidthReducedAccessRelatedInfo_r13);
+
+          sib1_1310->bandwidthReducedAccessRelatedInfo_r13->si_WindowLength_BR_r13
+                  = configuration->si_WindowLength_BR_r13[CC_id]; // 0
+
+
+          sib1_1310->bandwidthReducedAccessRelatedInfo_r13->si_RepetitionPattern_r13
+                  = configuration->si_RepetitionPattern_r13[CC_id]; // 0
+
+
+
+          sib1_1310->bandwidthReducedAccessRelatedInfo_r13->schedulingInfoList_BR_r13 = calloc(1, sizeof(LTE_SchedulingInfoList_BR_r13_t));
+
+          LTE_SchedulingInfo_BR_r13_t *schedulinginfo_br_13 = calloc(1, sizeof(LTE_SchedulingInfo_BR_r13_t));
+          memset(schedulinginfo_br_13, 0, sizeof(LTE_SchedulingInfo_BR_r13_t));
+
+          int num_sched_info_br = configuration->scheduling_info_br_size[CC_id];
+          int index;
+          for (index = 0; index < num_sched_info_br; ++index)
+          {
+
+              schedulinginfo_br_13->si_Narrowband_r13 = configuration->si_Narrowband_r13[CC_id][index];
+              schedulinginfo_br_13->si_TBS_r13 = configuration->si_TBS_r13[CC_id][index];
+              LOG_I(RRC,"Adding (%d,%d) to scheduling_info_br_13\n",(int)schedulinginfo_br_13->si_Narrowband_r13,(int)schedulinginfo_br_13->si_TBS_r13);
+              ASN_SEQUENCE_ADD(&sib1_1310->bandwidthReducedAccessRelatedInfo_r13->schedulingInfoList_BR_r13->list, schedulinginfo_br_13);
+          }
+
+
+          if (configuration->fdd_DownlinkOrTddSubframeBitmapBR_r13[CC_id])
+          {
+              sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13
+                  = calloc(1, sizeof(struct LTE_SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__fdd_DownlinkOrTddSubframeBitmapBR_r13));
+              memset(sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13, 0,
+                 sizeof(sizeof(struct LTE_SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__fdd_DownlinkOrTddSubframeBitmapBR_r13)));
+
+              if (*configuration->fdd_DownlinkOrTddSubframeBitmapBR_r13[CC_id])
+              {
+                  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13->present
+                         = LTE_SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__fdd_DownlinkOrTddSubframeBitmapBR_r13_PR_subframePattern10_r13;
+
+                  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13->choice.subframePattern10_r13.buf = calloc(2, sizeof(uint8_t));
+                  memmove(sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13->choice.subframePattern10_r13.buf, &configuration->fdd_DownlinkOrTddSubframeBitmapBR_val_r13[CC_id], 2 * sizeof(uint8_t));
+                  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13->choice.subframePattern10_r13.size = 2;
+                  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13->choice.subframePattern10_r13.bits_unused = 6;
+              }
+              else
+              {
+                  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13->present
+                        = LTE_SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__fdd_DownlinkOrTddSubframeBitmapBR_r13_PR_subframePattern40_r13;
+
+                  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13->choice.subframePattern40_r13.buf = calloc(5, sizeof(uint8_t));
+//                  memmove(sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13->choice.subframePattern40_r13.buf, &configuration->fdd_DownlinkOrTddSubframeBitmapBR_val_r13[CC_id], 5 * sizeof(uint8_t));
+                  int bm_index;
+                  for (bm_index = 0; bm_index < 5; bm_index++)
+                  {
+                      sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13->choice.subframePattern40_r13.buf[bm_index] = 0xFF;
+                  }
+                  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13->choice.subframePattern40_r13.size = 5;
+                  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13->choice.subframePattern40_r13.bits_unused = 0;
+              }
+
+          }
+          else
+          {
+              sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13 = NULL;
+          }
+
+          if (configuration->fdd_UplinkSubframeBitmapBR_r13[CC_id])
+          {
+              sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_UplinkSubframeBitmapBR_r13 = calloc(1, sizeof(BIT_STRING_t));
+              memset(sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_UplinkSubframeBitmapBR_r13, 0, sizeof(BIT_STRING_t));
+              sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_UplinkSubframeBitmapBR_r13->buf = calloc(2, sizeof(uint8_t));
+              memmove(sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_UplinkSubframeBitmapBR_r13->buf, configuration->fdd_UplinkSubframeBitmapBR_r13[CC_id],
+                  2 * sizeof(uint8_t));
+             sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_UplinkSubframeBitmapBR_r13->size = 2;
+             sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_UplinkSubframeBitmapBR_r13->bits_unused = 6;
+          }
+          else
+          {
+              sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_UplinkSubframeBitmapBR_r13 = NULL; 
+          }
+
+
+          sib1_1310->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13 = configuration->startSymbolBR_r13[CC_id];
+          sib1_1310->bandwidthReducedAccessRelatedInfo_r13->si_HoppingConfigCommon_r13
+                  = configuration->si_HoppingConfigCommon_r13[CC_id];
+
+          if (configuration->si_ValidityTime_r13[CC_id])
+          {
+              sib1_1310->bandwidthReducedAccessRelatedInfo_r13->si_ValidityTime_r13 = calloc(1, sizeof(long));
+              memset(sib1_1310->bandwidthReducedAccessRelatedInfo_r13->si_ValidityTime_r13, 0, sizeof(long));
+              *sib1_1310->bandwidthReducedAccessRelatedInfo_r13->si_ValidityTime_r13 = *configuration->si_ValidityTime_r13[CC_id];
+
+          }
+          else
+          {
+              sib1_1310->bandwidthReducedAccessRelatedInfo_r13->si_ValidityTime_r13 = NULL;
+          }
+
+
+          LTE_SystemInfoValueTagSI_r13_t *systemInfoValueTagSi_r13;
+          int num_system_info_value_tag = configuration->system_info_value_tag_SI_size[CC_id];
+          if (num_system_info_value_tag > 0)
+          {
+              sib1_1310->bandwidthReducedAccessRelatedInfo_r13->systemInfoValueTagList_r13 = calloc(1, sizeof(LTE_SystemInfoValueTagList_r13_t));
+              for (index = 0; index < num_system_info_value_tag; ++index)
+              {
+                  systemInfoValueTagSi_r13 = CALLOC(1, sizeof(LTE_SystemInfoValueTagSI_r13_t));
+                  if (configuration->systemInfoValueTagSi_r13[CC_id][index])
+                  {
+                      *systemInfoValueTagSi_r13 = configuration->systemInfoValueTagSi_r13[CC_id][index];
+                  }
+                  else
+                  {
+                      *systemInfoValueTagSi_r13 = 0;
+                  }
+                  ASN_SEQUENCE_ADD(&sib1_1310->bandwidthReducedAccessRelatedInfo_r13->systemInfoValueTagList_r13->list, systemInfoValueTagSi_r13);
+              }
+
+          }
+          else
+          {
+              sib1_1310->bandwidthReducedAccessRelatedInfo_r13->systemInfoValueTagList_r13 = NULL;
+          }
+
+      }
+      else
+      {
+          sib1_1310->bandwidthReducedAccessRelatedInfo_r13 = NULL;
+      }
+
+      sib1_1310->nonCriticalExtension = calloc(1, sizeof(LTE_SystemInformationBlockType1_v1320_IEs_t));
+      memset(sib1_1310->nonCriticalExtension, 0, sizeof(LTE_SystemInformationBlockType1_v1320_IEs_t));
+
+      /////Rel1320
+      LTE_SystemInformationBlockType1_v1320_IEs_t *sib1_1320 = sib1_1310->nonCriticalExtension;
+
+
+
+      if (configuration->freqHoppingParametersDL_r13[CC_id])
+      {
+          sib1_1320->freqHoppingParametersDL_r13 = calloc(1, sizeof(struct LTE_SystemInformationBlockType1_v1320_IEs__freqHoppingParametersDL_r13));
+          memset(sib1_1320->freqHoppingParametersDL_r13, 0, sizeof(struct LTE_SystemInformationBlockType1_v1320_IEs__freqHoppingParametersDL_r13));
+
+
+          if (configuration->mpdcch_pdsch_HoppingNB_r13[CC_id])
+          {
+              sib1_1320->freqHoppingParametersDL_r13->mpdcch_pdsch_HoppingNB_r13 = calloc(1, sizeof(long));
+              *sib1_1320->freqHoppingParametersDL_r13->mpdcch_pdsch_HoppingNB_r13 = *configuration->mpdcch_pdsch_HoppingNB_r13[CC_id];
+          }
+          else
+              sib1_1320->freqHoppingParametersDL_r13->mpdcch_pdsch_HoppingNB_r13 = NULL;
+
+          sib1_1320->freqHoppingParametersDL_r13->interval_DLHoppingConfigCommonModeA_r13 = calloc(1, sizeof(struct LTE_SystemInformationBlockType1_v1320_IEs__freqHoppingParametersDL_r13__interval_DLHoppingConfigCommonModeA_r13));
+          memset(sib1_1320->freqHoppingParametersDL_r13->interval_DLHoppingConfigCommonModeA_r13, 0, sizeof(struct LTE_SystemInformationBlockType1_v1320_IEs__freqHoppingParametersDL_r13__interval_DLHoppingConfigCommonModeA_r13));
+
+          if (configuration->interval_DLHoppingConfigCommonModeA_r13[CC_id])
+          {
+              sib1_1320->freqHoppingParametersDL_r13->interval_DLHoppingConfigCommonModeA_r13->present = LTE_SystemInformationBlockType1_v1320_IEs__freqHoppingParametersDL_r13__interval_DLHoppingConfigCommonModeA_r13_PR_interval_FDD_r13;
+              sib1_1320->freqHoppingParametersDL_r13->interval_DLHoppingConfigCommonModeA_r13->choice.interval_FDD_r13 = configuration->interval_DLHoppingConfigCommonModeA_r13_val[CC_id];
+          }
+          else
+          {
+              sib1_1320->freqHoppingParametersDL_r13->interval_DLHoppingConfigCommonModeA_r13->present = LTE_SystemInformationBlockType1_v1320_IEs__freqHoppingParametersDL_r13__interval_DLHoppingConfigCommonModeA_r13_PR_interval_TDD_r13;
+              sib1_1320->freqHoppingParametersDL_r13->interval_DLHoppingConfigCommonModeA_r13->choice.interval_TDD_r13 = configuration->interval_DLHoppingConfigCommonModeA_r13_val[CC_id];
+          }
+
+          sib1_1320->freqHoppingParametersDL_r13->interval_DLHoppingConfigCommonModeB_r13 = calloc(1, sizeof(struct LTE_SystemInformationBlockType1_v1320_IEs__freqHoppingParametersDL_r13__interval_DLHoppingConfigCommonModeB_r13));
+          memset(sib1_1320->freqHoppingParametersDL_r13->interval_DLHoppingConfigCommonModeB_r13, 0, sizeof(struct LTE_SystemInformationBlockType1_v1320_IEs__freqHoppingParametersDL_r13__interval_DLHoppingConfigCommonModeB_r13));
+
+          if (configuration->interval_DLHoppingConfigCommonModeB_r13[CC_id])
+          {
+              sib1_1320->freqHoppingParametersDL_r13->interval_DLHoppingConfigCommonModeB_r13->present = LTE_SystemInformationBlockType1_v1320_IEs__freqHoppingParametersDL_r13__interval_DLHoppingConfigCommonModeB_r13_PR_interval_FDD_r13;
+              sib1_1320->freqHoppingParametersDL_r13->interval_DLHoppingConfigCommonModeB_r13->choice.interval_FDD_r13 = configuration->interval_DLHoppingConfigCommonModeB_r13_val[CC_id];
+          }
+          else
+          {
+              sib1_1320->freqHoppingParametersDL_r13->interval_DLHoppingConfigCommonModeB_r13->present = LTE_SystemInformationBlockType1_v1320_IEs__freqHoppingParametersDL_r13__interval_DLHoppingConfigCommonModeB_r13_PR_interval_TDD_r13;
+              sib1_1320->freqHoppingParametersDL_r13->interval_DLHoppingConfigCommonModeB_r13->choice.interval_TDD_r13 = configuration->interval_DLHoppingConfigCommonModeB_r13_val[CC_id];
+          }
+
+          if (configuration->mpdcch_pdsch_HoppingOffset_r13[CC_id])
+          {
+
+              sib1_1320->freqHoppingParametersDL_r13->mpdcch_pdsch_HoppingOffset_r13 = calloc(1, sizeof(long));
+              *sib1_1320->freqHoppingParametersDL_r13->mpdcch_pdsch_HoppingOffset_r13 = *configuration->mpdcch_pdsch_HoppingOffset_r13[CC_id];
+          }
+          else
+              sib1_1320->freqHoppingParametersDL_r13->mpdcch_pdsch_HoppingOffset_r13 = NULL;
+
+      }
+      else
+          sib1_1320->freqHoppingParametersDL_r13 = NULL;
+
+      sib1_1320->nonCriticalExtension = NULL;
   }
+#else
+  sib1_1250->nonCriticalExtension = calloc(1, sizeof(LTE_SystemInformationBlockType1_v1310_IEs_t));
+  memset(sib1_1250->nonCriticalExtension, 0, sizeof(LTE_SystemInformationBlockType1_v1310_IEs_t));
+  SystemInformationBlockType1_v1310_IEs_t *sib1_1310 = sib1_1250->nonCriticalExtension;
+
+  sib1_1310->hyperSFN_r13 = calloc(1, sizeof(BIT_STRING_t)); // type
+  memset(sib1_1310->hyperSFN_r13, 0, sizeof(BIT_STRING_t));
+  sib1_1310->hyperSFN_r13->buf = calloc(2, sizeof(uint8_t));
+  memset(sib1_1310->hyperSFN_r13->buf, 0, 2*sizeof(uint8_t));
+  sib1_1310->hyperSFN_r13->size = 2;
+  sib1_1310->hyperSFN_r13->bits_unused = 6;
+
+  sib1_1310->eDRX_Allowed_r13 = NULL; // long*
+  sib1_1310->cellSelectionInfoCE_r13 = calloc(1, sizeof(LTE_CellSelectionInfoCE_r13_t));
+  memset(sib1_1310->cellSelectionInfoCE_r13, 0, sizeof(LTE_CellSelectionInfoCE_r13_t));
+  sib1_1310->cellSelectionInfoCE_r13->q_RxLevMinCE_r13 = -70; // (Q_RxLevMin_t) long
+  sib1_1310->cellSelectionInfoCE_r13->q_QualMinRSRQ_CE_r13 = NULL; // (Q_RxLevMin_t) *long
+
+  sib1_1310->bandwidthReducedAccessRelatedInfo_r13
+    = calloc(1, sizeof(struct LTE_SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13));
+
+  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->si_WindowLength_BR_r13
+    = LTE_SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_WindowLength_BR_r13_ms20; // 0
+
+
+  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->si_RepetitionPattern_r13
+    = LTE_SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_RepetitionPattern_r13_everyRF; // 0
+
+  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->schedulingInfoList_BR_r13 = calloc(1, sizeof(LTE_SchedulingInfoList_BR_r13_t));
+  SchedulingInfo_BR_r13_t *schedulinginfo_br_13 = calloc(1, sizeof(LTE_SchedulingInfo_BR_r13_t));
+  memset(schedulinginfo_br_13, 0, sizeof(LTE_SchedulingInfo_BR_r13_t));
+  schedulinginfo_br_13->si_Narrowband_r13 = 1;
+  schedulinginfo_br_13->si_TBS_r13 = LTE_SchedulingInfo_BR_r13__si_TBS_r13_b152;
+  ASN_SEQUENCE_ADD(&sib1_1310->bandwidthReducedAccessRelatedInfo_r13->schedulingInfoList_BR_r13->list, schedulinginfo_br_13);
+
+  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13
+    = calloc(1, sizeof(struct LTE_SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__fdd_DownlinkOrTddSubframeBitmapBR_r13));
+  memset(sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13, 0,
+	 sizeof(sizeof(struct LTE_SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__fdd_DownlinkOrTddSubframeBitmapBR_r13)));
+
+  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13->present
+    = LTE_SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__fdd_DownlinkOrTddSubframeBitmapBR_r13_PR_subframePattern10_r13;
+  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13->choice.subframePattern10_r13.buf = calloc(2, sizeof(uint8_t));
+  memset(sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13->choice.subframePattern10_r13.buf, 0, 2 * sizeof(uint8_t));
+  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13->choice.subframePattern10_r13.size = 2;
+  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13->choice.subframePattern10_r13.bits_unused = 6;
+
+  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_UplinkSubframeBitmapBR_r13 = calloc(1, sizeof(BIT_STRING_t));
+  memset(sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_UplinkSubframeBitmapBR_r13, 0, sizeof(BIT_STRING_t));
+  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_UplinkSubframeBitmapBR_r13->buf = calloc(2, sizeof(uint8_t));
+  memset(sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_UplinkSubframeBitmapBR_r13->buf, 0,
+	 2 * sizeof(uint8_t));
+  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_UplinkSubframeBitmapBR_r13->size = 2;
+  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_UplinkSubframeBitmapBR_r13->bits_unused = 6;
+  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13 = 1;
+  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->si_HoppingConfigCommon_r13
+    = LTE_SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_HoppingConfigCommon_r13_on;
+
+  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->si_ValidityTime_r13 = calloc(1, sizeof(long));
+  memset(sib1_1310->bandwidthReducedAccessRelatedInfo_r13->si_ValidityTime_r13, 0, sizeof(long));
+  *sib1_1310->bandwidthReducedAccessRelatedInfo_r13->si_ValidityTime_r13
+    = LTE_SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__si_ValidityTime_r13_true;
+
+
+  sib1_1310->bandwidthReducedAccessRelatedInfo_r13->systemInfoValueTagList_r13 = calloc(1, sizeof(LTE_SystemInfoValueTagList_r13_t));
+  LTE_SystemInfoValueTagSI_r13_t *systemInfoValueTagSi_r13 = CALLOC(1, sizeof(LTE_SystemInfoValueTagSI_r13_t));
+  *systemInfoValueTagSi_r13 = 0;
+  ASN_SEQUENCE_ADD(&sib1_1310->bandwidthReducedAccessRelatedInfo_r13->systemInfoValueTagList_r13->list, systemInfoValueTagSi_r13);
+
+  sib1_1310->nonCriticalExtension = calloc(1, sizeof(LTE_SystemInformationBlockType1_v1320_IEs_t));
+  memset(sib1_1310->nonCriticalExtension, 0, sizeof(LTE_SystemInformationBlockType1_v1320_IEs_t));
+
+  /////Rel1320
+  LTE_SystemInformationBlockType1_v1320_IEs_t *sib1_1320 = sib1_1310->nonCriticalExtension;
+  sib1_1320->freqHoppingParametersDL_r13 = calloc(1, sizeof(struct LTE_SystemInformationBlockType1_v1320_IEs__freqHoppingParametersDL_r13));
+  memset(sib1_1320->freqHoppingParametersDL_r13, 0, sizeof(struct LTE_SystemInformationBlockType1_v1320_IEs__freqHoppingParametersDL_r13));
+
+  sib1_1320->freqHoppingParametersDL_r13->mpdcch_pdsch_HoppingNB_r13 = calloc(1, sizeof(long));
+  *sib1_1320->freqHoppingParametersDL_r13->mpdcch_pdsch_HoppingNB_r13 = LTE_SystemInformationBlockType1_v1320_IEs__freqHoppingParametersDL_r13__mpdcch_pdsch_HoppingNB_r13_nb2;
+
+
+  sib1_1320->freqHoppingParametersDL_r13->interval_DLHoppingConfigCommonModeA_r13 = calloc(1, sizeof(struct LTE_SystemInformationBlockType1_v1320_IEs__freqHoppingParametersDL_r13__interval_DLHoppingConfigCommonModeA_r13));
+  memset(sib1_1320->freqHoppingParametersDL_r13->interval_DLHoppingConfigCommonModeA_r13, 0, sizeof(struct LTE_SystemInformationBlockType1_v1320_IEs__freqHoppingParametersDL_r13__interval_DLHoppingConfigCommonModeA_r13));
+  sib1_1320->freqHoppingParametersDL_r13->interval_DLHoppingConfigCommonModeA_r13->present = LTE_SystemInformationBlockType1_v1320_IEs__freqHoppingParametersDL_r13__interval_DLHoppingConfigCommonModeA_r13_PR_interval_FDD_r13;
+  sib1_1320->freqHoppingParametersDL_r13->interval_DLHoppingConfigCommonModeA_r13->choice.interval_FDD_r13 = LTE_SystemInformationBlockType1_v1320_IEs__freqHoppingParametersDL_r13__interval_DLHoppingConfigCommonModeA_r13__interval_FDD_r13_int1;
+
+  sib1_1320->freqHoppingParametersDL_r13->interval_DLHoppingConfigCommonModeB_r13 = calloc(1, sizeof(struct LTE_SystemInformationBlockType1_v1320_IEs__freqHoppingParametersDL_r13__interval_DLHoppingConfigCommonModeB_r13));
+  memset(sib1_1320->freqHoppingParametersDL_r13->interval_DLHoppingConfigCommonModeB_r13, 0, sizeof(struct LTE_SystemInformationBlockType1_v1320_IEs__freqHoppingParametersDL_r13__interval_DLHoppingConfigCommonModeB_r13));
+  sib1_1320->freqHoppingParametersDL_r13->interval_DLHoppingConfigCommonModeB_r13->present = LTE_SystemInformationBlockType1_v1320_IEs__freqHoppingParametersDL_r13__interval_DLHoppingConfigCommonModeB_r13_PR_interval_FDD_r13;
+  sib1_1320->freqHoppingParametersDL_r13->interval_DLHoppingConfigCommonModeB_r13->choice.interval_FDD_r13 = LTE_SystemInformationBlockType1_v1320_IEs__freqHoppingParametersDL_r13__interval_DLHoppingConfigCommonModeB_r13__interval_FDD_r13_int2;
+
+
+  sib1_1320->freqHoppingParametersDL_r13->mpdcch_pdsch_HoppingOffset_r13 = calloc(1, sizeof(long));
+  *sib1_1320->freqHoppingParametersDL_r13->mpdcch_pdsch_HoppingOffset_r13 = 1;
+
+  sib1_1320->nonCriticalExtension = NULL;
+#endif
+#endif
 
   (*sib1)->si_WindowLength=LTE_SystemInformationBlockType1__si_WindowLength_ms20;
   (*sib1)->systemInfoValueTag=0;
@@ -479,16 +892,24 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,
   return((enc_rval.encoded+7)/8);
 }
 
+
+
+
+
 uint8_t do_SIB23(uint8_t Mod_id,
 
-                 int CC_id
+		 int CC_id
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+		 , BOOLEAN_t brOption
+#endif
 #if defined(ENABLE_ITTI)
-  , RrcConfigurationReq *configuration
+		 , RrcConfigurationReq *configuration
 #endif
-                ) {
+		 ) {
   struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member *sib2_part,*sib3_part;
 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
-  //TTN - for D2D
+
+  int eMTC_configured=configuration->eMTC_configured;
   struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member *sib18_part, *sib19_part, *sib21_part;
   LTE_SL_CommRxPoolList_r12_t *SL_CommRxPoolList; //for SIB18
   struct LTE_SL_CommResourcePool_r12 *SL_CommResourcePool; //for SIB18
@@ -499,19 +920,37 @@ uint8_t do_SIB23(uint8_t Mod_id,
   //struct SL_V2X_ConfigCommon_r14 *SL_V2X_ConfigCommon;
 #endif
 #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
-  struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member *sib13_part;
+  struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member *sib13_part=NULL;
   LTE_MBSFN_SubframeConfigList_t *MBSFNSubframeConfigList;
   LTE_MBSFN_AreaInfoList_r9_t *MBSFNArea_list;
   struct LTE_MBSFN_AreaInfo_r9 *MBSFN_Area1, *MBSFN_Area2;
 #endif
   asn_enc_rval_t enc_rval;
-  uint8_t                           *buffer       = RC.rrc[Mod_id]->carrier[CC_id].SIB23;
-  LTE_BCCH_DL_SCH_Message_t             *bcch_message = &RC.rrc[Mod_id]->carrier[CC_id].systemInformation;
-  LTE_SystemInformationBlockType2_t     **sib2        = &RC.rrc[Mod_id]->carrier[CC_id].sib2;
-  LTE_SystemInformationBlockType3_t     **sib3        = &RC.rrc[Mod_id]->carrier[CC_id].sib3;
-#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
-  LTE_SystemInformationBlockType13_r9_t **sib13       = &RC.rrc[Mod_id]->carrier[CC_id].sib13;
-  uint8_t                           MBMS_flag     = RC.rrc[Mod_id]->carrier[CC_id].MBMS_flag;
+
+
+  LTE_BCCH_DL_SCH_Message_t         *bcch_message = &RC.rrc[Mod_id]->carrier[CC_id].systemInformation;
+  uint8_t                       *buffer;
+  LTE_SystemInformationBlockType2_t **sib2;
+  RadioResourceConfig           *rrconfig;
+
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+  if (brOption) {
+    buffer   = RC.rrc[Mod_id]->carrier[CC_id].SIB23_BR;
+    sib2     = &RC.rrc[Mod_id]->carrier[CC_id].sib2_BR;
+    rrconfig = &configuration->radioresourceconfig_BR[CC_id];
+    LOG_I(RRC,"Running SIB2/3 Encoding for eMTC\n");
+  }
+  else
+#endif
+    {
+      buffer   = RC.rrc[Mod_id]->carrier[CC_id].SIB23;
+      sib2     = &RC.rrc[Mod_id]->carrier[CC_id].sib2;
+      rrconfig = &configuration->radioresourceconfig[CC_id];
+    }
+    
+  LTE_SystemInformationBlockType3_t       **sib3        = &RC.rrc[Mod_id]->carrier[CC_id].sib3;
+#if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0))
+  LTE_SystemInformationBlockType13_r9_t   **sib13       = &RC.rrc[Mod_id]->carrier[CC_id].sib13;
 #endif
 #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
   //TTN - for D2D
@@ -537,8 +976,9 @@ uint8_t do_SIB23(uint8_t Mod_id,
     exit(-1);
   }
 
+
 #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
-  LOG_I(RRC,"[eNB %d] Configuration SIB2/3, MBMS = %d\n", Mod_id, MBMS_flag);
+  LOG_I(RRC,"[eNB %d] Configuration SIB2/3, eMBMS = %d\n", Mod_id, configuration->eMBMS_configured);
 #else
   LOG_I(RRC,"[eNB %d] Configuration SIB2/3\n", Mod_id);
 #endif
@@ -552,7 +992,7 @@ uint8_t do_SIB23(uint8_t Mod_id,
   *sib3 = &sib3_part->choice.sib3;
 #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
 
-  if (MBMS_flag > 0) {
+  if ((configuration->eMBMS_configured > 0) && (brOption==FALSE)) {
     sib13_part = CALLOC(1,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
     memset(sib13_part,0,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
     sib13_part->present = LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib13_v920;
@@ -560,20 +1000,24 @@ uint8_t do_SIB23(uint8_t Mod_id,
   }
 
 #endif
-#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+  if (configuration->SL_configured > 0) {
   //TTN - for D2D
-  sib18_part = CALLOC(1,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
-  sib19_part = CALLOC(1,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
-  sib21_part = CALLOC(1,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
-  memset(sib18_part,0,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
-  memset(sib19_part,0,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
-  memset(sib21_part,0,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
-  sib18_part->present = LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib18_v1250;
-  sib19_part->present = LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib19_v1250;
-  sib21_part->present = LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib21_v1430;
-  *sib18 = &sib18_part->choice.sib18_v1250;
-  *sib19 = &sib19_part->choice.sib19_v1250;
-  *sib21 = &sib21_part->choice.sib21_v1430;
+    sib18_part = CALLOC(1,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
+    sib19_part = CALLOC(1,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
+    sib21_part = CALLOC(1,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
+    memset(sib18_part,0,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
+    memset(sib19_part,0,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
+    memset(sib21_part,0,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
+    
+    sib18_part->present = LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib18_v1250;
+    sib19_part->present = LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib19_v1250;
+    sib21_part->present = LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib21_v1430;
+    
+    *sib18 = &sib18_part->choice.sib18_v1250;
+    *sib19 = &sib19_part->choice.sib19_v1250;
+    *sib21 = &sib21_part->choice.sib21_v1430;
+  }
 #endif
   // sib2
   (*sib2)->ac_BarringInfo = NULL;
@@ -582,98 +1026,131 @@ uint8_t do_SIB23(uint8_t Mod_id,
   (*sib2)->ext2 = NULL;
 #endif
 #if defined(ENABLE_ITTI)
-  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.numberOfRA_Preambles                         = configuration->rach_numberOfRA_Preambles[CC_id];
+  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.numberOfRA_Preambles                         = rrconfig->rach_numberOfRA_Preambles;
   (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig                        = NULL;
 
-  if (configuration->rach_preamblesGroupAConfig[CC_id]) {
+  if (rrconfig->rach_preamblesGroupAConfig) {
     (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig
       = CALLOC(1,sizeof(struct LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig));
     (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig->sizeOfRA_PreamblesGroupA
-      = configuration->rach_sizeOfRA_PreamblesGroupA[CC_id];
+      = rrconfig->rach_sizeOfRA_PreamblesGroupA;
     (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig->messageSizeGroupA
-      = configuration->rach_messageSizeGroupA[CC_id];
+      = rrconfig->rach_messageSizeGroupA;
     (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig->messagePowerOffsetGroupB
-      = configuration->rach_messagePowerOffsetGroupB[CC_id];
+      = rrconfig->rach_messagePowerOffsetGroupB;
+  }
+
+  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.powerRampingStep                   = rrconfig->rach_powerRampingStep;
+  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.preambleInitialReceivedTargetPower = rrconfig->rach_preambleInitialReceivedTargetPower;
+  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.preambleTransMax                       = rrconfig->rach_preambleTransMax;
+  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.ra_ResponseWindowSize                  = rrconfig->rach_raResponseWindowSize;
+  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.mac_ContentionResolutionTimer          = rrconfig->rach_macContentionResolutionTimer;
+  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.maxHARQ_Msg3Tx                                            = rrconfig->rach_maxHARQ_Msg3Tx;
+
+  if (eMTC_configured>0) {
+    (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1 = calloc(1, sizeof(struct LTE_RACH_ConfigCommon__ext1));
+    memset((*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1, 0, sizeof(struct LTE_RACH_ConfigCommon__ext1));
+    
+    if (rrconfig->preambleTransMax_CE_r13) {
+      (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->preambleTransMax_CE_r13 = calloc(1, sizeof(LTE_PreambleTransMax_t));
+      *(*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->preambleTransMax_CE_r13 = *rrconfig->preambleTransMax_CE_r13; // to be re-initialized when we find the enum
+    }
+    else (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->preambleTransMax_CE_r13 = NULL;
+  
+
+    (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->rach_CE_LevelInfoList_r13 = calloc(1, sizeof(LTE_RACH_CE_LevelInfoList_r13_t));
+    memset((*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->rach_CE_LevelInfoList_r13, 0, sizeof(LTE_RACH_CE_LevelInfoList_r13_t));
+
+    LTE_RACH_CE_LevelInfo_r13_t *rach_ce_levelinfo_r13;
+    int num_rach_ce_level_info = configuration->rach_CE_LevelInfoList_r13_size[CC_id];
+    int index;
+    for (index = 0; index < num_rach_ce_level_info; ++index) {
+      rach_ce_levelinfo_r13 = calloc(1, sizeof(LTE_RACH_CE_LevelInfo_r13_t));
+      if (configuration->rach_CE_LevelInfoList_r13_size[CC_id]) {
+          rach_ce_levelinfo_r13->preambleMappingInfo_r13.firstPreamble_r13 = configuration->firstPreamble_r13[CC_id][index];
+          rach_ce_levelinfo_r13->preambleMappingInfo_r13.lastPreamble_r13  = configuration->lastPreamble_r13[CC_id][index];
+          rach_ce_levelinfo_r13->ra_ResponseWindowSize_r13                 = configuration->ra_ResponseWindowSize_r13[CC_id][index];
+          rach_ce_levelinfo_r13->mac_ContentionResolutionTimer_r13         = configuration->mac_ContentionResolutionTimer_r13[CC_id][index];
+          rach_ce_levelinfo_r13->rar_HoppingConfig_r13                     = configuration->rar_HoppingConfig_r13[CC_id][index];
+      }
+      else
+      {
+          rach_ce_levelinfo_r13->preambleMappingInfo_r13.firstPreamble_r13 = 0;
+          rach_ce_levelinfo_r13->preambleMappingInfo_r13.lastPreamble_r13 = 63;
+          rach_ce_levelinfo_r13->ra_ResponseWindowSize_r13 = LTE_RACH_CE_LevelInfo_r13__ra_ResponseWindowSize_r13_sf80;
+          rach_ce_levelinfo_r13->mac_ContentionResolutionTimer_r13 = LTE_RACH_CE_LevelInfo_r13__mac_ContentionResolutionTimer_r13_sf200;
+          rach_ce_levelinfo_r13->rar_HoppingConfig_r13 = LTE_RACH_CE_LevelInfo_r13__rar_HoppingConfig_r13_off;
+      }
+      ASN_SEQUENCE_ADD(&(*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->rach_CE_LevelInfoList_r13->list, rach_ce_levelinfo_r13);
+    }
   }
 
-  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.powerRampingStep                   = configuration->rach_powerRampingStep[CC_id];
-  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.preambleInitialReceivedTargetPower =
-    configuration->rach_preambleInitialReceivedTargetPower[CC_id];
-  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.preambleTransMax                       = configuration->rach_preambleTransMax[CC_id];
-  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.ra_ResponseWindowSize                  = configuration->rach_raResponseWindowSize[CC_id];
-  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.mac_ContentionResolutionTimer          =
-    configuration->rach_macContentionResolutionTimer[CC_id];
-  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.maxHARQ_Msg3Tx                                            = configuration->rach_maxHARQ_Msg3Tx[CC_id];
+
   // BCCH-Config
   (*sib2)->radioResourceConfigCommon.bcch_Config.modificationPeriodCoeff
-    = configuration->bcch_modificationPeriodCoeff[CC_id];
+    = rrconfig->bcch_modificationPeriodCoeff;
   // PCCH-Config
   (*sib2)->radioResourceConfigCommon.pcch_Config.defaultPagingCycle
-    = configuration->pcch_defaultPagingCycle[CC_id];
+    = rrconfig->pcch_defaultPagingCycle;
   (*sib2)->radioResourceConfigCommon.pcch_Config.nB
-    = configuration->pcch_nB[CC_id];
-  LOG_I(RRC,"[SIB2] With ITTI. Basic config of paging cycle DRX: radio frame cycle length %x, paging occasion number %x\n",
-        (uint32_t)configuration->pcch_defaultPagingCycle[CC_id],
-        (uint32_t)configuration->pcch_nB[CC_id]);
+    = rrconfig->pcch_nB;
   // PRACH-Config
   (*sib2)->radioResourceConfigCommon.prach_Config.rootSequenceIndex
-    = configuration->prach_root[CC_id];
+    = rrconfig->prach_root;
   (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_ConfigIndex
-    = configuration->prach_config_index[CC_id];
+    = rrconfig->prach_config_index;
   (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.highSpeedFlag
-    = configuration->prach_high_speed[CC_id];
+    = rrconfig->prach_high_speed;
   (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig
-    = configuration->prach_zero_correlation[CC_id];
+    = rrconfig->prach_zero_correlation;
   (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_FreqOffset
-    = configuration->prach_freq_offset[CC_id];
+    = rrconfig->prach_freq_offset;
   // PDSCH-Config
   (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.referenceSignalPower
-    = configuration->pdsch_referenceSignalPower[CC_id];
+    = rrconfig->pdsch_referenceSignalPower;
   (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.p_b
-    = configuration->pdsch_p_b[CC_id];
+    = rrconfig->pdsch_p_b;
   // PUSCH-Config
   (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.n_SB
-    = configuration->pusch_n_SB[CC_id];
+    = rrconfig->pusch_n_SB;
   (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode
-    = configuration->pusch_hoppingMode[CC_id];
+    = rrconfig->pusch_hoppingMode;
   (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset
-    = configuration->pusch_hoppingOffset[CC_id];
+    = rrconfig->pusch_hoppingOffset;
   (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.enable64QAM
-    = configuration->pusch_enable64QAM[CC_id];
+    = rrconfig->pusch_enable64QAM;
   (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled
-    = configuration->pusch_groupHoppingEnabled[CC_id];
+    = rrconfig->pusch_groupHoppingEnabled;
   (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH
-    = configuration->pusch_groupAssignment[CC_id];
+    = rrconfig->pusch_groupAssignment;
   (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled
-    = configuration->pusch_sequenceHoppingEnabled[CC_id];
+    = rrconfig->pusch_sequenceHoppingEnabled;
   (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift
-    = configuration->pusch_nDMRS1[CC_id];
+    = rrconfig->pusch_nDMRS1;
   // PUCCH-Config
   (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.deltaPUCCH_Shift
-    = configuration->pucch_delta_shift[CC_id];
+    = rrconfig->pucch_delta_shift;
   (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.nRB_CQI
-    = configuration->pucch_nRB_CQI[CC_id];
+    = rrconfig->pucch_nRB_CQI;
   (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.nCS_AN
-    = configuration->pucch_nCS_AN[CC_id];
-  //#if (LTE_RRC_VERSION < MAKE_VERSION(10, 0, 0))
+    = rrconfig->pucch_nCS_AN;
   (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.n1PUCCH_AN
-    = configuration->pucch_n1_AN[CC_id];
-  //#endif
+    = rrconfig->pucch_n1_AN;
 
   // SRS Config
-  if (configuration->srs_enable[CC_id]==1) {
+  if (rrconfig->srs_enable == 1) {
     (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.present
       = LTE_SoundingRS_UL_ConfigCommon_PR_setup;
     (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_BandwidthConfig
-      = configuration->srs_BandwidthConfig[CC_id];
+      = rrconfig->srs_BandwidthConfig;
     (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig
-      = configuration->srs_SubframeConfig[CC_id];
+      = rrconfig->srs_SubframeConfig;
     (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.ackNackSRS_SimultaneousTransmission
-      = configuration->srs_ackNackST[CC_id];
+      = rrconfig->srs_ackNackST;
 
-    if (configuration->srs_MaxUpPts[CC_id]) {
+    if (rrconfig->srs_MaxUpPts) {
       (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts
-        = CALLOC(1,sizeof(long));
+	= CALLOC(1,sizeof(long));
       *(*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts=1;
     } else {
       (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts = NULL;
@@ -688,38 +1165,292 @@ uint8_t do_SIB23(uint8_t Mod_id,
 
   // uplinkPowerControlCommon
   (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUSCH
-    = configuration->pusch_p0_Nominal[CC_id];
+    = rrconfig->pusch_p0_Nominal;
   (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUCCH
-    = configuration->pucch_p0_Nominal[CC_id];
+    = rrconfig->pucch_p0_Nominal;
   (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.alpha
-    = configuration->pusch_alpha[CC_id];
+    = rrconfig->pusch_alpha;
   (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1
-    = configuration->pucch_deltaF_Format1[CC_id];
+    = rrconfig->pucch_deltaF_Format1;
   (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1b
-    = configuration->pucch_deltaF_Format1b[CC_id];
+    = rrconfig->pucch_deltaF_Format1b;
   (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2
-    = configuration->pucch_deltaF_Format2[CC_id];
+    = rrconfig->pucch_deltaF_Format2;
   (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2a
-    = configuration->pucch_deltaF_Format2a[CC_id];
+    = rrconfig->pucch_deltaF_Format2a;
   (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2b
-    = configuration->pucch_deltaF_Format2b[CC_id];
+    = rrconfig->pucch_deltaF_Format2b;
   (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaPreambleMsg3
-    = configuration->msg3_delta_Preamble[CC_id];
+    = rrconfig->msg3_delta_Preamble;
   (*sib2)->radioResourceConfigCommon.ul_CyclicPrefixLength
-    = configuration->ul_CyclicPrefixLength[CC_id];
+    = rrconfig->ul_CyclicPrefixLength;
+
+  if (eMTC_configured>0) {
+    (*sib2)->radioResourceConfigCommon.ext4 = calloc(1, sizeof(struct LTE_RadioResourceConfigCommonSIB__ext4));
+    memset((*sib2)->radioResourceConfigCommon.ext4, 0, sizeof(struct LTE_RadioResourceConfigCommonSIB__ext4));
+    (*sib2)->radioResourceConfigCommon.ext4->bcch_Config_v1310 = NULL; //calloc(1, sizeof(BCCH_Config_v1310_t));
+    //memset((*sib2)->radioResourceConfigCommon.ext4->bcch_Config_v1310, 0, sizeof(BCCH_Config_v1310_t));
+    //(*sib2)->radioResourceConfigCommon.ext4->bcch_Config_v1310->modificationPeriodCoeff_v1310 = BCCH_Config_v1310__modificationPeriodCoeff_v1310_n64;
+
+    if (configuration->pcch_config_v1310) {
+      (*sib2)->radioResourceConfigCommon.ext4->pcch_Config_v1310 = CALLOC(1, sizeof(LTE_PCCH_Config_v1310_t));
+      (*sib2)->radioResourceConfigCommon.ext4->pcch_Config_v1310->paging_narrowBands_r13 = configuration->paging_narrowbands_r13[CC_id];
+      (*sib2)->radioResourceConfigCommon.ext4->pcch_Config_v1310->mpdcch_NumRepetition_Paging_r13 = configuration->mpdcch_numrepetition_paging_r13[CC_id];
+      if (configuration->nb_v1310[CC_id])
+      {
+          (*sib2)->radioResourceConfigCommon.ext4->pcch_Config_v1310->nB_v1310 = CALLOC(1, sizeof(long));
+          *(*sib2)->radioResourceConfigCommon.ext4->pcch_Config_v1310->nB_v1310 = *configuration->nb_v1310[CC_id];
+      }
+      else
+      {
+          (*sib2)->radioResourceConfigCommon.ext4->pcch_Config_v1310->nB_v1310 = NULL;
+      }
+    }
+    else (*sib2)->radioResourceConfigCommon.ext4->pcch_Config_v1310 = NULL;
+ 
+
+
+  
+    if (configuration->sib2_freq_hoppingParameters_r13_exists[CC_id]) {
+
+      (*sib2)->radioResourceConfigCommon.ext4->freqHoppingParameters_r13 = CALLOC(1, sizeof(LTE_FreqHoppingParameters_r13_t));
+  
+      if (configuration->sib2_interval_ULHoppingConfigCommonModeA_r13[CC_id]) {
+          (*sib2)->radioResourceConfigCommon.ext4->freqHoppingParameters_r13->interval_ULHoppingConfigCommonModeA_r13
+                  = CALLOC(1, sizeof(struct LTE_FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13));
+          if (*configuration->sib2_interval_ULHoppingConfigCommonModeA_r13[CC_id] == 0) {
+              (*sib2)->radioResourceConfigCommon.ext4->freqHoppingParameters_r13->interval_ULHoppingConfigCommonModeA_r13->present
+                      = LTE_FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13_PR_interval_FDD_r13;
+              (*sib2)->radioResourceConfigCommon.ext4->freqHoppingParameters_r13->interval_ULHoppingConfigCommonModeA_r13->choice.interval_FDD_r13
+                      = configuration->sib2_interval_ULHoppingConfigCommonModeA_r13_val[CC_id];
+
+          }
+          else
+          {
+              (*sib2)->radioResourceConfigCommon.ext4->freqHoppingParameters_r13->interval_ULHoppingConfigCommonModeA_r13->present
+                      = LTE_FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13_PR_interval_TDD_r13;
+              (*sib2)->radioResourceConfigCommon.ext4->freqHoppingParameters_r13->interval_ULHoppingConfigCommonModeA_r13->choice.interval_TDD_r13
+                      = configuration->sib2_interval_ULHoppingConfigCommonModeA_r13_val[CC_id];
+
+          }
+      }
+      else (*sib2)->radioResourceConfigCommon.ext4->freqHoppingParameters_r13->interval_ULHoppingConfigCommonModeA_r13 = NULL;
+      
+
+      if (configuration->sib2_interval_ULHoppingConfigCommonModeB_r13[CC_id]) {
+          (*sib2)->radioResourceConfigCommon.ext4->freqHoppingParameters_r13->interval_ULHoppingConfigCommonModeB_r13
+                  = CALLOC(1, sizeof(struct LTE_FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13));
+          if (*configuration->sib2_interval_ULHoppingConfigCommonModeB_r13[CC_id] == 0)  {
+              (*sib2)->radioResourceConfigCommon.ext4->freqHoppingParameters_r13->interval_ULHoppingConfigCommonModeB_r13->present
+                      = LTE_FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13_PR_interval_FDD_r13;
+              (*sib2)->radioResourceConfigCommon.ext4->freqHoppingParameters_r13->interval_ULHoppingConfigCommonModeB_r13->choice.interval_FDD_r13
+                      = configuration->sib2_interval_ULHoppingConfigCommonModeB_r13_val[CC_id];
+          }
+          else {
+              (*sib2)->radioResourceConfigCommon.ext4->freqHoppingParameters_r13->interval_ULHoppingConfigCommonModeB_r13->present
+                      = LTE_FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13_PR_interval_TDD_r13;
+              (*sib2)->radioResourceConfigCommon.ext4->freqHoppingParameters_r13->interval_ULHoppingConfigCommonModeB_r13->choice.interval_TDD_r13
+                      = configuration->sib2_interval_ULHoppingConfigCommonModeB_r13_val[CC_id];
+          }
+      }
+      else (*sib2)->radioResourceConfigCommon.ext4->freqHoppingParameters_r13->interval_ULHoppingConfigCommonModeB_r13 = NULL;     
+    }
+    else (*sib2)->radioResourceConfigCommon.ext4->freqHoppingParameters_r13 = NULL;
+  // pdsch_ConfigCommon_v1310
+    (*sib2)->radioResourceConfigCommon.ext4->pdsch_ConfigCommon_v1310 = CALLOC(1,sizeof(LTE_PDSCH_ConfigCommon_v1310_t));
+
+    if (configuration->pdsch_maxNumRepetitionCEmodeA_r13[CC_id]) {
+        (*sib2)->radioResourceConfigCommon.ext4->pdsch_ConfigCommon_v1310->pdsch_maxNumRepetitionCEmodeA_r13 = CALLOC(1, sizeof(long));
+        *(*sib2)->radioResourceConfigCommon.ext4->pdsch_ConfigCommon_v1310->pdsch_maxNumRepetitionCEmodeA_r13 = *configuration->pdsch_maxNumRepetitionCEmodeA_r13[CC_id];
+    } else {
+        (*sib2)->radioResourceConfigCommon.ext4->pdsch_ConfigCommon_v1310->pdsch_maxNumRepetitionCEmodeA_r13 = NULL;
+    }
+
+    if (configuration->pdsch_maxNumRepetitionCEmodeB_r13[CC_id]) {
+        (*sib2)->radioResourceConfigCommon.ext4->pdsch_ConfigCommon_v1310->pdsch_maxNumRepetitionCEmodeB_r13 = CALLOC(1, sizeof(long)); // check if they're really long
+      *(*sib2)->radioResourceConfigCommon.ext4->pdsch_ConfigCommon_v1310->pdsch_maxNumRepetitionCEmodeB_r13 = *configuration->pdsch_maxNumRepetitionCEmodeB_r13[CC_id];
+    } else {
+      (*sib2)->radioResourceConfigCommon.ext4->pdsch_ConfigCommon_v1310->pdsch_maxNumRepetitionCEmodeB_r13 = NULL;
+    }
+
+  //  *(*sib2)->radioResourceConfigCommon.ext4->pdsch_ConfigCommon_v1310->pdsch_maxNumRepetitionCEmodeA_r13 = 0;
+  //  (*sib2)->radioResourceConfigCommon.ext4->pdsch_ConfigCommon_v1310->pdsch_maxNumRepetitionCEmodeB_r13 = NULL;
+
+  //  pusch_ConfigCommon_v1310
+    (*sib2)->radioResourceConfigCommon.ext4->pusch_ConfigCommon_v1310 = calloc(1,sizeof(LTE_PUSCH_ConfigCommon_v1310_t));
+
+    if (configuration->pusch_maxNumRepetitionCEmodeA_r13[CC_id]) {
+        (*sib2)->radioResourceConfigCommon.ext4->pusch_ConfigCommon_v1310->pusch_maxNumRepetitionCEmodeA_r13 = calloc(1,sizeof(long));
+        *(*sib2)->radioResourceConfigCommon.ext4->pusch_ConfigCommon_v1310->pusch_maxNumRepetitionCEmodeA_r13 = *configuration->pusch_maxNumRepetitionCEmodeA_r13[CC_id];
+    } else {
+        (*sib2)->radioResourceConfigCommon.ext4->pusch_ConfigCommon_v1310->pusch_maxNumRepetitionCEmodeA_r13 = NULL;
+    }
+
+    if (configuration->pusch_maxNumRepetitionCEmodeB_r13[CC_id]) {
+        (*sib2)->radioResourceConfigCommon.ext4->pusch_ConfigCommon_v1310->pusch_maxNumRepetitionCEmodeB_r13 = CALLOC(1, sizeof(long));
+        *(*sib2)->radioResourceConfigCommon.ext4->pusch_ConfigCommon_v1310->pusch_maxNumRepetitionCEmodeB_r13 = *configuration->pusch_maxNumRepetitionCEmodeB_r13[CC_id];
+    } else {
+      (*sib2)->radioResourceConfigCommon.ext4->pusch_ConfigCommon_v1310->pusch_maxNumRepetitionCEmodeB_r13 = NULL;
+    }
+
+    if (configuration->pusch_HoppingOffset_v1310[CC_id]) {
+        (*sib2)->radioResourceConfigCommon.ext4->pusch_ConfigCommon_v1310->pusch_HoppingOffset_v1310 = CALLOC(1, sizeof(long));
+        *(*sib2)->radioResourceConfigCommon.ext4->pusch_ConfigCommon_v1310->pusch_HoppingOffset_v1310 = *configuration->pusch_HoppingOffset_v1310[CC_id];
+    } else {
+        (*sib2)->radioResourceConfigCommon.ext4->pusch_ConfigCommon_v1310->pusch_HoppingOffset_v1310 = NULL;
+    }
+
+  //  *(*sib2)->radioResourceConfigCommon.ext4->pusch_ConfigCommon_v1310->pusch_maxNumRepetitionCEmodeA_r13 = 0;
+  //  (*sib2)->radioResourceConfigCommon.ext4->pusch_ConfigCommon_v1310->pusch_maxNumRepetitionCEmodeB_r13 = NULL;
+  //  (*sib2)->radioResourceConfigCommon.ext4->pusch_ConfigCommon_v1310->pusch_HoppingOffset_v1310 = NULL;
+
+
+    if (rrconfig->prach_ConfigCommon_v1310) {
+      (*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310 = calloc(1, sizeof(LTE_PRACH_ConfigSIB_v1310_t));
+      memset((*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310, 0, sizeof(LTE_PRACH_ConfigSIB_v1310_t));
+
+      LTE_RSRP_Range_t *rsrp_range;
+      int num_rsrp_range = configuration->rsrp_range_list_size[CC_id];
+      int rsrp_index;
+      for (rsrp_index = 0; rsrp_index < num_rsrp_range; ++rsrp_index) {
+          rsrp_range = CALLOC(1, sizeof(LTE_RSRP_Range_t));
+          if (configuration->rsrp_range_list_size[CC_id]) *rsrp_range = configuration->rsrp_range[CC_id][rsrp_index];
+          else                                            *rsrp_range = 60;
+          ASN_SEQUENCE_ADD(&(*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310->rsrp_ThresholdsPrachInfoList_r13.list, rsrp_range);
+      }
+
+      (*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310->mpdcch_startSF_CSS_RA_r13 = NULL;
+
+      if (rrconfig->mpdcch_startSF_CSS_RA_r13) {
+          (*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310->mpdcch_startSF_CSS_RA_r13 = calloc(1, sizeof(struct LTE_PRACH_ConfigSIB_v1310__mpdcch_startSF_CSS_RA_r13));
+          memset((*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310->mpdcch_startSF_CSS_RA_r13, 0, sizeof(struct LTE_PRACH_ConfigSIB_v1310__mpdcch_startSF_CSS_RA_r13));
+
+          if (*rrconfig->mpdcch_startSF_CSS_RA_r13) {
+              (*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310->mpdcch_startSF_CSS_RA_r13->present = LTE_PRACH_ConfigSIB_v1310__mpdcch_startSF_CSS_RA_r13_PR_fdd_r13;
+              (*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310->mpdcch_startSF_CSS_RA_r13->choice.fdd_r13 = rrconfig->mpdcch_startSF_CSS_RA_r13_val;
+          }
+          else {
+              (*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310->mpdcch_startSF_CSS_RA_r13->present = LTE_PRACH_ConfigSIB_v1310__mpdcch_startSF_CSS_RA_r13_PR_tdd_r13;
+              (*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310->mpdcch_startSF_CSS_RA_r13->choice.tdd_r13 = rrconfig->mpdcch_startSF_CSS_RA_r13_val;
+          }
+      }
+
+      if (rrconfig->prach_HoppingOffset_r13) {
+          (*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310->prach_HoppingOffset_r13 = calloc(1, sizeof(long));
+          *(*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310->prach_HoppingOffset_r13 = *rrconfig->prach_HoppingOffset_r13;
+      }
+      else (*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310->prach_HoppingOffset_r13 = NULL;
+       
+      LTE_PRACH_ParametersCE_r13_t *prach_parametersce_r13;
+
+      int num_prach_parameters_ce = configuration->prach_parameters_list_size[CC_id];
+      int prach_parameters_index;
+      AssertFatal(num_prach_parameters_ce > 0, "PRACH CE parameter list is empty\n");
+
+      for (prach_parameters_index = 0; prach_parameters_index < num_prach_parameters_ce; ++prach_parameters_index) {
+          prach_parametersce_r13 = CALLOC(1, sizeof(LTE_PRACH_ParametersCE_r13_t));
+          prach_parametersce_r13->prach_ConfigIndex_r13 = configuration->prach_config_index[CC_id][prach_parameters_index];
+          prach_parametersce_r13->prach_FreqOffset_r13 = configuration->prach_freq_offset[CC_id][prach_parameters_index];
+
+          AssertFatal(configuration->prach_StartingSubframe_r13[CC_id][prach_parameters_index]!=NULL,
+                      "configuration->prach_StartingSubframe_r13[%d][%d] is null",
+                      (int)CC_id,(int)prach_parameters_index);
+          if (configuration->prach_StartingSubframe_r13[CC_id][prach_parameters_index]){
+              prach_parametersce_r13->prach_StartingSubframe_r13 = CALLOC(1, sizeof(long));
+              *prach_parametersce_r13->prach_StartingSubframe_r13 = *configuration->prach_StartingSubframe_r13[CC_id][prach_parameters_index];
+          }
+          else prach_parametersce_r13->prach_StartingSubframe_r13 = NULL;
+        
+
+          if (configuration->maxNumPreambleAttemptCE_r13[CC_id][prach_parameters_index]) {
+              prach_parametersce_r13->maxNumPreambleAttemptCE_r13 = CALLOC(1, sizeof(long));
+              *prach_parametersce_r13->maxNumPreambleAttemptCE_r13 = *configuration->maxNumPreambleAttemptCE_r13[CC_id][prach_parameters_index];
+          }
+          else prach_parametersce_r13->maxNumPreambleAttemptCE_r13 = NULL;
+         
+          prach_parametersce_r13->numRepetitionPerPreambleAttempt_r13 = configuration->numRepetitionPerPreambleAttempt_r13[CC_id][prach_parameters_index];
+          prach_parametersce_r13->mpdcch_NumRepetition_RA_r13 = configuration->mpdcch_NumRepetition_RA_r13[CC_id][prach_parameters_index];
+          prach_parametersce_r13->prach_HoppingConfig_r13 = configuration->prach_HoppingConfig_r13[CC_id][prach_parameters_index];
+
+          long *maxavailablenarrowband;
+          int num_narrow_bands = configuration->max_available_narrow_band_size[CC_id][prach_parameters_index];
+          int narrow_band_index;
+          for (narrow_band_index = 0; narrow_band_index < num_narrow_bands; narrow_band_index++)
+          {
+              maxavailablenarrowband = CALLOC(1, sizeof(long));
+              *maxavailablenarrowband = configuration->max_available_narrow_band[CC_id][prach_parameters_index][narrow_band_index];
+              ASN_SEQUENCE_ADD(&prach_parametersce_r13->mpdcch_NarrowbandsToMonitor_r13.list, maxavailablenarrowband);
+          }
+
+
+          prach_parametersce_r13->mpdcch_NumRepetition_RA_r13 = LTE_PRACH_ParametersCE_r13__mpdcch_NumRepetition_RA_r13_r1;
+          prach_parametersce_r13->prach_HoppingConfig_r13 = LTE_PRACH_ParametersCE_r13__prach_HoppingConfig_r13_off;
+
+
+          ASN_SEQUENCE_ADD(&(*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310->prach_ParametersListCE_r13.list, prach_parametersce_r13);
+      }
+    }
+    else (*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310 = NULL;
+  
+
+
+    (*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310 = calloc(1, sizeof(LTE_PUCCH_ConfigCommon_v1310_t));
+    memset((*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310, 0, sizeof(LTE_PUCCH_ConfigCommon_v1310_t));
+    (*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310->n1PUCCH_AN_InfoList_r13 = calloc(1, sizeof(LTE_N1PUCCH_AN_InfoList_r13_t));
+
+    int num_pucch_info_list = configuration->pucch_info_value_size[CC_id];
+    int pucch_index;
+    long *pucch_info_value;
+    for (pucch_index = 0; pucch_index <  num_pucch_info_list; ++pucch_index) {
+      pucch_info_value = CALLOC(1, sizeof(long));
+      if (configuration->pucch_info_value_size[CC_id]) *pucch_info_value = configuration->pucch_info_value[CC_id][pucch_index];
+      else                                             *pucch_info_value = 0;
+      
+      ASN_SEQUENCE_ADD(&(*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310->n1PUCCH_AN_InfoList_r13->list, pucch_info_value);
+    }
+
+    if (configuration->pucch_NumRepetitionCE_Msg4_Level0_r13[CC_id]) {
+      (*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310->pucch_NumRepetitionCE_Msg4_Level0_r13  = CALLOC(1, sizeof(long));
+      *(*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310->pucch_NumRepetitionCE_Msg4_Level0_r13 =  *configuration->pucch_NumRepetitionCE_Msg4_Level0_r13[CC_id];
+    }
+    else (*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310->pucch_NumRepetitionCE_Msg4_Level0_r13 = NULL;
+
+    if (configuration->pucch_NumRepetitionCE_Msg4_Level1_r13[CC_id]) {
+      (*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310->pucch_NumRepetitionCE_Msg4_Level1_r13  = CALLOC(1, sizeof(long));
+      *(*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310->pucch_NumRepetitionCE_Msg4_Level1_r13 =  *configuration->pucch_NumRepetitionCE_Msg4_Level1_r13[CC_id];
+    }
+    else (*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310->pucch_NumRepetitionCE_Msg4_Level1_r13 = NULL;
+  
+
+    if (configuration->pucch_NumRepetitionCE_Msg4_Level2_r13[CC_id]) {
+      (*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310->pucch_NumRepetitionCE_Msg4_Level2_r13  = CALLOC(1, sizeof(long));
+      *(*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310->pucch_NumRepetitionCE_Msg4_Level2_r13 =  *configuration->pucch_NumRepetitionCE_Msg4_Level2_r13[CC_id];
+    }
+    else (*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310->pucch_NumRepetitionCE_Msg4_Level2_r13 = NULL;
+
+    if (configuration->pucch_NumRepetitionCE_Msg4_Level3_r13[CC_id]) {
+      (*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310->pucch_NumRepetitionCE_Msg4_Level3_r13  = CALLOC(1, sizeof(long));
+      *(*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310->pucch_NumRepetitionCE_Msg4_Level3_r13 =  *configuration->pucch_NumRepetitionCE_Msg4_Level3_r13[CC_id];
+    }
+    else (*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310->pucch_NumRepetitionCE_Msg4_Level3_r13 = NULL;
+
+  } // eMTC_configured>0
+  //-----------------------------------------------------------------------------------------------------------------------------------------
+
+
   // UE Timers and Constants
   (*sib2)->ue_TimersAndConstants.t300
-    = configuration->ue_TimersAndConstants_t300[CC_id];
+    = rrconfig->ue_TimersAndConstants_t300;
   (*sib2)->ue_TimersAndConstants.t301
-    = configuration->ue_TimersAndConstants_t301[CC_id];
+    = rrconfig->ue_TimersAndConstants_t301;
   (*sib2)->ue_TimersAndConstants.t310
-    = configuration->ue_TimersAndConstants_t310[CC_id];
+    = rrconfig->ue_TimersAndConstants_t310;
   (*sib2)->ue_TimersAndConstants.n310
-    = configuration->ue_TimersAndConstants_n310[CC_id];
+    = rrconfig->ue_TimersAndConstants_n310;
   (*sib2)->ue_TimersAndConstants.t311
-    = configuration->ue_TimersAndConstants_t311[CC_id];
+    = rrconfig->ue_TimersAndConstants_t311;
   (*sib2)->ue_TimersAndConstants.n311
-    = configuration->ue_TimersAndConstants_n311[CC_id];
+    = rrconfig->ue_TimersAndConstants_n311;
 #else
   (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.numberOfRA_Preambles=LTE_RACH_ConfigCommon__preambleInfo__numberOfRA_Preambles_n64;
   (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig = NULL;
@@ -731,13 +1462,32 @@ uint8_t do_SIB23(uint8_t Mod_id,
   (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.mac_ContentionResolutionTimer=
     LTE_RACH_ConfigCommon__ra_SupervisionInfo__mac_ContentionResolutionTimer_sf48;
   (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.maxHARQ_Msg3Tx = 4;
+
+  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1 = calloc(1, sizeof(struct LTE_RACH_ConfigCommon__ext1));
+  memset((*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1, 0, sizeof(struct LTE_RACH_ConfigCommon__ext1));
+  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->preambleTransMax_CE_r13 = calloc(1, sizeof(LTE_PreambleTransMax_t));
+  *(*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->preambleTransMax_CE_r13 = LTE_PreambleTransMax_n5; // to be re-initialized when we find the enum
+  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->rach_CE_LevelInfoList_r13 = calloc(1, sizeof(LTE_RACH_CE_LevelInfoList_r13_t));
+  memset((*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->rach_CE_LevelInfoList_r13, 0, sizeof(LTE_RACH_CE_LevelInfoList_r13_t));
+
+  LTE_RACH_CE_LevelInfo_r13_t *rach_ce_levelinfo_r13 = calloc(1, sizeof(LTE_RACH_CE_LevelInfo_r13_t));
+  memset(rach_ce_levelinfo_r13, 0, sizeof(LTE_RACH_CE_LevelInfo_r13_t));
+  rach_ce_levelinfo_r13->preambleMappingInfo_r13.firstPreamble_r13 = 0;
+  rach_ce_levelinfo_r13->preambleMappingInfo_r13.lastPreamble_r13 = 63;
+  rach_ce_levelinfo_r13->ra_ResponseWindowSize_r13 = LTE_RACH_CE_LevelInfo_r13__ra_ResponseWindowSize_r13_sf80;
+  rach_ce_levelinfo_r13->mac_ContentionResolutionTimer_r13 = LTE_RACH_CE_LevelInfo_r13__mac_ContentionResolutionTimer_r13_sf200;
+  rach_ce_levelinfo_r13->rar_HoppingConfig_r13 = LTE_RACH_CE_LevelInfo_r13__rar_HoppingConfig_r13_off;
+
+  ASN_SEQUENCE_ADD(&(*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ext1->rach_CE_LevelInfoList_r13->list, rach_ce_levelinfo_r13);
+ 
   // BCCH-Config
-  (*sib2)->radioResourceConfigCommon.bcch_Config.modificationPeriodCoeff=BCCH_Config__modificationPeriodCoeff_n2;
+  (*sib2)->radioResourceConfigCommon.bcch_Config.modificationPeriodCoeff=LTE_BCCH_Config__modificationPeriodCoeff_n2;
+
   // PCCH-Config
   (*sib2)->radioResourceConfigCommon.pcch_Config.defaultPagingCycle = LTE_PCCH_Config__defaultPagingCycle_rf128;
   (*sib2)->radioResourceConfigCommon.pcch_Config.nB=LTE_PCCH_Config__nB_oneT;
   // PRACH-Config
-  (*sib2)->radioResourceConfigCommon.prach_Config.rootSequenceIndex=Mod_id;//0;//384;
+  (*sib2)->radioResourceConfigCommon.prach_Config.rootSequenceIndex = Mod_id;//0;//384;
   (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_ConfigIndex = 0;//3;
   (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.highSpeedFlag = 0;
   (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig = 1;//12;
@@ -772,12 +1522,65 @@ uint8_t do_SIB23(uint8_t Mod_id,
   (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2b=LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF0;
   (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaPreambleMsg3 = 6;
   (*sib2)->radioResourceConfigCommon.ul_CyclicPrefixLength=UL_CyclicPrefixLength_len1;
+
+  (*sib2)->radioResourceConfigCommon.ext4 = calloc(1, sizeof(struct LTE_RadioResourceConfigCommonSIB__ext4));
+  memset((*sib2)->radioResourceConfigCommon.ext4, 0, sizeof(struct LTE_RadioResourceConfigCommonSIB__ext4));
+  (*sib2)->radioResourceConfigCommon.ext4->bcch_Config_v1310 = calloc(1, sizeof(LTE_BCCH_Config_v1310_t));
+  memset((*sib2)->radioResourceConfigCommon.ext4->bcch_Config_v1310, 0, sizeof(LTE_BCCH_Config_v1310_t));
+  (*sib2)->radioResourceConfigCommon.ext4->bcch_Config_v1310->modificationPeriodCoeff_v1310 = LTE_BCCH_Config_v1310__modificationPeriodCoeff_v1310_n64;
+  (*sib2)->radioResourceConfigCommon.ext4->pcch_Config_v1310 = NULL;
+  (*sib2)->radioResourceConfigCommon.ext4->freqHoppingParameters_r13 = NULL;
+  (*sib2)->radioResourceConfigCommon.ext4->pdsch_ConfigCommon_v1310 = NULL;
+  (*sib2)->radioResourceConfigCommon.ext4->pusch_ConfigCommon_v1310 = NULL;
+  (*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310 = calloc(1, sizeof(LTE_PRACH_ConfigSIB_v1310_t));
+  memset((*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310, 0, sizeof(PRACH_ConfigSIB_v1310_t));
+
+  LTE_RSRP_Range_t rsrp_range = 60;
+  ASN_SEQUENCE_ADD(&(*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310->rsrp_ThresholdsPrachInfoList_r13.list, &rsrp_range);
+
+  (*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310->mpdcch_startSF_CSS_RA_r13 = calloc(1, sizeof(struct LTE_PRACH_ConfigSIB_v1310__mpdcch_startSF_CSS_RA_r13));
+  memset((*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310->mpdcch_startSF_CSS_RA_r13, 0, sizeof(struct LTE_PRACH_ConfigSIB_v1310__mpdcch_startSF_CSS_RA_r13));
+  (*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310->mpdcch_startSF_CSS_RA_r13->present = LTE_PRACH_ConfigSIB_v1310__mpdcch_startSF_CSS_RA_r13_PR_fdd_r13;
+  (*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310->mpdcch_startSF_CSS_RA_r13->choice.fdd_r13 = LTE_PRACH_ConfigSIB_v1310__mpdcch_startSF_CSS_RA_r13__fdd_r13_v5;
+  (*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310->prach_HoppingOffset_r13 = NULL;
+
+  LTE_PRACH_ParametersCE_r13_t *prach_parametersce_r13 = calloc(1, sizeof(LTE_PRACH_ParametersCE_r13_t));
+  memset(prach_parametersce_r13, 0, sizeof(LTE_PRACH_ParametersCE_r13_t));
+
+  prach_parametersce_r13->prach_ConfigIndex_r13 = 3;
+  prach_parametersce_r13->prach_FreqOffset_r13 = 1;
+  prach_parametersce_r13->prach_StartingSubframe_r13 = NULL;
+  prach_parametersce_r13->maxNumPreambleAttemptCE_r13 = calloc(1, sizeof(long));
+  *prach_parametersce_r13->maxNumPreambleAttemptCE_r13 = LTE_PRACH_ParametersCE_r13__maxNumPreambleAttemptCE_r13_n3;
+  prach_parametersce_r13->numRepetitionPerPreambleAttempt_r13 = LTE_PRACH_ParametersCE_r13__numRepetitionPerPreambleAttempt_r13_n1;
+
+  long maxavailablenarrowband = 2;
+  ASN_SEQUENCE_ADD(&prach_parametersce_r13->mpdcch_NarrowbandsToMonitor_r13.list, &maxavailablenarrowband);
+
+  prach_parametersce_r13->mpdcch_NumRepetition_RA_r13 = LTE_PRACH_ParametersCE_r13__mpdcch_NumRepetition_RA_r13_r1;
+  prach_parametersce_r13->prach_HoppingConfig_r13 = LTE_PRACH_ParametersCE_r13__prach_HoppingConfig_r13_off;
+  ASN_SEQUENCE_ADD(&(*sib2)->radioResourceConfigCommon.ext4->prach_ConfigCommon_v1310->prach_ParametersListCE_r13.list, prach_parametersce_r13);
+
+  (*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310 = calloc(1, sizeof(LTE_PUCCH_ConfigCommon_v1310_t));
+  memset((*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310, 0, sizeof(LTE_PUCCH_ConfigCommon_v1310_t));
+
+  (*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310->n1PUCCH_AN_InfoList_r13 = calloc(1, sizeof(LTE_N1PUCCH_AN_InfoList_r13_t));
+  long pucch_info_value1 = 0;
+  long pucch_info_value2 = 2;
+  ASN_SEQUENCE_ADD(&(*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310->n1PUCCH_AN_InfoList_r13->list, &pucch_info_value1);
+  ASN_SEQUENCE_ADD(&(*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310->n1PUCCH_AN_InfoList_r13->list, &pucch_info_value2);
+  (*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310->pucch_NumRepetitionCE_Msg4_Level0_r13 = NULL;
+  (*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310->pucch_NumRepetitionCE_Msg4_Level1_r13 = NULL;
+  (*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310->pucch_NumRepetitionCE_Msg4_Level2_r13 = NULL;
+  (*sib2)->radioResourceConfigCommon.ext4->pucch_ConfigCommon_v1310->pucch_NumRepetitionCE_Msg4_Level3_r13 = NULL;
+
   (*sib2)->ue_TimersAndConstants.t300=UE_TimersAndConstants__t300_ms1000;
   (*sib2)->ue_TimersAndConstants.t301=UE_TimersAndConstants__t301_ms1000;
   (*sib2)->ue_TimersAndConstants.t310=UE_TimersAndConstants__t310_ms1000;
   (*sib2)->ue_TimersAndConstants.n310=UE_TimersAndConstants__n310_n20;
   (*sib2)->ue_TimersAndConstants.t311=UE_TimersAndConstants__t311_ms10000;
   (*sib2)->ue_TimersAndConstants.n311=UE_TimersAndConstants__n311_n1;
+
 #endif
   (*sib2)->freqInfo.additionalSpectrumEmission = 1;
   (*sib2)->freqInfo.ul_CarrierFreq = NULL;
@@ -785,7 +1588,7 @@ uint8_t do_SIB23(uint8_t Mod_id,
   //  (*sib2)->mbsfn_SubframeConfigList = NULL;
 #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
 
-  if (MBMS_flag > 0) {
+  if (configuration->eMBMS_configured > 0) {
     LOG_I(RRC,"Adding MBSFN subframe Configuration 1 to SIB2\n");
     LTE_MBSFN_SubframeConfig_t *sib2_mbsfn_SubframeConfig1;
     (*sib2)->mbsfn_SubframeConfigList = CALLOC(1,sizeof(struct LTE_MBSFN_SubframeConfigList));
@@ -799,9 +1602,11 @@ uint8_t do_SIB23(uint8_t Mod_id,
     sib2_mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.size= 1;
     sib2_mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.bits_unused= 2;
     sib2_mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x38<<2;
+
     ASN_SEQUENCE_ADD(&MBSFNSubframeConfigList->list,sib2_mbsfn_SubframeConfig1);
 
-    if (MBMS_flag == 4 ) {
+
+    if (configuration->eMBMS_configured == 4 ) {
       LOG_I(RRC,"Adding MBSFN subframe Configuration 2 to SIB2\n");
       LTE_MBSFN_SubframeConfig_t *sib2_mbsfn_SubframeConfig2;
       sib2_mbsfn_SubframeConfig2= CALLOC(1,sizeof(*sib2_mbsfn_SubframeConfig2));
@@ -813,6 +1618,7 @@ uint8_t do_SIB23(uint8_t Mod_id,
       sib2_mbsfn_SubframeConfig2->subframeAllocation.choice.oneFrame.size= 1;
       sib2_mbsfn_SubframeConfig2->subframeAllocation.choice.oneFrame.bits_unused= 2;
       sib2_mbsfn_SubframeConfig2->subframeAllocation.choice.oneFrame.buf[0]=0x07<<2;
+
       ASN_SEQUENCE_ADD(&MBSFNSubframeConfigList->list,sib2_mbsfn_SubframeConfig2);
     }
   }
@@ -830,6 +1636,7 @@ uint8_t do_SIB23(uint8_t Mod_id,
   (*sib3)->cellReselectionServingFreqInfo.s_NonIntraSearch=NULL;
   (*sib3)->cellReselectionServingFreqInfo.threshServingLow=31;
   (*sib3)->cellReselectionServingFreqInfo.cellReselectionPriority=7;
+
   (*sib3)->intraFreqCellReselectionInfo.q_RxLevMin = -70;
   (*sib3)->intraFreqCellReselectionInfo.p_Max = NULL;
   (*sib3)->intraFreqCellReselectionInfo.s_IntraSearch = CALLOC(1,sizeof(*(*sib3)->intraFreqCellReselectionInfo.s_IntraSearch));
@@ -843,11 +1650,24 @@ uint8_t do_SIB23(uint8_t Mod_id,
   (*sib3)->intraFreqCellReselectionInfo.neighCellConfig.bits_unused = 6;
   (*sib3)->intraFreqCellReselectionInfo.t_ReselectionEUTRA = 1;
   (*sib3)->intraFreqCellReselectionInfo.t_ReselectionEUTRA_SF = (struct LTE_SpeedStateScaleFactors *)NULL;
+
+  (*sib3)->ext1 = CALLOC(1, sizeof(struct LTE_SystemInformationBlockType3__ext1));
+  (*sib3)->ext1->s_IntraSearch_v920 = CALLOC(1, sizeof(struct LTE_SystemInformationBlockType3__ext1__s_IntraSearch_v920));
+  (*sib3)->ext1->s_IntraSearch_v920->s_IntraSearchP_r9 = 31; // FIXME
+  (*sib3)->ext1->s_IntraSearch_v920->s_IntraSearchQ_r9 = 4;
+
+  (*sib3)->ext4 = CALLOC(1, sizeof(struct LTE_SystemInformationBlockType3__ext4));
+  (*sib3)->ext4->cellSelectionInfoCE_r13 = CALLOC(1, sizeof(LTE_CellSelectionInfoCE_r13_t));
+  (*sib3)->ext4->cellSelectionInfoCE_r13->q_RxLevMinCE_r13 = -70;
+  (*sib3)->ext4->cellSelectionInfoCE_r13->q_QualMinRSRQ_CE_r13 = NULL;
+  (*sib3)->ext4->t_ReselectionEUTRA_CE_r13 = CALLOC(1, sizeof(LTE_T_ReselectionEUTRA_CE_r13_t));
+  *(*sib3)->ext4->t_ReselectionEUTRA_CE_r13 = 2;
+
   // SIB13
   // fill in all elements of SIB13 if present
 #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0))
 
-  if (MBMS_flag > 0 ) {
+  if (configuration->eMBMS_configured > 0 ) {
     //  Notification for mcch change
     (*sib13)->notificationConfig_r9.notificationRepetitionCoeff_r9= LTE_MBMS_NotificationConfig_r9__notificationRepetitionCoeff_r9_n2;
     (*sib13)->notificationConfig_r9.notificationOffset_r9= 0;
@@ -872,7 +1692,7 @@ uint8_t do_SIB23(uint8_t Mod_id,
     ASN_SEQUENCE_ADD(&MBSFNArea_list->list,MBSFN_Area1);
 
     //MBSFN Area 2: currently only activated for eMBMS relaying
-    if (MBMS_flag == 4 ) {
+    if (configuration->eMBMS_configured == 4 ) {
       MBSFN_Area2= CALLOC(1, sizeof(*MBSFN_Area2));
       MBSFN_Area2->mbsfn_AreaId_r9= 2;
       MBSFN_Area2->non_MBSFNregionLength= LTE_MBSFN_AreaInfo_r9__non_MBSFNregionLength_s2;
@@ -894,280 +1714,282 @@ uint8_t do_SIB23(uint8_t Mod_id,
 
 #endif
 #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
-  //TTN - for D2D
-  // SIB18
-  //commRxPool_r12
-  (*sib18)->commConfig_r12 = CALLOC (1, sizeof(*(*sib18)->commConfig_r12));
-  SL_CommRxPoolList= &(*sib18)->commConfig_r12->commRxPool_r12;
-  memset(SL_CommRxPoolList,0,sizeof(*SL_CommRxPoolList));
-  SL_CommResourcePool = CALLOC(1, sizeof(*SL_CommResourcePool));
-  memset(SL_CommResourcePool,0,sizeof(*SL_CommResourcePool));
-  SL_CommResourcePool->sc_CP_Len_r12 = configuration->rxPool_sc_CP_Len[CC_id];
-  SL_CommResourcePool->sc_Period_r12 = configuration->rxPool_sc_Period[CC_id];
-  SL_CommResourcePool->data_CP_Len_r12  = configuration->rxPool_data_CP_Len[CC_id];
-  //sc_TF_ResourceConfig_r12
-  SL_CommResourcePool->sc_TF_ResourceConfig_r12.prb_Num_r12 = configuration->rxPool_ResourceConfig_prb_Num[CC_id];
-  SL_CommResourcePool->sc_TF_ResourceConfig_r12.prb_Start_r12 = configuration->rxPool_ResourceConfig_prb_Start[CC_id];
-  SL_CommResourcePool->sc_TF_ResourceConfig_r12.prb_End_r12 = configuration->rxPool_ResourceConfig_prb_End[CC_id];
-  SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.present = configuration->rxPool_ResourceConfig_offsetIndicator_present[CC_id];
-
-  if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.present == LTE_SL_OffsetIndicator_r12_PR_small_r12 ) {
-    SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = configuration->rxPool_ResourceConfig_offsetIndicator_choice[CC_id] ;
-  } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.present == LTE_SL_OffsetIndicator_r12_PR_large_r12 ) {
-    SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.large_r12 = configuration->rxPool_ResourceConfig_offsetIndicator_choice[CC_id] ;
-  }
-
-  SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present = configuration->rxPool_ResourceConfig_subframeBitmap_present[CC_id];
-
-  if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs4_r12) {
-    //for BS4
-    SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
-    SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf  = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
-    SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
-  } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs8_r12) {
-    //for BS8
-    SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
-    SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.buf  = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
-    SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
-  } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs12_r12) {
-    //for BS12
-    SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
-    SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.buf  = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
-    SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
-  } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs16_r12) {
-    //for BS16
-    SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
-    SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf  = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
-    SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
-  } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs30_r12) {
-    //for BS30
-    SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
-    SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.buf  = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
-    SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
-  } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs40_r12) {
-    //for BS40
-    SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
-    SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf  = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
-    SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
-  } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs42_r12) {
-    //for BS42
-    SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
-    SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.buf  = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
-    SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
-  }
-
-  //dataHoppingConfig_r12
-  SL_CommResourcePool->dataHoppingConfig_r12.hoppingParameter_r12 = 0;
-  SL_CommResourcePool->dataHoppingConfig_r12.numSubbands_r12  =  LTE_SL_HoppingConfigComm_r12__numSubbands_r12_ns1;
-  SL_CommResourcePool->dataHoppingConfig_r12.rb_Offset_r12 = 0;
-  //ue_SelectedResourceConfig_r12
-  SL_CommResourcePool->ue_SelectedResourceConfig_r12 = CALLOC (1, sizeof (*SL_CommResourcePool->ue_SelectedResourceConfig_r12));
-  SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.prb_Num_r12 = 20;
-  SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.prb_Start_r12 = 5;
-  SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.prb_End_r12 = 44;
-  SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.offsetIndicator_r12.present = LTE_SL_OffsetIndicator_r12_PR_small_r12;
-  SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = 0 ;
-  SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.present = LTE_SubframeBitmapSL_r12_PR_bs40_r12;
-  SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = 5;
-  SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf  = CALLOC(1,5);
-  SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = 0;
-  SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[0] = 0xF0;
-  SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[1] = 0xFF;
-  SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[2] = 0xFF;
-  SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[3] = 0xFF;
-  SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[4] = 0xFF;
-  //SL_CommResourcePool->ue_SelectedResourceConfig_r12->trpt_Subset_r12 = CALLOC (1, sizeof(*SL_CommResourcePool->ue_SelectedResourceConfig_r12->trpt_Subset_r12));
-  //rxParametersNCell_r12
-  SL_CommResourcePool->rxParametersNCell_r12 = CALLOC (1, sizeof (*SL_CommResourcePool->rxParametersNCell_r12));
-  SL_CommResourcePool->rxParametersNCell_r12->tdd_Config_r12 = CALLOC (1, sizeof (*SL_CommResourcePool->rxParametersNCell_r12->tdd_Config_r12));
-  SL_CommResourcePool->rxParametersNCell_r12->tdd_Config_r12->subframeAssignment = 0 ;
-  SL_CommResourcePool->rxParametersNCell_r12->tdd_Config_r12->specialSubframePatterns = 0;
-  SL_CommResourcePool->rxParametersNCell_r12->syncConfigIndex_r12 = 0;
-  //txParameters_r12
-  SL_CommResourcePool->txParameters_r12 = CALLOC (1, sizeof (*SL_CommResourcePool->txParameters_r12));
-  SL_CommResourcePool->txParameters_r12->sc_TxParameters_r12.alpha_r12 = LTE_Alpha_r12_al0;
-  SL_CommResourcePool->txParameters_r12->sc_TxParameters_r12.p0_r12 = 0;
-  SL_CommResourcePool->ext1 = NULL ;
-  //end SL_CommResourcePool
-  //add SL_CommResourcePool to SL_CommRxPoolList
-  ASN_SEQUENCE_ADD(&SL_CommRxPoolList->list,SL_CommResourcePool);
-  //end commRxPool_r12
-  //TODO:  commTxPoolNormalCommon_r12, similar to commRxPool_r12
-  //TODO: commTxPoolExceptional_r12
-  //TODO: commSyncConfig_r12
-  // may add commTxResourceUC-ReqAllowed with Ext1
-  (*sib18)->ext1 = NULL;
-  (*sib18)->lateNonCriticalExtension = NULL;
-  // end SIB18
-  // SIB19
-  // fill in all elements of SIB19 if present
-  //discConfig_r12
-  (*sib19)->discConfig_r12 = CALLOC (1, sizeof(*(*sib19)->discConfig_r12));
-  SL_DiscRxPoolList = &(*sib19)->discConfig_r12->discRxPool_r12;
-  memset(SL_DiscRxPoolList,0,sizeof(*SL_DiscRxPoolList));
-  //fill SL_DiscResourcePool
-  SL_DiscResourcePool = CALLOC(1, sizeof(*SL_DiscResourcePool));
-  SL_DiscResourcePool->cp_Len_r12 = configuration->discRxPool_cp_Len[CC_id];
-  SL_DiscResourcePool->discPeriod_r12 = configuration->discRxPool_discPeriod[CC_id];
-  //sc_TF_ResourceConfig_r12
-  SL_DiscResourcePool->numRetx_r12 = configuration->discRxPool_numRetx[CC_id];
-  SL_DiscResourcePool->numRepetition_r12 = configuration->discRxPool_numRepetition[CC_id];
-  SL_DiscResourcePool->tf_ResourceConfig_r12.prb_Num_r12 = configuration->discRxPool_ResourceConfig_prb_Num[CC_id];
-  SL_DiscResourcePool->tf_ResourceConfig_r12.prb_Start_r12 = configuration->discRxPool_ResourceConfig_prb_Start[CC_id];
-  SL_DiscResourcePool->tf_ResourceConfig_r12.prb_End_r12 = configuration->discRxPool_ResourceConfig_prb_End[CC_id];
-  SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.present = configuration->discRxPool_ResourceConfig_offsetIndicator_present[CC_id];
-
-  if (SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.present == LTE_SL_OffsetIndicator_r12_PR_small_r12 ) {
-    SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = configuration->discRxPool_ResourceConfig_offsetIndicator_choice[CC_id] ;
-  } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.present == LTE_SL_OffsetIndicator_r12_PR_large_r12 ) {
-    SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.choice.large_r12 = configuration->discRxPool_ResourceConfig_offsetIndicator_choice[CC_id] ;
-  }
-
-  SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present = configuration->discRxPool_ResourceConfig_subframeBitmap_present[CC_id];
-
-  if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs4_r12) {
-    //for BS4
-    SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
-    SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf  =  (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
-    SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
-  } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs8_r12) {
-    //for BS8
-    SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
-    SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.buf  = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
-    SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
-  } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs12_r12) {
-    //for BS12
-    SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
-    SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.buf  = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
-    SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
-  } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs16_r12) {
-    //for BS16
-    SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
-    SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf  = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
-    SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
-  } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs30_r12) {
-    //for BS30
-    SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
-    SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.buf  = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
-    SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
-  } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs40_r12) {
-    //for BS40
-    SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
-    SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf  = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
-    SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
-  } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs42_r12) {
-    //for BS42
-    SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
-    SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.buf  = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
-    SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
-  }
-
-  //add SL_DiscResourcePool to SL_DiscRxPoolList
-  ASN_SEQUENCE_ADD(&SL_DiscRxPoolList->list,SL_DiscResourcePool);
-  /*
+  if (configuration->SL_configured>0) {
+    //TTN - for D2D
+    // SIB18
+    //commRxPool_r12
+    (*sib18)->commConfig_r12 = CALLOC (1, sizeof(*(*sib18)->commConfig_r12));
+    SL_CommRxPoolList= &(*sib18)->commConfig_r12->commRxPool_r12;
+    memset(SL_CommRxPoolList,0,sizeof(*SL_CommRxPoolList));
+    SL_CommResourcePool = CALLOC(1, sizeof(*SL_CommResourcePool));
+    memset(SL_CommResourcePool,0,sizeof(*SL_CommResourcePool));
+    SL_CommResourcePool->sc_CP_Len_r12 = configuration->rxPool_sc_CP_Len[CC_id];
+    SL_CommResourcePool->sc_Period_r12 = configuration->rxPool_sc_Period[CC_id];
+    SL_CommResourcePool->data_CP_Len_r12  = configuration->rxPool_data_CP_Len[CC_id];
+    //sc_TF_ResourceConfig_r12
+    SL_CommResourcePool->sc_TF_ResourceConfig_r12.prb_Num_r12 = configuration->rxPool_ResourceConfig_prb_Num[CC_id];
+    SL_CommResourcePool->sc_TF_ResourceConfig_r12.prb_Start_r12 = configuration->rxPool_ResourceConfig_prb_Start[CC_id];
+    SL_CommResourcePool->sc_TF_ResourceConfig_r12.prb_End_r12 = configuration->rxPool_ResourceConfig_prb_End[CC_id];
+    SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.present = configuration->rxPool_ResourceConfig_offsetIndicator_present[CC_id];
+    
+    if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.present == LTE_SL_OffsetIndicator_r12_PR_small_r12 ) {
+      SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = configuration->rxPool_ResourceConfig_offsetIndicator_choice[CC_id] ;
+    } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.present == LTE_SL_OffsetIndicator_r12_PR_large_r12 ) {
+      SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.large_r12 = configuration->rxPool_ResourceConfig_offsetIndicator_choice[CC_id] ;
+    }
+    
+    SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present = configuration->rxPool_ResourceConfig_subframeBitmap_present[CC_id];
+    
+    if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs4_r12) {
+      //for BS4
+      SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
+      SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf  = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
+      SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
+    } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs8_r12) {
+      //for BS8
+      SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
+      SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.buf  = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
+      SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
+    } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs12_r12) {
+      //for BS12
+      SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
+      SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.buf  = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
+      SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
+    } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs16_r12) {
+      //for BS16
+      SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
+      SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf  = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
+      SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
+    } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs30_r12) {
+      //for BS30
+      SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
+      SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.buf  = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
+      SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
+    } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs40_r12) {
+      //for BS40
+      SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
+      SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf  = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
+      SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
+    } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs42_r12) {
+      //for BS42
+      SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
+      SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.buf  = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
+      SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
+    }
+    
+    //dataHoppingConfig_r12
+    SL_CommResourcePool->dataHoppingConfig_r12.hoppingParameter_r12 = 0;
+    SL_CommResourcePool->dataHoppingConfig_r12.numSubbands_r12  =  LTE_SL_HoppingConfigComm_r12__numSubbands_r12_ns1;
+    SL_CommResourcePool->dataHoppingConfig_r12.rb_Offset_r12 = 0;
+    //ue_SelectedResourceConfig_r12
+    SL_CommResourcePool->ue_SelectedResourceConfig_r12 = CALLOC (1, sizeof (*SL_CommResourcePool->ue_SelectedResourceConfig_r12));
+    SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.prb_Num_r12 = 20;
+    SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.prb_Start_r12 = 5;
+    SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.prb_End_r12 = 44;
+    SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.offsetIndicator_r12.present = LTE_SL_OffsetIndicator_r12_PR_small_r12;
+    SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = 0 ;
+    SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.present = LTE_SubframeBitmapSL_r12_PR_bs40_r12;
+    SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = 5;
+    SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf  = CALLOC(1,5);
+    SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = 0;
+    SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[0] = 0xF0;
+    SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[1] = 0xFF;
+    SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[2] = 0xFF;
+    SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[3] = 0xFF;
+    SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[4] = 0xFF;
+    //SL_CommResourcePool->ue_SelectedResourceConfig_r12->trpt_Subset_r12 = CALLOC (1, sizeof(*SL_CommResourcePool->ue_SelectedResourceConfig_r12->trpt_Subset_r12));
+    //rxParametersNCell_r12
+    SL_CommResourcePool->rxParametersNCell_r12 = CALLOC (1, sizeof (*SL_CommResourcePool->rxParametersNCell_r12));
+    SL_CommResourcePool->rxParametersNCell_r12->tdd_Config_r12 = CALLOC (1, sizeof (*SL_CommResourcePool->rxParametersNCell_r12->tdd_Config_r12));
+    SL_CommResourcePool->rxParametersNCell_r12->tdd_Config_r12->subframeAssignment = 0 ;
+    SL_CommResourcePool->rxParametersNCell_r12->tdd_Config_r12->specialSubframePatterns = 0;
+    SL_CommResourcePool->rxParametersNCell_r12->syncConfigIndex_r12 = 0;
+    //txParameters_r12
+    SL_CommResourcePool->txParameters_r12 = CALLOC (1, sizeof (*SL_CommResourcePool->txParameters_r12));
+    SL_CommResourcePool->txParameters_r12->sc_TxParameters_r12.alpha_r12 = LTE_Alpha_r12_al0;
+    SL_CommResourcePool->txParameters_r12->sc_TxParameters_r12.p0_r12 = 0;
+    SL_CommResourcePool->ext1 = NULL ;
+    //end SL_CommResourcePool
+    //add SL_CommResourcePool to SL_CommRxPoolList
+    ASN_SEQUENCE_ADD(&SL_CommRxPoolList->list,SL_CommResourcePool);
+    //end commRxPool_r12
+    //TODO:  commTxPoolNormalCommon_r12, similar to commRxPool_r12
+    //TODO: commTxPoolExceptional_r12
+    //TODO: commSyncConfig_r12
+    // may add commTxResourceUC-ReqAllowed with Ext1
+    (*sib18)->ext1 = NULL;
+    (*sib18)->lateNonCriticalExtension = NULL;
+    // end SIB18
+    // SIB19
+    // fill in all elements of SIB19 if present
+    //discConfig_r12
+    (*sib19)->discConfig_r12 = CALLOC (1, sizeof(*(*sib19)->discConfig_r12));
+    SL_DiscRxPoolList = &(*sib19)->discConfig_r12->discRxPool_r12;
+    memset(SL_DiscRxPoolList,0,sizeof(*SL_DiscRxPoolList));
+    //fill SL_DiscResourcePool
+    SL_DiscResourcePool = CALLOC(1, sizeof(*SL_DiscResourcePool));
+    SL_DiscResourcePool->cp_Len_r12 = configuration->discRxPool_cp_Len[CC_id];
+    SL_DiscResourcePool->discPeriod_r12 = configuration->discRxPool_discPeriod[CC_id];
+    //sc_TF_ResourceConfig_r12
+    SL_DiscResourcePool->numRetx_r12 = configuration->discRxPool_numRetx[CC_id];
+    SL_DiscResourcePool->numRepetition_r12 = configuration->discRxPool_numRepetition[CC_id];
+    SL_DiscResourcePool->tf_ResourceConfig_r12.prb_Num_r12 = configuration->discRxPool_ResourceConfig_prb_Num[CC_id];
+    SL_DiscResourcePool->tf_ResourceConfig_r12.prb_Start_r12 = configuration->discRxPool_ResourceConfig_prb_Start[CC_id];
+    SL_DiscResourcePool->tf_ResourceConfig_r12.prb_End_r12 = configuration->discRxPool_ResourceConfig_prb_End[CC_id];
+    SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.present = configuration->discRxPool_ResourceConfig_offsetIndicator_present[CC_id];
+    
+    if (SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.present == LTE_SL_OffsetIndicator_r12_PR_small_r12 ) {
+      SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = configuration->discRxPool_ResourceConfig_offsetIndicator_choice[CC_id] ;
+    } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.present == LTE_SL_OffsetIndicator_r12_PR_large_r12 ) {
+      SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.choice.large_r12 = configuration->discRxPool_ResourceConfig_offsetIndicator_choice[CC_id] ;
+    }
+    
+    SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present = configuration->discRxPool_ResourceConfig_subframeBitmap_present[CC_id];
+    
+    if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs4_r12) {
+      //for BS4
+      SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
+      SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf  =  (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
+      SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
+    } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs8_r12) {
+      //for BS8
+      SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
+      SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.buf  = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
+      SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
+    } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs12_r12) {
+      //for BS12
+      SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
+      SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.buf  = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
+      SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
+    } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs16_r12) {
+      //for BS16
+      SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
+      SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf  = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
+      SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
+    } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs30_r12) {
+      //for BS30
+      SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
+      SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.buf  = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
+      SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
+    } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs40_r12) {
+      //for BS40
+      SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
+      SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf  = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
+      SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
+    } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs42_r12) {
+      //for BS42
+      SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
+      SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.buf  = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
+      SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
+    }
+    
+    //add SL_DiscResourcePool to SL_DiscRxPoolList
+    ASN_SEQUENCE_ADD(&SL_DiscRxPoolList->list,SL_DiscResourcePool);
+    /*
     //for DiscRxPoolPS
     (*sib19)->ext1 = CALLOC (1, sizeof(*(*sib19)->ext1));
     (*sib19)->ext1->discConfigPS_13 = CALLOC (1, sizeof(*((*sib19)->ext1->discConfigPS_13)));
-
+    
     SL_DiscRxPoolPSList = &(*sib19)->ext1->discConfigPS_13->discRxPoolPS_r13;
     memset(SL_DiscRxPoolPSList,0,sizeof(*SL_DiscRxPoolPSList));
     //fill SL_DiscResourcePool
     SL_DiscResourcePoolPS = CALLOC(1, sizeof(*SL_DiscResourcePoolPS));
-
+    
     SL_DiscResourcePoolPS->cp_Len_r12 = configuration->discRxPoolPS_cp_Len[CC_id];
     SL_DiscResourcePoolPS->discPeriod_r12 = configuration->discRxPoolPS_discPeriod[CC_id];
     //sc_TF_ResourceConfig_r12
     SL_DiscResourcePoolPS->numRetx_r12 = configuration->discRxPoolPS_numRetx[CC_id];
     SL_DiscResourcePoolPS->numRepetition_r12 =  configuration->discRxPoolPS_numRepetition[CC_id];
-
+    
     SL_DiscResourcePoolPS->tf_ResourceConfig_r12.prb_Num_r12 = configuration->discRxPoolPS_ResourceConfig_prb_Num[CC_id];
     SL_DiscResourcePoolPS->tf_ResourceConfig_r12.prb_Start_r12 = configuration->discRxPoolPS_ResourceConfig_prb_Start[CC_id];
     SL_DiscResourcePoolPS->tf_ResourceConfig_r12.prb_End_r12 = configuration->discRxPoolPS_ResourceConfig_prb_End[CC_id];
-
+    
     SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.present = configuration->discRxPoolPS_ResourceConfig_offsetIndicator_present[CC_id];
     if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.present == SL_OffsetIndicator_r12_PR_small_r12 ) {
-       SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = configuration->discRxPoolPS_ResourceConfig_offsetIndicator_choice[CC_id] ;
+    SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = configuration->discRxPoolPS_ResourceConfig_offsetIndicator_choice[CC_id] ;
     } else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.present == SL_OffsetIndicator_r12_PR_large_r12 ){
-       SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.choice.large_r12 = configuration->discRxPoolPS_ResourceConfig_offsetIndicator_choice[CC_id] ;
+    SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.choice.large_r12 = configuration->discRxPoolPS_ResourceConfig_offsetIndicator_choice[CC_id] ;
     }
-
+    
     SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_present[CC_id];
     if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs4_r12){
-       //for BS4
-       SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
-       SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf  = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
-       SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
+    //for BS4
+    SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
+    SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf  = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
+    SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
     } else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs8_r12){
-       //for BS8
-       SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
-       SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.buf  = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
-       SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
+    //for BS8
+    SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
+    SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.buf  = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
+    SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
     } else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs12_r12){
-       //for BS12
-       SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
-       SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.buf  = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
-       SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
+    //for BS12
+    SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
+    SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.buf  = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
+    SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
     }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs16_r12){
-       //for BS16
-       SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
-       SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf  = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
-       SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
+    //for BS16
+    SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
+    SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf  = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
+    SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
     }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs30_r12){
-       //for BS30
-       SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
-       SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.buf  = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
-       SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
+    //for BS30
+    SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
+    SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.buf  = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
+    SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
     }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs40_r12){
-       //for BS40
-       SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
-       SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf  = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
-       SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
+    //for BS40
+    SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
+    SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf  = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
+    SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
     }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs42_r12){
-       //for BS42
-       SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
-       SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.buf  = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
-       SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
+    //for BS42
+    SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id];
+    SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.buf  = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];;
+    SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id];
     }
-
+    
     //add SL_DiscResourcePool to SL_DiscRxPoolList
     ASN_SEQUENCE_ADD(&SL_DiscRxPoolPSList->list,SL_DiscResourcePoolPS);
-  */
-  (*sib19)->lateNonCriticalExtension = NULL;
-  //end SIB19
-  //SIB21
-  (*sib21)->sl_V2X_ConfigCommon_r14 = CALLOC (1, sizeof(*(*sib21)->sl_V2X_ConfigCommon_r14));
-  //SL_V2X_ConfigCommon= (*sib21)->sl_V2X_ConfigCommon_r14;
-  memset((*sib21)->sl_V2X_ConfigCommon_r14,0,sizeof(*(*sib21)->sl_V2X_ConfigCommon_r14));
-  struct LTE_SL_CommRxPoolListV2X_r14 *SL_CommRxPoolListV2X;
-  struct LTE_SL_CommResourcePoolV2X_r14 *SL_CommResourcePoolV2X;
-  (*sib21)->sl_V2X_ConfigCommon_r14->v2x_CommRxPool_r14 = CALLOC(1, sizeof(*(*sib21)->sl_V2X_ConfigCommon_r14->v2x_CommRxPool_r14));
-  SL_CommRxPoolListV2X = (*sib21)->sl_V2X_ConfigCommon_r14->v2x_CommRxPool_r14;
-  SL_CommResourcePoolV2X = CALLOC(1, sizeof(*SL_CommResourcePoolV2X));
-  memset(SL_CommResourcePoolV2X,0,sizeof(*SL_CommResourcePoolV2X));
-  SL_CommResourcePoolV2X->sl_OffsetIndicator_r14 = CALLOC(1, sizeof(*SL_CommResourcePoolV2X->sl_OffsetIndicator_r14));
-  SL_CommResourcePoolV2X->sl_OffsetIndicator_r14->present  = LTE_SL_OffsetIndicator_r12_PR_small_r12;
-  SL_CommResourcePoolV2X->sl_OffsetIndicator_r14->choice.small_r12 = 0;
-  SL_CommResourcePoolV2X->sl_Subframe_r14.present = LTE_SubframeBitmapSL_r14_PR_bs40_r14;
-  SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.size =  5;
-  SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf =  CALLOC(1,5);
-  SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.bits_unused = 0;
-  SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf[0] = 0xF0;
-  SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf[1] = 0xFF;
-  SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf[2] = 0xFF;
-  SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf[3] = 0xFF;
-  SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf[4] = 0xFF;
-  SL_CommResourcePoolV2X->adjacencyPSCCH_PSSCH_r14 = 1;
-  SL_CommResourcePoolV2X->sizeSubchannel_r14 = 10;
-  SL_CommResourcePoolV2X->numSubchannel_r14 =  5;
-  SL_CommResourcePoolV2X->startRB_Subchannel_r14 = 10;
-  //rxParametersNCell_r12
-  SL_CommResourcePoolV2X->rxParametersNCell_r14 = CALLOC (1, sizeof (*SL_CommResourcePoolV2X->rxParametersNCell_r14));
-  SL_CommResourcePoolV2X->rxParametersNCell_r14->tdd_Config_r14 = CALLOC (1, sizeof (*SL_CommResourcePoolV2X->rxParametersNCell_r14->tdd_Config_r14));
-  SL_CommResourcePoolV2X->rxParametersNCell_r14->tdd_Config_r14->subframeAssignment = 0 ;
-  SL_CommResourcePoolV2X->rxParametersNCell_r14->tdd_Config_r14->specialSubframePatterns = 0;
-  SL_CommResourcePoolV2X->rxParametersNCell_r14->syncConfigIndex_r14 = 0;
-  ASN_SEQUENCE_ADD(&SL_CommRxPoolListV2X->list,SL_CommResourcePoolV2X);
-  //end SIB21
+    */
+    (*sib19)->lateNonCriticalExtension = NULL;
+    //end SIB19
+    //SIB21
+    (*sib21)->sl_V2X_ConfigCommon_r14 = CALLOC (1, sizeof(*(*sib21)->sl_V2X_ConfigCommon_r14));
+    //SL_V2X_ConfigCommon= (*sib21)->sl_V2X_ConfigCommon_r14;
+    memset((*sib21)->sl_V2X_ConfigCommon_r14,0,sizeof(*(*sib21)->sl_V2X_ConfigCommon_r14));
+    struct LTE_SL_CommRxPoolListV2X_r14 *SL_CommRxPoolListV2X;
+    struct LTE_SL_CommResourcePoolV2X_r14 *SL_CommResourcePoolV2X;
+    (*sib21)->sl_V2X_ConfigCommon_r14->v2x_CommRxPool_r14 = CALLOC(1, sizeof(*(*sib21)->sl_V2X_ConfigCommon_r14->v2x_CommRxPool_r14));
+    SL_CommRxPoolListV2X = (*sib21)->sl_V2X_ConfigCommon_r14->v2x_CommRxPool_r14;
+    SL_CommResourcePoolV2X = CALLOC(1, sizeof(*SL_CommResourcePoolV2X));
+    memset(SL_CommResourcePoolV2X,0,sizeof(*SL_CommResourcePoolV2X));
+    SL_CommResourcePoolV2X->sl_OffsetIndicator_r14 = CALLOC(1, sizeof(*SL_CommResourcePoolV2X->sl_OffsetIndicator_r14));
+    SL_CommResourcePoolV2X->sl_OffsetIndicator_r14->present  = LTE_SL_OffsetIndicator_r12_PR_small_r12;
+    SL_CommResourcePoolV2X->sl_OffsetIndicator_r14->choice.small_r12 = 0;
+    SL_CommResourcePoolV2X->sl_Subframe_r14.present = LTE_SubframeBitmapSL_r14_PR_bs40_r14;
+    SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.size =  5;
+    SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf =  CALLOC(1,5);
+    SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.bits_unused = 0;
+    SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf[0] = 0xF0;
+    SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf[1] = 0xFF;
+    SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf[2] = 0xFF;
+    SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf[3] = 0xFF;
+    SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf[4] = 0xFF;
+    SL_CommResourcePoolV2X->adjacencyPSCCH_PSSCH_r14 = 1;
+    SL_CommResourcePoolV2X->sizeSubchannel_r14 = 10;
+    SL_CommResourcePoolV2X->numSubchannel_r14 =  5;
+    SL_CommResourcePoolV2X->startRB_Subchannel_r14 = 10;
+    //rxParametersNCell_r12
+    SL_CommResourcePoolV2X->rxParametersNCell_r14 = CALLOC (1, sizeof (*SL_CommResourcePoolV2X->rxParametersNCell_r14));
+    SL_CommResourcePoolV2X->rxParametersNCell_r14->tdd_Config_r14 = CALLOC (1, sizeof (*SL_CommResourcePoolV2X->rxParametersNCell_r14->tdd_Config_r14));
+    SL_CommResourcePoolV2X->rxParametersNCell_r14->tdd_Config_r14->subframeAssignment = 0 ;
+    SL_CommResourcePoolV2X->rxParametersNCell_r14->tdd_Config_r14->specialSubframePatterns = 0;
+    SL_CommResourcePoolV2X->rxParametersNCell_r14->syncConfigIndex_r14 = 0;
+    ASN_SEQUENCE_ADD(&SL_CommRxPoolListV2X->list,SL_CommResourcePoolV2X);
+    //end SIB21
+  }
 #endif
   bcch_message->message.present = LTE_BCCH_DL_SCH_MessageType_PR_c1;
   bcch_message->message.choice.c1.present = LTE_BCCH_DL_SCH_MessageType__c1_PR_systemInformation;
@@ -1175,6 +1997,7 @@ uint8_t do_SIB23(uint8_t Mod_id,
    (void*)systemInformation,
    sizeof(SystemInformation_t));*/
   bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.present = LTE_SystemInformation__criticalExtensions_PR_systemInformation_r8;
+
   bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count=0;
   //  asn_set_empty(&systemInformation->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list);//.size=0;
   //  systemInformation->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count=0;
@@ -1184,8 +2007,8 @@ uint8_t do_SIB23(uint8_t Mod_id,
                    sib3_part);
 #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
 
-  if (MBMS_flag > 0) {
-    ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list,sib13_part);
+  if (configuration->eMBMS_configured > 0) {
+    ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list, sib13_part);
   }
 
 #endif
@@ -1201,6 +2024,7 @@ uint8_t do_SIB23(uint8_t Mod_id,
                                    900);
   AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n",
                enc_rval.failed_type->name, enc_rval.encoded);
+
   LOG_D(RRC,"[eNB] SystemInformation Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
 
   if (enc_rval.encoded==-1) {
@@ -1262,7 +2086,7 @@ uint8_t do_RRCConnectionRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv) {
                                    buffer,
                                    100);
   AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n",
-               enc_rval.failed_type->name, enc_rval.encoded);
+	       enc_rval.failed_type->name, enc_rval.encoded);
   LOG_D(RRC,"[UE] RRCConnectionRequest Encoded %zd bits (%zd bytes) \n",enc_rval.encoded,(enc_rval.encoded+7)/8);
   return((enc_rval.encoded+7)/8);
 }
@@ -1412,8 +2236,8 @@ uint8_t do_SidelinkUEInformation(uint8_t Mod_id, uint8_t *buffer,  LTE_SL_Destin
   return((enc_rval.encoded+7)/8);
 }
 
-
 uint8_t do_RRCConnectionSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uint8_t Transaction_id, const int dedicatedInfoNASLength, const char *dedicatedInfoNAS) {
+
   asn_enc_rval_t enc_rval;
   LTE_UL_DCCH_Message_t ul_dcch_msg;
   LTE_RRCConnectionSetupComplete_t *rrcConnectionSetupComplete;
@@ -1725,6 +2549,8 @@ do_RRCConnectionSetup(
   //assign_enum(&physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode,
   //     AntennaInfoDedicated__transmissionMode_tm2);
 
+  LOG_D(RRC,"physicalConfigDedicated2 %p, physicalConfigDedicated2->antennaInfo %p => %d\n",physicalConfigDedicated2,physicalConfigDedicated2->antennaInfo,transmission_mode);
+
   switch (transmission_mode) {
     default:
       LOG_W(RRC,"At RRCConnectionSetup Transmission mode can only take values 1 or 2! Defaulting to 1!\n");
@@ -1883,88 +2709,514 @@ do_RRCConnectionSetup(
   return((enc_rval.encoded+7)/8);
 }
 
-//------------------------------------------------------------------------------
-uint8_t
-do_SecurityModeCommand(
-  const protocol_ctxt_t *const ctxt_pP,
-  uint8_t *const buffer,
-  const uint8_t Transaction_id,
-  const uint8_t cipheringAlgorithm,
-  const uint8_t integrityProtAlgorithm
-)
-//------------------------------------------------------------------------------
+
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+uint8_t do_RRCConnectionSetup_BR(
+				 const protocol_ctxt_t*     const ctxt_pP,
+				 rrc_eNB_ue_context_t*      const ue_context_pP,
+				 int                              CC_id,
+				 uint8_t*                   const buffer,
+				 const uint8_t                    transmission_mode,
+				 const uint8_t                    Transaction_id,
+				 LTE_SRB_ToAddModList_t             **SRB_configList,
+				 struct LTE_PhysicalConfigDedicated **physicalConfigDedicated)
 {
-  LTE_DL_DCCH_Message_t dl_dcch_msg;
+
   asn_enc_rval_t enc_rval;
-  memset(&dl_dcch_msg,0,sizeof(LTE_DL_DCCH_Message_t));
-  dl_dcch_msg.message.present           = LTE_DL_DCCH_MessageType_PR_c1;
-  dl_dcch_msg.message.choice.c1.present = LTE_DL_DCCH_MessageType__c1_PR_securityModeCommand;
-  dl_dcch_msg.message.choice.c1.choice.securityModeCommand.rrc_TransactionIdentifier = Transaction_id;
-  dl_dcch_msg.message.choice.c1.choice.securityModeCommand.criticalExtensions.present = LTE_SecurityModeCommand__criticalExtensions_PR_c1;
-  dl_dcch_msg.message.choice.c1.choice.securityModeCommand.criticalExtensions.choice.c1.present =
-    LTE_SecurityModeCommand__criticalExtensions__c1_PR_securityModeCommand_r8;
-  // the two following information could be based on the mod_id
-  dl_dcch_msg.message.choice.c1.choice.securityModeCommand.criticalExtensions.choice.c1.choice.securityModeCommand_r8.securityConfigSMC.securityAlgorithmConfig.cipheringAlgorithm
-    = (LTE_CipheringAlgorithm_r12_t)cipheringAlgorithm;
-  dl_dcch_msg.message.choice.c1.choice.securityModeCommand.criticalExtensions.choice.c1.choice.securityModeCommand_r8.securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm
-    = (e_LTE_SecurityAlgorithmConfig__integrityProtAlgorithm)integrityProtAlgorithm;
+  eNB_RRC_INST *rrc               = RC.rrc[ctxt_pP->module_id];
+  rrc_eNB_carrier_data_t *carrier = &rrc->carrier[CC_id];
 
-  if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
-    xer_fprint(stdout, &asn_DEF_LTE_DL_DCCH_Message, (void *)&dl_dcch_msg);
-  }
+  long* logicalchannelgroup = NULL;
+  struct LTE_SRB_ToAddMod* SRB1_config = NULL;
+  struct LTE_SRB_ToAddMod__rlc_Config* SRB1_rlc_config = NULL;
+  struct LTE_SRB_ToAddMod__logicalChannelConfig* SRB1_lchan_config = NULL;
+  struct LTE_LogicalChannelConfig__ul_SpecificParameters* SRB1_ul_SpecificParameters = NULL;
 
-  enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_DCCH_Message,
-                                   NULL,
-                                   (void *)&dl_dcch_msg,
-                                   buffer,
-                                   100);
+#ifdef CBA
+  struct PUSCH_CBAConfigDedicated_vlola*  pusch_CBAConfigDedicated_vlola = NULL;
+  long* betaOffset_CBA_Index = NULL;
+  long* cShift_CBA = NULL;
+#endif
+  LTE_PhysicalConfigDedicated_t* physicalConfigDedicated2 = NULL;
 
-  if(enc_rval.encoded == -1) {
-    LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n",
-          enc_rval.failed_type->name, enc_rval.encoded);
-    return -1;
-  }
+  LTE_DL_CCCH_Message_t dl_ccch_msg;
 
-  LOG_D(RRC,"[eNB %d] securityModeCommand for UE %x Encoded %zd bits (%zd bytes)\n",
-        ctxt_pP->module_id,
-        ctxt_pP->rnti,
-        enc_rval.encoded,
-        (enc_rval.encoded+7)/8);
+  LTE_RRCConnectionSetup_t* rrcConnectionSetup = NULL;
 
-  if (enc_rval.encoded==-1) {
-    LOG_E(RRC,"[eNB %d] ASN1 : securityModeCommand encoding failed for UE %x\n",
-          ctxt_pP->module_id,
-          ctxt_pP->rnti);
-    return(-1);
+  memset((void *)&dl_ccch_msg,0,sizeof(LTE_DL_CCCH_Message_t));
+  dl_ccch_msg.message.present           = LTE_DL_CCCH_MessageType_PR_c1;
+  dl_ccch_msg.message.choice.c1.present = LTE_DL_CCCH_MessageType__c1_PR_rrcConnectionSetup;
+  rrcConnectionSetup          = &dl_ccch_msg.message.choice.c1.choice.rrcConnectionSetup;
+
+  // RRCConnectionSetup
+  // Configure SRB1
+
+  //  *SRB_configList = CALLOC(1,sizeof(*SRB_configList));
+  if (*SRB_configList) {
+    free(*SRB_configList);
   }
 
-  //  rrc_ue_process_ueCapabilityEnquiry(0,1000,&dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry,0);
-  //  exit(-1);
-  return((enc_rval.encoded+7)/8);
-}
+  *SRB_configList = CALLOC(1,sizeof(LTE_SRB_ToAddModList_t));
 
-//------------------------------------------------------------------------------
-uint8_t
-do_UECapabilityEnquiry(
-  const protocol_ctxt_t *const ctxt_pP,
-  uint8_t               *const buffer,
-  const uint8_t                Transaction_id
-)
-//------------------------------------------------------------------------------
-{
-  LTE_DL_DCCH_Message_t dl_dcch_msg;
-  LTE_RAT_Type_t rat=LTE_RAT_Type_eutra;
-  asn_enc_rval_t enc_rval;
-  memset(&dl_dcch_msg,0,sizeof(LTE_DL_DCCH_Message_t));
-  dl_dcch_msg.message.present           = LTE_DL_DCCH_MessageType_PR_c1;
-  dl_dcch_msg.message.choice.c1.present = LTE_DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry;
-  dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.rrc_TransactionIdentifier = Transaction_id;
-  dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.present = LTE_UECapabilityEnquiry__criticalExtensions_PR_c1;
-  dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.choice.c1.present =
+  /// SRB1
+  SRB1_config = CALLOC(1,sizeof(*SRB1_config));
+
+  SRB1_config->srb_Identity = 1;
+  SRB1_rlc_config = CALLOC(1, sizeof(*SRB1_rlc_config));
+  SRB1_config->rlc_Config  = SRB1_rlc_config; // check this
+
+  SRB1_rlc_config->present = LTE_SRB_ToAddMod__rlc_Config_PR_explicitValue;
+  SRB1_rlc_config->choice.explicitValue.present = LTE_RLC_Config_PR_am;
+#if defined(ENABLE_ITTI)
+  SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = rrc->srb1_timer_poll_retransmit;
+  SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollPDU          = rrc->srb1_poll_pdu;
+  SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollByte         = rrc->srb1_poll_byte;
+  SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = rrc->srb1_max_retx_threshold;
+  SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering     = rrc->srb1_timer_reordering;
+  SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = rrc->srb1_timer_status_prohibit;
+#else
+  SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = LTE_T_PollRetransmit_ms20; // FIXME should be 80
+  SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollPDU          = LTE_PollPDU_p4; // FIXME should be infinity
+  SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollByte         = LTE_PollByte_kBinfinity;
+  SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = LTE_UL_AM_RLC__maxRetxThreshold_t8;
+
+  SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering     = LTE_T_Reordering_ms35;
+  SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = LTE_T_StatusProhibit_ms0;
+#endif
+
+  SRB1_lchan_config = CALLOC(1, sizeof(*SRB1_lchan_config));
+  SRB1_config->logicalChannelConfig = SRB1_lchan_config;
+
+  SRB1_lchan_config->present = LTE_SRB_ToAddMod__logicalChannelConfig_PR_explicitValue;
+  SRB1_ul_SpecificParameters = CALLOC(1, sizeof(*SRB1_ul_SpecificParameters));
+
+  SRB1_lchan_config->choice.explicitValue.ul_SpecificParameters = SRB1_ul_SpecificParameters;
+
+  SRB1_ul_SpecificParameters->priority = 1;
+
+  //assign_enum(&SRB1_ul_SpecificParameters->prioritisedBitRate,LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity);
+  SRB1_ul_SpecificParameters->prioritisedBitRate=LTE_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity;
+
+  //assign_enum(&SRB1_ul_SpecificParameters->bucketSizeDuration,LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50);
+  SRB1_ul_SpecificParameters->bucketSizeDuration=LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50;
+
+  logicalchannelgroup = CALLOC(1,sizeof(long));
+  *logicalchannelgroup=0;
+  SRB1_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup;
+
+
+  ASN_SEQUENCE_ADD(&(*SRB_configList)->list,SRB1_config);
+
+  // PhysicalConfigDedicated
+
+  physicalConfigDedicated2 = CALLOC(1,sizeof(*physicalConfigDedicated2));
+  *physicalConfigDedicated = physicalConfigDedicated2;
+
+  physicalConfigDedicated2->pdsch_ConfigDedicated         = CALLOC(1,sizeof(*physicalConfigDedicated2->pdsch_ConfigDedicated));
+  physicalConfigDedicated2->pucch_ConfigDedicated         = CALLOC(1,sizeof(*physicalConfigDedicated2->pucch_ConfigDedicated));
+
+  physicalConfigDedicated2->pusch_ConfigDedicated         = CALLOC(1,sizeof(*physicalConfigDedicated2->pusch_ConfigDedicated));;
+  physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH         = NULL;
+  physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH         = NULL;
+
+  physicalConfigDedicated2->uplinkPowerControlDedicated   = CALLOC(1,sizeof(*physicalConfigDedicated2->uplinkPowerControlDedicated));
+  physicalConfigDedicated2->cqi_ReportConfig              = CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig));
+
+  if (rrc->srs_enable[CC_id])
+      physicalConfigDedicated2->soundingRS_UL_ConfigDedicated = CALLOC(1,sizeof(*physicalConfigDedicated2->soundingRS_UL_ConfigDedicated));
+  else
+      physicalConfigDedicated2->soundingRS_UL_ConfigDedicated = NULL;
+  physicalConfigDedicated2->antennaInfo                   = CALLOC(1,sizeof(*physicalConfigDedicated2->antennaInfo));
+  physicalConfigDedicated2->schedulingRequestConfig       = CALLOC(1,sizeof(*physicalConfigDedicated2->schedulingRequestConfig));
+#ifdef CBA
+  physicalConfigDedicated2->pusch_CBAConfigDedicated_vlola = CALLOC(1,sizeof(*physicalConfigDedicated2->pusch_CBAConfigDedicated_vlola));
+#endif
+
+  if (carrier->p_eNB==2)
+    physicalConfigDedicated2->pdsch_ConfigDedicated->p_a = LTE_PDSCH_ConfigDedicated__p_a_dB_3;
+  else
+    physicalConfigDedicated2->pdsch_ConfigDedicated->p_a = LTE_PDSCH_ConfigDedicated__p_a_dB0;
+
+  // PUCCH
+  physicalConfigDedicated2->pucch_ConfigDedicated->ackNackRepetition.present=LTE_PUCCH_ConfigDedicated__ackNackRepetition_PR_release;
+  physicalConfigDedicated2->pucch_ConfigDedicated->ackNackRepetition.choice.release=0;
+
+  // PUSCH
+  physicalConfigDedicated2->pusch_ConfigDedicated->betaOffset_ACK_Index = 10;
+  physicalConfigDedicated2->pusch_ConfigDedicated->betaOffset_RI_Index = 9;
+  physicalConfigDedicated2->pusch_ConfigDedicated->betaOffset_CQI_Index = 10;
+
+  //
+
+
+  if (carrier->sib1->tdd_Config == NULL) {
+    physicalConfigDedicated2->pucch_ConfigDedicated->tdd_AckNackFeedbackMode=NULL;//PUCCH_ConfigDedicated__tdd_AckNackFeedbackMode_multiplexing;
+  } else { //TDD
+    physicalConfigDedicated2->pucch_ConfigDedicated->tdd_AckNackFeedbackMode = CALLOC(1,sizeof(long));
+    *(physicalConfigDedicated2->pucch_ConfigDedicated->tdd_AckNackFeedbackMode) =
+      LTE_PUCCH_ConfigDedicated__tdd_AckNackFeedbackMode_bundling;//PUCCH_ConfigDedicated__tdd_AckNackFeedbackMode_multiplexing;
+  }
+
+  /// TODO to be reviewed
+  // UplinkPowerControlDedicated
+  physicalConfigDedicated2->uplinkPowerControlDedicated->p0_UE_PUSCH = 0; // 0 dB
+  //assign_enum(&physicalConfigDedicated2->uplinkPowerControlDedicated->deltaMCS_Enabled,
+  // UplinkPowerControlDedicated__deltaMCS_Enabled_en1);
+  physicalConfigDedicated2->uplinkPowerControlDedicated->deltaMCS_Enabled= LTE_UplinkPowerControlDedicated__deltaMCS_Enabled_en1;
+  physicalConfigDedicated2->uplinkPowerControlDedicated->accumulationEnabled = 1;  // TRUE
+  physicalConfigDedicated2->uplinkPowerControlDedicated->p0_UE_PUCCH = 0; // 0 dB
+  physicalConfigDedicated2->uplinkPowerControlDedicated->pSRS_Offset = 0; // 0 dB
+  physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient = CALLOC(1,
+										    sizeof(*physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient));
+  //  assign_enum(physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient,FilterCoefficient_fc4); // fc4 dB
+  *physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient=LTE_FilterCoefficient_fc4; // fc4 dB
+
+  // TPC-PDCCH-Config
+
+  // CQI ReportConfig
+  physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic = CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic));
+  *physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic = LTE_CQI_ReportModeAperiodic_rm20;
+  physicalConfigDedicated2->cqi_ReportConfig->nomPDSCH_RS_EPRE_Offset = 0; // 0 dB
+  physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic = CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic));
+  physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->present = LTE_CQI_ReportPeriodic_PR_release;
+  physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.release = (NULL_t)0;
+
+    
+  /// TODO to be reviewed
+  if (rrc->srs_enable[CC_id]) {
+      physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->present = LTE_SoundingRS_UL_ConfigDedicated_PR_setup;
+      physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth =
+              LTE_SoundingRS_UL_ConfigDedicated__setup__srs_Bandwidth_bw0;
+      physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth =
+              LTE_SoundingRS_UL_ConfigDedicated__setup__srs_HoppingBandwidth_hbw0;
+      physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.freqDomainPosition=0;
+      physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.duration=1;
+      if (carrier->sib1->tdd_Config==NULL) { // FDD
+          if (carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.present
+                  == LTE_SoundingRS_UL_ConfigCommon_PR_setup)
+              if (carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig!=0)
+                  LOG_W(RRC,"This code has been optimized for SRS Subframe Config 0, but current config is %d. Expect undefined behaviour!\n",
+                        (int)carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig);
+          if (ue_context_pP->local_uid >=20)
+              LOG_W(RRC,"This code has been optimized for up to 10 UEs, but current UE_id is %d. Expect undefined behaviour!\n",
+                    ue_context_pP->local_uid);
+          //the current code will allow for 20 UEs - to be revised for more
+          physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex=7+ue_context_pP->local_uid/2;
+          physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb= ue_context_pP->local_uid%2;
+      }
+      else {
+          if (carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.present
+                  == LTE_SoundingRS_UL_ConfigCommon_PR_setup)
+              if (carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig!=7) {
+                  LOG_W(RRC,"This code has been optimized for SRS Subframe Config 7 and TDD config 3, but current configs are %d and %d. Expect undefined behaviour!\n",
+                        (int)carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig,
+                        (int)carrier->sib1->tdd_Config->subframeAssignment);
+              }
+          if (ue_context_pP->local_uid >=6)
+              LOG_W(RRC,"This code has been optimized for up to 6 UEs, but current UE_id is %d. Expect undefined behaviour!\n",
+                    ue_context_pP->local_uid);
+          physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex=17+ue_context_pP->local_uid/2;
+          physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb= ue_context_pP->local_uid%2;
+      }
+      LOG_W(RRC,"local UID %d, srs ConfigIndex %d, TransmissionComb %d\n",ue_context_pP->local_uid,
+            (int)physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex,
+            (int)physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb);
+
+      physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift=
+              LTE_SoundingRS_UL_ConfigDedicated__setup__cyclicShift_cs0;
+  }
+
+  //AntennaInfoDedicated
+  physicalConfigDedicated2->antennaInfo = CALLOC(1,sizeof(*physicalConfigDedicated2->antennaInfo));
+  physicalConfigDedicated2->antennaInfo->present = LTE_PhysicalConfigDedicated__antennaInfo_PR_explicitValue;
+
+  switch (transmission_mode) {
+  default:
+    LOG_W(RRC,"At RRCConnectionSetup Transmission mode can only take values 1 or 2! Defaulting to 1!\n");
+  case 1:
+    physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode=     LTE_AntennaInfoDedicated__transmissionMode_tm1;
+    break;
+
+  case 2:
+    physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode=     LTE_AntennaInfoDedicated__transmissionMode_tm2;
+    break;
+    /*
+      case 3:
+      physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode=     AntennaInfoDedicated__transmissionMode_tm3;
+      physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction=     CALLOC(1,
+      sizeof(*physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction));
+      physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
+      AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm3;
+      physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf= MALLOC(1);
+      physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf[0] = 0xc0;
+      physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.size=1;
+      physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.bits_unused=6;
+
+      break;
+
+      case 4:
+      physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode=     AntennaInfoDedicated__transmissionMode_tm4;
+      break;
+
+      case 5:
+      physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode=     AntennaInfoDedicated__transmissionMode_tm5;
+      break;
+
+      case 6:
+      physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode=     AntennaInfoDedicated__transmissionMode_tm6;
+      break;
+
+      case 7:
+      physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode=     AntennaInfoDedicated__transmissionMode_tm7;
+      break;
+    */
+  }
+
+
+  physicalConfigDedicated2->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.present = LTE_AntennaInfoDedicated__ue_TransmitAntennaSelection_PR_release;
+  physicalConfigDedicated2->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.choice.release = 0;
+
+  // SchedulingRequestConfig
+
+  physicalConfigDedicated2->schedulingRequestConfig->present = LTE_SchedulingRequestConfig_PR_setup;
+  physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 18;//ue_context_pP->local_uid;
+
+  if (carrier->sib1->tdd_Config == NULL) { // FDD
+    physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 76+(ue_context_pP->local_uid%10);  // Isr = 76 (every 80 subframes, offset=2+UE_id mod3)
+  } else {
+    switch (carrier->sib1->tdd_Config->subframeAssignment) {
+    case 1:
+      physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7+(ue_context_pP->local_uid&1)+((
+															ue_context_pP->local_uid&3)>>1)*5;  // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 7 for UE2, 8 for UE3 , 2 for UE4 etc..)
+      break;
+
+    case 3:
+      physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7+
+	(ue_context_pP->local_uid%3);  // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 3 for UE2, 2 for UE3 , etc..)
+      break;
+
+    case 4:
+      physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7+
+	(ue_context_pP->local_uid&1);  // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 3 for UE2, 2 for UE3 , etc..)
+      break;
+
+    default:
+      physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7;  // Isr = 5 (every 10 subframes, offset=2 for all UE0 etc..)
+      break;
+    }
+  }
+
+
+  physicalConfigDedicated2->schedulingRequestConfig->choice.setup.dsr_TransMax = LTE_SchedulingRequestConfig__setup__dsr_TransMax_n16;
+
+  physicalConfigDedicated2->ext4 =  calloc(1, sizeof(struct LTE_PhysicalConfigDedicated__ext4) );
+  physicalConfigDedicated2->ext4->csi_RS_ConfigNZPToReleaseList_r11 = NULL;
+  physicalConfigDedicated2->ext4->csi_RS_ConfigNZPToAddModList_r11 = NULL;
+  physicalConfigDedicated2->ext4->csi_RS_ConfigZPToAddModList_r11 = NULL;
+  physicalConfigDedicated2->ext4->csi_RS_ConfigZPToReleaseList_r11 = NULL;
+
+  physicalConfigDedicated2->ext4->epdcch_Config_r11 = calloc(1, sizeof(struct LTE_EPDCCH_Config_r11 ));
+  physicalConfigDedicated2->ext4->epdcch_Config_r11->config_r11.present = LTE_EPDCCH_Config_r11__config_r11_PR_setup;
+  physicalConfigDedicated2->ext4->epdcch_Config_r11->config_r11.choice.setup.subframePatternConfig_r11 = NULL;
+  physicalConfigDedicated2->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 = calloc(1,sizeof(long));
+  *physicalConfigDedicated2->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 = 2;
+  physicalConfigDedicated2->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToReleaseList_r11 = NULL;
+
+
+  physicalConfigDedicated2->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 = calloc(1, sizeof(LTE_EPDCCH_SetConfigToAddModList_r11_t));
+  //  memset(physicalConfigDedicated2->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11, 0, sizeof())
+  LTE_EPDCCH_SetConfig_r11_t *epdcch_setconfig_r11 = calloc(1, sizeof(LTE_EPDCCH_SetConfig_r11_t));
+  epdcch_setconfig_r11->setConfigId_r11 = 0;
+  epdcch_setconfig_r11->transmissionType_r11 = LTE_EPDCCH_SetConfig_r11__transmissionType_r11_distributed;
+  epdcch_setconfig_r11->resourceBlockAssignment_r11.numberPRB_Pairs_r11 = LTE_EPDCCH_SetConfig_r11__resourceBlockAssignment_r11__numberPRB_Pairs_r11_n2;
+  //epdcch_setconfig_r11->resourceBlockAssignment_r11.resourceBlockAssignment_r11 = calloc(0, sizeof(BIT_STRING_t));
+  epdcch_setconfig_r11->resourceBlockAssignment_r11.resourceBlockAssignment_r11.buf = calloc(1, 5 * sizeof(uint8_t));
+  epdcch_setconfig_r11->resourceBlockAssignment_r11.resourceBlockAssignment_r11.size = 5;
+  epdcch_setconfig_r11->resourceBlockAssignment_r11.resourceBlockAssignment_r11.bits_unused = 2;
+  memset(epdcch_setconfig_r11->resourceBlockAssignment_r11.resourceBlockAssignment_r11.buf, 0, 5 * sizeof(uint8_t));
+
+  epdcch_setconfig_r11->dmrs_ScramblingSequenceInt_r11 = 54;
+  epdcch_setconfig_r11->pucch_ResourceStartOffset_r11 = 0;
+  epdcch_setconfig_r11->re_MappingQCL_ConfigId_r11 = NULL;
+
+  epdcch_setconfig_r11->ext2 = calloc(1, sizeof(struct LTE_EPDCCH_SetConfig_r11__ext2));
+  epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310 = calloc(1,sizeof(struct LTE_EPDCCH_SetConfig_r11__ext2__numberPRB_Pairs_v1310));
+  epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present =  LTE_EPDCCH_SetConfig_r11__ext2__numberPRB_Pairs_v1310_PR_setup;
+  epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->choice.setup = LTE_EPDCCH_SetConfig_r11__ext2__numberPRB_Pairs_v1310__setup_n6;
+  epdcch_setconfig_r11->ext2->mpdcch_config_r13 = calloc(1, sizeof(struct LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13));
+  epdcch_setconfig_r11->ext2->mpdcch_config_r13->present = LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13_PR_setup;
+  epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.csi_NumRepetitionCE_r13                = LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13__setup__csi_NumRepetitionCE_r13_sf1;
+  epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_pdsch_HoppingConfig_r13         = LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13__setup__mpdcch_pdsch_HoppingConfig_r13_off;
+  epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_StartSF_UESS_r13.present        = LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13__setup__mpdcch_StartSF_UESS_r13_PR_fdd_r13;
+  epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_StartSF_UESS_r13.choice.fdd_r13 = LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13__setup__mpdcch_StartSF_UESS_r13__fdd_r13_v1;
+  epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_NumRepetition_r13               = LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13__setup__mpdcch_NumRepetition_r13_r1;
+  epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13                  = 3; // note: this is narrowband index 2
+  ASN_SEQUENCE_ADD(physicalConfigDedicated2->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11, epdcch_setconfig_r11);
+
+
+  // FIXME allocate physicalConfigDedicated2->ext7
+  physicalConfigDedicated2->ext7 = CALLOC(1, sizeof(struct LTE_PhysicalConfigDedicated__ext7));
+
+  physicalConfigDedicated2->ext7->pdsch_ConfigDedicated_v1310 = NULL; // has some parameters to be filled
+
+  physicalConfigDedicated2->ext7->pusch_ConfigDedicated_r13 = NULL;
+  physicalConfigDedicated2->ext7->pucch_ConfigDedicated_r13 = NULL;
+
+  physicalConfigDedicated2->ext7->pdcch_CandidateReductions_r13 = NULL;
+
+  physicalConfigDedicated2->ext7->cqi_ReportConfig_v1310 = NULL;
+
+  physicalConfigDedicated2->ext7->soundingRS_UL_ConfigDedicated_v1310 = NULL;
+  physicalConfigDedicated2->ext7->soundingRS_UL_ConfigDedicatedUpPTsExt_r13 = NULL;
+  physicalConfigDedicated2->ext7->soundingRS_UL_ConfigDedicatedAperiodic_v1310 = NULL;
+  physicalConfigDedicated2->ext7->soundingRS_UL_ConfigDedicatedAperiodicUpPTsExt_r13 = NULL;
+
+  physicalConfigDedicated2->ext7->csi_RS_Config_v1310 = NULL;
+
+  // FIXME ce_Mode_r13 allocation
+  physicalConfigDedicated2->ext7->ce_Mode_r13 = CALLOC(1, sizeof(struct LTE_PhysicalConfigDedicated__ext7__ce_Mode_r13));
+  physicalConfigDedicated2->ext7->ce_Mode_r13->present      = LTE_PhysicalConfigDedicated__ext7__ce_Mode_r13_PR_setup;
+  physicalConfigDedicated2->ext7->ce_Mode_r13->choice.setup = LTE_PhysicalConfigDedicated__ext7__ce_Mode_r13__setup_ce_ModeA;
+  physicalConfigDedicated2->ext7->csi_RS_ConfigNZPToAddModListExt_r13 = NULL;
+  physicalConfigDedicated2->ext7->csi_RS_ConfigNZPToReleaseListExt_r13 = NULL;
+
+
+  rrcConnectionSetup->rrc_TransactionIdentifier = Transaction_id;
+  rrcConnectionSetup->criticalExtensions.present = LTE_RRCConnectionSetup__criticalExtensions_PR_c1;
+  rrcConnectionSetup->criticalExtensions.choice.c1.present =LTE_RRCConnectionSetup__criticalExtensions__c1_PR_rrcConnectionSetup_r8 ;
+  rrcConnectionSetup->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated.srb_ToAddModList = *SRB_configList;
+  rrcConnectionSetup->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated.drb_ToAddModList = NULL;
+  rrcConnectionSetup->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated.drb_ToReleaseList = NULL;
+  rrcConnectionSetup->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated.sps_Config = NULL;
+  rrcConnectionSetup->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated.physicalConfigDedicated = physicalConfigDedicated2;
+  rrcConnectionSetup->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated.mac_MainConfig = NULL;
+
+#ifdef XER_PRINT
+  xer_fprint(stdout, &asn_DEF_DL_CCCH_Message, (void*)&dl_ccch_msg);
+#endif
+  enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_CCCH_Message,
+				   NULL,
+				   (void*)&dl_ccch_msg,
+				   buffer,
+				   100);
+  AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n",
+	       enc_rval.failed_type->name, enc_rval.encoded);
+
+#if defined(ENABLE_ITTI)
+# if !defined(DISABLE_XER_SPRINT)
+  {
+    char        message_string[20000];
+    size_t      message_string_size;
+
+    if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_LTE_DL_CCCH_Message, (void *) &dl_ccch_msg)) > 0) {
+      MessageDef *msg_p;
+
+      msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB, RRC_DL_CCCH, message_string_size + sizeof (IttiMsgText));
+      msg_p->ittiMsg.rrc_dl_ccch.size = message_string_size;
+      memcpy(&msg_p->ittiMsg.rrc_dl_ccch.text, message_string, message_string_size);
+
+      itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p);
+    }
+  }
+# endif
+#endif
+
+#ifdef USER_MODE
+  LOG_D(RRC,"RRCConnectionSetup_BR Encoded %d bits (%d bytes), ecause %d\n",
+	enc_rval.encoded,(enc_rval.encoded+7)/8,ecause);
+#endif
+
+  //  FREEMEM(SRB_list);
+  //  free(SRB1_config);
+  //  free(SRB1_rlc_config);
+  //  free(SRB1_lchan_config);
+  //  free(SRB1_ul_SpecificParameters);
+
+  return((enc_rval.encoded+7)/8);
+}
+#endif
+
+
+
+
+uint8_t do_SecurityModeCommand(
+			       const protocol_ctxt_t *const ctxt_pP,
+			       uint8_t *const buffer,
+			       const uint8_t Transaction_id,
+			       const uint8_t cipheringAlgorithm,
+			       const uint8_t integrityProtAlgorithm
+			       )
+//------------------------------------------------------------------------------
+{
+  LTE_DL_DCCH_Message_t dl_dcch_msg;
+  asn_enc_rval_t enc_rval;
+  memset(&dl_dcch_msg,0,sizeof(LTE_DL_DCCH_Message_t));
+  dl_dcch_msg.message.present           = LTE_DL_DCCH_MessageType_PR_c1;
+  dl_dcch_msg.message.choice.c1.present = LTE_DL_DCCH_MessageType__c1_PR_securityModeCommand;
+
+  dl_dcch_msg.message.choice.c1.choice.securityModeCommand.rrc_TransactionIdentifier = Transaction_id;
+  dl_dcch_msg.message.choice.c1.choice.securityModeCommand.criticalExtensions.present = LTE_SecurityModeCommand__criticalExtensions_PR_c1;
+  dl_dcch_msg.message.choice.c1.choice.securityModeCommand.criticalExtensions.choice.c1.present =
+    LTE_SecurityModeCommand__criticalExtensions__c1_PR_securityModeCommand_r8;
+  // the two following information could be based on the mod_id
+  dl_dcch_msg.message.choice.c1.choice.securityModeCommand.criticalExtensions.choice.c1.choice.securityModeCommand_r8.securityConfigSMC.securityAlgorithmConfig.cipheringAlgorithm
+    = (LTE_CipheringAlgorithm_r12_t)cipheringAlgorithm;
+  dl_dcch_msg.message.choice.c1.choice.securityModeCommand.criticalExtensions.choice.c1.choice.securityModeCommand_r8.securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm
+    = (e_LTE_SecurityAlgorithmConfig__integrityProtAlgorithm)integrityProtAlgorithm;
+
+  if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
+    xer_fprint(stdout, &asn_DEF_LTE_DL_DCCH_Message, (void *)&dl_dcch_msg);
+  }
+
+  enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_DCCH_Message,
+                                   NULL,
+                                   (void *)&dl_dcch_msg,
+                                   buffer,
+                                   100);
+
+  if(enc_rval.encoded == -1) {
+    LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n",
+          enc_rval.failed_type->name, enc_rval.encoded);
+    return -1;
+  }
+
+  LOG_D(RRC,"[eNB %d] securityModeCommand for UE %x Encoded %zd bits (%zd bytes)\n",
+        ctxt_pP->module_id,
+        ctxt_pP->rnti,
+        enc_rval.encoded,
+        (enc_rval.encoded+7)/8);
+
+  if (enc_rval.encoded==-1) {
+    LOG_E(RRC,"[eNB %d] ASN1 : securityModeCommand encoding failed for UE %x\n",
+	  ctxt_pP->module_id,
+	  ctxt_pP->rnti);
+    return(-1);
+  }
+
+  //  rrc_ue_process_ueCapabilityEnquiry(0,1000,&dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry,0);
+  //  exit(-1);
+  return((enc_rval.encoded+7)/8);
+}
+
+//------------------------------------------------------------------------------
+uint8_t do_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP,
+				uint8_t               *const buffer,
+				const uint8_t                Transaction_id)
+//------------------------------------------------------------------------------
+{
+  LTE_DL_DCCH_Message_t dl_dcch_msg;
+  LTE_RAT_Type_t rat=LTE_RAT_Type_eutra;
+  asn_enc_rval_t enc_rval;
+  memset(&dl_dcch_msg,0,sizeof(LTE_DL_DCCH_Message_t));
+  dl_dcch_msg.message.present           = LTE_DL_DCCH_MessageType_PR_c1;
+  dl_dcch_msg.message.choice.c1.present = LTE_DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry;
+  dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.rrc_TransactionIdentifier = Transaction_id;
+  dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.present = LTE_UECapabilityEnquiry__criticalExtensions_PR_c1;
+  dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.choice.c1.present =
     LTE_UECapabilityEnquiry__criticalExtensions__c1_PR_ueCapabilityEnquiry_r8;
   dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list.count=0;
   ASN_SEQUENCE_ADD(&dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list,
-                   &rat);
+		   &rat);
 
   if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
     xer_fprint(stdout, &asn_DEF_LTE_DL_DCCH_Message, (void *)&dl_dcch_msg);
@@ -1990,44 +3242,189 @@ do_UECapabilityEnquiry(
 
   if (enc_rval.encoded==-1) {
     LOG_E(RRC,"[eNB %d] ASN1 : UECapabilityRequest encoding failed for UE %x\n",
-          ctxt_pP->module_id,
-          ctxt_pP->rnti);
+	  ctxt_pP->module_id,
+	  ctxt_pP->rnti);
     return(-1);
   }
 
   return((enc_rval.encoded+7)/8);
 }
 
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+uint16_t do_RRCConnectionReconfiguration_BR(const protocol_ctxt_t*        const ctxt_pP,
+					    uint8_t                            *buffer,
+					    uint8_t                             Transaction_id,
+					    LTE_SRB_ToAddModList_t                 *SRB_list,
+					    LTE_DRB_ToAddModList_t                 *DRB_list,
+					    LTE_DRB_ToReleaseList_t                *DRB_list2,
+					    struct LTE_SPS_Config                  *sps_Config,
+					    struct LTE_PhysicalConfigDedicated     *physicalConfigDedicated,
+					    LTE_MeasObjectToAddModList_t           *MeasObj_list,
+					    LTE_ReportConfigToAddModList_t         *ReportConfig_list,
+					    LTE_QuantityConfig_t                   *quantityConfig,
+					    LTE_MeasIdToAddModList_t               *MeasId_list,
+					    LTE_MAC_MainConfig_t                   *mac_MainConfig,
+					    LTE_MeasGapConfig_t                    *measGapConfig,
+					    LTE_MobilityControlInfo_t              *mobilityInfo,
+					    struct LTE_MeasConfig__speedStatePars  *speedStatePars,
+					    LTE_RSRP_Range_t                       *rsrp,
+					    LTE_C_RNTI_t                           *cba_rnti,
+					    struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *dedicatedInfoNASList,
+					    LTE_SCellToAddMod_r10_t  *SCell_config)
+{
+  asn_enc_rval_t enc_rval;
+
+  LTE_DL_DCCH_Message_t dl_dcch_msg;
+  LTE_RRCConnectionReconfiguration_t *rrcConnectionReconfiguration;
+
+
+  memset(&dl_dcch_msg,0,sizeof(LTE_DL_DCCH_Message_t));
+
+  dl_dcch_msg.message.present           = LTE_DL_DCCH_MessageType_PR_c1;
+  dl_dcch_msg.message.choice.c1.present = LTE_DL_DCCH_MessageType__c1_PR_rrcConnectionReconfiguration;
+  rrcConnectionReconfiguration          = &dl_dcch_msg.message.choice.c1.choice.rrcConnectionReconfiguration;
+
+  // RRCConnectionReconfiguration
+  rrcConnectionReconfiguration->rrc_TransactionIdentifier = Transaction_id;
+  rrcConnectionReconfiguration->criticalExtensions.present = LTE_RRCConnectionReconfiguration__criticalExtensions_PR_c1;
+  rrcConnectionReconfiguration->criticalExtensions.choice.c1.present =LTE_RRCConnectionReconfiguration__criticalExtensions__c1_PR_rrcConnectionReconfiguration_r8 ;
+
+  rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated = CALLOC(1,
+																	  sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated));
+  rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList = SRB_list;
+  rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList = DRB_list;
+  rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToReleaseList = DRB_list2;
+  rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->sps_Config = sps_Config;
+  rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->physicalConfigDedicated = physicalConfigDedicated;
+  physicalConfigDedicated->cqi_ReportConfig = CALLOC(1, sizeof(struct LTE_CQI_ReportConfig));
+  physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic = CALLOC(1, sizeof(LTE_CQI_ReportModeAperiodic_t));
+  *physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic = LTE_CQI_ReportModeAperiodic_rm20;
+  physicalConfigDedicated->cqi_ReportConfig->nomPDSCH_RS_EPRE_Offset = 0;
+
+  if (mac_MainConfig!=NULL) {
+    rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->mac_MainConfig = CALLOC(1,
+																			    sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->mac_MainConfig));
+    rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->mac_MainConfig->present
+      =LTE_RadioResourceConfigDedicated__mac_MainConfig_PR_explicitValue;
+    memcpy(&rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->mac_MainConfig->choice.explicitValue,
+	   mac_MainConfig,
+	   sizeof(*mac_MainConfig));
+  } else {
+    rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->mac_MainConfig=NULL;
+  }
+
+  if (MeasId_list != NULL) {
+    rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig           = CALLOC(1,
+																    sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig));
+    memset((void*)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig,
+	   0, sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig));
+
+    rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->reportConfigToAddModList = ReportConfig_list;
+    rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measIdToAddModList       = MeasId_list;
+    rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measObjectToAddModList   = MeasObj_list;
+
+    if (quantityConfig!=NULL) {
+      rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->quantityConfig = CALLOC(1,
+																	    sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->quantityConfig));
+      memcpy((void *)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->quantityConfig,
+	     (void *)quantityConfig,
+	     sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->quantityConfig));
+    } else {
+      rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->quantityConfig = NULL;
+    }
+
+    if(speedStatePars != NULL) {
+      rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->speedStatePars = CALLOC(1,
+																	    sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->speedStatePars));
+      memcpy((void *)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->speedStatePars,
+	     (void *)speedStatePars,sizeof(*speedStatePars));
+    } else {
+      rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->speedStatePars = NULL;
+    }
+
+    rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->s_Measure= rsrp;
+  } else {
+    rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig = NULL;
+  }
+
+  if (mobilityInfo !=NULL) {
+    rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo = CALLOC(1,
+																   sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo));
+    memcpy((void*)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo, (void*)mobilityInfo,
+	   sizeof(LTE_MobilityControlInfo_t));
+
+  } else {
+    rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo  = NULL;
+  }
+
+  rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.dedicatedInfoNASList = dedicatedInfoNASList;
+  rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.securityConfigHO     = NULL;
+
+  enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_DCCH_Message,
+				   NULL,
+				   (void*)&dl_dcch_msg,
+				   buffer,
+				   RRC_BUF_SIZE);
+  AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed %s, %lu!\n",
+	       enc_rval.failed_type->name, enc_rval.encoded);
+
+#ifdef XER_PRINT
+  xer_fprint(stdout,&asn_DEF_DL_DCCH_Message,(void*)&dl_dcch_msg);
+#endif
+
+#if defined(ENABLE_ITTI)
+# if !defined(DISABLE_XER_SPRINT)
+  {
+    char        message_string[30000];
+    size_t      message_string_size;
+
+    if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_LTE_DL_DCCH_Message, (void *) &dl_dcch_msg)) > 0) {
+      MessageDef *msg_p;
+
+      msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB, RRC_DL_DCCH, message_string_size + sizeof (IttiMsgText));
+      msg_p->ittiMsg.rrc_dl_dcch.size = message_string_size;
+      memcpy(&msg_p->ittiMsg.rrc_dl_dcch.text, message_string, message_string_size);
+
+      itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p);
+    }
+  }
+# endif
+#endif
+
+
+  LOG_I(RRC,"RRCConnectionReconfiguration Encoded %d bits (%d bytes)\n",(int)enc_rval.encoded,(int)(enc_rval.encoded+7)/8);
+
+  return((enc_rval.encoded+7)/8);
+}
+#endif
+
 //------------------------------------------------------------------------------
-uint16_t
-do_RRCConnectionReconfiguration(
-  const protocol_ctxt_t        *const ctxt_pP,
-  uint8_t                            *buffer,
-  uint8_t                             Transaction_id,
-  LTE_SRB_ToAddModList_t                 *SRB_list,
-  LTE_DRB_ToAddModList_t                 *DRB_list,
-  LTE_DRB_ToReleaseList_t                *DRB_list2,
-  struct LTE_SPS_Config                  *sps_Config,
-  struct LTE_PhysicalConfigDedicated     *physicalConfigDedicated,
-  LTE_MeasObjectToAddModList_t           *MeasObj_list,
-  LTE_ReportConfigToAddModList_t         *ReportConfig_list,
-  LTE_QuantityConfig_t                   *quantityConfig,
-  LTE_MeasIdToAddModList_t               *MeasId_list,
-  LTE_MAC_MainConfig_t                   *mac_MainConfig,
-  LTE_MeasGapConfig_t                    *measGapConfig,
-  LTE_MobilityControlInfo_t              *mobilityInfo,
-  struct LTE_MeasConfig__speedStatePars  *speedStatePars,
-  LTE_RSRP_Range_t                       *rsrp,
-  LTE_C_RNTI_t                           *cba_rnti,
-  struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList
-  *dedicatedInfoNASList,
-  LTE_SL_CommConfig_r12_t                *sl_CommConfig,
-  LTE_SL_DiscConfig_r12_t                *sl_DiscConfig
+uint16_t do_RRCConnectionReconfiguration(const protocol_ctxt_t        *const ctxt_pP,
+					 uint8_t                            *buffer,
+					 uint8_t                             Transaction_id,
+					 LTE_SRB_ToAddModList_t                 *SRB_list,
+					 LTE_DRB_ToAddModList_t                 *DRB_list,
+					 LTE_DRB_ToReleaseList_t                *DRB_list2,
+					 struct LTE_SPS_Config                  *sps_Config,
+					 struct LTE_PhysicalConfigDedicated     *physicalConfigDedicated,
+					 LTE_MeasObjectToAddModList_t           *MeasObj_list,
+					 LTE_ReportConfigToAddModList_t         *ReportConfig_list,
+					 LTE_QuantityConfig_t                   *quantityConfig,
+					 LTE_MeasIdToAddModList_t               *MeasId_list,
+					 LTE_MAC_MainConfig_t                   *mac_MainConfig,
+					 LTE_MeasGapConfig_t                    *measGapConfig,
+					 LTE_MobilityControlInfo_t              *mobilityInfo,
+					 struct LTE_MeasConfig__speedStatePars  *speedStatePars,
+					 LTE_RSRP_Range_t                       *rsrp,
+					 LTE_C_RNTI_t                           *cba_rnti,
+					 struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList
+					 *dedicatedInfoNASList,
+					 LTE_SL_CommConfig_r12_t                *sl_CommConfig,
+					 LTE_SL_DiscConfig_r12_t                *sl_DiscConfig
 #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
-  , LTE_SCellToAddMod_r10_t  *SCell_config
+					 , LTE_SCellToAddMod_r10_t  *SCell_config
 #endif
-
-)
+					 )
 //------------------------------------------------------------------------------
 {
   asn_enc_rval_t enc_rval;
@@ -2042,7 +3439,7 @@ do_RRCConnectionReconfiguration(
   rrcConnectionReconfiguration->criticalExtensions.present = LTE_RRCConnectionReconfiguration__criticalExtensions_PR_c1;
   rrcConnectionReconfiguration->criticalExtensions.choice.c1.present = LTE_RRCConnectionReconfiguration__criticalExtensions__c1_PR_rrcConnectionReconfiguration_r8 ;
   rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated = CALLOC(1,
-      sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated));
+																	  sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated));
   rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList = SRB_list;
   rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList = DRB_list;
   rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToReleaseList = DRB_list2;
@@ -2054,12 +3451,12 @@ do_RRCConnectionReconfiguration(
 
   if (mac_MainConfig!=NULL) {
     rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->mac_MainConfig = CALLOC(1,
-        sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->mac_MainConfig));
+																			    sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->mac_MainConfig));
     rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->mac_MainConfig->present
       =LTE_RadioResourceConfigDedicated__mac_MainConfig_PR_explicitValue;
     memcpy(&rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->mac_MainConfig->choice.explicitValue,
-           mac_MainConfig,
-           sizeof(*mac_MainConfig));
+	   mac_MainConfig,
+	   sizeof(*mac_MainConfig));
   } else {
     rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->mac_MainConfig=NULL;
   }
@@ -2069,25 +3466,26 @@ do_RRCConnectionReconfiguration(
         sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig));
     memset((void *)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig,
            0, sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig));
+
     rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->reportConfigToAddModList = ReportConfig_list;
     rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measIdToAddModList       = MeasId_list;
     rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measObjectToAddModList   = MeasObj_list;
 
     if (quantityConfig!=NULL) {
       rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->quantityConfig = CALLOC(1,
-          sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->quantityConfig));
+																	    sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->quantityConfig));
       memcpy((void *)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->quantityConfig,
-             (void *)quantityConfig,
-             sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->quantityConfig));
+	     (void *)quantityConfig,
+	     sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->quantityConfig));
     } else {
       rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->quantityConfig = NULL;
     }
 
     if(speedStatePars != NULL) {
       rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->speedStatePars = CALLOC(1,
-          sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->speedStatePars));
+																	    sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->speedStatePars));
       memcpy((void *)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->speedStatePars,
-             (void *)speedStatePars,sizeof(*speedStatePars));
+	     (void *)speedStatePars,sizeof(*speedStatePars));
     } else {
       rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->speedStatePars = NULL;
     }
@@ -2356,10 +3754,8 @@ do_RRCConnectionReestablishment(
 }
 
 //------------------------------------------------------------------------------
-uint8_t
-do_RRCConnectionReestablishmentReject(
-  uint8_t                    Mod_id,
-  uint8_t                   *const buffer)
+uint8_t do_RRCConnectionReestablishmentReject(uint8_t                    Mod_id,
+					      uint8_t                   *const buffer)
 //------------------------------------------------------------------------------
 {
   asn_enc_rval_t enc_rval;
@@ -2394,10 +3790,8 @@ do_RRCConnectionReestablishmentReject(
 }
 
 //------------------------------------------------------------------------------
-uint8_t
-do_RRCConnectionReject(
-  uint8_t                    Mod_id,
-  uint8_t                   *const buffer)
+uint8_t do_RRCConnectionReject(uint8_t                    Mod_id,
+			       uint8_t                   *const buffer)
 //------------------------------------------------------------------------------
 {
   asn_enc_rval_t enc_rval;
@@ -2434,10 +3828,10 @@ do_RRCConnectionReject(
   return((enc_rval.encoded+7)/8);
 }
 
-uint8_t do_RRCConnectionRelease(
-  uint8_t                             Mod_id,
-  uint8_t                            *buffer,
-  uint8_t                             Transaction_id) {
+uint8_t do_RRCConnectionRelease(uint8_t                             Mod_id,
+				uint8_t                            *buffer,
+				uint8_t                             Transaction_id)
+{
   asn_enc_rval_t enc_rval;
   LTE_DL_DCCH_Message_t dl_dcch_msg;
   LTE_RRCConnectionRelease_t *rrcConnectionRelease;
@@ -2454,6 +3848,7 @@ uint8_t do_RRCConnectionRelease(
   rrcConnectionRelease->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r8.idleModeMobilityControlInfo = NULL;
   rrcConnectionRelease->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r8.nonCriticalExtension=CALLOC(1,
       sizeof(*rrcConnectionRelease->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r8.nonCriticalExtension));
+
   enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_DCCH_Message,
                                    NULL,
                                    (void *)&dl_dcch_msg,
@@ -2605,6 +4000,7 @@ uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_
   measurementReport->criticalExtensions.choice.c1.present=LTE_MeasurementReport__criticalExtensions__c1_PR_measurementReport_r8;
   measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.nonCriticalExtension=CALLOC(1,
       sizeof(*measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.nonCriticalExtension));
+
   measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measId=measid;
 #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
   measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultPCell.rsrpResult=rsrp_s;
@@ -2908,7 +4304,8 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) {
                                    &UECapability.sdu[0],
                                    MAX_UE_CAPABILITY_SIZE);
   AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n",
-               enc_rval.failed_type->name, enc_rval.encoded);
+	       enc_rval.failed_type->name, enc_rval.encoded);
+
   UECapability.sdu_size = (enc_rval.encoded + 7) / 8;
   LOG_I(PHY, "[RRC]UE Capability encoded, %d bytes (%zd bits)\n",
         UECapability.sdu_size, enc_rval.encoded + 7);
diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg.h b/openair2/RRC/LTE/MESSAGES/asn1_msg.h
index 2d0c6ba7b6298a8ffe700b12ad3e08a62d79ed41..819f90c33639f3308788f8cec2c604fc9ba9b945 100644
--- a/openair2/RRC/LTE/MESSAGES/asn1_msg.h
+++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.h
@@ -64,19 +64,31 @@ uint8_t get_adjacent_cell_mod_id(uint16_t phyCellId);
 @param phich_duration PHICH duration parameter
 @param frame radio frame number
 @return size of encoded bit stream in bytes*/
-uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich_Resource, uint32_t phich_duration, uint32_t frame);
+uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich_Resource, uint32_t phich_duration, uint32_t frame
+#if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0))
+	       , uint32_t schedulingInfoSIB1
+#endif
+	       );
 
 /**
 \brief Generate configuration for SIB1 (eNB).
 @param carrier pointer to Carrier information
 @param Mod_id Instance of eNB
 @param Component carrier Component carrier to configure
-@param configuration Pointer Configuration Request structure
+@param configuration Pointer Configuration Request structure  
+@param br_flag Do for BL/CE UE configuration
 @return size of encoded bit stream in bytes*/
 
-uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,int Mod_id,int CC_id, RrcConfigurationReq *configuration
+uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,int Mod_id,int CC_id
+#if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0))
+                , BOOLEAN_t brOption
+#endif
+#if defined(ENABLE_ITTI)
+                ,RrcConfigurationReq *configuration
+#endif
                );
 
+
 /**
 \brief Generate a default configuration for SIB2/SIB3 in one System Information PDU (eNB).
 @param Mod_id Index of eNB (used to derive some parameters)
@@ -90,6 +102,9 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,int Mod_id,int CC_id, RrcConfigu
 
 uint8_t do_SIB23(uint8_t Mod_id,
                  int CC_id
+#if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0))
+		 , BOOLEAN_t brOption
+#endif
 #if defined(ENABLE_ITTI)
   , RrcConfigurationReq *configuration
 #endif
@@ -152,7 +167,47 @@ do_RRCConnectionSetup(
   LTE_SRB_ToAddModList_t             **SRB_configList,
   struct LTE_PhysicalConfigDedicated **physicalConfigDedicated
 );
+#if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0))
+uint8_t
+do_RRCConnectionSetup_BR(
+	const protocol_ctxt_t*     const ctxt_pP,
+	rrc_eNB_ue_context_t*      const ue_context_pP,
+	int                              CC_id,
+	uint8_t*                   const buffer,
+	const uint8_t                    transmission_mode,
+	const uint8_t                    Transaction_id,
+	LTE_SRB_ToAddModList_t**             SRB_configList,
+	struct LTE_PhysicalConfigDedicated** physicalConfigDedicated
+);
+#endif
+
 
+
+#if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0))
+uint16_t
+do_RRCConnectionReconfiguration_BR(
+                   const protocol_ctxt_t*        const ctxt_pP,
+                   uint8_t                            *buffer,
+                   uint8_t                             Transaction_id,
+                   LTE_SRB_ToAddModList_t                 *SRB_list,
+                   LTE_DRB_ToAddModList_t                 *DRB_list,
+                   LTE_DRB_ToReleaseList_t                *DRB_list2,
+                   struct LTE_SPS_Config                  *sps_Config,
+                   struct LTE_PhysicalConfigDedicated     *physicalConfigDedicated,
+                   LTE_MeasObjectToAddModList_t           *MeasObj_list,
+                   LTE_ReportConfigToAddModList_t         *ReportConfig_list,
+                   LTE_QuantityConfig_t                   *quantityConfig,
+                   LTE_MeasIdToAddModList_t               *MeasId_list,
+                   LTE_MAC_MainConfig_t                   *mac_MainConfig,
+                   LTE_MeasGapConfig_t                    *measGapConfig,
+                   LTE_MobilityControlInfo_t              *mobilityInfo,
+                   struct LTE_MeasConfig__speedStatePars  *speedStatePars,
+                   LTE_RSRP_Range_t                       *rsrp,
+                   LTE_C_RNTI_t                           *cba_rnti,
+                   struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *dedicatedInfoNASList,
+                   LTE_SCellToAddMod_r10_t  *SCell_config
+                   );
+#endif
 /**
 \brief Generate an RRCConnectionReconfiguration DL-DCCH-Message (eNB).  This routine configures SRBToAddMod (SRB2) and one DRBToAddMod
 (DRB3).  PhysicalConfigDedicated is not updated.
diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-860.txt b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-860.txt
old mode 100755
new mode 100644
diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-a20.txt b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-a20.txt
old mode 100755
new mode 100644
diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-ah0.txt b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-ah0.txt
old mode 100755
new mode 100644
diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-c60.txt b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-c60.txt
old mode 100755
new mode 100644
diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-86.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-86.asn
old mode 100755
new mode 100644
diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-a20.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-a20.asn
old mode 100755
new mode 100644
diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20-lola.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20-lola.asn
old mode 100755
new mode 100644
diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn
old mode 100755
new mode 100644
diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn.orig b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn.orig
old mode 100755
new mode 100644
diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-86.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-86.asn
old mode 100755
new mode 100644
diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-a20.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-a20.asn
old mode 100755
new mode 100644
diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-10.21.0.asn1 b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-10.21.0.asn1
old mode 100755
new mode 100644
diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-11.18.0.asn1 b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-11.18.0.asn1
old mode 100755
new mode 100644
diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-12.16.0.asn1 b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-12.16.0.asn1
old mode 100755
new mode 100644
diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-13.9.1.asn1 b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-13.9.1.asn1
old mode 100755
new mode 100644
diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-14.4.0.asn1 b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-14.4.0.asn1
old mode 100755
new mode 100644
diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-14.6.2.asn1 b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-14.6.2.asn1
old mode 100755
new mode 100644
diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-14.7.0.asn1 b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-14.7.0.asn1
old mode 100755
new mode 100644
diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-15.1.0.asn1 b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-15.1.0.asn1
old mode 100755
new mode 100644
diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-15.2.1.asn1 b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-15.2.1.asn1
old mode 100755
new mode 100644
diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-15.2.2.asn1 b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-15.2.2.asn1
old mode 100755
new mode 100644
diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-8.21.0.asn1 b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-8.21.0.asn1
old mode 100755
new mode 100644
diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-9.18.0.asn1 b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-9.18.0.asn1
old mode 100755
new mode 100644
diff --git a/openair2/RRC/LTE/rrc_defs.h b/openair2/RRC/LTE/rrc_defs.h
index 9d428830860a5d80127476ad958141f0143ad295..f28b34982b393429b39bab03a35bf28ff4dac129 100644
--- a/openair2/RRC/LTE/rrc_defs.h
+++ b/openair2/RRC/LTE/rrc_defs.h
@@ -636,23 +636,24 @@ typedef struct {
   uint8_t                           *SIB23_BR;
   uint8_t                           sizeof_SIB23_BR;
 #endif
-  int                               physCellId;
-  int                               Ncp;
-  int                               p_eNB;
-  uint32_t                          dl_CarrierFreq;
-  uint32_t                          ul_CarrierFreq;
-  uint32_t                          pbch_repetition;
-  LTE_BCCH_BCH_Message_t            mib;
-  LTE_BCCH_DL_SCH_Message_t         siblock1;
-  LTE_BCCH_DL_SCH_Message_t         systemInformation;
-  //  SystemInformation_t           systemInformation;
-  LTE_SystemInformationBlockType1_t *sib1;
-  LTE_SystemInformationBlockType2_t *sib2;
-  LTE_SystemInformationBlockType3_t *sib3;
+  int                                   physCellId;
+  int                                   Ncp;
+  int                                   p_eNB;
+  uint32_t                              dl_CarrierFreq;
+  uint32_t                              ul_CarrierFreq;
+  uint32_t                              pbch_repetition;
+  LTE_BCCH_BCH_Message_t                mib;
+  LTE_BCCH_DL_SCH_Message_t             siblock1;
+  LTE_BCCH_DL_SCH_Message_t             siblock1_BR;
+  LTE_BCCH_DL_SCH_Message_t             systemInformation;
+  LTE_BCCH_DL_SCH_Message_t             systemInformation_BR;
+  //  SystemInformation_t               systemInformation;
+  LTE_SystemInformationBlockType1_t     *sib1;
+  LTE_SystemInformationBlockType2_t     *sib2;
+  LTE_SystemInformationBlockType3_t     *sib3;
 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
-  LTE_SystemInformationBlockType1_t *sib1_BR;
-  LTE_SystemInformationBlockType2_t *sib2_BR;
-  LTE_SystemInformationBlockType2_t *sib3_BR;
+  LTE_SystemInformationBlockType1_t     *sib1_BR;
+  LTE_SystemInformationBlockType2_t     *sib2_BR;
 #endif
 #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0))
   LTE_SystemInformationBlockType13_r9_t *sib13;
diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c
index d0a6693429aa77c9fb7241464eba6bfcafeeeb0d..792299f4ae47d7f5fdbb03bbf9f30bf889955672 100644
--- a/openair2/RRC/LTE/rrc_eNB.c
+++ b/openair2/RRC/LTE/rrc_eNB.c
@@ -141,12 +141,9 @@ openair_rrc_on(
 //-----------------------------------------------------------------------------
 static void
 init_SI(
-  const protocol_ctxt_t *const ctxt_pP,
-  const int              CC_id
-#if defined(ENABLE_ITTI)
-  ,
-  RrcConfigurationReq *configuration
-#endif
+  const protocol_ctxt_t* const ctxt_pP,
+  const int              CC_id,
+  RrcConfigurationReq * configuration
 )
 //-----------------------------------------------------------------------------
 {
@@ -167,40 +164,81 @@ init_SI(
 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
   RC.rrc[ctxt_pP->module_id]->carrier[CC_id].pbch_repetition = configuration->pbch_repetition[CC_id];
 #endif
-  LOG_I(RRC, "Configuring MIB (N_RB_DL %d,phich_Resource %d,phich_Duration %d)\n",
-        (int)configuration->N_RB_DL[CC_id],
-        (int)configuration->phich_resource[CC_id],
-        (int)configuration->phich_duration[CC_id]);
+  LOG_I(RRC, "Configuring MIB (N_RB_DL %d,phich_Resource %d,phich_Duration %d)\n", 
+	configuration->N_RB_DL[CC_id],
+	(int)configuration->radioresourceconfig[CC_id].phich_resource,
+	(int)configuration->radioresourceconfig[CC_id].phich_duration);
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+  LOG_I(RRC, "configuration->schedulingInfoSIB1_BR_r13[CC_id] %d\n",(int)configuration->schedulingInfoSIB1_BR_r13[CC_id]);
+#endif
   do_MIB(&RC.rrc[ctxt_pP->module_id]->carrier[CC_id],
-#ifdef ENABLE_ITTI
-         configuration->N_RB_DL[CC_id],
-         configuration->phich_resource[CC_id],
-         configuration->phich_duration[CC_id]
-#else
-         50,0,0
+	 configuration->N_RB_DL[CC_id],
+	 (int)configuration->radioresourceconfig[CC_id].phich_resource,
+	 (int)configuration->radioresourceconfig[CC_id].phich_duration,
+	 0
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+	 ,configuration->schedulingInfoSIB1_BR_r13[CC_id]
 #endif
-         ,0);
+	 );
+  
+
+
   RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB1 = 0;
   RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB23 = 0;
   RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB1 = (uint8_t *) malloc16(32);
   AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB1!=NULL,PROTOCOL_RRC_CTXT_FMT" init_SI: FATAL, no memory for SIB1 allocated\n",
-              PROTOCOL_RRC_CTXT_ARGS(ctxt_pP));
+	      PROTOCOL_RRC_CTXT_ARGS(ctxt_pP));
+
   RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB1 = do_SIB1(&RC.rrc[ctxt_pP->module_id]->carrier[CC_id],ctxt_pP->module_id,CC_id
-#if defined(ENABLE_ITTI)
-      , configuration
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+								   ,FALSE
 #endif
-                                                                  );
+								   , configuration
+								   );
+
   AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB1 != 255,"FATAL, RC.rrc[enb_mod_idP].carrier[CC_id].sizeof_SIB1 == 255");
-  RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB23 = (uint8_t *) malloc16(64);
+
+  
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+  RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB1_BR = 0;
+  if (configuration->schedulingInfoSIB1_BR_r13[CC_id]>0) {
+    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB1_BR = (uint8_t*) malloc16(32);
+    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB1_BR = do_SIB1(&RC.rrc[ctxt_pP->module_id]->carrier[CC_id],ctxt_pP->module_id,CC_id
+									,TRUE
+									, configuration
+									);
+  }
+#endif
+  
+  RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB23 = (uint8_t*) malloc16(64);
   AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB23!=NULL,"cannot allocate memory for SIB");
   RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB23 = do_SIB23(
-        ctxt_pP->module_id,
-        CC_id
-#if defined(ENABLE_ITTI)
-        , configuration
+								     ctxt_pP->module_id,
+								     CC_id
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+								     ,FALSE
 #endif
-      );
+								     , configuration
+								     );
+
   AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB23 != 255,"FATAL, RC.rrc[mod].carrier[CC_id].sizeof_SIB23 == 255");
+
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+  RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB23_BR = 0;
+  if (configuration->schedulingInfoSIB1_BR_r13[CC_id]>0) {
+    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB23_BR = (uint8_t*) malloc16(64);
+    AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB23_BR!=NULL,"cannot allocate memory for SIB");
+    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB23_BR = do_SIB23(
+									  ctxt_pP->module_id,
+                                      CC_id
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+                                      ,TRUE
+#endif
+                                      ,configuration
+                );
+  }
+#endif
+
   LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" SIB2/3 Contents (partial)\n",
         PROTOCOL_RRC_CTXT_ARGS(ctxt_pP));
   LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.n_SB = %ld\n",
@@ -232,9 +270,10 @@ init_SI(
         (int)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
         ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled);
   LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.cyclicShift  = %ld\n",
-        PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-        RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
-        ul_ReferenceSignalsPUSCH.cyclicShift);
+	PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+	RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon.
+	ul_ReferenceSignalsPUSCH.cyclicShift);
+
 #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
 
   if (RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MBMS_flag > 0) {
@@ -256,7 +295,7 @@ init_SI(
             RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationOffset);
     }
 
-#if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0))
+
 
     //   SIB13
     for (i = 0; i < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.count; i++) {
@@ -271,78 +310,85 @@ init_SI(
             PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
             RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.array[i]->mcch_Config_r9.mcch_Offset_r9);
     }
-
-#endif
-  } else memset((void *)&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13,0,sizeof(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13));
+  }
+  else memset((void*)&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13,0,sizeof(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13));
 
   //TTN - SIB 18
-  for (int j = 0; j < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.count; j++) {
-    LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Contents of SIB18 %d/%d \n",
-          PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          j+1,
-          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.count);
-    LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 rxPool_sc_CP_Len: %ld \n",
-          PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_CP_Len_r12);
-    LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 sc_Period_r12: %ld \n",
-          PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_Period_r12);
-    LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 data_CP_Len_r12: %ld \n",
-          PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->data_CP_Len_r12);
-    LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_Num_r12: %ld \n",
-          PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_Num_r12);
-    LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_Start_r12: %ld \n",
-          PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_Start_r12);
-    LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_End_r12: %ld \n",
-          PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_End_r12);
-    LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 offsetIndicator: %ld \n",
-          PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12);
-    LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 subframeBitmap_choice_bs_buf: %s \n",
-          PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf);
-  }
+  if (configuration->SL_configured>0) {
+    for (int j = 0; j < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.count; j++) {
+      LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Contents of SIB18 %d/%d \n",
+	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+	    j+1,
+	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.count);
+      LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 rxPool_sc_CP_Len: %ld \n",
+	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_CP_Len_r12);
+      LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 sc_Period_r12: %ld \n",
+	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_Period_r12);
+      LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 data_CP_Len_r12: %ld \n",
+	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->data_CP_Len_r12);
+      LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_Num_r12: %ld \n",
+	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_Num_r12);
+      LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_Start_r12: %ld \n",
+	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_Start_r12);
+      LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_End_r12: %ld \n",
+	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_End_r12);
+      LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 offsetIndicator: %ld \n",
+	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12);
+      LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 subframeBitmap_choice_bs_buf: %s \n",
+	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf);
+      
+    }
+
+
 
-  //TTN - SIB 19
-  for (int j = 0; j < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.count; j++) {
-    LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Contents of SIB19 %d/%d \n",
-          PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          j+1,
-          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.count);
-    LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 cp_Len_r12: %ld \n",
-          PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->cp_Len_r12);
-    LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 discPeriod_r12: %ld \n",
-          PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->discPeriod_r12);
-    LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 numRetx_r12: %ld \n",
-          PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->numRetx_r12);
-    LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 numRepetition_r12: %ld \n",
-          PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->numRepetition_r12);
-    LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_Num_r12: %ld \n",
-          PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_Num_r12);
-    LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_Start_r12: %ld \n",
-          PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_Start_r12);
-    LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_End_r12: %ld \n",
-          PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_End_r12);
-    LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 offsetIndicator: %ld \n",
-          PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12);
-    LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 subframeBitmap_choice_bs_buf: %s \n",
-          PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
-          RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf);
+
+    for (int j = 0; j < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.count; j++) {
+      LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Contents of SIB19 %d/%d \n",
+	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+	    j+1,
+	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.count);
+      LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 cp_Len_r12: %ld \n",
+	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->cp_Len_r12);
+      LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 discPeriod_r12: %ld \n",
+	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->discPeriod_r12);
+      LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 numRetx_r12: %ld \n",
+	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->numRetx_r12);
+      LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 numRepetition_r12: %ld \n",
+	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->numRepetition_r12);
+      LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_Num_r12: %ld \n",
+	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_Num_r12);
+      LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_Start_r12: %ld \n",
+	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_Start_r12);
+      LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_End_r12: %ld \n",
+	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_End_r12);
+      LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 offsetIndicator: %ld \n",
+	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12);
+      LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 subframeBitmap_choice_bs_buf: %s \n",
+	    PROTOCOL_RRC_CTXT_ARGS(ctxt_pP),
+	    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf);
+      
+    }
   }
 
-#endif
+#endif // (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))    
+
+
   LOG_D(RRC,
         PROTOCOL_RRC_CTXT_FMT" RRC_UE --- MAC_CONFIG_REQ (SIB1.tdd & SIB2 params) ---> MAC_UE\n",
         PROTOCOL_RRC_CTXT_ARGS(ctxt_pP));
@@ -350,17 +396,32 @@ init_SI(
 
   if ((RC.rrc[ctxt_pP->module_id]->carrier[CC_id].mib.message.schedulingInfoSIB1_BR_r13>0) &&
       (RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR!=NULL)) {
-    AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension!=NULL,
-                "sib2_br->nonCriticalExtension is null (v8.9)\n");
-    AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension!=NULL,
-                "sib2_br->nonCriticalExtension is null (v9.2)\n");
-    AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL,
-                "sib2_br->nonCriticalExtension is null (v11.3)\n");
-    AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL,
-                "sib2_br->nonCriticalExtension is null (v12.5)\n");
-    AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL,
-                "sib2_br->nonCriticalExtension is null (v13.10)\n");
-    sib1_v13ext = RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension;
+
+      AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension!=NULL,
+		  "sib2_br->nonCriticalExtension is null (v8.9)\n");
+      AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension!=NULL,
+		  "sib2_br->nonCriticalExtension is null (v9.2)\n");
+      AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL,
+		  "sib2_br->nonCriticalExtension is null (v11.3)\n");
+      AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL,
+		  "sib2_br->nonCriticalExtension is null (v12.5)\n");
+      AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL,
+		  "sib2_br->nonCriticalExtension is null (v13.10)\n");
+      sib1_v13ext = RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension;
+
+      // Basic Asserts for CE_level0 PRACH configuration
+
+      LTE_RadioResourceConfigCommonSIB_t *radioResourceConfigCommon_BR = &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2_BR->radioResourceConfigCommon;
+      struct LTE_PRACH_ConfigSIB_v1310 *ext4_prach=radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310; 
+      
+      LTE_PRACH_ParametersListCE_r13_t	 *prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13;
+      AssertFatal(prach_ParametersListCE_r13->list.count>0,"prach_ParametersListCE_r13 is empty\n");
+      LTE_PRACH_ParametersCE_r13_t *p = prach_ParametersListCE_r13->list.array[0];
+      AssertFatal(p->prach_StartingSubframe_r13 != NULL, "prach_StartingSubframe_r13 celevel0 is null\n");
+      AssertFatal((1<<p->numRepetitionPerPreambleAttempt_r13)<=(2<<*p->prach_StartingSubframe_r13),
+		  "prachce0->numReptitionPerPreambleAttempt_r13 %d > prach_StartingSubframe_r13 %d\n",
+		  1<<p->numRepetitionPerPreambleAttempt_r13,
+		  2<<*p->prach_StartingSubframe_r13);
   }
 
 #endif
@@ -2823,57 +2884,62 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t *cons
   //TODO: change TM for secondary CC in SCelltoaddmodlist
   if (*physicalConfigDedicated) {
     if ((*physicalConfigDedicated)->antennaInfo) {
-      (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.transmissionMode = rrc_inst->configuration.ue_TransmissionMode[0];
-      LOG_D(RRC,"Setting transmission mode to %ld+1\n",rrc_inst->configuration.ue_TransmissionMode[0]);
-
-      if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm3) {
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=
-          CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR));
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
-          LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm3;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf= MALLOC(1);
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf[0] = 0xc0;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.size=1;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.bits_unused=6;
-      } else if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm4) {
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=
-          CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR));
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
-          LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm4;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf= MALLOC(1);
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf[0] = 0xfc;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.size=1;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.bits_unused=2;
-      } else if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm5) {
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=
-          CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR));
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
-          LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm5;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf= MALLOC(1);
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf[0] = 0xf0;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.size=1;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.bits_unused=4;
-      } else if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm6) {
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=
-          CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR));
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
-          LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm6;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf= MALLOC(1);
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf[0] = 0xf0;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.size=1;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.bits_unused=4;
+
+      (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.transmissionMode = rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode;
+      LOG_D(RRC,"Setting transmission mode to %ld+1\n",rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode);
+      if (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm3) {
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=     
+	  CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR));
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
+	  LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm3;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf= MALLOC(1);
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf[0] = 0xc0;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.size=1;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.bits_unused=6;
       }
-    } else {
+      else if (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm4) {
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=     
+	  CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR));
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
+	  LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm4;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf= MALLOC(1);
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf[0] = 0xfc;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.size=1;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.bits_unused=2;
+      }
+      else if (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm5) {
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=     
+	  CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR));
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
+	  LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm5;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf= MALLOC(1);
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf[0] = 0xf0;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.size=1;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.bits_unused=4;
+      }
+      else if (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm6) {
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=     
+	  CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR));
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
+	  LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm6;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf= MALLOC(1);
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf[0] = 0xf0;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.size=1;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.bits_unused=4;
+      }
+    }
+    else {
       LOG_E(RRC,"antenna_info not present in physical_config_dedicated. Not reconfiguring!\n");
     }
 
     if ((*physicalConfigDedicated)->cqi_ReportConfig) {
-      if ((rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm4) ||
-          (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm5) ||
-          (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm6)) {
-        //feedback mode needs to be set as well
-        //TODO: I think this is taken into account in the PHY automatically based on the transmission mode variable
-        printf("setting cqi reporting mode to rm31\n");
+
+      if ((rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm4) ||
+	  (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm5) ||
+	  (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm6)) {
+	//feedback mode needs to be set as well
+	//TODO: I think this is taken into account in the PHY automatically based on the transmission mode variable
+	printf("setting cqi reporting mode to rm31\n");
 #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
         *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=LTE_CQI_ReportModeAperiodic_rm31;
 #else
@@ -3457,57 +3523,63 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt
   //TODO: change TM for secondary CC in SCelltoaddmodlist
   if (*physicalConfigDedicated) {
     if ((*physicalConfigDedicated)->antennaInfo) {
-      (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.transmissionMode = rrc_inst->configuration.ue_TransmissionMode[0];
-      LOG_D(RRC,"Setting transmission mode to %ld+1\n",rrc_inst->configuration.ue_TransmissionMode[0]);
-
-      if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm3) {
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=
-          CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR));
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
-          LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm3;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf= MALLOC(1);
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf[0] = 0xc0;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.size=1;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.bits_unused=6;
-      } else if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm4) {
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=
-          CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR));
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
-          LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm4;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf= MALLOC(1);
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf[0] = 0xfc;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.size=1;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.bits_unused=2;
-      } else if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm5) {
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=
-          CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR));
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
-          LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm5;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf= MALLOC(1);
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf[0] = 0xf0;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.size=1;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.bits_unused=4;
-      } else if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm6) {
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=
-          CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR));
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
-          LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm6;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf= MALLOC(1);
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf[0] = 0xf0;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.size=1;
-        (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.bits_unused=4;
+      (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.transmissionMode = rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode;
+      LOG_D(RRC,"Setting transmission mode to %ld+1\n",rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode);
+      if (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm3) {
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=     
+	  CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR));
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
+	  LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm3;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf= MALLOC(1);
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf[0] = 0xc0;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.size=1;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.bits_unused=6;
+      } else if (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm4) {
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=     
+	  CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR));
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
+	  LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm4;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf= MALLOC(1);
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf[0] = 0xfc;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.size=1;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.bits_unused=2;
+      } 
+      else if (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm5) {
+
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=     
+	  CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR));
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
+	  LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm5;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf= MALLOC(1);
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf[0] = 0xf0;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.size=1;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.bits_unused=4;
       }
-    } else {
+      
+      else if (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm6) {
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction=     
+	  CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR));
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present =
+	  LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm6;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf= MALLOC(1);
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf[0] = 0xf0;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.size=1;
+	(*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.bits_unused=4;
+	
+      }
+    }
+    else {
       LOG_E(RRC,"antenna_info not present in physical_config_dedicated. Not reconfiguring!\n");
     }
 
     if ((*physicalConfigDedicated)->cqi_ReportConfig) {
-      if ((rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm4) ||
-          (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm5) ||
-          (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm6)) {
-        //feedback mode needs to be set as well
-        //TODO: I think this is taken into account in the PHY automatically based on the transmission mode variable
-        printf("setting cqi reporting mode to rm31\n");
+      if ((rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm4) ||
+	  (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm5) ||
+	  (rrc_inst->configuration.radioresourceconfig[0].ue_TransmissionMode==LTE_AntennaInfoDedicated__transmissionMode_tm6)) {
+
+	//feedback mode needs to be set as well
+	//TODO: I think this is taken into account in the PHY automatically based on the transmission mode variable
+	printf("setting cqi reporting mode to rm31\n");
 #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
         *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=LTE_CQI_ReportModeAperiodic_rm31;
 #else
@@ -5196,129 +5268,145 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete(
 }
 
 //-----------------------------------------------------------------------------
-void
-rrc_eNB_generate_RRCConnectionSetup(
-  const protocol_ctxt_t *const ctxt_pP,
-  rrc_eNB_ue_context_t          *const ue_context_pP,
-  const int                    CC_id
-)
+void rrc_eNB_generate_RRCConnectionSetup(const protocol_ctxt_t *const ctxt_pP,
+					 rrc_eNB_ue_context_t          *const ue_context_pP,
+					 const int                    CC_id
+					 )
 //-----------------------------------------------------------------------------
 {
+
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+  boolean_t is_mtc = ctxt_pP->brOption;
+#endif
+
   LTE_LogicalChannelConfig_t             *SRB1_logicalChannelConfig;  //,*SRB2_logicalChannelConfig;
   LTE_SRB_ToAddModList_t                **SRB_configList;
   LTE_SRB_ToAddMod_t                     *SRB1_config;
+
   int                                 cnt;
   T(T_ENB_RRC_CONNECTION_SETUP, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
     T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
   SRB_configList = &ue_context_pP->ue_context.SRB_configList;
-  RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size =
-    do_RRCConnectionSetup(ctxt_pP,
-                          ue_context_pP,
-                          CC_id,
-                          (uint8_t *) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload,
-                          (uint8_t) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB, //at this point we do not have the UE capability information, so it can only be TM1 or TM2
-                          rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id),
-                          SRB_configList,
-                          &ue_context_pP->ue_context.physicalConfigDedicated);
-  LOG_DUMPMSG(RRC,DEBUG_RRC,
-              (char *)(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload),
-              RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size,
-              "[MSG] RRC Connection Setup\n");
-
-  // configure SRB1/SRB2, PhysicalConfigDedicated, LTE_MAC_MainConfig for UE
-
-  if (*SRB_configList != NULL) {
-    for (cnt = 0; cnt < (*SRB_configList)->list.count; cnt++) {
-      if ((*SRB_configList)->list.array[cnt]->srb_Identity == 1) {
-        SRB1_config = (*SRB_configList)->list.array[cnt];
-
-        if (SRB1_config->logicalChannelConfig) {
-          if (SRB1_config->logicalChannelConfig->present ==
-              LTE_SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) {
-            SRB1_logicalChannelConfig = &SRB1_config->logicalChannelConfig->choice.explicitValue;
-          } else {
-            SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue;
-          }
-        } else {
-          SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue;
-        }
-
-        LOG_D(RRC,
-              PROTOCOL_RRC_CTXT_UE_FMT" RRC_eNB --- MAC_CONFIG_REQ  (SRB1) ---> MAC_eNB\n",
-              PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
-        rrc_mac_config_req_eNB(
-          ctxt_pP->module_id,
-          ue_context_pP->ue_context.primaryCC_id,
-          0,0,0,0,0,
 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
-          0,
+  if (is_mtc) {
+    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size =
+      do_RRCConnectionSetup_BR(ctxt_pP,
+			       ue_context_pP,
+			       CC_id,
+			       (uint8_t*) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload,
+			       (const uint8_t) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB, //at this point we do not have the UE capability information, so it can only be TM1 or TM2
+			       rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id),
+			       SRB_configList,
+			       &ue_context_pP->ue_context.physicalConfigDedicated);
+  } else 
 #endif
-          ue_context_pP->ue_context.rnti,
-          (LTE_BCCH_BCH_Message_t *) NULL,
-          (LTE_RadioResourceConfigCommonSIB_t *) NULL,
+  {
+    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size =
+      do_RRCConnectionSetup(ctxt_pP,
+			    ue_context_pP,
+			    CC_id,
+			    (uint8_t *) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload,
+			    (uint8_t) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB, //at this point we do not have the UE capability information, so it can only be TM1 or TM2
+			    rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id),
+			    SRB_configList,
+			    &ue_context_pP->ue_context.physicalConfigDedicated);
+    LOG_DUMPMSG(RRC,DEBUG_RRC,
+		(char *)(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload),
+		RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size,
+		"[MSG] RRC Connection Setup\n");
+    
+    // configure SRB1/SRB2, PhysicalConfigDedicated, LTE_MAC_MainConfig for UE
+    
+    if (*SRB_configList != NULL) {
+      for (cnt = 0; cnt < (*SRB_configList)->list.count; cnt++) {
+	if ((*SRB_configList)->list.array[cnt]->srb_Identity == 1) {
+	  SRB1_config = (*SRB_configList)->list.array[cnt];
+	  
+	  if (SRB1_config->logicalChannelConfig) {
+	    if (SRB1_config->logicalChannelConfig->present ==
+		LTE_SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) {
+	      SRB1_logicalChannelConfig = &SRB1_config->logicalChannelConfig->choice.explicitValue;
+	    } else {
+	      SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue;
+	    }
+	  } else {
+	    SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue;
+	  }
+	  
+	  LOG_D(RRC,
+		PROTOCOL_RRC_CTXT_UE_FMT" RRC_eNB --- MAC_CONFIG_REQ  (SRB1) ---> MAC_eNB\n",
+		PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
+	  rrc_mac_config_req_eNB(
+				 ctxt_pP->module_id,
+				 ue_context_pP->ue_context.primaryCC_id,
+				 0,0,0,0,0,
 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
-          (LTE_RadioResourceConfigCommonSIB_t *) NULL,
+				 0,
 #endif
-          ue_context_pP->ue_context.physicalConfigDedicated,
+				 ue_context_pP->ue_context.rnti,
+				 (LTE_BCCH_BCH_Message_t *) NULL,
+				 (LTE_RadioResourceConfigCommonSIB_t *) NULL,
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+				 (LTE_RadioResourceConfigCommonSIB_t *) NULL,
+#endif
+				 ue_context_pP->ue_context.physicalConfigDedicated,
 #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
-          (LTE_SCellToAddMod_r10_t *)NULL,
-          //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL,
-#endif
-          (LTE_MeasObjectToAddMod_t **) NULL,
-          ue_context_pP->ue_context.mac_MainConfig,
-          1,
-          SRB1_logicalChannelConfig,
-          ue_context_pP->ue_context.measGapConfig,
-          (LTE_TDD_Config_t *) NULL,
-          NULL,
-          (LTE_SchedulingInfoList_t *) NULL,
-          0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL
+				 (LTE_SCellToAddMod_r10_t *)NULL,
+				 //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL,
+#endif
+				 (LTE_MeasObjectToAddMod_t **) NULL,
+				 ue_context_pP->ue_context.mac_MainConfig,
+				 1,
+				 SRB1_logicalChannelConfig,
+				 ue_context_pP->ue_context.measGapConfig,
+				 (LTE_TDD_Config_t *) NULL,
+				 NULL,
+				 (LTE_SchedulingInfoList_t *) NULL,
+				 0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL
 #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0))
-          , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL
+				 , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL
 #endif
 #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0))
-          ,
-          (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL
+				 ,
+				 (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL
 #endif
-        );
-        break;
+				 );
+	  break;
+	}
       }
     }
+    
+    MSC_LOG_TX_MESSAGE(
+		       MSC_RRC_ENB,
+		       MSC_RRC_UE,
+		       RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Header, // LG WARNING
+		       RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size,
+		       MSC_AS_TIME_FMT" LTE_RRCConnectionSetup UE %x size %u",
+		       MSC_AS_TIME_ARGS(ctxt_pP),
+		       ue_context_pP->ue_context.rnti,
+		       RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size);
+    LOG_I(RRC,
+	  PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating LTE_RRCConnectionSetup (bytes %d)\n",
+	  PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+	  RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size);
+    //ue_context_pP->ue_context.ue_release_timer_thres=100;
+    // activate release timer, if RRCSetupComplete not received after 100 frames, remove UE
+    ue_context_pP->ue_context.ue_release_timer=1;
+    // remove UE after 10 frames after LTE_RRCConnectionRelease is triggered
+    ue_context_pP->ue_context.ue_release_timer_thres=1000;
   }
-
-  MSC_LOG_TX_MESSAGE(
-    MSC_RRC_ENB,
-    MSC_RRC_UE,
-    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Header, // LG WARNING
-    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size,
-    MSC_AS_TIME_FMT" LTE_RRCConnectionSetup UE %x size %u",
-    MSC_AS_TIME_ARGS(ctxt_pP),
-    ue_context_pP->ue_context.rnti,
-    RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size);
-  LOG_I(RRC,
-        PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating LTE_RRCConnectionSetup (bytes %d)\n",
-        PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-        RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size);
-  //ue_context_pP->ue_context.ue_release_timer_thres=100;
-  // activate release timer, if RRCSetupComplete not received after 100 frames, remove UE
-  ue_context_pP->ue_context.ue_release_timer=1;
-  // remove UE after 10 frames after LTE_RRCConnectionRelease is triggered
-  ue_context_pP->ue_context.ue_release_timer_thres=1000;
 }
-
-
+  
 #if defined(ENABLE_ITTI)
 //-----------------------------------------------------------------------------
-char
-openair_rrc_eNB_configuration(
-  const module_id_t enb_mod_idP,
-  RrcConfigurationReq *configuration
-)
+char openair_rrc_eNB_configuration(
+				   const module_id_t enb_mod_idP,
+				   RrcConfigurationReq *configuration
+				   )
 #else
-char
-openair_rrc_eNB_init(
-  const module_id_t enb_mod_idP
-)
+char openair_rrc_eNB_init(
+			  const module_id_t enb_mod_idP
+			  )
 #endif
 //-----------------------------------------------------------------------------
 {
diff --git a/openair2/RRC/LTE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c
index 56219d9ebd73182501bb9259692bd6d331bf3e31..ebacfc838119b779badc14625022513390247db5 100644
--- a/openair2/RRC/LTE/rrc_eNB_S1AP.c
+++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c
@@ -1784,6 +1784,7 @@ int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance
   uint32_t T;  /* DRX cycle */
 
   for (uint16_t tai_size = 0; tai_size < S1AP_PAGING_IND(msg_p).tai_size; tai_size++) {
+
     LOG_D(RRC,"[eNB %d] In S1AP_PAGING_IND: MCC %d, MNC %d, TAC %d\n", instance, S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mcc,
           S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mnc, S1AP_PAGING_IND(msg_p).tac[tai_size]);
 
@@ -1795,7 +1796,7 @@ int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance
           lte_frame_type_t frame_type = RC.eNB[instance][CC_id]->frame_parms.frame_type;
           /* get nB from configuration */
           /* get default DRX cycle from configuration */
-          Tc = (uint8_t)RC.rrc[instance]->configuration.pcch_defaultPagingCycle[CC_id];
+          Tc = (uint8_t)RC.rrc[instance]->configuration.radioresourceconfig[CC_id].pcch_defaultPagingCycle;
 
           if (Tc < LTE_PCCH_Config__defaultPagingCycle_rf32 || Tc > LTE_PCCH_Config__defaultPagingCycle_rf256) {
             continue;
@@ -1805,8 +1806,7 @@ int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance
           /* set T = min(Tc,Tue) */
           T = Tc < Tue ? Ttab[Tc] : Ttab[Tue];
           /* set pcch_nB = PCCH-Config->nB */
-          pcch_nB = (uint32_t)RC.rrc[instance]->configuration.pcch_nB[CC_id];
-
+	  pcch_nB = (uint32_t)RC.rrc[instance]->configuration.radioresourceconfig[CC_id].pcch_nB;
           switch (pcch_nB) {
             case LTE_PCCH_Config__nB_fourT:
               Ns = 4;
diff --git a/openair2/RRC/LTE/rrc_proto.h b/openair2/RRC/LTE/rrc_proto.h
index 0aeb67dfbaa7ff688fd05d34353f38937bfd1d40..3777f3ea26b5c3b71e338e7ab61c30856cbdf8e0 100644
--- a/openair2/RRC/LTE/rrc_proto.h
+++ b/openair2/RRC/LTE/rrc_proto.h
@@ -432,6 +432,9 @@ mac_rrc_data_ind(
   const uint8_t*        sduP,
   const sdu_size_t      sdu_lenP,
   const uint8_t         mbsfn_sync_areaP
+#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+  , const boolean_t		brOption
+#endif
 );
 
 int8_t
diff --git a/openair2/UTIL/OMG/README.TXT b/openair2/UTIL/OMG/README.TXT
old mode 100755
new mode 100644
diff --git a/openair2/X2AP/MESSAGES/ASN1/R10/x2ap-10.7.0.asn1 b/openair2/X2AP/MESSAGES/ASN1/R10/x2ap-10.7.0.asn1
old mode 100755
new mode 100644
diff --git a/openair2/X2AP/MESSAGES/ASN1/R11/x2ap-11.9.0.asn1 b/openair2/X2AP/MESSAGES/ASN1/R11/x2ap-11.9.0.asn1
old mode 100755
new mode 100644
diff --git a/openair2/X2AP/MESSAGES/ASN1/R12/x2ap-12.8.0.asn1 b/openair2/X2AP/MESSAGES/ASN1/R12/x2ap-12.8.0.asn1
old mode 100755
new mode 100644
diff --git a/openair2/X2AP/MESSAGES/ASN1/R13/x2ap-13.7.0.asn1 b/openair2/X2AP/MESSAGES/ASN1/R13/x2ap-13.7.0.asn1
old mode 100755
new mode 100644
diff --git a/openair2/X2AP/MESSAGES/ASN1/R14/x2ap-14.6.0.asn1 b/openair2/X2AP/MESSAGES/ASN1/R14/x2ap-14.6.0.asn1
old mode 100755
new mode 100644
diff --git a/openair2/X2AP/MESSAGES/ASN1/R15/x2ap-15.1.0.asn1 b/openair2/X2AP/MESSAGES/ASN1/R15/x2ap-15.1.0.asn1
old mode 100755
new mode 100644
diff --git a/openair2/X2AP/MESSAGES/ASN1/R15/x2ap-15.2.0.asn1 b/openair2/X2AP/MESSAGES/ASN1/R15/x2ap-15.2.0.asn1
old mode 100755
new mode 100644
diff --git a/openair2/X2AP/MESSAGES/ASN1/R8/x2ap-8.9.0.asn1 b/openair2/X2AP/MESSAGES/ASN1/R8/x2ap-8.9.0.asn1
old mode 100755
new mode 100644
diff --git a/openair2/X2AP/MESSAGES/ASN1/R9/x2ap-9.6.0.asn1 b/openair2/X2AP/MESSAGES/ASN1/R9/x2ap-9.6.0.asn1
old mode 100755
new mode 100644
diff --git a/openair3/S1AP/MESSAGES/ASN1/R10/s1ap-10.9.0.asn1 b/openair3/S1AP/MESSAGES/ASN1/R10/s1ap-10.9.0.asn1
old mode 100755
new mode 100644
diff --git a/openair3/S1AP/MESSAGES/ASN1/R11/s1ap-11.8.0.asn1 b/openair3/S1AP/MESSAGES/ASN1/R11/s1ap-11.8.0.asn1
old mode 100755
new mode 100644
diff --git a/openair3/S1AP/MESSAGES/ASN1/R12/s1ap-12.7.0.asn1 b/openair3/S1AP/MESSAGES/ASN1/R12/s1ap-12.7.0.asn1
old mode 100755
new mode 100644
diff --git a/openair3/S1AP/MESSAGES/ASN1/R13/s1ap-13.6.0.asn1 b/openair3/S1AP/MESSAGES/ASN1/R13/s1ap-13.6.0.asn1
old mode 100755
new mode 100644
diff --git a/openair3/S1AP/MESSAGES/ASN1/R14/s1ap-14.5.0.asn1 b/openair3/S1AP/MESSAGES/ASN1/R14/s1ap-14.5.0.asn1
old mode 100755
new mode 100644
diff --git a/openair3/S1AP/MESSAGES/ASN1/R14/s1ap-14.6.0.asn1 b/openair3/S1AP/MESSAGES/ASN1/R14/s1ap-14.6.0.asn1
old mode 100755
new mode 100644
diff --git a/openair3/S1AP/MESSAGES/ASN1/R15/s1ap-15.1.0.asn1 b/openair3/S1AP/MESSAGES/ASN1/R15/s1ap-15.1.0.asn1
old mode 100755
new mode 100644
diff --git a/openair3/S1AP/MESSAGES/ASN1/R15/s1ap-15.2.0.asn1 b/openair3/S1AP/MESSAGES/ASN1/R15/s1ap-15.2.0.asn1
old mode 100755
new mode 100644
diff --git a/openair3/S1AP/MESSAGES/ASN1/R8/s1ap-8.10.0.asn1 b/openair3/S1AP/MESSAGES/ASN1/R8/s1ap-8.10.0.asn1
old mode 100755
new mode 100644
diff --git a/openair3/S1AP/MESSAGES/ASN1/R9/s1ap-9.10.0.asn1 b/openair3/S1AP/MESSAGES/ASN1/R9/s1ap-9.10.0.asn1
old mode 100755
new mode 100644
diff --git a/openair3/TEST/EPC_TEST/TEST_1MME_1ENB_1UE_ATTACH_GUTI/enb1.conf b/openair3/TEST/EPC_TEST/TEST_1MME_1ENB_1UE_ATTACH_GUTI/enb1.conf
old mode 100755
new mode 100644
diff --git a/openair3/valgrind.sh b/openair3/valgrind.sh
old mode 100644
new mode 100755
diff --git a/svn2git/git-author-rewrite.sh b/svn2git/git-author-rewrite.sh
old mode 100644
new mode 100755
diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c
index 8cf14b4ca8753ddfcdb886e505fd6415a9ae936e..11ad12bfec69652438ba2ccbeafd07d03329b274 100644
--- a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c
+++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c
@@ -244,7 +244,6 @@ int trx_eth_write_udp_IF4p5(openair0_device *device, openair0_timestamp timestam
   }
    
   eth->tx_nsamps = nblocks;
-  //  printf("Sending %d bytes to %s:%d\n",packet_size,str,ntohs(eth->local_addrd.sin_port));
 
   bytes_sent = sendto(eth->sockfdd,
 		      buff[0], 
diff --git a/targets/ARCH/EXMIMO/DRIVER/eurecom/Makefile b/targets/ARCH/EXMIMO/DRIVER/eurecom/Makefile
old mode 100755
new mode 100644
diff --git a/targets/ARCH/EXMIMO/DRIVER/exmimo3/Makefile b/targets/ARCH/EXMIMO/DRIVER/exmimo3/Makefile
old mode 100755
new mode 100644
diff --git a/targets/ARCH/EXMIMO/USERSPACE/OCTAVE/OFDM_TX.m b/targets/ARCH/EXMIMO/USERSPACE/OCTAVE/OFDM_TX.m
old mode 100755
new mode 100644
diff --git a/targets/ARCH/EXMIMO/USERSPACE/OCTAVE/OFDM_TX_FRAME.m b/targets/ARCH/EXMIMO/USERSPACE/OCTAVE/OFDM_TX_FRAME.m
old mode 100755
new mode 100644
diff --git a/targets/ARCH/EXMIMO/USERSPACE/OCTAVE/QAM_MOD.m b/targets/ARCH/EXMIMO/USERSPACE/OCTAVE/QAM_MOD.m
old mode 100755
new mode 100644
diff --git a/targets/ARCH/EXMIMO/USERSPACE/OCTAVE/exmimo_test_tx_rx.m b/targets/ARCH/EXMIMO/USERSPACE/OCTAVE/exmimo_test_tx_rx.m
old mode 100755
new mode 100644
diff --git a/targets/ARCH/EXMIMO/USERSPACE/OCTAVE/rx_calibration_exmimo_freq.m b/targets/ARCH/EXMIMO/USERSPACE/OCTAVE/rx_calibration_exmimo_freq.m
old mode 100755
new mode 100644
diff --git a/targets/ARCH/EXMIMO/USERSPACE/OCTAVE/rx_spec.m b/targets/ARCH/EXMIMO/USERSPACE/OCTAVE/rx_spec.m
old mode 100755
new mode 100644
diff --git a/targets/ARCH/EXMIMO/USERSPACE/OCTAVE/rx_spec_multicard_sync.m b/targets/ARCH/EXMIMO/USERSPACE/OCTAVE/rx_spec_multicard_sync.m
old mode 100755
new mode 100644
diff --git a/targets/ARCH/LMSSDR/LimeSDR_above_1p8GHz.ini b/targets/ARCH/LMSSDR/LimeSDR_above_1p8GHz.ini
old mode 100755
new mode 100644
diff --git a/targets/ARCH/LMSSDR/LimeSDR_above_1p8GHz_1v4.ini b/targets/ARCH/LMSSDR/LimeSDR_above_1p8GHz_1v4.ini
old mode 100755
new mode 100644
diff --git a/targets/ARCH/LMSSDR/LimeSDR_below_1p8GHz.ini b/targets/ARCH/LMSSDR/LimeSDR_below_1p8GHz.ini
old mode 100755
new mode 100644
diff --git a/targets/ARCH/LMSSDR/LimeSDR_below_1p8GHz_1v4.ini b/targets/ARCH/LMSSDR/LimeSDR_below_1p8GHz_1v4.ini
old mode 100755
new mode 100644
diff --git a/targets/ARCH/USRP/USERSPACE/LIB/Makefile.inc b/targets/ARCH/USRP/USERSPACE/LIB/Makefile.inc
deleted file mode 100644
index 631f2162bdb545a125e689dfe7c90773ea91d8d8..0000000000000000000000000000000000000000
--- a/targets/ARCH/USRP/USERSPACE/LIB/Makefile.inc
+++ /dev/null
@@ -1,4 +0,0 @@
-USRP_OBJ += $(OPENAIR_TARGETS)/ARCH/USRP/USERSPACE/LIB/usrp_lib.o
-USRP_FILE_OBJ += $(OPENAIR_TARGETS)/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp
-USRP_CFLAGS += -I$(OPENAIR_TARGETS)/ARCH/COMMON -I$(OPENAIR_TARGETS)/ARCH/USRP/USERSPACE/LIB/ -I$(OPENAIR_TARGETS)/COMMON
-
diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp
index c591cc6c0f31f2f324e2b3f09ad899313b7ab46f..563e3755b78d712729a37bcd3787046400aadd72 100644
--- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp
+++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp
@@ -346,6 +346,7 @@ static void trx_usrp_end(openair0_device *device) {
 
   done = 1;
 
+
   if (u_sf_mode != 2) { // not subframes replay
 #endif
     usrp_state_t *s = (usrp_state_t *)device->priv;
@@ -435,6 +436,7 @@ static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp,
 #endif
     usrp_state_t *s = (usrp_state_t *)device->priv;
     int nsamps2;  // aligned to upper 32 or 16 byte boundary
+
 #if defined(__x86_64) || defined(__i386__)
 #ifdef __AVX2__
     nsamps2 = (nsamps+7)>>3;
diff --git a/targets/ARCH/tcp_bridge/tcp_bridge_oai.c b/targets/ARCH/tcp_bridge/tcp_bridge_oai.c
index b0f131de9178dacdf06f252325fd3da7e7b2e7d3..a7bb8c00bfaeb50ab737c150c3f78092b70752b8 100644
--- a/targets/ARCH/tcp_bridge/tcp_bridge_oai.c
+++ b/targets/ARCH/tcp_bridge/tcp_bridge_oai.c
@@ -354,6 +354,29 @@ int tcp_bridge_ue_first_read(openair0_device *device, openair0_timestamp *timest
     abort();
   }
 
+  /* Due to some unknown bug in the eNB (or UE, or both), the first frames
+   * are not correctly generated (or handled), which leads to a bad behavior
+   * of the simulator in some cases (seen with 100 RBs: the UE reads a bad
+   * MIB and switches to 25 RBs, which results in a deadlock in this driver).
+   * Let's skip 10 frames to avoid this issue.
+   */
+  for (int i = 0; i < 10 * 10; i++) {
+    memset(b, 0, t->samples_per_subframe * 4);
+    n = fullwrite(t->sock, b, t->samples_per_subframe * 4);
+
+    if (n != t->samples_per_subframe * 4) {
+      printf("tcp_bridge: write error ret %d error %s\n", n, strerror(errno));
+      abort();
+    }
+
+    n = fullread(t->sock, b, t->samples_per_subframe * 4);
+
+    if (n != t->samples_per_subframe * 4) {
+      printf("tcp_bridge: read error ret %d error %s\n", n, strerror(errno));
+      abort();
+    }
+  }
+
   device->trx_read_func = tcp_bridge_read_ue;
   return tcp_bridge_read_ue(device, timestamp, buff, nsamps, cc);
 }
diff --git a/targets/DOCS/E-UTRAN_User_Guide.docx b/targets/DOCS/E-UTRAN_User_Guide.docx
old mode 100755
new mode 100644
diff --git a/targets/DOCS/E-UTRAN_User_Guide.pdf b/targets/DOCS/E-UTRAN_User_Guide.pdf
old mode 100755
new mode 100644
diff --git a/targets/DOCS/oai_L1_L2_procedures.ipe b/targets/DOCS/oai_L1_L2_procedures.ipe
old mode 100755
new mode 100644
diff --git a/targets/PROJECTS/CENTOS-LTE-EPC-INTEGRATION/CONF/enb.centos.calisson.conf b/targets/PROJECTS/CENTOS-LTE-EPC-INTEGRATION/CONF/enb.centos.calisson.conf
old mode 100755
new mode 100644
diff --git a/targets/PROJECTS/CENTOS-LTE-EPC-INTEGRATION/CONF/enb.centos.memphis.conf b/targets/PROJECTS/CENTOS-LTE-EPC-INTEGRATION/CONF/enb.centos.memphis.conf
old mode 100755
new mode 100644
diff --git a/targets/PROJECTS/CENTOS-LTE-EPC-INTEGRATION/CONF/enb.centos.nord.conf b/targets/PROJECTS/CENTOS-LTE-EPC-INTEGRATION/CONF/enb.centos.nord.conf
old mode 100755
new mode 100644
diff --git a/targets/PROJECTS/E-MBMS/enb.conf b/targets/PROJECTS/E-MBMS/enb.conf
old mode 100755
new mode 100644
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band13.tm1.50PRB.emtc.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band13.tm1.50PRB.emtc.conf
new file mode 100644
index 0000000000000000000000000000000000000000..d33a9dc41fbc88cb8fb01675ef77ee9e888fe9d9
--- /dev/null
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band13.tm1.50PRB.emtc.conf
@@ -0,0 +1,445 @@
+Active_eNBs = ( "eNB_Eurecom_LTEBox");
+# Asn1_verbosity, choice in: none, info, annoying
+Asn1_verbosity = "none";
+
+eNBs =
+(
+ {
+    ////////// Identification parameters:
+    eNB_ID    =  0xe00;
+
+    cell_type =  "CELL_MACRO_ENB";
+
+    eNB_name  =  "eNB_Eurecom_LTEBox";
+
+    // Tracking area code, 0x0000 and 0xfffe are reserved values
+    tracking_area_code  =  "1";
+
+    plmn_list = ( { mcc = 208; mnc = 93; mnc_length = 2;} );
+
+    tr_s_preference     = "local_mac"
+
+    ////////// Physical parameters:
+
+    component_carriers = (
+    {
+      node_function                             = "3GPP_eNodeB";
+      node_timing                               = "synch_to_ext_device";
+      node_synch_ref                            = 0;
+      frame_type                                = "FDD";
+      tdd_config                                = 3;
+      tdd_config_s                              = 0;
+      prefix_type                               = "NORMAL";
+      eutra_band                                = 13;
+      downlink_frequency                        = 751000000L;
+      uplink_frequency_offset                   = 31000000;
+      Nid_cell                                  = 0;
+      N_RB_DL                                   = 50;
+      Nid_cell_mbsfn                            = 0;
+      nb_antenna_ports                          = 1;
+      nb_antennas_tx                            = 1;
+      nb_antennas_rx                            = 1;
+      tx_gain                                   = 90;
+      rx_gain                                   = 110;
+      pbch_repetition                           = "FALSE";
+      prach_root                                = 0;
+      prach_config_index                        = 0;
+      prach_high_speed                          = "DISABLE";
+      prach_zero_correlation                    = 1;
+      prach_freq_offset                         = 1;
+      pucch_delta_shift                         = 1;
+      pucch_nRB_CQI                             = 1;
+      pucch_nCS_AN                              = 0;    
+      pucch_n1_AN                               = 32;
+      pdsch_referenceSignalPower                = -27;
+      pdsch_p_b                                 = 0;
+      pusch_n_SB                                = 1;
+      pusch_enable64QAM                         = "DISABLE";
+      pusch_hoppingMode                         = "interSubFrame";
+      pusch_hoppingOffset                       = 0; 
+      pusch_groupHoppingEnabled                 = "ENABLE";
+      pusch_groupAssignment                     = 0;
+      pusch_sequenceHoppingEnabled              = "DISABLE";
+      pusch_nDMRS1                              = 1;
+      phich_duration                            = "NORMAL";
+      phich_resource                            = "ONESIXTH";
+      srs_enable                                = "DISABLE"; 
+      /*  srs_BandwidthConfig                   =; 
+      srs_SubframeConfig                        =;
+      srs_ackNackST                             =;
+      srs_MaxUpPts                              =;*/
+
+      pusch_p0_Nominal                          = -96;
+      pusch_alpha                               = "AL1";
+      pucch_p0_Nominal                          = -104;
+      msg3_delta_Preamble                       = 6;
+      pucch_deltaF_Format1                      = "deltaF2";             
+      pucch_deltaF_Format1b                     = "deltaF3";            
+      pucch_deltaF_Format2                      = "deltaF0";            
+      pucch_deltaF_Format2a                     = "deltaF0";            
+      pucch_deltaF_Format2b                     = "deltaF0";            
+
+      rach_numberOfRA_Preambles                 = "n64"; #64 
+      rach_preamblesGroupAConfig                = "DISABLE"; 
+      /*
+      rach_sizeOfRA_PreamblesGroupA             = ;
+      rach_messageSizeGroupA                    = ;
+      rach_messagePowerOffsetGroupB             = ;
+      */
+      rach_powerRampingStep                     = 4;
+      rach_preambleInitialReceivedTargetPower   = -108;
+      rach_preambleTransMax                     = 10;
+      rach_raResponseWindowSize                 = 10;
+      rach_macContentionResolutionTimer         = 48;
+      rach_maxHARQ_Msg3Tx                       = 4;
+
+      pcch_default_PagingCycle                  = "rf128"; #128
+      pcch_nB                                   = "oneT";
+      bcch_modificationPeriodCoeff              = 2;
+      ue_TimersAndConstants_t300                = "ms1000";
+      ue_TimersAndConstants_t301                = "ms1000";
+      ue_TimersAndConstants_t310                = "ms1000";
+      ue_TimersAndConstants_t311                = "ms10000";
+      ue_TimersAndConstants_n310                = "n20";
+      ue_TimersAndConstants_n311                = "n1";
+      ue_TransmissionMode                       = "tm1";
+
+      # eMTC Parameters
+      emtc_parameters : 
+      {
+          eMTC_configured                       = 1;
+          #hyperSFN_r13                               = 0;
+          #eDRX_Allowed_r13                           = 0;
+          #q_QualMinRSRQ_CE_r13                       = ;
+
+          #SIB1
+          schedulingInfoSIB1_BR_r13                   = 4;
+
+          #system_info_value_tag_SI = 
+          #(
+          #    {
+          #        systemInfoValueTagSi_r13 = 0;
+          #    }
+          #);
+
+          cellSelectionInfoCE_r13                     = "ENABLE";
+          q_RxLevMinCE_r13                            = -70;
+          bandwidthReducedAccessRelatedInfo_r13       = "ENABLE"   
+          si_WindowLength_BR_r13                      = "ms20";    #0
+          si_RepetitionPattern_r13                    = "everyRF"; #0
+
+          scheduling_info_br =
+          (
+              {
+                  si_Narrowband_r13 = 8;
+                  si_TBS_r13        = 5;
+              }
+         );
+
+          fdd_DownlinkOrTddSubframeBitmapBR_r13     = "subframePattern40-r13"; 
+          fdd_DownlinkOrTddSubframeBitmapBR_val_r13 = 0xFFFFFFFFFF;
+          startSymbolBR_r13                           = 2;
+          si_HoppingConfigCommon_r13                  = "off"; #1; # Note: 1==OFF !
+          si_ValidityTime_r13                         = "true"; #0
+
+          freqHoppingParametersDL_r13                 = "DISABLE"
+          mpdcch_pdsch_HoppingNB_r13                  = "nb2"; #0
+          interval_DLHoppingConfigCommonModeA_r13     = "interval-FDD-r13"
+          interval_DLHoppingConfigCommonModeA_r13_val = 0;
+          interval_DLHoppingConfigCommonModeB_r13     = "interval-FDD-r13"
+          interval_DLHoppingConfigCommonModeB_r13_val = 0;
+          mpdcch_pdsch_HoppingOffset_r13              = 1;
+
+
+          # SIB23
+          frame_type                                = "FDD";
+          preambleTransMax_CE_r13                   = 10; #6
+
+          rach_numberOfRA_Preambles                 = 60; #14
+          rach_powerRampingStep                     = 4;
+          rach_preambleInitialReceivedTargetPower   = -110;           
+          rach_preambleTransMax                     = 10;
+          rach_raResponseWindowSize                 = 10;
+          rach_macContentionResolutionTimer         = 64;
+          rach_maxHARQ_Msg3Tx                       = 4;
+
+          # max size for this array is 4
+          rach_CE_LevelInfoList_r13 = 
+          (
+              {
+                  firstPreamble_r13                 = 60;
+                  lastPreamble_r13                  = 63;
+                  ra_ResponseWindowSize_r13         = 20; #0
+                  mac_ContentionResolutionTimer_r13 = 80; #0
+                  rar_HoppingConfig_r13             = "off";  #1;
+              }
+          );
+
+          # BCCH CONFIG          
+          bcch_modificationPeriodCoeff              = 2;
+
+          #PCCH Config
+          pcch_default_PagingCycle                  = "rf128"; #128
+          pcch_nB                                   = "oneT";
+
+          #PRACH Config
+          prach_root                                = 89;
+          prach_config_index                        = 0;
+          prach_high_speed                          = "DISABLE";
+          prach_zero_correlation                    = 1;
+          prach_freq_offset                         = 1;
+
+          #PDSCH Config Common          
+          pdsch_referenceSignalPower                = -27
+          pdsch_p_b                                 = 0;
+
+
+          # PUSCH Config Common
+          pusch_n_SB                                = 1;
+          pusch_hoppingMode                         = "interSubFrame";
+          pusch_hoppingOffset                       = 0;
+          pusch_enable64QAM                         = "DISABLE";
+          pusch_groupHoppingEnabled                 = "ENABLE";
+          pusch_groupAssignment                     = 0;
+          pusch_sequenceHoppingEnabled              = "DISABLE";
+          pusch_nDMRS1                              = 1;
+
+          # PUCCH Config Common
+          pucch_delta_shift                         = 1;
+          pucch_nRB_CQI                             = 0;
+          pucch_nCS_AN                              = 0;
+          pucch_n1_AN                               = 32;
+
+          pusch_p0_Nominal                          = -96;
+          pusch_alpha                               = "AL1";
+          pucch_p0_Nominal                          = -104;
+          pucch_deltaF_Format1                      = "deltaF0"; 
+          pucch_deltaF_Format1b                     = "deltaF3";            
+          pucch_deltaF_Format2                      = "deltaF0";           
+          pucch_deltaF_Format2a                     = "deltaF0";            
+          pucch_deltaF_Format2b                     = "deltaF0";
+
+          msg3_delta_Preamble                       = 6;
+
+
+          prach_ConfigCommon_v1310                  = "ENABLE";
+ 
+          mpdcch_startSF_CSS_RA_r13                 = "fdd-r13";
+          mpdcch_startSF_CSS_RA_r13_val             = "v1"; #0
+          prach_HoppingOffset_r13                   = 0;
+
+         
+          pdsch_maxNumRepetitionCEmodeA_r13         = "r16"; #0
+          #pdsch_maxNumRepetitionCEmodeB_r13         = "r384"; # NULL - 2
+
+          pusch_maxNumRepetitionCEmodeA_r13         = "r8"; #0
+          #pusch_maxNumRepetitionCEmodeB_r13         = "r768"; #4 #NULL
+          #pusch_HoppingOffset_v1310                 = 5; #NULL
+
+          # max size for this array is 3
+          rsrp_range_list =
+          (
+              {
+                  rsrp_range_br = 0;
+              }
+          );
+
+          # max size for this array is 4
+          prach_parameters_ce_r13 = 
+          (
+              {
+                  prach_config_index_br                     = 3;
+                  prach_freq_offset_br                      = 2;
+                  prach_StartingSubframe_r13                = 2;
+                  maxNumPreambleAttemptCE_r13               = 10; #6
+                  numRepetitionPerPreambleAttempt_r13       = 1;  #0
+                  mpdcch_NumRepetition_RA_r13               = 1;  #0
+                  prach_HoppingConfig_r13                   = 0;  #1
+                  max_available_narrow_band                 = [3]; 
+             }
+          );
+
+          n1PUCCH_AN_InfoList_r13 = 
+          (
+              {
+                  pucch_info_value = 0;
+              }
+          );
+          
+
+          ue_TimersAndConstants_t300                = "ms1000";
+          ue_TimersAndConstants_t301                = "ms400";
+          ue_TimersAndConstants_t310                = "ms50";
+          ue_TimersAndConstants_t311                = "ms30000";
+          ue_TimersAndConstants_n310                = "n1";
+          ue_TimersAndConstants_n311                = "n10";
+          ue_TransmissionMode                       = "tm1";
+
+          pcch_config_v1310 :
+          {
+              paging_narrowbands_r13           = 1;
+              mpdcch_numrepetition_paging_r13  = "r1";         #0
+              #nb_v1310                        = "one256thT";  #2
+          }
+
+
+          pucch_NumRepetitionCE_Msg4_Level0_r13      = "n1";  #0 
+          #pucch_NumRepetitionCE_Msg4_Level1_r13     = "n2";  #1
+          #pucch_NumRepetitionCE_Msg4_Level2_r13     = "n16"; #2
+          #pucch_NumRepetitionCE_Msg4_Level3_r13     = "n32"; #3
+
+          sib2_freq_hoppingParameters_r13 : 
+          {
+             #sib2_mpdcch_pdsch_hoppingNB_r13                   = "nb2"; #0
+             #sib2_interval_DLHoppingConfigCommonModeA_r13      = "FDD"; # choice -> (0, FDD) (1, TDD)
+             #sib2_interval_DLHoppingConfigCommonModeA_r13_val  = "int1";          
+             #sib2_interval_DLHoppingConfigCommonModeB_r13      = "FDD"; # choice -> (0, FDD) (1, TDD)
+             #sib2_interval_DLHoppingConfigCommonModeB_r13_val  = "int2";        
+
+             sib2_interval_ULHoppingConfigCommonModeA_r13      = "FDD";  # choice -> (0, FDD) (1, TDD)
+             sib2_interval_ULHoppingConfigCommonModeA_r13_val  = "int4"; #2          
+#            sib2_interval_ULHoppingConfigCommonModeB_r13      = "FDD";  # choice -> (0, FDD) (1, TDD)
+#            sib2_interval_ULHoppingConfigCommonModeB_r13_val  = "int2"; #0
+
+#             sib2_mpdcch_pdsch_hoppingOffset_r13               = 1;
+          }
+
+          rach_preamblesGroupAConfig                = "DISABLE";
+          
+          phich_duration                            = "NORMAL";
+          phich_resource                            = "ONESIXTH";
+          srs_enable                                = "DISABLE";
+          
+      }
+
+
+
+}
+
+
+
+
+    );
+
+
+    srb1_parameters :
+    {
+        # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500]
+        timer_poll_retransmit    = 80;
+
+        # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200]
+        timer_reordering         = 35;
+
+        # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500]
+        timer_status_prohibit    = 0;
+
+        # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)]
+        poll_pdu                 =  4;
+
+        # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)]
+        poll_byte                =  99999;
+
+        # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32]
+        max_retx_threshold       =  4;
+    }
+
+    # ------- SCTP definitions
+    SCTP :
+    {
+        # Number of streams to use in input/output
+        SCTP_INSTREAMS  = 2;
+        SCTP_OUTSTREAMS = 2;
+    };
+
+
+    ////////// MME parameters:
+    mme_ip_address      = ( { ipv4       = "127.0.0.3";
+                              ipv6       = "192:168:30::17";
+                              active     = "yes";
+                              preference = "ipv4";
+                            }
+                          );
+
+    NETWORK_INTERFACES :
+    {
+
+        ENB_INTERFACE_NAME_FOR_S1_MME            = "lo";
+        ENB_IPV4_ADDRESS_FOR_S1_MME              = "127.0.0.2/24";
+        ENB_INTERFACE_NAME_FOR_S1U               = "lo";
+        ENB_IPV4_ADDRESS_FOR_S1U                 = "127.0.0.4/24";
+        ENB_PORT_FOR_S1U                         = 2152; # Spec 2152
+
+        ENB_IPV4_ADDRESS_FOR_X2C                 = "127.0.0.2/24";
+        ENB_PORT_FOR_X2C                         = 36422; # Spec 36422
+    };
+
+    log_config :
+    {
+      global_log_level                      ="info";
+      global_log_verbosity                  ="medium";
+      hw_log_level                          ="info";
+      hw_log_verbosity                      ="medium";
+      phy_log_level                         ="info";
+      phy_log_verbosity                     ="medium";
+      mac_log_level                         ="info";
+      mac_log_verbosity                     ="high";
+      rlc_log_level                         ="info";
+      rlc_log_verbosity                     ="medium";
+      pdcp_log_level                        ="info";
+      pdcp_log_verbosity                    ="medium";
+      rrc_log_level                         ="info";
+      rrc_log_verbosity                     ="medium";
+   };
+  }
+);
+
+MACRLCs = (
+        {	
+        num_cc	 = 1;
+        tr_s_preference = "local_L1";
+        tr_n_preference = "local_RRC";
+	phy_test_mode = 0;
+        puSch10xSnr     =  200;
+        puCch10xSnr     =  200;
+        }  
+);
+
+L1s = (
+      {
+      num_cc = 1;
+      tr_n_preference = "local_mac";
+      }  
+);
+
+RUs = (
+    {     
+        local_rf       = "yes"
+        nb_tx          = 1
+        nb_rx          = 1
+        att_tx         = 0
+        att_rx         = 0;
+        bands          = [13];
+        max_pdschReferenceSignalPower = -27;
+        max_rxgain                    = 125;
+        eNB_instances  = [0];
+    }
+);  
+
+log_config :
+     {
+       global_log_level                      ="info";
+       global_log_verbosity                  ="medium";
+       hw_log_level                          ="info";
+       hw_log_verbosity                      ="medium";
+       phy_log_level                         ="info";
+       phy_log_verbosity                     ="medium";
+       mac_log_level                         ="info";
+       mac_log_verbosity                     ="high";
+       rlc_log_level                         ="info";
+       rlc_log_verbosity                     ="medium";
+       pdcp_log_level                        ="info";
+       pdcp_log_verbosity                    ="medium";
+       rrc_log_level                         ="info";
+       rrc_log_verbosity                     ="medium";
+    };
+
diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c
index ddc7fdf94bc19e176ba66034ea51dcc8295a0fd1..0583c689e66c85ab1e48ce0fe9cb2c6184e46eac 100644
--- a/targets/RT/USER/lte-ru.c
+++ b/targets/RT/USER/lte-ru.c
@@ -1429,6 +1429,7 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) {
     cfg->tx_gain[i] = (double)ru->att_tx;
     cfg->rx_gain[i] = ru->max_rxgain-(double)ru->att_rx;
 
+
     cfg->configFilename = rf_config_file;
     printf("channel %d, Setting tx_gain offset %f, rx_gain offset %f, tx_freq %f, rx_freq %f\n",
 	   i, cfg->tx_gain[i],
@@ -2772,6 +2773,7 @@ void init_RU(char *rf_config_file) {
     // use eNB_list[0] as a reference for RU frame parameters
     // NOTE: multiple CC_id are not handled here yet!
 
+
     if (ru->num_eNB > 0) {
       LOG_D(PHY, "%s() RC.ru[%d].num_eNB:%d ru->eNB_list[0]:%p RC.eNB[0][0]:%p rf_config_file:%s\n", __FUNCTION__, ru_id, ru->num_eNB, ru->eNB_list[0], RC.eNB[0][0], ru->rf_config_file);
 
@@ -2783,6 +2785,7 @@ void init_RU(char *rf_config_file) {
       //
       // DJP - feptx_prec() / feptx_ofdm() parses the eNB_list (based on num_eNB) and copies the txdata_F to txdata in RU
       //
+
       }
       else
       {
diff --git a/targets/TEST/AT_COMMANDS/Makefile b/targets/TEST/AT_COMMANDS/Makefile
old mode 100755
new mode 100644
diff --git a/targets/TEST/PACKET_TRACER/Makefile b/targets/TEST/PACKET_TRACER/Makefile
old mode 100755
new mode 100644
diff --git a/targets/TEST/PDCP/Makefile b/targets/TEST/PDCP/Makefile
old mode 100755
new mode 100644
diff --git a/targets/TEST/PDCP/with_rlc/Makefile.data_bearer b/targets/TEST/PDCP/with_rlc/Makefile.data_bearer
old mode 100755
new mode 100644
diff --git a/targets/TEST/PDCP/with_rlc/readme_test_pdcp_rlc.txt b/targets/TEST/PDCP/with_rlc/readme_test_pdcp_rlc.txt
old mode 100755
new mode 100644
diff --git a/targets/TEST/RLC_AM_V9.3.0/Makefile b/targets/TEST/RLC_AM_V9.3.0/Makefile
old mode 100755
new mode 100644
diff --git a/targets/TEST/RLC_UM_V9.3.0/Makefile b/targets/TEST/RLC_UM_V9.3.0/Makefile
old mode 100755
new mode 100644